"minecraft.custom:minecraft.open_<LOCKABLE_BLOCK>" and "minecraft.custom:minecraft.inspect_<LOCKABLE_BLOCK>" incorrectly increase when attempting to open or inspect locked blocks
The Bug:
"minecraft.custom:minecraft.open_<LOCKABLE_BLOCK>" and "minecraft.custom:minecraft.inspect_<LOCKABLE_BLOCK>" incorrectly increase when attempting to open or inspect locked blocks.
Steps to Reproduce:
- Create a scoreboard objective for tracking when you open a chest and set it to display on the sidebar by using the commands provided below.
/scoreboard objectives add OpenChest minecraft.custom:minecraft.open_chest
/scoreboard objectives setdisplay sidebar OpenChest
- Place down a chest, open it, and take note of how the scoreboard correctly increases.
- Summon a locked chest by using the command provided below.
/setblock ~ ~ ~ minecraft:chest{lock:{components:{"minecraft:custom_name":'"Mojira"'}}} - Attempt to open it.
- Take note as to whether or not "minecraft.custom:minecraft.open_<LOCKABLE_BLOCK>" and "minecraft.custom:minecraft.inspect_<LOCKABLE_BLOCK>" incorrectly increase when attempting to open or inspect locked blocks.
Observed Behavior:
The scoreboard incorrectly increases.
Expected Behavior:
The scoreboard would not increase.
Code Analysis:
Code analysis by [Mod] Avoma can be found below.
The following is based on a decompiled version of Minecraft 1.18.2 using MCP-Reborn.
public class ChestBlock extends AbstractChestBlock<ChestBlockEntity> implements SimpleWaterloggedBlock { ... public InteractionResult use(BlockState $bs, Level $l, BlockPos $bp, Player $p, InteractionHand $ih, BlockHitResult $bhr) { if ($l.isClientSide) { return InteractionResult.SUCCESS; } else { MenuProvider menuprovider = this.getMenuProvider($bs, $l, $bp); if (menuprovider != null) { $p.openMenu(menuprovider); $p.awardStat(this.getOpenChestStat()); PiglinAi.angerNearbyPiglins($p, true); } return InteractionResult.CONSUME; } } ...
If we look at the above class, we can see that no checks are carried out the see whether or not the desired chest contains a lock when attempting to open it, before awarding the appropriate statistic. The awardStat() method will always be called when the chest is right-clicked on, regardless of whether or not it has a lock, resulting in this issue occurring.
Linked Issues
is duplicated by1
- Unresolved
[Mod] AvomaJoseph Smith
- 16
- 7
- Confirmed
Low
- Platform
- Statistics
1.8.2-pre1 - 1.21.4
1.8.2-pre1 1.8.8 15w47c 1.10.2 16w43a 1.11.2 17w06a 1.12.1 18w03b 1.13.1 1.15.2 20w13b 20w15a 1.16-pre5 1.16.2 1.16.4 20w46a 20w48a 21w03a 1.16.5 21w05b 21w06a 21w11a 21w14a 21w17a 1.17.1 21w38a 21w39a 21w40a 21w42a 1.18-pre1 1.18-pre7 1.18 1.18.1 22w05a 1.18.2-rc1 1.18.2 22w17a 22w18a 1.19 1.19.2 22w43a 1.19.3 23w05a 23w06a 1.19.4 1.20 1.20.1 1.20.4 23w51b 24w11a 24w19b 1.21 1.21.4
Created Issue:
Chests Opened Statistic Bug
When a player tries to open a chest but can't because it is locked, their "Chests Opened" statistic still goes up even if it doesn't open.
If you want to test it yourself than place a chest and edit it's block data to set a lock on it. Then check your statistics and look at the "Chests Opened" statistic. Try to open the chest without the key and check your statistics again. You will see that the "Chests Opened" statistic has gone up.
P.S This might apply to anything else that can be locked as well.
Environment
Mac OSX
Chests Opened Statistic BugAttempting to interact with "locked" blocks counts as a successful try in the statistics
Attempting to interact with "locked" blockscounts as a successful tryin the statisticsAttempting to interact with "locked" blocks increases "Chests Opened" in the statistics
When a player tries to open a chest but can't because it is locked, their "Chests Opened" statistic still goes up even if it doesn't open.
If you want to test it yourself than place a chest and edit it's block data to set a lock on it. Then check your statistics and look at the "Chests Opened" statistic. Try to open the chest without the key and check your statistics again. You will see that the "Chests Opened" statistic has gone up.
P.S This might apply to anything else that can be locked as well.
The bug
When a player tries to open a chest but can't because it is locked, their "Chests Opened" statistic still goes up even if it doesn't open.
P.S. This might apply to anything else that can be locked as well.How to reproduce
- Run these commands:
/scoreboard objectives add openchest minecraft.custom:minecraft.open_chest "OpenChests" /scoreboard objectives setdisplay sidebar openchest /scoreboard players set @p openchest 0- Open a chest that is not locked
→Your score went up by 1
- Place a locked chest with /setblock ~ ~ ~ chest{Lock:"Lock"}
- Open the locked chest
→Your score went up by 1 despite the fact that the chest is locked
Mac OSX
The bug
When a player tries to open a chest but can't because it is locked, their "Chests Opened" statistic still goes up even if it doesn't open.
P.S. This might apply to anything else that can be locked as well.How to reproduce
- Run these commands:
/scoreboard objectives add openchest minecraft.custom:minecraft.open_chest "OpenChests" /scoreboard objectives setdisplay sidebar openchest /scoreboard players set @p openchest 0- Open a chest that is not locked
→Your score went up by 1
- Place a locked chest with /setblock ~ ~ ~ chest{Lock:"Lock"}
- Open the locked chest
→Your score went up by 1 despite the fact that the chest is locked
The bug
When a player tries to open a chest but can't because it is locked, their "Chests Opened" statistic still goes up even if it doesn't open.
P.S. This might apply to anything else that can be locked as well.How to reproduce
- Run these commands:
/scoreboard objectives add openchest minecraft.custom:minecraft.open_chest "OpenChests" /scoreboard objectives setdisplay sidebar openchest /scoreboard players set @p openchest 0- Open a chest that is not locked
→Your score went up by 1
- Place a locked chest with /setblock ~ ~ ~ chest{Lock:"Lock"}
- Open the locked chest
→Your score went up by 1 despite the fact that the chest is locked
The Bug:
minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK incorrectly increase when attempting to open or inspect locked blocks.
Steps to Reproduce:
- Create a scoreboard objective for tracking when you open a chest and set it to display on the sidebar.
/scoreboard objectives add OpenChest minecraft.custom:minecraft.open_chest /scoreboard objectives setdisplay sidebar OpenChest
- Place down a chest and open it.
- →
Notice how the scoreboard increases.
- Place down a locked chest through the use of the following command.
/setblock ~ ~ ~ minecraft:chest{Lock:"Lock"}
- Attempt to open it.
- →
Notice how the scoreboard increases again despite not actually being able to open the locked chest.
Information:
Here is a table of all scoreboard objectives affected by this issue.
Scoreboard Objective minecraft.custom:minecraft.inspect_dispenser minecraft.custom:minecraft.inspect_dropper minecraft.custom:minecraft.inspect_hopper minecraft.custom:minecraft.open_barrel minecraft.custom:minecraft.open_chest minecraft.custom:minecraft.open_shulker_box
Attempting to interact with "locked" blocks increases "Chests Opened"in the statisticsminecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK incorrectly increase when attempting to open or inspect locked blocks
The Bug:
minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK incorrectly increase when attempting to open or inspect locked blocks.
Steps to Reproduce:
- Create a scoreboard objective for tracking when you open a chest and set it to display on the sidebar.
/scoreboard objectives add OpenChest minecraft.custom:minecraft.open_chest /scoreboard objectives setdisplay sidebar OpenChest
- Place down a chest and open it.
- →
Notice how the scoreboard increases.
- Place down a locked chest through the use of the following command.
/setblock ~ ~ ~ minecraft:chest{Lock:"Lock"}
- Attempt to open it.
- →
Notice how the scoreboard increases again despite not actually being able to open the locked chest.
Information:
Here is a table of all scoreboard objectives affected by this issue.
Scoreboard Objective minecraft.custom:minecraft.inspect_dispenser minecraft.custom:minecraft.inspect_dropper minecraft.custom:minecraft.inspect_hopper minecraft.custom:minecraft.open_barrel minecraft.custom:minecraft.open_chest minecraft.custom:minecraft.open_shulker_box The Bug:
minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK incorrectly increase when attempting to open or inspect locked blocks.
Steps to Reproduce:
- Create a scoreboard objective for tracking when you open a chest and set it to display on the sidebar.
/scoreboard objectives add OpenChest minecraft.custom:minecraft.open_chest /scoreboard objectives setdisplay sidebar OpenChest
- Place down a chest and open it.
- →
Notice how the scoreboard increases.
- Place down a locked chest through the use of the following command.
/setblock ~ ~ ~ minecraft:chest{Lock:"Lock"}
- Attempt to open it.
- →
Notice how the scoreboard increases again despite not actually being able to open the locked chest.
Information:
Here is a table of all scoreboard objectives affected by this issue.
Scoreboard Objective minecraft.custom:minecraft.inspect_dispenser minecraft.custom:minecraft.inspect_dropper minecraft.custom:minecraft.inspect_hopper minecraft.custom:minecraft.open_barrel minecraft.custom:minecraft.open_chest minecraft.custom:minecraft.open_shulker_box
The Bug:
minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK incorrectly increase when attempting to open or inspect locked blocks.
Steps to Reproduce:
- Create a scoreboard objective for tracking when you open a chest and set it to display on the sidebar.
/scoreboard objectives add OpenChest minecraft.custom:minecraft.open_chest /scoreboard objectives setdisplay sidebar OpenChest
- Place down a chest and open it.
- →
Notice how the scoreboard increases.
- Place down a locked chest through the use of the following command.
/setblock ~ ~ ~ minecraft:chest{Lock:"Lock"}
- Attempt to open it.
- →
Notice how the scoreboard increases again despite not actually being able to open the locked chest.
Expected Behavior:
The expected behavior would be that minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK would not increase when attempting to open or inspect locked blocks.
Information:
Here is a table of all scoreboard objectives affected by this issue.
Scoreboard Objective minecraft.custom:minecraft.inspect_dispenser minecraft.custom:minecraft.inspect_dropper minecraft.custom:minecraft.inspect_hopper minecraft.custom:minecraft.open_barrel minecraft.custom:minecraft.open_chest minecraft.custom:minecraft.open_shulker_box
The Bug:
minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK incorrectly increase when attempting to open or inspect locked blocks.
Steps to Reproduce:
- Create a scoreboard objective for tracking when you open a chest and set it to display on the sidebar.
/scoreboard objectives add OpenChest minecraft.custom:minecraft.open_chest /scoreboard objectives setdisplay sidebar OpenChest
- Place down a chest and open it.
- →
Notice how the scoreboard increases.
- Place down a locked chest through the use of the following command.
/setblock ~ ~ ~ minecraft:chest{Lock:"Lock"}
- Attempt to open it.
- →
Notice how the scoreboard increases again despite not actually being able to open the locked chest.
Expected Behavior:
The expected behavior would be thatminecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCKwould notincrease when attempting to open or inspect locked blocks.Information:
Here is a table of all scoreboard objectives affected by this issue.
Scoreboard Objective minecraft.custom:minecraft.inspect_dispenser minecraft.custom:minecraft.inspect_dropper minecraft.custom:minecraft.inspect_hopper minecraft.custom:minecraft.open_barrel minecraft.custom:minecraft.open_chest minecraft.custom:minecraft.open_shulker_box The Bug:
minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK incorrectly increase when attempting to open or inspect locked blocks.
Steps to Reproduce:
- Create a scoreboard objective for tracking when you open a chest and set it to display on the sidebar.
/scoreboard objectives add OpenChest minecraft.custom:minecraft.open_chest /scoreboard objectives setdisplay sidebar OpenChest
- Place down a chest and open it.
- →
Notice how the scoreboard increases.
- Place down a locked chest through the use of the following command.
/setblock ~ ~ ~ minecraft:chest{Lock:"Lock"}
- Attempt to open it.
- →
Notice how the scoreboard increases again despite not actually being able to open the locked chest.
Observed Behavior:
minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK incorrectly increase when attempting to open or inspect locked blocks.
Expected Behavior:
minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK would not increase when attempting to open or inspect locked blocks.
Information:
Here is a table of all scoreboard objectives affected by this issue.
Scoreboard Objective minecraft.custom:minecraft.inspect_dispenser minecraft.custom:minecraft.inspect_dropper minecraft.custom:minecraft.inspect_hopper minecraft.custom:minecraft.open_barrel minecraft.custom:minecraft.open_chest minecraft.custom:minecraft.open_shulker_box
The Bug:
minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK incorrectly increase when attempting to open or inspect locked blocks.
Steps to Reproduce:
- Create a scoreboard objective for tracking when you open a chest and set it to display on the sidebar.
/scoreboard objectives add OpenChest minecraft.custom:minecraft.open_chest /scoreboard objectives setdisplay sidebar OpenChest
- Place down a chest and open it.
- →
Notice how the scoreboard increases.
- Place down a locked chest through the use of the following command.
/setblock ~ ~ ~ minecraft:chest{Lock:"Lock"}
- Attempt to open it.
- →
Notice how the scoreboard increases again despite not actually being able to open the locked chest.
Observed Behavior:
minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK incorrectly increase when attempting to open or inspect locked blocks.
Expected Behavior:
minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK would not increase when attempting to open or inspect locked blocks.
Information:
Here is a table of all scoreboard objectives affected by this issue.
Scoreboard Objective minecraft.custom:minecraft.inspect_dispenser minecraft.custom:minecraft.inspect_dropper minecraft.custom:minecraft.inspect_hopper minecraft.custom:minecraft.open_barrel minecraft.custom:minecraft.open_chest minecraft.custom:minecraft.open_shulker_box The Bug:
minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK incorrectly increase when attempting to open or inspect locked blocks.
Steps to Reproduce:
- Create a scoreboard objective for tracking when you open a chest and set it to display on the sidebar.
/scoreboard objectives add OpenChest minecraft.custom:minecraft.open_chest /scoreboard objectives setdisplay sidebar OpenChest
- Place down a chest and open it.
- →
Notice how the scoreboard increases.
- Place down a locked chest through the use of the following command.
/setblock ~ ~ ~ minecraft:chest{Lock:"Lock"}
- Attempt to open it.
- →
Notice how the scoreboard increases again despite not actually being able to open the locked chest.
Observed Behavior:
minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK incorrectly increase when attempting to open or inspect locked blocks.
Expected Behavior:
minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK would not increase when attempting to open or inspect locked blocks.
Information:
Here is a table of all scoreboard objectives affected by this issue.
Scoreboard Objective minecraft.custom:minecraft.inspect_dispenser minecraft.custom:minecraft.inspect_dropper minecraft.custom:minecraft.inspect_hopper minecraft.custom:minecraft.open_barrel minecraft.custom:minecraft.open_chest minecraft.custom:minecraft.open_shulker_box
The Bug:
minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK incorrectly increase when attempting to open or inspect locked blocks.
Steps to Reproduce:
- Create a scoreboard objective for tracking when you open a chest and set it to display on the sidebar.
/scoreboard objectives add OpenChest minecraft.custom:minecraft.open_chest /scoreboard objectives setdisplay sidebar OpenChest
- Place down a chest and open it.
- →
Notice how the scoreboard increases.
- Place down a locked chest through the use of the following command.
/setblock ~ ~ ~ minecraft:chest{Lock:"Lock"}
- Attempt to open it.
- →
Notice how the scoreboard increases again despite not actually being able to open the locked chest.
Observed Behavior:
minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK incorrectly increase when attempting to open or inspect locked blocks.
Expected Behavior:
minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK would not increase when attempting to open or inspect locked blocks.
Information:
Here is a table of all scoreboard objectives affected by this issue.
Scoreboard Objective minecraft.custom:minecraft.inspect_dispenser minecraft.custom:minecraft.inspect_dropper minecraft.custom:minecraft.inspect_hopper minecraft.custom:minecraft.open_barrel minecraft.custom:minecraft.open_chest minecraft.custom:minecraft.open_shulker_box The Bug:
minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK incorrectly increase when attempting to open or inspect locked blocks.
Steps to Reproduce:
- Create a scoreboard objective for tracking when you open a chest and set it to display on the sidebar.
/scoreboard objectives add OpenChest minecraft.custom:minecraft.open_chest /scoreboard objectives setdisplay sidebar OpenChest
- Place down a chest and open it.
- →
Notice how the scoreboard increases.
- Place down a locked chest through the use of the following command.
/setblock ~ ~ ~ minecraft:chest{Lock:"Lock"}
- Attempt to open it.
- Take note as to whether or not minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK incorrectly increase when attempting to open or inspect locked blocks.
Observed Behavior:
The scoreboard incorrectly increases.
Expected Behavior:
The scoreboard would not increase.
Code Analysis:
Code analysis by [Mod] Avoma can be found below.
The following is based on a decompiled version of Minecraft 1.18.2 using MCP-Reborn.
net.minecraft.world.level.block.ChestBlock.javapublic class ChestBlock extends AbstractChestBlock<ChestBlockEntity> implements SimpleWaterloggedBlock { ... public InteractionResult use(BlockState $bs, Level $l, BlockPos $bp, Player $p, InteractionHand $ih, BlockHitResult $bhr) { if ($l.isClientSide) { return InteractionResult.SUCCESS; } else { MenuProvider menuprovider = this.getMenuProvider($bs, $l, $bp); if (menuprovider != null) { $p.openMenu(menuprovider); $p.awardStat(this.getOpenChestStat()); PiglinAi.angerNearbyPiglins($p, true); } return InteractionResult.CONSUME; } } ...If we look at the above class, we can see that no checks are carried out the see whether or not the desired chest contains a lock when attempting to open it, before awarding the appropriate statistic. The awardStat() method will always be called when the chest is right-clicked on, regardless of whether or not it has a lock, resulting in this issue occurring.
The Bug:
minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK incorrectly increase when attempting to open or inspect locked blocks.
Steps to Reproduce:
- Create a scoreboard objective for tracking when you open a chest and set it to display on the sidebar.
/scoreboard objectives add OpenChest minecraft.custom:minecraft.open_chest /scoreboard objectives setdisplay sidebar OpenChest
- Place down a chest and open it.
→Notice how the scoreboard increases.
- Place down a
locked chest through the use of the following command. /setblock ~ ~ ~ minecraft:chest{Lock:"Lock"}
- Attempt to open it.
- Take note as to whether or not minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK incorrectly increase when attempting to open or inspect locked blocks.
Observed Behavior:
The scoreboard incorrectly increases.
Expected Behavior:
The scoreboard would not increase.
Code Analysis:
Code analysis by [Mod] Avoma can be found below.
The following is based on a decompiled version of Minecraft 1.18.2 using MCP-Reborn.
net.minecraft.world.level.block.ChestBlock.javapublic class ChestBlock extends AbstractChestBlock<ChestBlockEntity> implements SimpleWaterloggedBlock { ... public InteractionResult use(BlockState $bs, Level $l, BlockPos $bp, Player $p, InteractionHand $ih, BlockHitResult $bhr) { if ($l.isClientSide) { return InteractionResult.SUCCESS; } else { MenuProvider menuprovider = this.getMenuProvider($bs, $l, $bp); if (menuprovider != null) { $p.openMenu(menuprovider); $p.awardStat(this.getOpenChestStat()); PiglinAi.angerNearbyPiglins($p, true); } return InteractionResult.CONSUME; } } ...If we look at the above class, we can see that no checks are carried out the see whether or not the desired chest contains a lock when attempting to open it, before awarding the appropriate statistic. The awardStat() method will always be called when the chest is right-clicked on, regardless of whether or not it has a lock, resulting in this issue occurring.
The Bug:
minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK incorrectly increase when attempting to open or inspect locked blocks.
Steps to Reproduce:
- Create a scoreboard objective for tracking when you open a chest and set it to display on the sidebar by using the commands provided below.
/scoreboard objectives add OpenChest minecraft.custom:minecraft.open_chest/scoreboard objectives setdisplay sidebar OpenChest- Place down a chest, open it, and take note of how the scoreboard correctly increases.
- Summon a locked chest by using the command provided below.
/setblock ~ ~ ~ minecraft:chest{Lock:"Lock"}- Attempt to open it.
- Take note as to whether or not minecraft.custom:minecraft.open_LOCKABLE_BLOCK and minecraft.custom:minecraft.inspect_LOCKABLE_BLOCK incorrectly increase when attempting to open or inspect locked blocks.
Observed Behavior:
The scoreboard incorrectly increases.
Expected Behavior:
The scoreboard would not increase.
Code Analysis:
Code analysis by [Mod] Avoma can be found below.
The following is based on a decompiled version of Minecraft 1.18.2 using MCP-Reborn.
net.minecraft.world.level.block.ChestBlock.javapublic class ChestBlock extends AbstractChestBlock<ChestBlockEntity> implements SimpleWaterloggedBlock { ... public InteractionResult use(BlockState $bs, Level $l, BlockPos $bp, Player $p, InteractionHand $ih, BlockHitResult $bhr) { if ($l.isClientSide) { return InteractionResult.SUCCESS; } else { MenuProvider menuprovider = this.getMenuProvider($bs, $l, $bp); if (menuprovider != null) { $p.openMenu(menuprovider); $p.awardStat(this.getOpenChestStat()); PiglinAi.angerNearbyPiglins($p, true); } return InteractionResult.CONSUME; } } ...If we look at the above class, we can see that no checks are carried out the see whether or not the desired chest contains a lock when attempting to open it, before awarding the appropriate statistic. The awardStat() method will always be called when the chest is right-clicked on, regardless of whether or not it has a lock, resulting in this issue occurring.
The Bug:
"minecraft.custom:minecraft.open_<LOCKABLE_BLOCK>" and "minecraft.custom:minecraft.inspect_<LOCKABLE_BLOCK>" incorrectly increase when attempting to open or inspect locked blocks.
Steps to Reproduce:
- Create a scoreboard objective for tracking when you open a chest and set it to display on the sidebar by using the commands provided below.
/scoreboard objectives add OpenChest minecraft.custom:minecraft.open_chest/scoreboard objectives setdisplay sidebar OpenChest- Place down a chest, open it, and take note of how the scoreboard correctly increases.
- Summon a locked chest by using the command provided below.
/setblock ~ ~ ~ minecraft:chest{Lock:"Lock"}- Attempt to open it.
- Take note as to whether or not "minecraft.custom:minecraft.open_<LOCKABLE_BLOCK>" and "minecraft.custom:minecraft.inspect_<LOCKABLE_BLOCK>" incorrectly increase when attempting to open or inspect locked blocks.
Observed Behavior:
The scoreboard incorrectly increases.
Expected Behavior:
The scoreboard would not increase.
Code Analysis:
Code analysis by [Mod] Avoma can be found below.
The following is based on a decompiled version of Minecraft 1.18.2 using MCP-Reborn.
net.minecraft.world.level.block.ChestBlock.javapublic class ChestBlock extends AbstractChestBlock<ChestBlockEntity> implements SimpleWaterloggedBlock { ... public InteractionResult use(BlockState $bs, Level $l, BlockPos $bp, Player $p, InteractionHand $ih, BlockHitResult $bhr) { if ($l.isClientSide) { return InteractionResult.SUCCESS; } else { MenuProvider menuprovider = this.getMenuProvider($bs, $l, $bp); if (menuprovider != null) { $p.openMenu(menuprovider); $p.awardStat(this.getOpenChestStat()); PiglinAi.angerNearbyPiglins($p, true); } return InteractionResult.CONSUME; } } ...If we look at the above class, we can see that no checks are carried out the see whether or not the desired chest contains a lock when attempting to open it, before awarding the appropriate statistic. The awardStat() method will always be called when the chest is right-clicked on, regardless of whether or not it has a lock, resulting in this issue occurring.
"minecraft.custom:minecraft.open_<LOCKABLE_BLOCK>" and "minecraft.custom:minecraft.inspect_<LOCKABLE_BLOCK>" incorrectly increase when attempting to open or inspect locked blocks
is duplicated by
The Bug:
"minecraft.custom:minecraft.open_<LOCKABLE_BLOCK>" and "minecraft.custom:minecraft.inspect_<LOCKABLE_BLOCK>" incorrectly increase when attempting to open or inspect locked blocks.
Steps to Reproduce:
- Create a scoreboard objective for tracking when you open a chest and set it to display on the sidebar by using the commands provided below.
/scoreboard objectives add OpenChest minecraft.custom:minecraft.open_chest/scoreboard objectives setdisplay sidebar OpenChest- Place down a chest, open it, and take note of how the scoreboard correctly increases.
- Summon a locked chest by using the command provided below.
/setblock ~ ~ ~ minecraft:chest{Lock:"Lock"}- Attempt to open it.
- Take note as to whether or not "minecraft.custom:minecraft.open_<LOCKABLE_BLOCK>" and "minecraft.custom:minecraft.inspect_<LOCKABLE_BLOCK>" incorrectly increase when attempting to open or inspect locked blocks.
Observed Behavior:
The scoreboard incorrectly increases.
Expected Behavior:
The scoreboard would not increase.
Code Analysis:
Code analysis by [Mod] Avoma can be found below.
The following is based on a decompiled version of Minecraft 1.18.2 using MCP-Reborn.
net.minecraft.world.level.block.ChestBlock.javapublic class ChestBlock extends AbstractChestBlock<ChestBlockEntity> implements SimpleWaterloggedBlock { ... public InteractionResult use(BlockState $bs, Level $l, BlockPos $bp, Player $p, InteractionHand $ih, BlockHitResult $bhr) { if ($l.isClientSide) { return InteractionResult.SUCCESS; } else { MenuProvider menuprovider = this.getMenuProvider($bs, $l, $bp); if (menuprovider != null) { $p.openMenu(menuprovider); $p.awardStat(this.getOpenChestStat()); PiglinAi.angerNearbyPiglins($p, true); } return InteractionResult.CONSUME; } } ...If we look at the above class, we can see that no checks are carried out the see whether or not the desired chest contains a lock when attempting to open it, before awarding the appropriate statistic. The awardStat() method will always be called when the chest is right-clicked on, regardless of whether or not it has a lock, resulting in this issue occurring.
The Bug:
"minecraft.custom:minecraft.open_<LOCKABLE_BLOCK>" and "minecraft.custom:minecraft.inspect_<LOCKABLE_BLOCK>" incorrectly increase when attempting to open or inspect locked blocks.
Steps to Reproduce:
- Create a scoreboard objective for tracking when you open a chest and set it to display on the sidebar by using the commands provided below.
/scoreboard objectives add OpenChest minecraft.custom:minecraft.open_chest/scoreboard objectives setdisplay sidebar OpenChest- Place down a chest, open it, and take note of how the scoreboard correctly increases.
- Summon a locked chest by using the command provided below.
/setblock ~ ~ ~ minecraft:chest{lock:{components:{"minecraft:custom_name":'"Mojira"'}}}- Attempt to open it.
- Take note as to whether or not "minecraft.custom:minecraft.open_<LOCKABLE_BLOCK>" and "minecraft.custom:minecraft.inspect_<LOCKABLE_BLOCK>" incorrectly increase when attempting to open or inspect locked blocks.
Observed Behavior:
The scoreboard incorrectly increases.
Expected Behavior:
The scoreboard would not increase.
Code Analysis:
Code analysis by [Mod] Avoma can be found below.
The following is based on a decompiled version of Minecraft 1.18.2 using MCP-Reborn.
net.minecraft.world.level.block.ChestBlock.javapublic class ChestBlock extends AbstractChestBlock<ChestBlockEntity> implements SimpleWaterloggedBlock { ... public InteractionResult use(BlockState $bs, Level $l, BlockPos $bp, Player $p, InteractionHand $ih, BlockHitResult $bhr) { if ($l.isClientSide) { return InteractionResult.SUCCESS; } else { MenuProvider menuprovider = this.getMenuProvider($bs, $l, $bp); if (menuprovider != null) { $p.openMenu(menuprovider); $p.awardStat(this.getOpenChestStat()); PiglinAi.angerNearbyPiglins($p, true); } return InteractionResult.CONSUME; } } ...If we look at the above class, we can see that no checks are carried out the see whether or not the desired chest contains a lock when attempting to open it, before awarding the appropriate statistic. The awardStat() method will always be called when the chest is right-clicked on, regardless of whether or not it has a lock, resulting in this issue occurring.
Thank you for your report!
We're actually already tracking this issue in MC-75532, so this ticket is being resolved and linked as a duplicate.
If you would like to add a vote or any additional information to the main ticket it would be appreciated.
Please be sure to use the search feature before creating a ticket to see if the issue has already been reported.
Quick Links:
📓 Bug Tracker Guidelines – 🛠 Community Support – 📧 Mojang Support – ✍️ Feedback and Suggestions – 💬 Mojira Discord

Can confirm for MC 1.12.1.
A chest lock can be set using the following command.
/blockdata ~ ~ ~ {Lock:"Lock"}This bug still occurs in 1.14, and 1.15, and 1.15.1. Mojang PLEASE fix this bug, it makes no sense for something like this to be postponed for so many versions. This hinders our ability to map make; we shouldn't have to be making workarounds to bugs that are supposed to get fixed within a reasonable time frame. Five years of not fixing this is unacceptable in my opinion. I'd like to see this get fixed in 1.16.
Confirmed in 20w13b
Confirmed in 20w15a
Confirmed in 1.16-pre5.
Confirmed in 20w48a
Can confirm in 21w03a.
Can confirm in 21w05b.
Can confirm in 21w06a
Can confirm in 1.16.5 and 21w11a. Video attached.
Can confirm in 21w14a.
Can confirm in 21w17a.
Can confirm in 1.17.1.
I'd like to request ownership of this ticket since the current reporter has been inactive since December 2014. I'm willing to provide all of the necessary information and will keep this report updated.
This isn't just the case with the minecraft.custom:minecraft.open_chest. This also affects other scoreboard objectives. I've updated this ticket accordingly to reflect this information.