diff --git a/CHANGELOG.md b/CHANGELOG.md index af32336b6..1d6a75e1a 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Fixed JEI hotkeys not working on fluid filter slots (raoulvdberge) - Fixed crash when opening Crafter Manager with FTB Quests installed (raoulvdberge) - GregTech Community Edition items are now banned from rendering on Refined Storage patterns because they are causing crashes (raoulvdberge) +- Fixed a bug where the container slots weren't synced when opening a Grid (raoulvdberge) ### 1.6.14 - Fixed server crash (raoulvdberge) diff --git a/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/network/grid/GridManager.java b/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/network/grid/GridManager.java index d57bcfd4c..3ee64e171 100644 --- a/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/network/grid/GridManager.java +++ b/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/network/grid/GridManager.java @@ -61,13 +61,25 @@ public class GridManager implements IGridManager { player.getNextWindowId(); player.closeContainer(); + // The order of sending this packet and setting openContainer matters! + + // We first need to send the grid open packet with the window id. + + // Then we set the openContainer so the slots are getting sent (EntityPlayerMP::update -> Container::detectAndSendChanges). + + // If the client window id mismatches with the server window id this causes problems with slots not being set. + // If we would set the openContainer first, the slot packets would be sent first but wouldn't be able to be set + // on the client since the window id would mismatch. + // So we first send the window id in MessageGridOpen. + + // The order is preserved by TCP. + RS.INSTANCE.network.sendTo(new MessageGridOpen(player.currentWindowId, pos, id, stack), player); + player.openContainer = new ContainerGrid(grid.getLeft(), new ResizableDisplayDummy(), grid.getRight() instanceof TileBase ? (TileBase) grid.getRight() : null, player); player.openContainer.windowId = player.currentWindowId; player.openContainer.addListener(player); MinecraftForge.EVENT_BUS.post(new PlayerContainerEvent.Open(player, player.openContainer)); - - RS.INSTANCE.network.sendTo(new MessageGridOpen(player.currentWindowId, pos, id, stack), player); } @Override