Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit bf471f7

Browse files
committed
Entity Events, kind of
1 parent 4dcc0c6 commit bf471f7

File tree

79 files changed

+889
-2535
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+889
-2535
lines changed

patchwork-events-entity/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ dependencies {
55
implementation project(path: ':patchwork-api-base', configuration: 'dev')
66
implementation project(path: ':patchwork-extensions', configuration: 'dev')
77
implementation project(path: ':patchwork-extensions-item', configuration: 'dev')
8+
implementation project(path: ':patchwork-capabilities', configuration: 'dev')
89
}

patchwork-events-entity/src/main/java/net/minecraftforge/event/entity/EntityEvent.java

Lines changed: 72 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -19,46 +19,48 @@
1919

2020
package net.minecraftforge.event.entity;
2121

22+
import net.minecraftforge.common.MinecraftForge;
2223
import net.minecraftforge.eventbus.api.Event;
2324

2425
import net.minecraft.entity.Entity;
2526
import net.minecraft.entity.EntityDimensions;
2627
import net.minecraft.entity.EntityPose;
2728

2829
/**
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+
**/
3838
public class EntityEvent extends Event {
3939
private final Entity entity;
4040

41-
public EntityEvent(Entity entity) {
41+
public EntityEvent(Entity entity)
42+
{
4243
this.entity = entity;
4344
}
4445

45-
public Entity getEntity() {
46+
public Entity getEntity()
47+
{
4648
return entity;
4749
}
4850

4951
/**
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+
**/
6061
public static class EntityConstructing extends EntityEvent {
61-
public EntityConstructing(Entity entity) {
62+
public EntityConstructing(Entity entity)
63+
{
6264
super(entity);
6365
}
6466
}
@@ -92,17 +94,16 @@ public void setCanUpdate(boolean canUpdate) {
9294
}*/
9395

9496
/**
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+
**/
106107
public static class EnteringChunk extends EntityEvent {
107108
private int newChunkX;
108109
private int newChunkZ;
@@ -151,48 +152,60 @@ public void setOldChunkZ(int oldChunkZ) {
151152
}
152153

153154
/**
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 {
165166
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;
169171

170-
public EyeHeight(Entity entity, EntityPose pose, EntityDimensions size, float defaultHeight) {
172+
public Size(Entity entity, EntityPose pose, EntityDimensions size, float defaultEyeHeight)
173+
{
171174
super(entity);
172175
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;
176180
}
177181

182+
178183
public EntityPose getPose() {
179184
return pose;
180185
}
181186

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;
184197
}
185198

186-
public float getOldHeight() {
187-
return oldHeight;
199+
public float getOldEyeHeight() {
200+
return oldEyeHeight;
188201
}
189202

190-
public float getNewHeight() {
191-
return newHeight;
203+
public float getNewEyeHeight() {
204+
return newEyeHeight;
192205
}
193206

194-
public void setNewHeight(float newSize) {
195-
this.newHeight = newSize;
207+
public void setNewEyeHeight(float newHeight) {
208+
this.newEyeHeight = newHeight;
196209
}
197210
}
198211
}

patchwork-events-entity/src/main/java/net/minecraftforge/event/entity/EntityJoinWorldEvent.java

Lines changed: 0 additions & 63 deletions
This file was deleted.

patchwork-events-entity/src/main/java/net/minecraftforge/event/entity/EntityTravelToDimensionEvent.java

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)