diff options
author | Alkalus <Draknyte1@hotmail.com> | 2020-03-31 01:25:58 +0100 |
---|---|---|
committer | Alkalus <Draknyte1@hotmail.com> | 2020-03-31 01:25:58 +0100 |
commit | 75ea33600537047847091b55a46f5b88c3c75dbb (patch) | |
tree | 3050dc52746859cb9003e09f75dc91a7d7eb5911 /src/Java/gtPlusPlus/core/util/reflect | |
parent | b5cbe510e959ae0fe8803b5df1031f2752c50e30 (diff) | |
download | GT5-Unofficial-75ea33600537047847091b55a46f5b88c3c75dbb.tar.gz GT5-Unofficial-75ea33600537047847091b55a46f5b88c3c75dbb.tar.bz2 GT5-Unofficial-75ea33600537047847091b55a46f5b88c3c75dbb.zip |
+ Added Custom NEI Handler for IsaMIll.
+ Added Death by IsaMIll.
% Moved debug mode switch to AsmConfig.
$ Fixed handling of custom OrePrefixes.
$ Fixed OreDict registration of MetaFoodItems.
$ Improved handling of Core Classes being static initialised too early.
$ Fixed client-side bug in Distillus which would cause an infinite loop.
$ Fixed bug in ForgeEnumHelper.
$ Fixed bug in setField methods from ReflectionUtils.
Diffstat (limited to 'src/Java/gtPlusPlus/core/util/reflect')
-rw-r--r-- | src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index 4d8a02d800..e45d27b926 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -365,7 +365,13 @@ public class ReflectionUtils { public static boolean setField(final Object object, final String fieldName, final Object fieldValue) { - Class<?> clazz = object.getClass(); + Class<?> clazz; + if (object instanceof Class) { + clazz = (Class<?>) object; + } + else { + clazz = object.getClass(); + } while (clazz != null) { try { final Field field = getField(clazz, fieldName); @@ -387,7 +393,13 @@ public class ReflectionUtils { } public static boolean setField(final Object object, final Field field, final Object fieldValue) { - Class<?> clazz = object.getClass(); + Class<?> clazz; + if (object instanceof Class) { + clazz = (Class<?>) object; + } + else { + clazz = object.getClass(); + } while (clazz != null) { try { final Field field2 = getField(clazz, field.getName()); @@ -522,6 +534,25 @@ public class ReflectionUtils { return false; } + + public static Object invokeNonBool(Object objectInstance, Method method, Object[] values){ + if (objectInstance == null || method == null || values == null){ + return false; + } + String methodName = method.getName(); + Class<?> mLocalClass = (objectInstance instanceof Class ? (Class<?>) objectInstance : objectInstance.getClass()); + Logger.REFLECTION("Trying to invoke "+methodName+" on an instance of "+mLocalClass.getCanonicalName()+"."); + try { + return method.invoke(objectInstance, values); + } + catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + Logger.REFLECTION("Failed to Dynamically invoke "+methodName+" on an object of type: "+mLocalClass.getName()); + } + + Logger.REFLECTION("Invoke failed or did something wrong."); + return null; + } + public static Object invokeNonBool(Object objectInstance, String methodName, Class[] parameters, Object[] values){ if (objectInstance == null || methodName == null || parameters == null || values == null){ return false; @@ -973,9 +1004,9 @@ public class ReflectionUtils { */ private static void makeModifiable(Field nameField) throws Exception { nameField.setAccessible(true); - Field modifiers = getField(Field.class, "modifiers"); - modifiers.setAccessible(true); - modifiers.setInt(nameField, nameField.getModifiers() & ~Modifier.FINAL); + Field modifiers = getField(Field.class, "modifiers"); + modifiers.setAccessible(true); + modifiers.setInt(nameField, nameField.getModifiers() & ~Modifier.FINAL); } |