Fixed bug where EC closes if another player is still inside

This commit is contained in:
2025-04-11 14:17:14 +02:00
parent 168f916baa
commit c7722115ed
2 changed files with 6 additions and 2 deletions

View File

@ -113,7 +113,6 @@ public class SharedEnderChest implements ServerLifecycleEvents.ServerStopping, S
} }
public static void openSharedEnderChest(PlayerEntity player, World world, BlockPos pos) { public static void openSharedEnderChest(PlayerEntity player, World world, BlockPos pos) {
playEnderChestOpenSound(world, pos);
fakeEnderChestOpen(world, pos, true); fakeEnderChestOpen(world, pos, true);
sharedInventory.openedEnderChests.put(player, pos); sharedInventory.openedEnderChests.put(player, pos);
player.openHandledScreen(new SimpleNamedScreenHandlerFactory((int_1, playerInventory, playerEntity) -> player.openHandledScreen(new SimpleNamedScreenHandlerFactory((int_1, playerInventory, playerEntity) ->
@ -133,6 +132,10 @@ public class SharedEnderChest implements ServerLifecycleEvents.ServerStopping, S
return; return;
} }
if(open)
playEnderChestOpenSound(world, pos);
else
playEnderChestCloseSound(world, pos);
world.addSyncedBlockEvent(pos, Blocks.ENDER_CHEST, 1, open ? 1 : 0); world.addSyncedBlockEvent(pos, Blocks.ENDER_CHEST, 1, open ? 1 : 0);
} }

View File

@ -89,7 +89,8 @@ public class SharedInventory implements Inventory {
@Override @Override
public void onClose(PlayerEntity player) { public void onClose(PlayerEntity player) {
BlockPos pos = openedEnderChests.remove(player); BlockPos pos = openedEnderChests.remove(player);
if(openedEnderChests.containsValue(pos))
return;
SharedEnderChest.fakeEnderChestOpen(player.getWorld(), pos, false); SharedEnderChest.fakeEnderChestOpen(player.getWorld(), pos, false);
SharedEnderChest.playEnderChestCloseSound(player.getWorld(), pos);
} }
} }