2018-12-17 06:18:06 +01:00
|
|
|
From 12c01d5926cc5657e82bc0e57258c7536bbec558 Mon Sep 17 00:00:00 2001
|
2016-12-17 05:13:45 +01:00
|
|
|
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/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java
|
2018-12-08 11:09:55 +01:00
|
|
|
index cc38cfb04..46606ed5c 100644
|
2016-12-17 05:13:45 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityArrow.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityArrow.java
|
2018-08-26 20:11:49 +02:00
|
|
|
@@ -195,6 +195,16 @@ public abstract class EntityArrow extends Entity implements IProjectile {
|
2016-12-17 05:13:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start - Call ProjectileCollideEvent
|
2018-07-16 22:08:09 +02:00
|
|
|
+ // TODO: flag - noclip - call cancelled?
|
2016-12-17 05:13:45 +01:00
|
|
|
+ if (movingobjectposition != null && movingobjectposition.entity != null) {
|
|
|
|
+ com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileCollideEvent(this, movingobjectposition);
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ movingobjectposition = null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
2018-07-16 22:08:09 +02:00
|
|
|
if (movingobjectposition != null && !flag) {
|
2016-12-17 05:13:45 +01:00
|
|
|
this.a(movingobjectposition);
|
2018-07-16 22:08:09 +02:00
|
|
|
this.impulse = true;
|
2016-12-17 05:13:45 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java
|
2018-12-08 11:09:55 +01:00
|
|
|
index 3e3619d79..58cc4824c 100644
|
2016-12-17 05:13:45 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityFireball.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityFireball.java
|
2018-07-16 22:08:09 +02:00
|
|
|
@@ -68,6 +68,15 @@ public abstract class EntityFireball extends Entity {
|
2016-12-17 05:13:45 +01:00
|
|
|
++this.f;
|
|
|
|
MovingObjectPosition movingobjectposition = ProjectileHelper.a(this, true, this.f >= 25, this.shooter);
|
|
|
|
|
|
|
|
+ // Paper start - Call ProjectileCollideEvent
|
|
|
|
+ if (movingobjectposition != null && movingobjectposition.entity != null) {
|
|
|
|
+ com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = CraftEventFactory.callProjectileCollideEvent(this, movingobjectposition);
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ movingobjectposition = null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
if (movingobjectposition != null) {
|
|
|
|
this.a(movingobjectposition);
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityFishingHook.java b/src/main/java/net/minecraft/server/EntityFishingHook.java
|
2018-12-17 06:18:06 +01:00
|
|
|
index cffb40efb..45a326779 100644
|
2016-12-17 05:13:45 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityFishingHook.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityFishingHook.java
|
2018-07-16 22:08:09 +02:00
|
|
|
@@ -245,6 +245,16 @@ public class EntityFishingHook extends Entity {
|
2016-12-17 05:13:45 +01:00
|
|
|
|
|
|
|
vec3d = new Vec3D(this.locX, this.locY, this.locZ);
|
|
|
|
vec3d1 = new Vec3D(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
|
|
|
|
+
|
|
|
|
+ // Paper start - Call ProjectileCollideEvent
|
|
|
|
+ if (movingobjectposition != null && movingobjectposition.entity != null) {
|
|
|
|
+ com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileCollideEvent(this, movingobjectposition);
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ movingobjectposition = null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
if (movingobjectposition != null) {
|
|
|
|
vec3d1 = new Vec3D(movingobjectposition.pos.x, movingobjectposition.pos.y, movingobjectposition.pos.z);
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityProjectile.java b/src/main/java/net/minecraft/server/EntityProjectile.java
|
2018-12-08 11:09:55 +01:00
|
|
|
index 11638221b..431afaf2f 100644
|
2016-12-17 05:13:45 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityProjectile.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityProjectile.java
|
2018-07-16 22:08:09 +02:00
|
|
|
@@ -144,6 +144,15 @@ public abstract class EntityProjectile extends Entity implements IProjectile {
|
2016-12-17 05:13:45 +01:00
|
|
|
movingobjectposition = new MovingObjectPosition(entity);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start - Call ProjectileCollideEvent
|
|
|
|
+ if (movingobjectposition != null && movingobjectposition.entity != null) {
|
|
|
|
+ com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileCollideEvent(this, movingobjectposition);
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ movingobjectposition = null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
if (movingobjectposition != null) {
|
2018-12-08 11:09:55 +01:00
|
|
|
if (movingobjectposition.type == MovingObjectPosition.EnumMovingObjectType.BLOCK && this.world.getType(movingobjectposition.getBlockPosition()).getBlock() == Blocks.NETHER_PORTAL) {
|
|
|
|
this.e(movingobjectposition.getBlockPosition());
|
2016-12-17 05:13:45 +01:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2018-12-17 06:18:06 +01:00
|
|
|
index 2a06cbf85..464c5cfc9 100644
|
2016-12-17 05:13:45 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2018-12-17 06:18:06 +01:00
|
|
|
@@ -955,6 +955,16 @@ public class CraftEventFactory {
|
2016-12-17 05:13:45 +01:00
|
|
|
return CraftItemStack.asNMSCopy(bitem);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ public static com.destroystokyo.paper.event.entity.ProjectileCollideEvent callProjectileCollideEvent(Entity entity, MovingObjectPosition position) {
|
|
|
|
+ Projectile projectile = (Projectile) entity.getBukkitEntity();
|
|
|
|
+ org.bukkit.entity.Entity collided = position.entity.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);
|
|
|
|
--
|
2018-12-17 06:18:06 +01:00
|
|
|
2.20.0
|
2016-12-17 05:13:45 +01:00
|
|
|
|