diff --git a/src/main/java/net/PeytonPlayz585/shadow/Config.java b/src/main/java/net/PeytonPlayz585/shadow/Config.java index c221b67..73c6027 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/Config.java +++ b/src/main/java/net/PeytonPlayz585/shadow/Config.java @@ -3,14 +3,12 @@ package net.PeytonPlayz585.shadow; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Array; -import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Set; import java.util.StringTokenizer; -import net.PeytonPlayz585.shadow.reflect.Reflector; import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime; import net.lax1dude.eaglercraft.v1_8.log4j.LogManager; import net.lax1dude.eaglercraft.v1_8.log4j.Logger; @@ -428,7 +426,8 @@ public class Config { public static DefaultResourcePack getDefaultResourcePack() { if (defaultResourcePackLazy == null) { Minecraft minecraft = Minecraft.getMinecraft(); - defaultResourcePackLazy = (DefaultResourcePack)Reflector.getFieldValue(minecraft, Reflector.Minecraft_defaultResourcePack); + //defaultResourcePackLazy = (DefaultResourcePack)Reflector.getFieldValue(minecraft, Reflector.Minecraft_defaultResourcePack); + defaultResourcePackLazy = Minecraft.getMinecraft().mcDefaultResourcePack; if (defaultResourcePackLazy == null) { ResourcePackRepository resourcepackrepository = minecraft.getResourcePackRepository(); diff --git a/src/main/java/net/PeytonPlayz585/shadow/CustomColors.java b/src/main/java/net/PeytonPlayz585/shadow/CustomColors.java index 0c32c64..ac9825c 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/CustomColors.java +++ b/src/main/java/net/PeytonPlayz585/shadow/CustomColors.java @@ -1,6 +1,5 @@ package net.PeytonPlayz585.shadow; -import java.awt.image.BufferedImage; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -12,10 +11,10 @@ import java.util.Map; import java.util.Properties; import java.util.Random; import java.util.Set; -import javax.imageio.ImageIO; import net.PeytonPlayz585.shadow.apache.ImmutablePair; import net.PeytonPlayz585.shadow.apache.Pair; +import net.lax1dude.eaglercraft.v1_8.opengl.ImageData; import net.minecraft.block.Block; import net.minecraft.block.BlockRedstoneWire; import net.minecraft.block.BlockStem; @@ -26,6 +25,7 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.texture.TextureUtil; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; import net.minecraft.item.EnumDyeColor; @@ -360,9 +360,9 @@ public class CustomColors { if (inputstream == null) { return defHeight; } else { - BufferedImage bufferedimage = ImageIO.read(inputstream); + ImageData bufferedimage = TextureUtil.readBufferedImage(inputstream); inputstream.close(); - return bufferedimage == null ? defHeight : bufferedimage.getHeight(); + return bufferedimage == null ? defHeight : bufferedimage.height; } } catch (IOException var4) { return defHeight; diff --git a/src/main/java/net/PeytonPlayz585/shadow/json/JSONUtils.java b/src/main/java/net/PeytonPlayz585/shadow/json/JSONUtils.java new file mode 100644 index 0000000..fc4c23b --- /dev/null +++ b/src/main/java/net/PeytonPlayz585/shadow/json/JSONUtils.java @@ -0,0 +1,47 @@ +package net.PeytonPlayz585.shadow.json; + +import java.util.ArrayList; +import java.util.List; + +import org.json.JSONArray; +import org.json.JSONObject; + +import net.minecraft.client.resources.data.AnimationFrame; +import net.minecraft.client.resources.data.AnimationMetadataSection; +import net.minecraft.client.resources.data.IMetadataSection; + +public class JSONUtils { + + public static T fixJson(String string) { + JSONObject jsonObject = new JSONObject(string); + JSONObject animationObject = jsonObject.getJSONObject("animation"); + int frametime = animationObject.getInt("frametime"); + JSONArray frames = animationObject.getJSONArray("frames"); + boolean interpolate = false; + + if(animationObject.has("interpolate")) { + interpolate = animationObject.getBoolean("interpolate"); + } + + List list = new ArrayList(); + + for(int i = 0; i < frames.length(); i++) { + int time; + if(frames.get(i) instanceof JSONObject) { + JSONObject obj = frames.getJSONObject(i); + if(obj.has("time")) { + time = obj.getInt("time"); + } else { + time = -1; + } + } else { + time = -1; + } + list.add(new AnimationFrame(i, time)); + } + + AnimationMetadataSection data = new AnimationMetadataSection(list, 16, 16, frametime, interpolate); + IMetadataSection imetadatasection = (IMetadataSection) data; + return (T) imetadatasection; + } +} diff --git a/src/main/java/net/PeytonPlayz585/shadow/reflect/FieldLocatorActionKeyF3.java b/src/main/java/net/PeytonPlayz585/shadow/reflect/FieldLocatorActionKeyF3.java index b36675e..0f736ee 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/reflect/FieldLocatorActionKeyF3.java +++ b/src/main/java/net/PeytonPlayz585/shadow/reflect/FieldLocatorActionKeyF3.java @@ -1,47 +1,47 @@ -package net.PeytonPlayz585.shadow.reflect; - -import java.lang.reflect.Field; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import net.PeytonPlayz585.shadow.Config; -import net.minecraft.client.Minecraft; - -public class FieldLocatorActionKeyF3 implements IFieldLocator { - public Field getField() { - Class oclass = Minecraft.class; - Field field = this.getFieldRenderChunksMany(); - - if (field == null) { - Config.log("(Reflector) Field not present: " + oclass.getName() + ".actionKeyF3 (field renderChunksMany not found)"); - return null; - } else { - Field field1 = ReflectorRaw.getFieldAfter(Minecraft.class, field, Boolean.TYPE, 0); - - if (field1 == null) { - Config.log("(Reflector) Field not present: " + oclass.getName() + ".actionKeyF3"); - return null; - } else { - return field1; - } - } - } - - private Field getFieldRenderChunksMany() { - Minecraft minecraft = Minecraft.getMinecraft(); - boolean flag = minecraft.renderChunksMany; - Field[] afield = Minecraft.class.getDeclaredFields(); - minecraft.renderChunksMany = true; - Field[] afield1 = ReflectorRaw.getFields(minecraft, afield, Boolean.TYPE, Boolean.TRUE); - minecraft.renderChunksMany = false; - Field[] afield2 = ReflectorRaw.getFields(minecraft, afield, Boolean.TYPE, Boolean.FALSE); - minecraft.renderChunksMany = flag; - Set < Field > set = new HashSet(Arrays.asList(afield1)); - Set < Field > set1 = new HashSet(Arrays.asList(afield2)); - Set < Field > set2 = new HashSet(set); - set2.retainAll(set1); - Field[] afield3 = (Field[])((Field[]) set2.toArray(new Field[set2.size()])); - return afield3.length != 1 ? null : afield3[0]; - } -} \ No newline at end of file +//package net.PeytonPlayz585.shadow.reflect; +// +//import java.lang.reflect.Field; +//import java.util.Arrays; +//import java.util.HashSet; +//import java.util.Set; +// +//import net.PeytonPlayz585.shadow.Config; +//import net.minecraft.client.Minecraft; +// +//public class FieldLocatorActionKeyF3 implements IFieldLocator { +// public Field getField() { +// Class oclass = Minecraft.class; +// Field field = this.getFieldRenderChunksMany(); +// +// if (field == null) { +// Config.log("(Reflector) Field not present: " + oclass.getName() + ".actionKeyF3 (field renderChunksMany not found)"); +// return null; +// } else { +// Field field1 = ReflectorRaw.getFieldAfter(Minecraft.class, field, Boolean.TYPE, 0); +// +// if (field1 == null) { +// Config.log("(Reflector) Field not present: " + oclass.getName() + ".actionKeyF3"); +// return null; +// } else { +// return field1; +// } +// } +// } +// +// private Field getFieldRenderChunksMany() { +// Minecraft minecraft = Minecraft.getMinecraft(); +// boolean flag = minecraft.renderChunksMany; +// Field[] afield = Minecraft.class.getDeclaredFields(); +// minecraft.renderChunksMany = true; +// Field[] afield1 = ReflectorRaw.getFields(minecraft, afield, Boolean.TYPE, Boolean.TRUE); +// minecraft.renderChunksMany = false; +// Field[] afield2 = ReflectorRaw.getFields(minecraft, afield, Boolean.TYPE, Boolean.FALSE); +// minecraft.renderChunksMany = flag; +// Set < Field > set = new HashSet(Arrays.asList(afield1)); +// Set < Field > set1 = new HashSet(Arrays.asList(afield2)); +// Set < Field > set2 = new HashSet(set); +// set2.retainAll(set1); +// Field[] afield3 = (Field[])((Field[]) set2.toArray(new Field[set2.size()])); +// return afield3.length != 1 ? null : afield3[0]; +// } +//} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/reflect/FieldLocatorFixed.java b/src/main/java/net/PeytonPlayz585/shadow/reflect/FieldLocatorFixed.java index 302aee0..0294338 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/reflect/FieldLocatorFixed.java +++ b/src/main/java/net/PeytonPlayz585/shadow/reflect/FieldLocatorFixed.java @@ -1,15 +1,15 @@ -package net.PeytonPlayz585.shadow.reflect; - -import java.lang.reflect.Field; - -public class FieldLocatorFixed implements IFieldLocator { - private Field field; - - public FieldLocatorFixed(Field field) { - this.field = field; - } - - public Field getField() { - return this.field; - } -} \ No newline at end of file +//package net.PeytonPlayz585.shadow.reflect; +// +//import java.lang.reflect.Field; +// +//public class FieldLocatorFixed implements IFieldLocator { +// private Field field; +// +// public FieldLocatorFixed(Field field) { +// this.field = field; +// } +// +// public Field getField() { +// return this.field; +// } +//} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/reflect/FieldLocatorName.java b/src/main/java/net/PeytonPlayz585/shadow/reflect/FieldLocatorName.java index 30212f1..5d5c8bd 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/reflect/FieldLocatorName.java +++ b/src/main/java/net/PeytonPlayz585/shadow/reflect/FieldLocatorName.java @@ -1,56 +1,56 @@ -package net.PeytonPlayz585.shadow.reflect; - -import java.lang.reflect.Field; - -import net.PeytonPlayz585.shadow.Config; - -public class FieldLocatorName implements IFieldLocator { - private ReflectorClass reflectorClass = null; - private String targetFieldName = null; - - public FieldLocatorName(ReflectorClass reflectorClass, String targetFieldName) { - this.reflectorClass = reflectorClass; - this.targetFieldName = targetFieldName; - } - - public Field getField() { - Class oclass = this.reflectorClass.getTargetClass(); - - if (oclass == null) { - return null; - } else { - try { - Field field = this.getDeclaredField(oclass, this.targetFieldName); - field.setAccessible(true); - return field; - } catch (NoSuchFieldException var3) { - Config.log("(Reflector) Field not present: " + oclass.getName() + "." + this.targetFieldName); - return null; - } catch (SecurityException securityexception) { - securityexception.printStackTrace(); - return null; - } catch (Throwable throwable) { - throwable.printStackTrace(); - return null; - } - } - } - - private Field getDeclaredField(Class cls, String name) throws NoSuchFieldException { - Field[] afield = cls.getDeclaredFields(); - - for (int i = 0; i < afield.length; ++i) { - Field field = afield[i]; - - if (field.getName().equals(name)) { - return field; - } - } - - if (cls == Object.class) { - throw new NoSuchFieldException(name); - } else { - return this.getDeclaredField(cls.getSuperclass(), name); - } - } -} \ No newline at end of file +//package net.PeytonPlayz585.shadow.reflect; +// +//import java.lang.reflect.Field; +// +//import net.PeytonPlayz585.shadow.Config; +// +//public class FieldLocatorName implements IFieldLocator { +// private ReflectorClass reflectorClass = null; +// private String targetFieldName = null; +// +// public FieldLocatorName(ReflectorClass reflectorClass, String targetFieldName) { +// this.reflectorClass = reflectorClass; +// this.targetFieldName = targetFieldName; +// } +// +// public Field getField() { +// Class oclass = this.reflectorClass.getTargetClass(); +// +// if (oclass == null) { +// return null; +// } else { +// try { +// Field field = this.getDeclaredField(oclass, this.targetFieldName); +// field.setAccessible(true); +// return field; +// } catch (NoSuchFieldException var3) { +// Config.log("(Reflector) Field not present: " + oclass.getName() + "." + this.targetFieldName); +// return null; +// } catch (SecurityException securityexception) { +// securityexception.printStackTrace(); +// return null; +// } catch (Throwable throwable) { +// throwable.printStackTrace(); +// return null; +// } +// } +// } +// +// private Field getDeclaredField(Class cls, String name) throws NoSuchFieldException { +// Field[] afield = cls.getDeclaredFields(); +// +// for (int i = 0; i < afield.length; ++i) { +// Field field = afield[i]; +// +// if (field.getName().equals(name)) { +// return field; +// } +// } +// +// if (cls == Object.class) { +// throw new NoSuchFieldException(name); +// } else { +// return this.getDeclaredField(cls.getSuperclass(), name); +// } +// } +//} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/reflect/FieldLocatorType.java b/src/main/java/net/PeytonPlayz585/shadow/reflect/FieldLocatorType.java index eedad9d..606ea66 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/reflect/FieldLocatorType.java +++ b/src/main/java/net/PeytonPlayz585/shadow/reflect/FieldLocatorType.java @@ -1,58 +1,58 @@ -package net.PeytonPlayz585.shadow.reflect; - -import java.lang.reflect.Field; - -import net.PeytonPlayz585.shadow.Config; - -public class FieldLocatorType implements IFieldLocator { - private ReflectorClass reflectorClass; - private Class targetFieldType; - private int targetFieldIndex; - - public FieldLocatorType(ReflectorClass reflectorClass, Class targetFieldType) { - this(reflectorClass, targetFieldType, 0); - } - - public FieldLocatorType(ReflectorClass reflectorClass, Class targetFieldType, int targetFieldIndex) { - this.reflectorClass = null; - this.targetFieldType = null; - this.reflectorClass = reflectorClass; - this.targetFieldType = targetFieldType; - this.targetFieldIndex = targetFieldIndex; - } - - public Field getField() { - Class oclass = this.reflectorClass.getTargetClass(); - - if (oclass == null) { - return null; - } else { - try { - Field[] afield = oclass.getDeclaredFields(); - int i = 0; - - for (int j = 0; j < afield.length; ++j) { - Field field = afield[j]; - - if (field.getType() == this.targetFieldType) { - if (i == this.targetFieldIndex) { - field.setAccessible(true); - return field; - } - - ++i; - } - } - - Config.log("(Reflector) Field not present: " + oclass.getName() + ".(type: " + this.targetFieldType + ", index: " + this.targetFieldIndex + ")"); - return null; - } catch (SecurityException securityexception) { - securityexception.printStackTrace(); - return null; - } catch (Throwable throwable) { - throwable.printStackTrace(); - return null; - } - } - } -} \ No newline at end of file +//package net.PeytonPlayz585.shadow.reflect; +// +//import java.lang.reflect.Field; +// +//import net.PeytonPlayz585.shadow.Config; +// +//public class FieldLocatorType implements IFieldLocator { +// private ReflectorClass reflectorClass; +// private Class targetFieldType; +// private int targetFieldIndex; +// +// public FieldLocatorType(ReflectorClass reflectorClass, Class targetFieldType) { +// this(reflectorClass, targetFieldType, 0); +// } +// +// public FieldLocatorType(ReflectorClass reflectorClass, Class targetFieldType, int targetFieldIndex) { +// this.reflectorClass = null; +// this.targetFieldType = null; +// this.reflectorClass = reflectorClass; +// this.targetFieldType = targetFieldType; +// this.targetFieldIndex = targetFieldIndex; +// } +// +// public Field getField() { +// Class oclass = this.reflectorClass.getTargetClass(); +// +// if (oclass == null) { +// return null; +// } else { +// try { +// Field[] afield = oclass.getDeclaredFields(); +// int i = 0; +// +// for (int j = 0; j < afield.length; ++j) { +// Field field = afield[j]; +// +// if (field.getType() == this.targetFieldType) { +// if (i == this.targetFieldIndex) { +// field.setAccessible(true); +// return field; +// } +// +// ++i; +// } +// } +// +// Config.log("(Reflector) Field not present: " + oclass.getName() + ".(type: " + this.targetFieldType + ", index: " + this.targetFieldIndex + ")"); +// return null; +// } catch (SecurityException securityexception) { +// securityexception.printStackTrace(); +// return null; +// } catch (Throwable throwable) { +// throwable.printStackTrace(); +// return null; +// } +// } +// } +//} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/reflect/FieldLocatorTypes.java b/src/main/java/net/PeytonPlayz585/shadow/reflect/FieldLocatorTypes.java index c2acccb..dd5a25c 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/reflect/FieldLocatorTypes.java +++ b/src/main/java/net/PeytonPlayz585/shadow/reflect/FieldLocatorTypes.java @@ -1,46 +1,46 @@ -package net.PeytonPlayz585.shadow.reflect; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import net.PeytonPlayz585.shadow.Config; - -public class FieldLocatorTypes implements IFieldLocator { - private Field field = null; - - public FieldLocatorTypes(Class cls, Class[] preTypes, Class type, Class[] postTypes, String errorName) { - Field[] afield = cls.getDeclaredFields(); - List < Class > list = new ArrayList(); - - for (int i = 0; i < afield.length; ++i) { - Field field = afield[i]; - list.add(field.getType()); - } - - List < Class > list1 = new ArrayList(); - list1.addAll(Arrays. < Class > asList(preTypes)); - list1.add(type); - list1.addAll(Arrays. < Class > asList(postTypes)); - int l = Collections.indexOfSubList(list, list1); - - if (l < 0) { - Config.log("(Reflector) Field not found: " + errorName); - } else { - int j = Collections.indexOfSubList(list.subList(l + 1, list.size()), list1); - - if (j >= 0) { - Config.log("(Reflector) More than one match found for field: " + errorName); - } else { - int k = l + preTypes.length; - this.field = afield[k]; - } - } - } - - public Field getField() { - return this.field; - } -} \ No newline at end of file +//package net.PeytonPlayz585.shadow.reflect; +// +//import java.lang.reflect.Field; +//import java.util.ArrayList; +//import java.util.Arrays; +//import java.util.Collections; +//import java.util.List; +// +//import net.PeytonPlayz585.shadow.Config; +// +//public class FieldLocatorTypes implements IFieldLocator { +// private Field field = null; +// +// public FieldLocatorTypes(Class cls, Class[] preTypes, Class type, Class[] postTypes, String errorName) { +// Field[] afield = cls.getDeclaredFields(); +// List < Class > list = new ArrayList(); +// +// for (int i = 0; i < afield.length; ++i) { +// Field field = afield[i]; +// list.add(field.getType()); +// } +// +// List < Class > list1 = new ArrayList(); +// list1.addAll(Arrays. < Class > asList(preTypes)); +// list1.add(type); +// list1.addAll(Arrays. < Class > asList(postTypes)); +// int l = Collections.indexOfSubList(list, list1); +// +// if (l < 0) { +// Config.log("(Reflector) Field not found: " + errorName); +// } else { +// int j = Collections.indexOfSubList(list.subList(l + 1, list.size()), list1); +// +// if (j >= 0) { +// Config.log("(Reflector) More than one match found for field: " + errorName); +// } else { +// int k = l + preTypes.length; +// this.field = afield[k]; +// } +// } +// } +// +// public Field getField() { +// return this.field; +// } +//} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/reflect/IFieldLocator.java b/src/main/java/net/PeytonPlayz585/shadow/reflect/IFieldLocator.java index 1f4c9de..b218482 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/reflect/IFieldLocator.java +++ b/src/main/java/net/PeytonPlayz585/shadow/reflect/IFieldLocator.java @@ -1,7 +1,7 @@ -package net.PeytonPlayz585.shadow.reflect; - -import java.lang.reflect.Field; - -public interface IFieldLocator { - Field getField(); -} \ No newline at end of file +//package net.PeytonPlayz585.shadow.reflect; +// +//import java.lang.reflect.Field; +// +//public interface IFieldLocator { +// Field getField(); +//} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/reflect/IResolvable.java b/src/main/java/net/PeytonPlayz585/shadow/reflect/IResolvable.java index abcfe0a..eb2425f 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/reflect/IResolvable.java +++ b/src/main/java/net/PeytonPlayz585/shadow/reflect/IResolvable.java @@ -1,5 +1,5 @@ -package net.PeytonPlayz585.shadow.reflect; - -public interface IResolvable { - void resolve(); -} \ No newline at end of file +//package net.PeytonPlayz585.shadow.reflect; +// +//public interface IResolvable { +// void resolve(); +//} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/reflect/Reflector.java b/src/main/java/net/PeytonPlayz585/shadow/reflect/Reflector.java index 5fe5cbe..dd9b875 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/reflect/Reflector.java +++ b/src/main/java/net/PeytonPlayz585/shadow/reflect/Reflector.java @@ -1,551 +1,551 @@ -package net.PeytonPlayz585.shadow.reflect; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import net.PeytonPlayz585.shadow.ArrayUtils; -import net.PeytonPlayz585.shadow.Config; -import net.lax1dude.eaglercraft.v1_8.log4j.LogManager; -import net.lax1dude.eaglercraft.v1_8.log4j.Logger; -import net.minecraft.client.Minecraft; -import net.minecraft.client.resources.DefaultResourcePack; - -public class Reflector { - private static final Logger LOGGER = LogManager.getLogger(); - public static ReflectorClass Minecraft = new ReflectorClass(Minecraft.class); - public static ReflectorField Minecraft_defaultResourcePack = new ReflectorField(Minecraft, DefaultResourcePack.class); - - public static void callVoid(ReflectorMethod refMethod, Object...params) { - try { - Method method = refMethod.getTargetMethod(); - - if (method == null) { - return; - } - - method.invoke((Object) null, params); - } catch (Throwable throwable) { - handleException(throwable, (Object) null, refMethod, params); - } - } - - public static boolean callBoolean(ReflectorMethod refMethod, Object...params) { - try { - Method method = refMethod.getTargetMethod(); - - if (method == null) { - return false; - } else { - Boolean obool = (Boolean) method.invoke((Object) null, params); - return obool.booleanValue(); - } - } catch (Throwable throwable) { - handleException(throwable, (Object) null, refMethod, params); - return false; - } - } - - public static int callInt(ReflectorMethod refMethod, Object...params) { - try { - Method method = refMethod.getTargetMethod(); - - if (method == null) { - return 0; - } else { - Integer integer = (Integer) method.invoke((Object) null, params); - return integer.intValue(); - } - } catch (Throwable throwable) { - handleException(throwable, (Object) null, refMethod, params); - return 0; - } - } - - public static float callFloat(ReflectorMethod refMethod, Object...params) { - try { - Method method = refMethod.getTargetMethod(); - - if (method == null) { - return 0.0F; - } else { - Float f = (Float) method.invoke((Object) null, params); - return f.floatValue(); - } - } catch (Throwable throwable) { - handleException(throwable, (Object) null, refMethod, params); - return 0.0F; - } - } - - public static double callDouble(ReflectorMethod refMethod, Object...params) { - try { - Method method = refMethod.getTargetMethod(); - - if (method == null) { - return 0.0D; - } else { - Double d0 = (Double) method.invoke((Object) null, params); - return d0.doubleValue(); - } - } catch (Throwable throwable) { - handleException(throwable, (Object) null, refMethod, params); - return 0.0D; - } - } - - public static String callString(ReflectorMethod refMethod, Object...params) { - try { - Method method = refMethod.getTargetMethod(); - - if (method == null) { - return null; - } else { - String s = (String) method.invoke((Object) null, params); - return s; - } - } catch (Throwable throwable) { - handleException(throwable, (Object) null, refMethod, params); - return null; - } - } - - public static Object call(ReflectorMethod refMethod, Object...params) { - try { - Method method = refMethod.getTargetMethod(); - - if (method == null) { - return null; - } else { - Object object = method.invoke((Object) null, params); - return object; - } - } catch (Throwable throwable) { - handleException(throwable, (Object) null, refMethod, params); - return null; - } - } - - public static void callVoid(Object obj, ReflectorMethod refMethod, Object...params) { - try { - if (obj == null) { - return; - } - - Method method = refMethod.getTargetMethod(); - - if (method == null) { - return; - } - - method.invoke(obj, params); - } catch (Throwable throwable) { - handleException(throwable, obj, refMethod, params); - } - } - - public static boolean callBoolean(Object obj, ReflectorMethod refMethod, Object...params) { - try { - Method method = refMethod.getTargetMethod(); - - if (method == null) { - return false; - } else { - Boolean obool = (Boolean) method.invoke(obj, params); - return obool.booleanValue(); - } - } catch (Throwable throwable) { - handleException(throwable, obj, refMethod, params); - return false; - } - } - - public static int callInt(Object obj, ReflectorMethod refMethod, Object...params) { - try { - Method method = refMethod.getTargetMethod(); - - if (method == null) { - return 0; - } else { - Integer integer = (Integer) method.invoke(obj, params); - return integer.intValue(); - } - } catch (Throwable throwable) { - handleException(throwable, obj, refMethod, params); - return 0; - } - } - - public static float callFloat(Object obj, ReflectorMethod refMethod, Object...params) { - try { - Method method = refMethod.getTargetMethod(); - - if (method == null) { - return 0.0F; - } else { - Float f = (Float) method.invoke(obj, params); - return f.floatValue(); - } - } catch (Throwable throwable) { - handleException(throwable, obj, refMethod, params); - return 0.0F; - } - } - - public static double callDouble(Object obj, ReflectorMethod refMethod, Object...params) { - try { - Method method = refMethod.getTargetMethod(); - - if (method == null) { - return 0.0D; - } else { - Double d0 = (Double) method.invoke(obj, params); - return d0.doubleValue(); - } - } catch (Throwable throwable) { - handleException(throwable, obj, refMethod, params); - return 0.0D; - } - } - - public static String callString(Object obj, ReflectorMethod refMethod, Object...params) { - try { - Method method = refMethod.getTargetMethod(); - - if (method == null) { - return null; - } else { - String s = (String) method.invoke(obj, params); - return s; - } - } catch (Throwable throwable) { - handleException(throwable, obj, refMethod, params); - return null; - } - } - - public static Object call(Object obj, ReflectorMethod refMethod, Object...params) { - try { - Method method = refMethod.getTargetMethod(); - - if (method == null) { - return null; - } else { - Object object = method.invoke(obj, params); - return object; - } - } catch (Throwable throwable) { - handleException(throwable, obj, refMethod, params); - return null; - } - } - - public static Object getFieldValue(ReflectorField refField) { - return getFieldValue((Object) null, refField); - } - - public static Object getFieldValue(Object obj, ReflectorField refField) { - try { - Field field = refField.getTargetField(); - - if (field == null) { - return null; - } else { - Object object = field.get(obj); - return object; - } - } catch (Throwable throwable) { - Config.error("", throwable); - return null; - } - } - - public static boolean getFieldValueBoolean(ReflectorField refField, boolean def) { - try { - Field field = refField.getTargetField(); - - if (field == null) { - return def; - } else { - boolean flag = field.getBoolean((Object) null); - return flag; - } - } catch (Throwable throwable) { - Config.error("", throwable); - return def; - } - } - - public static boolean getFieldValueBoolean(Object obj, ReflectorField refField, boolean def) { - try { - Field field = refField.getTargetField(); - - if (field == null) { - return def; - } else { - boolean flag = field.getBoolean(obj); - return flag; - } - } catch (Throwable throwable) { - Config.error("", throwable); - return def; - } - } - - public static Object getFieldValue(ReflectorFields refFields, int index) { - ReflectorField reflectorfield = refFields.getReflectorField(index); - return reflectorfield == null ? null : getFieldValue(reflectorfield); - } - - public static Object getFieldValue(Object obj, ReflectorFields refFields, int index) { - ReflectorField reflectorfield = refFields.getReflectorField(index); - return reflectorfield == null ? null : getFieldValue(obj, reflectorfield); - } - - public static float getFieldValueFloat(Object obj, ReflectorField refField, float def) { - try { - Field field = refField.getTargetField(); - - if (field == null) { - return def; - } else { - float f = field.getFloat(obj); - return f; - } - } catch (Throwable throwable) { - Config.error("", throwable); - return def; - } - } - - public static int getFieldValueInt(Object obj, ReflectorField refField, int def) { - try { - Field field = refField.getTargetField(); - - if (field == null) { - return def; - } else { - int i = field.getInt(obj); - return i; - } - } catch (Throwable throwable) { - Config.error("", throwable); - return def; - } - } - - public static long getFieldValueLong(Object obj, ReflectorField refField, long def) { - try { - Field field = refField.getTargetField(); - - if (field == null) { - return def; - } else { - long i = field.getLong(obj); - return i; - } - } catch (Throwable throwable) { - Config.error("", throwable); - return def; - } - } - - public static boolean setFieldValue(ReflectorField refField, Object value) { - return setFieldValue((Object) null, refField, value); - } - - public static boolean setFieldValue(Object obj, ReflectorField refField, Object value) { - try { - Field field = refField.getTargetField(); - - if (field == null) { - return false; - } else { - field.set(obj, value); - return true; - } - } catch (Throwable throwable) { - Config.error("", throwable); - return false; - } - } - - public static boolean setFieldValueInt(ReflectorField refField, int value) { - return setFieldValueInt((Object) null, refField, value); - } - - public static boolean setFieldValueInt(Object obj, ReflectorField refField, int value) { - try { - Field field = refField.getTargetField(); - - if (field == null) { - return false; - } else { - field.setInt(obj, value); - return true; - } - } catch (Throwable throwable) { - Config.error("", throwable); - return false; - } - } - - public static Object newInstance(ReflectorConstructor constr, Object...params) { - Constructor constructor = constr.getTargetConstructor(); - - if (constructor == null) { - return null; - } else { - try { - Object object = constructor.newInstance(params); - return object; - } catch (Throwable throwable) { - handleException(throwable, constr, params); - return null; - } - } - } - - public static boolean matchesTypes(Class[] pTypes, Class[] cTypes) { - if (pTypes.length != cTypes.length) { - return false; - } else { - for (int i = 0; i < cTypes.length; ++i) { - Class oclass = pTypes[i]; - Class oclass1 = cTypes[i]; - - if (oclass != oclass1) { - return false; - } - } - - return true; - } - } - - private static void dbgCall(boolean isStatic, String callType, ReflectorMethod refMethod, Object[] params, Object retVal) { - String s = refMethod.getTargetMethod().getDeclaringClass().getName(); - String s1 = refMethod.getTargetMethod().getName(); - String s2 = ""; - - if (isStatic) { - s2 = " static"; - } - - Config.dbg(callType + s2 + " " + s + "." + s1 + "(" + ArrayUtils.arrayToString(params) + ") => " + retVal); - } - - private static void dbgCallVoid(boolean isStatic, String callType, ReflectorMethod refMethod, Object[] params) { - String s = refMethod.getTargetMethod().getDeclaringClass().getName(); - String s1 = refMethod.getTargetMethod().getName(); - String s2 = ""; - - if (isStatic) { - s2 = " static"; - } - - Config.dbg(callType + s2 + " " + s + "." + s1 + "(" + ArrayUtils.arrayToString(params) + ")"); - } - - private static void dbgFieldValue(boolean isStatic, String accessType, ReflectorField refField, Object val) { - String s = refField.getTargetField().getDeclaringClass().getName(); - String s1 = refField.getTargetField().getName(); - String s2 = ""; - - if (isStatic) { - s2 = " static"; - } - - Config.dbg(accessType + s2 + " " + s + "." + s1 + " => " + val); - } - - private static void handleException(Throwable e, Object obj, ReflectorMethod refMethod, Object[] params) { - if (e instanceof InvocationTargetException) { - Throwable throwable = e.getCause(); - - if (throwable instanceof RuntimeException) { - RuntimeException runtimeexception = (RuntimeException) throwable; - throw runtimeexception; - } else { - Config.error("", e); - } - } else { - Config.warn("*** Exception outside of method ***"); - Config.warn("Method deactivated: " + refMethod.getTargetMethod()); - refMethod.deactivate(); - - if (e instanceof IllegalArgumentException) { - Config.warn("*** IllegalArgumentException ***"); - Config.warn("Method: " + refMethod.getTargetMethod()); - Config.warn("Object: " + obj); - Config.warn("Parameter classes: " + ArrayUtils.arrayToString(getClasses(params))); - Config.warn("Parameters: " + ArrayUtils.arrayToString(params)); - } - - Config.warn("", e); - } - } - - private static void handleException(Throwable e, ReflectorConstructor refConstr, Object[] params) { - if (e instanceof InvocationTargetException) { - Config.error("", e); - } else { - Config.warn("*** Exception outside of constructor ***"); - Config.warn("Constructor deactivated: " + refConstr.getTargetConstructor()); - refConstr.deactivate(); - - if (e instanceof IllegalArgumentException) { - Config.warn("*** IllegalArgumentException ***"); - Config.warn("Constructor: " + refConstr.getTargetConstructor()); - Config.warn("Parameter classes: " + ArrayUtils.arrayToString(getClasses(params))); - Config.warn("Parameters: " + ArrayUtils.arrayToString(params)); - } - - Config.warn("", e); - } - } - - private static Object[] getClasses(Object[] objs) { - if (objs == null) { - return new Class[0]; - } else { - Class[] aclass = new Class[objs.length]; - - for (int i = 0; i < aclass.length; ++i) { - Object object = objs[i]; - - if (object != null) { - aclass[i] = object.getClass(); - } - } - - return aclass; - } - } - - private static ReflectorField[] getReflectorFields(ReflectorClass parentClass, Class fieldType, int count) { - ReflectorField[] areflectorfield = new ReflectorField[count]; - - for (int i = 0; i < areflectorfield.length; ++i) { - areflectorfield[i] = new ReflectorField(parentClass, fieldType, i); - } - - return areflectorfield; - } - - private static boolean logEntry(String str) { - LOGGER.info("[OptiFine] " + str); - return true; - } - - private static boolean registerResolvable(final String str) { - IResolvable iresolvable = new IResolvable() { - public void resolve() { - Reflector.LOGGER.info("[OptiFine] " + str); - } - }; - ReflectorResolver.register(iresolvable); - return true; - } -} \ No newline at end of file +//package net.PeytonPlayz585.shadow.reflect; +// +//import java.lang.reflect.Constructor; +//import java.lang.reflect.Field; +//import java.lang.reflect.InvocationTargetException; +//import java.lang.reflect.Method; +// +//import net.PeytonPlayz585.shadow.ArrayUtils; +//import net.PeytonPlayz585.shadow.Config; +//import net.lax1dude.eaglercraft.v1_8.log4j.LogManager; +//import net.lax1dude.eaglercraft.v1_8.log4j.Logger; +//import net.minecraft.client.Minecraft; +//import net.minecraft.client.resources.DefaultResourcePack; +// +//public class Reflector { +// private static final Logger LOGGER = LogManager.getLogger(); +// public static ReflectorClass Minecraft = new ReflectorClass(Minecraft.class); +// public static ReflectorField Minecraft_defaultResourcePack = new ReflectorField(Minecraft, DefaultResourcePack.class); +// +// public static void callVoid(ReflectorMethod refMethod, Object...params) { +// try { +// Method method = refMethod.getTargetMethod(); +// +// if (method == null) { +// return; +// } +// +// method.invoke((Object) null, params); +// } catch (Throwable throwable) { +// handleException(throwable, (Object) null, refMethod, params); +// } +// } +// +// public static boolean callBoolean(ReflectorMethod refMethod, Object...params) { +// try { +// Method method = refMethod.getTargetMethod(); +// +// if (method == null) { +// return false; +// } else { +// Boolean obool = (Boolean) method.invoke((Object) null, params); +// return obool.booleanValue(); +// } +// } catch (Throwable throwable) { +// handleException(throwable, (Object) null, refMethod, params); +// return false; +// } +// } +// +// public static int callInt(ReflectorMethod refMethod, Object...params) { +// try { +// Method method = refMethod.getTargetMethod(); +// +// if (method == null) { +// return 0; +// } else { +// Integer integer = (Integer) method.invoke((Object) null, params); +// return integer.intValue(); +// } +// } catch (Throwable throwable) { +// handleException(throwable, (Object) null, refMethod, params); +// return 0; +// } +// } +// +// public static float callFloat(ReflectorMethod refMethod, Object...params) { +// try { +// Method method = refMethod.getTargetMethod(); +// +// if (method == null) { +// return 0.0F; +// } else { +// Float f = (Float) method.invoke((Object) null, params); +// return f.floatValue(); +// } +// } catch (Throwable throwable) { +// handleException(throwable, (Object) null, refMethod, params); +// return 0.0F; +// } +// } +// +// public static double callDouble(ReflectorMethod refMethod, Object...params) { +// try { +// Method method = refMethod.getTargetMethod(); +// +// if (method == null) { +// return 0.0D; +// } else { +// Double d0 = (Double) method.invoke((Object) null, params); +// return d0.doubleValue(); +// } +// } catch (Throwable throwable) { +// handleException(throwable, (Object) null, refMethod, params); +// return 0.0D; +// } +// } +// +// public static String callString(ReflectorMethod refMethod, Object...params) { +// try { +// Method method = refMethod.getTargetMethod(); +// +// if (method == null) { +// return null; +// } else { +// String s = (String) method.invoke((Object) null, params); +// return s; +// } +// } catch (Throwable throwable) { +// handleException(throwable, (Object) null, refMethod, params); +// return null; +// } +// } +// +// public static Object call(ReflectorMethod refMethod, Object...params) { +// try { +// Method method = refMethod.getTargetMethod(); +// +// if (method == null) { +// return null; +// } else { +// Object object = method.invoke((Object) null, params); +// return object; +// } +// } catch (Throwable throwable) { +// handleException(throwable, (Object) null, refMethod, params); +// return null; +// } +// } +// +// public static void callVoid(Object obj, ReflectorMethod refMethod, Object...params) { +// try { +// if (obj == null) { +// return; +// } +// +// Method method = refMethod.getTargetMethod(); +// +// if (method == null) { +// return; +// } +// +// method.invoke(obj, params); +// } catch (Throwable throwable) { +// handleException(throwable, obj, refMethod, params); +// } +// } +// +// public static boolean callBoolean(Object obj, ReflectorMethod refMethod, Object...params) { +// try { +// Method method = refMethod.getTargetMethod(); +// +// if (method == null) { +// return false; +// } else { +// Boolean obool = (Boolean) method.invoke(obj, params); +// return obool.booleanValue(); +// } +// } catch (Throwable throwable) { +// handleException(throwable, obj, refMethod, params); +// return false; +// } +// } +// +// public static int callInt(Object obj, ReflectorMethod refMethod, Object...params) { +// try { +// Method method = refMethod.getTargetMethod(); +// +// if (method == null) { +// return 0; +// } else { +// Integer integer = (Integer) method.invoke(obj, params); +// return integer.intValue(); +// } +// } catch (Throwable throwable) { +// handleException(throwable, obj, refMethod, params); +// return 0; +// } +// } +// +// public static float callFloat(Object obj, ReflectorMethod refMethod, Object...params) { +// try { +// Method method = refMethod.getTargetMethod(); +// +// if (method == null) { +// return 0.0F; +// } else { +// Float f = (Float) method.invoke(obj, params); +// return f.floatValue(); +// } +// } catch (Throwable throwable) { +// handleException(throwable, obj, refMethod, params); +// return 0.0F; +// } +// } +// +// public static double callDouble(Object obj, ReflectorMethod refMethod, Object...params) { +// try { +// Method method = refMethod.getTargetMethod(); +// +// if (method == null) { +// return 0.0D; +// } else { +// Double d0 = (Double) method.invoke(obj, params); +// return d0.doubleValue(); +// } +// } catch (Throwable throwable) { +// handleException(throwable, obj, refMethod, params); +// return 0.0D; +// } +// } +// +// public static String callString(Object obj, ReflectorMethod refMethod, Object...params) { +// try { +// Method method = refMethod.getTargetMethod(); +// +// if (method == null) { +// return null; +// } else { +// String s = (String) method.invoke(obj, params); +// return s; +// } +// } catch (Throwable throwable) { +// handleException(throwable, obj, refMethod, params); +// return null; +// } +// } +// +// public static Object call(Object obj, ReflectorMethod refMethod, Object...params) { +// try { +// Method method = refMethod.getTargetMethod(); +// +// if (method == null) { +// return null; +// } else { +// Object object = method.invoke(obj, params); +// return object; +// } +// } catch (Throwable throwable) { +// handleException(throwable, obj, refMethod, params); +// return null; +// } +// } +// +// public static Object getFieldValue(ReflectorField refField) { +// return getFieldValue((Object) null, refField); +// } +// +// public static Object getFieldValue(Object obj, ReflectorField refField) { +// try { +// Field field = refField.getTargetField(); +// +// if (field == null) { +// return null; +// } else { +// Object object = field.get(obj); +// return object; +// } +// } catch (Throwable throwable) { +// Config.error("", throwable); +// return null; +// } +// } +// +// public static boolean getFieldValueBoolean(ReflectorField refField, boolean def) { +// try { +// Field field = refField.getTargetField(); +// +// if (field == null) { +// return def; +// } else { +// boolean flag = field.getBoolean((Object) null); +// return flag; +// } +// } catch (Throwable throwable) { +// Config.error("", throwable); +// return def; +// } +// } +// +// public static boolean getFieldValueBoolean(Object obj, ReflectorField refField, boolean def) { +// try { +// Field field = refField.getTargetField(); +// +// if (field == null) { +// return def; +// } else { +// boolean flag = field.getBoolean(obj); +// return flag; +// } +// } catch (Throwable throwable) { +// Config.error("", throwable); +// return def; +// } +// } +// +// public static Object getFieldValue(ReflectorFields refFields, int index) { +// ReflectorField reflectorfield = refFields.getReflectorField(index); +// return reflectorfield == null ? null : getFieldValue(reflectorfield); +// } +// +// public static Object getFieldValue(Object obj, ReflectorFields refFields, int index) { +// ReflectorField reflectorfield = refFields.getReflectorField(index); +// return reflectorfield == null ? null : getFieldValue(obj, reflectorfield); +// } +// +// public static float getFieldValueFloat(Object obj, ReflectorField refField, float def) { +// try { +// Field field = refField.getTargetField(); +// +// if (field == null) { +// return def; +// } else { +// float f = field.getFloat(obj); +// return f; +// } +// } catch (Throwable throwable) { +// Config.error("", throwable); +// return def; +// } +// } +// +// public static int getFieldValueInt(Object obj, ReflectorField refField, int def) { +// try { +// Field field = refField.getTargetField(); +// +// if (field == null) { +// return def; +// } else { +// int i = field.getInt(obj); +// return i; +// } +// } catch (Throwable throwable) { +// Config.error("", throwable); +// return def; +// } +// } +// +// public static long getFieldValueLong(Object obj, ReflectorField refField, long def) { +// try { +// Field field = refField.getTargetField(); +// +// if (field == null) { +// return def; +// } else { +// long i = field.getLong(obj); +// return i; +// } +// } catch (Throwable throwable) { +// Config.error("", throwable); +// return def; +// } +// } +// +// public static boolean setFieldValue(ReflectorField refField, Object value) { +// return setFieldValue((Object) null, refField, value); +// } +// +// public static boolean setFieldValue(Object obj, ReflectorField refField, Object value) { +// try { +// Field field = refField.getTargetField(); +// +// if (field == null) { +// return false; +// } else { +// field.set(obj, value); +// return true; +// } +// } catch (Throwable throwable) { +// Config.error("", throwable); +// return false; +// } +// } +// +// public static boolean setFieldValueInt(ReflectorField refField, int value) { +// return setFieldValueInt((Object) null, refField, value); +// } +// +// public static boolean setFieldValueInt(Object obj, ReflectorField refField, int value) { +// try { +// Field field = refField.getTargetField(); +// +// if (field == null) { +// return false; +// } else { +// field.setInt(obj, value); +// return true; +// } +// } catch (Throwable throwable) { +// Config.error("", throwable); +// return false; +// } +// } +// +// public static Object newInstance(ReflectorConstructor constr, Object...params) { +// Constructor constructor = constr.getTargetConstructor(); +// +// if (constructor == null) { +// return null; +// } else { +// try { +// Object object = constructor.newInstance(params); +// return object; +// } catch (Throwable throwable) { +// handleException(throwable, constr, params); +// return null; +// } +// } +// } +// +// public static boolean matchesTypes(Class[] pTypes, Class[] cTypes) { +// if (pTypes.length != cTypes.length) { +// return false; +// } else { +// for (int i = 0; i < cTypes.length; ++i) { +// Class oclass = pTypes[i]; +// Class oclass1 = cTypes[i]; +// +// if (oclass != oclass1) { +// return false; +// } +// } +// +// return true; +// } +// } +// +// private static void dbgCall(boolean isStatic, String callType, ReflectorMethod refMethod, Object[] params, Object retVal) { +// String s = refMethod.getTargetMethod().getDeclaringClass().getName(); +// String s1 = refMethod.getTargetMethod().getName(); +// String s2 = ""; +// +// if (isStatic) { +// s2 = " static"; +// } +// +// Config.dbg(callType + s2 + " " + s + "." + s1 + "(" + ArrayUtils.arrayToString(params) + ") => " + retVal); +// } +// +// private static void dbgCallVoid(boolean isStatic, String callType, ReflectorMethod refMethod, Object[] params) { +// String s = refMethod.getTargetMethod().getDeclaringClass().getName(); +// String s1 = refMethod.getTargetMethod().getName(); +// String s2 = ""; +// +// if (isStatic) { +// s2 = " static"; +// } +// +// Config.dbg(callType + s2 + " " + s + "." + s1 + "(" + ArrayUtils.arrayToString(params) + ")"); +// } +// +// private static void dbgFieldValue(boolean isStatic, String accessType, ReflectorField refField, Object val) { +// String s = refField.getTargetField().getDeclaringClass().getName(); +// String s1 = refField.getTargetField().getName(); +// String s2 = ""; +// +// if (isStatic) { +// s2 = " static"; +// } +// +// Config.dbg(accessType + s2 + " " + s + "." + s1 + " => " + val); +// } +// +// private static void handleException(Throwable e, Object obj, ReflectorMethod refMethod, Object[] params) { +// if (e instanceof InvocationTargetException) { +// Throwable throwable = e.getCause(); +// +// if (throwable instanceof RuntimeException) { +// RuntimeException runtimeexception = (RuntimeException) throwable; +// throw runtimeexception; +// } else { +// Config.error("", e); +// } +// } else { +// Config.warn("*** Exception outside of method ***"); +// Config.warn("Method deactivated: " + refMethod.getTargetMethod()); +// refMethod.deactivate(); +// +// if (e instanceof IllegalArgumentException) { +// Config.warn("*** IllegalArgumentException ***"); +// Config.warn("Method: " + refMethod.getTargetMethod()); +// Config.warn("Object: " + obj); +// Config.warn("Parameter classes: " + ArrayUtils.arrayToString(getClasses(params))); +// Config.warn("Parameters: " + ArrayUtils.arrayToString(params)); +// } +// +// Config.warn("", e); +// } +// } +// +// private static void handleException(Throwable e, ReflectorConstructor refConstr, Object[] params) { +// if (e instanceof InvocationTargetException) { +// Config.error("", e); +// } else { +// Config.warn("*** Exception outside of constructor ***"); +// Config.warn("Constructor deactivated: " + refConstr.getTargetConstructor()); +// refConstr.deactivate(); +// +// if (e instanceof IllegalArgumentException) { +// Config.warn("*** IllegalArgumentException ***"); +// Config.warn("Constructor: " + refConstr.getTargetConstructor()); +// Config.warn("Parameter classes: " + ArrayUtils.arrayToString(getClasses(params))); +// Config.warn("Parameters: " + ArrayUtils.arrayToString(params)); +// } +// +// Config.warn("", e); +// } +// } +// +// private static Object[] getClasses(Object[] objs) { +// if (objs == null) { +// return new Class[0]; +// } else { +// Class[] aclass = new Class[objs.length]; +// +// for (int i = 0; i < aclass.length; ++i) { +// Object object = objs[i]; +// +// if (object != null) { +// aclass[i] = object.getClass(); +// } +// } +// +// return aclass; +// } +// } +// +// private static ReflectorField[] getReflectorFields(ReflectorClass parentClass, Class fieldType, int count) { +// ReflectorField[] areflectorfield = new ReflectorField[count]; +// +// for (int i = 0; i < areflectorfield.length; ++i) { +// areflectorfield[i] = new ReflectorField(parentClass, fieldType, i); +// } +// +// return areflectorfield; +// } +// +// private static boolean logEntry(String str) { +// LOGGER.info("[OptiFine] " + str); +// return true; +// } +// +// private static boolean registerResolvable(final String str) { +// IResolvable iresolvable = new IResolvable() { +// public void resolve() { +// Reflector.LOGGER.info("[OptiFine] " + str); +// } +// }; +// ReflectorResolver.register(iresolvable); +// return true; +// } +//} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorClass.java b/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorClass.java index aa15b26..a5241a7 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorClass.java +++ b/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorClass.java @@ -1,66 +1,66 @@ -package net.PeytonPlayz585.shadow.reflect; - -import net.PeytonPlayz585.shadow.Config; - -public class ReflectorClass implements IResolvable { - private String targetClassName = null; - private boolean checked = false; - private Class targetClass = null; - - public ReflectorClass(String targetClassName) { - this.targetClassName = targetClassName; - ReflectorResolver.register(this); - } - - public ReflectorClass(Class targetClass) { - this.targetClass = targetClass; - this.targetClassName = targetClass.getName(); - this.checked = true; - } - - public Class getTargetClass() { - if (this.checked) { - return this.targetClass; - } else { - this.checked = true; - - try { - this.targetClass = Class.forName(this.targetClassName); - } catch (ClassNotFoundException var2) { - Config.log("(Reflector) Class not present: " + this.targetClassName); - } catch (Throwable throwable) { - throwable.printStackTrace(); - } - - return this.targetClass; - } - } - - public boolean exists() { - return this.getTargetClass() != null; - } - - public String getTargetClassName() { - return this.targetClassName; - } - - public boolean isInstance(Object obj) { - return this.getTargetClass() == null ? false : this.getTargetClass().isInstance(obj); - } - - public ReflectorField makeField(String name) { - return new ReflectorField(this, name); - } - - public ReflectorMethod makeMethod(String name) { - return new ReflectorMethod(this, name); - } - - public ReflectorMethod makeMethod(String name, Class[] paramTypes) { - return new ReflectorMethod(this, name, paramTypes); - } - - public void resolve() { - Class oclass = this.getTargetClass(); - } -} \ No newline at end of file +//package net.PeytonPlayz585.shadow.reflect; +// +//import net.PeytonPlayz585.shadow.Config; +// +//public class ReflectorClass implements IResolvable { +// private String targetClassName = null; +// private boolean checked = false; +// private Class targetClass = null; +// +// public ReflectorClass(String targetClassName) { +// this.targetClassName = targetClassName; +// ReflectorResolver.register(this); +// } +// +// public ReflectorClass(Class targetClass) { +// this.targetClass = targetClass; +// this.targetClassName = targetClass.getName(); +// this.checked = true; +// } +// +// public Class getTargetClass() { +// if (this.checked) { +// return this.targetClass; +// } else { +// this.checked = true; +// +// try { +// this.targetClass = Class.forName(this.targetClassName); +// } catch (ClassNotFoundException var2) { +// Config.log("(Reflector) Class not present: " + this.targetClassName); +// } catch (Throwable throwable) { +// throwable.printStackTrace(); +// } +// +// return this.targetClass; +// } +// } +// +// public boolean exists() { +// return this.getTargetClass() != null; +// } +// +// public String getTargetClassName() { +// return this.targetClassName; +// } +// +// public boolean isInstance(Object obj) { +// return this.getTargetClass() == null ? false : this.getTargetClass().isInstance(obj); +// } +// +// public ReflectorField makeField(String name) { +// return new ReflectorField(this, name); +// } +// +// public ReflectorMethod makeMethod(String name) { +// return new ReflectorMethod(this, name); +// } +// +// public ReflectorMethod makeMethod(String name, Class[] paramTypes) { +// return new ReflectorMethod(this, name, paramTypes); +// } +// +// public void resolve() { +// Class oclass = this.getTargetClass(); +// } +//} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorConstructor.java b/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorConstructor.java index 4341585..3a69b92 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorConstructor.java +++ b/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorConstructor.java @@ -1,80 +1,80 @@ -package net.PeytonPlayz585.shadow.reflect; - -import java.lang.reflect.Constructor; - -import net.PeytonPlayz585.shadow.ArrayUtils; -import net.PeytonPlayz585.shadow.Config; - -public class ReflectorConstructor implements IResolvable { - private ReflectorClass reflectorClass = null; - private Class[] parameterTypes = null; - private boolean checked = false; - private Constructor targetConstructor = null; - - public ReflectorConstructor(ReflectorClass reflectorClass, Class[] parameterTypes) { - this.reflectorClass = reflectorClass; - this.parameterTypes = parameterTypes; - ReflectorResolver.register(this); - } - - public Constructor getTargetConstructor() { - if (this.checked) { - return this.targetConstructor; - } else { - this.checked = true; - Class oclass = this.reflectorClass.getTargetClass(); - - if (oclass == null) { - return null; - } else { - try { - this.targetConstructor = findConstructor(oclass, this.parameterTypes); - - if (this.targetConstructor == null) { - Config.dbg("(Reflector) Constructor not present: " + oclass.getName() + ", params: " + ArrayUtils.arrayToString((Object[]) this.parameterTypes)); - } - - if (this.targetConstructor != null) { - this.targetConstructor.setAccessible(true); - } - } catch (Throwable throwable) { - throwable.printStackTrace(); - } - - return this.targetConstructor; - } - } - } - - private static Constructor findConstructor(Class cls, Class[] paramTypes) { - Constructor[] aconstructor = cls.getDeclaredConstructors(); - - for (int i = 0; i < aconstructor.length; ++i) { - Constructor constructor = aconstructor[i]; - Class[] aclass = constructor.getParameterTypes(); - - if (Reflector.matchesTypes(paramTypes, aclass)) { - return constructor; - } - } - - return null; - } - - public boolean exists() { - return this.checked ? this.targetConstructor != null : this.getTargetConstructor() != null; - } - - public void deactivate() { - this.checked = true; - this.targetConstructor = null; - } - - public Object newInstance(Object...params) { - return Reflector.newInstance(this, params); - } - - public void resolve() { - Constructor constructor = this.getTargetConstructor(); - } -} \ No newline at end of file +//package net.PeytonPlayz585.shadow.reflect; +// +//import java.lang.reflect.Constructor; +// +//import net.PeytonPlayz585.shadow.ArrayUtils; +//import net.PeytonPlayz585.shadow.Config; +// +//public class ReflectorConstructor implements IResolvable { +// private ReflectorClass reflectorClass = null; +// private Class[] parameterTypes = null; +// private boolean checked = false; +// private Constructor targetConstructor = null; +// +// public ReflectorConstructor(ReflectorClass reflectorClass, Class[] parameterTypes) { +// this.reflectorClass = reflectorClass; +// this.parameterTypes = parameterTypes; +// ReflectorResolver.register(this); +// } +// +// public Constructor getTargetConstructor() { +// if (this.checked) { +// return this.targetConstructor; +// } else { +// this.checked = true; +// Class oclass = this.reflectorClass.getTargetClass(); +// +// if (oclass == null) { +// return null; +// } else { +// try { +// this.targetConstructor = findConstructor(oclass, this.parameterTypes); +// +// if (this.targetConstructor == null) { +// Config.dbg("(Reflector) Constructor not present: " + oclass.getName() + ", params: " + ArrayUtils.arrayToString((Object[]) this.parameterTypes)); +// } +// +// if (this.targetConstructor != null) { +// this.targetConstructor.setAccessible(true); +// } +// } catch (Throwable throwable) { +// throwable.printStackTrace(); +// } +// +// return this.targetConstructor; +// } +// } +// } +// +// private static Constructor findConstructor(Class cls, Class[] paramTypes) { +// Constructor[] aconstructor = cls.getDeclaredConstructors(); +// +// for (int i = 0; i < aconstructor.length; ++i) { +// Constructor constructor = aconstructor[i]; +// Class[] aclass = constructor.getParameterTypes(); +// +// if (Reflector.matchesTypes(paramTypes, aclass)) { +// return constructor; +// } +// } +// +// return null; +// } +// +// public boolean exists() { +// return this.checked ? this.targetConstructor != null : this.getTargetConstructor() != null; +// } +// +// public void deactivate() { +// this.checked = true; +// this.targetConstructor = null; +// } +// +// public Object newInstance(Object...params) { +// return Reflector.newInstance(this, params); +// } +// +// public void resolve() { +// Constructor constructor = this.getTargetConstructor(); +// } +//} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorField.java b/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorField.java index 35b7d4a..05c7a3d 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorField.java +++ b/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorField.java @@ -1,68 +1,68 @@ -package net.PeytonPlayz585.shadow.reflect; - -import java.lang.reflect.Field; - -public class ReflectorField implements IResolvable { - private IFieldLocator fieldLocator; - private boolean checked; - private Field targetField; - - public ReflectorField(ReflectorClass reflectorClass, String targetFieldName) { - this((IFieldLocator)(new FieldLocatorName(reflectorClass, targetFieldName))); - } - - public ReflectorField(ReflectorClass reflectorClass, Class targetFieldType) { - this(reflectorClass, targetFieldType, 0); - } - - public ReflectorField(ReflectorClass reflectorClass, Class targetFieldType, int targetFieldIndex) { - this((IFieldLocator)(new FieldLocatorType(reflectorClass, targetFieldType, targetFieldIndex))); - } - - public ReflectorField(Field field) { - this((IFieldLocator)(new FieldLocatorFixed(field))); - } - - public ReflectorField(IFieldLocator fieldLocator) { - this.fieldLocator = null; - this.checked = false; - this.targetField = null; - this.fieldLocator = fieldLocator; - ReflectorResolver.register(this); - } - - public Field getTargetField() { - if (this.checked) { - return this.targetField; - } else { - this.checked = true; - this.targetField = this.fieldLocator.getField(); - - if (this.targetField != null) { - this.targetField.setAccessible(true); - } - - return this.targetField; - } - } - - public Object getValue() { - return Reflector.getFieldValue((Object) null, this); - } - - public void setValue(Object value) { - Reflector.setFieldValue((Object) null, this, value); - } - - public void setValue(Object obj, Object value) { - Reflector.setFieldValue(obj, this, value); - } - - public boolean exists() { - return this.getTargetField() != null; - } - - public void resolve() { - Field field = this.getTargetField(); - } -} \ No newline at end of file +//package net.PeytonPlayz585.shadow.reflect; +// +//import java.lang.reflect.Field; +// +//public class ReflectorField implements IResolvable { +// private IFieldLocator fieldLocator; +// private boolean checked; +// private Field targetField; +// +// public ReflectorField(ReflectorClass reflectorClass, String targetFieldName) { +// this((IFieldLocator)(new FieldLocatorName(reflectorClass, targetFieldName))); +// } +// +// public ReflectorField(ReflectorClass reflectorClass, Class targetFieldType) { +// this(reflectorClass, targetFieldType, 0); +// } +// +// public ReflectorField(ReflectorClass reflectorClass, Class targetFieldType, int targetFieldIndex) { +// this((IFieldLocator)(new FieldLocatorType(reflectorClass, targetFieldType, targetFieldIndex))); +// } +// +// public ReflectorField(Field field) { +// this((IFieldLocator)(new FieldLocatorFixed(field))); +// } +// +// public ReflectorField(IFieldLocator fieldLocator) { +// this.fieldLocator = null; +// this.checked = false; +// this.targetField = null; +// this.fieldLocator = fieldLocator; +// ReflectorResolver.register(this); +// } +// +// public Field getTargetField() { +// if (this.checked) { +// return this.targetField; +// } else { +// this.checked = true; +// this.targetField = this.fieldLocator.getField(); +// +// if (this.targetField != null) { +// this.targetField.setAccessible(true); +// } +// +// return this.targetField; +// } +// } +// +// public Object getValue() { +// return Reflector.getFieldValue((Object) null, this); +// } +// +// public void setValue(Object value) { +// Reflector.setFieldValue((Object) null, this, value); +// } +// +// public void setValue(Object obj, Object value) { +// Reflector.setFieldValue(obj, this, value); +// } +// +// public boolean exists() { +// return this.getTargetField() != null; +// } +// +// public void resolve() { +// Field field = this.getTargetField(); +// } +//} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorFields.java b/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorFields.java index 42e52c3..f958f71 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorFields.java +++ b/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorFields.java @@ -1,39 +1,39 @@ -package net.PeytonPlayz585.shadow.reflect; - -public class ReflectorFields { - private ReflectorClass reflectorClass; - private Class fieldType; - private int fieldCount; - private ReflectorField[] reflectorFields; - - public ReflectorFields(ReflectorClass reflectorClass, Class fieldType, int fieldCount) { - this.reflectorClass = reflectorClass; - this.fieldType = fieldType; - - if (reflectorClass.exists()) { - if (fieldType != null) { - this.reflectorFields = new ReflectorField[fieldCount]; - - for (int i = 0; i < this.reflectorFields.length; ++i) { - this.reflectorFields[i] = new ReflectorField(reflectorClass, fieldType, i); - } - } - } - } - - public ReflectorClass getReflectorClass() { - return this.reflectorClass; - } - - public Class getFieldType() { - return this.fieldType; - } - - public int getFieldCount() { - return this.fieldCount; - } - - public ReflectorField getReflectorField(int index) { - return index >= 0 && index < this.reflectorFields.length ? this.reflectorFields[index] : null; - } -} \ No newline at end of file +//package net.PeytonPlayz585.shadow.reflect; +// +//public class ReflectorFields { +// private ReflectorClass reflectorClass; +// private Class fieldType; +// private int fieldCount; +// private ReflectorField[] reflectorFields; +// +// public ReflectorFields(ReflectorClass reflectorClass, Class fieldType, int fieldCount) { +// this.reflectorClass = reflectorClass; +// this.fieldType = fieldType; +// +// if (reflectorClass.exists()) { +// if (fieldType != null) { +// this.reflectorFields = new ReflectorField[fieldCount]; +// +// for (int i = 0; i < this.reflectorFields.length; ++i) { +// this.reflectorFields[i] = new ReflectorField(reflectorClass, fieldType, i); +// } +// } +// } +// } +// +// public ReflectorClass getReflectorClass() { +// return this.reflectorClass; +// } +// +// public Class getFieldType() { +// return this.fieldType; +// } +// +// public int getFieldCount() { +// return this.fieldCount; +// } +// +// public ReflectorField getReflectorField(int index) { +// return index >= 0 && index < this.reflectorFields.length ? this.reflectorFields[index] : null; +// } +//} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorMethod.java b/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorMethod.java index 908acbd..4ac3383 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorMethod.java +++ b/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorMethod.java @@ -1,197 +1,197 @@ -package net.PeytonPlayz585.shadow.reflect; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; - -import net.PeytonPlayz585.shadow.Config; - -public class ReflectorMethod implements IResolvable { - private ReflectorClass reflectorClass; - private String targetMethodName; - private Class[] targetMethodParameterTypes; - private boolean checked; - private Method targetMethod; - - public ReflectorMethod(ReflectorClass reflectorClass, String targetMethodName) { - this(reflectorClass, targetMethodName, (Class[]) null); - } - - public ReflectorMethod(ReflectorClass reflectorClass, String targetMethodName, Class[] targetMethodParameterTypes) { - this.reflectorClass = null; - this.targetMethodName = null; - this.targetMethodParameterTypes = null; - this.checked = false; - this.targetMethod = null; - this.reflectorClass = reflectorClass; - this.targetMethodName = targetMethodName; - this.targetMethodParameterTypes = targetMethodParameterTypes; - ReflectorResolver.register(this); - } - - public Method getTargetMethod() { - if (this.checked) { - return this.targetMethod; - } else { - this.checked = true; - Class oclass = this.reflectorClass.getTargetClass(); - - if (oclass == null) { - return null; - } else { - try { - if (this.targetMethodParameterTypes == null) { - Method[] amethod = getMethods(oclass, this.targetMethodName); - - if (amethod.length <= 0) { - Config.log("(Reflector) Method not present: " + oclass.getName() + "." + this.targetMethodName); - return null; - } - - if (amethod.length > 1) { - Config.warn("(Reflector) More than one method found: " + oclass.getName() + "." + this.targetMethodName); - - for (int i = 0; i < amethod.length; ++i) { - Method method = amethod[i]; - Config.warn("(Reflector) - " + method); - } - - return null; - } - - this.targetMethod = amethod[0]; - } else { - this.targetMethod = getMethod(oclass, this.targetMethodName, this.targetMethodParameterTypes); - } - - if (this.targetMethod == null) { - Config.log("(Reflector) Method not present: " + oclass.getName() + "." + this.targetMethodName); - return null; - } else { - this.targetMethod.setAccessible(true); - return this.targetMethod; - } - } catch (Throwable throwable) { - throwable.printStackTrace(); - return null; - } - } - } - } - - public boolean exists() { - return this.checked ? this.targetMethod != null : this.getTargetMethod() != null; - } - - public Class getReturnType() { - Method method = this.getTargetMethod(); - return method == null ? null : method.getReturnType(); - } - - public void deactivate() { - this.checked = true; - this.targetMethod = null; - } - - public Object call(Object...params) { - return Reflector.call(this, params); - } - - public boolean callBoolean(Object...params) { - return Reflector.callBoolean(this, params); - } - - public int callInt(Object...params) { - return Reflector.callInt(this, params); - } - - public float callFloat(Object...params) { - return Reflector.callFloat(this, params); - } - - public double callDouble(Object...params) { - return Reflector.callDouble(this, params); - } - - public String callString(Object...params) { - return Reflector.callString(this, params); - } - - public Object call(Object param) { - return Reflector.call(this, new Object[] { - param - }); - } - - public boolean callBoolean(Object param) { - return Reflector.callBoolean(this, new Object[] { - param - }); - } - - public int callInt(Object param) { - return Reflector.callInt(this, new Object[] { - param - }); - } - - public float callFloat(Object param) { - return Reflector.callFloat(this, new Object[] { - param - }); - } - - public double callDouble(Object param) { - return Reflector.callDouble(this, new Object[] { - param - }); - } - - public String callString1(Object param) { - return Reflector.callString(this, new Object[] { - param - }); - } - - public void callVoid(Object...params) { - Reflector.callVoid(this, params); - } - - public static Method getMethod(Class cls, String methodName, Class[] paramTypes) { - Method[] amethod = cls.getDeclaredMethods(); - - for (int i = 0; i < amethod.length; ++i) { - Method method = amethod[i]; - - if (method.getName().equals(methodName)) { - Class[] aclass = method.getParameterTypes(); - - if (Reflector.matchesTypes(paramTypes, aclass)) { - return method; - } - } - } - - return null; - } - - public static Method[] getMethods(Class cls, String methodName) { - List list = new ArrayList(); - Method[] amethod = cls.getDeclaredMethods(); - - for (int i = 0; i < amethod.length; ++i) { - Method method = amethod[i]; - - if (method.getName().equals(methodName)) { - list.add(method); - } - } - - Method[] amethod1 = (Method[])((Method[]) list.toArray(new Method[list.size()])); - return amethod1; - } - - public void resolve() { - Method method = this.getTargetMethod(); - } -} \ No newline at end of file +//package net.PeytonPlayz585.shadow.reflect; +// +//import java.lang.reflect.Method; +//import java.util.ArrayList; +//import java.util.List; +// +//import net.PeytonPlayz585.shadow.Config; +// +//public class ReflectorMethod implements IResolvable { +// private ReflectorClass reflectorClass; +// private String targetMethodName; +// private Class[] targetMethodParameterTypes; +// private boolean checked; +// private Method targetMethod; +// +// public ReflectorMethod(ReflectorClass reflectorClass, String targetMethodName) { +// this(reflectorClass, targetMethodName, (Class[]) null); +// } +// +// public ReflectorMethod(ReflectorClass reflectorClass, String targetMethodName, Class[] targetMethodParameterTypes) { +// this.reflectorClass = null; +// this.targetMethodName = null; +// this.targetMethodParameterTypes = null; +// this.checked = false; +// this.targetMethod = null; +// this.reflectorClass = reflectorClass; +// this.targetMethodName = targetMethodName; +// this.targetMethodParameterTypes = targetMethodParameterTypes; +// ReflectorResolver.register(this); +// } +// +// public Method getTargetMethod() { +// if (this.checked) { +// return this.targetMethod; +// } else { +// this.checked = true; +// Class oclass = this.reflectorClass.getTargetClass(); +// +// if (oclass == null) { +// return null; +// } else { +// try { +// if (this.targetMethodParameterTypes == null) { +// Method[] amethod = getMethods(oclass, this.targetMethodName); +// +// if (amethod.length <= 0) { +// Config.log("(Reflector) Method not present: " + oclass.getName() + "." + this.targetMethodName); +// return null; +// } +// +// if (amethod.length > 1) { +// Config.warn("(Reflector) More than one method found: " + oclass.getName() + "." + this.targetMethodName); +// +// for (int i = 0; i < amethod.length; ++i) { +// Method method = amethod[i]; +// Config.warn("(Reflector) - " + method); +// } +// +// return null; +// } +// +// this.targetMethod = amethod[0]; +// } else { +// this.targetMethod = getMethod(oclass, this.targetMethodName, this.targetMethodParameterTypes); +// } +// +// if (this.targetMethod == null) { +// Config.log("(Reflector) Method not present: " + oclass.getName() + "." + this.targetMethodName); +// return null; +// } else { +// this.targetMethod.setAccessible(true); +// return this.targetMethod; +// } +// } catch (Throwable throwable) { +// throwable.printStackTrace(); +// return null; +// } +// } +// } +// } +// +// public boolean exists() { +// return this.checked ? this.targetMethod != null : this.getTargetMethod() != null; +// } +// +// public Class getReturnType() { +// Method method = this.getTargetMethod(); +// return method == null ? null : method.getReturnType(); +// } +// +// public void deactivate() { +// this.checked = true; +// this.targetMethod = null; +// } +// +// public Object call(Object...params) { +// return Reflector.call(this, params); +// } +// +// public boolean callBoolean(Object...params) { +// return Reflector.callBoolean(this, params); +// } +// +// public int callInt(Object...params) { +// return Reflector.callInt(this, params); +// } +// +// public float callFloat(Object...params) { +// return Reflector.callFloat(this, params); +// } +// +// public double callDouble(Object...params) { +// return Reflector.callDouble(this, params); +// } +// +// public String callString(Object...params) { +// return Reflector.callString(this, params); +// } +// +// public Object call(Object param) { +// return Reflector.call(this, new Object[] { +// param +// }); +// } +// +// public boolean callBoolean(Object param) { +// return Reflector.callBoolean(this, new Object[] { +// param +// }); +// } +// +// public int callInt(Object param) { +// return Reflector.callInt(this, new Object[] { +// param +// }); +// } +// +// public float callFloat(Object param) { +// return Reflector.callFloat(this, new Object[] { +// param +// }); +// } +// +// public double callDouble(Object param) { +// return Reflector.callDouble(this, new Object[] { +// param +// }); +// } +// +// public String callString1(Object param) { +// return Reflector.callString(this, new Object[] { +// param +// }); +// } +// +// public void callVoid(Object...params) { +// Reflector.callVoid(this, params); +// } +// +// public static Method getMethod(Class cls, String methodName, Class[] paramTypes) { +// Method[] amethod = cls.getDeclaredMethods(); +// +// for (int i = 0; i < amethod.length; ++i) { +// Method method = amethod[i]; +// +// if (method.getName().equals(methodName)) { +// Class[] aclass = method.getParameterTypes(); +// +// if (Reflector.matchesTypes(paramTypes, aclass)) { +// return method; +// } +// } +// } +// +// return null; +// } +// +// public static Method[] getMethods(Class cls, String methodName) { +// List list = new ArrayList(); +// Method[] amethod = cls.getDeclaredMethods(); +// +// for (int i = 0; i < amethod.length; ++i) { +// Method method = amethod[i]; +// +// if (method.getName().equals(methodName)) { +// list.add(method); +// } +// } +// +// Method[] amethod1 = (Method[])((Method[]) list.toArray(new Method[list.size()])); +// return amethod1; +// } +// +// public void resolve() { +// Method method = this.getTargetMethod(); +// } +//} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorRaw.java b/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorRaw.java index 9601fc5..8935957 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorRaw.java +++ b/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorRaw.java @@ -1,157 +1,157 @@ -package net.PeytonPlayz585.shadow.reflect; - -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class ReflectorRaw { - public static Field getField(Class cls, Class fieldType) { - try { - Field[] afield = cls.getDeclaredFields(); - - for (int i = 0; i < afield.length; ++i) { - Field field = afield[i]; - - if (field.getType() == fieldType) { - field.setAccessible(true); - return field; - } - } - - return null; - } catch (Exception var5) { - return null; - } - } - - public static Field[] getFields(Class cls, Class fieldType) { - try { - Field[] afield = cls.getDeclaredFields(); - return getFields(afield, fieldType); - } catch (Exception var3) { - return null; - } - } - - public static Field[] getFields(Field[] fields, Class fieldType) { - try { - List list = new ArrayList(); - - for (int i = 0; i < fields.length; ++i) { - Field field = fields[i]; - - if (field.getType() == fieldType) { - field.setAccessible(true); - list.add(field); - } - } - - Field[] afield = (Field[])((Field[]) list.toArray(new Field[list.size()])); - return afield; - } catch (Exception var5) { - return null; - } - } - - public static Field[] getFieldsAfter(Class cls, Field field, Class fieldType) { - try { - Field[] afield = cls.getDeclaredFields(); - List < Field > list = Arrays. < Field > asList(afield); - int i = list.indexOf(field); - - if (i < 0) { - return new Field[0]; - } else { - List < Field > list1 = list.subList(i + 1, list.size()); - Field[] afield1 = (Field[])((Field[]) list1.toArray(new Field[list1.size()])); - return getFields(afield1, fieldType); - } - } catch (Exception var8) { - return null; - } - } - - public static Field[] getFields(Object obj, Field[] fields, Class fieldType, Object value) { - try { - List < Field > list = new ArrayList(); - - for (int i = 0; i < fields.length; ++i) { - Field field = fields[i]; - - if (field.getType() == fieldType) { - boolean flag = Modifier.isStatic(field.getModifiers()); - - if ((obj != null || flag) && (obj == null || !flag)) { - field.setAccessible(true); - Object object = field.get(obj); - - if (object == value) { - list.add(field); - } else if (object != null && value != null && object.equals(value)) { - list.add(field); - } - } - } - } - - Field[] afield = (Field[])((Field[]) list.toArray(new Field[list.size()])); - return afield; - } catch (Exception var9) { - return null; - } - } - - public static Field getField(Class cls, Class fieldType, int index) { - Field[] afield = getFields(cls, fieldType); - return index >= 0 && index < afield.length ? afield[index] : null; - } - - public static Field getFieldAfter(Class cls, Field field, Class fieldType, int index) { - Field[] afield = getFieldsAfter(cls, field, fieldType); - return index >= 0 && index < afield.length ? afield[index] : null; - } - - public static Object getFieldValue(Object obj, Class cls, Class fieldType) { - ReflectorField reflectorfield = getReflectorField(cls, fieldType); - return reflectorfield == null ? null : (!reflectorfield.exists() ? null : Reflector.getFieldValue(obj, reflectorfield)); - } - - public static Object getFieldValue(Object obj, Class cls, Class fieldType, int index) { - ReflectorField reflectorfield = getReflectorField(cls, fieldType, index); - return reflectorfield == null ? null : (!reflectorfield.exists() ? null : Reflector.getFieldValue(obj, reflectorfield)); - } - - public static boolean setFieldValue(Object obj, Class cls, Class fieldType, Object value) { - ReflectorField reflectorfield = getReflectorField(cls, fieldType); - return reflectorfield == null ? false : (!reflectorfield.exists() ? false : Reflector.setFieldValue(obj, reflectorfield, value)); - } - - public static boolean setFieldValue(Object obj, Class cls, Class fieldType, int index, Object value) { - ReflectorField reflectorfield = getReflectorField(cls, fieldType, index); - return reflectorfield == null ? false : (!reflectorfield.exists() ? false : Reflector.setFieldValue(obj, reflectorfield, value)); - } - - public static ReflectorField getReflectorField(Class cls, Class fieldType) { - Field field = getField(cls, fieldType); - - if (field == null) { - return null; - } else { - ReflectorClass reflectorclass = new ReflectorClass(cls); - return new ReflectorField(reflectorclass, field.getName()); - } - } - - public static ReflectorField getReflectorField(Class cls, Class fieldType, int index) { - Field field = getField(cls, fieldType, index); - - if (field == null) { - return null; - } else { - ReflectorClass reflectorclass = new ReflectorClass(cls); - return new ReflectorField(reflectorclass, field.getName()); - } - } -} \ No newline at end of file +//package net.PeytonPlayz585.shadow.reflect; +// +//import java.lang.reflect.Field; +//import java.lang.reflect.Modifier; +//import java.util.ArrayList; +//import java.util.Arrays; +//import java.util.List; +// +//public class ReflectorRaw { +// public static Field getField(Class cls, Class fieldType) { +// try { +// Field[] afield = cls.getDeclaredFields(); +// +// for (int i = 0; i < afield.length; ++i) { +// Field field = afield[i]; +// +// if (field.getType() == fieldType) { +// field.setAccessible(true); +// return field; +// } +// } +// +// return null; +// } catch (Exception var5) { +// return null; +// } +// } +// +// public static Field[] getFields(Class cls, Class fieldType) { +// try { +// Field[] afield = cls.getDeclaredFields(); +// return getFields(afield, fieldType); +// } catch (Exception var3) { +// return null; +// } +// } +// +// public static Field[] getFields(Field[] fields, Class fieldType) { +// try { +// List list = new ArrayList(); +// +// for (int i = 0; i < fields.length; ++i) { +// Field field = fields[i]; +// +// if (field.getType() == fieldType) { +// field.setAccessible(true); +// list.add(field); +// } +// } +// +// Field[] afield = (Field[])((Field[]) list.toArray(new Field[list.size()])); +// return afield; +// } catch (Exception var5) { +// return null; +// } +// } +// +// public static Field[] getFieldsAfter(Class cls, Field field, Class fieldType) { +// try { +// Field[] afield = cls.getDeclaredFields(); +// List < Field > list = Arrays. < Field > asList(afield); +// int i = list.indexOf(field); +// +// if (i < 0) { +// return new Field[0]; +// } else { +// List < Field > list1 = list.subList(i + 1, list.size()); +// Field[] afield1 = (Field[])((Field[]) list1.toArray(new Field[list1.size()])); +// return getFields(afield1, fieldType); +// } +// } catch (Exception var8) { +// return null; +// } +// } +// +// public static Field[] getFields(Object obj, Field[] fields, Class fieldType, Object value) { +// try { +// List < Field > list = new ArrayList(); +// +// for (int i = 0; i < fields.length; ++i) { +// Field field = fields[i]; +// +// if (field.getType() == fieldType) { +// boolean flag = Modifier.isStatic(field.getModifiers()); +// +// if ((obj != null || flag) && (obj == null || !flag)) { +// field.setAccessible(true); +// Object object = field.get(obj); +// +// if (object == value) { +// list.add(field); +// } else if (object != null && value != null && object.equals(value)) { +// list.add(field); +// } +// } +// } +// } +// +// Field[] afield = (Field[])((Field[]) list.toArray(new Field[list.size()])); +// return afield; +// } catch (Exception var9) { +// return null; +// } +// } +// +// public static Field getField(Class cls, Class fieldType, int index) { +// Field[] afield = getFields(cls, fieldType); +// return index >= 0 && index < afield.length ? afield[index] : null; +// } +// +// public static Field getFieldAfter(Class cls, Field field, Class fieldType, int index) { +// Field[] afield = getFieldsAfter(cls, field, fieldType); +// return index >= 0 && index < afield.length ? afield[index] : null; +// } +// +// public static Object getFieldValue(Object obj, Class cls, Class fieldType) { +// ReflectorField reflectorfield = getReflectorField(cls, fieldType); +// return reflectorfield == null ? null : (!reflectorfield.exists() ? null : Reflector.getFieldValue(obj, reflectorfield)); +// } +// +// public static Object getFieldValue(Object obj, Class cls, Class fieldType, int index) { +// ReflectorField reflectorfield = getReflectorField(cls, fieldType, index); +// return reflectorfield == null ? null : (!reflectorfield.exists() ? null : Reflector.getFieldValue(obj, reflectorfield)); +// } +// +// public static boolean setFieldValue(Object obj, Class cls, Class fieldType, Object value) { +// ReflectorField reflectorfield = getReflectorField(cls, fieldType); +// return reflectorfield == null ? false : (!reflectorfield.exists() ? false : Reflector.setFieldValue(obj, reflectorfield, value)); +// } +// +// public static boolean setFieldValue(Object obj, Class cls, Class fieldType, int index, Object value) { +// ReflectorField reflectorfield = getReflectorField(cls, fieldType, index); +// return reflectorfield == null ? false : (!reflectorfield.exists() ? false : Reflector.setFieldValue(obj, reflectorfield, value)); +// } +// +// public static ReflectorField getReflectorField(Class cls, Class fieldType) { +// Field field = getField(cls, fieldType); +// +// if (field == null) { +// return null; +// } else { +// ReflectorClass reflectorclass = new ReflectorClass(cls); +// return new ReflectorField(reflectorclass, field.getName()); +// } +// } +// +// public static ReflectorField getReflectorField(Class cls, Class fieldType, int index) { +// Field field = getField(cls, fieldType, index); +// +// if (field == null) { +// return null; +// } else { +// ReflectorClass reflectorclass = new ReflectorClass(cls); +// return new ReflectorField(reflectorclass, field.getName()); +// } +// } +//} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorResolver.java b/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorResolver.java index e2144da..e2597b1 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorResolver.java +++ b/src/main/java/net/PeytonPlayz585/shadow/reflect/ReflectorResolver.java @@ -1,28 +1,28 @@ -package net.PeytonPlayz585.shadow.reflect; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class ReflectorResolver { - private static final List < IResolvable > RESOLVABLES = Collections. < IResolvable > synchronizedList(new ArrayList()); - private static boolean resolved = false; - - protected static void register(IResolvable resolvable) { - if (!resolved) { - RESOLVABLES.add(resolvable); - } else { - resolvable.resolve(); - } - } - - public static void resolve() { - if (!resolved) { - for (IResolvable iresolvable: RESOLVABLES) { - iresolvable.resolve(); - } - - resolved = true; - } - } -} \ No newline at end of file +//package net.PeytonPlayz585.shadow.reflect; +// +//import java.util.ArrayList; +//import java.util.Collections; +//import java.util.List; +// +//public class ReflectorResolver { +// private static final List < IResolvable > RESOLVABLES = Collections. < IResolvable > synchronizedList(new ArrayList()); +// private static boolean resolved = false; +// +// protected static void register(IResolvable resolvable) { +// if (!resolved) { +// RESOLVABLES.add(resolvable); +// } else { +// resolvable.resolve(); +// } +// } +// +// public static void resolve() { +// if (!resolved) { +// for (IResolvable iresolvable: RESOLVABLES) { +// iresolvable.resolve(); +// } +// +// resolved = true; +// } +// } +//} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/SimpleResource.java b/src/main/java/net/minecraft/client/resources/SimpleResource.java index 675d0c5..8d92657 100644 --- a/src/main/java/net/minecraft/client/resources/SimpleResource.java +++ b/src/main/java/net/minecraft/client/resources/SimpleResource.java @@ -10,6 +10,7 @@ import org.json.JSONObject; import com.google.common.collect.Maps; +import net.PeytonPlayz585.shadow.json.JSONUtils; import net.lax1dude.eaglercraft.v1_8.IOUtils; import net.minecraft.client.resources.data.IMetadataSection; import net.minecraft.client.resources.data.IMetadataSerializer; @@ -89,11 +90,20 @@ public class SimpleResource implements IResource { try { imetadatasection = this.srMetadataSerializer.parseMetadataSection(s, this.mcmetaJson); } catch(Exception e) { - //Temp fix, no frame time :( - imetadatasection = this.srMetadataSerializer.parseMetadataSection(s, new JSONObject("{\"animation\":{}}")); + if(this.srResourceLocation.toString().contains("mcpatcher") || this.srResourceLocation.toString().contains("optifine")) { + try { + imetadatasection = JSONUtils.fixJson(mcmetaJson.toString()); + mapMetadataSections.put(s, imetadatasection); + } catch(Exception e1) { + //Return it anyways lol + return (T) imetadatasection; + } + } else { + //Return it anyways lol + return (T) imetadatasection; + } } } - return (T) imetadatasection; } }