diff options
author | kekzdealer <kekzdealer@gmail.com> | 2019-12-10 11:36:39 +0100 |
---|---|---|
committer | kekzdealer <kekzdealer@gmail.com> | 2019-12-10 11:36:39 +0100 |
commit | c7329fe829f69f4585837a5f483dab064d57774f (patch) | |
tree | 73d512a3afa641f989df2c155949296dbfd383f0 /src/main/java/container | |
parent | f9eac626254ed31477925618a45af5005e4628ac (diff) | |
download | GT5-Unofficial-c7329fe829f69f4585837a5f483dab064d57774f.tar.gz GT5-Unofficial-c7329fe829f69f4585837a5f483dab064d57774f.tar.bz2 GT5-Unofficial-c7329fe829f69f4585837a5f483dab064d57774f.zip |
visiting Lucy~
Diffstat (limited to 'src/main/java/container')
-rw-r--r-- | src/main/java/container/Container_ItemProxyEndpoint.java (renamed from src/main/java/container/Container_ItemDistributionNode.java) | 24 | ||||
-rw-r--r-- | src/main/java/container/Container_ItemProxySource.java | 80 | ||||
-rw-r--r-- | src/main/java/container/Gui_ItemProxyEndpoint.java | 50 | ||||
-rw-r--r-- | src/main/java/container/Gui_ItemProxySource.java (renamed from src/main/java/container/Gui_ItemDistributionNode.java) | 15 |
4 files changed, 150 insertions, 19 deletions
diff --git a/src/main/java/container/Container_ItemDistributionNode.java b/src/main/java/container/Container_ItemProxyEndpoint.java index 08096bc80f..5718943efe 100644 --- a/src/main/java/container/Container_ItemDistributionNode.java +++ b/src/main/java/container/Container_ItemProxyEndpoint.java @@ -2,25 +2,24 @@ package container; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import tileentities.TE_ItemDistributionNode; +import net.minecraft.tileentity.TileEntity; -public class Container_ItemDistributionNode extends Container { +public class Container_ItemProxyEndpoint extends Container { - private final TE_ItemDistributionNode te; + private final IInventory teInventory; private int slotID = 0; - public Container_ItemDistributionNode(TE_ItemDistributionNode te, EntityPlayer player) { - this.te = te; + public Container_ItemProxyEndpoint(TileEntity te, EntityPlayer player) { + this.teInventory = (IInventory) te; - // Networked Storage - for(int i = 0; i < 4; i++) { - for(int j = 0; j < 4; j++) { - super.addSlotToContainer(new Slot(te, slotID++, 18 * j + 20, 19 * i + 20)); - } - } + // Source Slot + addSlotToContainer(new Slot(teInventory, slotID++, 80, 35)); + // Config slot + addSlotToContainer(new Slot(teInventory, slotID++, 100, 35)); //Inventory for (int i = 0; i < 3; i++) { @@ -62,7 +61,8 @@ public class Container_ItemDistributionNode extends Container { @Override public boolean canInteractWith(EntityPlayer player) { - return te.isUseableByPlayer(player); + return teInventory.isUseableByPlayer(player); } } + diff --git a/src/main/java/container/Container_ItemProxySource.java b/src/main/java/container/Container_ItemProxySource.java new file mode 100644 index 0000000000..50facb4bf2 --- /dev/null +++ b/src/main/java/container/Container_ItemProxySource.java @@ -0,0 +1,80 @@ +package container; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +public class Container_ItemProxySource extends Container { + + private final IInventory teInventory; + + private int slotID = 0; + + public Container_ItemProxySource(TileEntity te, EntityPlayer player) { + this.teInventory = (IInventory) te; + + // Source Slots + addSlotToContainer(new Slot(teInventory, slotID++, 53, 8)); + addSlotToContainer(new Slot(teInventory, slotID++, 71, 8)); + addSlotToContainer(new Slot(teInventory, slotID++, 89, 8)); + addSlotToContainer(new Slot(teInventory, slotID++, 107, 8)); + addSlotToContainer(new Slot(teInventory, slotID++, 53, 26)); + addSlotToContainer(new Slot(teInventory, slotID++, 71, 26)); + addSlotToContainer(new Slot(teInventory, slotID++, 89, 26)); + addSlotToContainer(new Slot(teInventory, slotID++, 107, 26)); + addSlotToContainer(new Slot(teInventory, slotID++, 53, 44)); + addSlotToContainer(new Slot(teInventory, slotID++, 71, 44)); + addSlotToContainer(new Slot(teInventory, slotID++, 89, 44)); + addSlotToContainer(new Slot(teInventory, slotID++, 107, 44)); + addSlotToContainer(new Slot(teInventory, slotID++, 53, 62)); + addSlotToContainer(new Slot(teInventory, slotID++, 71, 62)); + addSlotToContainer(new Slot(teInventory, slotID++, 89, 62)); + addSlotToContainer(new Slot(teInventory, slotID++, 107, 62)); + + //Inventory + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + // Hotbar + for (int i = 0; i < 9; i++) { + addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142)); + } + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotRaw) { + ItemStack stack = null; + final Slot slot = (Slot) inventorySlots.get(slotRaw); + + if (slot != null && slot.getHasStack()) { + final ItemStack stackInSlot = slot.getStack(); + stack = stackInSlot.copy(); + + if (slotRaw < 3 * 9) { + if (!mergeItemStack(stackInSlot, 3 * 9, inventorySlots.size(), true)) { + return null; + } + } else if (!mergeItemStack(stackInSlot, 0, 3 * 9, false)) { + return null; + } + + if (stackInSlot.stackSize == 0) { + slot.putStack((ItemStack) null); + } else { + slot.onSlotChanged(); + } + } + return stack; + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + return teInventory.isUseableByPlayer(player); + } + +} diff --git a/src/main/java/container/Gui_ItemProxyEndpoint.java b/src/main/java/container/Gui_ItemProxyEndpoint.java new file mode 100644 index 0000000000..0fb1b6e05b --- /dev/null +++ b/src/main/java/container/Gui_ItemProxyEndpoint.java @@ -0,0 +1,50 @@ +package container; + +import org.lwjgl.opengl.GL11; + +import kekztech.KekzCore; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; + +public class Gui_ItemProxyEndpoint extends GuiContainer { + + private final ResourceLocation texture = new ResourceLocation(KekzCore.MODID, "textures/gui/ItemTech1by1.png"); + + private final InventoryPlayer inventory; + private final IInventory te; + + public Gui_ItemProxyEndpoint(TileEntity te, EntityPlayer player) { + super(new Container_ItemProxyEndpoint(te, player)); + inventory = player.inventory; + this.te = (IInventory) te; + + } + + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { + + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + + final int x = (super.width - super.xSize) / 2; + final int y = (super.height - super.ySize) / 2; + + super.drawTexturedModalRect(x, y, 0, 0, super.xSize, super.ySize); + } + + @Override + protected void drawGuiContainerForegroundLayer(int p1, int p2) { + super.fontRendererObj.drawString( + I18n.format(te.getInventoryName()), + (super.xSize / 2) - (fontRendererObj.getStringWidth(I18n.format(te.getInventoryName())) / 2), + 6, 4210752, false); + super.fontRendererObj.drawString( + I18n.format(inventory.getInventoryName()), 8, super.ySize - 96 + 2, 4210752); + } +} diff --git a/src/main/java/container/Gui_ItemDistributionNode.java b/src/main/java/container/Gui_ItemProxySource.java index 08f530fce8..e72928f7ff 100644 --- a/src/main/java/container/Gui_ItemDistributionNode.java +++ b/src/main/java/container/Gui_ItemProxySource.java @@ -8,20 +8,21 @@ import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import tileentities.TE_ItemDistributionNode; -public class Gui_ItemDistributionNode extends GuiContainer { +public class Gui_ItemProxySource extends GuiContainer { - private final ResourceLocation texture = new ResourceLocation(KekzCore.MODID, "textures/gui/ItemDistributionNode.png"); + private final ResourceLocation texture = new ResourceLocation(KekzCore.MODID, "textures/gui/ItemTech4by4.png"); private final InventoryPlayer inventory; - private final TE_ItemDistributionNode te; + private final IInventory te; - public Gui_ItemDistributionNode(TE_ItemDistributionNode te, EntityPlayer player) { - super(new Container_ItemDistributionNode(te, player)); + public Gui_ItemProxySource(TileEntity te, EntityPlayer player) { + super(new Container_ItemProxySource(te, player)); inventory = player.inventory; - this.te = te; + this.te = (IInventory) te; } |