2017-05-05 01:08:52 +02:00
|
|
|
From 7aee300956e5692856336b83dbb238c2ffa47d97 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
|
2017-03-25 06:22:02 +01:00
|
|
|
index 8cda47518..79ca071bc 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
|
2016-12-17 05:23:03 +01:00
|
|
|
@@ -190,6 +190,15 @@ public abstract class EntityArrow extends Entity implements IProjectile {
|
2016-12-17 05:13:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // 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) {
|
|
|
|
this.a(movingobjectposition);
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java
|
2017-03-25 06:22:02 +01:00
|
|
|
index 789de85d1..d5c9d24cf 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
|
|
|
|
@@ -70,6 +70,15 @@ public abstract class EntityFireball extends Entity {
|
|
|
|
++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
|
2017-03-25 06:22:02 +01:00
|
|
|
index 606160a17..b78e0e49e 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
|
2016-12-20 23:34:27 +01:00
|
|
|
@@ -240,6 +240,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
|
2017-03-25 06:22:02 +01:00
|
|
|
index 6fbc84559..a8b9d9263 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
|
|
|
|
@@ -160,6 +160,15 @@ public abstract class EntityProjectile extends Entity implements IProjectile {
|
|
|
|
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) {
|
|
|
|
if (movingobjectposition.type == MovingObjectPosition.EnumMovingObjectType.BLOCK && this.world.getType(movingobjectposition.a()).getBlock() == Blocks.PORTAL) {
|
|
|
|
this.e(movingobjectposition.a());
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2017-05-05 01:08:52 +02:00
|
|
|
index 999e38878..e669f0878 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
|
2017-03-15 15:32:50 +01:00
|
|
|
@@ -794,6 +794,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);
|
|
|
|
--
|
2017-05-05 01:08:52 +02:00
|
|
|
2.12.2
|
2016-12-17 05:13:45 +01:00
|
|
|
|