From 5dfee9ec7a4e6b32bde3017d5590329eca3e551d Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Mon, 13 Jan 2014 00:06:13 -0500 Subject: [PATCH] Precision Sawmill and overall Chance Machine framework GUI & Container --- common/mekanism/client/ClientProxy.java | 4 +- .../mekanism/client/gui/GuiChanceMachine.java | 66 ++++++- .../client/gui/GuiPrecisionSawmill.java | 10 +- common/mekanism/common/CommonProxy.java | 4 + .../mekanism/common/block/BlockMachine.java | 2 +- .../container/ContainerChanceMachine.java | 168 +++++++++++++++++- .../container/ContainerElectricMachine.java | 2 +- .../mekanism/gui/GuiPrecisionSawmill.png | Bin 4287 -> 4282 bytes 8 files changed, 247 insertions(+), 9 deletions(-) diff --git a/common/mekanism/client/ClientProxy.java b/common/mekanism/client/ClientProxy.java index 3d0c03277..7d6d01352 100644 --- a/common/mekanism/client/ClientProxy.java +++ b/common/mekanism/client/ClientProxy.java @@ -26,6 +26,7 @@ import mekanism.client.gui.GuiOsmiumCompressor; import mekanism.client.gui.GuiPasswordEnter; import mekanism.client.gui.GuiPasswordModify; import mekanism.client.gui.GuiPortableTeleporter; +import mekanism.client.gui.GuiPrecisionSawmill; import mekanism.client.gui.GuiPurificationChamber; import mekanism.client.gui.GuiRobitCrafting; import mekanism.client.gui.GuiRobitInventory; @@ -419,7 +420,8 @@ public class ClientProxy extends CommonProxy return new GuiElectrolyticSeparator(player.inventory, (TileEntityElectrolyticSeparator)tileEntity); case 33: return new GuiSalinationController(player.inventory, (TileEntitySalinationController)tileEntity); - + case 34: + return new GuiPrecisionSawmill(player.inventory, (TileEntityPrecisionSawmill)tileEntity); } return null; diff --git a/common/mekanism/client/gui/GuiChanceMachine.java b/common/mekanism/client/gui/GuiChanceMachine.java index f07044797..e08ac3e8a 100644 --- a/common/mekanism/client/gui/GuiChanceMachine.java +++ b/common/mekanism/client/gui/GuiChanceMachine.java @@ -1,6 +1,68 @@ package mekanism.client.gui; -public class GuiChanceMachine +import java.util.List; + +import mekanism.api.ListUtils; +import mekanism.client.gui.GuiEnergyInfo.IInfoHandler; +import mekanism.common.inventory.container.ContainerChanceMachine; +import mekanism.common.tile.TileEntityChanceMachine; +import mekanism.common.util.MekanismUtils; +import net.minecraft.entity.player.InventoryPlayer; + +import org.lwjgl.opengl.GL11; + +public class GuiChanceMachine extends GuiMekanism { - + public TileEntityChanceMachine tileEntity; + + public GuiChanceMachine(InventoryPlayer inventory, TileEntityChanceMachine tentity) + { + super(tentity, new ContainerChanceMachine(inventory, tentity)); + tileEntity = tentity; + + guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.guiLocation)); + guiElements.add(new GuiUpgradeManagement(this, tileEntity, tileEntity.guiLocation)); + guiElements.add(new GuiConfigurationTab(this, tileEntity, tileEntity.guiLocation)); + guiElements.add(new GuiPowerBar(this, tileEntity, tileEntity.guiLocation, 164, 15)); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() + { + String multiplier = MekanismUtils.getEnergyDisplay(MekanismUtils.getEnergyPerTick(tileEntity.getSpeedMultiplier(), tileEntity.getEnergyMultiplier(), tileEntity.ENERGY_PER_TICK)); + return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); + } + }, this, tileEntity, tileEntity.guiLocation)); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); + fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + mc.renderEngine.bindTexture(tileEntity.guiLocation); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; + int yAxis = mouseY - guiHeight; + + int displayInt; + + displayInt = tileEntity.getScaledProgress(24); + drawTexturedModalRect(guiWidth + 79, guiHeight + 39, 176, 0, displayInt + 1, 7); + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/common/mekanism/client/gui/GuiPrecisionSawmill.java b/common/mekanism/client/gui/GuiPrecisionSawmill.java index 33cf1a584..2cf2a8538 100644 --- a/common/mekanism/client/gui/GuiPrecisionSawmill.java +++ b/common/mekanism/client/gui/GuiPrecisionSawmill.java @@ -1,6 +1,12 @@ package mekanism.client.gui; -public class GuiPrecisionSawmill +import mekanism.common.tile.TileEntityChanceMachine; +import net.minecraft.entity.player.InventoryPlayer; + +public class GuiPrecisionSawmill extends GuiChanceMachine { - + public GuiPrecisionSawmill(InventoryPlayer inventory, TileEntityChanceMachine tentity) + { + super(inventory, tentity); + } } diff --git a/common/mekanism/common/CommonProxy.java b/common/mekanism/common/CommonProxy.java index 14660b9c0..5a0f59608 100644 --- a/common/mekanism/common/CommonProxy.java +++ b/common/mekanism/common/CommonProxy.java @@ -4,6 +4,7 @@ import java.io.File; import mekanism.common.entity.EntityRobit; import mekanism.common.inventory.container.ContainerAdvancedElectricMachine; +import mekanism.common.inventory.container.ContainerChanceMachine; import mekanism.common.inventory.container.ContainerChemicalInfuser; import mekanism.common.inventory.container.ContainerChemicalOxidizer; import mekanism.common.inventory.container.ContainerDictionary; @@ -29,6 +30,7 @@ import mekanism.common.inventory.container.ContainerTeleporter; import mekanism.common.tile.TileEntityAdvancedElectricMachine; import mekanism.common.tile.TileEntityAdvancedFactory; import mekanism.common.tile.TileEntityBin; +import mekanism.common.tile.TileEntityChanceMachine; import mekanism.common.tile.TileEntityChargepad; import mekanism.common.tile.TileEntityChemicalInfuser; import mekanism.common.tile.TileEntityChemicalInjectionChamber; @@ -359,6 +361,8 @@ public class CommonProxy return new ContainerElectrolyticSeparator(player.inventory, (TileEntityElectrolyticSeparator)tileEntity); case 33: return new ContainerSalinationController(player.inventory, (TileEntitySalinationController)tileEntity); + case 34: + return new ContainerChanceMachine(player.inventory, (TileEntityChanceMachine)tileEntity); } return null; diff --git a/common/mekanism/common/block/BlockMachine.java b/common/mekanism/common/block/BlockMachine.java index 334b7abc1..1fab1a79e 100644 --- a/common/mekanism/common/block/BlockMachine.java +++ b/common/mekanism/common/block/BlockMachine.java @@ -1116,7 +1116,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds CHEMICAL_INFUSER(Mekanism.machineBlock2ID, 2, "ChemicalInfuser", 30, 20000, TileEntityChemicalInfuser.class, true, false), CHEMICAL_INJECTION_CHAMBER(Mekanism.machineBlock2ID, 3, "ChemicalInjectionChamber", 31, Mekanism.chemicalInjectionChamberUsage*400, TileEntityChemicalInjectionChamber.class, false, true), ELECTROLYTIC_SEPARATOR(Mekanism.machineBlock2ID, 4, "ElectrolyticSeparator", 32, 20000, TileEntityElectrolyticSeparator.class, true, false), - PRECISION_SAWMILL(Mekanism.machineBlock2ID, 5, "PrecisionSawmill", 33, Mekanism.precisionSawmillUsage*400, TileEntityPrecisionSawmill.class, false, true); + PRECISION_SAWMILL(Mekanism.machineBlock2ID, 5, "PrecisionSawmill", 34, Mekanism.precisionSawmillUsage*400, TileEntityPrecisionSawmill.class, false, true); public int typeId; public int meta; diff --git a/common/mekanism/common/inventory/container/ContainerChanceMachine.java b/common/mekanism/common/inventory/container/ContainerChanceMachine.java index d0dfbcd8a..88a12f88c 100644 --- a/common/mekanism/common/inventory/container/ContainerChanceMachine.java +++ b/common/mekanism/common/inventory/container/ContainerChanceMachine.java @@ -1,6 +1,170 @@ package mekanism.common.inventory.container; -public class ContainerChanceMachine +import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge; +import mekanism.common.inventory.slot.SlotMachineUpgrade; +import mekanism.common.inventory.slot.SlotOutput; +import mekanism.common.item.ItemMachineUpgrade; +import mekanism.common.recipe.RecipeHandler; +import mekanism.common.tile.TileEntityChanceMachine; +import mekanism.common.util.ChargeUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class ContainerChanceMachine extends Container { - + private TileEntityChanceMachine tileEntity; + + public ContainerChanceMachine(InventoryPlayer inventory, TileEntityChanceMachine tentity) + { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 56, 17)); + addSlotToContainer(new SlotDischarge(tentity, 1, 56, 53)); + addSlotToContainer(new SlotOutput(tentity, 2, 116, 35)); + addSlotToContainer(new SlotMachineUpgrade(tentity, 3, 180, 11)); + addSlotToContainer(new SlotOutput(tentity, 4, 132, 35)); + int slotX; + + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } + + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + + tileEntity.open(inventory.player); + tileEntity.openChest(); + } + + @Override + public void onContainerClosed(EntityPlayer entityplayer) + { + super.onContainerClosed(entityplayer); + + tileEntity.close(entityplayer); + tileEntity.closeChest(); + } + + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return tileEntity.isUseableByPlayer(entityplayer); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); + + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); + + if(slotID == 2 || slotID == 4) + { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } + else if(ChargeUtils.canBeDischarged(slotStack)) + { + if(slotID != 1) + { + if(!mergeItemStack(slotStack, 1, 2, false)) + { + return null; + } + } + else if(slotID == 1) + { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(RecipeHandler.getChanceOutput(slotStack, false, tileEntity.getRecipes()) != null) + { + if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3 && slotID != 4) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(slotStack.getItem() instanceof ItemMachineUpgrade) + { + if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) + { + if(!mergeItemStack(slotStack, 3, 4, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + if(slotID >= 5 && slotID <= 31) + { + if(!mergeItemStack(slotStack, 32, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 31) + { + if(!mergeItemStack(slotStack, 5, 31, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } + } + + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } + + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/common/mekanism/common/inventory/container/ContainerElectricMachine.java b/common/mekanism/common/inventory/container/ContainerElectricMachine.java index 9402da8d9..23da23b07 100644 --- a/common/mekanism/common/inventory/container/ContainerElectricMachine.java +++ b/common/mekanism/common/inventory/container/ContainerElectricMachine.java @@ -97,7 +97,7 @@ public class ContainerElectricMachine extends Container { if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) { - if (!mergeItemStack(slotStack, 0, 1, false)) + if(!mergeItemStack(slotStack, 0, 1, false)) { return null; } diff --git a/resources/assets/mekanism/gui/GuiPrecisionSawmill.png b/resources/assets/mekan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