--- a/net/minecraft/world/entity/monster/EntityZombieVillager.java +++ b/net/minecraft/world/entity/monster/EntityZombieVillager.java @@ -49,6 +49,13 @@ import net.minecraft.world.level.gameevent.GameEvent; 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 DATA_CONVERTING_ID = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.BOOLEAN); @@ -62,6 +69,7 @@ private NBTBase gossips; private NBTTagCompound tradeOffers; private int villagerXp; + private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field public EntityZombieVillager(EntityTypes entitytypes, World world) { super(entitytypes, world); @@ -78,7 +86,7 @@ @Override public void saveData(NBTTagCompound nbttagcompound) { super.saveData(nbttagcompound); - DataResult dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData()); + DataResult dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData()); // CraftBukkit - decompile error Logger logger = EntityZombieVillager.LOGGER; Objects.requireNonNull(logger); @@ -134,6 +142,10 @@ public void tick() { if (!this.level.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.villagerConversionTime -= i; if (this.villagerConversionTime <= 0) { @@ -142,6 +154,7 @@ } super.tick(); + this.lastTick = MinecraftServer.currentTick; // CraftBukkit } @Override @@ -186,8 +199,11 @@ this.conversionStarter = uuid; this.villagerConversionTime = i; this.getDataWatcher().set(EntityZombieVillager.DATA_CONVERTING_ID, true); - this.removeEffect(MobEffects.WEAKNESS); - this.addEffect(new MobEffect(MobEffects.DAMAGE_BOOST, i, Math.min(this.level.getDifficulty().a() - 1, 0))); + // CraftBukkit start + this.setPersistenceRequired(true); // CraftBukkit - SPIGOT-4684 update persistence + this.removeEffect(MobEffects.WEAKNESS, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); + this.addEffect(new MobEffect(MobEffects.DAMAGE_BOOST, i, Math.min(this.level.getDifficulty().a() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); + // CraftBukkit end this.level.broadcastEntityEffect(this, (byte) 16); } @@ -204,7 +220,13 @@ } 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; @@ -219,7 +241,9 @@ double d0 = (double) this.e(enumitemslot); if (d0 > 1.0D) { + this.forceDrops = true; // CraftBukkit this.b(itemstack); + this.forceDrops = false; // CraftBukkit } } } @@ -245,7 +269,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); }