From 9811e590e7887d092d3dac3d0ea3da42e6631a52 Mon Sep 17 00:00:00 2001 From: Astoria Date: Fri, 17 Mar 2023 20:26:42 -0500 Subject: [PATCH] By Eris it works on MP. --- .../afloydironchest/blocks/SteelChest.java | 4 +-- .../gui/ContainerWideChest.java | 8 ++--- .../afloydironchest/gui/GuiDiamondChest.java | 25 ++------------- .../mixin/MixinEntityPlayerMP.java | 2 +- .../mixin/MixinNetClientHandler.java | 29 ++++++++++++++++++ .../resources/afloydironchest.mixins.json | 3 +- .../assets/ironchest/gui/containerWide.png | Bin 5172 -> 5674 bytes 7 files changed, 40 insertions(+), 31 deletions(-) create mode 100644 src/main/java/net/brokenmoon/afloydironchest/mixin/MixinNetClientHandler.java diff --git a/src/main/java/net/brokenmoon/afloydironchest/blocks/SteelChest.java b/src/main/java/net/brokenmoon/afloydironchest/blocks/SteelChest.java index 22651fa..a69ce89 100644 --- a/src/main/java/net/brokenmoon/afloydironchest/blocks/SteelChest.java +++ b/src/main/java/net/brokenmoon/afloydironchest/blocks/SteelChest.java @@ -57,10 +57,10 @@ public class SteelChest extends BlockContainer{ public static void displayGui(EntityPlayer player, IInventory inventory){ if(player instanceof EntityPlayerMP) { //Multiplayer - ((IEntityPlayerMP)player).displayGUIIronChest(inventory); + ((IEntityPlayerMP)player).displayGUIDiamondChest(inventory); return; } //Singleplayer - ((IEntityPlayerSP)player).displayGUIIronChest(inventory); + ((IEntityPlayerSP)player).displayGUIDiamondChest(inventory); } } diff --git a/src/main/java/net/brokenmoon/afloydironchest/gui/ContainerWideChest.java b/src/main/java/net/brokenmoon/afloydironchest/gui/ContainerWideChest.java index b547c31..4a4e47c 100644 --- a/src/main/java/net/brokenmoon/afloydironchest/gui/ContainerWideChest.java +++ b/src/main/java/net/brokenmoon/afloydironchest/gui/ContainerWideChest.java @@ -4,28 +4,26 @@ import net.minecraft.src.*; public class ContainerWideChest extends Container { private IInventory inventory; - private int numberOfRowsLower = 4; private int numberOfRowsUpper; public ContainerWideChest(IInventory lowerInventory, IInventory upperInventory) { this.inventory = upperInventory; this.numberOfRowsUpper = upperInventory.getSizeInventory() / 12; - int i = (this.numberOfRowsUpper - 4) * 18; //Upper for (int j = 0; j < this.numberOfRowsUpper; ++j) { for (int i1 = 0; i1 < 12; ++i1) { - this.addSlot(new Slot(upperInventory, i1 + j * 12, -18 - 6 + i1 * 18, -36 + j * 18)); + this.addSlot(new Slot(upperInventory, i1 + j * 12, 8 + i1 * 18, 8 + j * 18)); } } //Lower for (int k = 0; k < 3; ++k) { for (int j1 = 0; j1 < 9; ++j1) { - this.addSlot(new Slot(lowerInventory, j1 + k * 9 + 9, 3 + j1 * 18, 49 + k * 18 + i)); + this.addSlot(new Slot(lowerInventory, j1 + k * 9 + 9, 8 + 18 + 9 + j1 * 18, 174 + k * 18)); } } //Taskbar for (int l = 0; l < 9; ++l) { - this.addSlot(new Slot(lowerInventory, l, 3 + l * 18, 49 + 18 * 3 + 4 + i)); + this.addSlot(new Slot(lowerInventory, l, 8 + 18 + 9 + l * 18, 232)); } } diff --git a/src/main/java/net/brokenmoon/afloydironchest/gui/GuiDiamondChest.java b/src/main/java/net/brokenmoon/afloydironchest/gui/GuiDiamondChest.java index 3ffb39c..29e0333 100644 --- a/src/main/java/net/brokenmoon/afloydironchest/gui/GuiDiamondChest.java +++ b/src/main/java/net/brokenmoon/afloydironchest/gui/GuiDiamondChest.java @@ -9,24 +9,14 @@ public class GuiDiamondChest extends GuiContainer { private IInventory lowerChestInventory; private int inventoryRows; - public int xSize = 240; - public int ySize = 222; - public GuiDiamondChest(IInventory iinventory, IInventory iinventory1) { super(new ContainerWideChest(iinventory, iinventory1)); this.upperChestInventory = iinventory; this.lowerChestInventory = iinventory1; this.field_948_f = false; - int c = 222; - int i = c - 108; this.inventoryRows = iinventory1.getSizeInventory() / 12; - this.ySize = i + this.inventoryRows * 18; - } - - @Override - protected void drawGuiContainerForegroundLayer() { - this.fontRenderer.drawString(this.lowerChestInventory.getInvName(), -24, -47, 0x404040); - this.fontRenderer.drawString(this.upperChestInventory.getInvName(), 3, 128, 0x404040); + this.ySize = 256; + this.xSize = 230; } @Override @@ -36,15 +26,6 @@ public class GuiDiamondChest extends GuiContainer { this.mc.renderEngine.bindTexture(i); int x = (this.width - this.xSize) / 2; int y = (this.height - this.ySize) / 2; - int h1 = Math.min(this.inventoryRows, 6) * 18 + 17; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, h1); - int rows = this.inventoryRows; - while (rows > 6) { - int h2 = Math.min(rows, 6) * 18; - this.drawTexturedModalRect(x, y + h1, 0, 17, this.xSize, h2); - rows -= 6; - h1 += h2; - } - this.drawTexturedModalRect(x, y + this.inventoryRows * 18 + 17, 0, 126, this.xSize, 96); + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); } } diff --git a/src/main/java/net/brokenmoon/afloydironchest/mixin/MixinEntityPlayerMP.java b/src/main/java/net/brokenmoon/afloydironchest/mixin/MixinEntityPlayerMP.java index 0e2c91a..deda0f0 100644 --- a/src/main/java/net/brokenmoon/afloydironchest/mixin/MixinEntityPlayerMP.java +++ b/src/main/java/net/brokenmoon/afloydironchest/mixin/MixinEntityPlayerMP.java @@ -29,7 +29,7 @@ public class MixinEntityPlayerMP implements IEntityPlayerMP { public void displayGUIDiamondChest(IInventory iinventory) { this.getNextWindowId(); NetServerHandler.logger.info(((EntityPlayerMP)(Object)this).username + " interacted with chest at (" + ((EntityPlayerMP)(Object)this).posX + ", " + ((EntityPlayerMP)(Object)this).posY + ", " + ((EntityPlayerMP)(Object)this).posZ + ")"); - this.playerNetServerHandler.sendPacket(new Packet100OpenWindow(this.currentWindowId, 0, iinventory.getInvName(), iinventory.getSizeInventory())); + this.playerNetServerHandler.sendPacket(new Packet100OpenWindow(this.currentWindowId, 7, iinventory.getInvName(), iinventory.getSizeInventory())); ((EntityPlayerMP)(Object)this).craftingInventory = new ContainerWideChest(((EntityPlayerMP)(Object)this).inventory, iinventory); ((EntityPlayerMP)(Object)this).craftingInventory.windowId = this.currentWindowId; ((EntityPlayerMP)(Object)this).craftingInventory.onContainerInit(((EntityPlayerMP)(Object)this)); diff --git a/src/main/java/net/brokenmoon/afloydironchest/mixin/MixinNetClientHandler.java b/src/main/java/net/brokenmoon/afloydironchest/mixin/MixinNetClientHandler.java new file mode 100644 index 0000000..bdf382e --- /dev/null +++ b/src/main/java/net/brokenmoon/afloydironchest/mixin/MixinNetClientHandler.java @@ -0,0 +1,29 @@ +package net.brokenmoon.afloydironchest.mixin; + +import net.brokenmoon.afloydironchest.MixinInterfaces.IEntityPlayerSP; +import net.brokenmoon.afloydironchest.tileEntities.TileEntityDiamondChest; +import net.minecraft.client.Minecraft; +import net.minecraft.src.NetClientHandler; +import net.minecraft.src.Packet100OpenWindow; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(value = NetClientHandler.class, remap = false) +public class MixinNetClientHandler { + + @Shadow + private Minecraft mc; + + @Inject(method = "handleOpenWindow", at = @At("TAIL")) + public void injectMethod(Packet100OpenWindow packet100openwindow, CallbackInfo info) { + if (packet100openwindow.inventoryType == 7) { + TileEntityDiamondChest dchest = new TileEntityDiamondChest(); + ((IEntityPlayerSP)this.mc.thePlayer).displayGUIDiamondChest(dchest); + this.mc.thePlayer.craftingInventory.windowId = packet100openwindow.windowId; + } + } + +} diff --git a/src/main/resources/afloydironchest.mixins.json b/src/main/resources/afloydironchest.mixins.json index 291f41c..02391ee 100644 --- a/src/main/resources/afloydironchest.mixins.json +++ b/src/main/resources/afloydironchest.mixins.json @@ -6,7 +6,8 @@ "mixins": [ "MixinEntityPlayerMP", "MixinEntityPlayerSP", - "MixinTileEntity" + "MixinTileEntity", + "MixinNetClientHandler" ], "client": [ diff --git a/src/main/resources/assets/ironchest/gui/containerWide.png b/src/main/resources/assets/ironchest/gui/containerWide.png index befcfab8f4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