aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/eio/handler
diff options
context:
space:
mode:
authorAlkalus <draknyte1@hotmail.com>2017-11-28 16:57:40 +1000
committerAlkalus <draknyte1@hotmail.com>2017-11-28 16:57:40 +1000
commit2da6615bb5f44de794159aa6a64fee4df7f2afd3 (patch)
tree4000acddf5c47909e4c19de7529f4688192b81ac /src/Java/gtPlusPlus/xmod/eio/handler
parent3494624390b1d9ddf6ee5ce65cc4a333f9d2d63a (diff)
downloadGT5-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/handler')
-rw-r--r--src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java141
1 files changed, 77 insertions, 64 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) {
}
}
-
}
}