SPIGOT-5794: Only skip interact event if position, hand and itemstack are equal

By: Brokkonaut <hannos17@gmx.de>
This commit is contained in:
CraftBukkit/Spigot
2020-09-12 08:36:10 +10:00
parent 5425f6ba43
commit c6d968eda2
2 changed files with 13 additions and 7 deletions

View File

@@ -243,13 +243,16 @@
}
}
}
@@ -287,12 +423,40 @@
@@ -287,12 +423,46 @@
}
}
+ // CraftBukkit start - whole method
+ public boolean interactResult = false;
+ public boolean firedInteract = false;
+ public BlockPosition interactPosition;
+ public EnumHand interactHand;
+ public ItemStack interactItemStack;
public EnumInteractionResult a(EntityPlayer entityplayer, World world, ItemStack itemstack, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) {
BlockPosition blockposition = movingobjectpositionblock.getBlockPosition();
IBlockData iblockdata = world.getType(blockposition);
@@ -268,6 +271,9 @@
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityplayer, Action.RIGHT_CLICK_BLOCK, blockposition, movingobjectpositionblock.getDirection(), itemstack, cancelledBlock, enumhand);
+ firedInteract = true;
+ interactResult = event.useItemInHand() == Event.Result.DENY;
+ interactPosition = blockposition.immutableCopy();
+ interactHand = enumhand;
+ interactItemStack = itemstack.cloneItemStack();
+
+ if (event.useInteractedBlock() == Event.Result.DENY) {
+ // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
@@ -284,7 +290,7 @@
if (itileinventory != null) {
entityplayer.openContainer(itileinventory);
@@ -306,7 +470,7 @@
@@ -306,7 +476,7 @@
ItemStack itemstack1 = itemstack.cloneItemStack();
if (!flag1) {
@@ -293,7 +299,7 @@
if (enuminteractionresult.a()) {
CriterionTriggers.M.a(entityplayer, blockposition, itemstack1);
@@ -314,17 +478,17 @@
@@ -314,17 +484,17 @@
}
}
@@ -314,7 +320,7 @@
}
if (enuminteractionresult1.a()) {
@@ -332,10 +496,10 @@
@@ -332,10 +502,10 @@
}
return enuminteractionresult1;