mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 00:07:56 +01:00
Fix ProjectilCollideEvent cancellation (Fixes #2953)
This commit is contained in:
parent
e5e4e9f717
commit
7434b6d710
@ -1,11 +1,11 @@
|
||||
From b38e2ce60d5ae0311eb67bc508840ddf27ac1aa2 Mon Sep 17 00:00:00 2001
|
||||
From 448ac613a2925088451c81269df877b33053955c 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/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java
|
||||
index 2b14b2c3f..634e2bd30 100644
|
||||
index 2b14b2c3fa..634e2bd304 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityArrow.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityArrow.java
|
||||
@@ -187,6 +187,17 @@ public abstract class EntityArrow extends Entity implements IProjectile {
|
||||
@ -27,7 +27,7 @@ index 2b14b2c3f..634e2bd30 100644
|
||||
this.a((MovingObjectPosition) object);
|
||||
this.impulse = true;
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java
|
||||
index 078cc2523..6756c79b3 100644
|
||||
index 078cc25231..6756c79b31 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityFireball.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityFireball.java
|
||||
@@ -67,7 +67,16 @@ public abstract class EntityFireball extends Entity {
|
||||
@ -49,16 +49,14 @@ index 078cc2523..6756c79b3 100644
|
||||
|
||||
// CraftBukkit start - Fire ProjectileHitEvent
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityFishingHook.java b/src/main/java/net/minecraft/server/EntityFishingHook.java
|
||||
index 39e3bd379..0a17715a1 100644
|
||||
index 39e3bd3795..807ec3394d 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityFishingHook.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityFishingHook.java
|
||||
@@ -214,8 +214,19 @@ public class EntityFishingHook extends Entity {
|
||||
@@ -214,7 +214,16 @@ public class EntityFishingHook extends Entity {
|
||||
return !entity.isSpectator() && (entity.isInteractable() || entity instanceof EntityItem) && (entity != this.owner || this.g >= 5);
|
||||
}, RayTrace.BlockCollisionOption.COLLIDER, true);
|
||||
|
||||
- if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) {
|
||||
+ if (movingobjectposition != null && movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { // Paper - add null check in case cancelled
|
||||
org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // CraftBukkit - Call event
|
||||
+ // Paper start - Call ProjectileCollideEvent
|
||||
+ if (movingobjectposition instanceof MovingObjectPositionEntity) {
|
||||
+ com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileCollideEvent(this, (MovingObjectPositionEntity)movingobjectposition);
|
||||
@ -68,13 +66,12 @@ index 39e3bd379..0a17715a1 100644
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
+
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // Craftbukkit - Call event
|
||||
+ if (movingobjectposition != null && movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { // Paper - add null check in case cancelled
|
||||
org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // CraftBukkit - Call event
|
||||
if (movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY) {
|
||||
this.hooked = ((MovingObjectPositionEntity) movingobjectposition).getEntity();
|
||||
this.n();
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityProjectile.java b/src/main/java/net/minecraft/server/EntityProjectile.java
|
||||
index 2e4c9d426..724b78b5d 100644
|
||||
index 2e4c9d4267..724b78b5d2 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityProjectile.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityProjectile.java
|
||||
@@ -99,7 +99,16 @@ public abstract class EntityProjectile extends Entity implements IProjectile {
|
||||
@ -96,7 +93,7 @@ index 2e4c9d426..724b78b5d 100644
|
||||
this.c(((MovingObjectPositionBlock) movingobjectposition).getBlockPosition());
|
||||
} else {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
index 95973558e..c45b7c15f 100644
|
||||
index 95973558e3..c45b7c15fc 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
@@ -1149,6 +1149,16 @@ public class CraftEventFactory {
|
||||
|
@ -1,4 +1,4 @@
|
||||
From dfa14f50d01094fce3527e2051c95b49c3f7bf40 Mon Sep 17 00:00:00 2001
|
||||
From d4538e81dbb8445b87043c86a2c1ada843ab6283 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Tue, 19 Dec 2017 16:31:46 -0500
|
||||
Subject: [PATCH] ExperienceOrbs API for Reason/Source/Triggering player
|
||||
@ -8,7 +8,7 @@ Adds lots of information about why this orb exists.
|
||||
Replaces isFromBottle() with logic that persists entity reloads too.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java
|
||||
index 5de881371..5f261b9b9 100644
|
||||
index 5de881371a..5f261b9b92 100644
|
||||
--- a/src/main/java/net/minecraft/server/Block.java
|
||||
+++ b/src/main/java/net/minecraft/server/Block.java
|
||||
@@ -511,13 +511,13 @@ public class Block implements IMaterial {
|
||||
@ -28,7 +28,7 @@ index 5de881371..5f261b9b9 100644
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/ContainerGrindstone.java b/src/main/java/net/minecraft/server/ContainerGrindstone.java
|
||||
index 2d2cd09ad..ed88e208d 100644
|
||||
index 2d2cd09ad1..ed88e208d0 100644
|
||||
--- a/src/main/java/net/minecraft/server/ContainerGrindstone.java
|
||||
+++ b/src/main/java/net/minecraft/server/ContainerGrindstone.java
|
||||
@@ -81,7 +81,7 @@ public class ContainerGrindstone extends Container {
|
||||
@ -41,7 +41,7 @@ index 2d2cd09ad..ed88e208d 100644
|
||||
|
||||
world.triggerEffect(1042, blockposition, 0);
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityEnderDragon.java b/src/main/java/net/minecraft/server/EntityEnderDragon.java
|
||||
index 876257769..138e2ea56 100644
|
||||
index 8762577696..138e2ea56a 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityEnderDragon.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityEnderDragon.java
|
||||
@@ -616,7 +616,7 @@ public class EntityEnderDragon extends EntityInsentient implements IMonster {
|
||||
@ -54,7 +54,7 @@ index 876257769..138e2ea56 100644
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityExperienceOrb.java b/src/main/java/net/minecraft/server/EntityExperienceOrb.java
|
||||
index 0447800d9..d4275e733 100644
|
||||
index 0447800d9d..d4275e733d 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityExperienceOrb.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityExperienceOrb.java
|
||||
@@ -16,9 +16,59 @@ public class EntityExperienceOrb extends Entity {
|
||||
@ -134,10 +134,10 @@ index 0447800d9..d4275e733 100644
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityFishingHook.java b/src/main/java/net/minecraft/server/EntityFishingHook.java
|
||||
index 0a17715a1..cbd30b33b 100644
|
||||
index 807ec3394d..73f5961aa3 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityFishingHook.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityFishingHook.java
|
||||
@@ -403,7 +403,7 @@ public class EntityFishingHook extends Entity {
|
||||
@@ -401,7 +401,7 @@ public class EntityFishingHook extends Entity {
|
||||
this.world.addEntity(entityitem);
|
||||
// CraftBukkit start - this.random.nextInt(6) + 1 -> playerFishEvent.getExpToDrop()
|
||||
if (playerFishEvent.getExpToDrop() > 0) {
|
||||
@ -147,7 +147,7 @@ index 0a17715a1..cbd30b33b 100644
|
||||
// CraftBukkit end
|
||||
if (itemstack1.getItem().a(TagsItem.FISHES)) {
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
index dd1caec9d..2775afc32 100644
|
||||
index dd1caec9da..2775afc327 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
@@ -1379,7 +1379,8 @@ public abstract class EntityLiving extends Entity {
|
||||
@ -161,7 +161,7 @@ index dd1caec9d..2775afc32 100644
|
||||
this.expToDrop = 0;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityThrownExpBottle.java b/src/main/java/net/minecraft/server/EntityThrownExpBottle.java
|
||||
index 0bfc0a773..ba2f90cc6 100644
|
||||
index 0bfc0a773d..ba2f90cc6a 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityThrownExpBottle.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityThrownExpBottle.java
|
||||
@@ -43,7 +43,7 @@ public class EntityThrownExpBottle extends EntityProjectileThrowable {
|
||||
@ -174,7 +174,7 @@ index 0bfc0a773..ba2f90cc6 100644
|
||||
|
||||
this.die();
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityTurtle.java b/src/main/java/net/minecraft/server/EntityTurtle.java
|
||||
index c73cc9ae4..76296119a 100644
|
||||
index c73cc9ae4b..76296119a1 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityTurtle.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityTurtle.java
|
||||
@@ -510,7 +510,7 @@ public class EntityTurtle extends EntityAnimal {
|
||||
@ -187,7 +187,7 @@ index c73cc9ae4..76296119a 100644
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityVillager.java b/src/main/java/net/minecraft/server/EntityVillager.java
|
||||
index 5e3835851..6ca4fa43c 100644
|
||||
index 5e3835851d..6ca4fa43c4 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityVillager.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityVillager.java
|
||||
@@ -509,7 +509,7 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
|
||||
@ -200,7 +200,7 @@ index 5e3835851..6ca4fa43c 100644
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityVillagerTrader.java b/src/main/java/net/minecraft/server/EntityVillagerTrader.java
|
||||
index 530c69996..2ad8dba5c 100644
|
||||
index 530c699964..2ad8dba5c0 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityVillagerTrader.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityVillagerTrader.java
|
||||
@@ -147,7 +147,7 @@ public class EntityVillagerTrader extends EntityVillagerAbstract {
|
||||
@ -213,7 +213,7 @@ index 530c69996..2ad8dba5c 100644
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/PathfinderGoalBreed.java b/src/main/java/net/minecraft/server/PathfinderGoalBreed.java
|
||||
index 1ab2668e9..2b708761d 100644
|
||||
index 1ab2668e91..2b708761d0 100644
|
||||
--- a/src/main/java/net/minecraft/server/PathfinderGoalBreed.java
|
||||
+++ b/src/main/java/net/minecraft/server/PathfinderGoalBreed.java
|
||||
@@ -117,7 +117,7 @@ public class PathfinderGoalBreed extends PathfinderGoal {
|
||||
@ -226,7 +226,7 @@ index 1ab2668e9..2b708761d 100644
|
||||
// CraftBukkit end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerInteractManager.java b/src/main/java/net/minecraft/server/PlayerInteractManager.java
|
||||
index f6c6ea4aa..dff3eb118 100644
|
||||
index f6c6ea4aaf..dff3eb1188 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerInteractManager.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerInteractManager.java
|
||||
@@ -374,7 +374,7 @@ public class PlayerInteractManager {
|
||||
@ -239,7 +239,7 @@ index f6c6ea4aa..dff3eb118 100644
|
||||
|
||||
return true;
|
||||
diff --git a/src/main/java/net/minecraft/server/SlotFurnaceResult.java b/src/main/java/net/minecraft/server/SlotFurnaceResult.java
|
||||
index d2698e847..edc4a5c34 100644
|
||||
index d2698e847c..edc4a5c34e 100644
|
||||
--- a/src/main/java/net/minecraft/server/SlotFurnaceResult.java
|
||||
+++ b/src/main/java/net/minecraft/server/SlotFurnaceResult.java
|
||||
@@ -2,7 +2,7 @@ package net.minecraft.server;
|
||||
@ -252,7 +252,7 @@ index d2698e847..edc4a5c34 100644
|
||||
|
||||
public SlotFurnaceResult(EntityHuman entityhuman, IInventory iinventory, int i, int j, int k) {
|
||||
diff --git a/src/main/java/net/minecraft/server/TileEntityFurnace.java b/src/main/java/net/minecraft/server/TileEntityFurnace.java
|
||||
index 8dc47452a..560e2f42b 100644
|
||||
index 8dc47452a4..560e2f42b7 100644
|
||||
--- a/src/main/java/net/minecraft/server/TileEntityFurnace.java
|
||||
+++ b/src/main/java/net/minecraft/server/TileEntityFurnace.java
|
||||
@@ -554,7 +554,7 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
|
||||
@ -265,7 +265,7 @@ index 8dc47452a..560e2f42b 100644
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index a41b32ddc..462458645 100644
|
||||
index a41b32ddc7..462458645e 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -1791,7 +1791,7 @@ public class CraftWorld implements World {
|
||||
@ -278,7 +278,7 @@ index a41b32ddc..462458645 100644
|
||||
entity = new EntityLightning(world, x, y, z, false);
|
||||
} else if (Firework.class.isAssignableFrom(clazz)) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java
|
||||
index 1b512cc45..fbad04567 100644
|
||||
index 1b512cc45c..fbad045675 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java
|
||||
@@ -20,6 +20,18 @@ public class CraftExperienceOrb extends CraftEntity implements ExperienceOrb {
|
||||
|
Loading…
Reference in New Issue
Block a user