Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
49 Zeilen
3.1 KiB
Diff
49 Zeilen
3.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: AlphaBlend <whizkid3000@hotmail.com>
|
|
Date: Sun, 16 Oct 2016 23:19:30 -0700
|
|
Subject: [PATCH] Add EntityZapEvent
|
|
|
|
|
|
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 63c10be6eacd7108b8b4795d76bf624e0614440a..243eb1e54293c763a06febff551c051398d43535 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
@@ -846,10 +846,17 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
|
@Override
|
|
public void thunderHit(ServerLevel world, LightningBolt lightning) {
|
|
if (world.getDifficulty() != Difficulty.PEACEFUL) {
|
|
- Villager.LOGGER.info("Villager {} was struck by lightning {}.", this, lightning);
|
|
+ // Paper - Add EntityZapEvent; move log down, event can cancel
|
|
Witch entitywitch = (Witch) EntityType.WITCH.create(world);
|
|
|
|
if (entitywitch != null) {
|
|
+ // Paper start - Add EntityZapEvent
|
|
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityZapEvent(this, lightning, entitywitch).isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+ if (org.spigotmc.SpigotConfig.logVillagerDeaths) Villager.LOGGER.info("Villager {} was struck by lightning {}.", this, lightning); // Move down
|
|
+ // Paper end - Add EntityZapEvent
|
|
+
|
|
entitywitch.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
|
|
entitywitch.finalizeSpawn(world, world.getCurrentDifficultyAt(entitywitch.blockPosition()), MobSpawnType.CONVERSION, (SpawnGroupData) null);
|
|
entitywitch.setNoAi(this.isNoAi());
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
index 09b6cfd22673d338c5d16162bafeac2ae0b3074a..72eb4ddf05e43dd2da6bfdc6987a9218fcf1171a 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -1196,6 +1196,14 @@ public class CraftEventFactory {
|
|
return !event.isCancelled();
|
|
}
|
|
|
|
+ // Paper start
|
|
+ public static com.destroystokyo.paper.event.entity.EntityZapEvent callEntityZapEvent(Entity entity, Entity lightning, Entity changedEntity) {
|
|
+ com.destroystokyo.paper.event.entity.EntityZapEvent event = new com.destroystokyo.paper.event.entity.EntityZapEvent(entity.getBukkitEntity(), (LightningStrike) lightning.getBukkitEntity(), changedEntity.getBukkitEntity());
|
|
+ entity.getBukkitEntity().getServer().getPluginManager().callEvent(event);
|
|
+ return event;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public static boolean callEntityChangeBlockEvent(Entity entity, BlockPos position, net.minecraft.world.level.block.state.BlockState newBlock) {
|
|
return CraftEventFactory.callEntityChangeBlockEvent(entity, position, newBlock, false);
|
|
}
|