The chest and barrel close animation doesn't occur while player in spectator gamemode is viewing chest contents.
Steps to reproduce:
Get a player to open a chest.
Open the same chest while in spectator.
Have them close the chest.
The chest remains open until exited by the spectator.
Linked issues
is duplicated by 3
Attachments
Comments 6
Maybe it isn't a heavy bug, but don't you think it shouldn't look like that? Spectator mode is for not being noticed by players in other gamemodes, so in my opinion it is a little bug.
Can confirm in a vanilla environment, this also occurs with barrels. Copied over steps to reproduce from MC-234928.
This bug does not affect shulker boxes (another container with an opening/closing animation).
There is a difference in Minecraft's code (simplified) between the affected containers (chests and barrels) and shulker boxes:
Affected containers:
useWithoutItem(Level, Player, /*...*/) {
if (Level.isClientSide) {
return SUCCESS; // player opened the container
} else {
//...
}
}
Shulker box (unaffected):
useWithoutItem(Level, Player, /*...*/) {
if (Level.isClientSide) {
return SUCCESS; // player opened the container
} else if (Player.isSpectator()) {
return CONSUME; // player is in spectator mode, so they didn't actually open the container
} else {
//...
}
}
Shulker boxes have the following code (simplified) that checks if they are in spectator mode and removes the interaction while the affected containers do not:
else if (Player.isSpectator()) {
return CONSUME;
}
Potential Fix: Adding the code that I highlighted from the shulker box to the affected containers' code might fix the bug.
This is not a bug. Spectators can look inside of containers without opening them. This is the same for barrels, shulker boxes, and even mods (like Quark) follow this rule.