2021-03-16 09:00:00 +11:00
|
|
|
--- a/net/minecraft/world/entity/monster/EntityZombieVillager.java
|
|
|
|
+++ b/net/minecraft/world/entity/monster/EntityZombieVillager.java
|
2023-09-22 02:40:00 +10:00
|
|
|
@@ -50,6 +50,13 @@
|
|
|
|
import org.joml.Vector3f;
|
2022-03-01 02:00:00 +11:00
|
|
|
import org.slf4j.Logger;
|
2021-03-09 08:47:33 +11:00
|
|
|
|
2018-11-14 14:10:22 +11:00
|
|
|
+// CraftBukkit start
|
2021-03-16 09:00:00 +11:00
|
|
|
+import net.minecraft.server.MinecraftServer;
|
2019-07-26 09:58:18 +10:00
|
|
|
+import org.bukkit.entity.ZombieVillager;
|
2020-08-12 07:00:00 +10:00
|
|
|
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
2018-11-14 14:10:22 +11:00
|
|
|
+import org.bukkit.event.entity.EntityTransformEvent;
|
|
|
|
+// CraftBukkit end
|
2021-03-09 08:47:33 +11:00
|
|
|
+
|
2019-04-23 12:00:00 +10:00
|
|
|
public class EntityZombieVillager extends EntityZombie implements VillagerDataHolder {
|
2018-11-14 14:10:22 +11:00
|
|
|
|
2022-03-01 02:00:00 +11:00
|
|
|
private static final Logger LOGGER = LogUtils.getLogger();
|
2023-09-22 02:40:00 +10:00
|
|
|
@@ -67,6 +74,7 @@
|
2021-11-22 09:00:00 +11:00
|
|
|
@Nullable
|
2021-06-11 15:00:00 +10:00
|
|
|
private NBTTagCompound tradeOffers;
|
|
|
|
private int villagerXp;
|
2016-11-17 12:41:03 +11:00
|
|
|
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
|
|
|
|
|
2019-04-23 12:00:00 +10:00
|
|
|
public EntityZombieVillager(EntityTypes<? extends EntityZombieVillager> entitytypes, World world) {
|
|
|
|
super(entitytypes, world);
|
2023-09-22 02:40:00 +10:00
|
|
|
@@ -85,7 +93,7 @@
|
2020-06-25 10:00:00 +10:00
|
|
|
@Override
|
2021-11-22 09:00:00 +11:00
|
|
|
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
|
|
|
|
super.addAdditionalSaveData(nbttagcompound);
|
2021-06-11 15:00:00 +10:00
|
|
|
- DataResult dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData());
|
|
|
|
+ DataResult<NBTBase> dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData()); // CraftBukkit - decompile error
|
2020-06-25 10:00:00 +10:00
|
|
|
Logger logger = EntityZombieVillager.LOGGER;
|
|
|
|
|
2021-06-11 15:00:00 +10:00
|
|
|
Objects.requireNonNull(logger);
|
2023-09-22 02:40:00 +10:00
|
|
|
@@ -141,6 +149,10 @@
|
2018-07-15 10:00:00 +10:00
|
|
|
public void tick() {
|
2023-06-08 01:30:00 +10:00
|
|
|
if (!this.level().isClientSide && this.isAlive() && this.isConverting()) {
|
2019-04-23 12:00:00 +10:00
|
|
|
int i = this.getConversionProgress();
|
2016-11-17 12:41:03 +11:00
|
|
|
+ // CraftBukkit start - Use wall time instead of ticks for villager conversion
|
|
|
|
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
|
|
|
|
+ i *= elapsedTicks;
|
|
|
|
+ // CraftBukkit end
|
|
|
|
|
2021-06-11 15:00:00 +10:00
|
|
|
this.villagerConversionTime -= i;
|
|
|
|
if (this.villagerConversionTime <= 0) {
|
2023-09-22 02:40:00 +10:00
|
|
|
@@ -149,6 +161,7 @@
|
2020-06-24 08:52:40 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
super.tick();
|
|
|
|
+ this.lastTick = MinecraftServer.currentTick; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-09-22 02:40:00 +10:00
|
|
|
@@ -192,8 +205,10 @@
|
2021-06-11 15:00:00 +10:00
|
|
|
this.conversionStarter = uuid;
|
|
|
|
this.villagerConversionTime = i;
|
2021-11-22 09:00:00 +11:00
|
|
|
this.getEntityData().set(EntityZombieVillager.DATA_CONVERTING_ID, true);
|
2018-07-20 16:04:37 +10:00
|
|
|
- this.removeEffect(MobEffects.WEAKNESS);
|
2023-06-08 01:30:00 +10:00
|
|
|
- this.addEffect(new MobEffect(MobEffects.DAMAGE_BOOST, i, Math.min(this.level().getDifficulty().getId() - 1, 0)));
|
2018-07-20 16:04:37 +10:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ this.removeEffect(MobEffects.WEAKNESS, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
|
2023-06-08 01:30:00 +10:00
|
|
|
+ this.addEffect(new MobEffect(MobEffects.DAMAGE_BOOST, i, Math.min(this.level().getDifficulty().getId() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
|
2018-07-20 16:04:37 +10:00
|
|
|
+ // CraftBukkit end
|
2023-06-08 01:30:00 +10:00
|
|
|
this.level().broadcastEntityEvent(this, (byte) 16);
|
2021-06-11 15:00:00 +10:00
|
|
|
}
|
|
|
|
|
2023-09-22 02:40:00 +10:00
|
|
|
@@ -210,7 +225,13 @@
|
2018-07-20 16:04:37 +10:00
|
|
|
}
|
|
|
|
|
2021-11-22 09:00:00 +11:00
|
|
|
private void finishConversion(WorldServer worldserver) {
|
|
|
|
- EntityVillager entityvillager = (EntityVillager) this.convertTo(EntityTypes.VILLAGER, false);
|
2018-11-14 14:10:22 +11:00
|
|
|
+ // CraftBukkit start
|
2021-11-22 09:00:00 +11:00
|
|
|
+ EntityVillager entityvillager = (EntityVillager) this.convertTo(EntityTypes.VILLAGER, false, EntityTransformEvent.TransformReason.CURED, CreatureSpawnEvent.SpawnReason.CURED);
|
2020-08-12 07:00:00 +10:00
|
|
|
+ if (entityvillager == null) {
|
2019-07-26 09:58:18 +10:00
|
|
|
+ ((ZombieVillager) getBukkitEntity()).setConversionTime(-1); // SPIGOT-5208: End conversion to stop event spam
|
2018-11-14 14:10:22 +11:00
|
|
|
+ return;
|
|
|
|
+ }
|
2018-12-05 09:51:20 +11:00
|
|
|
+ // CraftBukkit end
|
2020-08-12 07:00:00 +10:00
|
|
|
EnumItemSlot[] aenumitemslot = EnumItemSlot.values();
|
|
|
|
int i = aenumitemslot.length;
|
2017-05-14 12:00:00 +10:00
|
|
|
|
2023-09-22 02:40:00 +10:00
|
|
|
@@ -225,7 +246,9 @@
|
2021-11-22 09:00:00 +11:00
|
|
|
double d0 = (double) this.getEquipmentDropChance(enumitemslot);
|
2021-04-12 08:28:19 +10:00
|
|
|
|
|
|
|
if (d0 > 1.0D) {
|
|
|
|
+ this.forceDrops = true; // CraftBukkit
|
2021-11-22 09:00:00 +11:00
|
|
|
this.spawnAtLocation(itemstack);
|
2021-04-12 08:28:19 +10:00
|
|
|
+ this.forceDrops = false; // CraftBukkit
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-09-22 02:40:00 +10:00
|
|
|
@@ -252,7 +275,7 @@
|
2018-07-20 16:04:37 +10: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
|
2020-06-25 10:00:00 +10:00
|
|
|
if (!this.isSilent()) {
|
2021-11-22 09:00:00 +11:00
|
|
|
worldserver.levelEvent((EntityHuman) null, 1027, this.blockPosition(), 0);
|
2020-06-25 10:00:00 +10:00
|
|
|
}
|