Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
SPIGOT-5794: Only skip interact event if position, hand and itemstack are equal
Dieser Commit ist enthalten in:
Ursprung
bf3d720714
Commit
6f55306c44
@ -717,14 +717,14 @@
|
|||||||
+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack, enumhand);
|
+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack, enumhand);
|
||||||
+ cancelled = event.useItemInHand() == Event.Result.DENY;
|
+ cancelled = event.useItemInHand() == Event.Result.DENY;
|
||||||
+ } else {
|
+ } else {
|
||||||
+ if (player.playerInteractManager.firedInteract) {
|
+ MovingObjectPositionBlock movingobjectpositionblock = (MovingObjectPositionBlock) movingobjectposition;
|
||||||
+ player.playerInteractManager.firedInteract = false;
|
+ if (player.playerInteractManager.firedInteract && player.playerInteractManager.interactPosition.equals(movingobjectpositionblock.getBlockPosition()) && player.playerInteractManager.interactHand == enumhand && ItemStack.equals(player.playerInteractManager.interactItemStack, itemstack)) {
|
||||||
+ cancelled = player.playerInteractManager.interactResult;
|
+ cancelled = player.playerInteractManager.interactResult;
|
||||||
+ } else {
|
+ } 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);
|
+ 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;
|
+ cancelled = event.useItemInHand() == Event.Result.DENY;
|
||||||
+ }
|
+ }
|
||||||
|
+ player.playerInteractManager.firedInteract = false;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ if (cancelled) {
|
+ if (cancelled) {
|
||||||
|
@ -243,13 +243,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -287,12 +423,40 @@
|
@@ -287,12 +423,46 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+ // CraftBukkit start - whole method
|
+ // CraftBukkit start - whole method
|
||||||
+ public boolean interactResult = false;
|
+ public boolean interactResult = false;
|
||||||
+ public boolean firedInteract = 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) {
|
public EnumInteractionResult a(EntityPlayer entityplayer, World world, ItemStack itemstack, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) {
|
||||||
BlockPosition blockposition = movingobjectpositionblock.getBlockPosition();
|
BlockPosition blockposition = movingobjectpositionblock.getBlockPosition();
|
||||||
IBlockData iblockdata = world.getType(blockposition);
|
IBlockData iblockdata = world.getType(blockposition);
|
||||||
@ -268,6 +271,9 @@
|
|||||||
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityplayer, Action.RIGHT_CLICK_BLOCK, blockposition, movingobjectpositionblock.getDirection(), itemstack, cancelledBlock, enumhand);
|
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityplayer, Action.RIGHT_CLICK_BLOCK, blockposition, movingobjectpositionblock.getDirection(), itemstack, cancelledBlock, enumhand);
|
||||||
+ firedInteract = true;
|
+ firedInteract = true;
|
||||||
+ interactResult = event.useItemInHand() == Event.Result.DENY;
|
+ interactResult = event.useItemInHand() == Event.Result.DENY;
|
||||||
|
+ interactPosition = blockposition.immutableCopy();
|
||||||
|
+ interactHand = enumhand;
|
||||||
|
+ interactItemStack = itemstack.cloneItemStack();
|
||||||
+
|
+
|
||||||
+ if (event.useInteractedBlock() == Event.Result.DENY) {
|
+ 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.
|
+ // 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) {
|
if (itileinventory != null) {
|
||||||
entityplayer.openContainer(itileinventory);
|
entityplayer.openContainer(itileinventory);
|
||||||
@@ -306,7 +470,7 @@
|
@@ -306,7 +476,7 @@
|
||||||
ItemStack itemstack1 = itemstack.cloneItemStack();
|
ItemStack itemstack1 = itemstack.cloneItemStack();
|
||||||
|
|
||||||
if (!flag1) {
|
if (!flag1) {
|
||||||
@ -293,7 +299,7 @@
|
|||||||
|
|
||||||
if (enuminteractionresult.a()) {
|
if (enuminteractionresult.a()) {
|
||||||
CriterionTriggers.M.a(entityplayer, blockposition, itemstack1);
|
CriterionTriggers.M.a(entityplayer, blockposition, itemstack1);
|
||||||
@@ -314,17 +478,17 @@
|
@@ -314,17 +484,17 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,7 +320,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (enuminteractionresult1.a()) {
|
if (enuminteractionresult1.a()) {
|
||||||
@@ -332,10 +496,10 @@
|
@@ -332,10 +502,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
return enuminteractionresult1;
|
return enuminteractionresult1;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren