From 4fccaa1f5fe92b4f8884b0182d6e77dc1b2fd7df Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Tue, 12 Apr 2016 08:39:50 +0100 Subject: [PATCH] Update AlloySmelter to new system --- .../java/techreborn/client/GuiHandler.java | 2 +- .../container/ContainerAlloySmelter.java | 67 ++++++++++++++----- .../client/gui/GuiAlloySmelter.java | 3 +- 3 files changed, 54 insertions(+), 18 deletions(-) diff --git a/src/main/java/techreborn/client/GuiHandler.java b/src/main/java/techreborn/client/GuiHandler.java index b793ab0aa..5dde26e31 100644 --- a/src/main/java/techreborn/client/GuiHandler.java +++ b/src/main/java/techreborn/client/GuiHandler.java @@ -97,7 +97,7 @@ public class GuiHandler implements IGuiHandler return new ContainerBlastFurnace((TileBlastFurnace) world.getTileEntity(new BlockPos(x, y, z)), player); } else if (ID == alloySmelterID) { - return new ContainerAlloySmelter((TileAlloySmelter) world.getTileEntity(new BlockPos(x, y, z)), player); + container = new ContainerAlloySmelter(); } else if (ID == industrialGrinderID) { return new ContainerIndustrialGrinder((TileIndustrialGrinder) world.getTileEntity(new BlockPos(x, y, z)), diff --git a/src/main/java/techreborn/client/container/ContainerAlloySmelter.java b/src/main/java/techreborn/client/container/ContainerAlloySmelter.java index 3d4873b31..ec6b04bb4 100644 --- a/src/main/java/techreborn/client/container/ContainerAlloySmelter.java +++ b/src/main/java/techreborn/client/container/ContainerAlloySmelter.java @@ -1,37 +1,50 @@ package techreborn.client.container; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.EnumFacing; +import reborncore.api.tile.IContainerLayout; import reborncore.client.gui.BaseSlot; +import reborncore.client.gui.SlotCharge; +import reborncore.client.gui.SlotInput; import reborncore.client.gui.SlotOutput; import techreborn.api.gui.SlotUpgrade; import techreborn.tiles.TileAlloySmelter; -public class ContainerAlloySmelter extends ContainerCrafting +import javax.annotation.Nullable; +import java.util.List; + +public class ContainerAlloySmelter extends ContainerCrafting implements IContainerLayout { public int tickTime; EntityPlayer player; TileAlloySmelter tile; - public ContainerAlloySmelter(TileAlloySmelter tileAlloysmelter, EntityPlayer player) + @Override + public boolean canInteractWith(EntityPlayer player) { - super(tileAlloysmelter.crafter); - tile = tileAlloysmelter; - this.player = player; + return true; + } + + @Override + public void addInventorySlots() { // input - this.addSlotToContainer(new BaseSlot(tileAlloysmelter.inventory, 0, 47, 17)); - this.addSlotToContainer(new BaseSlot(tileAlloysmelter.inventory, 1, 65, 17)); + this.addSlotToContainer(new SlotInput(tile.inventory, 0, 47, 17)); + this.addSlotToContainer(new SlotInput(tile.inventory, 1, 65, 17)); // outputs - this.addSlotToContainer(new SlotOutput(tileAlloysmelter.inventory, 2, 116, 35)); + this.addSlotToContainer(new SlotOutput(tile.inventory, 2, 116, 35)); // battery - this.addSlotToContainer(new BaseSlot(tileAlloysmelter.inventory, 3, 56, 53)); + this.addSlotToContainer(new SlotCharge(tile.inventory, 3, 56, 53)); // upgrades - this.addSlotToContainer(new SlotUpgrade(tileAlloysmelter.inventory, 4, 152, 8)); - this.addSlotToContainer(new SlotUpgrade(tileAlloysmelter.inventory, 5, 152, 26)); - this.addSlotToContainer(new SlotUpgrade(tileAlloysmelter.inventory, 6, 152, 44)); - this.addSlotToContainer(new SlotUpgrade(tileAlloysmelter.inventory, 7, 152, 62)); + this.addSlotToContainer(new SlotUpgrade(tile.inventory, 4, 152, 8)); + this.addSlotToContainer(new SlotUpgrade(tile.inventory, 5, 152, 26)); + this.addSlotToContainer(new SlotUpgrade(tile.inventory, 6, 152, 44)); + this.addSlotToContainer(new SlotUpgrade(tile.inventory, 7, 152, 62)); + } + @Override + public void addPlayerSlots() { int i; for (i = 0; i < 3; ++i) @@ -49,9 +62,31 @@ public class ContainerAlloySmelter extends ContainerCrafting } @Override - public boolean canInteractWith(EntityPlayer player) - { - return true; + public void setTile(TileAlloySmelter tile) { + this.tile = tile; + setCrafter(tile.crafter); } + @Nullable + @Override + public TileAlloySmelter getTile() { + return tile; + } + + @Override + public void setPlayer(EntityPlayer player) { + this.player = player; + } + + @Nullable + @Override + public EntityPlayer getPlayer() { + return player; + } + + @Nullable + @Override + public List getSlotsForSide(EnumFacing facing) { + return null; + } } diff --git a/src/main/java/techreborn/client/gui/GuiAlloySmelter.java b/src/main/java/techreborn/client/gui/GuiAlloySmelter.java index 9889fba1c..8da0389a0 100644 --- a/src/main/java/techreborn/client/gui/GuiAlloySmelter.java +++ b/src/main/java/techreborn/client/gui/GuiAlloySmelter.java @@ -5,6 +5,7 @@ import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.translation.I18n; +import reborncore.common.container.RebornContainer; import techreborn.client.container.ContainerAlloySmelter; import techreborn.tiles.TileAlloySmelter; @@ -18,7 +19,7 @@ public class GuiAlloySmelter extends GuiContainer public GuiAlloySmelter(EntityPlayer player, TileAlloySmelter tilealloysmelter) { - super(new ContainerAlloySmelter(tilealloysmelter, player)); + super(RebornContainer.createContainer(ContainerAlloySmelter.class, tilealloysmelter, player)); this.xSize = 176; this.ySize = 167; alloysmelter = tilealloysmelter;