From 9bda4134570bd8b60a797ed63cb13ced442576d0 Mon Sep 17 00:00:00 2001 From: blablubbabc Date: Fri, 17 May 2019 14:08:33 +0200 Subject: [PATCH] SPIGOT-4943: Zombie villager conversion player API. Also resetting the conversion player when stopping a conversion. --- nms-patches/EntityZombieVillager.patch | 9 ++++++--- .../craftbukkit/entity/CraftVillagerZombie.java | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/nms-patches/EntityZombieVillager.patch b/nms-patches/EntityZombieVillager.patch index 051d0aabf7..cb1e11c951 100644 --- a/nms-patches/EntityZombieVillager.patch +++ b/nms-patches/EntityZombieVillager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityZombieVillager.java +++ b/net/minecraft/server/EntityZombieVillager.java -@@ -3,6 +3,10 @@ +@@ -3,15 +3,20 @@ import com.mojang.datafixers.Dynamic; import java.util.UUID; import javax.annotation.Nullable; @@ -11,8 +11,11 @@ public class EntityZombieVillager extends EntityZombie implements VillagerDataHolder { -@@ -12,6 +16,7 @@ - private UUID conversionPlayer; + public static final DataWatcherObject CONVERTING = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.i); + private static final DataWatcherObject c = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.q); + public int conversionTime; +- private UUID conversionPlayer; ++ public UUID conversionPlayer; // CraftBukkit - public private NBTTagCompound bB; private int bC; + private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java index df9d1069ee..98b6dcf47b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java @@ -7,6 +7,8 @@ import net.minecraft.server.EntityZombieVillager; import net.minecraft.server.IRegistry; import net.minecraft.server.MinecraftKey; import org.apache.commons.lang.Validate; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; import org.bukkit.entity.Villager; @@ -62,8 +64,20 @@ public class CraftVillagerZombie extends CraftZombie implements ZombieVillager { getHandle().conversionTime = -1; getHandle().getDataWatcher().set(EntityZombieVillager.CONVERTING, false); getHandle().persistent = false; // CraftBukkit - SPIGOT-4684 update persistence + getHandle().conversionPlayer = null; } else { getHandle().startConversion((UUID) null, time); } } + + @Override + public OfflinePlayer getConversionPlayer() { + return (getHandle().conversionPlayer == null) ? null : Bukkit.getOfflinePlayer(getHandle().conversionPlayer); + } + + @Override + public void setConversionPlayer(OfflinePlayer conversionPlayer) { + if (!this.isConverting()) return; + getHandle().conversionPlayer = (conversionPlayer == null) ? null : conversionPlayer.getUniqueId(); + } }