mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-26 12:36:07 +01:00
4c9bdf53ac
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 9d0ad318 Fix javadoc errors in previous commits 9501daa2 #578: Add methods to modify the rate of regeneration and starvation 197d8f3d #577: Add EntityExhaustionEvent CraftBukkit Changes: a021e334 #795: Add methods to modify the rate of regeneration and starvation 509e523c #792: Add EntityExhaustionEvent Spigot Changes: db99f821 Rebuild patches
59 lines
3.4 KiB
Diff
59 lines
3.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Sat, 16 Jan 2021 14:30:12 -0500
|
|
Subject: [PATCH] Make ProjectileHitEvent Cancellable
|
|
|
|
Allows cancelling things like detonating TNT from Fire Arrows
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java
|
|
index 74ca38f8e4e1addc243c3f3b57021d26f0ce3c97..0840fdf3585407ec317f0326359619220c64db78 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityFireball.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityFireball.java
|
|
@@ -71,7 +71,7 @@ public abstract class EntityFireball extends IProjectile {
|
|
|
|
// CraftBukkit start - Fire ProjectileHitEvent
|
|
if (this.dead) {
|
|
- CraftEventFactory.callProjectileHitEvent(this, movingobjectposition);
|
|
+ if (!CraftEventFactory.callProjectileHitEvent(this, movingobjectposition)) return; // Paper - this is an undesired duplicate event, but make cancellable
|
|
}
|
|
// CraftBukkit end
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/IProjectile.java b/src/main/java/net/minecraft/server/IProjectile.java
|
|
index 9f5ce64a60fe7c312399ee416b11b84213dd3bee..bbc089b41fcbe0141f13591db2cb44b9e688cac4 100644
|
|
--- a/src/main/java/net/minecraft/server/IProjectile.java
|
|
+++ b/src/main/java/net/minecraft/server/IProjectile.java
|
|
@@ -118,7 +118,7 @@ public abstract class IProjectile extends Entity {
|
|
}
|
|
|
|
protected void a(MovingObjectPosition movingobjectposition) {
|
|
- org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // CraftBukkit - Call event
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition)) return; // CraftBukkit - Call event // Paper - make cancellable
|
|
MovingObjectPosition.EnumMovingObjectType movingobjectposition_enummovingobjecttype = movingobjectposition.getType();
|
|
|
|
if (movingobjectposition_enummovingobjecttype == MovingObjectPosition.EnumMovingObjectType.ENTITY) {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
index 8bbce9b07afb0ba327b399bf8c13b64d6d3c6e16..579e1b3cde06a1138d90cda61a2bcf87aed3be98 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -1296,9 +1296,9 @@ public class CraftEventFactory {
|
|
return event;
|
|
}
|
|
|
|
- public static void callProjectileHitEvent(Entity entity, MovingObjectPosition position) {
|
|
+ public static boolean callProjectileHitEvent(Entity entity, MovingObjectPosition position) { // Paper - make cancellable
|
|
if (position.getType() == MovingObjectPosition.EnumMovingObjectType.MISS) {
|
|
- return;
|
|
+ return false; // Paper - make cancellable
|
|
}
|
|
|
|
Block hitBlock = null;
|
|
@@ -1315,7 +1315,7 @@ public class CraftEventFactory {
|
|
}
|
|
|
|
ProjectileHitEvent event = new ProjectileHitEvent((Projectile) entity.getBukkitEntity(), hitEntity, hitBlock, hitFace);
|
|
- entity.world.getServer().getPluginManager().callEvent(event);
|
|
+ return event.callEvent(); // Paper
|
|
}
|
|
|
|
public static ExpBottleEvent callExpBottleEvent(Entity entity, int exp) {
|