--- a/net/minecraft/server/EntityZombie.java +++ b/net/minecraft/server/EntityZombie.java @@ -8,6 +8,14 @@ import java.util.function.Predicate; import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; +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 EntityZombie extends EntityMonster { protected static final IAttribute d = (new AttributeRanged((IAttribute) null, "zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).a("Spawn Reinforcements Chance"); @@ -23,6 +31,7 @@ private boolean bE; private int bF; public int drownedConversionTime; + private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field public EntityZombie(EntityTypes entitytypes, World world) { super(entitytypes, world); @@ -144,7 +153,11 @@ public void tick() { if (!this.world.isClientSide && this.isAlive()) { if (this.isDrownConverting()) { - --this.drownedConversionTime; + // CraftBukkit start - Use wall time instead of ticks for conversion + int elapsedTicks = MinecraftServer.currentTick - this.lastTick; + this.lastTick = MinecraftServer.currentTick; + this.drownedConversionTime -= elapsedTicks; + // CraftBukkit end if (this.drownedConversionTime < 0) { this.ea(); } @@ -193,6 +206,7 @@ } public void startDrownedConversion(int i) { + this.lastTick = MinecraftServer.currentTick; // CraftBukkit this.drownedConversionTime = i; this.getDataWatcher().set(EntityZombie.DROWN_CONVERTING, true); } @@ -231,7 +245,12 @@ entityzombie.setCustomNameVisible(this.getCustomNameVisible()); } - this.world.addEntity(entityzombie); + // CraftBukkit start + if (CraftEventFactory.callEntityTransformEvent(this, entityzombie, EntityTransformEvent.TransformReason.DROWNED).isCancelled()) { + return; + } + // CraftBukkit end + this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.DROWNED); // CraftBukkit - added spawn reason this.die(); } } @@ -264,8 +283,8 @@ if (this.world.getType(blockposition).a((IBlockAccess) this.world, blockposition, (Entity) entityzombie) && this.world.getLightLevel(new BlockPosition(i1, j1, k1)) < 10) { entityzombie.setPosition((double) i1, (double) j1, (double) k1); if (!this.world.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D) && this.world.i((Entity) entityzombie) && this.world.getCubes(entityzombie) && !this.world.containsLiquid(entityzombie.getBoundingBox())) { - this.world.addEntity(entityzombie); - entityzombie.setGoalTarget(entityliving); + this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit + entityzombie.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true); // CraftBukkit entityzombie.prepare(this.world, this.world.getDamageScaler(new BlockPosition(entityzombie)), EnumMobSpawn.REINFORCEMENT, (GroupDataEntity) null, (NBTTagCompound) null); this.getAttributeInstance(EntityZombie.d).addModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION)); entityzombie.getAttributeInstance(EntityZombie.d).addModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION)); @@ -289,7 +308,14 @@ float f = this.world.getDamageScaler(new BlockPosition(this)).b(); if (this.getItemInMainHand().isEmpty() && this.isBurning() && this.random.nextFloat() < f * 0.3F) { - entity.setOnFire(2 * (int) f); + // CraftBukkit start + EntityCombustByEntityEvent event = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 2 * (int) f); // PAIL: fixme + this.world.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + entity.setOnFire(event.getDuration(), false); + } + // CraftBukkit end } } @@ -379,7 +405,7 @@ EntityZombieVillager entityzombievillager = (EntityZombieVillager) EntityTypes.ZOMBIE_VILLAGER.a(this.world); entityzombievillager.u(entityvillager); - entityvillager.die(); + // entityvillager.die(); // CraftBukkit - moved down entityzombievillager.prepare(this.world, this.world.getDamageScaler(new BlockPosition(entityzombievillager)), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false), (NBTTagCompound) null); entityzombievillager.setVillagerData(entityvillager.getVillagerData()); entityzombievillager.a((NBTBase) entityvillager.es().a((DynamicOps) DynamicOpsNBT.a).getValue()); @@ -392,7 +418,13 @@ entityzombievillager.setCustomNameVisible(entityvillager.getCustomNameVisible()); } - this.world.addEntity(entityzombievillager); + // CraftBukkit start + if (CraftEventFactory.callEntityTransformEvent(this, entityzombievillager, EntityTransformEvent.TransformReason.INFECTION).isCancelled()) { + return; + } + entityvillager.die(); // CraftBukkit - from above + this.world.addEntity(entityzombievillager, CreatureSpawnEvent.SpawnReason.INFECTION); // CraftBukkit - add SpawnReason + // CraftBukkit end this.world.a((EntityHuman) null, 1026, new BlockPosition(this), 0); } @@ -439,7 +471,7 @@ entitychicken1.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); entitychicken1.prepare(generatoraccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null, (NBTTagCompound) null); entitychicken1.r(true); - generatoraccess.addEntity(entitychicken1); + generatoraccess.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit this.startRiding(entitychicken1); } }