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 0000000..befcfab Binary files /dev/null and b/src/main/resources/assets/ironchest/gui/containerWide.png differ