diff options
author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2019-03-01 03:00:51 +0000 |
---|---|---|
committer | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2019-03-01 03:00:51 +0000 |
commit | 35522722af5dddea144c841a71f4fa9087e68966 (patch) | |
tree | 39f2e3908901026411d9b0ca77d4416ffb8d18cb /src/Java/gtPlusPlus/core | |
parent | a5f5766e189593f8cfe7fbef862b1bb77207720e (diff) | |
download | GT5-Unofficial-35522722af5dddea144c841a71f4fa9087e68966.tar.gz GT5-Unofficial-35522722af5dddea144c841a71f4fa9087e68966.tar.bz2 GT5-Unofficial-35522722af5dddea144c841a71f4fa9087e68966.zip |
% More work on TiCon Compat.
Diffstat (limited to 'src/Java/gtPlusPlus/core')
-rw-r--r-- | src/Java/gtPlusPlus/core/material/Material.java | 10 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/util/data/StringUtils.java | 15 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java | 29 |
3 files changed, 46 insertions, 8 deletions
diff --git a/src/Java/gtPlusPlus/core/material/Material.java b/src/Java/gtPlusPlus/core/material/Material.java index 01503a1fc5..ba572efe90 100644 --- a/src/Java/gtPlusPlus/core/material/Material.java +++ b/src/Java/gtPlusPlus/core/material/Material.java @@ -498,7 +498,9 @@ public class Material { this.textureSet = setTextureSet(set, vTier); if (LoadedMods.TiCon && this.materialState == MaterialState.SOLID) { - this.vTiConHandler = new BaseTinkersMaterial(this); + if (this.getProtons() >= 98 || this.getComposites().size() > 1 || this.getMeltingPointC() >= 3600) { + this.vTiConHandler = new BaseTinkersMaterial(this); + } } Logger.MATERIALS("Creating a Material instance for "+materialName); @@ -753,7 +755,11 @@ public class Material { } final public Block getBlock(){ - return Block.getBlockFromItem(getBlock(1).getItem()); + Block b = Block.getBlockFromItem(getBlock(1).getItem()); + if (b == null) { + Logger.INFO("[ERROR] Tried to get invalid block for "+this.getLocalizedName()+", returning debug block instead."); + } + return b != null ? b : Blocks.lit_furnace; } public final ItemStack getBlock(final int stacksize){ diff --git a/src/Java/gtPlusPlus/core/util/data/StringUtils.java b/src/Java/gtPlusPlus/core/util/data/StringUtils.java index e58b68665a..b64266b5d4 100644 --- a/src/Java/gtPlusPlus/core/util/data/StringUtils.java +++ b/src/Java/gtPlusPlus/core/util/data/StringUtils.java @@ -116,4 +116,19 @@ public class StringUtils { String restLetters = data.substring(1).toLowerCase(); return firstLetter + restLetters; } + + public static <V> String getDataStringFromArray(V[] parameterTypes) { + if (parameterTypes == null || parameterTypes.length == 0) { + return "empty/null"; + } + else { + String aData = ""; + for (V y : parameterTypes) { + if (y != null) { + aData += ", "+y.toString(); + } + } + return aData; + } + } } diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index 372bf81fe9..88175b0a82 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -12,6 +12,7 @@ import java.util.Map; import com.google.common.reflect.ClassPath; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.data.StringUtils; public class ReflectionUtils { @@ -116,6 +117,19 @@ public class ReflectionUtils { } + + /** + * Returns a cached {@link Method} object. Wraps {@link #getMethod(Class, String, Class...)}. + * @param aObject - Object containing the Method. + * @param aMethodName - Method's name in {@link String} form. + * @param aTypes - Class Array of Types for {@link Method}'s constructor. + * @return - Valid, non-final, {@link Method} object, or {@link null}. + */ + public static Method getMethod(Object aObject, String aMethodName, Class[] aTypes) { + return getMethod(aObject.getClass(), aMethodName, aTypes); + } + + /** * Returns a cached {@link Method} object. * @param aClass - Class containing the Method. @@ -127,7 +141,7 @@ public class ReflectionUtils { String aMethodKey = aTypes.toString(); CachedMethod y = mCachedMethods.get(aMethodName + "." + aMethodKey); if (y == null) { - Method u = getMethod_Internal(aClass, aMethodKey, aTypes); + Method u = getMethod_Internal(aClass, aMethodName, aTypes); if (u != null) { Logger.REFLECTION("Caching Method: "+aMethodName + "." + aMethodKey); cacheMethod(u); @@ -457,6 +471,7 @@ public class ReflectionUtils { private static Method getMethod_Internal(Class aClass, String aMethodName, Class... aTypes) { Method m = null; try { + Logger.REFLECTION("Method: Internal Lookup: "+aMethodName); m = aClass.getDeclaredMethod(aMethodName, aTypes); if (m != null) { m.setAccessible(true); @@ -468,6 +483,7 @@ public class ReflectionUtils { } } catch (Throwable t) { + Logger.REFLECTION("Method: Internal Lookup Failed: "+aMethodName); try { m = getMethodRecursively(aClass, aMethodName); } catch (NoSuchMethodException e) { @@ -479,9 +495,10 @@ public class ReflectionUtils { return m; } - private static Method getMethodRecursively(final Class<?> clazz, final String fieldName) throws NoSuchMethodException { + private static Method getMethodRecursively(final Class<?> clazz, final String aMethodName) throws NoSuchMethodException { try { - Method k = clazz.getDeclaredMethod(fieldName); + Logger.REFLECTION("Method: Recursion Lookup: "+aMethodName); + Method k = clazz.getDeclaredMethod(aMethodName); makeMethodAccessible(k); return k; } catch (final NoSuchMethodException e) { @@ -489,7 +506,7 @@ public class ReflectionUtils { if (superClass == null || superClass == Object.class) { throw e; } - return getMethod_Internal(superClass, fieldName); + return getMethod_Internal(superClass, aMethodName); } } @@ -502,7 +519,7 @@ public class ReflectionUtils { Logger.INFO("Dumping all Methods."); for (Method method : methods) { - System.out.println(method.getName()); + System.out.println(method.getName()+" | "+StringUtils.getDataStringFromArray(method.getParameterTypes())); } Logger.INFO("Dumping all Fields."); for (Field f : fields) { @@ -510,7 +527,7 @@ public class ReflectionUtils { } Logger.INFO("Dumping all Constructors."); for (Constructor c : consts) { - System.out.println(c.getName()+" | "+c.getParameterCount()+" | "+c.getParameterTypes().toString()); + System.out.println(c.getName()+" | "+c.getParameterCount()+" | "+StringUtils.getDataStringFromArray(c.getParameterTypes())); } } |