1718f61bf8
Doesn't compile yet. CraftBukkit Changes: 90d6905b Repackage NMS 69cf961d Repackage patches Spigot Changes: 79d53c28 Repackage NMS
59 Zeilen
3.5 KiB
Diff
59 Zeilen
3.5 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/world/entity/projectile/EntityFireball.java b/src/main/java/net/minecraft/world/entity/projectile/EntityFireball.java
|
|
index 08b3499681eaf23a2f79f6dd9134ccfd86d888a4..7428de092006d5da3e8a543e46a11c6122eac323 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/EntityFireball.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/EntityFireball.java
|
|
@@ -86,7 +86,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/world/entity/projectile/IProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/IProjectile.java
|
|
index 0e3c646dca1fa1fa895c3aece037367a9b2cf378..054785a3db3c787f5c1444613d3e8fe235e397f1 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/IProjectile.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/IProjectile.java
|
|
@@ -129,7 +129,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 013ef80b91c03bb6baf6249d8584ba1a393b0dec..7ad42020c0ac735d5c24912a7de98d7a40870d0a 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -1295,9 +1295,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;
|
|
@@ -1314,7 +1314,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) {
|