diff options
author | Alkalus <draknyte1@hotmail.com> | 2017-11-28 16:57:40 +1000 |
---|---|---|
committer | Alkalus <draknyte1@hotmail.com> | 2017-11-28 16:57:40 +1000 |
commit | 2da6615bb5f44de794159aa6a64fee4df7f2afd3 (patch) | |
tree | 4000acddf5c47909e4c19de7529f4688192b81ac /src/Java/gtPlusPlus/xmod/eio | |
parent | 3494624390b1d9ddf6ee5ce65cc4a333f9d2d63a (diff) | |
download | GT5-Unofficial-2da6615bb5f44de794159aa6a64fee4df7f2afd3.tar.gz GT5-Unofficial-2da6615bb5f44de794159aa6a64fee4df7f2afd3.tar.bz2 GT5-Unofficial-2da6615bb5f44de794159aa6a64fee4df7f2afd3.zip |
$ Fixed EIO Tooltip handler.
$ Fixed several custom plates not generating.
$ Fixed some bad generated material values by using placeholders instead.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/eio')
-rw-r--r-- | src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java | 141 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/xmod/eio/material/MaterialEIO.java | 56 |
2 files changed, 105 insertions, 92 deletions
diff --git a/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java b/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java index ae0ca232b7..820592a300 100644 --- a/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java +++ b/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java @@ -1,8 +1,11 @@ package gtPlusPlus.xmod.eio.handler; +import java.lang.reflect.Field; + import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gregtech.api.enums.Materials; import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.eio.material.MaterialEIO; @@ -29,88 +32,98 @@ public class HandlerTooltip_EIO { //Is the EIO Ingot Item null? //If it is, reflect in. - if (mIngot == null){ - Class<?> oMainClass; + if (mIngot == null){ try { - oMainClass = Class.forName("crazypants.enderio.EnderIO"); + Class<?> oMainClass = Class.forName("crazypants.enderio.EnderIO"); Class<?> oIngotClass = Class.forName("crazypants.enderio.material.ItemAlloy"); - Object oAlloy = ReflectionUtils.getField(oMainClass, "itemAlloy"); - if (oAlloy != null && oIngotClass.isInstance(oAlloy)){ - mIngot = (Item) oAlloy; - } - } - catch (ClassNotFoundException | NoSuchFieldException e) {} - } - - //If EIO Item Is not Null, see if the ItemStacks for the ingots are null - //if they stacks are null, set the stack using the item set via reflection. - //The meta data is based on the oridinals of the materials in the EIO enum. - if (mIngot != null){ - if (mElectricalSteel == null){ - mElectricalSteel = ItemUtils.simpleMetaStack(mIngot, 0, 1); - } - if (mEnergeticAlloy == null){ - mEnergeticAlloy = ItemUtils.simpleMetaStack(mIngot, 1, 1); - } - if (mVibrantAlloy == null){ - mVibrantAlloy = ItemUtils.simpleMetaStack(mIngot, 2, 1); - } - if (mRedstoneAlloy == null){ - mRedstoneAlloy = ItemUtils.simpleMetaStack(mIngot, 3, 1); - } - if (mConductiveIron == null){ - mConductiveIron = ItemUtils.simpleMetaStack(mIngot, 4, 1); - } - if (mPulsatingIron == null){ - mPulsatingIron = ItemUtils.simpleMetaStack(mIngot, 5, 1); - } - if (mDarkIron == null){ - mDarkIron = ItemUtils.simpleMetaStack(mIngot, 6, 1); + if (oMainClass != null && oIngotClass != null){ + + Field oAlloyField = oMainClass.getDeclaredField("itemAlloy"); + oAlloyField.setAccessible(true); + Object oAlloy = oAlloyField.get(oMainClass); + + if (oAlloy != null){ + if (oIngotClass.isInstance(oAlloy) || Item.class.isInstance(oAlloy)){ + mIngot = (Item) oAlloy; + } + + } + } } - if (mSoularium == null){ - mSoularium = ItemUtils.simpleMetaStack(mIngot, 7, 1); + catch (Throwable e) { } + } - try { - + try { + if (mIngot != null){ //If the Item is an instance of ItemAlloy.class then proceed - if (Class.forName("crazypants.enderio.material.ItemAlloy").isInstance(event.itemStack.getItem())){ - - //If stacks match, add a tooltip. - if (event.itemStack == mElectricalSteel){ - event.toolTip.add(MaterialEIO.ELECTRICAL_STEEL.vChemicalFormula); + if (Class.forName("crazypants.enderio.material.ItemAlloy").isInstance(event.itemStack.getItem()) || event.itemStack.getUnlocalizedName().toLowerCase().contains("item.itemAlloy")){ + + //If EIO Item Is not Null, see if the ItemStacks for the ingots are null + //if they stacks are null, set the stack using the item set via reflection. + //The meta data is based on the oridinals of the materials in the EIO enum. + + if (mElectricalSteel == null){ + mElectricalSteel = ItemUtils.simpleMetaStack(mIngot, 0, 1); } - else if (event.itemStack == mEnergeticAlloy){ - event.toolTip.add(MaterialEIO.ENERGETIC_ALLOY.vChemicalFormula); + if (mEnergeticAlloy == null){ + mEnergeticAlloy = ItemUtils.simpleMetaStack(mIngot, 1, 1); } - else if (event.itemStack == mVibrantAlloy){ - event.toolTip.add(MaterialEIO.VIBRANT_ALLOY.vChemicalFormula); + if (mVibrantAlloy == null){ + mVibrantAlloy = ItemUtils.simpleMetaStack(mIngot, 2, 1); } - else if (event.itemStack == mRedstoneAlloy){ - event.toolTip.add(MaterialEIO.REDSTONE_ALLOY.vChemicalFormula); + if (mRedstoneAlloy == null){ + mRedstoneAlloy = ItemUtils.simpleMetaStack(mIngot, 3, 1); } - else if (event.itemStack == mConductiveIron){ - event.toolTip.add(MaterialEIO.CONDUCTIVE_IRON.vChemicalFormula); + if (mConductiveIron == null){ + mConductiveIron = ItemUtils.simpleMetaStack(mIngot, 4, 1); } - else if (event.itemStack == mPulsatingIron){ - event.toolTip.add(MaterialEIO.PULSATING_IRON.vChemicalFormula); + if (mPulsatingIron == null){ + mPulsatingIron = ItemUtils.simpleMetaStack(mIngot, 5, 1); } - else if (event.itemStack == mDarkIron){ - event.toolTip.add(Materials.DarkSteel.mChemicalFormula); + if (mDarkIron == null){ + mDarkIron = ItemUtils.simpleMetaStack(mIngot, 6, 1); } - else if (event.itemStack == mSoularium){ - event.toolTip.add(MaterialEIO.SOULARIUM.vChemicalFormula); + if (mSoularium == null){ + mSoularium = ItemUtils.simpleMetaStack(mIngot, 7, 1); } + + + //If stacks match, add a tooltip. + if (this.mIngot != null){ + if (event.itemStack.getItem() == this.mIngot){ + if (event.itemStack.getItemDamage() == 0){ + event.toolTip.add(MaterialEIO.ELECTRICAL_STEEL.vChemicalFormula); + } + else if (event.itemStack.getItemDamage() == 1){ + event.toolTip.add(MaterialEIO.ENERGETIC_ALLOY.vChemicalFormula); + } + else if (event.itemStack.getItemDamage() == 2){ + event.toolTip.add(MaterialEIO.VIBRANT_ALLOY.vChemicalFormula); + } + else if (event.itemStack.getItemDamage() == 3){ + event.toolTip.add(MaterialEIO.REDSTONE_ALLOY.vChemicalFormula); + } + else if (event.itemStack.getItemDamage() == 4){ + event.toolTip.add(MaterialEIO.CONDUCTIVE_IRON.vChemicalFormula); + } + else if (event.itemStack.getItemDamage() == 5){ + event.toolTip.add(MaterialEIO.PULSATING_IRON.vChemicalFormula); + } + else if (event.itemStack.getItemDamage() == 6){ + event.toolTip.add(Materials.DarkSteel.mChemicalFormula); + } + else if (event.itemStack.getItemDamage() == 7){ + event.toolTip.add(MaterialEIO.SOULARIUM.vChemicalFormula); + } + } + } } } - - catch (ClassNotFoundException e) { - } - - + } + catch (ClassNotFoundException e) { } } - } } diff --git a/src/Java/gtPlusPlus/xmod/eio/material/MaterialEIO.java b/src/Java/gtPlusPlus/xmod/eio/material/MaterialEIO.java index 1bcc0a3c1f..cdb04c9b45 100644 --- a/src/Java/gtPlusPlus/xmod/eio/material/MaterialEIO.java +++ b/src/Java/gtPlusPlus/xmod/eio/material/MaterialEIO.java @@ -13,10 +13,10 @@ public class MaterialEIO { "Soularium", //Material Name MaterialState.SOLID, //State new short[]{95,90,54, 0}, //Material Colour - -1, //Melting Point in C - -1, - -1, - -1, + 10, //Melting Point in C + 10, + 10, + 10, false, //Uses Blast furnace? //Material Stacks with Percentage of required elements. new MaterialStack[]{ @@ -28,10 +28,10 @@ public class MaterialEIO { "Conductive Iron", //Material Name MaterialState.SOLID, //State new short[]{164,109,100, 0}, //Material Colour - -1, //Melting Point in C - -1, - -1, - -1, + 10, //Melting Point in C + 10, + 10, + 10, false, //Uses Blast furnace? //Material Stacks with Percentage of required elements. new MaterialStack[]{ @@ -43,10 +43,10 @@ public class MaterialEIO { "Pulsating Iron", //Material Name MaterialState.SOLID, //State new short[]{50,91,21, 0}, //Material Colour - -1, //Melting Point in C - -1, - -1, - -1, + 10, //Melting Point in C + 10, + 10, + 10, false, //Uses Blast furnace? //Material Stacks with Percentage of required elements. new MaterialStack[]{ @@ -58,10 +58,10 @@ public class MaterialEIO { "Electrical Steel", //Material Name MaterialState.SOLID, //State new short[]{194,194,194, 0}, //Material Colour - -1, //Melting Point in C - -1, - -1, - -1, + 10, //Melting Point in C + 10, + 10, + 10, false, //Uses Blast furnace? //Material Stacks with Percentage of required elements. new MaterialStack[]{ @@ -73,10 +73,10 @@ public class MaterialEIO { "Energetic Alloy", //Material Name MaterialState.SOLID, //State new short[]{252,151,45, 0}, //Material Colour - -1, //Melting Point in C - -1, - -1, - -1, + 10, //Melting Point in C + 10, + 10, + 10, false, //Uses Blast furnace? //Material Stacks with Percentage of required elements. new MaterialStack[]{ @@ -89,10 +89,10 @@ public class MaterialEIO { "Vibrant Alloy", //Material Name MaterialState.SOLID, //State new short[]{204,242,142, 0}, //Material Colour - -1, //Melting Point in C - -1, - -1, - -1, + 10, //Melting Point in C + 10, + 10, + 10, false, //Uses Blast furnace? //Material Stacks with Percentage of required elements. new MaterialStack[]{ @@ -104,10 +104,10 @@ public class MaterialEIO { "Redstone Alloy", //Material Name MaterialState.SOLID, //State new short[]{178,34,34, 0}, //Material Colour - -1, //Melting Point in C - -1, - -1, - -1, + 10, //Melting Point in C + 10, + 10, + 10, false, //Uses Blast furnace? //Material Stacks with Percentage of required elements. new MaterialStack[]{ |