30 lines
2.1 KiB
Diff
30 lines
2.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Etil <81570777+etil2jz@users.noreply.github.com>
|
|
Date: Sun, 26 Sep 2021 12:35:18 +0200
|
|
Subject: [PATCH] Improve EntityTransformEvent cancellation handling
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
index 4904971710acbb2855ed9ed96fead4aed189c494..cd332a416bc56227d1d197ab1bc892ac90181b3a 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
@@ -858,7 +858,6 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
|
}
|
|
// Paper end
|
|
|
|
- if (org.spigotmc.SpigotConfig.logVillagerDeaths) Villager.LOGGER.info("Villager {} was struck by lightning {}.", this, lightning); // Paper - move log down, event can cancel
|
|
|
|
entitywitch.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
|
|
entitywitch.finalizeSpawn(world, world.getCurrentDifficultyAt(entitywitch.blockPosition()), MobSpawnType.CONVERSION, (SpawnGroupData) null, (CompoundTag) null);
|
|
@@ -871,8 +870,10 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
|
entitywitch.setPersistenceRequired();
|
|
// CraftBukkit start
|
|
if (CraftEventFactory.callEntityTransformEvent(this, entitywitch, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) {
|
|
+ super.thunderHit(world, lightning); // Mirai - didn't cancel the lighting, just the transformation
|
|
return;
|
|
}
|
|
+ if (org.spigotmc.SpigotConfig.logVillagerDeaths) Villager.LOGGER.info("Villager {} was struck by lightning {}.", this, lightning); // Paper - move log down, event can cancel - // Mirai - move even further down because if transformation is cancelled, the entity won't die
|
|
world.addAllEntities(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
|
|
// CraftBukkit end
|
|
this.releaseAllPois();
|