diff options
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/eio')
-rw-r--r-- | src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java | 116 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/xmod/eio/material/MaterialEIO.java | 118 |
2 files changed, 234 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java b/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java new file mode 100644 index 0000000000..ae0ca232b7 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java @@ -0,0 +1,116 @@ +package gtPlusPlus.xmod.eio.handler; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gregtech.api.enums.Materials; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.item.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.eio.material.MaterialEIO; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; + +public class HandlerTooltip_EIO { + + Item mIngot; + ItemStack mPulsatingIron; + ItemStack mConductiveIron; + ItemStack mRedstoneAlloy; + ItemStack mElectricalSteel; + ItemStack mEnergeticAlloy; + ItemStack mVibrantAlloy; + ItemStack mSoularium; + ItemStack mDarkIron; + + @SubscribeEvent + public void onItemTooltip(ItemTooltipEvent event){ + //Is EIO loaded? + if (LoadedMods.EnderIO){ + + //Is the EIO Ingot Item null? + //If it is, reflect in. + if (mIngot == null){ + Class<?> oMainClass; + try { + 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 (mSoularium == null){ + mSoularium = ItemUtils.simpleMetaStack(mIngot, 7, 1); + } + + try { + + //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); + } + else if (event.itemStack == mEnergeticAlloy){ + event.toolTip.add(MaterialEIO.ENERGETIC_ALLOY.vChemicalFormula); + } + else if (event.itemStack == mVibrantAlloy){ + event.toolTip.add(MaterialEIO.VIBRANT_ALLOY.vChemicalFormula); + } + else if (event.itemStack == mRedstoneAlloy){ + event.toolTip.add(MaterialEIO.REDSTONE_ALLOY.vChemicalFormula); + } + else if (event.itemStack == mConductiveIron){ + event.toolTip.add(MaterialEIO.CONDUCTIVE_IRON.vChemicalFormula); + } + else if (event.itemStack == mPulsatingIron){ + event.toolTip.add(MaterialEIO.PULSATING_IRON.vChemicalFormula); + } + else if (event.itemStack == mDarkIron){ + event.toolTip.add(Materials.DarkSteel.mChemicalFormula); + } + else if (event.itemStack == mSoularium){ + event.toolTip.add(MaterialEIO.SOULARIUM.vChemicalFormula); + } + } + } + + catch (ClassNotFoundException e) { + } + + + } + } + + } + +} diff --git a/src/Java/gtPlusPlus/xmod/eio/material/MaterialEIO.java b/src/Java/gtPlusPlus/xmod/eio/material/MaterialEIO.java new file mode 100644 index 0000000000..1bcc0a3c1f --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/eio/material/MaterialEIO.java @@ -0,0 +1,118 @@ +package gtPlusPlus.xmod.eio.material; + +import gtPlusPlus.core.material.ALLOY; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.MaterialStack; +import gtPlusPlus.core.material.NONMATERIAL; +import gtPlusPlus.core.material.state.MaterialState; + +public class MaterialEIO { + + public static final Material SOULARIUM = new Material( + "Soularium", //Material Name + MaterialState.SOLID, //State + new short[]{95,90,54, 0}, //Material Colour + -1, //Melting Point in C + -1, + -1, + -1, + false, //Uses Blast furnace? + //Material Stacks with Percentage of required elements. + new MaterialStack[]{ + new MaterialStack(ELEMENT.getInstance().GOLD, 1), + new MaterialStack(NONMATERIAL.SOULSAND, 1) + }); + + public static final Material CONDUCTIVE_IRON = new Material( + "Conductive Iron", //Material Name + MaterialState.SOLID, //State + new short[]{164,109,100, 0}, //Material Colour + -1, //Melting Point in C + -1, + -1, + -1, + false, //Uses Blast furnace? + //Material Stacks with Percentage of required elements. + new MaterialStack[]{ + new MaterialStack(ELEMENT.getInstance().IRON, 1), + new MaterialStack(NONMATERIAL.REDSTONE, 1) + }); + + public static final Material PULSATING_IRON = new Material( + "Pulsating Iron", //Material Name + MaterialState.SOLID, //State + new short[]{50,91,21, 0}, //Material Colour + -1, //Melting Point in C + -1, + -1, + -1, + false, //Uses Blast furnace? + //Material Stacks with Percentage of required elements. + new MaterialStack[]{ + new MaterialStack(ELEMENT.getInstance().IRON, 1), + new MaterialStack(NONMATERIAL.ENDERPEARL, 1) + }); + + public static final Material ELECTRICAL_STEEL = new Material( + "Electrical Steel", //Material Name + MaterialState.SOLID, //State + new short[]{194,194,194, 0}, //Material Colour + -1, //Melting Point in C + -1, + -1, + -1, + false, //Uses Blast furnace? + //Material Stacks with Percentage of required elements. + new MaterialStack[]{ + new MaterialStack(ALLOY.STEEL, 3), + new MaterialStack(ELEMENT.getInstance().SILICON, 1) + }); + + public static final Material ENERGETIC_ALLOY = new Material( + "Energetic Alloy", //Material Name + MaterialState.SOLID, //State + new short[]{252,151,45, 0}, //Material Colour + -1, //Melting Point in C + -1, + -1, + -1, + false, //Uses Blast furnace? + //Material Stacks with Percentage of required elements. + new MaterialStack[]{ + new MaterialStack(ELEMENT.getInstance().GOLD, 1), + new MaterialStack(NONMATERIAL.REDSTONE, 1), + new MaterialStack(NONMATERIAL.GLOWSTONE, 1) + }); + + public static final Material VIBRANT_ALLOY = new Material( + "Vibrant Alloy", //Material Name + MaterialState.SOLID, //State + new short[]{204,242,142, 0}, //Material Colour + -1, //Melting Point in C + -1, + -1, + -1, + false, //Uses Blast furnace? + //Material Stacks with Percentage of required elements. + new MaterialStack[]{ + new MaterialStack(ENERGETIC_ALLOY, 1), + new MaterialStack(NONMATERIAL.ENDERPEARL, 1) + }); + + public static final Material REDSTONE_ALLOY = new Material( + "Redstone Alloy", //Material Name + MaterialState.SOLID, //State + new short[]{178,34,34, 0}, //Material Colour + -1, //Melting Point in C + -1, + -1, + -1, + false, //Uses Blast furnace? + //Material Stacks with Percentage of required elements. + new MaterialStack[]{ + new MaterialStack(ELEMENT.getInstance().SILICON, 1), + new MaterialStack(NONMATERIAL.REDSTONE, 1) + }); + +} |