mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-25 16:50:17 +01:00
81 lines
4.6 KiB
Diff
81 lines
4.6 KiB
Diff
From d61e3c6a3da9d7a3f34fce5580f222bfa92482a6 Mon Sep 17 00:00:00 2001
|
|
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
|
|
index b71ebea..3021c81 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityArrow.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityArrow.java
|
|
@@ -264,7 +264,7 @@ public abstract class EntityArrow extends Entity implements IProjectile {
|
|
|
|
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
|
|
index 45e5972..88372f3 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityFireball.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityFireball.java
|
|
@@ -75,7 +75,7 @@ public abstract class EntityFireball extends Entity {
|
|
|
|
// 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
|
|
index e0475ce..395f30b 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityFishingHook.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityFishingHook.java
|
|
@@ -234,7 +234,7 @@ public class EntityFishingHook extends Entity {
|
|
// Paper end
|
|
|
|
if (movingobjectposition != null) {
|
|
- org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // Craftbukkit - Call event
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition.entity); // Craftbukkit - Call event // Paper - Include entity in movingobjectposition
|
|
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
|
|
index 3d5548f..0dbd66a 100644
|
|
--- 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
|
|
index f80856a..4ce1980 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -784,6 +784,15 @@ public class CraftEventFactory {
|
|
return event;
|
|
}
|
|
|
|
+ // 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
|
|
+
|
|
public static ExpBottleEvent callExpBottleEvent(Entity entity, int exp) {
|
|
ThrownExpBottle bottle = (ThrownExpBottle) entity.getBukkitEntity();
|
|
ExpBottleEvent event = new ExpBottleEvent(bottle, exp);
|
|
--
|
|
2.10.2
|
|
|