aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Java/miscutil/MiscUtils.java11
-rw-r--r--src/Java/miscutil/core/util/ClassUtils.java75
-rw-r--r--src/Java/miscutil/core/util/Utils.java20
-rw-r--r--src/Java/miscutil/xmod/gregtech/common/blocks/fluid/GregtechFluidHandler.java101
-rw-r--r--src/Java/miscutil/xmod/ic2/HANDLER_IC2.java4
5 files changed, 168 insertions, 43 deletions
diff --git a/src/Java/miscutil/MiscUtils.java b/src/Java/miscutil/MiscUtils.java
index e02ad3233d..8407ddab6a 100644
--- a/src/Java/miscutil/MiscUtils.java
+++ b/src/Java/miscutil/MiscUtils.java
@@ -21,10 +21,7 @@ import miscutil.core.handler.events.LoginEventHandler;
import miscutil.core.item.general.RF2EU_Battery;
import miscutil.core.lib.CORE;
import miscutil.core.util.Utils;
-import miscutil.core.util.item.UtilsItems;
import miscutil.xmod.gregtech.HANDLER_GT;
-import net.minecraft.init.Items;
-import net.minecraft.item.ItemStack;
import net.minecraftforge.common.config.Configuration;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
@@ -36,7 +33,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
-@Mod(modid=CORE.MODID, name=CORE.name, version=CORE.VERSION, dependencies="required-after:Forge; after:IC2; after:psychedelicraft; after:gregtech; after:Forestry; after:MagicBees; after:CoFHCore; after:Growthcraft; after:Railcraft; after:CompactWindmills; after:ForbiddenMagic; after:MorePlanet; after:PneumaticCraft; after:ExtraUtilities; after:Thaumcraft; after:rftools; after:simplyjetpacks; after:BigReactors; after:EnderIO;")
+@Mod(modid=CORE.MODID, name=CORE.name, version=CORE.VERSION, dependencies="required-after:Forge; after:IC2; after:ihl; after:psychedelicraft; after:gregtech; after:Forestry; after:MagicBees; after:CoFHCore; after:Growthcraft; after:Railcraft; after:CompactWindmills; after:ForbiddenMagic; after:MorePlanet; after:PneumaticCraft; after:ExtraUtilities; after:Thaumcraft; after:rftools; after:simplyjetpacks; after:BigReactors; after:EnderIO;")
public class MiscUtils
implements ActionListener
{
@@ -114,12 +111,6 @@ implements ActionListener
public void serverStarting(FMLServerStartingEvent event)
{
event.registerServerCommand(new CommandMath());
- ItemStack input = UtilsItems.getSimpleStack(Items.poisonous_potato);
- ItemStack output = UtilsItems.getSimpleStack(Items.baked_potato);
- CORE.GT_Recipe.addSmeltingAndAlloySmeltingRecipe(input, output);
- input = UtilsItems.getSimpleStack(Items.slime_ball);
- output = UtilsItems.getSimpleStack(Items.nether_star);
- CORE.GT_Recipe.addSmeltingAndAlloySmeltingRecipe(input, output);
}
@Mod.EventHandler
diff --git a/src/Java/miscutil/core/util/ClassUtils.java b/src/Java/miscutil/core/util/ClassUtils.java
index 6ea9336006..ecf83f8b8f 100644
--- a/src/Java/miscutil/core/util/ClassUtils.java
+++ b/src/Java/miscutil/core/util/ClassUtils.java
@@ -1,23 +1,78 @@
package miscutil.core.util;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
public class ClassUtils {
-
+
/*@ if (isPresent("com.optionaldependency.DependencyClass")) {
// This block will never execute when the dependency is not present
// There is therefore no more risk of code throwing NoClassDefFoundException.
executeCodeLinkingToDependency();
}*/
public static boolean isPresent(String className) {
- try {
- Class.forName(className);
- return true;
- } catch (Throwable ex) {
- // Class or one of its dependencies is not present...
- return false;
- }
+ try {
+ Class.forName(className);
+ return true;
+ } catch (Throwable ex) {
+ // Class or one of its dependencies is not present...
+ return false;
+ }
+ }
+
+ public static Method getMethodViaReflection(Class<?> lookupClass, String methodName, boolean invoke) throws Exception{
+ Class<? extends Class> lookup = lookupClass.getClass();
+ Method m = lookup.getDeclaredMethod(methodName);
+ m.setAccessible(true);// Abracadabra
+ if (invoke){
+ m.invoke(lookup);// now its OK
+ }
+ return m;
}
-
-
+ public static Class getNonPublicClass(String className){
+ Class<?> c = null;
+ try {
+ c = Class.forName(className);
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ //full package name --------^^^^^^^^^^
+ //or simpler without Class.forName:
+ //Class<package1.A> c = package1.A.class;
+
+ if (null != c){
+ //In our case we need to use
+ Constructor<?> constructor = null;
+ try {
+ constructor = c.getDeclaredConstructor();
+ } catch (NoSuchMethodException | SecurityException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ //note: getConstructor() can return only public constructors
+ //so we needed to search for any Declared constructor
+
+ //now we need to make this constructor accessible
+ if (null != constructor){
+ constructor.setAccessible(true);//ABRACADABRA!
+
+ try {
+ Object o = constructor.newInstance();
+ return (Class) o;
+ } catch (InstantiationException | IllegalAccessException
+ | IllegalArgumentException | InvocationTargetException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ return null;
+ }
+
+
+
}
diff --git a/src/Java/miscutil/core/util/Utils.java b/src/Java/miscutil/core/util/Utils.java
index 476ca77e98..64e7b46496 100644
--- a/src/Java/miscutil/core/util/Utils.java
+++ b/src/Java/miscutil/core/util/Utils.java
@@ -3,10 +3,14 @@ package miscutil.core.util;
import gregtech.api.enums.TC_Aspects;
import gregtech.api.enums.TC_Aspects.TC_AspectStack;
import ic2.core.IC2Potion;
+import ic2.core.Ic2Items;
+import ic2.core.init.InternalName;
import ic2.core.item.armor.ItemArmorHazmat;
+import ic2.core.item.resources.ItemCell;
import java.awt.Color;
import java.awt.Graphics;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -31,6 +35,7 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
+import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
@@ -461,6 +466,21 @@ public class Utils {
return false;
}
+ public static ItemStack createInternalNameAndFluidCell(String s){
+ InternalName yourName = EnumHelper.addEnum(InternalName.class, s, new Class[0], new Object[0]);
+ ItemCell item = (ItemCell)Ic2Items.cell.getItem();
+ try
+ {
+ Class<? extends ItemCell> clz = item.getClass();
+ Method methode = clz.getMethod("addCell", int.class, InternalName.class, Block[].class);
+ methode.setAccessible(true);
+ return (ItemStack) methode.invoke(item, 1000, yourName, new Block[0]);
+ }
+ catch(Exception e){
+ }
+ return null;
+ }
+
}
diff --git a/src/Java/miscutil/xmod/gregtech/common/blocks/fluid/GregtechFluidHandler.java b/src/Java/miscutil/xmod/gregtech/common/blocks/fluid/GregtechFluidHandler.java
index d50312e17f..d71461197f 100644
--- a/src/Java/miscutil/xmod/gregtech/common/blocks/fluid/GregtechFluidHandler.java
+++ b/src/Java/miscutil/xmod/gregtech/common/blocks/fluid/GregtechFluidHandler.java
@@ -5,19 +5,32 @@ import gregtech.api.enums.ItemList;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.util.GT_OreDictUnificator;
import ic2.api.item.IC2Items;
+import ic2.core.Ic2Items;
+import ic2.core.init.InternalName;
+import ic2.core.item.resources.ItemCell;
+
+import java.util.HashMap;
+import java.util.IdentityHashMap;
+import java.util.Map;
+
import miscutil.core.lib.LoadedMods;
import miscutil.core.util.Utils;
import miscutil.core.util.fluid.FluidUtils;
import miscutil.core.util.item.UtilsItems;
import miscutil.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials;
import miscutil.xmod.gregtech.common.Meta_GT_Proxy;
+import net.minecraft.block.Block;
+import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
+import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
public class GregtechFluidHandler {
+ protected static int cellID = 0;
+
public static void run(){
start();
}
@@ -50,37 +63,37 @@ public class GregtechFluidHandler {
Utils.LOG_INFO("Adding in GT Fluids for Molten Salt, Cooled Salt and Various other Nuclide related content.");
Meta_GT_Proxy.addFluid("hydrofluoricAcid", "Hydrofluoric Acid", GT_Materials.HydrofluoricAcid, 1, 120, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.HydrofluoricAcid, 1L), ItemList.Cell_Empty.get(1L, new Object[0]), 1000);
generateIC2FluidCell("HydrofluoricAcid");
-
+
Meta_GT_Proxy.addFluid("sulfurDioxide", "Sulfur Dioxide", GT_Materials.SulfurDioxide, 4, -100, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.SulfurDioxide, 1L), ItemList.Cell_Empty.get(1L, new Object[0]), 1000);
generateIC2FluidCell("SulfurDioxide");
-
+
Meta_GT_Proxy.addFluid("sulfurousAcid", "Sulfurous Acid", GT_Materials.SulfurousAcid, 4, 75, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.SulfurousAcid, 1L), ItemList.Cell_Empty.get(1L, new Object[0]), 1000);
generateIC2FluidCell("SulfurousAcid");
-
+
Meta_GT_Proxy.addFluid("sulfuricApatite", "Sulfuric Apatite", GT_Materials.SulfuricApatite, 4, 500, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.SulfuricApatite, 1L), ItemList.Cell_Empty.get(1L, new Object[0]), 1000);
generateIC2FluidCell("SulfuricApatite");
-
+
Meta_GT_Proxy.addFluid("uraniumHexafluoride", "Uranium Hexafluoride", GT_Materials.UraniumHexaFluoride, 4, 200, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.UraniumHexaFluoride, 1L), ItemList.Cell_Empty.get(1L, new Object[0]), 1000);
generateIC2FluidCell("UraniumHexaFluoride");
-
+
Meta_GT_Proxy.addFluid("uraniumTetrafluoride", "Uranium Tetrafluoride", GT_Materials.UraniumTetraFluoride, 4, 950, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.UraniumTetraFluoride, 1L), ItemList.Cell_Empty.get(1L, new Object[0]), 1000);
generateIC2FluidCell("UraniumTetraFluoride");
-
+
Meta_GT_Proxy.addFluid("thoriumTetrafluoride", "Thorium Tetrafluoride", GT_Materials.ThoriumTetraFluoride, 4, 1250, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.ThoriumTetraFluoride, 1L), ItemList.Cell_Empty.get(1L, new Object[0]), 1000);
generateIC2FluidCell("ThoriumTetraFluoride");
-
-
+
+
if (!LoadedMods.IHL || UtilsItems.getItemStackOfAmountFromOreDict("cellHydrogenChloride", 1) == null){
-
+
if (FluidUtils.getFluidStack("hydrogenchloride", 1) == null){
- if (LoadedMods.IHL){
- Utils.LOG_INFO("IHL Loaded but hydrogen chloride could not be found for some reason. Adding our own.");
+ if (LoadedMods.IHL){
+ Utils.LOG_INFO("IHL Loaded but hydrogen chloride could not be found for some reason. Adding our own.");
}
- else {
- Utils.LOG_INFO("No Suitable versions of Hydrogen Chloride available, adding our own.");
- }
- Meta_GT_Proxy.addFluid("hydrogenChloride", "Hydrogen Chloride", GT_Materials.HydrogenChloride, 4, 75, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.HydrogenChloride, 1L), ItemList.Cell_Empty.get(1L, new Object[0]), 1000);
- generateIC2FluidCell("HydrogenChloride");
+ else {
+ Utils.LOG_INFO("No Suitable versions of Hydrogen Chloride available, adding our own.");
+ }
+ Meta_GT_Proxy.addFluid("hydrogenChloride", "Hydrogen Chloride", GT_Materials.HydrogenChloride, 4, 75, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.HydrogenChloride, 1L), ItemList.Cell_Empty.get(1L, new Object[0]), 1000);
+ generateIC2FluidCell("HydrogenChloride");
}
}
@@ -101,9 +114,9 @@ public class GregtechFluidHandler {
* so if you dissolve aparite in sulphuric acid
* you'll get a mixture of SO2, H2O, HF and HCl
*/
-
-
-
+
+
+
FluidStack[] apatiteOutput = {
FluidUtils.getFluidStack("sulfurousacid", 3800),
FluidUtils.getFluidStack("hydrofluoricacid", 400)
@@ -114,7 +127,7 @@ public class GregtechFluidHandler {
UtilsItems.getItemStackOfAmountFromOreDict("cellHydrogenChloride", 1),
45*20,
256);
-
+
FluidStack[] sulfurousacidOutput = {
FluidUtils.getFluidStack("sulfurdioxide", 500),
FluidUtils.getFluidStack("water", 500)
@@ -125,7 +138,7 @@ public class GregtechFluidHandler {
null,
10*20,
60);
-
+
FluidStack[] sulfurdioxideOutput = {
FluidUtils.getFluidStack("oxygen", 133*2)
};
@@ -164,9 +177,53 @@ public class GregtechFluidHandler {
FluidContainerRegistry.registerFluidContainer(new FluidContainerRegistry.FluidContainerData(FluidUtils.getFluidStack(fluidNameWithCaps.toLowerCase(), 1000), filledCell, emptyCell.copy()));
}
else {
- Utils.LOG_INFO("Failed to create a cell for "+fluidNameWithCaps);
+
+ Utils.LOG_INFO("Failed to create a cell for "+fluidNameWithCaps+". Trying seconday method.");
+ Utils.createInternalNameAndFluidCell(fluidNameWithCaps);
+ //setUpNewFluidCell(cellID++, fluidNameWithCaps);
+
+ }
+ }
+ }
+
+ public static <T extends Enum<? >> T addEnum(Class<T> enumType, String enumName, Class<?>[] paramTypes, Object[] paramValues) {
+ return null;
+ }
+
+ private static Map<Integer, InternalName> names = new HashMap<Integer, InternalName>();
+ private static Map<Block, ItemStack> cells = new IdentityHashMap<Block, ItemStack>();
+
+ public static boolean setUpNewFluidCell(int meta, String name){
+ try {
+ InternalName fluidName = EnumHelper.addEnum(InternalName.class, name, new Class[0], new Object[0]);
+ //EnumHelper.addEnum(InternalName.class, "InternalName", name);
+ if (fluidName.valueOf(name) != null){
+ addRegisterCell(meta, fluidName);
+ return true;
}
+ Utils.LOG_INFO("Secondary Cell Method failed.");
+ return false;
+ } catch (Throwable r) {
+ Utils.LOG_INFO("Secondary Cell Method failed..");
+ Utils.LOG_INFO("Reason: "+r.getMessage());
+ Utils.LOG_INFO("Reason: "+r);
+ r.printStackTrace();
+ return false;
}
}
+ private static ItemStack addCell(int meta, InternalName name){
+ ItemCell itemCell = new ItemCell(InternalName.valueOf(name.name()));
+ names.put(Integer.valueOf(meta), InternalName.valueOf(name.name()));
+ ItemStack ret = new ItemStack(itemCell, 1, meta);
+ cells.put(Blocks.air, ret);
+ return ret;
+ }
+
+ private static ItemStack addRegisterCell(int meta, InternalName name){
+ ItemStack ret = addCell(meta, name);
+ FluidContainerRegistry.registerFluidContainer(FluidUtils.getFluidStack("air", 0), ret.copy(), Ic2Items.cell.copy());
+ return ret;
+ }
+
}
diff --git a/src/Java/miscutil/xmod/ic2/HANDLER_IC2.java b/src/Java/miscutil/xmod/ic2/HANDLER_IC2.java
index 968603a01d..cf2e0e3d17 100644
--- a/src/Java/miscutil/xmod/ic2/HANDLER_IC2.java
+++ b/src/Java/miscutil/xmod/ic2/HANDLER_IC2.java
@@ -1,6 +1,8 @@
package miscutil.xmod.ic2;
+import ic2.core.init.InternalName;
import miscutil.core.lib.LoadedMods;
+import miscutil.xmod.ic2.block.RTGGenerator.BlockRTG;
import miscutil.xmod.ic2.item.IC2_Items;
import miscutil.xmod.ic2.recipe.RECIPE_IC2;
@@ -9,7 +11,7 @@ public class HANDLER_IC2{
public static void preInit() {
if (LoadedMods.IndustrialCraft2){
IC2_Items.register();
- //new BlockRTG(InternalName.blockGenerator);
+ new BlockRTG(InternalName.beer);
}
}