Files
CatServer/patches/net/minecraft/entity/EntityAgeable.java.patch
2019-02-24 22:29:41 +08:00

89 lines
3.0 KiB
Diff

--- ../src-base/minecraft/net/minecraft/entity/EntityAgeable.java
+++ ../src-work/minecraft/net/minecraft/entity/EntityAgeable.java
@@ -22,6 +22,33 @@
private float ageWidth = -1.0F;
private float ageHeight;
+ public boolean ageLocked;
+
+ // Spigot start
+ @Override
+ public void inactiveTick()
+ {
+ super.inactiveTick();
+ if ( this.world.isRemote || this.ageLocked )
+ { // CraftBukkit
+ this.setScaleForAge( this.isChild() );
+ } else
+ {
+ int i = this.getGrowingAge();
+
+ if ( i < 0 )
+ {
+ ++i;
+ this.setGrowingAge( i );
+ } else if ( i > 0 )
+ {
+ --i;
+ this.setGrowingAge( i );
+ }
+ }
+ }
+ // Spigot end
+
public EntityAgeable(World worldIn)
{
super(worldIn);
@@ -38,7 +65,7 @@
{
if (!this.world.isRemote)
{
- Class <? extends Entity > oclass = (Class)EntityList.REGISTRY.getObject(ItemMonsterPlacer.getNamedIdFrom(itemstack));
+ Class <? extends Entity > oclass = EntityList.getClass(ItemMonsterPlacer.getNamedIdFrom(itemstack));
if (oclass != null && this.getClass() == oclass)
{
@@ -48,7 +75,7 @@
{
entityageable.setGrowingAge(-24000);
entityageable.setLocationAndAngles(this.posX, this.posY, this.posZ, 0.0F, 0.0F);
- this.world.spawnEntity(entityageable);
+ this.world.addEntity(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG);
if (itemstack.hasDisplayName())
{
@@ -79,7 +106,7 @@
}
else
{
- Class <? extends Entity > oclass = (Class)EntityList.REGISTRY.getObject(ItemMonsterPlacer.getNamedIdFrom(stack));
+ Class <? extends Entity > oclass = EntityList.getClass(ItemMonsterPlacer.getNamedIdFrom(stack));
return oclass != null && entityClass == oclass;
}
}
@@ -154,6 +181,7 @@
super.writeEntityToNBT(compound);
compound.setInteger("Age", this.getGrowingAge());
compound.setInteger("ForcedAge", this.forcedAge);
+ compound.setBoolean("AgeLocked", this.ageLocked);
}
public void readEntityFromNBT(NBTTagCompound compound)
@@ -161,6 +189,7 @@
super.readEntityFromNBT(compound);
this.setGrowingAge(compound.getInteger("Age"));
this.forcedAge = compound.getInteger("ForcedAge");
+ this.ageLocked = compound.getBoolean("AgeLocked");
}
public void notifyDataManagerChange(DataParameter<?> key)
@@ -177,7 +206,7 @@
{
super.onLivingUpdate();
- if (this.world.isRemote)
+ if (this.world.isRemote || ageLocked)
{
if (this.forcedAgeTimer > 0)
{