diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch index 009db0ab8a..34c2cdc20d 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch @@ -97,21 +97,39 @@ } } -@@ -411,7 +437,12 @@ +@@ -411,18 +437,28 @@ } EntityVillager entityvillager = (EntityVillager) entityliving; - EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false); + // CraftBukkit start -+ EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false, EntityTransformEvent.TransformReason.INFECTION, CreatureSpawnEvent.SpawnReason.INFECTION); -+ if (entityzombievillager == null) { -+ return; -+ } -+ // CraftBukkit end ++ zombifyVillager(worldserver, entityvillager, this.blockPosition(), this.isSilent(), false); ++ } ++ } ++ public static EntityZombieVillager zombifyVillager(WorldServer worldserver, EntityVillager entityvillager, net.minecraft.core.BlockPosition blockPosition, boolean silent, boolean custom) { ++ EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false, EntityTransformEvent.TransformReason.INFECTION, (custom) ? CreatureSpawnEvent.SpawnReason.CUSTOM : CreatureSpawnEvent.SpawnReason.INFECTION); ++ if (entityzombievillager != null) { ++ // CraftBukkit end entityzombievillager.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityzombievillager.blockPosition()), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false, true), (NBTTagCompound) null); entityzombievillager.setVillagerData(entityvillager.getVillagerData()); -@@ -473,7 +504,7 @@ + entityzombievillager.setGossips((NBTBase) entityvillager.getGossips().store(DynamicOpsNBT.INSTANCE).getValue()); + entityzombievillager.setTradeOffers(entityvillager.getOffers().createTag()); + entityzombievillager.setVillagerXp(entityvillager.getVillagerXp()); +- if (!this.isSilent()) { +- worldserver.levelEvent((EntityHuman) null, 1026, this.blockPosition(), 0); ++ // CraftBukkit start ++ if (!silent) { ++ worldserver.levelEvent((EntityHuman) null, 1026, blockPosition, 0); + } ++ // CraftBukkit end + } + ++ return entityzombievillager; // CraftBukkit + } + + @Override +@@ -473,7 +509,7 @@ entitychicken1.finalizeSpawn(worldaccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null, (NBTTagCompound) null); entitychicken1.setChickenJockey(true); this.startRiding(entitychicken1); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java index 69adeeb98a..c67ecdbe8e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java @@ -4,6 +4,8 @@ import com.google.common.base.Preconditions; import java.util.Locale; import net.minecraft.core.BlockPosition; import net.minecraft.core.IRegistry; +import net.minecraft.world.entity.monster.EntityZombie; +import net.minecraft.world.entity.monster.EntityZombieVillager; import net.minecraft.world.entity.npc.EntityVillager; import net.minecraft.world.entity.npc.VillagerProfession; import net.minecraft.world.level.block.BlockBed; @@ -14,8 +16,7 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.entity.EntityType; import org.bukkit.entity.Villager; -import org.bukkit.entity.Villager.Profession; -import org.bukkit.entity.Villager.Type; +import org.bukkit.entity.ZombieVillager; public class CraftVillager extends CraftAbstractVillager implements Villager { @@ -121,6 +122,12 @@ public class CraftVillager extends CraftAbstractVillager implements Villager { getHandle().setUnhappy(); } + @Override + public ZombieVillager zombify() { + EntityZombieVillager entityzombievillager = EntityZombie.zombifyVillager(getHandle().level.getMinecraftWorld(), getHandle(), getHandle().blockPosition(), isSilent(), true); + return (entityzombievillager != null) ? (ZombieVillager) entityzombievillager.getBukkitEntity() : null; + } + public static Profession nmsToBukkitProfession(VillagerProfession nms) { return Profession.valueOf(IRegistry.VILLAGER_PROFESSION.getKey(nms).getPath().toUpperCase(Locale.ROOT)); }