aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/xmod/galacticraft
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/galacticraft')
-rw-r--r--src/main/java/gtPlusPlus/xmod/galacticraft/HANDLER_GalactiCraft.java49
-rw-r--r--src/main/java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java132
-rw-r--r--src/main/java/gtPlusPlus/xmod/galacticraft/util/GalacticUtils.java294
3 files changed, 234 insertions, 241 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/galacticraft/HANDLER_GalactiCraft.java b/src/main/java/gtPlusPlus/xmod/galacticraft/HANDLER_GalactiCraft.java
index d5c7a7e4e5..5957cfc89d 100644
--- a/src/main/java/gtPlusPlus/xmod/galacticraft/HANDLER_GalactiCraft.java
+++ b/src/main/java/gtPlusPlus/xmod/galacticraft/HANDLER_GalactiCraft.java
@@ -3,32 +3,29 @@ package gtPlusPlus.xmod.galacticraft;
import gtPlusPlus.core.lib.LoadedMods;
public class HANDLER_GalactiCraft {
-
- //private static final HashMap<String, BaseSolarSystem> mSystemsCache = new HashMap<String, BaseSolarSystem>();
-
- public static void preInit(){
- if (LoadedMods.GalacticraftCore){
- //mSystemsCache.put("HD10180", new SystemHD10180());
- /*for (BaseSolarSystem solar : mSystemsCache.values()) {
- Logger.SPACE("Running 'pre-init' for "+solar.mSystemName);
- solar.preInit();
- }*/
- }
- }
- public static void init(){
- if (LoadedMods.GalacticraftCore){
- /*for (BaseSolarSystem solar : mSystemsCache.values()) {
- Logger.SPACE("Running 'init' for "+solar.mSystemName);
- solar.init();
- }*/
- }
- }
+ // private static final HashMap<String, BaseSolarSystem> mSystemsCache = new HashMap<String, BaseSolarSystem>();
- public static void postInit(){
- if (LoadedMods.GalacticraftCore){
-
- }
- }
-
+ public static void preInit() {
+ if (LoadedMods.GalacticraftCore) {
+ // mSystemsCache.put("HD10180", new SystemHD10180());
+ /*for (BaseSolarSystem solar : mSystemsCache.values()) {
+ Logger.SPACE("Running 'pre-init' for "+solar.mSystemName);
+ solar.preInit();
+ }*/
+ }
+ }
+
+ public static void init() {
+ if (LoadedMods.GalacticraftCore) {
+ /*for (BaseSolarSystem solar : mSystemsCache.values()) {
+ Logger.SPACE("Running 'init' for "+solar.mSystemName);
+ solar.init();
+ }*/
+ }
+ }
+
+ public static void postInit() {
+ if (LoadedMods.GalacticraftCore) {}
+ }
}
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);
+ }
+ }
+ }
+ }
+ }
+ }
}
diff --git a/src/main/java/gtPlusPlus/xmod/galacticraft/util/GalacticUtils.java b/src/main/java/gtPlusPlus/xmod/galacticraft/util/GalacticUtils.java
index f237aed335..b0b5b48d7d 100644
--- a/src/main/java/gtPlusPlus/xmod/galacticraft/util/GalacticUtils.java
+++ b/src/main/java/gtPlusPlus/xmod/galacticraft/util/GalacticUtils.java
@@ -1,169 +1,163 @@
package gtPlusPlus.xmod.galacticraft.util;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
import gregtech.api.enums.Materials;
import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.core.item.chemistry.RocketFuels;
import gtPlusPlus.core.util.minecraft.FluidUtils;
import gtPlusPlus.core.util.reflect.ReflectionUtils;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import net.minecraft.entity.Entity;
import net.minecraftforge.fluids.FluidStack;
public class GalacticUtils {
- static final private Class<?> aTieredRocket;
- static final private Class<?> aLandingPad;
- static final private Class<?> aBuggyPad;
- static final private Class<?> aIDockable;
- static final private Class<?> aIFuelable;
- static final private Method getRocketTier;
- static final private Method getRocket;
- static final private Method getBuggy;
-
- static {
- Class<?> a1, a2, a3, a4, a5;
- Method m1, m2, m3;
- try {
- a1 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket");
- a2 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad");
- a3 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.tile.TileEntityBuggyFueler");
- a4 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.api.entity.IDockable");
- a5 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.api.entity.IFuelable");
- m1 = ReflectionUtils.getMethod(a1, "getRocketTier");
- m2 = ReflectionUtils.getMethod(a2, "getDockedEntity");
- m3 = ReflectionUtils.getMethod(a3, "getDockedEntity");
- }
- catch (Throwable t) {
- a1 = null;
- a2 = null;
- a3 = null;
- a4 = null;
- a5 = null;
- m1 = null;
- m2 = null;
- m3 = null;
- }
- aTieredRocket = a1;
- aLandingPad = a2;
- aBuggyPad = a3;
- aIDockable = a4;
- aIFuelable = a5;
- getRocketTier = m1;
- getRocket = m2;
- getBuggy = m3;
- if (a1 != null && a2 != null && a3 != null && a4 != null && a5 != null && m1 != null && m2 != null && m3 != null) {
- Logger.SPACE("Successfully relfected into 5 classes and 3 methods.");
- }
- else {
- Logger.SPACE("Failed to relfect into Galacticraft classes and methods.");
- if (a1 == null) {
- Logger.SPACE("micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket was null..");
- }
- if (a2 == null) {
- Logger.SPACE("micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad was null..");
- }
- if (a3 == null) {
- Logger.SPACE("micdoodle8.mods.galacticraft.core.tile.TileEntityBuggyFueler was null..");
- }
- if (a4 == null) {
- Logger.SPACE("micdoodle8.mods.galacticraft.api.entity.IDockable was null..");
- }
- if (a5 == null) {
- Logger.SPACE("micdoodle8.mods.galacticraft.api.entity.IFuelable was null..");
- }
- if (m1 == null) {
- Logger.SPACE("getRocketTier was null..");
- }
- if (m2 == null) {
- Logger.SPACE("getDockedEntity was null..");
- }
- if (m3 == null) {
- Logger.SPACE("getDockedEntity(buggy) was null..");
- }
- }
- }
-
-
- public static int getRocketTier(Entity aEntity) {
- if (aTieredRocket.isInstance(aEntity)) {
- if (getRocketTier != null) {
- try {
- return (int) getRocketTier.invoke(aEntity, new Object[] {});
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- }
- }
- }
- return -1;
- }
-
- public static int getRocketTier(Object aEntity) {
- if (aIFuelable.isInstance(aEntity)) {
- if (aLandingPad.isInstance(aEntity)) {
- Object rocket;
- try {
- rocket = getRocket.invoke(aLandingPad, new Object[] {});
- if (aIDockable.isInstance(rocket) && rocket != null) {
- return getRocketTier((Entity) rocket);
- }
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- }
- }
- else if (aBuggyPad.isInstance(aEntity)) {
- Object buggy;
- try {
- buggy = getBuggy.invoke(aBuggyPad, new Object[] {});
- if (aIDockable.isInstance(buggy) && buggy != null) {
- return 0;
- }
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- }
- }
- }
- return -1;
- }
-
- public static boolean isFuelValidForTier(int aTier, FluidStack aFuel) {
- FluidStack aValidForThisTier = getValidFuelForTier(aTier);
- if (aFuel.isFluidEqual(aValidForThisTier)) {
- return true;
- }
- return false;
- }
+ private static final Class<?> aTieredRocket;
+ private static final Class<?> aLandingPad;
+ private static final Class<?> aBuggyPad;
+ private static final Class<?> aIDockable;
+ private static final Class<?> aIFuelable;
+ private static final Method getRocketTier;
+ private static final Method getRocket;
+ private static final Method getBuggy;
+ static {
+ Class<?> a1, a2, a3, a4, a5;
+ Method m1, m2, m3;
+ try {
+ a1 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket");
+ a2 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad");
+ a3 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.tile.TileEntityBuggyFueler");
+ a4 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.api.entity.IDockable");
+ a5 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.api.entity.IFuelable");
+ m1 = ReflectionUtils.getMethod(a1, "getRocketTier");
+ m2 = ReflectionUtils.getMethod(a2, "getDockedEntity");
+ m3 = ReflectionUtils.getMethod(a3, "getDockedEntity");
+ } catch (Throwable t) {
+ a1 = null;
+ a2 = null;
+ a3 = null;
+ a4 = null;
+ a5 = null;
+ m1 = null;
+ m2 = null;
+ m3 = null;
+ }
+ aTieredRocket = a1;
+ aLandingPad = a2;
+ aBuggyPad = a3;
+ aIDockable = a4;
+ aIFuelable = a5;
+ getRocketTier = m1;
+ getRocket = m2;
+ getBuggy = m3;
+ if (a1 != null
+ && a2 != null
+ && a3 != null
+ && a4 != null
+ && a5 != null
+ && m1 != null
+ && m2 != null
+ && m3 != null) {
+ Logger.SPACE("Successfully relfected into 5 classes and 3 methods.");
+ } else {
+ Logger.SPACE("Failed to relfect into Galacticraft classes and methods.");
+ if (a1 == null) {
+ Logger.SPACE("micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket was null..");
+ }
+ if (a2 == null) {
+ Logger.SPACE("micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad was null..");
+ }
+ if (a3 == null) {
+ Logger.SPACE("micdoodle8.mods.galacticraft.core.tile.TileEntityBuggyFueler was null..");
+ }
+ if (a4 == null) {
+ Logger.SPACE("micdoodle8.mods.galacticraft.api.entity.IDockable was null..");
+ }
+ if (a5 == null) {
+ Logger.SPACE("micdoodle8.mods.galacticraft.api.entity.IFuelable was null..");
+ }
+ if (m1 == null) {
+ Logger.SPACE("getRocketTier was null..");
+ }
+ if (m2 == null) {
+ Logger.SPACE("getDockedEntity was null..");
+ }
+ if (m3 == null) {
+ Logger.SPACE("getDockedEntity(buggy) was null..");
+ }
+ }
+ }
+ public static int getRocketTier(Entity aEntity) {
+ if (aTieredRocket.isInstance(aEntity)) {
+ if (getRocketTier != null) {
+ try {
+ return (int) getRocketTier.invoke(aEntity, new Object[] {});
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ }
+ }
+ }
+ return -1;
+ }
- public static FluidStack getValidFuelForTier(Entity aEntity) {
- if (aTieredRocket.isInstance(aEntity)) {
- return getValidFuelForTier(getRocketTier(aEntity));
- }
- else {
- Logger.SPACE("Failed to get valid rocket fuel for "+aEntity.getClass().getCanonicalName());
- return getValidFuelForTier(0);
- }
- }
+ public static int getRocketTier(Object aEntity) {
+ if (aIFuelable.isInstance(aEntity)) {
+ if (aLandingPad.isInstance(aEntity)) {
+ Object rocket;
+ try {
+ rocket = getRocket.invoke(aLandingPad, new Object[] {});
+ if (aIDockable.isInstance(rocket) && rocket != null) {
+ return getRocketTier((Entity) rocket);
+ }
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ }
+ } else if (aBuggyPad.isInstance(aEntity)) {
+ Object buggy;
+ try {
+ buggy = getBuggy.invoke(aBuggyPad, new Object[] {});
+ if (aIDockable.isInstance(buggy) && buggy != null) {
+ return 0;
+ }
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ }
+ }
+ }
+ return -1;
+ }
- public static FluidStack getValidFuelForTier(int aTier) {
- if (aTier > 0 && aTier <= 2) {
- return FluidUtils.getFluidStack(RocketFuels.RP1_Plus_Liquid_Oxygen, 1000);
- }
- else if (aTier >= 3 && aTier <= 5) {
- return FluidUtils.getFluidStack(RocketFuels.Dense_Hydrazine_Mix, 1000);
- }
- else if (aTier >= 6 && aTier <= 7) {
- return FluidUtils.getFluidStack(RocketFuels.Monomethylhydrazine_Plus_Nitric_Acid, 1000);
- }
- else if (aTier >= 8 && aTier <= 10) {
- return FluidUtils.getFluidStack(RocketFuels.Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide, 1000);
- }
- else {
- if (aTier == 0) {
- return Materials.Fuel.getFluid(1000);
- }
- return null;
- }
+ public static boolean isFuelValidForTier(int aTier, FluidStack aFuel) {
+ FluidStack aValidForThisTier = getValidFuelForTier(aTier);
+ if (aFuel.isFluidEqual(aValidForThisTier)) {
+ return true;
+ }
+ return false;
+ }
- }
+ public static FluidStack getValidFuelForTier(Entity aEntity) {
+ if (aTieredRocket.isInstance(aEntity)) {
+ return getValidFuelForTier(getRocketTier(aEntity));
+ } else {
+ Logger.SPACE(
+ "Failed to get valid rocket fuel for " + aEntity.getClass().getCanonicalName());
+ return getValidFuelForTier(0);
+ }
+ }
+ public static FluidStack getValidFuelForTier(int aTier) {
+ if (aTier > 0 && aTier <= 2) {
+ return FluidUtils.getFluidStack(RocketFuels.RP1_Plus_Liquid_Oxygen, 1000);
+ } else if (aTier >= 3 && aTier <= 5) {
+ return FluidUtils.getFluidStack(RocketFuels.Dense_Hydrazine_Mix, 1000);
+ } else if (aTier >= 6 && aTier <= 7) {
+ return FluidUtils.getFluidStack(RocketFuels.Monomethylhydrazine_Plus_Nitric_Acid, 1000);
+ } else if (aTier >= 8 && aTier <= 10) {
+ return FluidUtils.getFluidStack(RocketFuels.Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide, 1000);
+ } else {
+ if (aTier == 0) {
+ return Materials.Fuel.getFluid(1000);
+ }
+ return null;
+ }
+ }
}