Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
1718f61bf8
Doesn't compile yet. CraftBukkit Changes: 90d6905b Repackage NMS 69cf961d Repackage patches Spigot Changes: 79d53c28 Repackage NMS
94 Zeilen
5.5 KiB
Diff
94 Zeilen
5.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Techcable <Techcable@outlook.com>
|
|
Date: Fri, 16 Dec 2016 21:25:39 -0600
|
|
Subject: [PATCH] Add ProjectileCollideEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/EntityArrow.java b/src/main/java/net/minecraft/world/entity/projectile/EntityArrow.java
|
|
index 9bd4a283a99f86c9a26f73e0bad0c3414d66ad55..5ecbe9135a71dd84e0722fa9c039c272a11d206f 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/EntityArrow.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/EntityArrow.java
|
|
@@ -198,6 +198,17 @@ public abstract class EntityArrow extends IProjectile {
|
|
}
|
|
}
|
|
|
|
+ // Paper start - Call ProjectileCollideEvent
|
|
+ // TODO: flag - noclip - call cancelled?
|
|
+ if (object instanceof MovingObjectPositionEntity) {
|
|
+ com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileCollideEvent(this, (MovingObjectPositionEntity)object);
|
|
+ if (event.isCancelled()) {
|
|
+ object = null;
|
|
+ movingobjectpositionentity = null;
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
if (object != null && !flag) {
|
|
this.a((MovingObjectPosition) object);
|
|
this.impulse = true;
|
|
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 ed76aec99f46a7923d139e347779c24f512ac131..08b3499681eaf23a2f79f6dd9134ccfd86d888a4 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/EntityFireball.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/EntityFireball.java
|
|
@@ -72,7 +72,16 @@ public abstract class EntityFireball extends IProjectile {
|
|
|
|
MovingObjectPosition movingobjectposition = ProjectileHelper.a((Entity) this, this::a);
|
|
|
|
- if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) {
|
|
+ // Paper start - Call ProjectileCollideEvent
|
|
+ if (movingobjectposition instanceof MovingObjectPositionEntity) {
|
|
+ com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = CraftEventFactory.callProjectileCollideEvent(this, (MovingObjectPositionEntity)movingobjectposition);
|
|
+ if (event.isCancelled()) {
|
|
+ movingobjectposition = null;
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
+ if (movingobjectposition != null && movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { // Paper - add null check in case cancelled
|
|
this.a(movingobjectposition);
|
|
|
|
// CraftBukkit start - Fire ProjectileHitEvent
|
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/EntityProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/EntityProjectile.java
|
|
index 829b4f28896bcb0eb6e48242bd00585eeaae62c2..7bf41d2c924531f7a28e906c64b8a4ccd3dffedb 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/EntityProjectile.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/EntityProjectile.java
|
|
@@ -57,7 +57,17 @@ public abstract class EntityProjectile extends IProjectile {
|
|
}
|
|
|
|
if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS && !flag) {
|
|
+ // Paper start - Call ProjectileCollideEvent
|
|
+ if (movingobjectposition instanceof MovingObjectPositionEntity) {
|
|
+ com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileCollideEvent(this, (MovingObjectPositionEntity)movingobjectposition);
|
|
+ if (event.isCancelled()) {
|
|
+ movingobjectposition = null;
|
|
+ }
|
|
+ }
|
|
+ if (movingobjectposition != null) {
|
|
+ // Paper end
|
|
this.a(movingobjectposition);
|
|
+ } // Paper
|
|
}
|
|
|
|
this.checkBlockCollisions();
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
index 52028387ae90b9e125b4522e5a3963a1119499e4..2dcdc428028a40c06b0ec1e50af76c16f051f084 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -1181,6 +1181,16 @@ public class CraftEventFactory {
|
|
return CraftItemStack.asNMSCopy(bitem);
|
|
}
|
|
|
|
+ // Paper start
|
|
+ public static com.destroystokyo.paper.event.entity.ProjectileCollideEvent callProjectileCollideEvent(Entity entity, MovingObjectPositionEntity position) {
|
|
+ Projectile projectile = (Projectile) entity.getBukkitEntity();
|
|
+ org.bukkit.entity.Entity collided = position.getEntity().getBukkitEntity();
|
|
+ com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = new com.destroystokyo.paper.event.entity.ProjectileCollideEvent(projectile, collided);
|
|
+ Bukkit.getPluginManager().callEvent(event);
|
|
+ return event;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public static ProjectileLaunchEvent callProjectileLaunchEvent(Entity entity) {
|
|
Projectile bukkitEntity = (Projectile) entity.getBukkitEntity();
|
|
ProjectileLaunchEvent event = new ProjectileLaunchEvent(bukkitEntity);
|