diff options
author | Jakub <53441451+kuba6000@users.noreply.github.com> | 2022-08-29 16:04:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-29 16:04:28 +0200 |
commit | 7d1f51a8937e0a86486267437d444696e81e8aa0 (patch) | |
tree | a5b145e7271998f7b4b968a2212ed487e54a92b5 /src/main/java/gtPlusPlus/xmod/galacticraft/handler | |
parent | 5267969156d30b4bb5f4cb2279ebb49db6bd40e2 (diff) | |
download | GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.tar.gz GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.tar.bz2 GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.zip |
Buildscript + Spotless (#318)
* Convert AES.java to readable class
* Buildscript
* Spotless
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/galacticraft/handler')
-rw-r--r-- | src/main/java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java | 132 |
1 files changed, 67 insertions, 65 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java b/src/main/java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java index 3b59b58cab..b0c5032e5f 100644 --- a/src/main/java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java +++ b/src/main/java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java @@ -1,83 +1,85 @@ package gtPlusPlus.xmod.galacticraft.handler; -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.LinkedHashMap; - 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 gtPlusPlus.preloader.asm.AsmConfig; +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.LinkedHashMap; +import net.minecraft.block.Block; +import net.minecraft.item.Item; 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 HashMap <Integer, String> mFuelNames; - - static { - mFuelNames = new LinkedHashMap<Integer, String>(); - } + private static Item mItemBlock; + private static Block mBlock; + private static Class<?> oMainClass; + private static Class<?> oFuelLoaderClass; + private static HashMap<Integer, String> mFuelNames; + + static { + mFuelNames = new LinkedHashMap<Integer, String>(); + } + + @SubscribeEvent + public void onItemTooltip(ItemTooltipEvent event) { + if (LoadedMods.GalacticraftCore && AsmConfig.enableGcFuelChanges) { - @SubscribeEvent - public void onItemTooltip(ItemTooltipEvent event) { - if (LoadedMods.GalacticraftCore && AsmConfig.enableGcFuelChanges) { + if (mBlock == null) { + try { + Class<?> GCBlocks = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.blocks.GCBlocks"); + if (GCBlocks != null) { + oMainClass = GCBlocks; - if (mBlock == null) { - try { - Class<?> GCBlocks = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.blocks.GCBlocks"); - if (GCBlocks != null) { - oMainClass = GCBlocks; + Class<?> GCFuelLoader = + ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.blocks.BlockFuelLoader"); - Class<?> GCFuelLoader = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.blocks.BlockFuelLoader"); + if (GCFuelLoader != null) { + oFuelLoaderClass = GCFuelLoader; + } - if (GCFuelLoader != null) { - oFuelLoaderClass = GCFuelLoader; - } + Field aField = ReflectionUtils.getField(oMainClass, "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 = new LinkedHashMap<Integer, String>(); + } - Field aField = ReflectionUtils.getField(oMainClass, "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 = new LinkedHashMap<Integer, String>(); - } - - if (mFuelNames.isEmpty()) { - for (int aMapKey : RocketFuels.mValidRocketFuels.keySet()) { - Fluid aFuel = RocketFuels.mValidRocketFuels.get(aMapKey); - if (aFuel != null) { - mFuelNames.put(aMapKey, aFuel.getLocalizedName()); - } - } - } - if (mItemBlock != null && !mFuelNames.isEmpty()) { - Item aTempItem = event.itemStack.getItem(); - Block aTempBlock = Block.getBlockFromItem(aTempItem); - if (aTempItem == mItemBlock || oFuelLoaderClass.isInstance(aTempBlock) || event.itemStack.getUnlocalizedName().toLowerCase().contains("fuelloader")) { - for (int aMapKey : mFuelNames.keySet()) { - String aFuel = mFuelNames.get(aMapKey); - if (aFuel != null) { - event.toolTip.add("Tier "+(aMapKey+1)+": "+aFuel); - } - } - } - } - } - } + if (mFuelNames.isEmpty()) { + for (int aMapKey : RocketFuels.mValidRocketFuels.keySet()) { + Fluid aFuel = RocketFuels.mValidRocketFuels.get(aMapKey); + if (aFuel != null) { + mFuelNames.put(aMapKey, aFuel.getLocalizedName()); + } + } + } + if (mItemBlock != null && !mFuelNames.isEmpty()) { + Item aTempItem = event.itemStack.getItem(); + Block aTempBlock = Block.getBlockFromItem(aTempItem); + if (aTempItem == mItemBlock + || oFuelLoaderClass.isInstance(aTempBlock) + || event.itemStack.getUnlocalizedName().toLowerCase().contains("fuelloader")) { + for (int aMapKey : mFuelNames.keySet()) { + String aFuel = mFuelNames.get(aMapKey); + if (aFuel != null) { + event.toolTip.add("Tier " + (aMapKey + 1) + ": " + aFuel); + } + } + } + } + } + } } |