aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/galacticraft/handler
diff options
context:
space:
mode:
author‭huajijam <strhuaji@gmail.com>2019-03-18 20:52:30 +0800
committer‭huajijam <strhuaji@gmail.com>2019-03-18 20:52:30 +0800
commit8b090e1fd20eb4c301996b5e1dfeb78353e595e4 (patch)
tree52152dd767d195c76baa8fd8bacb14b105aaa146 /src/Java/gtPlusPlus/xmod/galacticraft/handler
parent40d7e5da9f5b84213e2c3e4596fdc69b94bd523e (diff)
downloadGT5-Unofficial-8b090e1fd20eb4c301996b5e1dfeb78353e595e4.tar.gz
GT5-Unofficial-8b090e1fd20eb4c301996b5e1dfeb78353e595e4.tar.bz2
GT5-Unofficial-8b090e1fd20eb4c301996b5e1dfeb78353e595e4.zip
fix a bug
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/galacticraft/handler')
-rw-r--r--src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java42
1 files changed, 23 insertions, 19 deletions
diff --git a/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java b/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java
index 9075666b8b..64f1cfbe23 100644
--- a/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java
+++ b/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java
@@ -1,6 +1,8 @@
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;
@@ -8,6 +10,7 @@ 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 net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.fluids.Fluid;
@@ -17,20 +20,19 @@ public class HandlerTooltip_GC {
private static Block mBlock;
private static Class<?> oMainClass;
private static Class<?> oFuelLoaderClass;
- private static String[] mFuelNames;
+ private static HashMap <Integer, String> mFuelNames;
@SubscribeEvent
public void onItemTooltip(ItemTooltipEvent event) {
- if (LoadedMods.GalacticraftCore) {
+ if (LoadedMods.GalacticraftCore && AsmConfig.enableGcFuelChanges) {
if (mBlock == null) {
try {
- Class<?> GCBlocks = Class.forName("micdoodle8.mods.galacticraft.core.blocks.GCBlocks");
+ Class<?> GCBlocks = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.blocks.GCBlocks");
if (GCBlocks != null) {
oMainClass = GCBlocks;
- Class<?> GCFuelLoader = Class
- .forName("micdoodle8.mods.galacticraft.core.blocks.BlockFuelLoader");
+ Class<?> GCFuelLoader = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.blocks.BlockFuelLoader");
if (GCFuelLoader != null) {
oFuelLoaderClass = GCFuelLoader;
@@ -48,24 +50,26 @@ public class HandlerTooltip_GC {
} 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 (mFuelNames == null || mFuelNames.isEmpty()) {
+ mFuelNames = new LinkedHashMap<Integer, String>();
+ for (int aMapKey : RocketFuels.mValidRocketFuels.keySet()) {
+ Fluid aFuel = RocketFuels.mValidRocketFuels.get(aMapKey);
+ if (aFuel != null) {
+ mFuelNames.put(aMapKey, aFuel.getLocalizedName());
+ }
}
- }
- if (mItemBlock != null) {
+ }
+ 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")) {
- int aTier = 0;
- for (String s : mFuelNames) {
- if (s != null) {
- event.toolTip.add("Tier "+aTier+": "+s);
+ 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);
}
- }
+ }
}
}
}