mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-10 10:17:38 +01:00
9d740b84b0
By: md_5 <git@md-5.net>
100 lines
4.4 KiB
Diff
100 lines
4.4 KiB
Diff
--- a/net/minecraft/world/entity/monster/EntityZombieVillager.java
|
|
+++ b/net/minecraft/world/entity/monster/EntityZombieVillager.java
|
|
@@ -47,6 +47,13 @@
|
|
import net.minecraft.world.level.block.state.IBlockData;
|
|
import org.slf4j.Logger;
|
|
|
|
+// CraftBukkit start
|
|
+import net.minecraft.server.MinecraftServer;
|
|
+import org.bukkit.entity.ZombieVillager;
|
|
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
|
+import org.bukkit.event.entity.EntityTransformEvent;
|
|
+// CraftBukkit end
|
|
+
|
|
public class EntityZombieVillager extends EntityZombie implements VillagerDataHolder {
|
|
|
|
private static final Logger LOGGER = LogUtils.getLogger();
|
|
@@ -64,6 +71,7 @@
|
|
@Nullable
|
|
private NBTTagCompound tradeOffers;
|
|
private int villagerXp;
|
|
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
|
|
|
|
public EntityZombieVillager(EntityTypes<? extends EntityZombieVillager> entitytypes, World world) {
|
|
super(entitytypes, world);
|
|
@@ -82,7 +90,7 @@
|
|
@Override
|
|
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
|
|
super.addAdditionalSaveData(nbttagcompound);
|
|
- DataResult dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData());
|
|
+ DataResult<NBTBase> dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData()); // CraftBukkit - decompile error
|
|
Logger logger = EntityZombieVillager.LOGGER;
|
|
|
|
Objects.requireNonNull(logger);
|
|
@@ -138,6 +146,10 @@
|
|
public void tick() {
|
|
if (!this.level().isClientSide && this.isAlive() && this.isConverting()) {
|
|
int i = this.getConversionProgress();
|
|
+ // CraftBukkit start - Use wall time instead of ticks for villager conversion
|
|
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
|
|
+ i *= elapsedTicks;
|
|
+ // CraftBukkit end
|
|
|
|
this.villagerConversionTime -= i;
|
|
if (this.villagerConversionTime <= 0) {
|
|
@@ -146,6 +158,7 @@
|
|
}
|
|
|
|
super.tick();
|
|
+ this.lastTick = MinecraftServer.currentTick; // CraftBukkit
|
|
}
|
|
|
|
@Override
|
|
@@ -189,8 +202,10 @@
|
|
this.conversionStarter = uuid;
|
|
this.villagerConversionTime = i;
|
|
this.getEntityData().set(EntityZombieVillager.DATA_CONVERTING_ID, true);
|
|
- this.removeEffect(MobEffects.WEAKNESS);
|
|
- this.addEffect(new MobEffect(MobEffects.DAMAGE_BOOST, i, Math.min(this.level().getDifficulty().getId() - 1, 0)));
|
|
+ // CraftBukkit start
|
|
+ this.removeEffect(MobEffects.WEAKNESS, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
|
|
+ this.addEffect(new MobEffect(MobEffects.DAMAGE_BOOST, i, Math.min(this.level().getDifficulty().getId() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
|
|
+ // CraftBukkit end
|
|
this.level().broadcastEntityEvent(this, (byte) 16);
|
|
}
|
|
|
|
@@ -207,7 +222,13 @@
|
|
}
|
|
|
|
private void finishConversion(WorldServer worldserver) {
|
|
- EntityVillager entityvillager = (EntityVillager) this.convertTo(EntityTypes.VILLAGER, false);
|
|
+ // CraftBukkit start
|
|
+ EntityVillager entityvillager = (EntityVillager) this.convertTo(EntityTypes.VILLAGER, false, EntityTransformEvent.TransformReason.CURED, CreatureSpawnEvent.SpawnReason.CURED);
|
|
+ if (entityvillager == null) {
|
|
+ ((ZombieVillager) getBukkitEntity()).setConversionTime(-1); // SPIGOT-5208: End conversion to stop event spam
|
|
+ return;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
EnumItemSlot[] aenumitemslot = EnumItemSlot.values();
|
|
int i = aenumitemslot.length;
|
|
|
|
@@ -222,7 +243,9 @@
|
|
double d0 = (double) this.getEquipmentDropChance(enumitemslot);
|
|
|
|
if (d0 > 1.0D) {
|
|
+ this.forceDrops = true; // CraftBukkit
|
|
this.spawnAtLocation(itemstack);
|
|
+ this.forceDrops = false; // CraftBukkit
|
|
}
|
|
}
|
|
}
|
|
@@ -249,7 +272,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
|
|
if (!this.isSilent()) {
|
|
worldserver.levelEvent((EntityHuman) null, 1027, this.blockPosition(), 0);
|
|
}
|