diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/AgeableMob.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/entity/AgeableMob.java.patch | 213 |
1 files changed, 213 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/AgeableMob.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/AgeableMob.java.patch new file mode 100644 index 0000000000..2251d746cd --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/AgeableMob.java.patch @@ -0,0 +1,213 @@ +--- a/net/minecraft/world/entity/AgeableMob.java ++++ b/net/minecraft/world/entity/AgeableMob.java +@@ -13,34 +13,33 @@ + import net.minecraft.world.level.ServerLevelAccessor; + + public abstract class AgeableMob extends PathfinderMob { ++ + private static final EntityDataAccessor<Boolean> DATA_BABY_ID = SynchedEntityData.defineId(AgeableMob.class, EntityDataSerializers.BOOLEAN); + public static final int BABY_START_AGE = -24000; + private static final int FORCED_AGE_PARTICLE_TICKS = 40; + protected int age; + protected int forcedAge; + protected int forcedAgeTimer; ++ public boolean ageLocked; // CraftBukkit + + protected AgeableMob(EntityType<? extends AgeableMob> entityType, Level level) { + super(entityType, level); + } + + @Override +- public SpawnGroupData finalizeSpawn( +- ServerLevelAccessor level, DifficultyInstance difficulty, MobSpawnType reason, @Nullable SpawnGroupData spawnData, @Nullable CompoundTag dataTag +- ) { ++ public GroupDataEntity finalizeSpawn(ServerLevelAccessor level, DifficultyInstance difficulty, EnumMobSpawn reason, @Nullable GroupDataEntity spawnData, @Nullable CompoundTag dataTag) { + if (spawnData == null) { + spawnData = new AgeableMob.AgeableMobGroupData(true); + } + +- AgeableMob.AgeableMobGroupData ageableMobGroupData = (AgeableMob.AgeableMobGroupData)spawnData; +- if (ageableMobGroupData.isShouldSpawnBaby() +- && ageableMobGroupData.getGroupSize() > 0 +- && level.getRandom().nextFloat() <= ageableMobGroupData.getBabySpawnChance()) { ++ AgeableMob.AgeableMobGroupData entityageable_a = (AgeableMob.AgeableMobGroupData) spawnData; ++ ++ if (entityageable_a.isShouldSpawnBaby() && entityageable_a.getGroupSize() > 0 && level.getRandom().nextFloat() <= entityageable_a.getBabySpawnChance()) { + this.setAge(-24000); + } + +- ageableMobGroupData.increaseGroupSizeByOne(); +- return super.finalizeSpawn(level, difficulty, reason, spawnData, dataTag); ++ entityageable_a.increaseGroupSizeByOne(); ++ return super.finalizeSpawn(level, difficulty, reason, (GroupDataEntity) spawnData, dataTag); + } + + @Nullable +@@ -49,7 +48,7 @@ + @Override + protected void defineSynchedData() { + super.defineSynchedData(); +- this.entityData.define(DATA_BABY_ID, false); ++ this.entityData.define(AgeableMob.DATA_BABY_ID, false); + } + + public boolean canBreed() { +@@ -57,24 +56,23 @@ + } + + public int getAge() { +- if (this.level().isClientSide) { +- return this.entityData.get(DATA_BABY_ID) ? -1 : 1; +- } else { +- return this.age; +- } ++ return this.level().isClientSide ? ((Boolean) this.entityData.get(AgeableMob.DATA_BABY_ID) ? -1 : 1) : this.age; + } + + public void ageUp(int amount, boolean forced) { +- int age = this.getAge(); +- int var6 = age + amount * 20; +- if (var6 > 0) { +- var6 = 0; ++ int j = this.getAge(); ++ int k = j; ++ ++ j += amount * 20; ++ if (j > 0) { ++ j = 0; + } + +- int i1 = var6 - age; +- this.setAge(var6); ++ int l = j - k; ++ ++ this.setAge(j); + if (forced) { +- this.forcedAge += i1; ++ this.forcedAge += l; + if (this.forcedAgeTimer == 0) { + this.forcedAgeTimer = 40; + } +@@ -83,6 +81,7 @@ + if (this.getAge() == 0) { + this.setAge(this.forcedAge); + } ++ + } + + public void ageUp(int amount) { +@@ -90,12 +89,14 @@ + } + + public void setAge(int age) { +- int age1 = this.getAge(); ++ int j = this.getAge(); ++ + this.age = age; +- if (age1 < 0 && age >= 0 || age1 >= 0 && age < 0) { +- this.entityData.set(DATA_BABY_ID, age < 0); ++ if (j < 0 && age >= 0 || j >= 0 && age < 0) { ++ this.entityData.set(AgeableMob.DATA_BABY_ID, age < 0); + this.ageBoundaryReached(); + } ++ + } + + @Override +@@ -103,6 +104,7 @@ + super.addAdditionalSaveData(compound); + compound.putInt("Age", this.getAge()); + compound.putInt("ForcedAge", this.forcedAge); ++ compound.putBoolean("AgeLocked", this.ageLocked); // CraftBukkit + } + + @Override +@@ -110,11 +112,12 @@ + super.readAdditionalSaveData(compound); + this.setAge(compound.getInt("Age")); + this.forcedAge = compound.getInt("ForcedAge"); ++ this.ageLocked = compound.getBoolean("AgeLocked"); // CraftBukkit + } + + @Override + public void onSyncedDataUpdated(EntityDataAccessor<?> key) { +- if (DATA_BABY_ID.equals(key)) { ++ if (AgeableMob.DATA_BABY_ID.equals(key)) { + this.refreshDimensions(); + } + +@@ -124,28 +127,41 @@ + @Override + public void aiStep() { + super.aiStep(); +- if (this.level().isClientSide) { ++ if (this.level().isClientSide || ageLocked) { // CraftBukkit + if (this.forcedAgeTimer > 0) { + if (this.forcedAgeTimer % 4 == 0) { +- this.level().addParticle(ParticleTypes.HAPPY_VILLAGER, this.getRandomX(1.0), this.getRandomY() + 0.5, this.getRandomZ(1.0), 0.0, 0.0, 0.0); ++ this.level().addParticle(ParticleTypes.HAPPY_VILLAGER, this.getRandomX(1.0D), this.getRandomY() + 0.5D, this.getRandomZ(1.0D), 0.0D, 0.0D, 0.0D); + } + +- this.forcedAgeTimer--; ++ --this.forcedAgeTimer; + } + } else if (this.isAlive()) { +- int age = this.getAge(); +- if (age < 0) { +- this.setAge(++age); +- } else if (age > 0) { +- this.setAge(--age); ++ int i = this.getAge(); ++ ++ if (i < 0) { ++ ++i; ++ this.setAge(i); ++ } else if (i > 0) { ++ --i; ++ this.setAge(i); + } + } ++ + } + + protected void ageBoundaryReached() { +- if (!this.isBaby() && this.isPassenger() && this.getVehicle() instanceof Boat boat && !boat.hasEnoughSpaceFor(this)) { +- this.stopRiding(); ++ if (!this.isBaby() && this.isPassenger()) { ++ Entity entity = this.getVehicle(); ++ ++ if (entity instanceof Boat) { ++ Boat entityboat = (Boat) entity; ++ ++ if (!entityboat.hasEnoughSpaceFor(this)) { ++ this.stopRiding(); ++ } ++ } + } ++ + } + + @Override +@@ -159,10 +175,11 @@ + } + + public static int getSpeedUpSecondsWhenFeeding(int ticksUntilAdult) { +- return (int)((float)(ticksUntilAdult / 20) * 0.1F); ++ return (int) ((float) (ticksUntilAdult / 20) * 0.1F); + } + +- public static class AgeableMobGroupData implements SpawnGroupData { ++ public static class AgeableMobGroupData implements GroupDataEntity { ++ + private int groupSize; + private final boolean shouldSpawnBaby; + private final float babySpawnChance; +@@ -185,7 +202,7 @@ + } + + public void increaseGroupSizeByOne() { +- this.groupSize++; ++ ++this.groupSize; + } + + public boolean isShouldSpawnBaby() { |