aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/util
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2019-10-10 17:45:37 +0100
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2019-10-10 17:45:37 +0100
commitab84b1d95f8c4880891debc594a41f57941de78a (patch)
treec3bcdbda25cb0d45028dff77944d3e5fbff7edcd /src/Java/gtPlusPlus/core/util
parent89d30a5cfcc2d3d5773647350edf913f156062b3 (diff)
downloadGT5-Unofficial-ab84b1d95f8c4880891debc594a41f57941de78a.tar.gz
GT5-Unofficial-ab84b1d95f8c4880891debc594a41f57941de78a.tar.bz2
GT5-Unofficial-ab84b1d95f8c4880891debc594a41f57941de78a.zip
+ Added some new functions to ReflectionUtils.java.
+ Added an alternative way to Obtain Blizz rods, dust and Cryotheum dust if GalaxySpace is loaded. Closes #557. $ Fixed bug in DecayableRecipeHandler.java. $ Fixed instance where I was directly referencing forestry code. $ Rewrote how canning/uncanning recipes are handled, hopefully fixes the corruption of the recipe map. > I potentially broke some of my own canning recipes, so be aware of any missing and let me know.
Diffstat (limited to 'src/Java/gtPlusPlus/core/util')
-rw-r--r--src/Java/gtPlusPlus/core/util/math/MathUtils.java5
-rw-r--r--src/Java/gtPlusPlus/core/util/minecraft/FluidUtils.java8
-rw-r--r--src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java44
3 files changed, 43 insertions, 14 deletions
diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java
index a9f7b901ef..2f4db2efcc 100644
--- a/src/Java/gtPlusPlus/core/util/math/MathUtils.java
+++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java
@@ -13,6 +13,8 @@ import gtPlusPlus.core.util.Utils;
public class MathUtils {
+ final static Random rand = CORE.RANDOM;
+
/**
* Returns a psuedo-random number between min and max, inclusive.
* The difference between min and max can be at most
@@ -23,9 +25,6 @@ public class MathUtils {
* @return Integer between min and max, inclusive.
* @see java.util.Random#nextInt(int)
*/
-
- final static Random rand = CORE.RANDOM;
-
public static int randInt(final int min, final int max) {
// nextInt is normally exclusive of the top value,
// so add 1 to make it inclusive
diff --git a/src/Java/gtPlusPlus/core/util/minecraft/FluidUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/FluidUtils.java
index a2bfa5dcb2..a0eb0f17e2 100644
--- a/src/Java/gtPlusPlus/core/util/minecraft/FluidUtils.java
+++ b/src/Java/gtPlusPlus/core/util/minecraft/FluidUtils.java
@@ -13,9 +13,11 @@ import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.api.objects.minecraft.FluidGT6;
import gtPlusPlus.core.item.base.BaseItemComponent;
import gtPlusPlus.core.item.base.cell.BaseItemPlasmaCell;
+import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.material.Material;
import gtPlusPlus.core.material.MaterialGenerator;
import gtPlusPlus.core.material.MaterialStack;
+import gtPlusPlus.core.recipe.common.CI;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials;
import net.minecraftforge.fluids.*;
@@ -309,7 +311,7 @@ public class FluidUtils {
rFluid.setTemperature((int) (aTemperatureK));
}
if ((aFullContainer != null) && (aEmptyContainer != null) && !FluidContainerRegistry.registerFluidContainer(new FluidStack(rFluid, aFluidAmount), aFullContainer, aEmptyContainer)) {
- MaterialGenerator.addFluidCannerRecipe(aFullContainer, container(aFullContainer, false), null, new FluidStack(rFluid, aFluidAmount));
+ CORE.RA.addFluidCannerRecipe(CI.emptyCells(1), aFullContainer, null, new FluidStack(rFluid, aFluidAmount));
}
else {
//Utils.LOG_INFO("Failed creating recipes to fill/empty cells of "+aName+".");
@@ -461,7 +463,7 @@ public class FluidUtils {
aGenerateCell);
if (dustStack != null){
- MaterialGenerator.addFluidExtractionRecipe(
+ CORE.RA.addFluidExtractionRecipe(
dustStack, //Input
null, //Input 2
FluidUtils.getFluidStack(gtFluid, amountPerItem), //Fluid Output
@@ -471,7 +473,7 @@ public class FluidUtils {
);
}
if (dustStack2 != null){
- MaterialGenerator.addFluidExtractionRecipe(
+ CORE.RA.addFluidExtractionRecipe(
dustStack2, //Input
null, //Input 2
FluidUtils.getFluidStack(gtFluid, amountPerItem), //Fluid Output
diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java
index b52c13c563..7ef9ef6632 100644
--- a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java
+++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java
@@ -169,6 +169,17 @@ public class ReflectionUtils {
return y.get();
}
}
+
+ public static boolean isStaticMethod(Class<?> aClass, String aMethodName, Class<?>... aTypes) {
+ return isStaticMethod(ReflectionUtils.getMethod(aClass, aMethodName, aTypes));
+ }
+
+ public static boolean isStaticMethod(Method aMethod) {
+ if (aMethod != null && Modifier.isStatic(aMethod.getModifiers())) {
+ return true;
+ }
+ return false;
+ }
@@ -381,7 +392,6 @@ public class ReflectionUtils {
public static boolean invoke(Object objectInstance, String methodName, Class[] parameters, Object[] values){
if (objectInstance == null || methodName == null || parameters == null || values == null){
- //Logger.REFLECTION("Null value when trying to Dynamically invoke "+methodName+" on an object of type: "+objectInstance.getClass().getName());
return false;
}
Class<?> mLocalClass = (objectInstance instanceof Class ? (Class<?>) objectInstance : objectInstance.getClass());
@@ -389,6 +399,28 @@ public class ReflectionUtils {
try {
Method mInvokingMethod = mLocalClass.getDeclaredMethod(methodName, parameters);
if (mInvokingMethod != null){
+ return invoke(objectInstance, mInvokingMethod, values);
+ }
+ }
+ catch (NoSuchMethodException | SecurityException | IllegalArgumentException e) {
+ Logger.REFLECTION("Failed to Dynamically invoke "+methodName+" on an object of type: "+mLocalClass.getName());
+ }
+
+ Logger.REFLECTION("Invoke failed or did something wrong.");
+ return false;
+ }
+
+ public static boolean invoke(Object objectInstance, Method method, Object[] values){
+ if (method == null || values == null || (!ReflectionUtils.isStaticMethod(method) && objectInstance == null)){
+ //Logger.REFLECTION("Null value when trying to Dynamically invoke "+methodName+" on an object of type: "+objectInstance.getClass().getName());
+ return false;
+ }
+ String methodName = method.getName();
+ String classname = objectInstance != null ? objectInstance.getClass().getCanonicalName() : method.getDeclaringClass().getCanonicalName();
+ Logger.REFLECTION("Trying to invoke "+methodName+" on an instance of "+classname+".");
+ try {
+ Method mInvokingMethod = method;
+ if (mInvokingMethod != null){
Logger.REFLECTION(methodName+" was not null.");
if ((boolean) mInvokingMethod.invoke(objectInstance, values)){
Logger.REFLECTION("Successfully invoked "+methodName+".");
@@ -398,14 +430,10 @@ public class ReflectionUtils {
Logger.REFLECTION("Invocation failed for "+methodName+".");
}
}
- else {
- Logger.REFLECTION(methodName+" is null.");
- }
}
- catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- Logger.REFLECTION("Failed to Dynamically invoke "+methodName+" on an object of type: "+mLocalClass.getName());
- }
-
+ catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ Logger.REFLECTION("Failed to Dynamically invoke "+methodName+" on an object of type: "+classname);
+ }
Logger.REFLECTION("Invoke failed or did something wrong.");
return false;
}