Fix InventoryOpenEvent cancellation

This commit is contained in:
Tamion
2024-08-19 18:05:26 +02:00
parent be5187c2da
commit 2742ad6a9a
23 changed files with 325 additions and 64 deletions

View File

@@ -374,7 +374,7 @@
}
}
}
@@ -321,15 +514,61 @@
@@ -321,17 +514,62 @@
}
}
@@ -397,6 +397,8 @@
+ cancelledBlock = !(itileinventory instanceof MenuProvider);
+ }
- if (itileinventory != null) {
- player.openMenu(itileinventory);
+ if (player.getCooldowns().isOnCooldown(stack)) {
+ cancelledItem = true; // Paper - correctly handle items on cooldown
+ }
@@ -433,10 +435,11 @@
+ } else if (this.gameModeForPlayer == GameType.SPECTATOR) {
+ MenuProvider itileinventory = iblockdata.getMenuProvider(world, blockposition);
+
if (itileinventory != null) {
player.openMenu(itileinventory);
+ if (itileinventory != null && player.openMenu(itileinventory).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
return InteractionResult.CONSUME;
@@ -359,7 +598,7 @@
} else {
return InteractionResult.PASS;
@@ -359,7 +597,7 @@
}
}