diff --git a/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index 93149620f7..2d067e4d5e 100644 --- a/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -3,17 +3,10 @@ import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.Field; -import java.lang.reflect.GenericDeclaration; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.lang.reflect.TypeVariable; -import java.util.HashMap; import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; import java.util.Map; import org.apache.commons.lang3.ArrayUtils; @@ -222,13 +215,6 @@ public static Method getMethod(Class<?> aClass, String aMethodName, Class<?>... } } - public static boolean isStaticMethod(Method aMethod) { - if (aMethod != null && Modifier.isStatic(aMethod.getModifiers())) { - return true; - } - return false; - } - /** * Returns a cached {@link Field} object. * @@ -356,10 +342,10 @@ public static boolean setField(final Object object, final String fieldName, fina return true; } } catch (final NoSuchFieldException e) { - Logger.REFLECTION("setField(" + object.toString() + ", " + fieldName + ") failed."); + Logger.REFLECTION("setField(" + object + ", " + fieldName + ") failed."); clazz = clazz.getSuperclass(); } catch (final Exception e) { - Logger.REFLECTION("setField(" + object.toString() + ", " + fieldName + ") failed."); + Logger.REFLECTION("setField(" + object + ", " + fieldName + ") failed."); throw new IllegalStateException(e); } } @@ -382,10 +368,10 @@ public static boolean setField(final Object object, final Field field, final Obj return true; } } catch (final NoSuchFieldException e) { - Logger.REFLECTION("setField(" + object.toString() + ", " + field.getName() + ") failed."); + Logger.REFLECTION("setField(" + object + ", " + field.getName() + ") failed."); clazz = clazz.getSuperclass(); } catch (final Exception e) { - Logger.REFLECTION("setField(" + object.toString() + ", " + field.getName() + ") failed."); + Logger.REFLECTION("setField(" + object + ", " + field.getName() + ") failed."); throw new IllegalStateException(e); } } @@ -409,81 +395,6 @@ public static void setByte(Object clazz, String fieldName, byte newValue) { cacheAccessor(nameField).setValue(null, newValue); } - public static boolean invoke(Object objectInstance, String methodName, Class[] parameters, Object[] values) { - if (objectInstance == null || methodName == null || parameters == null || values == null) { - return false; - } - Class<?> mLocalClass = (objectInstance instanceof Class ? (Class<?>) objectInstance - : objectInstance.getClass()); - Logger.REFLECTION( - "Trying to invoke " + methodName + " on an instance of " + mLocalClass.getCanonicalName() + "."); - 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 + "."); - return true; - } else { - Logger.REFLECTION("Invocation failed for " + methodName + "."); - } - } - } 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; - } - - public static boolean invokeVoid(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."); - mInvokingMethod.invoke(objectInstance, values); - Logger.REFLECTION("Successfully invoked " + methodName + "."); - return true; - } - } 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; - } - public static boolean invokeVoid(Object objectInstance, String methodName, Class[] parameters, Object[] values) { if (objectInstance == null || methodName == null || parameters == null || values == null) { return false; @@ -512,117 +423,11 @@ public static boolean invokeVoid(Object objectInstance, String methodName, Class return false; } - public static Object invokeNonBool(Object objectInstance, Method method, Object[] values) { - if ((!ReflectionUtils.isStaticMethod(method) && objectInstance == null) || method == null || values == null) { - 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 { - return method.invoke(objectInstance, values); - } 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 null; - } - - public static Object invokeNonBool(Object objectInstance, String methodName, Class[] parameters, Object[] values) { - if (objectInstance == null || methodName == null || parameters == null || values == null) { - return false; - } - Class<?> mLocalClass = (objectInstance instanceof Class ? (Class<?>) objectInstance - : objectInstance.getClass()); - Logger.REFLECTION( - "Trying to invoke " + methodName + " on an instance of " + mLocalClass.getCanonicalName() + "."); - try { - Method mInvokingMethod = mLocalClass.getDeclaredMethod(methodName, parameters); - if (mInvokingMethod != null) { - Logger.REFLECTION(methodName + " was not null."); - return mInvokingMethod.invoke(objectInstance, values); - } 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()); - } - - Logger.REFLECTION("Invoke failed or did something wrong."); - return null; - } - - /* - * Internal Magic that probably should not get exposed. - */ /* * Below Code block is used for determining generic types associated with type<E> */ - private static void extractTypeArguments(Map<Type, Type> typeMap, Class<?> clazz) { - Type genericSuperclass = clazz.getGenericSuperclass(); - if (!(genericSuperclass instanceof ParameterizedType parameterizedType)) { - return; - } - - Type[] typeParameter = ((Class<?>) parameterizedType.getRawType()).getTypeParameters(); - Type[] actualTypeArgument = parameterizedType.getActualTypeArguments(); - for (int i = 0; i < typeParameter.length; i++) { - if (typeMap.containsKey(actualTypeArgument[i])) { - actualTypeArgument[i] = typeMap.get(actualTypeArgument[i]); - } - typeMap.put(typeParameter[i], actualTypeArgument[i]); - } - } - - private static Class<?> browseNestedTypes(Object instance, TypeVariable<?> actualType) { - Class<?> instanceClass = instance.getClass(); - List<Class<?>> nestedOuterTypes = new LinkedList<>(); - for (Class<?> enclosingClass = instanceClass.getEnclosingClass(); enclosingClass - != null; enclosingClass = enclosingClass.getEnclosingClass()) { - try { - Field this$0 = instanceClass.getDeclaredField("this$0"); - Object outerInstance = this$0.get(instance); - Class<?> outerClass = outerInstance.getClass(); - nestedOuterTypes.add(outerClass); - Map<Type, Type> outerTypeMap = new HashMap<>(); - extractTypeArguments(outerTypeMap, outerClass); - for (Map.Entry<Type, Type> entry : outerTypeMap.entrySet()) { - if (!(entry.getKey() instanceof TypeVariable<?>foundType)) { - continue; - } - if (foundType.getName().equals(actualType.getName()) - && isInnerClass(foundType.getGenericDeclaration(), actualType.getGenericDeclaration())) { - if (entry.getValue() instanceof Class) { - return (Class<?>) entry.getValue(); - } - actualType = (TypeVariable<?>) entry.getValue(); - } - } - } catch (NoSuchFieldException | IllegalAccessException e) { - - } - } - return null; - } - - private static boolean isInnerClass(GenericDeclaration outerDeclaration, GenericDeclaration innerDeclaration) { - if (!(outerDeclaration instanceof Class<?>outerClass) || !(innerDeclaration instanceof Class<?>innerClass)) { - return false; - } - while ((innerClass = innerClass.getEnclosingClass()) != null) { - if (innerClass == outerClass) { - return true; - } - } - return false; - } - /* * End of Generics Block */ @@ -632,20 +437,15 @@ private static Field getField_Internal(final Class<?> clazz, final String fieldN Logger.REFLECTION("Field: Internal Lookup: " + fieldName); Field k = clazz.getDeclaredField(fieldName); makeFieldAccessible(k); - // Logger.REFLECTION("Got Field from Class. "+fieldName+" did exist within "+clazz.getCanonicalName()+"."); return k; } catch (final NoSuchFieldException e) { Logger.REFLECTION("Field: Internal Lookup Failed: " + fieldName); final Class<?> superClass = clazz.getSuperclass(); if (superClass == null) { Logger.REFLECTION("Unable to find field '" + fieldName + "'"); - // Logger.REFLECTION("Failed to get Field from Class. "+fieldName+" does not existing within - // "+clazz.getCanonicalName()+"."); throw e; } Logger.REFLECTION("Method: Recursion Lookup: " + fieldName + " - Checking in " + superClass.getName()); - // Logger.REFLECTION("Failed to get Field from Class. "+fieldName+" does not existing within - // "+clazz.getCanonicalName()+". Trying super class."); return getField_Internal(superClass, fieldName); } } @@ -873,10 +673,6 @@ private static void setFieldValue_Internal(Object owner, Field field, Object val cacheAccessor(field).setValue(owner, value); } - public static boolean doesFieldExist(String clazz, String string) { - return doesFieldExist(ReflectionUtils.getClass(clazz), string); - } - public static boolean doesFieldExist(Class<?> clazz, String string) { if (clazz != null) { if (ReflectionUtils.getField(clazz, string) != null) { diff --git a/src/main/java/gtPlusPlus/everglades/GTplusplus_Everglades.java b/src/main/java/gtPlusPlus/everglades/GTplusplus_Everglades.java index a5ffe1c7fc..858d3aba21 100644 --- a/src/main/java/gtPlusPlus/everglades/GTplusplus_Everglades.java +++ b/src/main/java/gtPlusPlus/everglades/GTplusplus_Everglades.java @@ -49,7 +49,6 @@ public class GTplusplus_Everglades implements ActionListener { // Dark World Handler protected static volatile Biome_Everglades Everglades_Biome; protected static volatile Dimension_Everglades Everglades_Dimension; - public static int globalEvergladesPortalSpawnTimer = 0; // Pre-Init @Mod.EventHandler @@ -174,19 +173,6 @@ public void serverLoad(FMLServerStartingEvent event) { getEvergladesBiome().serverLoad(event); } - /* - * @Override public int getBurnTime(ItemStack fuel) { if (DarkWorld_Biome.addFuel(fuel) != 0) return - * DarkWorld_Biome.addFuel(fuel); if (DarkWorld_Dimension.addFuel(fuel) != 0) return - * DarkWorld_Dimension.addFuel(fuel); return 0; } - */ - - /* - * @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, - * IChunkProvider chunkProvider) { chunkX = chunkX * 16; chunkZ = chunkZ * 16; if (world.provider.dimensionId == - * Dimension_DarkWorld.DIMID) { DarkWorld_Biome.generateSurface(world, random, chunkX, chunkZ); } //What does this - * even do? if (world.provider.dimensionId == -1) { DarkWorld_Biome.generateNether(world, random, chunkX, chunkZ); } - * if (world.provider.dimensionId == 0) { DarkWorld_Biome.generateSurface(world, random, chunkX, chunkZ); } } - */ @EventHandler public static void postInit(final FMLPostInitializationEvent e) { diff --git a/src/main/java/gtPlusPlus/everglades/world/WorldChunkManagerCustom.java b/src/main/java/gtPlusPlus/everglades/world/WorldChunkManagerCustom.java index 6a4ef65f17..5e02448cec 100644 --- a/src/main/java/gtPlusPlus/everglades/world/WorldChunkManagerCustom.java +++ b/src/main/java/gtPlusPlus/everglades/world/WorldChunkManagerCustom.java @@ -47,10 +47,6 @@ public WorldChunkManagerCustom(long seed, WorldType worldType) { this.biomeIndexLayer = agenlayer[1]; } - public WorldChunkManagerCustom(World world) { - this(world.getSeed(), world.getWorldInfo().getTerrainType()); - } - /** * Gets the list of valid biomes for the player to spawn in. */ diff --git a/src/main/java/gtPlusPlus/everglades/world/WorldProviderMod.java b/src/main/java/gtPlusPlus/everglades/world/WorldProviderMod.java index 9b25025263..c8a69a3b0e 100644 --- a/src/main/java/gtPlusPlus/everglades/world/WorldProviderMod.java +++ b/src/main/java/gtPlusPlus/everglades/world/WorldProviderMod.java @@ -31,21 +31,11 @@ public IChunkProvider createChunkGenerator() { return new ChunkProviderModded(this.worldObj, this.worldObj.getSeed() - 1278); } - @Override - public boolean isSurfaceWorld() { - return true; - } - @Override public boolean canCoordinateBeSpawn(int par1, int par2) { return false; } - @Override - public boolean canRespawnHere() { - return true; - } - @Override public float getSunBrightness(float par1) { return (par1 * 2F); diff --git a/src/main/java/gtPlusPlus/nei/handlers/NeiTextureHandler.java b/src/main/java/gtPlusPlus/nei/handlers/NeiTextureHandler.java index 1cec4d33e1..2c299e5071 100644 --- a/src/main/java/gtPlusPlus/nei/handlers/NeiTextureHandler.java +++ b/src/main/java/gtPlusPlus/nei/handlers/NeiTextureHandler.java @@ -38,7 +38,6 @@ */ public final class NeiTextureHandler { - public static final NeiTextureHandler RECIPE = new NeiTextureHandler(16, 132, 16, 16); public static final NeiTextureHandler RECIPE_BUTTON = new NeiTextureHandler(128, 116, 24, 24); public final double minU; diff --git a/src/main/java/gtPlusPlus/xmod/thermalfoundation/block/TF_Block_Fluid_Cryotheum.java b/src/main/java/gtPlusPlus/xmod/thermalfoundation/block/TF_Block_Fluid_Cryotheum.java index d567d7bbc2..3b28aa67a8 100644 --- a/src/main/java/gtPlusPlus/xmod/thermalfoundation/block/TF_Block_Fluid_Cryotheum.java +++ b/src/main/java/gtPlusPlus/xmod/thermalfoundation/block/TF_Block_Fluid_Cryotheum.java @@ -30,8 +30,6 @@ public class TF_Block_Fluid_Cryotheum extends BlockFluidInteractive { - Random random = new Random(); - public static final int LEVELS = 5; public static final Material materialFluidCryotheum = new MaterialLiquid(MapColor.iceColor); private static boolean enableSourceFall = true; private static boolean effect = true; @@ -62,13 +60,8 @@ public boolean preInit() { this.addInteraction(Blocks.leaves, Blocks.air); this.addInteraction(Blocks.tallgrass, Blocks.air); this.addInteraction(Blocks.fire, Blocks.air); - // addInteraction(TFBlocks.blockFluidGlowstone, 0, Blocks.glowstone); - final String str1 = "Fluid.Cryotheum"; - String str2 = "Enable this for Fluid Cryotheum to be worse than lava, except cold."; effect = true; - - str2 = "Enable this for Fluid Cryotheum Source blocks to gradually fall downwards."; enableSourceFall = true; return true; @@ -182,6 +175,4 @@ protected void interactWithBlock(final World paramWorld, final int paramInt1, fi } } - protected void triggerInteractionEffects(final World paramWorld, final int paramInt1, final int paramInt2, - final int paramInt3) {} } diff --git a/src/main/java/gtPlusPlus/xmod/thermalfoundation/block/TF_Block_Fluid_Ender.java b/src/main/java/gtPlusPlus/xmod/thermalfoundation/block/TF_Block_Fluid_Ender.java index 5bbf0ea3ab..f43142a06e 100644 --- a/src/main/java/gtPlusPlus/xmod/thermalfoundation/block/TF_Block_Fluid_Ender.java +++ b/src/main/java/gtPlusPlus/xmod/thermalfoundation/block/TF_Block_Fluid_Ender.java @@ -16,7 +16,6 @@ public class TF_Block_Fluid_Ender extends BlockFluidCoFHBase { - public static final int LEVELS = 4; public static final Material materialFluidEnder = new MaterialLiquid(MapColor.greenColor); private static boolean effect = true; @@ -34,9 +33,6 @@ public TF_Block_Fluid_Ender() { public boolean preInit() { GameRegistry.registerBlock(this, "FluidEnder"); - String str1 = "Fluid.Ender"; - String str2 = "Enable this for Fluid Ender to randomly teleport entities on contact."; - return true; } diff --git a/src/main/java/gtPlusPlus/xmod/thermalfoundation/block/TF_Block_Fluid_Pyrotheum.java b/src/main/java/gtPlusPlus/xmod/thermalfoundation/block/TF_Block_Fluid_Pyrotheum.java index af6b74c216..b9a27f77f6 100644 --- a/src/main/java/gtPlusPlus/xmod/thermalfoundation/block/TF_Block_Fluid_Pyrotheum.java +++ b/src/main/java/gtPlusPlus/xmod/thermalfoundation/block/TF_Block_Fluid_Pyrotheum.java @@ -25,8 +25,6 @@ public class TF_Block_Fluid_Pyrotheum extends BlockFluidInteractive { Random random = new Random(); - public static final int LEVELS = 5; - public static final Material materialFluidPyrotheum = new MaterialLiquid(MapColor.tntColor); private static boolean effect = true; private static boolean enableSourceFall = true; diff --git a/src/main/java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java b/src/main/java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java index fb89680e6c..cf9b6c0767 100644 --- a/src/main/java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java +++ b/src/main/java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java @@ -261,39 +261,6 @@ public static List<?> getDryingRecipes() { return aData; } - public static Object generateToolMaterial(String name, String localizationString, int level, int durability, - int speed, int damage, float handle, int reinforced, float stonebound, String style, int primaryColor) { - try { - Constructor<?> constructor = mClass_ToolMaterial.getConstructor( - String.class, - String.class, - int.class, - int.class, - int.class, - int.class, - float.class, - int.class, - float.class, - String.class, - int.class); - return constructor.newInstance( - name, - localizationString, - level, - durability, - speed, - damage, - handle, - reinforced, - stonebound, - style, - primaryColor); - } catch (Throwable t) { - t.printStackTrace(); - return null; - } - } - public static List<?> getTableCastingRecipes() { Object aCastingTableHandlerInstance = getCastingInstance(0); List<?> aTemp;