summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntityZombieVillager.patch
blob: 2b8d7cddfc0a0176dcac2126bed544088c32a3cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
--- a/net/minecraft/server/EntityZombieVillager.java
+++ b/net/minecraft/server/EntityZombieVillager.java
@@ -9,6 +9,7 @@
     private static final DataWatcherObject<Integer> c = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.b);
     private int conversionTime;
     private UUID by;
+    private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
 
     public EntityZombieVillager(World world) {
         super(world);
@@ -58,8 +59,13 @@
     }
 
     public void B_() {
-        if (!this.world.isClientSide && this.isConverting()) {
+        if (!this.world.isClientSide && this.isConverting() && this.isAlive()) { // CraftBukkit
             int i = this.du();
+            // CraftBukkit start - Use wall time instead of ticks for villager conversion
+            int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
+            this.lastTick = MinecraftServer.currentTick;
+            i *= elapsedTicks;
+            // CraftBukkit end
 
             this.conversionTime -= i;
             if (this.conversionTime <= 0) {
@@ -123,7 +129,7 @@
             entityvillager.setCustomNameVisible(this.getCustomNameVisible());
         }
 
-        this.world.addEntity(entityvillager);
+        this.world.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CURED); // CraftBukkit - add SpawnReason
         if (this.by != null) {
             EntityHuman entityhuman = this.world.b(this.by);