|
19 | 19 |
|
20 | 20 | package net.minecraftforge.event.entity;
|
21 | 21 |
|
| 22 | +import net.minecraftforge.common.MinecraftForge; |
22 | 23 | import net.minecraftforge.eventbus.api.Event;
|
23 | 24 |
|
24 | 25 | import net.minecraft.entity.Entity;
|
25 | 26 | import net.minecraft.entity.EntityDimensions;
|
26 | 27 | import net.minecraft.entity.EntityPose;
|
27 | 28 |
|
28 | 29 | /**
|
29 |
| - * EntityEvent is fired when an event involving any Entity occurs. |
30 |
| - * |
31 |
| - * <p>If a method utilizes this {@link net.minecraftforge.eventbus.api.Event} as its parameter, the method will |
32 |
| - * receive every child event of this class.</p> |
33 |
| - * |
34 |
| - * <p>{@link #entity} contains the entity that caused this event to occur.</p> |
35 |
| - * |
36 |
| - * <p>All children of this event are fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}.</p> |
37 |
| - */ |
| 30 | + * EntityEvent is fired when an event involving any Entity occurs.<br> |
| 31 | + * If a method utilizes this {@link net.minecraftforge.eventbus.api.Event} as its parameter, the method will |
| 32 | + * receive every child event of this class.<br> |
| 33 | + * <br> |
| 34 | + * {@link #entity} contains the entity that caused this event to occur.<br> |
| 35 | + * <br> |
| 36 | + * All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.<br> |
| 37 | + **/ |
38 | 38 | public class EntityEvent extends Event {
|
39 | 39 | private final Entity entity;
|
40 | 40 |
|
41 |
| - public EntityEvent(Entity entity) { |
| 41 | + public EntityEvent(Entity entity) |
| 42 | + { |
42 | 43 | this.entity = entity;
|
43 | 44 | }
|
44 | 45 |
|
45 |
| - public Entity getEntity() { |
| 46 | + public Entity getEntity() |
| 47 | + { |
46 | 48 | return entity;
|
47 | 49 | }
|
48 | 50 |
|
49 | 51 | /**
|
50 |
| - * EntityConstructing is fired when an Entity is being created. |
51 |
| - * |
52 |
| - * <p>This event is fired within the constructor of the Entity.</p> |
53 |
| - * |
54 |
| - * <p>This event is not cancellable.</p> |
55 |
| - * |
56 |
| - * <p>This event does not have a result.</p> |
57 |
| - * |
58 |
| - * <p>This event is fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}.</p> |
59 |
| - */ |
| 52 | + * EntityConstructing is fired when an Entity is being created. <br> |
| 53 | + * This event is fired within the constructor of the Entity.<br> |
| 54 | + * <br> |
| 55 | + * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.<br> |
| 56 | + * <br> |
| 57 | + * This event does not have a result. {@link HasResult}<br> |
| 58 | + * <br> |
| 59 | + * This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br> |
| 60 | + **/ |
60 | 61 | public static class EntityConstructing extends EntityEvent {
|
61 |
| - public EntityConstructing(Entity entity) { |
| 62 | + public EntityConstructing(Entity entity) |
| 63 | + { |
62 | 64 | super(entity);
|
63 | 65 | }
|
64 | 66 | }
|
@@ -92,17 +94,16 @@ public void setCanUpdate(boolean canUpdate) {
|
92 | 94 | }*/
|
93 | 95 |
|
94 | 96 | /**
|
95 |
| - * EnteringChunk is fired when an Entity enters a chunk. |
96 |
| - * |
97 |
| - * <p>This event is fired whenever vanilla Minecraft determines that an entity |
98 |
| - * is entering a chunk in {@link net.minecraft.world.chunk.Chunk#addEntity(net.minecraft.entity.Entity)}</p> |
99 |
| - * |
100 |
| - * <p>This event is not cancellable.</p> |
101 |
| - * |
102 |
| - * <p>This event does not have a result.</p> |
103 |
| - * |
104 |
| - * <p>This event is fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}.</p> |
105 |
| - */ |
| 97 | + * EnteringChunk is fired when an Entity enters a chunk. <br> |
| 98 | + * This event is fired whenever vanilla Minecraft determines that an entity <br> |
| 99 | + * is entering a chunk in {@link Chunk#addEntity(net.minecraft.entity.Entity)} <br> |
| 100 | + * <br> |
| 101 | + * This event is not {@link Cancelable}.<br> |
| 102 | + * <br> |
| 103 | + * This event does not have a result. {@link HasResult} |
| 104 | + * <br> |
| 105 | + * This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br> |
| 106 | + **/ |
106 | 107 | public static class EnteringChunk extends EntityEvent {
|
107 | 108 | private int newChunkX;
|
108 | 109 | private int newChunkZ;
|
@@ -151,48 +152,60 @@ public void setOldChunkZ(int oldChunkZ) {
|
151 | 152 | }
|
152 | 153 |
|
153 | 154 | /**
|
154 |
| - * EyeHeight is fired when an Entity's eye height changes. |
155 |
| - * |
156 |
| - * <p>This event is fired whenever the {@link EntityPose} changes, and in a few other hardcoded scenarios.</p> |
157 |
| - * |
158 |
| - * <p>This event is not cancellable.</p> |
159 |
| - * |
160 |
| - * <p>This event does not have a result.</p> |
161 |
| - * |
162 |
| - * <p>This event is fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}.</p> |
163 |
| - */ |
164 |
| - public static class EyeHeight extends EntityEvent { |
| 155 | + * This event is fired whenever the {@link Pose} changes, and in a few other hardcoded scenarios.<br> |
| 156 | + * CAREFUL: This is also fired in the Entity constructor. Therefore the entity(subclass) might not be fully initialized. Check Entity#isAddedToWorld() or !Entity#firstUpdate.<br> |
| 157 | + * If you change the player's size, you probably want to set the eye height accordingly as well<br> |
| 158 | + * <br> |
| 159 | + * This event is not {@link Cancelable}.<br> |
| 160 | + * <br> |
| 161 | + * This event does not have a result. {@link HasResult} |
| 162 | + * <br> |
| 163 | + * This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br> |
| 164 | + **/ |
| 165 | + public static class Size extends EntityEvent { |
165 | 166 | private final EntityPose pose;
|
166 |
| - private final EntityDimensions size; |
167 |
| - private final float oldHeight; |
168 |
| - private float newHeight; |
| 167 | + private final EntityDimensions oldSize; |
| 168 | + private EntityDimensions newSize; |
| 169 | + private final float oldEyeHeight; |
| 170 | + private float newEyeHeight; |
169 | 171 |
|
170 |
| - public EyeHeight(Entity entity, EntityPose pose, EntityDimensions size, float defaultHeight) { |
| 172 | + public Size(Entity entity, EntityPose pose, EntityDimensions size, float defaultEyeHeight) |
| 173 | + { |
171 | 174 | super(entity);
|
172 | 175 | this.pose = pose;
|
173 |
| - this.size = size; |
174 |
| - this.oldHeight = defaultHeight; |
175 |
| - this.newHeight = defaultHeight; |
| 176 | + this.oldSize = size; |
| 177 | + this.newSize = size; |
| 178 | + this.oldEyeHeight = defaultEyeHeight; |
| 179 | + this.newEyeHeight = defaultEyeHeight; |
176 | 180 | }
|
177 | 181 |
|
| 182 | + |
178 | 183 | public EntityPose getPose() {
|
179 | 184 | return pose;
|
180 | 185 | }
|
181 | 186 |
|
182 |
| - public EntityDimensions getSize() { |
183 |
| - return size; |
| 187 | + public EntityDimensions getOldSize() { |
| 188 | + return oldSize; |
| 189 | + } |
| 190 | + |
| 191 | + public EntityDimensions getNewSize() { |
| 192 | + return newSize; |
| 193 | + } |
| 194 | + |
| 195 | + public void setNewSize(EntityDimensions size) { |
| 196 | + this.newSize = size; |
184 | 197 | }
|
185 | 198 |
|
186 |
| - public float getOldHeight() { |
187 |
| - return oldHeight; |
| 199 | + public float getOldEyeHeight() { |
| 200 | + return oldEyeHeight; |
188 | 201 | }
|
189 | 202 |
|
190 |
| - public float getNewHeight() { |
191 |
| - return newHeight; |
| 203 | + public float getNewEyeHeight() { |
| 204 | + return newEyeHeight; |
192 | 205 | }
|
193 | 206 |
|
194 |
| - public void setNewHeight(float newSize) { |
195 |
| - this.newHeight = newSize; |
| 207 | + public void setNewEyeHeight(float newHeight) { |
| 208 | + this.newEyeHeight = newHeight; |
196 | 209 | }
|
197 | 210 | }
|
198 | 211 | }
|
0 commit comments