Revert "Revert "Wide Chest, almost working""

This reverts commit 4a645cd035.
main
Astoria 2 years ago
parent 4a645cd035
commit 3206c61a9e

@ -4,4 +4,6 @@ import net.minecraft.src.IInventory;
public interface IEntityPlayerMP {
public void displayGUIIronChest(IInventory iinventory);
public void displayGUIDiamondChest(IInventory iinventory);
}

@ -4,4 +4,6 @@ import net.minecraft.src.IInventory;
public interface IEntityPlayerSP {
public void displayGUIIronChest(IInventory iinventory);
public void displayGUIDiamondChest(IInventory iinventory);
}

@ -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);
}
}

@ -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);
}
}
}

@ -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);
}
}

@ -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));
}
}

@ -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));
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Loading…
Cancel
Save