mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 11:29:15 +00:00
Replace EntityHeight event with EntitySize event (#6858)
This commit is contained in:
1 parent
e3db429763
commit
fc000fe913
4 files changed
+125
-81
No files matched your search
@@ -35,6 +35,8 @@ import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.Commands;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.Pose;
|
||||
import net.minecraft.entity.EntitySize;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
@@ -743,4 +745,11 @@ public class ForgeEventFactory
|
||||
RegisterCommandsEvent event = new RegisterCommandsEvent(dispatcher, environment);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static net.minecraftforge.event.entity.EntityEvent.Size getEntitySizeForge(Entity player, Pose pose, EntitySize size, float eyeHeight)
|
||||
{
|
||||
EntityEvent.Size evt = new EntityEvent.Size(player, pose, size, eyeHeight);
|
||||
MinecraftForge.EVENT_BUS.post(evt);
|
||||
return evt;
|
||||
}
|
||||
}
|
||||
@@ -137,10 +137,11 @@ public class EntityEvent extends Event
|
||||
public int getOldChunkZ() { return oldChunkZ; }
|
||||
public void setOldChunkZ(int oldChunkZ) { this.oldChunkZ = oldChunkZ; }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* EyeHeight is fired when an Entity's eye height changes. <br>
|
||||
* This event is fired whenever the {@link Pose} changes, and in a few other hardcoded scenarios.<br>
|
||||
* 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>
|
||||
* If you change the player's size, you probably want to set the eye height accordingly as well<br>
|
||||
* <br>
|
||||
* This event is not {@link Cancelable}.<br>
|
||||
* <br>
|
||||
@@ -148,26 +149,31 @@ public class EntityEvent extends Event
|
||||
* <br>
|
||||
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
|
||||
**/
|
||||
public static class EyeHeight extends EntityEvent
|
||||
public static class Size extends EntityEvent
|
||||
{
|
||||
private final Pose pose;
|
||||
private final EntitySize size;
|
||||
private final float oldHeight;
|
||||
private float newHeight;
|
||||
|
||||
public EyeHeight(Entity entity, Pose pose, EntitySize size, float defaultHeight)
|
||||
private final EntitySize oldSize;
|
||||
private EntitySize newSize;
|
||||
private final float oldEyeHeight;
|
||||
private float newEyeHeight;
|
||||
|
||||
public Size(Entity entity, Pose pose, EntitySize size, float defaultEyeHeight)
|
||||
{
|
||||
super(entity);
|
||||
this.pose = pose;
|
||||
this.size = size;
|
||||
this.oldHeight = defaultHeight;
|
||||
this.newHeight = defaultHeight;
|
||||
this.oldSize = size;
|
||||
this.newSize = size;
|
||||
this.oldEyeHeight = defaultEyeHeight;
|
||||
this.newEyeHeight = defaultEyeHeight;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Pose getPose() { return pose; }
|
||||
public EntitySize getSize() { return size; }
|
||||
public float getOldHeight() { return oldHeight; }
|
||||
public float getNewHeight() { return newHeight; }
|
||||
public void setNewHeight(float newSize) { this.newHeight = newSize; }
|
||||
public EntitySize getOldSize() { return oldSize; }
|
||||
public EntitySize getNewSize() { return newSize; }
|
||||
public void setNewSize(EntitySize size) { this.newSize = size; }
|
||||
public float getOldEyeHeight() { return oldEyeHeight; }
|
||||
public float getNewEyeHeight() { return newEyeHeight; }
|
||||
public void setNewEyeHeight(float newHeight) { this.newEyeHeight = newHeight; }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user