diff --git a/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java b/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java index d2fd4d5bb..49600da1b 100644 --- a/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java +++ b/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java @@ -7,8 +7,8 @@ package dan200.computercraft.client.proxy; import dan200.computercraft.ComputerCraft; -import dan200.computercraft.client.FrameInfo; import dan200.computercraft.client.ClientRegistry; +import dan200.computercraft.client.FrameInfo; import dan200.computercraft.client.gui.*; import dan200.computercraft.client.render.TileEntityCableRenderer; import dan200.computercraft.client.render.TileEntityMonitorRenderer; @@ -26,6 +26,8 @@ import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry; import net.fabricmc.fabric.api.client.render.BlockEntityRendererRegistry; import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; import net.fabricmc.fabric.api.event.client.ClientTickCallback; +import net.minecraft.container.ArrayPropertyDelegate; +import net.minecraft.inventory.BasicInventory; public final class ComputerCraftProxyClient { @@ -56,7 +58,10 @@ public final class ComputerCraftProxyClient ContainerType.registerGui( TileEntityContainerType::printer, GuiPrinter::new ); ContainerType.registerGui( TileEntityContainerType::turtle, ( id, packet, player ) -> { TileTurtle turtle = (TileTurtle) packet.getTileEntity( player ); - return new GuiTurtle( turtle, new ContainerTurtle( id, player.inventory, turtle.getAccess(), turtle.getClientComputer() ), player.inventory ); + return new GuiTurtle( turtle, + new ContainerTurtle( id, player.inventory, new BasicInventory( TileTurtle.INVENTORY_SIZE ), new ArrayPropertyDelegate( 1 ) ), + player.inventory + ); } ); ContainerType.registerGui( PocketComputerContainerType::new, GuiPocketComputer::new ); diff --git a/src/main/java/dan200/computercraft/shared/turtle/inventory/ContainerTurtle.java b/src/main/java/dan200/computercraft/shared/turtle/inventory/ContainerTurtle.java index ff606511b..e6d4d9916 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/inventory/ContainerTurtle.java +++ b/src/main/java/dan200/computercraft/shared/turtle/inventory/ContainerTurtle.java @@ -35,7 +35,7 @@ public class ContainerTurtle extends Container implements IContainerComputer private final InputState input = new InputState( this ); private int m_selectedSlot; - protected ContainerTurtle( int id, PlayerInventory playerInventory, Inventory inventory, PropertyDelegate properties, int playerInvStartY, int turtleInvStartX ) + private ContainerTurtle( int id, PlayerInventory playerInventory, Inventory inventory, PropertyDelegate properties, int playerInvStartY, int turtleInvStartX ) { super( null, id ); @@ -71,6 +71,11 @@ public class ContainerTurtle extends Container implements IContainerComputer } } + public ContainerTurtle( int id, PlayerInventory playerInventory, Inventory inventory, PropertyDelegate properties ) + { + this( id, playerInventory, inventory, properties, 134, 175 ); + } + public ContainerTurtle( int id, PlayerInventory playerInventory, ITurtleAccess turtle, IComputer computer ) { this( id, playerInventory, turtle.getInventory(), new DefaultPropertyDelegate() @@ -78,8 +83,7 @@ public class ContainerTurtle extends Container implements IContainerComputer @Override public int get( int id ) { - if( id == PROPERTY_SLOT ) return turtle.getSelectedSlot(); - return 0; + return id == PROPERTY_SLOT ? turtle.getSelectedSlot() : 0; } @Override @@ -87,7 +91,7 @@ public class ContainerTurtle extends Container implements IContainerComputer { return 1; } - }, 134, 175 ); + } ); this.computer = computer; }