From cc24e7a835c651f3e15662e37d797424062a401d Mon Sep 17 00:00:00 2001 From: Astoria Date: Fri, 17 Mar 2023 18:13:14 -0500 Subject: [PATCH] Wide Chest, almost working --- .../MixinInterfaces/IEntityPlayerMP.java | 2 + .../MixinInterfaces/IEntityPlayerSP.java | 2 + .../afloydironchest/blocks/DiamondChest.java | 4 +- .../gui/ContainerWideChest.java | 59 ++++++++++++++++++ .../afloydironchest/gui/GuiDiamondChest.java | 50 +++++++++++++++ .../mixin/MixinEntityPlayerMP.java | 10 +++ .../mixin/MixinEntityPlayerSP.java | 5 ++ .../assets/ironchest/gui/containerWide.png | Bin 0 -> 5172 bytes 8 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 src/main/java/net/brokenmoon/afloydironchest/gui/ContainerWideChest.java create mode 100644 src/main/java/net/brokenmoon/afloydironchest/gui/GuiDiamondChest.java create mode 100644 src/main/resources/assets/ironchest/gui/containerWide.png diff --git a/src/main/java/net/brokenmoon/afloydironchest/MixinInterfaces/IEntityPlayerMP.java b/src/main/java/net/brokenmoon/afloydironchest/MixinInterfaces/IEntityPlayerMP.java index f9ee7e9..2cb4170 100644 --- a/src/main/java/net/brokenmoon/afloydironchest/MixinInterfaces/IEntityPlayerMP.java +++ b/src/main/java/net/brokenmoon/afloydironchest/MixinInterfaces/IEntityPlayerMP.java @@ -4,4 +4,6 @@ import net.minecraft.src.IInventory; public interface IEntityPlayerMP { public void displayGUIIronChest(IInventory iinventory); + + public void displayGUIDiamondChest(IInventory iinventory); } diff --git a/src/main/java/net/brokenmoon/afloydironchest/MixinInterfaces/IEntityPlayerSP.java b/src/main/java/net/brokenmoon/afloydironchest/MixinInterfaces/IEntityPlayerSP.java index 95562c6..8e29cc5 100644 --- a/src/main/java/net/brokenmoon/afloydironchest/MixinInterfaces/IEntityPlayerSP.java +++ b/src/main/java/net/brokenmoon/afloydironchest/MixinInterfaces/IEntityPlayerSP.java @@ -4,4 +4,6 @@ import net.minecraft.src.IInventory; public interface IEntityPlayerSP { public void displayGUIIronChest(IInventory iinventory); + + public void displayGUIDiamondChest(IInventory iinventory); } diff --git a/src/main/java/net/brokenmoon/afloydironchest/blocks/DiamondChest.java b/src/main/java/net/brokenmoon/afloydironchest/blocks/DiamondChest.java index af8bcd0..f82f2d2 100644 --- a/src/main/java/net/brokenmoon/afloydironchest/blocks/DiamondChest.java +++ b/src/main/java/net/brokenmoon/afloydironchest/blocks/DiamondChest.java @@ -57,10 +57,10 @@ public class DiamondChest 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 new file mode 100644 index 0000000..b547c31 --- /dev/null +++ b/src/main/java/net/brokenmoon/afloydironchest/gui/ContainerWideChest.java @@ -0,0 +1,59 @@ +package net.brokenmoon.afloydironchest.gui; + +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)); + } + } + //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)); + } + } + //Taskbar + for (int l = 0; l < 9; ++l) { + this.addSlot(new Slot(lowerInventory, l, 3 + l * 18, 49 + 18 * 3 + 4 + i)); + } + } + + @Override + public boolean isUsableByPlayer(EntityPlayer entityplayer) { + return this.inventory.canInteractWith(entityplayer); + } + + @Override + public void quickMoveItems(int slotID, EntityPlayer player, boolean shift, boolean control) { + Slot slot = (Slot)this.inventorySlots.get(slotID); + if (slot == null || !slot.hasStack()) { + return; + } + ItemStack item = slot.getStack(); + ItemStack originalItem = item.copy(); + if (slotID < this.numberOfRowsUpper * 12) { + this.onStackMergeShiftClick(item, this.numberOfRowsUpper * 12, this.inventorySlots.size(), true); + } else { + this.onStackMergeShiftClick(item, 0, this.numberOfRowsUpper * 12, false); + } + if (item.stackSize == 0) { + slot.putStack(null); + } else { + slot.onSlotChanged(); + } + if (item.stackSize != originalItem.stackSize) { + slot.onPickupFromSlot(item); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/brokenmoon/afloydironchest/gui/GuiDiamondChest.java b/src/main/java/net/brokenmoon/afloydironchest/gui/GuiDiamondChest.java new file mode 100644 index 0000000..3ffb39c --- /dev/null +++ b/src/main/java/net/brokenmoon/afloydironchest/gui/GuiDiamondChest.java @@ -0,0 +1,50 @@ +package net.brokenmoon.afloydironchest.gui; + +import net.minecraft.src.GuiContainer; +import net.minecraft.src.IInventory; +import org.lwjgl.opengl.GL11; + +public class GuiDiamondChest extends GuiContainer { + private IInventory upperChestInventory; + 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); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f) { + int i = this.mc.renderEngine.getTexture("/assets/ironchest/gui/containerWide.png"); + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + 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); + } +} diff --git a/src/main/java/net/brokenmoon/afloydironchest/mixin/MixinEntityPlayerMP.java b/src/main/java/net/brokenmoon/afloydironchest/mixin/MixinEntityPlayerMP.java index 8411926..0e2c91a 100644 --- a/src/main/java/net/brokenmoon/afloydironchest/mixin/MixinEntityPlayerMP.java +++ b/src/main/java/net/brokenmoon/afloydironchest/mixin/MixinEntityPlayerMP.java @@ -1,6 +1,7 @@ package net.brokenmoon.afloydironchest.mixin; import net.brokenmoon.afloydironchest.MixinInterfaces.IEntityPlayerMP; +import net.brokenmoon.afloydironchest.gui.ContainerWideChest; import net.minecraft.src.*; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -24,4 +25,13 @@ public class MixinEntityPlayerMP implements IEntityPlayerMP { ((EntityPlayerMP)(Object)this).craftingInventory.windowId = this.currentWindowId; ((EntityPlayerMP)(Object)this).craftingInventory.onContainerInit(((EntityPlayerMP)(Object)this)); } + + 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())); + ((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/MixinEntityPlayerSP.java b/src/main/java/net/brokenmoon/afloydironchest/mixin/MixinEntityPlayerSP.java index 45f1386..d56fda3 100644 --- a/src/main/java/net/brokenmoon/afloydironchest/mixin/MixinEntityPlayerSP.java +++ b/src/main/java/net/brokenmoon/afloydironchest/mixin/MixinEntityPlayerSP.java @@ -1,5 +1,6 @@ package net.brokenmoon.afloydironchest.mixin; +import net.brokenmoon.afloydironchest.gui.GuiDiamondChest; import net.brokenmoon.afloydironchest.gui.GuiIronChest; import net.minecraft.client.Minecraft; import net.minecraft.src.*; @@ -13,4 +14,8 @@ public class MixinEntityPlayerSP { public void displayGUIIronChest(IInventory iinventory) { this.mc.displayGuiScreen(new GuiIronChest(((EntityPlayerSP)(Object)this).inventory, iinventory)); } + + public void displayGUIDiamondChest(IInventory iinventory) { + this.mc.displayGuiScreen(new GuiDiamondChest(((EntityPlayerSP)(Object)this).inventory, iinventory)); + } } diff --git a/src/main/resources/assets/ironchest/gui/containerWide.png b/src/main/resources/assets/ironchest/gui/containerWide.png new file mode 100644 index 0000000000000000000000000000000000000000..befcfab8f4c45683a40ecf93b15e4120e969b77e GIT binary patch literal 5172 zcmeHLdsGuw8Xu5KjL%dNaM6x~Z9zMEza}I+BnWX04G;xgs7^97FiIXKLlS&c1nbH! zKH3WIp(=K3T`Naj*MhI5*ecrfS#_(30^no}7!6n_Xl>(QV1;#Wc8F#~WhmE4M zNtnsClQ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