13
0
geforkt von Mirrors/Paper

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

Dieser Commit ist enthalten in:
Brokkonaut 2020-09-12 08:36:10 +10:00 committet von md_5
Ursprung bf3d720714
Commit 6f55306c44
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: E8E901AC7C617C11
2 geänderte Dateien mit 13 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -717,14 +717,14 @@
+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack, enumhand);
+ cancelled = event.useItemInHand() == Event.Result.DENY;
+ } else {
+ if (player.playerInteractManager.firedInteract) {
+ player.playerInteractManager.firedInteract = false;
+ MovingObjectPositionBlock movingobjectpositionblock = (MovingObjectPositionBlock) movingobjectposition;
+ if (player.playerInteractManager.firedInteract && player.playerInteractManager.interactPosition.equals(movingobjectpositionblock.getBlockPosition()) && player.playerInteractManager.interactHand == enumhand && ItemStack.equals(player.playerInteractManager.interactItemStack, itemstack)) {
+ cancelled = player.playerInteractManager.interactResult;
+ } else {
+ MovingObjectPositionBlock movingobjectpositionblock = (MovingObjectPositionBlock) movingobjectposition;
+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, movingobjectpositionblock.getBlockPosition(), movingobjectpositionblock.getDirection(), itemstack, true, enumhand);
+ cancelled = event.useItemInHand() == Event.Result.DENY;
+ }
+ player.playerInteractManager.firedInteract = false;
+ }
+
+ if (cancelled) {

Datei anzeigen

@ -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;