Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-16 11:30:06 +01:00
a207d14a0e
Signed-off-by: Mariell Hoversholm <proximyst@proximyst.com>
59 Zeilen
3.4 KiB
Diff
59 Zeilen
3.4 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/animal/Pig.java b/src/main/java/net/minecraft/world/entity/animal/Pig.java
|
|
index 6ecf7afe5fd7c4c95a17eaed1445d034aa2d5f18..e512a38ccbba93266f0234e3b2fcf7f62693039b 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/Pig.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Pig.java
|
|
@@ -254,6 +254,11 @@ public class Pig extends Animal implements ItemSteerable, Saddleable {
|
|
}
|
|
|
|
entitypigzombie.setPersistenceRequired();
|
|
+ // Paper start
|
|
+ if (CraftEventFactory.callEntityZapEvent(this, lightning, entitypigzombie).isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+ // Paper end
|
|
// CraftBukkit start
|
|
if (CraftEventFactory.callPigZapEvent(this, lightning, entitypigzombie).isCancelled()) {
|
|
return;
|
|
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 2f99bdaabe1c1a6a4e1a7e2bd533a63b12818be1..5648a4a4d8511ac8c46c61245a7ff83753a3e51f 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
@@ -786,6 +786,12 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
|
Villager.LOGGER.info("Villager {} was struck by lightning {}.", this, lightning);
|
|
Witch entitywitch = (Witch) EntityType.WITCH.create((Level) world);
|
|
|
|
+ // Paper start
|
|
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityZapEvent(this, lightning, entitywitch).isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
entitywitch.moveTo(this.getX(), this.getY(), this.getZ(), this.yRot, this.xRot);
|
|
entitywitch.finalizeSpawn(world, world.getCurrentDifficultyAt(entitywitch.blockPosition()), MobSpawnType.CONVERSION, (SpawnGroupData) null, (CompoundTag) 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 7fde1bb7587e567270e3f936381c6d361870211f..81af3e2e0964b6e179f92a342efdae943be18b75 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -1086,6 +1086,14 @@ public class CraftEventFactory {
|
|
return event;
|
|
}
|
|
|
|
+ // 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 HorseJumpEvent callHorseJumpEvent(Entity horse, float power) {
|
|
HorseJumpEvent event = new HorseJumpEvent((AbstractHorse) horse.getBukkitEntity(), power);
|
|
horse.getBukkitEntity().getServer().getPluginManager().callEvent(event);
|