mirror of
https://github.com/PaperMC/Paper.git
synced 2025-07-26 01:32:02 -07:00
Correctly handle interactions with items on cooldown
This commit is contained in:
@@ -369,7 +369,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -321,15 +510,58 @@
|
||||
@@ -321,15 +510,59 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,6 +383,7 @@
|
||||
BlockPos blockposition = hitResult.getBlockPos();
|
||||
BlockState iblockdata = world.getBlockState(blockposition);
|
||||
+ boolean cancelledBlock = false;
|
||||
+ boolean cancelledItem = false; // Paper - correctly handle items on cooldown
|
||||
|
||||
if (!iblockdata.getBlock().isEnabled(world.enabledFeatures())) {
|
||||
return InteractionResult.FAIL;
|
||||
@@ -392,10 +393,10 @@
|
||||
+ }
|
||||
|
||||
+ if (player.getCooldowns().isOnCooldown(stack)) {
|
||||
+ cancelledBlock = true;
|
||||
+ cancelledItem = true; // Paper - correctly handle items on cooldown
|
||||
+ }
|
||||
+
|
||||
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, blockposition, hitResult.getDirection(), stack, cancelledBlock, hand, hitResult.getLocation());
|
||||
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, blockposition, hitResult.getDirection(), stack, cancelledBlock, cancelledItem, hand, hitResult.getLocation()); // Paper - correctly handle items on cooldown
|
||||
+ this.firedInteract = true;
|
||||
+ this.interactResult = event.useItemInHand() == Event.Result.DENY;
|
||||
+ this.interactPosition = blockposition.immutable();
|
||||
@@ -428,7 +429,7 @@
|
||||
if (itileinventory != null) {
|
||||
player.openMenu(itileinventory);
|
||||
return InteractionResult.CONSUME;
|
||||
@@ -359,7 +591,7 @@
|
||||
@@ -359,7 +592,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user