From 734e7a1498ef6ca48f95f075aaa66372639c9618 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Wed, 3 Oct 2018 16:47:35 +0100 Subject: $ Fixed COFH OreDictionaryArbiter via ASM. $ Cleaned up GC Fuel ASM, Rockets are now tiered. % Added ability for Rover to use Diesel still. % Added Tooltip to the GC Fuel Loader, showing what Tier requires which fuel. > Bug still exists on sending packets, which may cause the client to boot the player back to the menu. --- .../galacticraft/handler/HandlerTooltip_GC.java | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java (limited to 'src/Java/gtPlusPlus/xmod/galacticraft/handler') diff --git a/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java b/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java new file mode 100644 index 0000000000..9075666b8b --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java @@ -0,0 +1,73 @@ +package gtPlusPlus.xmod.galacticraft.handler; + +import java.lang.reflect.Field; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import gtPlusPlus.core.item.chemistry.RocketFuels; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import net.minecraftforge.fluids.Fluid; + +public class HandlerTooltip_GC { + + private static Item mItemBlock; + private static Block mBlock; + private static Class oMainClass; + private static Class oFuelLoaderClass; + private static String[] mFuelNames; + + @SubscribeEvent + public void onItemTooltip(ItemTooltipEvent event) { + if (LoadedMods.GalacticraftCore) { + + if (mBlock == null) { + try { + Class GCBlocks = Class.forName("micdoodle8.mods.galacticraft.core.blocks.GCBlocks"); + if (GCBlocks != null) { + oMainClass = GCBlocks; + + Class GCFuelLoader = Class + .forName("micdoodle8.mods.galacticraft.core.blocks.BlockFuelLoader"); + + if (GCFuelLoader != null) { + oFuelLoaderClass = GCFuelLoader; + } + + Field aField = ReflectionUtils.getField(GCBlocks, "fuelLoader"); + if (aField != null) { + Block aBlock = (Block) aField.get(null); + if (aBlock != null) { + mBlock = aBlock; + mItemBlock = Item.getItemFromBlock(mBlock); + } + } + } + } catch (Throwable t) { + } + } + if (mFuelNames == null || mFuelNames.length == 0) { + mFuelNames = new String[RocketFuels.mValidRocketFuels.size()]; + int slot = 0; + for (Fluid f : RocketFuels.mValidRocketFuels.values()) { + mFuelNames[slot++] = f.getLocalizedName(); + } + } + if (mItemBlock != null) { + Item aTempItem = event.itemStack.getItem(); + Block aTempBlock = Block.getBlockFromItem(aTempItem); + if (aTempItem == mItemBlock || oFuelLoaderClass.isInstance(aTempBlock) + || event.itemStack.getUnlocalizedName().toLowerCase().contains("fuelloader")) { + int aTier = 0; + for (String s : mFuelNames) { + if (s != null) { + event.toolTip.add("Tier "+aTier+": "+s); + } + } + } + } + } + } +} -- cgit