From e77844904520793efa081f66d37356a42d384306 Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Mon, 21 Jul 2014 18:07:15 -0400 Subject: [PATCH] More work! Finished off the upgrade tab and removed upgrade slot from all upgrade-wielding containers. --- .../java/mekanism/client/ClientProxy.java | 4 ++ .../client/gui/GuiConfigurationTab.java | 3 - .../mekanism/client/gui/GuiUpgradeTab.java | 26 +++++---- .../java/mekanism/common/CommonProxy.java | 4 +- .../inventory/container/ContainerFactory.java | 56 ++++++------------- .../ContainerMetallurgicInfuser.java | 23 ++++---- .../inventory/container/ContainerPRC.java | 33 +++-------- .../tile/TileEntityMetallurgicInfuser.java | 4 +- 8 files changed, 60 insertions(+), 93 deletions(-) diff --git a/src/main/java/mekanism/client/ClientProxy.java b/src/main/java/mekanism/client/ClientProxy.java index 4e7ac4bd2..38d0b44e6 100644 --- a/src/main/java/mekanism/client/ClientProxy.java +++ b/src/main/java/mekanism/client/ClientProxy.java @@ -45,6 +45,7 @@ import mekanism.client.gui.GuiSalinationController; import mekanism.client.gui.GuiSeismicReader; import mekanism.client.gui.GuiSeismicVibrator; import mekanism.client.gui.GuiTeleporter; +import mekanism.client.gui.GuiUpgradeManagement; import mekanism.client.render.MekanismRenderer; import mekanism.client.render.RenderGlowPanel; import mekanism.client.render.RenderPartTransmitter; @@ -86,6 +87,7 @@ import mekanism.client.sound.SoundMap; import mekanism.common.CommonProxy; import mekanism.common.IElectricChest; import mekanism.common.IInvConfiguration; +import mekanism.common.IUpgradeTile; import mekanism.common.Mekanism; import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.entity.EntityBabySkeleton; @@ -465,6 +467,8 @@ public class ClientProxy extends CommonProxy return new GuiPortableTank(player.inventory, (TileEntityPortableTank)tileEntity); case 42: return new GuiFluidicPlenisher(player.inventory, (TileEntityFluidicPlenisher)tileEntity); + case 43: + return new GuiUpgradeManagement(player.inventory, (IUpgradeTile)tileEntity); } return null; diff --git a/src/main/java/mekanism/client/gui/GuiConfigurationTab.java b/src/main/java/mekanism/client/gui/GuiConfigurationTab.java index de7233434..270851f2c 100644 --- a/src/main/java/mekanism/client/gui/GuiConfigurationTab.java +++ b/src/main/java/mekanism/client/gui/GuiConfigurationTab.java @@ -2,7 +2,6 @@ package mekanism.client.gui; import mekanism.api.Coord4D; import mekanism.client.sound.SoundHandler; -import mekanism.common.IRedstoneControl; import mekanism.common.Mekanism; import mekanism.common.network.PacketSimpleGui.SimpleGuiMessage; import mekanism.common.util.MekanismUtils; @@ -68,8 +67,6 @@ public class GuiConfigurationTab extends GuiElement @Override public void mouseClicked(int xAxis, int yAxis, int button) { - IRedstoneControl control = (IRedstoneControl)tileEntity; - if(button == 0) { if(xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) diff --git a/src/main/java/mekanism/client/gui/GuiUpgradeTab.java b/src/main/java/mekanism/client/gui/GuiUpgradeTab.java index dd94bc319..489fca465 100644 --- a/src/main/java/mekanism/client/gui/GuiUpgradeTab.java +++ b/src/main/java/mekanism/client/gui/GuiUpgradeTab.java @@ -4,7 +4,6 @@ import mekanism.api.Coord4D; import mekanism.client.sound.SoundHandler; import mekanism.common.IUpgradeTile; import mekanism.common.Mekanism; -import mekanism.common.network.PacketRemoveUpgrade.RemoveUpgradeMessage; import mekanism.common.network.PacketSimpleGui.SimpleGuiMessage; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; @@ -34,12 +33,15 @@ public class GuiUpgradeTab extends GuiElement { mc.renderEngine.bindTexture(RESOURCE); - guiObj.drawTexturedRect(guiWidth + 176, guiHeight + 6, 0, 0, 26, 63); - - IUpgradeTile upgradeTile = (IUpgradeTile)tileEntity; - int displayInt = upgradeTile.getComponent().getScaledUpgradeProgress(14); - - guiObj.drawTexturedRect(guiWidth + 180, guiHeight + 30, 26, 0, 10, displayInt); + guiObj.drawTexturedRect(guiWidth + 176, guiHeight + 6, 0, 0, 26, 26); + + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) + { + guiObj.drawTexturedRect(guiWidth + 179, guiHeight + 10, 26, 0, 18, 18); + } + else { + guiObj.drawTexturedRect(guiWidth + 179, guiHeight + 10, 26, 18, 18, 18); + } mc.renderEngine.bindTexture(defaultLocation); } @@ -56,7 +58,6 @@ public class GuiUpgradeTab extends GuiElement displayTooltip(MekanismUtils.localize("gui.upgrades"), xAxis, yAxis); } - mc.renderEngine.bindTexture(defaultLocation); } @@ -66,10 +67,13 @@ public class GuiUpgradeTab extends GuiElement @Override public void mouseClicked(int xAxis, int yAxis, int button) { - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) + if(button == 0) { - Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tileEntity), 9)); - SoundHandler.playSound("gui.button.press"); + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) + { + Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tileEntity), 43)); + SoundHandler.playSound("gui.button.press"); + } } } } diff --git a/src/main/java/mekanism/common/CommonProxy.java b/src/main/java/mekanism/common/CommonProxy.java index e80e59ec5..68f701f58 100644 --- a/src/main/java/mekanism/common/CommonProxy.java +++ b/src/main/java/mekanism/common/CommonProxy.java @@ -2,7 +2,6 @@ package mekanism.common; import java.io.File; -import mekanism.api.Coord4D; import mekanism.api.MekanismAPI; import mekanism.common.EnergyDisplay.EnergyType; import mekanism.common.entity.EntityRobit; @@ -37,6 +36,7 @@ import mekanism.common.inventory.container.ContainerRotaryCondensentrator; import mekanism.common.inventory.container.ContainerSalinationController; import mekanism.common.inventory.container.ContainerSeismicVibrator; import mekanism.common.inventory.container.ContainerTeleporter; +import mekanism.common.inventory.container.ContainerUpgradeManagement; import mekanism.common.tile.TileEntityAdvancedElectricMachine; import mekanism.common.tile.TileEntityAdvancedFactory; import mekanism.common.tile.TileEntityBin; @@ -426,6 +426,8 @@ public class CommonProxy return new ContainerPortableTank(player.inventory, (TileEntityPortableTank)tileEntity); case 42: return new ContainerFluidicPlenisher(player.inventory, (TileEntityFluidicPlenisher)tileEntity); + case 43: + return new ContainerUpgradeManagement(player.inventory, (IUpgradeTile)tileEntity); } return null; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerFactory.java b/src/main/java/mekanism/common/inventory/container/ContainerFactory.java index 35a35cc07..dfba80122 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerFactory.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerFactory.java @@ -3,7 +3,6 @@ package mekanism.common.inventory.container; import mekanism.common.IFactory.RecipeType; import mekanism.common.Tier; import mekanism.common.Tier.FactoryTier; -import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge; import mekanism.common.inventory.slot.SlotMachineUpgrade; import mekanism.common.inventory.slot.SlotOutput; @@ -25,7 +24,6 @@ public class ContainerFactory extends Container { tileEntity = tentity; - addSlotToContainer(new SlotMachineUpgrade(tentity, 0, 180, 11)); addSlotToContainer(new SlotDischarge(tentity, 1, 7, 13)); addSlotToContainer(new Slot(tentity, 2, 180, 75)); addSlotToContainer(new Slot(tentity, 3, 180, 112)); @@ -37,14 +35,14 @@ public class ContainerFactory extends Container { int xAxis = 55 + (i*38); - addSlotToContainer(new Slot(tentity, 5+i, xAxis, 13)); + addSlotToContainer(new Slot(tentity, 4+i, xAxis, 13)); } for(int i = 0; i < tileEntity.tier.processes; i++) { int xAxis = 55 + (i*38); - addSlotToContainer(new SlotOutput(tentity, tileEntity.tier.processes+5+i, xAxis, 57)); + addSlotToContainer(new SlotOutput(tentity, tileEntity.tier.processes+4+i, xAxis, 57)); } } else if(tileEntity.tier == FactoryTier.ADVANCED) @@ -53,14 +51,14 @@ public class ContainerFactory extends Container { int xAxis = 35 + (i*26); - addSlotToContainer(new Slot(tentity, 5+i, xAxis, 13)); + addSlotToContainer(new Slot(tentity, 4+i, xAxis, 13)); } for(int i = 0; i < tileEntity.tier.processes; i++) { int xAxis = 35 + (i*26); - addSlotToContainer(new SlotOutput(tentity, tileEntity.tier.processes+5+i, xAxis, 57)); + addSlotToContainer(new SlotOutput(tentity, tileEntity.tier.processes+4+i, xAxis, 57)); } } else if(tileEntity.tier == FactoryTier.ELITE) @@ -69,14 +67,14 @@ public class ContainerFactory extends Container { int xAxis = 29 + (i*19); - addSlotToContainer(new Slot(tentity, 5+i, xAxis, 13)); + addSlotToContainer(new Slot(tentity, 4+i, xAxis, 13)); } for(int i = 0; i < tileEntity.tier.processes; i++) { int xAxis = 29 + (i*19); - addSlotToContainer(new SlotOutput(tentity, tileEntity.tier.processes+5+i, xAxis, 57)); + addSlotToContainer(new SlotOutput(tentity, tileEntity.tier.processes+4+i, xAxis, 57)); } } @@ -84,7 +82,7 @@ public class ContainerFactory extends Container for(slotX = 0; slotX < 3; slotX++) { - for(int slotY = 0; slotY < 9; ++slotY) + for(int slotY = 0; slotY < 9; slotY++) { addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 95 + slotX * 18)); } @@ -132,14 +130,14 @@ public class ContainerFactory extends Container return null; } } - else if(slotID != 2 && slotID != 3 && isProperMachine(slotStack) && !slotStack.isItemEqual(tileEntity.getMachineStack())) + else if(slotID != 1 && slotID != 2 && isProperMachine(slotStack) && !slotStack.isItemEqual(tileEntity.getMachineStack())) { - if(!mergeItemStack(slotStack, 2, 3, false)) + if(!mergeItemStack(slotStack, 1, 2, false)) { return null; } } - else if(slotID == 3) + else if(slotID == 2) { if(!mergeItemStack(slotStack, tileEntity.inventory.length, inventorySlots.size(), true)) { @@ -150,7 +148,7 @@ public class ContainerFactory extends Container { if(!isInputSlot(slotID)) { - if(!mergeItemStack(slotStack, 5, 5+tileEntity.tier.processes, false)) + if(!mergeItemStack(slotStack, 4, 4+tileEntity.tier.processes, false)) { return null; } @@ -164,14 +162,14 @@ public class ContainerFactory extends Container } else if(ChargeUtils.canBeDischarged(slotStack)) { - if(slotID != 1) + if(slotID != 0) { - if(!mergeItemStack(slotStack, 1, 2, false)) + if(!mergeItemStack(slotStack, 0, 1, false)) { return null; } } - else if(slotID == 1) + else if(slotID == 0) { if(!mergeItemStack(slotStack, tileEntity.inventory.length, inventorySlots.size(), true)) { @@ -183,23 +181,7 @@ public class ContainerFactory extends Container { if(slotID > tileEntity.inventory.length-1) { - if(!mergeItemStack(slotStack, 4, 5, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, tileEntity.inventory.length, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotStack.getItem() instanceof ItemMachineUpgrade) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) + if(!mergeItemStack(slotStack, 3, 4, false)) { return null; } @@ -259,13 +241,9 @@ public class ContainerFactory extends Container { if(itemStack != null && itemStack.getItem() instanceof ItemBlockMachine) { - MachineType type = MachineType.get(itemStack); - - if(type == MachineType.ENERGIZED_SMELTER || type == MachineType.ENRICHMENT_CHAMBER || - type == MachineType.CRUSHER || type == MachineType.OSMIUM_COMPRESSOR || - type == MachineType.COMBINER || type == MachineType.PURIFICATION_CHAMBER) + for(RecipeType type : RecipeType.values()) { - return true; + return itemStack.isItemEqual(type.getStack()); } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java b/src/main/java/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java index 3e15e8425..3958df8c7 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java @@ -23,22 +23,21 @@ public class ContainerMetallurgicInfuser extends Container public ContainerMetallurgicInfuser(InventoryPlayer inventory, TileEntityMetallurgicInfuser tentity) { tileEntity = tentity; - addSlotToContainer(new SlotMachineUpgrade(tentity, 0, 180, 11)); + addSlotToContainer(new SlotDischarge(tentity, 0, 143, 35)); addSlotToContainer(new Slot(tentity, 1, 17, 35)); addSlotToContainer(new Slot(tentity, 2, 51, 43)); addSlotToContainer(new SlotOutput(tentity, 3, 109, 43)); - addSlotToContainer(new SlotDischarge(tentity, 4, 143, 35)); int slotX; - for(slotX = 0; slotX < 3; ++slotX) + for(slotX = 0; slotX < 3; slotX++) { - for(int slotY = 0; slotY < 9; ++slotY) + 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) + for(slotX = 0; slotX < 9; slotX++) { addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); } @@ -73,7 +72,7 @@ public class ContainerMetallurgicInfuser extends Container ItemStack slotStack = currentSlot.getStack(); stack = slotStack.copy(); - if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3 && slotID != 4) + if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) { if(InfuseRegistry.getObject(slotStack) != null && (tileEntity.type == null || tileEntity.type == InfuseRegistry.getObject(slotStack).type)) { @@ -104,22 +103,22 @@ public class ContainerMetallurgicInfuser extends Container } } else { - if(slotID >= 5 && slotID <= 31) + if(slotID >= 4 && slotID <= 30) { - if(!mergeItemStack(slotStack, 32, inventorySlots.size(), false)) + if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) { return null; } } - else if(slotID > 31) + else if(slotID > 30) { - if(!mergeItemStack(slotStack, 5, 31, false)) + if(!mergeItemStack(slotStack, 4, 30, false)) { return null; } } else { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { return null; } @@ -127,7 +126,7 @@ public class ContainerMetallurgicInfuser extends Container } } else { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { return null; } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerPRC.java b/src/main/java/mekanism/common/inventory/container/ContainerPRC.java index caa26ffc9..cd44ecd2b 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerPRC.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerPRC.java @@ -23,7 +23,6 @@ public class ContainerPRC extends Container addSlotToContainer(new Slot(tentity, 0, 54, 35)); addSlotToContainer(new SlotDischarge(tentity, 1, 141, 19)); addSlotToContainer(new SlotOutput(tentity, 2, 116, 35)); - addSlotToContainer(new SlotMachineUpgrade(tentity, 3, 180, 11)); int slotX; for(slotX = 0; slotX < 3; ++slotX) @@ -71,7 +70,7 @@ public class ContainerPRC extends Container if(slotID == 2) { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { return null; } @@ -87,7 +86,7 @@ public class ContainerPRC extends Container } else if(slotID == 1) { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { return null; } @@ -103,45 +102,29 @@ public class ContainerPRC extends Container } } 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, 4, inventorySlots.size(), true)) + if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { return null; } } } else { - if(slotID >= 4 && slotID <= 30) + if(slotID >= 3 && slotID <= 29) { - if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) + if(!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) { return null; } } - else if(slotID > 30) + else if(slotID > 29) { - if(!mergeItemStack(slotStack, 4, 30, false)) + if(!mergeItemStack(slotStack, 3, 29, false)) { return null; } } else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { return null; } diff --git a/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java b/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java index ad8344d57..3348c8a9b 100644 --- a/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java +++ b/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java @@ -80,7 +80,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem /** This machine's current RedstoneControl type. */ public RedstoneControl controlType = RedstoneControl.DISABLED; - public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 0); + public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 4); public TileComponentEjector ejectorComponent; public TileEntityMetallurgicInfuser() @@ -131,7 +131,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem } } - ChargeUtils.discharge(4, this); + ChargeUtils.discharge(0, this); if(inventory[1] != null) {