From df00993c0df8efd4162d6b80a1662a213ff5910f Mon Sep 17 00:00:00 2001 From: Doug Gabehart Date: Wed, 14 Dec 2016 11:12:07 -0600 Subject: Added updateArmorStats method which includes additional checks to ensure that values are not null and the key in question exists in mStats Removed player.closeScreen call in mouseClicked to prevent display glitch when switching armor gui tabs; (mouse focus from returning to 2x2 crafting grid) --- .../gregtech/common/items/armor/gui/GuiElectricArmor1.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/main/java/gregtech/common/items/armor/gui') diff --git a/src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java b/src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java index 3ea092a2ab..071bbbc414 100644 --- a/src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java +++ b/src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java @@ -151,10 +151,15 @@ public class GuiElectricArmor1 extends GuiContainer { 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();} + if(xStart>72&&xStart<81&&cont.mInvArmor.data.helmet!=null){cont.mInvArmor.data.helmet.openGui=true;} + if(xStart>82&&xStart<91&&cont.mInvArmor.data.chestplate!=null){cont.mInvArmor.data.chestplate.openGui=true;} + if(xStart>92&&xStart<101&&cont.mInvArmor.data.leggings!=null){cont.mInvArmor.data.leggings.openGui=true;} + if(xStart>102&&xStart<112&&cont.mInvArmor.data.boots!=null){cont.mInvArmor.data.boots.openGui=true;} + +// 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); -- cgit From b9ebe166556ed514d9588b9dec1abbd04f4519fc Mon Sep 17 00:00:00 2001 From: Doug Gabehart Date: Wed, 14 Dec 2016 11:34:00 -0600 Subject: Removed player.closeScreen call to fix graphics glitch when switching armor tabs --- .../java/gregtech/common/items/armor/gui/GuiModularArmor.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/main/java/gregtech/common/items/armor/gui') diff --git a/src/main/java/gregtech/common/items/armor/gui/GuiModularArmor.java b/src/main/java/gregtech/common/items/armor/gui/GuiModularArmor.java index a24ca3ca1e..ae2ba88013 100644 --- a/src/main/java/gregtech/common/items/armor/gui/GuiModularArmor.java +++ b/src/main/java/gregtech/common/items/armor/gui/GuiModularArmor.java @@ -191,10 +191,10 @@ public class GuiModularArmor extends GuiContainer { int yStart = mouseY-((height - ySize) / 2); if(yStart>67&&yStart<77){ if(xStart>124&&xStart<163){ - if(xStart>124&&xStart<133&&cont.mInvArmor.data.helmet!=null){cont.mInvArmor.data.helmet.openGui=true;player.closeScreen();} - if(xStart>134&&xStart<143&&cont.mInvArmor.data.chestplate!=null){cont.mInvArmor.data.chestplate.openGui=true;player.closeScreen();} - if(xStart>144&&xStart<153&&cont.mInvArmor.data.leggings!=null){cont.mInvArmor.data.leggings.openGui=true;player.closeScreen();} - if(xStart>154&&xStart<163&&cont.mInvArmor.data.boots!=null){cont.mInvArmor.data.boots.openGui=true;player.closeScreen();} + if(xStart>124&&xStart<133&&cont.mInvArmor.data.helmet!=null){cont.mInvArmor.data.helmet.openGui=true;} + if(xStart>134&&xStart<143&&cont.mInvArmor.data.chestplate!=null){cont.mInvArmor.data.chestplate.openGui=true;} + if(xStart>144&&xStart<153&&cont.mInvArmor.data.leggings!=null){cont.mInvArmor.data.leggings.openGui=true;} + if(xStart>154&&xStart<163&&cont.mInvArmor.data.boots!=null){cont.mInvArmor.data.boots.openGui=true;} } } super.mouseClicked(mouseX, mouseY, mouseBtn); -- cgit From 6ceff6d783d96f3e251cbc741f4a1d7e558edfd1 Mon Sep 17 00:00:00 2001 From: Doug Gabehart Date: Wed, 14 Dec 2016 16:04:20 -0600 Subject: Fixed issue with Modular Armor inventory not saving properly after removing the call to closeScreen Added null and key checks when determining if a full radiation or electrical armor set is configured --- .../java/gregtech/common/items/armor/gui/GuiElectricArmor1.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/main/java/gregtech/common/items/armor/gui') diff --git a/src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java b/src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java index 071bbbc414..657010f672 100644 --- a/src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java +++ b/src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java @@ -40,7 +40,12 @@ public class GuiElectricArmor1 extends GuiContainer { cont = containerModularArmor; tab = 0; } - + @Override + public void onGuiClosed() + { + cont.saveInventory(player); + super.onGuiClosed(); + }; public String seperateNumber(long number){ DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.US); DecimalFormatSymbols symbols = formatter.getDecimalFormatSymbols(); -- cgit From 63643784370e291dd9262855ac73b4ec63b347f3 Mon Sep 17 00:00:00 2001 From: Doug Gabehart Date: Wed, 14 Dec 2016 20:35:43 -0600 Subject: More stability improvements. (Null value and checks to ensure keys exist) --- .../java/gregtech/common/items/armor/gui/GuiElectricArmor1.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/main/java/gregtech/common/items/armor/gui') diff --git a/src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java b/src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java index 657010f672..50a6a05b0c 100644 --- a/src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java +++ b/src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java @@ -102,12 +102,12 @@ public class GuiElectricArmor1 extends GuiContainer { default: break; } - - if(cont.mInvArmor.data.mStat.get(StatType.TANKCAP)>0){ + float tankCap = cont.mInvArmor.data.mStat.containsKey(StatType.TANKCAP) ? cont.mInvArmor.data.mStat.get(StatType.TANKCAP) :0.0f; + if(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)); + float weight = cont.mInvArmor.data.mStat.containsKey(StatType.WEIGHT) ? cont.mInvArmor.data.mStat.get(StatType.WEIGHT) : 0.0f; + int bar = (int) Math.floor(18 * (weight)/(float)1000); drawTexturedModalRect(xStart + 15, yStart + 7, 217, 26, bar, 5); drawTexturedModalRect(xStart + bar + 15, yStart + 7, 197+bar, 26, 18-bar, 5); -- cgit From 3d2dd065fafb12a7107aa9b33cd6ed442197c25e Mon Sep 17 00:00:00 2001 From: Doug Gabehart Date: Thu, 15 Dec 2016 17:11:13 -0600 Subject: Added check to ensure that fluid is set trying to provide air to player during onArmorTick Looking at how to fill helmet tank from air cell --- .../common/items/armor/gui/GuiElectricArmor1.java | 43 +++++++++++++++++----- 1 file changed, 33 insertions(+), 10 deletions(-) (limited to 'src/main/java/gregtech/common/items/armor/gui') diff --git a/src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java b/src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java index 50a6a05b0c..dec19e0308 100644 --- a/src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java +++ b/src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java @@ -1,7 +1,10 @@ package gregtech.common.items.armor.gui; +import gregtech.api.enums.GT_Values; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Network; +import gregtech.common.items.armor.ArmorData; import gregtech.common.items.armor.components.StatType; import java.text.DecimalFormat; @@ -168,27 +171,39 @@ public class GuiElectricArmor1 extends GuiContainer { } } // Slot slot = getSlotAtPosition(mouseX, mouseY); -// if (slot != null && slot instanceof SlotFluid && player != null) { +// if (slot != null && slot instanceof SlotFluid && player != null && cont.mInvArmor.data.helmet!=null) { // ItemStack tmp = player.inventory.getItemStack(); +// //GT_Network gtn = new GT_Network(); // if (tmp == null) { -// GTExtras.NET.sendToServer(new FluidSync(player.getCommandSenderName(), 0, "null")); +// //GT_Values.NW.sendToServer(new FluidSync(player.getCommandSenderName(), 0, "null")); // } +// //ArmorData armorData = new ArmorData(player,); // 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); +// slot.putStack(GT_Utility.getFluidDisplayStack(tmp2, true)); +// +// if(cont.mInvArmor.data.helmet.fluid == null) +// { +// cont.mInvArmor.data.helmet.fluid = new FluidStack(tmp2.getFluid(), tmp2.amount); +// } +// else +// { +// cont.mInvArmor.data.helmet.fluid.amount += tmp2.amount; +// } +// +// //GT_Values.NW.sendToServer(new FluidSync(player.getCommandSenderName(), tmp2.amount, GT_Utility.getFluidName(tmp2, false))); +// ItemStack tmp4 = GT_Utility.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())); +// //GT_Values.NW.sendToServer(new FluidSync2(player.getCommandSenderName())); // } else { // player.inventory.setItemStack(null); // player.inventory.addItemStackToInventory(tmp4); -// GTExtras.NET.sendToServer(new FluidSync2(player.getCommandSenderName())); +// //GT_Values.NW.sendToServer(new FluidSync2(player.getCommandSenderName())); // } // // } else if (slot.getHasStack() && tmp2 != null) { @@ -204,9 +219,17 @@ public class GuiElectricArmor1 extends GuiContainer { // 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))); +// //GT_Values.NW.sendToServer(new FluidSync2(player.getCommandSenderName())); +// slot.putStack(GT_Utility.getFluidDisplayStack(tmp2, true)); +// if(cont.mInvArmor.data.helmet.fluid == null) +// { +// cont.mInvArmor.data.helmet.fluid = new FluidStack(tmp2.getFluid(), tmp2.amount); +// } +// else +// { +// cont.mInvArmor.data.helmet.fluid.amount += tmp2.amount; +// } +// //GT_Values.NW.sendToServer(new FluidSync(player.getCommandSenderName(), tmp2.amount, GT_Utility.getFluidName(tmp2, false))); // } // } // } -- cgit