diff options
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/monster/Zombie.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/monster/Zombie.java.patch | 228 |
1 files changed, 228 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/monster/Zombie.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/monster/Zombie.java.patch new file mode 100644 index 0000000000..385c5f7f80 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/monster/Zombie.java.patch @@ -0,0 +1,228 @@ +--- a/net/minecraft/world/entity/monster/Zombie.java ++++ b/net/minecraft/world/entity/monster/Zombie.java +@@ -65,6 +54,25 @@ + import net.minecraft.world.level.block.Blocks; + import net.minecraft.world.level.block.state.BlockState; + import org.joml.Vector3f; ++import net.minecraft.core.BlockPos; ++import net.minecraft.nbt.CompoundTag; ++import net.minecraft.nbt.NbtOps; ++import net.minecraft.nbt.Tag; ++import net.minecraft.network.syncher.EntityDataAccessor; ++import net.minecraft.network.syncher.EntityDataSerializers; ++import net.minecraft.network.syncher.SynchedEntityData; ++// CraftBukkit start ++import net.minecraft.server.MinecraftServer; ++import net.minecraft.server.level.ServerLevel; ++import net.minecraft.sounds.SoundEvent; ++import net.minecraft.sounds.SoundEvents; ++import net.minecraft.sounds.SoundSource; ++import net.minecraft.tags.FluidTags; ++import org.bukkit.event.entity.CreatureSpawnEvent; ++import org.bukkit.event.entity.EntityCombustByEntityEvent; ++import org.bukkit.event.entity.EntityTargetEvent; ++import org.bukkit.event.entity.EntityTransformEvent; ++// CraftBukkit end + + public class Zombie extends Monster { + private static final UUID SPEED_MODIFIER_BABY_UUID = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836"); +@@ -84,7 +93,8 @@ + private final BreakDoorGoal breakDoorGoal = new BreakDoorGoal(this, DOOR_BREAKING_PREDICATE); + private boolean canBreakDoors; + private int inWaterTime; +- private int conversionTime; ++ public int conversionTime; ++ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field + + public Zombie(EntityType<? extends Zombie> entityType, Level level) { + super(entityType, level); +@@ -202,7 +211,10 @@ + public void tick() { + if (!this.level().isClientSide && this.isAlive() && !this.isNoAi()) { + if (this.isUnderWaterConverting()) { +- this.conversionTime--; ++ // CraftBukkit start - Use wall time instead of ticks for conversion ++ int elapsedTicks = MinecraftServer.currentTick - this.lastTick; ++ this.conversionTime -= elapsedTicks; ++ // CraftBukkit end + if (this.conversionTime < 0) { + this.doUnderWaterConversion(); + } +@@ -219,6 +231,7 @@ + } + + super.tick(); ++ this.lastTick = MinecraftServer.currentTick; // CraftBukkit + } + + @Override +@@ -248,7 +263,8 @@ + super.aiStep(); + } + +- private void startUnderWaterConversion(int conversionTime) { ++ public void startUnderWaterConversion(int conversionTime) { ++ this.lastTick = MinecraftServer.currentTick; // CraftBukkit + this.conversionTime = conversionTime; + this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, true); + } +@@ -261,10 +278,15 @@ + } + + protected void convertToZombieType(EntityType<? extends Zombie> entityType) { +- Zombie zombie = this.convertTo(entityType, true); +- if (zombie != null) { +- zombie.handleAttributes(zombie.level().getCurrentDifficultyAt(zombie.blockPosition()).getSpecialMultiplier()); +- zombie.setCanBreakDoors(zombie.supportsBreakDoorGoal() && this.canBreakDoors()); ++ Zombie entityzombie = (Zombie) this.convertTo(entityType, true, EntityTransformEvent.TransformReason.DROWNED, CreatureSpawnEvent.SpawnReason.DROWNED); ++ ++ if (entityzombie != null) { ++ entityzombie.handleAttributes(entityzombie.level().getCurrentDifficultyAt(entityzombie.blockPosition()).getSpecialMultiplier()); ++ entityzombie.setCanBreakDoors(entityzombie.supportsBreakDoorGoal() && this.canBreakDoors()); ++ // CraftBukkit start - SPIGOT-5208: End conversion to stop event spam ++ } else { ++ ((org.bukkit.entity.Zombie) getBukkitEntity()).setConversionTime(-1); ++ // CraftBukkit end + } + } + +@@ -294,29 +315,22 @@ + int floor2 = Mth.floor(this.getZ()); + Zombie zombie = new Zombie(this.level()); + +- for (int i = 0; i < 50; i++) { +- int i1 = floor + Mth.nextInt(this.random, 7, 40) * Mth.nextInt(this.random, -1, 1); +- int i2 = floor1 + Mth.nextInt(this.random, 7, 40) * Mth.nextInt(this.random, -1, 1); +- int i3 = floor2 + Mth.nextInt(this.random, 7, 40) * Mth.nextInt(this.random, -1, 1); +- BlockPos blockPos = new BlockPos(i1, i2, i3); +- EntityType<?> type = zombie.getType(); +- SpawnPlacements.Type placementType = SpawnPlacements.getPlacementType(type); +- if (NaturalSpawner.isSpawnPositionOk(placementType, this.level(), blockPos, type) +- && SpawnPlacements.checkSpawnRules(type, serverLevel, MobSpawnType.REINFORCEMENT, blockPos, this.level().random)) { +- zombie.setPos((double)i1, (double)i2, (double)i3); +- if (!this.level().hasNearbyAlivePlayer((double)i1, (double)i2, (double)i3, 7.0) +- && this.level().isUnobstructed(zombie) +- && this.level().noCollision(zombie) +- && !this.level().containsAnyLiquid(zombie.getBoundingBox())) { +- zombie.setTarget(target); +- zombie.finalizeSpawn( +- serverLevel, this.level().getCurrentDifficultyAt(zombie.blockPosition()), MobSpawnType.REINFORCEMENT, null, null +- ); +- serverLevel.addFreshEntityWithPassengers(zombie); +- this.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE) +- .addPermanentModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05F, AttributeModifier.Operation.ADDITION)); +- zombie.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE) +- .addPermanentModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05F, AttributeModifier.Operation.ADDITION)); ++ for (int l = 0; l < 50; ++l) { ++ int i1 = i + Mth.nextInt(this.random, 7, 40) * Mth.nextInt(this.random, -1, 1); ++ int j1 = j + Mth.nextInt(this.random, 7, 40) * Mth.nextInt(this.random, -1, 1); ++ int k1 = k + Mth.nextInt(this.random, 7, 40) * Mth.nextInt(this.random, -1, 1); ++ BlockPos blockposition = new BlockPos(i1, j1, k1); ++ EntityType<?> entitytypes = entityzombie.getType(); ++ SpawnPlacements.Surface entitypositiontypes_surface = SpawnPlacements.getPlacementType(entitytypes); ++ ++ if (NaturalSpawner.isSpawnPositionOk(entitypositiontypes_surface, this.level(), blockposition, entitytypes) && SpawnPlacements.checkSpawnRules(entitytypes, worldserver, EnumMobSpawn.REINFORCEMENT, blockposition, this.level().random)) { ++ entityzombie.setPos((double) i1, (double) j1, (double) k1); ++ if (!this.level().hasNearbyAlivePlayer((double) i1, (double) j1, (double) k1, 7.0D) && this.level().isUnobstructed(entityzombie) && this.level().noCollision((Entity) entityzombie) && !this.level().containsAnyLiquid(entityzombie.getBoundingBox())) { ++ entityzombie.setTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true); // CraftBukkit ++ entityzombie.finalizeSpawn(worldserver, this.level().getCurrentDifficultyAt(entityzombie.blockPosition()), EnumMobSpawn.REINFORCEMENT, (GroupDataEntity) null, (CompoundTag) null); ++ worldserver.addFreshEntityWithPassengers(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit ++ this.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE).addPermanentModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION)); ++ entityzombie.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE).addPermanentModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION)); + break; + } + } +@@ -331,9 +346,17 @@ + public boolean doHurtTarget(Entity entity) { + boolean flag = super.doHurtTarget(entity); + if (flag) { +- float effectiveDifficulty = this.level().getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); +- if (this.getMainHandItem().isEmpty() && this.isOnFire() && this.random.nextFloat() < effectiveDifficulty * 0.3F) { +- entity.setSecondsOnFire(2 * (int)effectiveDifficulty); ++ float f = this.level().getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); ++ ++ if (this.getMainHandItem().isEmpty() && this.isOnFire() && this.random.nextFloat() < f * 0.3F) { ++ // CraftBukkit start ++ EntityCombustByEntityEvent event = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 2 * (int) f); // PAIL: fixme ++ this.level().getCraftServer().getPluginManager().callEvent(event); ++ ++ if (!event.isCancelled()) { ++ entity.setSecondsOnFire(event.getDuration(), false); ++ } ++ // CraftBukkit end + } + } + +@@ -409,25 +438,36 @@ + if (level.getDifficulty() != Difficulty.HARD && this.random.nextBoolean()) { + return flag; + } ++ // CraftBukkit start ++ flag = zombifyVillager(level, entityvillager, this.blockPosition(), this.isSilent(), CreatureSpawnEvent.SpawnReason.INFECTION) == null; ++ } + +- ZombieVillager zombieVillager = villager.convertTo(EntityType.ZOMBIE_VILLAGER, false); +- if (zombieVillager != null) { +- zombieVillager.finalizeSpawn( +- level, level.getCurrentDifficultyAt(zombieVillager.blockPosition()), MobSpawnType.CONVERSION, new Zombie.ZombieGroupData(false, true), null +- ); +- zombieVillager.setVillagerData(villager.getVillagerData()); +- zombieVillager.setGossips(villager.getGossips().store(NbtOps.INSTANCE)); +- zombieVillager.setTradeOffers(villager.getOffers().createTag()); +- zombieVillager.setVillagerXp(villager.getVillagerXp()); +- if (!this.isSilent()) { +- level.levelEvent(null, 1026, this.blockPosition(), 0); ++ return flag; ++ } ++ ++ public static ZombieVillager zombifyVillager(ServerLevel worldserver, Villager entityvillager, net.minecraft.core.BlockPos blockPosition, boolean silent, CreatureSpawnEvent.SpawnReason spawnReason) { ++ { ++ ZombieVillager entityzombievillager = (ZombieVillager) entityvillager.convertTo(EntityType.ZOMBIE_VILLAGER, false, EntityTransformEvent.TransformReason.INFECTION, spawnReason); ++ // CraftBukkit end ++ ++ if (entityzombievillager != null) { ++ entityzombievillager.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityzombievillager.blockPosition()), EnumMobSpawn.CONVERSION, new Zombie.ZombieGroupData(false, true), (CompoundTag) null); ++ entityzombievillager.setVillagerData(entityvillager.getVillagerData()); ++ entityzombievillager.setGossips((Tag) entityvillager.getGossips().store(NbtOps.INSTANCE)); ++ entityzombievillager.setTradeOffers(entityvillager.getOffers().createTag()); ++ entityzombievillager.setVillagerXp(entityvillager.getVillagerXp()); ++ // CraftBukkit start ++ if (!silent) { ++ worldserver.levelEvent((Player) null, 1026, blockPosition, 0); + } + + flag = false; + } + } + +- return flag; ++ return entityzombievillager; ++ } ++ // CraftBukkit end + } + + @Override +@@ -471,14 +511,15 @@ + chicken.setChickenJockey(true); + this.startRiding(chicken); + } +- } else if ((double)random.nextFloat() < 0.05) { +- Chicken chicken1 = EntityType.CHICKEN.create(this.level()); +- if (chicken1 != null) { +- chicken1.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F); +- chicken1.finalizeSpawn(level, difficulty, MobSpawnType.JOCKEY, null, null); +- chicken1.setChickenJockey(true); +- this.startRiding(chicken1); +- level.addFreshEntity(chicken1); ++ } else if ((double) randomsource.nextFloat() < 0.05D) { ++ Chicken entitychicken1 = (Chicken) EntityType.CHICKEN.create(this.level()); ++ ++ if (entitychicken1 != null) { ++ entitychicken1.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F); ++ entitychicken1.finalizeSpawn(level, difficulty, EnumMobSpawn.JOCKEY, (GroupDataEntity) null, (CompoundTag) null); ++ entitychicken1.setChickenJockey(true); ++ this.startRiding(entitychicken1); ++ level.addFreshEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit + } + } + } |