--- a/net/minecraft/world/entity/monster/EntityZombieVillager.java +++ b/net/minecraft/world/entity/monster/EntityZombieVillager.java @@ -47,6 +47,13 @@ import net.minecraft.world.level.block.Blocks; import org.apache.logging.log4j.Logger; +// CraftBukkit start +import net.minecraft.server.MinecraftServer; +import org.bukkit.entity.ZombieVillager; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.EntityTransformEvent; +// CraftBukkit end + public class EntityZombieVillager extends EntityZombie implements VillagerDataHolder { public static final DataWatcherObject CONVERTING = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.i); @@ -56,6 +63,7 @@ private NBTBase bp; private NBTTagCompound bq; private int br; + private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field public EntityZombieVillager(EntityTypes entitytypes, World world) { super(entitytypes, world); @@ -72,7 +80,7 @@ @Override public void saveData(NBTTagCompound nbttagcompound) { super.saveData(nbttagcompound); - DataResult dataresult = VillagerData.a.encodeStart(DynamicOpsNBT.a, this.getVillagerData()); + DataResult dataresult = VillagerData.a.encodeStart(DynamicOpsNBT.a, this.getVillagerData()); // CraftBukkit - decompile error Logger logger = EntityZombieVillager.LOGGER; logger.getClass(); @@ -128,6 +136,10 @@ public void tick() { if (!this.world.isClientSide && this.isAlive() && this.isConverting()) { int i = this.getConversionProgress(); + // CraftBukkit start - Use wall time instead of ticks for villager conversion + int elapsedTicks = MinecraftServer.currentTick - this.lastTick; + i *= elapsedTicks; + // CraftBukkit end this.conversionTime -= i; if (this.conversionTime <= 0) { @@ -136,6 +148,7 @@ } super.tick(); + this.lastTick = MinecraftServer.currentTick; // CraftBukkit } @Override @@ -179,13 +192,22 @@ this.conversionPlayer = uuid; this.conversionTime = i; this.getDataWatcher().set(EntityZombieVillager.CONVERTING, true); - this.removeEffect(MobEffects.WEAKNESS); - this.addEffect(new MobEffect(MobEffects.INCREASE_DAMAGE, i, Math.min(this.world.getDifficulty().a() - 1, 0))); + // CraftBukkit start + this.persistent = true; // CraftBukkit - SPIGOT-4684 update persistence + this.removeEffect(MobEffects.WEAKNESS, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); + this.addEffect(new MobEffect(MobEffects.INCREASE_DAMAGE, i, Math.min(this.world.getDifficulty().a() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); + // CraftBukkit end this.world.broadcastEntityEffect(this, (byte) 16); } private void c(WorldServer worldserver) { - EntityVillager entityvillager = (EntityVillager) this.a(EntityTypes.VILLAGER, false); + // CraftBukkit start + EntityVillager entityvillager = (EntityVillager) this.a(EntityTypes.VILLAGER, false, EntityTransformEvent.TransformReason.CURED, CreatureSpawnEvent.SpawnReason.CURED); + if (entityvillager == null) { + ((ZombieVillager) getBukkitEntity()).setConversionTime(-1); // SPIGOT-5208: End conversion to stop event spam + return; + } + // CraftBukkit end EnumItemSlot[] aenumitemslot = EnumItemSlot.values(); int i = aenumitemslot.length; @@ -200,7 +222,9 @@ double d0 = (double) this.e(enumitemslot); if (d0 > 1.0D) { + this.forceDrops = true; // CraftBukkit this.a(itemstack); + this.forceDrops = false; // CraftBukkit } } } @@ -226,7 +250,7 @@ } } - entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0)); + entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); // CraftBukkit if (!this.isSilent()) { worldserver.a((EntityHuman) null, 1027, this.getChunkCoordinates(), 0); }