2016-11-25 04:12:18 +01:00
From 6f81a88ba6c88fd8ac2f420dc4010b7b9999d2d0 Mon Sep 17 00:00:00 2001
2016-10-05 23:07:29 +02:00
From: AlphaBlend <whizkid3000@hotmail.com>
Date: Wed, 21 Sep 2016 20:40:46 -0700
Subject: [PATCH] Add hit entity to ProjectileHitEvent
diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java
2016-11-17 03:23:38 +01:00
index b71ebea..3021c81 100644
2016-10-05 23:07:29 +02:00
--- a/src/main/java/net/minecraft/server/EntityArrow.java
+++ b/src/main/java/net/minecraft/server/EntityArrow.java
2016-11-17 03:23:38 +01:00
@@ -264,7 +264,7 @@ public abstract class EntityArrow extends Entity implements IProjectile {
2016-10-05 23:07:29 +02:00
protected void a(MovingObjectPosition movingobjectposition) {
Entity entity = movingobjectposition.entity;
- org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // CraftBukkit - Call event
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, entity); // CraftBukkit - Call event // Paper - Include entity in movingobjectposition
if (entity != null) {
float f = MathHelper.sqrt(this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ);
int i = MathHelper.f((double) f * this.damage);
diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java
2016-11-17 03:23:38 +01:00
index 45e5972..88372f3 100644
2016-10-05 23:07:29 +02:00
--- a/src/main/java/net/minecraft/server/EntityFireball.java
+++ b/src/main/java/net/minecraft/server/EntityFireball.java
2016-11-17 03:23:38 +01:00
@@ -75,7 +75,7 @@ public abstract class EntityFireball extends Entity {
2016-10-05 23:07:29 +02:00
// CraftBukkit start - Fire ProjectileHitEvent
if (this.dead) {
- CraftEventFactory.callProjectileHitEvent(this);
+ CraftEventFactory.callProjectileHitEvent(this, movingobjectposition.entity); // Paper - include entity in movingobjectposition
}
// CraftBukkit end
}
diff --git a/src/main/java/net/minecraft/server/EntityFishingHook.java b/src/main/java/net/minecraft/server/EntityFishingHook.java
2016-11-25 04:12:18 +01:00
index 59a3748..157e32c 100644
2016-10-05 23:07:29 +02:00
--- a/src/main/java/net/minecraft/server/EntityFishingHook.java
+++ b/src/main/java/net/minecraft/server/EntityFishingHook.java
2016-11-25 04:12:18 +01:00
@@ -265,7 +265,7 @@ public class EntityFishingHook extends Entity {
2016-11-17 03:23:38 +01:00
}
2016-10-05 23:07:29 +02:00
2016-11-25 04:12:18 +01:00
if (movingobjectposition != null && movingobjectposition.type != MovingObjectPosition.EnumMovingObjectType.MISS) {
- org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // Craftbukkit - Call event
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition.entity); // Craftbukkit - Call event
if (movingobjectposition.type == MovingObjectPosition.EnumMovingObjectType.ENTITY) {
this.hooked = movingobjectposition.entity;
this.s();
2016-10-05 23:07:29 +02:00
diff --git a/src/main/java/net/minecraft/server/EntityProjectile.java b/src/main/java/net/minecraft/server/EntityProjectile.java
2016-11-17 03:23:38 +01:00
index 3d5548f..0dbd66a 100644
2016-10-05 23:07:29 +02:00
--- a/src/main/java/net/minecraft/server/EntityProjectile.java
+++ b/src/main/java/net/minecraft/server/EntityProjectile.java
@@ -175,7 +175,7 @@ public abstract class EntityProjectile extends Entity implements IProjectile {
this.a(movingobjectposition);
// CraftBukkit start
if (this.dead) {
- org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition.entity); // Paper - include Entity in movingobjectposition
}
// CraftBukkit end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
2016-11-25 04:12:18 +01:00
index 64d4f7e..b9e910d 100644
2016-10-05 23:07:29 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
2016-11-25 04:12:18 +01:00
@@ -1037,4 +1037,13 @@ public class CraftEventFactory {
child.world.getServer().getPluginManager().callEvent(event);
2016-10-05 23:07:29 +02:00
return event;
}
2016-11-25 04:12:18 +01:00
+
2016-10-05 23:07:29 +02:00
+ // Paper start
+ public static ProjectileHitEvent callProjectileHitEvent(Entity entity, Entity hitEntity) {
+ ProjectileHitEvent event = new ProjectileHitEvent((Projectile) entity.getBukkitEntity(), (hitEntity == null ? null : hitEntity.getBukkitEntity()));
+
+ entity.world.getServer().getPluginManager().callEvent(event);
+ return event;
+ }
+ // Paper end
2016-11-25 04:12:18 +01:00
}
2016-10-05 23:07:29 +02:00
--
2016-11-25 04:12:18 +01:00
2.10.2.windows.1
2016-10-05 23:07:29 +02:00