aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/items/armor/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/common/items/armor/gui')
-rw-r--r--src/main/java/gregtech/common/items/armor/gui/ContainerBasicArmor.java48
-rw-r--r--src/main/java/gregtech/common/items/armor/gui/ContainerElectricArmor1.java53
-rw-r--r--src/main/java/gregtech/common/items/armor/gui/ContainerModularArmor.java169
-rw-r--r--src/main/java/gregtech/common/items/armor/gui/FluidSync.java67
-rw-r--r--src/main/java/gregtech/common/items/armor/gui/FluidSync2.java67
-rw-r--r--src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java311
-rw-r--r--src/main/java/gregtech/common/items/armor/gui/GuiModularArmor.java203
-rw-r--r--src/main/java/gregtech/common/items/armor/gui/InventoryArmor.java237
-rw-r--r--src/main/java/gregtech/common/items/armor/gui/SlotArmor.java18
-rw-r--r--src/main/java/gregtech/common/items/armor/gui/SlotFluid.java33
-rw-r--r--src/main/java/gregtech/common/items/armor/gui/SlotLocked.java33
11 files changed, 1239 insertions, 0 deletions
diff --git a/src/main/java/gregtech/common/items/armor/gui/ContainerBasicArmor.java b/src/main/java/gregtech/common/items/armor/gui/ContainerBasicArmor.java
new file mode 100644
index 0000000000..a2ee329099
--- /dev/null
+++ b/src/main/java/gregtech/common/items/armor/gui/ContainerBasicArmor.java
@@ -0,0 +1,48 @@
+package gregtech.common.items.armor.gui;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+public class ContainerBasicArmor extends ContainerModularArmor {
+
+ public ContainerBasicArmor(EntityPlayer player, InventoryArmor aInvArmor) {
+ super(player, aInvArmor);
+ }
+
+ public void addSlots(InventoryPlayer aInventoryPlayer) {
+ addSlotToContainer(new SlotArmor(mInvArmor, 0, 118, 6));
+ addSlotToContainer(new SlotArmor(mInvArmor, 1, 136, 6));
+ addSlotToContainer(new SlotArmor(mInvArmor, 2, 154, 6));
+ addSlotToContainer(new SlotArmor(mInvArmor, 3, 118, 24));
+ addSlotToContainer(new SlotArmor(mInvArmor, 4, 136, 24));
+ addSlotToContainer(new SlotArmor(mInvArmor, 5, 154, 24));
+ addSlotToContainer(new SlotArmor(mInvArmor, 6, 118, 42));
+ addSlotToContainer(new SlotArmor(mInvArmor, 7, 136, 42));
+ addSlotToContainer(new SlotArmor(mInvArmor, 8, 154, 42));
+
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 9; j++) {
+ addSlotToContainer(new Slot(aInventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
+ }
+ }
+
+ for (int i = 0; i < 9; i++) {
+ ItemStack stackInSlot = aInventoryPlayer.getStackInSlot(i);
+ if(isIdenticalItem(mInvArmor.parent,stackInSlot)){
+ addSlotToContainer(new SlotLocked(aInventoryPlayer,i,8+i*18,142));
+ }else{
+ addSlotToContainer(new Slot(aInventoryPlayer, i, 8 + i * 18, 142));}
+ }
+ }
+
+ public int getSlotCount() {
+ return 9;
+ }
+
+ public int getShiftClickSlotCount() {
+ return 9;
+ }
+
+}
diff --git a/src/main/java/gregtech/common/items/armor/gui/ContainerElectricArmor1.java b/src/main/java/gregtech/common/items/armor/gui/ContainerElectricArmor1.java
new file mode 100644
index 0000000000..02c8f016bb
--- /dev/null
+++ b/src/main/java/gregtech/common/items/armor/gui/ContainerElectricArmor1.java
@@ -0,0 +1,53 @@
+package gregtech.common.items.armor.gui;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+public class ContainerElectricArmor1 extends ContainerBasicArmor {
+
+ public ContainerElectricArmor1(EntityPlayer player, InventoryArmor aInvArmor) {
+ super(player, aInvArmor);
+ }
+
+ public void addSlots(InventoryPlayer aInventoryPlayer) {
+ addSlotToContainer(new SlotArmor(mInvArmor, 0, 118, 6));
+ addSlotToContainer(new SlotArmor(mInvArmor, 1, 136, 6));
+ addSlotToContainer(new SlotArmor(mInvArmor, 2, 154, 6));
+ addSlotToContainer(new SlotArmor(mInvArmor, 3, 118, 24));
+ addSlotToContainer(new SlotArmor(mInvArmor, 4, 136, 24));
+ addSlotToContainer(new SlotArmor(mInvArmor, 5, 154, 24));
+ addSlotToContainer(new SlotArmor(mInvArmor, 6, 118, 42));
+ addSlotToContainer(new SlotArmor(mInvArmor, 7, 136, 42));
+ addSlotToContainer(new SlotArmor(mInvArmor, 8, 154, 42));
+ addSlotToContainer(new SlotArmor(mInvArmor, 9, 118, 60));
+ addSlotToContainer(new SlotArmor(mInvArmor, 10, 136, 60));
+ addSlotToContainer(new SlotArmor(mInvArmor, 11, 154, 60));
+
+ addSlotToContainer(new SlotFluid(mInvArmor,12,94,32));
+
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 9; j++) {
+ addSlotToContainer(new Slot(aInventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
+ }
+ }
+
+ for (int i = 0; i < 9; i++) {
+ ItemStack stackInSlot = aInventoryPlayer.getStackInSlot(i);
+ if(isIdenticalItem(mInvArmor.parent,stackInSlot)){
+ addSlotToContainer(new SlotLocked(aInventoryPlayer,i,8+i*18,142));
+ }else{
+ addSlotToContainer(new Slot(aInventoryPlayer, i, 8 + i * 18, 142));}
+ }
+ }
+
+ public int getSlotCount() {
+ return 12;
+ }
+
+ public int getShiftClickSlotCount() {
+ return 12;
+ }
+
+}
diff --git a/src/main/java/gregtech/common/items/armor/gui/ContainerModularArmor.java b/src/main/java/gregtech/common/items/armor/gui/ContainerModularArmor.java
new file mode 100644
index 0000000000..0258a3eb3c
--- /dev/null
+++ b/src/main/java/gregtech/common/items/armor/gui/ContainerModularArmor.java
@@ -0,0 +1,169 @@
+package gregtech.common.items.armor.gui;
+
+import gregtech.common.items.armor.ArmorData;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.oredict.OreDictionary;
+
+public abstract class ContainerModularArmor extends Container {
+
+ public InventoryArmor mInvArmor;
+
+ public ContainerModularArmor(EntityPlayer player, InventoryArmor aInvArmor) {
+ this.mInvArmor = aInvArmor;
+ addSlots(player.inventory);
+ }
+
+ public ArmorData getData(EntityPlayer aPlayer){
+ return null;
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer aPlayer) {
+ return true;
+ }
+
+ public abstract void addSlots(InventoryPlayer aInventoryPlayer);
+
+ public abstract int getSlotCount();
+
+ public abstract int getShiftClickSlotCount();
+
+ public void saveInventory(EntityPlayer entityplayer) {
+ mInvArmor.onGuiSaved(entityplayer);
+ }
+
+ @Override
+ public void onContainerClosed(EntityPlayer player) {
+ super.onContainerClosed(player);
+ if (!player.worldObj.isRemote) {
+ saveInventory(player);
+ }
+ }
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
+ if (player == null) {
+ return null;
+ }
+
+ ItemStack originalStack = null;
+ Slot slot = (Slot) inventorySlots.get(slotIndex);
+ int numSlots = inventorySlots.size();
+ if (slot != null && slot.getHasStack()) {
+ ItemStack stackInSlot = slot.getStack();
+ originalStack = stackInSlot.copy();
+ if (slotIndex >= numSlots - 9 * 4 && tryShiftItem(stackInSlot, numSlots)) {
+ } else if (slotIndex >= numSlots - 9 * 4 && slotIndex < numSlots - 9) {
+ if (!shiftItemStack(stackInSlot, numSlots - 9, numSlots)) {
+ return null;
+ }
+ } else if (slotIndex >= numSlots - 9 && slotIndex < numSlots) {
+ if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots - 9)) {
+ return null;
+ }
+ } else if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots)) {
+ return null;
+ }
+ slot.onSlotChange(stackInSlot, originalStack);
+ if (stackInSlot.stackSize <= 0) {
+ slot.putStack(null);
+ } else {
+ slot.onSlotChanged();
+ }
+ if (stackInSlot.stackSize == originalStack.stackSize) {
+ return null;
+ }
+ slot.onPickupFromSlot(player, stackInSlot);
+ }
+ return originalStack;
+ }
+
+ private boolean tryShiftItem(ItemStack stackToShift, int numSlots) {
+ for (int machineIndex = 0; machineIndex < numSlots - 9 * 4; machineIndex++) {
+ Slot slot = (Slot) inventorySlots.get(machineIndex);
+ if (slot.getHasStack()) {
+ continue;
+ }
+ if(slot instanceof SlotLocked){
+ continue;
+ }
+ if(slot instanceof SlotFluid){
+ continue;
+ }
+
+ if (!slot.isItemValid(stackToShift)) {
+ continue;
+ }
+ if (shiftItemStack(stackToShift, machineIndex, machineIndex + 1)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected boolean shiftItemStack(ItemStack stackToShift, int start, int end) {
+ boolean changed = false;
+ if (stackToShift.isStackable()) {
+ for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < end; slotIndex++) {
+ Slot slot = (Slot) inventorySlots.get(slotIndex);
+ ItemStack stackInSlot = slot.getStack();
+ if (stackInSlot != null && isIdenticalItem(stackInSlot, stackToShift)) {
+ int resultingStackSize = stackInSlot.stackSize + stackToShift.stackSize;
+ int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
+ if (resultingStackSize <= max) {
+ stackToShift.stackSize = 0;
+ stackInSlot.stackSize = resultingStackSize;
+ slot.onSlotChanged();
+ changed = true;
+ } else if (stackInSlot.stackSize < max) {
+ stackToShift.stackSize -= max - stackInSlot.stackSize;
+ stackInSlot.stackSize = max;
+ slot.onSlotChanged();
+ changed = true;
+ }
+ }
+ }
+ }
+ if (stackToShift.stackSize > 0) {
+ for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < end; slotIndex++) {
+ Slot slot = (Slot) inventorySlots.get(slotIndex);
+ ItemStack stackInSlot = slot.getStack();
+ if (stackInSlot == null) {
+ int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
+ stackInSlot = stackToShift.copy();
+ stackInSlot.stackSize = Math.min(stackToShift.stackSize, max);
+ stackToShift.stackSize -= stackInSlot.stackSize;
+ slot.putStack(stackInSlot);
+ slot.onSlotChanged();
+ changed = true;
+ }
+ }
+ }
+ return changed;
+ }
+
+ public static boolean isIdenticalItem(ItemStack lhs, ItemStack rhs) {
+ if (lhs == null || rhs == null) {
+ return false;
+ }
+
+ if (lhs.getItem() != rhs.getItem()) {
+ return false;
+ }
+
+ if (lhs.getItemDamage() != OreDictionary.WILDCARD_VALUE) {
+ if (lhs.getItemDamage() != rhs.getItemDamage()) {
+ return false;
+ }
+ }
+
+ return ItemStack.areItemStackTagsEqual(lhs, rhs);
+ }
+
+}
diff --git a/src/main/java/gregtech/common/items/armor/gui/FluidSync.java b/src/main/java/gregtech/common/items/armor/gui/FluidSync.java
new file mode 100644
index 0000000000..8f1aef56d1
--- /dev/null
+++ b/src/main/java/gregtech/common/items/armor/gui/FluidSync.java
@@ -0,0 +1,67 @@
+package gregtech.common.items.armor.gui;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.WorldServer;
+import net.minecraftforge.common.DimensionManager;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+
+import com.google.common.base.Charsets;
+import com.google.common.io.ByteArrayDataInput;
+import com.google.common.io.ByteArrayDataOutput;
+import com.google.common.io.ByteStreams;
+
+public class FluidSync /**implements IPacket**/ {
+ String playerName;
+ int amount;
+ String fluid;
+
+// @Override
+ public byte getPacketID() {
+ return 0;
+ }
+
+ public FluidSync(String player, int amount, String fluid) {
+ this.playerName = player;
+ this.amount = amount;
+ this.fluid = fluid.toLowerCase();
+ }
+
+// @Override
+ public ByteArrayDataOutput encode() {
+ ByteArrayDataOutput rOut = ByteStreams.newDataOutput(4);
+ rOut.writeUTF(playerName + ";" + amount + ";" + fluid);
+ return rOut;
+ }
+
+// @Override
+// public IPacket decode(ByteArrayDataInput aData) {
+// String tmp = aData.readUTF();
+// String[] tmp2 = tmp.split(";");
+// return new FluidSync(tmp2[0], Integer.parseInt(tmp2[1]), tmp2[2].toLowerCase());
+// }
+//
+// @Override
+// public void process(IBlockAccess aWorld, INetworkHandler aNetworkHandler) {
+// WorldServer[] worlds = DimensionManager.getWorlds();
+// EntityPlayer tmp;
+// for (int i = 0; i < worlds.length; i++) {
+// tmp = worlds[i].getPlayerEntityByName(playerName);
+// if (tmp != null) {
+// try {
+// if (fluid.equals("null")) {
+// tmp.openContainer.getSlot(12).putStack(null);
+// } else {
+// tmp.openContainer.getSlot(12).putStack(UT.Fluids.display(new FluidStack(FluidRegistry.getFluid(fluid), amount), true));
+// }
+// tmp.openContainer.detectAndSendChanges();
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+//
+// }
+// }
+// }
+
+}
diff --git a/src/main/java/gregtech/common/items/armor/gui/FluidSync2.java b/src/main/java/gregtech/common/items/armor/gui/FluidSync2.java
new file mode 100644
index 0000000000..75c3c6d363
--- /dev/null
+++ b/src/main/java/gregtech/common/items/armor/gui/FluidSync2.java
@@ -0,0 +1,67 @@
+package gregtech.common.items.armor.gui;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.WorldServer;
+import net.minecraftforge.common.DimensionManager;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+
+import com.google.common.base.Charsets;
+import com.google.common.io.ByteArrayDataInput;
+import com.google.common.io.ByteArrayDataOutput;
+import com.google.common.io.ByteStreams;
+
+public class FluidSync2 /**implements IPacket**/ {
+ String playerName;
+
+// @Override
+ public byte getPacketID() {
+ return 1;
+ }
+
+ public FluidSync2(String player) {
+ this.playerName = player;
+ }
+
+// @Override
+ public ByteArrayDataOutput encode() {
+ ByteArrayDataOutput rOut = ByteStreams.newDataOutput(4);
+ rOut.writeUTF(playerName);
+ return rOut;
+ }
+
+// @Override
+// public IPacket decode(ByteArrayDataInput aData) {
+// return new FluidSync2(aData.readUTF());
+// }
+//
+// @Override
+// public void process(IBlockAccess aWorld, INetworkHandler aNetworkHandler) {
+// WorldServer[] worlds = DimensionManager.getWorlds();
+// EntityPlayer tmp;
+// for (int i = 0; i < worlds.length; i++) {
+// tmp = worlds[i].getPlayerEntityByName(playerName);
+// if (tmp != null) {
+// try {
+// ItemStack tmp2 = tmp.inventory.getItemStack();
+// ItemStack tmp3 = UT.Fluids.getContainerForFilledItem(tmp2, true);
+// if (tmp2.stackSize <= 1) {
+// tmp2 = null;
+// } else {
+// tmp2.stackSize--;
+// }
+// tmp.inventory.setItemStack(tmp2);
+// if(tmp3!=null){
+// tmp3.stackSize=1;
+// tmp.inventory.addItemStackToInventory(tmp3);}
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+//
+// }
+// }
+// }
+
+}
diff --git a/src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java b/src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java
new file mode 100644
index 0000000000..3ea092a2ab
--- /dev/null
+++ b/src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java
@@ -0,0 +1,311 @@
+package gregtech.common.items.armor.gui;
+
+import gregtech.api.util.GT_LanguageManager;
+import gregtech.api.util.GT_Utility;
+import gregtech.common.items.armor.components.StatType;
+
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Items;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.ResourceLocation;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.IFluidContainerItem;
+
+@SideOnly(Side.CLIENT)
+public class GuiElectricArmor1 extends GuiContainer {
+ ContainerModularArmor cont;
+ EntityPlayer player;
+ private int tab;
+
+ public GuiElectricArmor1(ContainerModularArmor containerModularArmor, EntityPlayer aPlayer) {
+ super(containerModularArmor);
+ player = aPlayer;
+ cont = containerModularArmor;
+ tab = 0;
+ }
+
+ public String seperateNumber(long number){
+ DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.US);
+ DecimalFormatSymbols symbols = formatter.getDecimalFormatSymbols();
+ symbols.setGroupingSeparator(' ');
+ return formatter.format(number);
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int x, int y) {
+ int xStart = (width - xSize) / 2;
+ int yStart = (height - ySize) / 2;
+ int x2 = x - xStart;
+ int y2 = y - yStart;
+ drawTooltip(x2, y2 + 5);
+ }
+
+ @Override
+ protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
+ GL11.glColor4f(1F, 1F, 1F, 1F);
+ this.mc.getTextureManager().bindTexture(new ResourceLocation("gregtech", "textures/gui/armorgui3x4.png"));
+ int xStart = (width - xSize) / 2;
+ int yStart = (height - ySize) / 2;
+ //Draw background
+ drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);
+ //Draw active arrows
+ drawTexturedModalRect(xStart + 10, yStart + 70, 219, 11, 14, 5);
+ //Draw active armor symbol
+ switch (cont.mInvArmor.data.type) {
+ case 0:
+ drawTexturedModalRect(xStart + 73, yStart + 68, 177, 10, 10, 9);
+ break;
+ case 1:
+ drawTexturedModalRect(xStart + 83, yStart + 68, 187, 10, 10, 9);
+ break;
+ case 2:
+ drawTexturedModalRect(xStart + 93, yStart + 68, 197, 10, 10, 9);
+ break;
+ case 3:
+ drawTexturedModalRect(xStart + 103, yStart + 68, 207, 10, 10, 9);
+ break;
+ default:
+ break;
+ }
+ //Draw active tab
+ switch(tab){
+ case 0:
+ break;
+ case 1:
+ drawTexturedModalRect(xStart + 7, yStart + 14, 2, 167, 104, 54);
+ break;
+ case 2:
+ drawTexturedModalRect(xStart + 7, yStart + 14, 107, 167, 104, 54);
+ break;
+ default:
+ break;
+ }
+
+ if(cont.mInvArmor.data.mStat.get(StatType.TANKCAP)>0){
+ drawTexturedModalRect(xStart + 94, yStart + 32, 231, 69, 16, 34);
+ }
+
+ int bar = (int) Math.floor(18 * (cont.mInvArmor.data.mStat.get(StatType.WEIGHT)/(float)1000));
+ drawTexturedModalRect(xStart + 15, yStart + 7, 217, 26, bar, 5);
+ drawTexturedModalRect(xStart + bar + 15, yStart + 7, 197+bar, 26, 18-bar, 5);
+
+ if(tab==0){
+ //processing power bar
+ bar = Math.min((int) Math.floor(52 * ((float)cont.mInvArmor.data.mStat.get(StatType.PROCESSINGPOWERUSED)/(float)cont.mInvArmor.data.mStat.get(StatType.PROCESSINGPOWER))),52);
+ drawTexturedModalRect(xStart + 17, yStart + 17, 177, 146, bar, 5);
+ drawTexturedModalRect(xStart + bar + 17, yStart + 17, 177+bar, 139, 52-bar, 5);
+ }else if(tab==1){
+
+ }else{
+ //Def tab values
+ if(cont.mInvArmor.data.mStat.get(StatType.PHYSICALDEFENCE)>0)drawTexturedModalRect(xStart + 30, yStart + 20, 186, 33, 7, 7);
+ drawBars(31, 20, cont.mInvArmor.data.mStat.get(StatType.PHYSICALDEFENCE));
+ if(cont.mInvArmor.data.mStat.get(StatType.PROJECTILEDEFENCE)>0)drawTexturedModalRect(xStart + 30, yStart + 29, 186, 42, 7, 7);
+ drawBars(31, 29, cont.mInvArmor.data.mStat.get(StatType.PROJECTILEDEFENCE));
+ if(cont.mInvArmor.data.mStat.get(StatType.FIREDEFENCE)>0)drawTexturedModalRect(xStart + 30, yStart + 38, 186, 51, 7, 7);
+ drawBars(31, 38, cont.mInvArmor.data.mStat.get(StatType.FIREDEFENCE));
+ if(cont.mInvArmor.data.mStat.get(StatType.MAGICDEFENCE)>0)drawTexturedModalRect(xStart + 30, yStart + 47, 186, 60, 7, 7);
+ drawBars(31, 47, cont.mInvArmor.data.mStat.get(StatType.MAGICDEFENCE));
+ if(cont.mInvArmor.data.mStat.get(StatType.EXPLOSIONDEFENCE)>0)drawTexturedModalRect(xStart + 30, yStart + 56, 186, 69, 7, 7);
+ drawBars(31, 56, cont.mInvArmor.data.mStat.get(StatType.EXPLOSIONDEFENCE));
+ if(cont.mInvArmor.data.mStat.get(StatType.RADIATIONDEFENCE)>0)drawTexturedModalRect(xStart + 61, yStart + 20, 186, 87, 7, 7);
+ drawBars(62, 20, cont.mInvArmor.data.mStat.get(StatType.RADIATIONDEFENCE));
+ if(cont.mInvArmor.data.mStat.get(StatType.ELECTRICALDEFENCE)>0)drawTexturedModalRect(xStart + 61, yStart + 29, 186, 96, 7, 7);
+ drawBars(62, 29, cont.mInvArmor.data.mStat.get(StatType.ELECTRICALDEFENCE));
+ if(cont.mInvArmor.data.mStat.get(StatType.WITHERDEFENCE)>0)drawTexturedModalRect(xStart + 61, yStart + 38, 186, 105, 7, 7);
+ drawBars(62, 38, cont.mInvArmor.data.mStat.get(StatType.WITHERDEFENCE));
+ if(cont.mInvArmor.data.mStat.get(StatType.FALLDEFENCE)>0)drawTexturedModalRect(xStart + 61, yStart + 47, 186, 114, 7, 7);
+ if(cont.mInvArmor.data.mStat.get(StatType.THORNS)>0)drawTexturedModalRect(xStart + 61, yStart + 56, 186, 123, 7, 7);
+ if(cont.mInvArmor.data.mStat.get(StatType.MAGNET)>0)drawTexturedModalRect(xStart + 70, yStart + 56, 186, 78, 7, 7);
+ }
+
+
+ }
+
+ protected void mouseClicked(int mouseX, int mouseY, int mouseBtn) {
+ int xStart = mouseX-((width - xSize) / 2);
+ int yStart = mouseY-((height - ySize) / 2);
+ if(yStart>68&&yStart<77){
+ if(xStart>18&&xStart<26){
+ tab++;
+ }else if(xStart>8&&xStart<17){
+ tab--;
+ }
+ if(tab>2){tab=0;}
+ if(tab<0){tab=2;}
+ if(xStart>72&&xStart<112){
+ if(xStart>72&&xStart<81&&cont.mInvArmor.data.helmet!=null){cont.mInvArmor.data.helmet.openGui=true;player.closeScreen();}
+ if(xStart>82&&xStart<91&&cont.mInvArmor.data.chestplate!=null){cont.mInvArmor.data.chestplate.openGui=true;player.closeScreen();}
+ if(xStart>92&&xStart<101&&cont.mInvArmor.data.leggings!=null){cont.mInvArmor.data.leggings.openGui=true;player.closeScreen();}
+ if(xStart>102&&xStart<112&&cont.mInvArmor.data.boots!=null){cont.mInvArmor.data.boots.openGui=true;player.closeScreen();}
+ }
+ }
+// Slot slot = getSlotAtPosition(mouseX, mouseY);
+// if (slot != null && slot instanceof SlotFluid && player != null) {
+// ItemStack tmp = player.inventory.getItemStack();
+// if (tmp == null) {
+// GTExtras.NET.sendToServer(new FluidSync(player.getCommandSenderName(), 0, "null"));
+// }
+// if (tmp != null && tmp.getItem() instanceof IFluidContainerItem) {
+// FluidStack tmp2 = ((IFluidContainerItem) tmp.getItem()).getFluid(tmp);
+// if (!slot.getHasStack() && tmp2 != null) {
+// slot.putStack(UT.Fluids.display(tmp2, true));
+// GTExtras.NET.sendToServer(new FluidSync(player.getCommandSenderName(), tmp2.amount, UT.Fluids.name(tmp2, false)));
+// ItemStack tmp4 = UT.Fluids.getContainerForFilledItem(tmp, true);
+// tmp4.stackSize = 1;
+// if (tmp.stackSize > 1) {
+// player.inventory.addItemStackToInventory(tmp4);
+// tmp.stackSize--;
+// player.inventory.setItemStack(tmp);
+// GTExtras.NET.sendToServer(new FluidSync2(player.getCommandSenderName()));
+// } else {
+// player.inventory.setItemStack(null);
+// player.inventory.addItemStackToInventory(tmp4);
+// GTExtras.NET.sendToServer(new FluidSync2(player.getCommandSenderName()));
+// }
+//
+// } else if (slot.getHasStack() && tmp2 != null) {
+// Item fluidSlot = slot.getStack().getItem();
+// if (fluidSlot.getDamage(slot.getStack()) == tmp2.getFluidID()) {
+// NBTTagCompound nbt = slot.getStack().getTagCompound();
+// if (nbt != null) {
+// tmp2.amount += nbt.getLong("mFluidDisplayAmount");
+// ItemStack tmp3 = player.inventory.getItemStack();
+// if (tmp3.stackSize <= 1) {
+// tmp3 = null;
+// } else {
+// tmp3.stackSize--;
+// }
+// player.inventory.setItemStack(tmp3);
+// GTExtras.NET.sendToServer(new FluidSync2(player.getCommandSenderName()));
+// slot.putStack(UT.Fluids.display(tmp2, true));
+// GTExtras.NET.sendToServer(new FluidSync(player.getCommandSenderName(), tmp2.amount, UT.Fluids.name(tmp2, false)));
+// }
+// }
+// }
+// }
+// }
+ super.mouseClicked(mouseX, mouseY, mouseBtn);
+ }
+
+ protected void drawTooltip(int x, int y) {
+ List<String> list = new ArrayList<String>();
+ //General tooltips
+ if(x>=7&&y>=11&&x<=33&&y<=17){
+ list.add(GT_LanguageManager.getTranslation("Weight") + ": " + cont.mInvArmor.data.mStat.get(StatType.WEIGHT));
+ list.add("Total Weight: "+cont.mInvArmor.data.maxWeight);
+ if (cont.mInvArmor.data.mStat.get(StatType.WEIGHT) > 1000)
+ list.add("Too Heavy!");
+ }
+ if(x>=56&&y>=11&&x<=112&&y<=17){
+ list.add("Stored Energy: "+seperateNumber(cont.mInvArmor.data.charge)+" EU");
+ }
+ if(y>74&&y<83){
+ if(x>8&&x<17){
+ list.add("Previous Page");
+ }else if(x>18&&x<27){
+ list.add("Next Page");
+ }else if(x>72&&x<80){
+ list.add("Helmet");
+ }else if(x>81&&x<90){
+ list.add("Chestplate");
+ }else if(x>91&&x<100){
+ list.add("Leggings");
+ }else if(x>101&&x<110){
+ list.add("Boots");
+ }
+ }
+ if(tab==0){
+ if(x>=93&&y>=36&&x<=110&&y<=71){list.add("Tank Capacity: "+cont.mInvArmor.data.mStat.get(StatType.TANKCAP)+"L");
+ }
+ if(x>=7&&y>=22&&x<=70&&y<=28){list.add("Processing Power Provided: "+cont.mInvArmor.data.mStat.get(StatType.PROCESSINGPOWER));
+ list.add("Processing Power Used: "+cont.mInvArmor.data.mStat.get(StatType.PROCESSINGPOWERUSED));
+ }
+ }else if(tab==1){
+
+ }else{
+ if (x >= 28 && x <= 58) {
+ if (y >= 25 && y <= 32) {
+ list.add(GT_LanguageManager.getTranslation("Physical Defence") + ": " + (Math.round(cont.mInvArmor.data.mStat.get(StatType.PHYSICALDEFENCE) * 1000) / 10.0) + "%");
+ } else if (y >= 33 && y <= 41) {
+ list.add(GT_LanguageManager.getTranslation("Projectile Defence") + ": " + (Math.round(cont.mInvArmor.data.mStat.get(StatType.PROJECTILEDEFENCE) * 1000) / 10.0) + "%");
+ } else if (y >= 42 && y <= 50) {
+ list.add(GT_LanguageManager.getTranslation("Fire Defence") + ": " + (Math.round(cont.mInvArmor.data.mStat.get(StatType.FIREDEFENCE) * 1000) / 10.0) + "%");
+ } else if (y >= 51 && y <= 59) {
+ list.add(GT_LanguageManager.getTranslation("Magical Defence") + ": " + (Math.round(cont.mInvArmor.data.mStat.get(StatType.MAGICDEFENCE) * 1000) / 10.0) + "%");
+ } else if (y >= 60 && y <= 68) {
+ list.add(GT_LanguageManager.getTranslation("Explosion Defence") + ": " + (Math.round(cont.mInvArmor.data.mStat.get(StatType.EXPLOSIONDEFENCE) * 1000) / 10.0) + "%");
+ }
+ } else if (x >= 59 && x <= 90) {
+ if (y >= 25 && y <= 32) {
+ list.add(GT_LanguageManager.getTranslation("Radiation Defence") + ": " + (Math.round(cont.mInvArmor.data.mStat.get(StatType.RADIATIONDEFENCE) * 1000) / 10.0) + "%");
+ if(cont.mInvArmor.data.mBStat.get(StatType.FULLRADIATIONARMOR)){
+ list.add(GT_LanguageManager.getTranslation("Radiation Immunity"));}
+ } else if (y >= 33 && y <= 41) {
+ list.add(GT_LanguageManager.getTranslation("Electrical Defence") + ": " + (Math.round(cont.mInvArmor.data.mStat.get(StatType.ELECTRICALDEFENCE) * 1000) / 10.0) + "%");
+ if(cont.mInvArmor.data.mBStat.get(StatType.FULLELECTRICARMOR)){
+ list.add(GT_LanguageManager.getTranslation("Electric Immunity"));}
+ } else if (y >= 42 && y <= 50) {
+ list.add(GT_LanguageManager.getTranslation("Wither Defence") + ": " + (Math.round(cont.mInvArmor.data.mStat.get(StatType.WITHERDEFENCE) * 1000) / 10.0) + "%");
+ } else if (y >= 51 && y <= 59) {
+ if(cont.mInvArmor.data.type!=3){
+ list.add(GT_LanguageManager.getTranslation("Fall Damage absorbtion"));
+ list.add(GT_LanguageManager.getTranslation("Only for Boots"));
+ }else{
+ list.add(GT_LanguageManager.getTranslation("Absorbs") + " " + (int) Math.round(cont.mInvArmor.data.mStat.get(StatType.FALLDEFENCE)) + GT_LanguageManager.getTranslation("m of Fall Damage"));}
+ } else if (y >= 60 && y <= 68) {
+ if(x<69){
+ list.add(GT_LanguageManager.getTranslation("Thorns") + ": " + (int) Math.round(cont.mInvArmor.data.mStat.get(StatType.THORNSSINGLE)) + " Dmg");
+ list.add(GT_LanguageManager.getTranslation("Total Thorns") + ": " + (int) Math.round(cont.mInvArmor.data.mStat.get(StatType.THORNS)) + " Dmg");
+ }else{
+ list.add(GT_LanguageManager.getTranslation("Magnet") + ": " + cont.mInvArmor.data.mStat.get(StatType.MAGNETSINGLE) + " m");
+ list.add(GT_LanguageManager.getTranslation("Total Magnet") + ": " + cont.mInvArmor.data.mStat.get(StatType.MAGNET) + " m");}
+ }
+ }
+ }
+ if (!list.isEmpty())
+ drawHoveringText(list, x, y, fontRendererObj);
+ }
+
+ public void drawBars(int x, int y, float value) {
+
+ int bar = (int) Math.floor(18 * value);
+ int xStart = (width - xSize) / 2;
+ int yStart = (height - ySize) / 2;
+ xStart += 8;
+ yStart += 1;
+ drawTexturedModalRect(xStart + x, yStart + y, 217, 26, bar, 5);
+ drawTexturedModalRect(xStart+ bar + x, yStart + y, 197+bar, 26, 18-bar, 5);
+ }
+
+ protected Slot getSlotAtPosition(int p_146975_1_, int p_146975_2_) {
+ for (int k = 0; k < cont.inventorySlots.size(); ++k) {
+ Slot slot = (Slot) cont.inventorySlots.get(k);
+ if (this.isMouseOverSlot(slot, p_146975_1_, p_146975_2_)) {
+ return slot;
+ }
+ }
+ return null;
+ }
+
+ private boolean isMouseOverSlot(Slot p_146981_1_, int p_146981_2_, int p_146981_3_) {
+ return this.func_146978_c(p_146981_1_.xDisplayPosition, p_146981_1_.yDisplayPosition, 16, 16, p_146981_2_, p_146981_3_);
+ }
+}
diff --git a/src/main/java/gregtech/common/items/armor/gui/GuiModularArmor.java b/src/main/java/gregtech/common/items/armor/gui/GuiModularArmor.java
new file mode 100644
index 0000000000..a24ca3ca1e
--- /dev/null
+++ b/src/main/java/gregtech/common/items/armor/gui/GuiModularArmor.java
@@ -0,0 +1,203 @@
+package gregtech.common.items.armor.gui;
+
+import gregtech.api.util.GT_LanguageManager;
+import gregtech.common.items.armor.components.StatType;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.util.ResourceLocation;
+
+@SideOnly(Side.CLIENT)
+public class GuiModularArmor extends GuiContainer {
+ ContainerModularArmor cont;
+ EntityPlayer player;
+
+ public GuiModularArmor(ContainerModularArmor containerModularArmor,EntityPlayer aPlayer) {
+ super(containerModularArmor);
+ cont = containerModularArmor;
+ this.player = aPlayer;
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int x, int y) {
+ int xStart = (width - xSize) / 2;
+ int yStart = (height - ySize) / 2;
+ int x2 = x - xStart;
+ int y2 = y - yStart;
+ drawTooltip(x2, y2 + 5);
+ }
+
+ protected void drawTooltip(int x, int y) {
+ List<String> list = new ArrayList<String>();
+ if (x >= 10 && x <= 17) {
+ if (y >= 20 && y <= 27) {
+ list.add(GT_LanguageManager.getTranslation("Weight") + ": " + cont.mInvArmor.data.mStat.get(StatType.WEIGHT));
+ list.add("Total Weight: "+cont.mInvArmor.data.maxWeight);
+ if (cont.mInvArmor.data.mStat.get(StatType.WEIGHT) > 1000)
+ list.add("Too Heavy!");
+ } else if (y >= 29 && y <= 36) {
+ list.add(GT_LanguageManager.getTranslation("Physical Defence") + ": " + (Math.round(cont.mInvArmor.data.mStat.get(StatType.PHYSICALDEFENCE) * 1000) / 10.0) + "%");
+ } else if (y >= 38 && y <= 45) {
+ list.add(GT_LanguageManager.getTranslation("Projectile Defence") + ": " + (Math.round(cont.mInvArmor.data.mStat.get(StatType.PROJECTILEDEFENCE) * 1000) / 10.0) + "%");
+ } else if (y >= 47 && y <= 54) {
+ list.add(GT_LanguageManager.getTranslation("Fire Defence") + ": " + (Math.round(cont.mInvArmor.data.mStat.get(StatType.FIREDEFENCE) * 1000) / 10.0) + "%");
+ } else if (y >= 56 && y <= 63) {
+ list.add(GT_LanguageManager.getTranslation("Magic Defence") + ": " + (Math.round(cont.mInvArmor.data.mStat.get(StatType.MAGICDEFENCE) * 1000) / 10.0) + "%");
+ } else if (y >= 65 && y <= 72) {
+ list.add(GT_LanguageManager.getTranslation("Explosion Defence") + ": " + (Math.round(cont.mInvArmor.data.mStat.get(StatType.EXPLOSIONDEFENCE) * 1000) / 10.0) + "%");
+ }
+ } else if (x >= 59 && x <= 66) {
+ if (y >= 20 && y <= 27) {
+ list.add(GT_LanguageManager.getTranslation("Thorns") + ": " + (int) Math.round(cont.mInvArmor.data.mStat.get(StatType.THORNSSINGLE)) + " Dmg");
+ list.add(GT_LanguageManager.getTranslation("Total Thorns") + ": " + (int) Math.round(cont.mInvArmor.data.mStat.get(StatType.THORNS)) + " Dmg");
+ } else if (y >= 29 && y <= 36) {
+ list.add(GT_LanguageManager.getTranslation("Magnet") + ": " + cont.mInvArmor.data.mStat.get(StatType.MAGNETSINGLE) + " m");
+ list.add(GT_LanguageManager.getTranslation("Total Magnet") + ": " + cont.mInvArmor.data.mStat.get(StatType.MAGNET) + " m");
+ } else if (y >= 38 && y <= 45) {
+ list.add(GT_LanguageManager.getTranslation("Radiation Defence") + ": " + (Math.round(cont.mInvArmor.data.mStat.get(StatType.RADIATIONDEFENCE) * 1000) / 10.0) + "%");
+ if(cont.mInvArmor.data.mBStat.get(StatType.FULLRADIATIONARMOR)){
+ list.add(GT_LanguageManager.getTranslation("Radiation Immunity"));}
+ } else if (y >= 47 && y <= 54) {
+ list.add(GT_LanguageManager.getTranslation("Electrical Defence") + ": " + (Math.round(cont.mInvArmor.data.mStat.get(StatType.ELECTRICALDEFENCE) * 1000) / 10.0) + "%");
+ if(cont.mInvArmor.data.mBStat.get(StatType.FULLELECTRICARMOR)){
+ list.add("Electric Immunity");}
+ } else if (y >= 56 && y <= 63) {
+ list.add(GT_LanguageManager.getTranslation("Wither Defence") + ": " + (Math.round(cont.mInvArmor.data.mStat.get(StatType.WITHERDEFENCE) * 1000) / 10.0) + "%");
+ } else if (y >= 65 && y <= 72) {
+ if(cont.mInvArmor.data.type!=3){
+ list.add(GT_LanguageManager.getTranslation("Fall Damage absorbtion"));
+ list.add(GT_LanguageManager.getTranslation("Only for Boots"));
+ }else{
+ list.add(GT_LanguageManager.getTranslation("Absorbs") + " " + (int) Math.round(cont.mInvArmor.data.mStat.get(StatType.FALLDEFENCE)) + GT_LanguageManager.getTranslation("m of Fall Damage"));}
+ }
+ }
+ if (!list.isEmpty())
+ drawHoveringText(list, x, y, fontRendererObj);
+ }
+
+ @Override
+ protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
+ GL11.glColor4f(1F, 1F, 1F, 1F);
+ this.mc.getTextureManager().bindTexture(new ResourceLocation("gregtech", "textures/gui/armorgui3x3.png"));
+ int xStart = (width - xSize) / 2;
+ int yStart = (height - ySize) / 2;
+ drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);