2024-08-31 20:50:24 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tamion <70228790+notTamion@users.noreply.github.com>
Date: Mon, 19 Aug 2024 18:05:26 +0200
Subject: [PATCH] Fix InventoryOpenEvent cancellation
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
2024-10-25 00:08:35 +02:00
@@ -0,0 +0,0 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player {
2024-08-31 20:50:24 +02:00
} else if (factory instanceof ChestBlock.DoubleInventory) {
// SPIGOT-5355 - double chests too :(
((ChestBlock.DoubleInventory) factory).inventorylargechest.stopOpen(this);
+ // Paper start - Fix InventoryOpenEvent cancellation
+ } else if (!this.enderChestInventory.isActiveChest(null)) {
+ this.enderChestInventory.stopOpen(this);
+ // Paper end - Fix InventoryOpenEvent cancellation
}
return OptionalInt.empty();
}
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -0,0 +0,0 @@ public class ServerPlayerGameMode {
} 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
2024-10-25 00:08:35 +02:00
return InteractionResult.CONSUME;
2024-08-31 20:50:24 +02:00
} else {
return InteractionResult.PASS;
2024-10-25 00:08:35 +02:00
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractChestBoat.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractChestBoat.java
2024-08-31 20:50:24 +02:00
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
2024-10-25 00:08:35 +02:00
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractChestBoat.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractChestBoat.java
@@ -0,0 +0,0 @@ public abstract class AbstractChestBoat extends AbstractBoat implements HasCusto
2024-08-31 20:50:24 +02:00
@Override
public void openCustomInventoryScreen(Player player) {
- player.openMenu(this);
2024-10-25 00:08:35 +02:00
+ // Paper - fix inventory open cancel - moved into below if
Level world = player.level();
- if (world instanceof ServerLevel worldserver) {
+ if (world instanceof ServerLevel worldserver && player.openMenu(this).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
2024-08-31 20:50:24 +02:00
this.gameEvent(GameEvent.CONTAINER_OPEN, player);
2024-10-25 00:08:35 +02:00
PiglinAi.angerNearbyPiglins(worldserver, player, true);
2024-08-31 20:50:24 +02:00
}
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java b/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java
@@ -0,0 +0,0 @@ public interface ContainerEntity extends Container, MenuProvider {
}
default InteractionResult interactWithContainerVehicle(Player player) {
- player.openMenu(this);
+ // Paper start - Fix InventoryOpenEvent cancellation
+ if (player.openMenu(this).isEmpty()) {
+ return InteractionResult.PASS;
+ }
+ // Paper end - Fix InventoryOpenEvent cancellation
2024-10-25 00:08:35 +02:00
return InteractionResult.SUCCESS;
2024-08-31 20:50:24 +02:00
}
diff --git a/src/main/java/net/minecraft/world/level/block/AnvilBlock.java b/src/main/java/net/minecraft/world/level/block/AnvilBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/AnvilBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/AnvilBlock.java
@@ -0,0 +0,0 @@ public class AnvilBlock extends FallingBlock {
2024-10-25 00:08:35 +02:00
@Override
2024-08-31 20:50:24 +02:00
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
2024-10-25 00:08:35 +02:00
if (!world.isClientSide) {
2024-08-31 20:50:24 +02:00
- player.openMenu(state.getMenuProvider(world, pos));
2024-10-25 00:08:35 +02:00
+ if (player.openMenu(state.getMenuProvider(world, pos)).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
2024-08-31 20:50:24 +02:00
player.awardStat(Stats.INTERACT_WITH_ANVIL);
2024-10-25 00:08:35 +02:00
+ } // Paper - Fix InventoryOpenEvent cancellation
2024-08-31 20:50:24 +02:00
}
2024-10-25 00:08:35 +02:00
return InteractionResult.SUCCESS;
2024-08-31 20:50:24 +02:00
diff --git a/src/main/java/net/minecraft/world/level/block/BarrelBlock.java b/src/main/java/net/minecraft/world/level/block/BarrelBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/BarrelBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BarrelBlock.java
@@ -0,0 +0,0 @@ public class BarrelBlock extends BaseEntityBlock {
2024-10-25 00:08:35 +02:00
@Override
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
- if (world instanceof ServerLevel serverLevel && world.getBlockEntity(pos) instanceof BarrelBlockEntity barrelBlockEntity) {
- player.openMenu(barrelBlockEntity);
+ if (world instanceof ServerLevel serverLevel && world.getBlockEntity(pos) instanceof BarrelBlockEntity barrelBlockEntity && player.openMenu(barrelBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.OPEN_BARREL);
PiglinAi.angerNearbyPiglins(serverLevel, player, true);
}
2024-08-31 20:50:24 +02:00
diff --git a/src/main/java/net/minecraft/world/level/block/BeaconBlock.java b/src/main/java/net/minecraft/world/level/block/BeaconBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/BeaconBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BeaconBlock.java
@@ -0,0 +0,0 @@ public class BeaconBlock extends BaseEntityBlock implements BeaconBeamBlock {
2024-10-25 00:08:35 +02:00
@Override
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
- if (!world.isClientSide && world.getBlockEntity(pos) instanceof BeaconBlockEntity beaconBlockEntity) {
- player.openMenu(beaconBlockEntity);
+ if (!world.isClientSide && world.getBlockEntity(pos) instanceof BeaconBlockEntity beaconBlockEntity && player.openMenu(beaconBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.INTERACT_WITH_BEACON);
}
2024-08-31 20:50:24 +02:00
diff --git a/src/main/java/net/minecraft/world/level/block/BlastFurnaceBlock.java b/src/main/java/net/minecraft/world/level/block/BlastFurnaceBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/BlastFurnaceBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BlastFurnaceBlock.java
@@ -0,0 +0,0 @@ public class BlastFurnaceBlock extends AbstractFurnaceBlock {
@Override
protected void openContainer(Level world, BlockPos pos, Player player) {
BlockEntity blockEntity = world.getBlockEntity(pos);
- if (blockEntity instanceof BlastFurnaceBlockEntity) {
- player.openMenu((MenuProvider)blockEntity);
+ if (blockEntity instanceof BlastFurnaceBlockEntity && player.openMenu((MenuProvider)blockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.INTERACT_WITH_BLAST_FURNACE);
}
}
diff --git a/src/main/java/net/minecraft/world/level/block/BrewingStandBlock.java b/src/main/java/net/minecraft/world/level/block/BrewingStandBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/BrewingStandBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BrewingStandBlock.java
@@ -0,0 +0,0 @@ public class BrewingStandBlock extends BaseEntityBlock {
2024-10-25 00:08:35 +02:00
@Override
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
- if (!world.isClientSide && world.getBlockEntity(pos) instanceof BrewingStandBlockEntity brewingStandBlockEntity) {
- player.openMenu(brewingStandBlockEntity);
+ if (!world.isClientSide && world.getBlockEntity(pos) instanceof BrewingStandBlockEntity brewingStandBlockEntity && player.openMenu(brewingStandBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.INTERACT_WITH_BREWINGSTAND);
}
2024-08-31 20:50:24 +02:00
diff --git a/src/main/java/net/minecraft/world/level/block/CartographyTableBlock.java b/src/main/java/net/minecraft/world/level/block/CartographyTableBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/CartographyTableBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/CartographyTableBlock.java
@@ -0,0 +0,0 @@ public class CartographyTableBlock extends Block {
2024-10-25 00:08:35 +02:00
@Override
2024-08-31 20:50:24 +02:00
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
2024-10-25 00:08:35 +02:00
if (!world.isClientSide) {
2024-08-31 20:50:24 +02:00
- player.openMenu(state.getMenuProvider(world, pos));
2024-10-25 00:08:35 +02:00
+ if (player.openMenu(state.getMenuProvider(world, pos)).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
2024-08-31 20:50:24 +02:00
player.awardStat(Stats.INTERACT_WITH_CARTOGRAPHY_TABLE);
2024-10-25 00:08:35 +02:00
+ } // Paper - Fix InventoryOpenEvent cancellation
2024-08-31 20:50:24 +02:00
}
2024-10-25 00:08:35 +02:00
return InteractionResult.SUCCESS;
2024-08-31 20:50:24 +02:00
diff --git a/src/main/java/net/minecraft/world/level/block/ChestBlock.java b/src/main/java/net/minecraft/world/level/block/ChestBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/ChestBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/ChestBlock.java
@@ -0,0 +0,0 @@ public class ChestBlock extends AbstractChestBlock<ChestBlockEntity> implements
2024-10-25 00:08:35 +02:00
if (world instanceof ServerLevel worldserver) {
2024-08-31 20:50:24 +02:00
MenuProvider itileinventory = this.getMenuProvider(state, world, pos);
- if (itileinventory != null) {
- player.openMenu(itileinventory);
+ if (itileinventory != null && player.openMenu(itileinventory).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(this.getOpenChestStat());
2024-10-25 00:08:35 +02:00
PiglinAi.angerNearbyPiglins(worldserver, player, true);
2024-08-31 20:50:24 +02:00
}
diff --git a/src/main/java/net/minecraft/world/level/block/CraftingTableBlock.java b/src/main/java/net/minecraft/world/level/block/CraftingTableBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/CraftingTableBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/CraftingTableBlock.java
@@ -0,0 +0,0 @@ public class CraftingTableBlock extends Block {
2024-10-25 00:08:35 +02:00
@Override
2024-08-31 20:50:24 +02:00
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
2024-10-25 00:08:35 +02:00
if (!world.isClientSide) {
2024-08-31 20:50:24 +02:00
- player.openMenu(state.getMenuProvider(world, pos));
2024-10-25 00:08:35 +02:00
+ if (player.openMenu(state.getMenuProvider(world, pos)).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
2024-08-31 20:50:24 +02:00
player.awardStat(Stats.INTERACT_WITH_CRAFTING_TABLE);
2024-10-25 00:08:35 +02:00
+ } // Paper - Fix InventoryOpenEvent cancellation
2024-08-31 20:50:24 +02:00
}
2024-10-25 00:08:35 +02:00
return InteractionResult.SUCCESS;
2024-08-31 20:50:24 +02:00
diff --git a/src/main/java/net/minecraft/world/level/block/DispenserBlock.java b/src/main/java/net/minecraft/world/level/block/DispenserBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/DispenserBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/DispenserBlock.java
@@ -0,0 +0,0 @@ public class DispenserBlock extends BaseEntityBlock {
2024-10-25 00:08:35 +02:00
if (tileentity instanceof DispenserBlockEntity) {
DispenserBlockEntity tileentitydispenser = (DispenserBlockEntity) tileentity;
- player.openMenu(tileentitydispenser);
+ if (player.openMenu(tileentitydispenser).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(tileentitydispenser instanceof DropperBlockEntity ? Stats.INSPECT_DROPPER : Stats.INSPECT_DISPENSER);
+ } // Paper - Fix InventoryOpenEvent cancellation
}
}
2024-08-31 20:50:24 +02:00
diff --git a/src/main/java/net/minecraft/world/level/block/EnderChestBlock.java b/src/main/java/net/minecraft/world/level/block/EnderChestBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/EnderChestBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/EnderChestBlock.java
@@ -0,0 +0,0 @@ public class EnderChestBlock extends AbstractChestBlock<EnderChestBlockEntity> i
2024-10-25 00:08:35 +02:00
if (world.getBlockState(blockPos).isRedstoneConductor(world, blockPos)) { // Paper - diff on change; make sure that EnderChest#isBlocked uses the same logic
return InteractionResult.SUCCESS;
2024-08-31 20:50:24 +02:00
} else {
2024-10-25 00:08:35 +02:00
- if (world instanceof ServerLevel serverLevel) {
2024-11-18 20:47:52 +01:00
- playerEnderChestContainer.setActiveChest(enderChestBlockEntity);
- player.openMenu(
- new SimpleMenuProvider((i, inventory, playerx) -> ChestMenu.threeRows(i, inventory, playerEnderChestContainer), CONTAINER_TITLE)
- );
2024-10-25 00:08:35 +02:00
+ // Paper start - Fix InventoryOpenEvent cancellation - moved up;
2024-11-18 20:47:52 +01:00
+ playerEnderChestContainer.setActiveChest(enderChestBlockEntity); // Needs to happen before ChestMenu.threeRows as it is required for opening animations
2024-10-25 00:08:35 +02:00
+ if (world instanceof ServerLevel serverLevel && player.openMenu(
+ new SimpleMenuProvider((i, inventory, playerx) -> ChestMenu.threeRows(i, inventory, playerEnderChestContainer), CONTAINER_TITLE)
2024-08-31 20:50:24 +02:00
+ ).isPresent()) {
2024-10-25 00:08:35 +02:00
+ // Paper end - Fix InventoryOpenEvent cancellation - moved up;
+ // Paper - Fix InventoryOpenEvent cancellation - moved up;
player.awardStat(Stats.OPEN_ENDERCHEST);
PiglinAi.angerNearbyPiglins(serverLevel, player, true);
}
2024-08-31 20:50:24 +02:00
diff --git a/src/main/java/net/minecraft/world/level/block/FurnaceBlock.java b/src/main/java/net/minecraft/world/level/block/FurnaceBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/FurnaceBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/FurnaceBlock.java
@@ -0,0 +0,0 @@ public class FurnaceBlock extends AbstractFurnaceBlock {
@Override
protected void openContainer(Level world, BlockPos pos, Player player) {
BlockEntity blockEntity = world.getBlockEntity(pos);
- if (blockEntity instanceof FurnaceBlockEntity) {
- player.openMenu((MenuProvider)blockEntity);
+ if (blockEntity instanceof FurnaceBlockEntity && player.openMenu((MenuProvider)blockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.INTERACT_WITH_FURNACE);
}
}
diff --git a/src/main/java/net/minecraft/world/level/block/GrindstoneBlock.java b/src/main/java/net/minecraft/world/level/block/GrindstoneBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/GrindstoneBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/GrindstoneBlock.java
@@ -0,0 +0,0 @@ public class GrindstoneBlock extends FaceAttachedHorizontalDirectionalBlock {
2024-10-25 00:08:35 +02:00
@Override
2024-08-31 20:50:24 +02:00
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
2024-10-25 00:08:35 +02:00
if (!world.isClientSide) {
2024-08-31 20:50:24 +02:00
- player.openMenu(state.getMenuProvider(world, pos));
2024-10-25 00:08:35 +02:00
+ if (player.openMenu(state.getMenuProvider(world, pos)).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
2024-08-31 20:50:24 +02:00
player.awardStat(Stats.INTERACT_WITH_GRINDSTONE);
2024-10-25 00:08:35 +02:00
+ } // Paper - Fix InventoryOpenEvent cancellation
2024-08-31 20:50:24 +02:00
}
2024-10-25 00:08:35 +02:00
return InteractionResult.SUCCESS;
2024-08-31 20:50:24 +02:00
diff --git a/src/main/java/net/minecraft/world/level/block/HopperBlock.java b/src/main/java/net/minecraft/world/level/block/HopperBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/HopperBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/HopperBlock.java
@@ -0,0 +0,0 @@ public class HopperBlock extends BaseEntityBlock {
2024-10-25 00:08:35 +02:00
@Override
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
- if (!world.isClientSide && world.getBlockEntity(pos) instanceof HopperBlockEntity hopperBlockEntity) {
- player.openMenu(hopperBlockEntity);
+ if (!world.isClientSide && world.getBlockEntity(pos) instanceof HopperBlockEntity hopperBlockEntity && player.openMenu(hopperBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.INSPECT_HOPPER);
}
2024-08-31 20:50:24 +02:00
diff --git a/src/main/java/net/minecraft/world/level/block/LecternBlock.java b/src/main/java/net/minecraft/world/level/block/LecternBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/LecternBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/LecternBlock.java
@@ -0,0 +0,0 @@ public class LecternBlock extends BaseEntityBlock {
private void openScreen(Level world, BlockPos pos, Player player) {
BlockEntity tileentity = world.getBlockEntity(pos);
- if (tileentity instanceof LecternBlockEntity) {
- player.openMenu((LecternBlockEntity) tileentity);
+ if (tileentity instanceof LecternBlockEntity && player.openMenu((LecternBlockEntity) tileentity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.INTERACT_WITH_LECTERN);
}
diff --git a/src/main/java/net/minecraft/world/level/block/LoomBlock.java b/src/main/java/net/minecraft/world/level/block/LoomBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/LoomBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/LoomBlock.java
@@ -0,0 +0,0 @@ public class LoomBlock extends HorizontalDirectionalBlock {
2024-10-25 00:08:35 +02:00
@Override
2024-08-31 20:50:24 +02:00
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
2024-10-25 00:08:35 +02:00
if (!world.isClientSide) {
2024-08-31 20:50:24 +02:00
- player.openMenu(state.getMenuProvider(world, pos));
2024-10-25 00:08:35 +02:00
+ if (player.openMenu(state.getMenuProvider(world, pos)).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
2024-08-31 20:50:24 +02:00
player.awardStat(Stats.INTERACT_WITH_LOOM);
2024-10-25 00:08:35 +02:00
+ } // Paper - Fix InventoryOpenEvent cancellation
2024-08-31 20:50:24 +02:00
}
2024-10-25 00:08:35 +02:00
return InteractionResult.SUCCESS;
2024-08-31 20:50:24 +02:00
diff --git a/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java b/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java
@@ -0,0 +0,0 @@ public class ShulkerBoxBlock extends BaseEntityBlock {
2024-10-25 00:08:35 +02:00
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
if (world instanceof ServerLevel serverLevel
&& world.getBlockEntity(pos) instanceof ShulkerBoxBlockEntity shulkerBoxBlockEntity
- && canOpen(state, world, pos, shulkerBoxBlockEntity)) {
- player.openMenu(shulkerBoxBlockEntity);
+ && canOpen(state, world, pos, shulkerBoxBlockEntity) // Paper - Fix InventoryOpenEvent cancellation - expand if for belows check
+ && player.openMenu(shulkerBoxBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.OPEN_SHULKER_BOX);
PiglinAi.angerNearbyPiglins(serverLevel, player, true);
}
2024-08-31 20:50:24 +02:00
diff --git a/src/main/java/net/minecraft/world/level/block/SmithingTableBlock.java b/src/main/java/net/minecraft/world/level/block/SmithingTableBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/SmithingTableBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/SmithingTableBlock.java
@@ -0,0 +0,0 @@ public class SmithingTableBlock extends CraftingTableBlock {
2024-10-25 00:08:35 +02:00
@Override
2024-08-31 20:50:24 +02:00
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
2024-10-25 00:08:35 +02:00
if (!world.isClientSide) {
2024-08-31 20:50:24 +02:00
- player.openMenu(state.getMenuProvider(world, pos));
2024-10-25 00:08:35 +02:00
+ if (player.openMenu(state.getMenuProvider(world, pos)).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
2024-08-31 20:50:24 +02:00
player.awardStat(Stats.INTERACT_WITH_SMITHING_TABLE);
2024-10-25 00:08:35 +02:00
+ } // Paper - Fix InventoryOpenEvent cancellation
2024-08-31 20:50:24 +02:00
}
2024-10-25 00:08:35 +02:00
return InteractionResult.SUCCESS;
2024-08-31 20:50:24 +02:00
diff --git a/src/main/java/net/minecraft/world/level/block/SmokerBlock.java b/src/main/java/net/minecraft/world/level/block/SmokerBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/SmokerBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/SmokerBlock.java
@@ -0,0 +0,0 @@ public class SmokerBlock extends AbstractFurnaceBlock {
@Override
protected void openContainer(Level world, BlockPos pos, Player player) {
BlockEntity blockEntity = world.getBlockEntity(pos);
- if (blockEntity instanceof SmokerBlockEntity) {
- player.openMenu((MenuProvider)blockEntity);
+ if (blockEntity instanceof SmokerBlockEntity && player.openMenu((MenuProvider)blockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.INTERACT_WITH_SMOKER);
}
}
diff --git a/src/main/java/net/minecraft/world/level/block/StonecutterBlock.java b/src/main/java/net/minecraft/world/level/block/StonecutterBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/StonecutterBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/StonecutterBlock.java
@@ -0,0 +0,0 @@ public class StonecutterBlock extends Block {
2024-10-25 00:08:35 +02:00
@Override
2024-08-31 20:50:24 +02:00
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
2024-10-25 00:08:35 +02:00
if (!world.isClientSide) {
2024-08-31 20:50:24 +02:00
- player.openMenu(state.getMenuProvider(world, pos));
2024-10-25 00:08:35 +02:00
+ if (player.openMenu(state.getMenuProvider(world, pos)).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
2024-08-31 20:50:24 +02:00
player.awardStat(Stats.INTERACT_WITH_STONECUTTER);
2024-10-25 00:08:35 +02:00
+ } // Paper - Fix InventoryOpenEvent cancellation
2024-08-31 20:50:24 +02:00
}
2024-10-25 00:08:35 +02:00
return InteractionResult.SUCCESS;