aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/monster/ZombieVillager.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/monster/ZombieVillager.java.patch')
-rw-r--r--patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/monster/ZombieVillager.java.patch99
1 files changed, 99 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/monster/ZombieVillager.java.patch b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/monster/ZombieVillager.java.patch
new file mode 100644
index 0000000000..41eb20eaef
--- /dev/null
+++ b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/monster/ZombieVillager.java.patch
@@ -0,0 +1,99 @@
+--- a/net/minecraft/world/entity/monster/ZombieVillager.java
++++ b/net/minecraft/world/entity/monster/ZombieVillager.java
+@@ -50,6 +46,16 @@
+ import org.joml.Vector3f;
+ import org.slf4j.Logger;
+
++// CraftBukkit start
++import net.minecraft.server.MinecraftServer;
++import net.minecraft.server.level.ServerLevel;
++import net.minecraft.server.level.ServerPlayer;
++import net.minecraft.sounds.SoundEvent;
++import net.minecraft.sounds.SoundEvents;
++import org.bukkit.event.entity.CreatureSpawnEvent;
++import org.bukkit.event.entity.EntityTransformEvent;
++// CraftBukkit end
++
+ public class ZombieVillager extends Zombie implements VillagerDataHolder {
+
+ private static final Logger LOGGER = LogUtils.getLogger();
+@@ -67,6 +73,7 @@
+ @Nullable
+ private CompoundTag tradeOffers;
+ private int villagerXp;
++ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
+
+ public ZombieVillager(EntityType<? extends ZombieVillager> entitytype, Level level) {
+ super(entitytype, level);
+@@ -145,6 +148,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) {
+@@ -153,6 +160,7 @@
+ }
+
+ super.tick();
++ this.lastTick = MinecraftServer.currentTick; // CraftBukkit
+ }
+
+ @Override
+@@ -199,8 +204,10 @@
+ this.conversionStarter = uuid;
+ this.villagerConversionTime = i;
+ this.getEntityData().set(ZombieVillager.DATA_CONVERTING_ID, true);
+- this.removeEffect(MobEffects.WEAKNESS);
+- this.addEffect(new MobEffectInstance(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 MobEffectInstance(MobEffects.DAMAGE_BOOST, villagerConversionTime, Math.min(this.level().getDifficulty().getId() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
++ // CraftBukkit end
+ this.level().broadcastEntityEvent(this, (byte) 16);
+ }
+
+@@ -217,10 +223,16 @@
+ }
+ }
+
+- private void finishConversion(ServerLevel serverlevel) {
+- Villager villager = (Villager) this.convertTo(EntityType.VILLAGER, false);
+- EquipmentSlot[] aequipmentslot = EquipmentSlot.values();
+- int i = aequipmentslot.length;
++ private void finishConversion(ServerLevel serverLevel) {
++ // CraftBukkit start
++ Villager entityvillager = (Villager) this.convertTo(EntityType.VILLAGER, false, EntityTransformEvent.TransformReason.CURED, CreatureSpawnEvent.SpawnReason.CURED);
++ if (entityvillager == null) {
++ ((org.bukkit.entity.ZombieVillager) getBukkitEntity()).setConversionTime(-1); // SPIGOT-5208: End conversion to stop event spam
++ return;
++ }
++ // CraftBukkit end
++ EquipmentSlot[] aenumitemslot = EquipmentSlot.values();
++ int i = aenumitemslot.length;
+
+ for (int j = 0; j < i; ++j) {
+ EquipmentSlot equipmentslot = aequipmentslot[j];
+@@ -233,7 +245,9 @@
+ double d0 = (double) this.getEquipmentDropChance(equipmentslot);
+
+ if (d0 > 1.0D) {
++ this.forceDrops = true; // CraftBukkit
+ this.spawnAtLocation(itemstack);
++ this.forceDrops = false; // CraftBukkit
+ }
+ }
+ }
+@@ -260,7 +274,7 @@
+ }
+ }
+
+- villager.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0));
++ entityvillager.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); // CraftBukkit
+ if (!this.isSilent()) {
+ serverlevel.levelEvent((Player) null, 1027, this.blockPosition(), 0);
+ }