Skip to content
This repository has been archived by the owner on May 26, 2024. It is now read-only.

Commit

Permalink
Unused stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
GTNH-Colen committed May 19, 2024
1 parent 8745955 commit 15fd005
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 285 deletions.
212 changes: 4 additions & 208 deletions src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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);
}
}
Expand All @@ -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;
Expand Down Expand Up @@ -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
*/
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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) {
Expand Down
14 changes: 0 additions & 14 deletions src/main/java/gtPlusPlus/everglades/GTplusplus_Everglades.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/gtPlusPlus/everglades/world/WorldProviderMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {}
}
Loading

0 comments on commit 15fd005

Please sign in to comment.