3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-24 15:20:11 +01:00
Paper/nms-patches/EntityZombieVillager.patch

80 Zeilen
3.5 KiB
Diff

2016-11-17 02:41:03 +01:00
--- a/net/minecraft/server/EntityZombieVillager.java
+++ b/net/minecraft/server/EntityZombieVillager.java
2019-05-27 22:30:00 +02:00
@@ -3,6 +3,10 @@
2019-04-23 04:00:00 +02:00
import com.mojang.datafixers.Dynamic;
import java.util.UUID;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityTransformEvent;
+// CraftBukkit end
2019-04-23 04:00:00 +02:00
public class EntityZombieVillager extends EntityZombie implements VillagerDataHolder {
2019-05-27 22:30:00 +02:00
@@ -12,6 +16,7 @@
public UUID conversionPlayer;
2019-04-23 04:00:00 +02:00
private NBTTagCompound bB;
private int bC;
2016-11-17 02:41:03 +01:00
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
2019-04-23 04:00:00 +02:00
public EntityZombieVillager(EntityTypes<? extends EntityZombieVillager> entitytypes, World world) {
super(entitytypes, world);
2019-05-14 02:00:00 +02:00
@@ -66,6 +71,11 @@
2018-07-15 02:00:00 +02:00
public void tick() {
2019-04-23 04:00:00 +02:00
if (!this.world.isClientSide && this.isAlive() && this.isConverting()) {
int i = this.getConversionProgress();
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) {
2019-05-14 02:00:00 +02:00
@@ -113,8 +123,11 @@
2019-04-23 04:00:00 +02:00
this.conversionPlayer = uuid;
this.conversionTime = i;
2018-12-25 22:00:00 +01:00
this.getDataWatcher().set(EntityZombieVillager.CONVERTING, true);
- this.removeEffect(MobEffects.WEAKNESS);
- this.addEffect(new MobEffect(MobEffects.INCREASE_DAMAGE, i, Math.min(this.world.getDifficulty().a() - 1, 0)));
+ // CraftBukkit start
+ this.persistent = true; // CraftBukkit - SPIGOT-4684 update persistence
+ 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);
}
2019-05-14 02:00:00 +02:00
@@ -133,14 +146,20 @@
entityvillager.setAgeRaw(-24000);
}
2019-04-23 04:00:00 +02:00
- this.die();
+ // this.die(); // 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());
}
2019-04-23 04:00:00 +02:00
- worldserver.addEntity(entityvillager);
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityTransformEvent(this, entityvillager, EntityTransformEvent.TransformReason.CURED).isCancelled()) {
+ return;
+ }
2019-04-23 04:00:00 +02:00
+ this.die(); // CraftBukkit - from above
+ worldserver.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CURED); // CraftBukkit - add SpawnReason
+ // CraftBukkit end
2019-04-23 04:00:00 +02:00
if (this.conversionPlayer != null) {
EntityHuman entityhuman = worldserver.b(this.conversionPlayer);
2017-05-14 04:00:00 +02:00
2019-05-14 02:00:00 +02:00
@@ -150,7 +169,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
2019-05-14 02:00:00 +02:00
worldserver.a((EntityHuman) null, 1027, new BlockPosition(this), 0);
}