2016-11-17 02:41:03 +01:00
|
|
|
--- a/net/minecraft/server/EntityZombieVillager.java
|
|
|
|
+++ b/net/minecraft/server/EntityZombieVillager.java
|
2018-11-14 04:10:22 +01:00
|
|
|
@@ -2,6 +2,10 @@
|
|
|
|
|
|
|
|
import java.util.UUID;
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
+import org.bukkit.event.entity.EntityTransformEvent;
|
|
|
|
+// CraftBukkit end
|
|
|
|
|
|
|
|
public class EntityZombieVillager extends EntityZombie {
|
|
|
|
|
|
|
|
@@ -9,6 +13,7 @@
|
2018-07-15 02:00:00 +02:00
|
|
|
private static final DataWatcherObject<Integer> b = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.b);
|
2016-11-17 02:41:03 +01:00
|
|
|
private int conversionTime;
|
2018-07-15 02:00:00 +02:00
|
|
|
private UUID bD;
|
2016-11-17 02:41:03 +01:00
|
|
|
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
|
|
|
|
|
|
|
|
public EntityZombieVillager(World world) {
|
2018-07-15 02:00:00 +02:00
|
|
|
super(EntityTypes.ZOMBIE_VILLAGER, world);
|
2018-11-14 04:10:22 +01:00
|
|
|
@@ -54,8 +59,13 @@
|
2018-11-06 08:03:42 +01:00
|
|
|
}
|
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
public void tick() {
|
2018-11-06 08:03:42 +01:00
|
|
|
- if (!this.world.isClientSide && this.isConverting()) {
|
|
|
|
+ if (!this.world.isClientSide && this.isConverting() && this.isAlive()) { // CraftBukkit
|
2018-08-26 04:00:00 +02:00
|
|
|
int i = this.dK();
|
2016-11-17 02:41:03 +01:00
|
|
|
+ // 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) {
|
2018-11-14 04:10:22 +01:00
|
|
|
@@ -100,8 +110,10 @@
|
2018-07-20 08:04:37 +02:00
|
|
|
this.bD = uuid;
|
|
|
|
this.conversionTime = i;
|
2018-12-06 00:00:00 +01:00
|
|
|
this.getDataWatcher().set(EntityZombieVillager.a, true);
|
2018-07-20 08:04:37 +02:00
|
|
|
- this.removeEffect(MobEffects.WEAKNESS);
|
|
|
|
- this.addEffect(new MobEffect(MobEffects.INCREASE_DAMAGE, i, Math.min(this.world.getDifficulty().a() - 1, 0)));
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ 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);
|
|
|
|
}
|
|
|
|
|
2018-12-04 23:51:20 +01:00
|
|
|
@@ -116,14 +128,20 @@
|
|
|
|
entityvillager.setAgeRaw(-24000);
|
|
|
|
}
|
|
|
|
|
|
|
|
- this.world.kill(this);
|
|
|
|
+ // this.world.kill(this); // CraftBukkit - moved down
|
|
|
|
entityvillager.setNoAI(this.isNoAI());
|
|
|
|
if (this.hasCustomName()) {
|
|
|
|
entityvillager.setCustomName(this.getCustomName());
|
2016-11-17 02:41:03 +01:00
|
|
|
entityvillager.setCustomNameVisible(this.getCustomNameVisible());
|
|
|
|
}
|
|
|
|
|
|
|
|
- this.world.addEntity(entityvillager);
|
2018-11-14 04:10:22 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (CraftEventFactory.callEntityTransformEvent(this, entityvillager, EntityTransformEvent.TransformReason.CURED).isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
2018-12-04 23:51:20 +01:00
|
|
|
+ this.world.kill(this); // CraftBukkit - from above
|
2016-11-17 02:41:03 +01:00
|
|
|
+ this.world.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CURED); // CraftBukkit - add SpawnReason
|
2018-12-04 23:51:20 +01:00
|
|
|
+ // CraftBukkit end
|
2018-07-15 02:00:00 +02:00
|
|
|
if (this.bD != null) {
|
|
|
|
EntityHuman entityhuman = this.world.b(this.bD);
|
2017-05-14 04:00:00 +02:00
|
|
|
|
2018-12-04 23:51:20 +01:00
|
|
|
@@ -132,7 +150,7 @@
|
2018-07-20 08:04:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0));
|
|
|
|
+ entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); // CraftBukkit
|
|
|
|
this.world.a((EntityHuman) null, 1027, new BlockPosition((int) this.locX, (int) this.locY, (int) this.locZ), 0);
|
|
|
|
}
|
|
|
|
|