Permanent fix for custom items, remove reflections

This commit is contained in:
PeytonPlayz595 2024-04-14 18:52:09 -04:00
parent 35c95f2aad
commit 77c5c24a18
19 changed files with 1486 additions and 1430 deletions

View File

@ -3,14 +3,12 @@ package net.PeytonPlayz585.shadow;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import net.PeytonPlayz585.shadow.reflect.Reflector;
import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime; import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager; import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger; import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
@ -428,7 +426,8 @@ public class Config {
public static DefaultResourcePack getDefaultResourcePack() { public static DefaultResourcePack getDefaultResourcePack() {
if (defaultResourcePackLazy == null) { if (defaultResourcePackLazy == null) {
Minecraft minecraft = Minecraft.getMinecraft(); 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) { if (defaultResourcePackLazy == null) {
ResourcePackRepository resourcepackrepository = minecraft.getResourcePackRepository(); ResourcePackRepository resourcepackrepository = minecraft.getResourcePackRepository();

View File

@ -1,6 +1,5 @@
package net.PeytonPlayz585.shadow; package net.PeytonPlayz585.shadow;
import java.awt.image.BufferedImage;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -12,10 +11,10 @@ import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.Random; import java.util.Random;
import java.util.Set; import java.util.Set;
import javax.imageio.ImageIO;
import net.PeytonPlayz585.shadow.apache.ImmutablePair; import net.PeytonPlayz585.shadow.apache.ImmutablePair;
import net.PeytonPlayz585.shadow.apache.Pair; import net.PeytonPlayz585.shadow.apache.Pair;
import net.lax1dude.eaglercraft.v1_8.opengl.ImageData;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockRedstoneWire; import net.minecraft.block.BlockRedstoneWire;
import net.minecraft.block.BlockStem; import net.minecraft.block.BlockStem;
@ -26,6 +25,7 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX; import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.EnumDyeColor; import net.minecraft.item.EnumDyeColor;
@ -360,9 +360,9 @@ public class CustomColors {
if (inputstream == null) { if (inputstream == null) {
return defHeight; return defHeight;
} else { } else {
BufferedImage bufferedimage = ImageIO.read(inputstream); ImageData bufferedimage = TextureUtil.readBufferedImage(inputstream);
inputstream.close(); inputstream.close();
return bufferedimage == null ? defHeight : bufferedimage.getHeight(); return bufferedimage == null ? defHeight : bufferedimage.height;
} }
} catch (IOException var4) { } catch (IOException var4) {
return defHeight; return defHeight;

View File

@ -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 extends IMetadataSection> 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<AnimationFrame> list = new ArrayList<AnimationFrame>();
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;
}
}

View File

@ -1,47 +1,47 @@
package net.PeytonPlayz585.shadow.reflect; //package net.PeytonPlayz585.shadow.reflect;
//
import java.lang.reflect.Field; //import java.lang.reflect.Field;
import java.util.Arrays; //import java.util.Arrays;
import java.util.HashSet; //import java.util.HashSet;
import java.util.Set; //import java.util.Set;
//
import net.PeytonPlayz585.shadow.Config; //import net.PeytonPlayz585.shadow.Config;
import net.minecraft.client.Minecraft; //import net.minecraft.client.Minecraft;
//
public class FieldLocatorActionKeyF3 implements IFieldLocator { //public class FieldLocatorActionKeyF3 implements IFieldLocator {
public Field getField() { // public Field getField() {
Class oclass = Minecraft.class; // Class oclass = Minecraft.class;
Field field = this.getFieldRenderChunksMany(); // Field field = this.getFieldRenderChunksMany();
//
if (field == null) { // if (field == null) {
Config.log("(Reflector) Field not present: " + oclass.getName() + ".actionKeyF3 (field renderChunksMany not found)"); // Config.log("(Reflector) Field not present: " + oclass.getName() + ".actionKeyF3 (field renderChunksMany not found)");
return null; // return null;
} else { // } else {
Field field1 = ReflectorRaw.getFieldAfter(Minecraft.class, field, Boolean.TYPE, 0); // Field field1 = ReflectorRaw.getFieldAfter(Minecraft.class, field, Boolean.TYPE, 0);
//
if (field1 == null) { // if (field1 == null) {
Config.log("(Reflector) Field not present: " + oclass.getName() + ".actionKeyF3"); // Config.log("(Reflector) Field not present: " + oclass.getName() + ".actionKeyF3");
return null; // return null;
} else { // } else {
return field1; // return field1;
} // }
} // }
} // }
//
private Field getFieldRenderChunksMany() { // private Field getFieldRenderChunksMany() {
Minecraft minecraft = Minecraft.getMinecraft(); // Minecraft minecraft = Minecraft.getMinecraft();
boolean flag = minecraft.renderChunksMany; // boolean flag = minecraft.renderChunksMany;
Field[] afield = Minecraft.class.getDeclaredFields(); // Field[] afield = Minecraft.class.getDeclaredFields();
minecraft.renderChunksMany = true; // minecraft.renderChunksMany = true;
Field[] afield1 = ReflectorRaw.getFields(minecraft, afield, Boolean.TYPE, Boolean.TRUE); // Field[] afield1 = ReflectorRaw.getFields(minecraft, afield, Boolean.TYPE, Boolean.TRUE);
minecraft.renderChunksMany = false; // minecraft.renderChunksMany = false;
Field[] afield2 = ReflectorRaw.getFields(minecraft, afield, Boolean.TYPE, Boolean.FALSE); // Field[] afield2 = ReflectorRaw.getFields(minecraft, afield, Boolean.TYPE, Boolean.FALSE);
minecraft.renderChunksMany = flag; // minecraft.renderChunksMany = flag;
Set < Field > set = new HashSet(Arrays.asList(afield1)); // Set < Field > set = new HashSet(Arrays.asList(afield1));
Set < Field > set1 = new HashSet(Arrays.asList(afield2)); // Set < Field > set1 = new HashSet(Arrays.asList(afield2));
Set < Field > set2 = new HashSet(set); // Set < Field > set2 = new HashSet(set);
set2.retainAll(set1); // set2.retainAll(set1);
Field[] afield3 = (Field[])((Field[]) set2.toArray(new Field[set2.size()])); // Field[] afield3 = (Field[])((Field[]) set2.toArray(new Field[set2.size()]));
return afield3.length != 1 ? null : afield3[0]; // return afield3.length != 1 ? null : afield3[0];
} // }
} //}

View File

@ -1,15 +1,15 @@
package net.PeytonPlayz585.shadow.reflect; //package net.PeytonPlayz585.shadow.reflect;
//
import java.lang.reflect.Field; //import java.lang.reflect.Field;
//
public class FieldLocatorFixed implements IFieldLocator { //public class FieldLocatorFixed implements IFieldLocator {
private Field field; // private Field field;
//
public FieldLocatorFixed(Field field) { // public FieldLocatorFixed(Field field) {
this.field = field; // this.field = field;
} // }
//
public Field getField() { // public Field getField() {
return this.field; // return this.field;
} // }
} //}

View File

@ -1,56 +1,56 @@
package net.PeytonPlayz585.shadow.reflect; //package net.PeytonPlayz585.shadow.reflect;
//
import java.lang.reflect.Field; //import java.lang.reflect.Field;
//
import net.PeytonPlayz585.shadow.Config; //import net.PeytonPlayz585.shadow.Config;
//
public class FieldLocatorName implements IFieldLocator { //public class FieldLocatorName implements IFieldLocator {
private ReflectorClass reflectorClass = null; // private ReflectorClass reflectorClass = null;
private String targetFieldName = null; // private String targetFieldName = null;
//
public FieldLocatorName(ReflectorClass reflectorClass, String targetFieldName) { // public FieldLocatorName(ReflectorClass reflectorClass, String targetFieldName) {
this.reflectorClass = reflectorClass; // this.reflectorClass = reflectorClass;
this.targetFieldName = targetFieldName; // this.targetFieldName = targetFieldName;
} // }
//
public Field getField() { // public Field getField() {
Class oclass = this.reflectorClass.getTargetClass(); // Class oclass = this.reflectorClass.getTargetClass();
//
if (oclass == null) { // if (oclass == null) {
return null; // return null;
} else { // } else {
try { // try {
Field field = this.getDeclaredField(oclass, this.targetFieldName); // Field field = this.getDeclaredField(oclass, this.targetFieldName);
field.setAccessible(true); // field.setAccessible(true);
return field; // return field;
} catch (NoSuchFieldException var3) { // } catch (NoSuchFieldException var3) {
Config.log("(Reflector) Field not present: " + oclass.getName() + "." + this.targetFieldName); // Config.log("(Reflector) Field not present: " + oclass.getName() + "." + this.targetFieldName);
return null; // return null;
} catch (SecurityException securityexception) { // } catch (SecurityException securityexception) {
securityexception.printStackTrace(); // securityexception.printStackTrace();
return null; // return null;
} catch (Throwable throwable) { // } catch (Throwable throwable) {
throwable.printStackTrace(); // throwable.printStackTrace();
return null; // return null;
} // }
} // }
} // }
//
private Field getDeclaredField(Class cls, String name) throws NoSuchFieldException { // private Field getDeclaredField(Class cls, String name) throws NoSuchFieldException {
Field[] afield = cls.getDeclaredFields(); // Field[] afield = cls.getDeclaredFields();
//
for (int i = 0; i < afield.length; ++i) { // for (int i = 0; i < afield.length; ++i) {
Field field = afield[i]; // Field field = afield[i];
//
if (field.getName().equals(name)) { // if (field.getName().equals(name)) {
return field; // return field;
} // }
} // }
//
if (cls == Object.class) { // if (cls == Object.class) {
throw new NoSuchFieldException(name); // throw new NoSuchFieldException(name);
} else { // } else {
return this.getDeclaredField(cls.getSuperclass(), name); // return this.getDeclaredField(cls.getSuperclass(), name);
} // }
} // }
} //}

View File

@ -1,58 +1,58 @@
package net.PeytonPlayz585.shadow.reflect; //package net.PeytonPlayz585.shadow.reflect;
//
import java.lang.reflect.Field; //import java.lang.reflect.Field;
//
import net.PeytonPlayz585.shadow.Config; //import net.PeytonPlayz585.shadow.Config;
//
public class FieldLocatorType implements IFieldLocator { //public class FieldLocatorType implements IFieldLocator {
private ReflectorClass reflectorClass; // private ReflectorClass reflectorClass;
private Class targetFieldType; // private Class targetFieldType;
private int targetFieldIndex; // private int targetFieldIndex;
//
public FieldLocatorType(ReflectorClass reflectorClass, Class targetFieldType) { // public FieldLocatorType(ReflectorClass reflectorClass, Class targetFieldType) {
this(reflectorClass, targetFieldType, 0); // this(reflectorClass, targetFieldType, 0);
} // }
//
public FieldLocatorType(ReflectorClass reflectorClass, Class targetFieldType, int targetFieldIndex) { // public FieldLocatorType(ReflectorClass reflectorClass, Class targetFieldType, int targetFieldIndex) {
this.reflectorClass = null; // this.reflectorClass = null;
this.targetFieldType = null; // this.targetFieldType = null;
this.reflectorClass = reflectorClass; // this.reflectorClass = reflectorClass;
this.targetFieldType = targetFieldType; // this.targetFieldType = targetFieldType;
this.targetFieldIndex = targetFieldIndex; // this.targetFieldIndex = targetFieldIndex;
} // }
//
public Field getField() { // public Field getField() {
Class oclass = this.reflectorClass.getTargetClass(); // Class oclass = this.reflectorClass.getTargetClass();
//
if (oclass == null) { // if (oclass == null) {
return null; // return null;
} else { // } else {
try { // try {
Field[] afield = oclass.getDeclaredFields(); // Field[] afield = oclass.getDeclaredFields();
int i = 0; // int i = 0;
//
for (int j = 0; j < afield.length; ++j) { // for (int j = 0; j < afield.length; ++j) {
Field field = afield[j]; // Field field = afield[j];
//
if (field.getType() == this.targetFieldType) { // if (field.getType() == this.targetFieldType) {
if (i == this.targetFieldIndex) { // if (i == this.targetFieldIndex) {
field.setAccessible(true); // field.setAccessible(true);
return field; // return field;
} // }
//
++i; // ++i;
} // }
} // }
//
Config.log("(Reflector) Field not present: " + oclass.getName() + ".(type: " + this.targetFieldType + ", index: " + this.targetFieldIndex + ")"); // Config.log("(Reflector) Field not present: " + oclass.getName() + ".(type: " + this.targetFieldType + ", index: " + this.targetFieldIndex + ")");
return null; // return null;
} catch (SecurityException securityexception) { // } catch (SecurityException securityexception) {
securityexception.printStackTrace(); // securityexception.printStackTrace();
return null; // return null;
} catch (Throwable throwable) { // } catch (Throwable throwable) {
throwable.printStackTrace(); // throwable.printStackTrace();
return null; // return null;
} // }
} // }
} // }
} //}

View File

@ -1,46 +1,46 @@
package net.PeytonPlayz585.shadow.reflect; //package net.PeytonPlayz585.shadow.reflect;
//
import java.lang.reflect.Field; //import java.lang.reflect.Field;
import java.util.ArrayList; //import java.util.ArrayList;
import java.util.Arrays; //import java.util.Arrays;
import java.util.Collections; //import java.util.Collections;
import java.util.List; //import java.util.List;
//
import net.PeytonPlayz585.shadow.Config; //import net.PeytonPlayz585.shadow.Config;
//
public class FieldLocatorTypes implements IFieldLocator { //public class FieldLocatorTypes implements IFieldLocator {
private Field field = null; // private Field field = null;
//
public FieldLocatorTypes(Class cls, Class[] preTypes, Class type, Class[] postTypes, String errorName) { // public FieldLocatorTypes(Class cls, Class[] preTypes, Class type, Class[] postTypes, String errorName) {
Field[] afield = cls.getDeclaredFields(); // Field[] afield = cls.getDeclaredFields();
List < Class > list = new ArrayList(); // List < Class > list = new ArrayList();
//
for (int i = 0; i < afield.length; ++i) { // for (int i = 0; i < afield.length; ++i) {
Field field = afield[i]; // Field field = afield[i];
list.add(field.getType()); // list.add(field.getType());
} // }
//
List < Class > list1 = new ArrayList(); // List < Class > list1 = new ArrayList();
list1.addAll(Arrays. < Class > asList(preTypes)); // list1.addAll(Arrays. < Class > asList(preTypes));
list1.add(type); // list1.add(type);
list1.addAll(Arrays. < Class > asList(postTypes)); // list1.addAll(Arrays. < Class > asList(postTypes));
int l = Collections.indexOfSubList(list, list1); // int l = Collections.indexOfSubList(list, list1);
//
if (l < 0) { // if (l < 0) {
Config.log("(Reflector) Field not found: " + errorName); // Config.log("(Reflector) Field not found: " + errorName);
} else { // } else {
int j = Collections.indexOfSubList(list.subList(l + 1, list.size()), list1); // int j = Collections.indexOfSubList(list.subList(l + 1, list.size()), list1);
//
if (j >= 0) { // if (j >= 0) {
Config.log("(Reflector) More than one match found for field: " + errorName); // Config.log("(Reflector) More than one match found for field: " + errorName);
} else { // } else {
int k = l + preTypes.length; // int k = l + preTypes.length;
this.field = afield[k]; // this.field = afield[k];
} // }
} // }
} // }
//
public Field getField() { // public Field getField() {
return this.field; // return this.field;
} // }
} //}

View File

@ -1,7 +1,7 @@
package net.PeytonPlayz585.shadow.reflect; //package net.PeytonPlayz585.shadow.reflect;
//
import java.lang.reflect.Field; //import java.lang.reflect.Field;
//
public interface IFieldLocator { //public interface IFieldLocator {
Field getField(); // Field getField();
} //}

View File

@ -1,5 +1,5 @@
package net.PeytonPlayz585.shadow.reflect; //package net.PeytonPlayz585.shadow.reflect;
//
public interface IResolvable { //public interface IResolvable {
void resolve(); // void resolve();
} //}

File diff suppressed because it is too large Load Diff

View File

@ -1,66 +1,66 @@
package net.PeytonPlayz585.shadow.reflect; //package net.PeytonPlayz585.shadow.reflect;
//
import net.PeytonPlayz585.shadow.Config; //import net.PeytonPlayz585.shadow.Config;
//
public class ReflectorClass implements IResolvable { //public class ReflectorClass implements IResolvable {
private String targetClassName = null; // private String targetClassName = null;
private boolean checked = false; // private boolean checked = false;
private Class targetClass = null; // private Class targetClass = null;
//
public ReflectorClass(String targetClassName) { // public ReflectorClass(String targetClassName) {
this.targetClassName = targetClassName; // this.targetClassName = targetClassName;
ReflectorResolver.register(this); // ReflectorResolver.register(this);
} // }
//
public ReflectorClass(Class targetClass) { // public ReflectorClass(Class targetClass) {
this.targetClass = targetClass; // this.targetClass = targetClass;
this.targetClassName = targetClass.getName(); // this.targetClassName = targetClass.getName();
this.checked = true; // this.checked = true;
} // }
//
public Class getTargetClass() { // public Class getTargetClass() {
if (this.checked) { // if (this.checked) {
return this.targetClass; // return this.targetClass;
} else { // } else {
this.checked = true; // this.checked = true;
//
try { // try {
this.targetClass = Class.forName(this.targetClassName); // this.targetClass = Class.forName(this.targetClassName);
} catch (ClassNotFoundException var2) { // } catch (ClassNotFoundException var2) {
Config.log("(Reflector) Class not present: " + this.targetClassName); // Config.log("(Reflector) Class not present: " + this.targetClassName);
} catch (Throwable throwable) { // } catch (Throwable throwable) {
throwable.printStackTrace(); // throwable.printStackTrace();
} // }
//
return this.targetClass; // return this.targetClass;
} // }
} // }
//
public boolean exists() { // public boolean exists() {
return this.getTargetClass() != null; // return this.getTargetClass() != null;
} // }
//
public String getTargetClassName() { // public String getTargetClassName() {
return this.targetClassName; // return this.targetClassName;
} // }
//
public boolean isInstance(Object obj) { // public boolean isInstance(Object obj) {
return this.getTargetClass() == null ? false : this.getTargetClass().isInstance(obj); // return this.getTargetClass() == null ? false : this.getTargetClass().isInstance(obj);
} // }
//
public ReflectorField makeField(String name) { // public ReflectorField makeField(String name) {
return new ReflectorField(this, name); // return new ReflectorField(this, name);
} // }
//
public ReflectorMethod makeMethod(String name) { // public ReflectorMethod makeMethod(String name) {
return new ReflectorMethod(this, name); // return new ReflectorMethod(this, name);
} // }
//
public ReflectorMethod makeMethod(String name, Class[] paramTypes) { // public ReflectorMethod makeMethod(String name, Class[] paramTypes) {
return new ReflectorMethod(this, name, paramTypes); // return new ReflectorMethod(this, name, paramTypes);
} // }
//
public void resolve() { // public void resolve() {
Class oclass = this.getTargetClass(); // Class oclass = this.getTargetClass();
} // }
} //}

View File

@ -1,80 +1,80 @@
package net.PeytonPlayz585.shadow.reflect; //package net.PeytonPlayz585.shadow.reflect;
//
import java.lang.reflect.Constructor; //import java.lang.reflect.Constructor;
//
import net.PeytonPlayz585.shadow.ArrayUtils; //import net.PeytonPlayz585.shadow.ArrayUtils;
import net.PeytonPlayz585.shadow.Config; //import net.PeytonPlayz585.shadow.Config;
//
public class ReflectorConstructor implements IResolvable { //public class ReflectorConstructor implements IResolvable {
private ReflectorClass reflectorClass = null; // private ReflectorClass reflectorClass = null;
private Class[] parameterTypes = null; // private Class[] parameterTypes = null;
private boolean checked = false; // private boolean checked = false;
private Constructor targetConstructor = null; // private Constructor targetConstructor = null;
//
public ReflectorConstructor(ReflectorClass reflectorClass, Class[] parameterTypes) { // public ReflectorConstructor(ReflectorClass reflectorClass, Class[] parameterTypes) {
this.reflectorClass = reflectorClass; // this.reflectorClass = reflectorClass;
this.parameterTypes = parameterTypes; // this.parameterTypes = parameterTypes;
ReflectorResolver.register(this); // ReflectorResolver.register(this);
} // }
//
public Constructor getTargetConstructor() { // public Constructor getTargetConstructor() {
if (this.checked) { // if (this.checked) {
return this.targetConstructor; // return this.targetConstructor;
} else { // } else {
this.checked = true; // this.checked = true;
Class oclass = this.reflectorClass.getTargetClass(); // Class oclass = this.reflectorClass.getTargetClass();
//
if (oclass == null) { // if (oclass == null) {
return null; // return null;
} else { // } else {
try { // try {
this.targetConstructor = findConstructor(oclass, this.parameterTypes); // this.targetConstructor = findConstructor(oclass, this.parameterTypes);
//
if (this.targetConstructor == null) { // if (this.targetConstructor == null) {
Config.dbg("(Reflector) Constructor not present: " + oclass.getName() + ", params: " + ArrayUtils.arrayToString((Object[]) this.parameterTypes)); // Config.dbg("(Reflector) Constructor not present: " + oclass.getName() + ", params: " + ArrayUtils.arrayToString((Object[]) this.parameterTypes));
} // }
//
if (this.targetConstructor != null) { // if (this.targetConstructor != null) {
this.targetConstructor.setAccessible(true); // this.targetConstructor.setAccessible(true);
} // }
} catch (Throwable throwable) { // } catch (Throwable throwable) {
throwable.printStackTrace(); // throwable.printStackTrace();
} // }
//
return this.targetConstructor; // return this.targetConstructor;
} // }
} // }
} // }
//
private static Constructor findConstructor(Class cls, Class[] paramTypes) { // private static Constructor findConstructor(Class cls, Class[] paramTypes) {
Constructor[] aconstructor = cls.getDeclaredConstructors(); // Constructor[] aconstructor = cls.getDeclaredConstructors();
//
for (int i = 0; i < aconstructor.length; ++i) { // for (int i = 0; i < aconstructor.length; ++i) {
Constructor constructor = aconstructor[i]; // Constructor constructor = aconstructor[i];
Class[] aclass = constructor.getParameterTypes(); // Class[] aclass = constructor.getParameterTypes();
//
if (Reflector.matchesTypes(paramTypes, aclass)) { // if (Reflector.matchesTypes(paramTypes, aclass)) {
return constructor; // return constructor;
} // }
} // }
//
return null; // return null;
} // }
//
public boolean exists() { // public boolean exists() {
return this.checked ? this.targetConstructor != null : this.getTargetConstructor() != null; // return this.checked ? this.targetConstructor != null : this.getTargetConstructor() != null;
} // }
//
public void deactivate() { // public void deactivate() {
this.checked = true; // this.checked = true;
this.targetConstructor = null; // this.targetConstructor = null;
} // }
//
public Object newInstance(Object...params) { // public Object newInstance(Object...params) {
return Reflector.newInstance(this, params); // return Reflector.newInstance(this, params);
} // }
//
public void resolve() { // public void resolve() {
Constructor constructor = this.getTargetConstructor(); // Constructor constructor = this.getTargetConstructor();
} // }
} //}

View File

@ -1,68 +1,68 @@
package net.PeytonPlayz585.shadow.reflect; //package net.PeytonPlayz585.shadow.reflect;
//
import java.lang.reflect.Field; //import java.lang.reflect.Field;
//
public class ReflectorField implements IResolvable { //public class ReflectorField implements IResolvable {
private IFieldLocator fieldLocator; // private IFieldLocator fieldLocator;
private boolean checked; // private boolean checked;
private Field targetField; // private Field targetField;
//
public ReflectorField(ReflectorClass reflectorClass, String targetFieldName) { // public ReflectorField(ReflectorClass reflectorClass, String targetFieldName) {
this((IFieldLocator)(new FieldLocatorName(reflectorClass, targetFieldName))); // this((IFieldLocator)(new FieldLocatorName(reflectorClass, targetFieldName)));
} // }
//
public ReflectorField(ReflectorClass reflectorClass, Class targetFieldType) { // public ReflectorField(ReflectorClass reflectorClass, Class targetFieldType) {
this(reflectorClass, targetFieldType, 0); // this(reflectorClass, targetFieldType, 0);
} // }
//
public ReflectorField(ReflectorClass reflectorClass, Class targetFieldType, int targetFieldIndex) { // public ReflectorField(ReflectorClass reflectorClass, Class targetFieldType, int targetFieldIndex) {
this((IFieldLocator)(new FieldLocatorType(reflectorClass, targetFieldType, targetFieldIndex))); // this((IFieldLocator)(new FieldLocatorType(reflectorClass, targetFieldType, targetFieldIndex)));
} // }
//
public ReflectorField(Field field) { // public ReflectorField(Field field) {
this((IFieldLocator)(new FieldLocatorFixed(field))); // this((IFieldLocator)(new FieldLocatorFixed(field)));
} // }
//
public ReflectorField(IFieldLocator fieldLocator) { // public ReflectorField(IFieldLocator fieldLocator) {
this.fieldLocator = null; // this.fieldLocator = null;
this.checked = false; // this.checked = false;
this.targetField = null; // this.targetField = null;
this.fieldLocator = fieldLocator; // this.fieldLocator = fieldLocator;
ReflectorResolver.register(this); // ReflectorResolver.register(this);
} // }
//
public Field getTargetField() { // public Field getTargetField() {
if (this.checked) { // if (this.checked) {
return this.targetField; // return this.targetField;
} else { // } else {
this.checked = true; // this.checked = true;
this.targetField = this.fieldLocator.getField(); // this.targetField = this.fieldLocator.getField();
//
if (this.targetField != null) { // if (this.targetField != null) {
this.targetField.setAccessible(true); // this.targetField.setAccessible(true);
} // }
//
return this.targetField; // return this.targetField;
} // }
} // }
//
public Object getValue() { // public Object getValue() {
return Reflector.getFieldValue((Object) null, this); // return Reflector.getFieldValue((Object) null, this);
} // }
//
public void setValue(Object value) { // public void setValue(Object value) {
Reflector.setFieldValue((Object) null, this, value); // Reflector.setFieldValue((Object) null, this, value);
} // }
//
public void setValue(Object obj, Object value) { // public void setValue(Object obj, Object value) {
Reflector.setFieldValue(obj, this, value); // Reflector.setFieldValue(obj, this, value);
} // }
//
public boolean exists() { // public boolean exists() {
return this.getTargetField() != null; // return this.getTargetField() != null;
} // }
//
public void resolve() { // public void resolve() {
Field field = this.getTargetField(); // Field field = this.getTargetField();
} // }
} //}

View File

@ -1,39 +1,39 @@
package net.PeytonPlayz585.shadow.reflect; //package net.PeytonPlayz585.shadow.reflect;
//
public class ReflectorFields { //public class ReflectorFields {
private ReflectorClass reflectorClass; // private ReflectorClass reflectorClass;
private Class fieldType; // private Class fieldType;
private int fieldCount; // private int fieldCount;
private ReflectorField[] reflectorFields; // private ReflectorField[] reflectorFields;
//
public ReflectorFields(ReflectorClass reflectorClass, Class fieldType, int fieldCount) { // public ReflectorFields(ReflectorClass reflectorClass, Class fieldType, int fieldCount) {
this.reflectorClass = reflectorClass; // this.reflectorClass = reflectorClass;
this.fieldType = fieldType; // this.fieldType = fieldType;
//
if (reflectorClass.exists()) { // if (reflectorClass.exists()) {
if (fieldType != null) { // if (fieldType != null) {
this.reflectorFields = new ReflectorField[fieldCount]; // this.reflectorFields = new ReflectorField[fieldCount];
//
for (int i = 0; i < this.reflectorFields.length; ++i) { // for (int i = 0; i < this.reflectorFields.length; ++i) {
this.reflectorFields[i] = new ReflectorField(reflectorClass, fieldType, i); // this.reflectorFields[i] = new ReflectorField(reflectorClass, fieldType, i);
} // }
} // }
} // }
} // }
//
public ReflectorClass getReflectorClass() { // public ReflectorClass getReflectorClass() {
return this.reflectorClass; // return this.reflectorClass;
} // }
//
public Class getFieldType() { // public Class getFieldType() {
return this.fieldType; // return this.fieldType;
} // }
//
public int getFieldCount() { // public int getFieldCount() {
return this.fieldCount; // return this.fieldCount;
} // }
//
public ReflectorField getReflectorField(int index) { // public ReflectorField getReflectorField(int index) {
return index >= 0 && index < this.reflectorFields.length ? this.reflectorFields[index] : null; // return index >= 0 && index < this.reflectorFields.length ? this.reflectorFields[index] : null;
} // }
} //}

View File

@ -1,197 +1,197 @@
package net.PeytonPlayz585.shadow.reflect; //package net.PeytonPlayz585.shadow.reflect;
//
import java.lang.reflect.Method; //import java.lang.reflect.Method;
import java.util.ArrayList; //import java.util.ArrayList;
import java.util.List; //import java.util.List;
//
import net.PeytonPlayz585.shadow.Config; //import net.PeytonPlayz585.shadow.Config;
//
public class ReflectorMethod implements IResolvable { //public class ReflectorMethod implements IResolvable {
private ReflectorClass reflectorClass; // private ReflectorClass reflectorClass;
private String targetMethodName; // private String targetMethodName;
private Class[] targetMethodParameterTypes; // private Class[] targetMethodParameterTypes;
private boolean checked; // private boolean checked;
private Method targetMethod; // private Method targetMethod;
//
public ReflectorMethod(ReflectorClass reflectorClass, String targetMethodName) { // public ReflectorMethod(ReflectorClass reflectorClass, String targetMethodName) {
this(reflectorClass, targetMethodName, (Class[]) null); // this(reflectorClass, targetMethodName, (Class[]) null);
} // }
//
public ReflectorMethod(ReflectorClass reflectorClass, String targetMethodName, Class[] targetMethodParameterTypes) { // public ReflectorMethod(ReflectorClass reflectorClass, String targetMethodName, Class[] targetMethodParameterTypes) {
this.reflectorClass = null; // this.reflectorClass = null;
this.targetMethodName = null; // this.targetMethodName = null;
this.targetMethodParameterTypes = null; // this.targetMethodParameterTypes = null;
this.checked = false; // this.checked = false;
this.targetMethod = null; // this.targetMethod = null;
this.reflectorClass = reflectorClass; // this.reflectorClass = reflectorClass;
this.targetMethodName = targetMethodName; // this.targetMethodName = targetMethodName;
this.targetMethodParameterTypes = targetMethodParameterTypes; // this.targetMethodParameterTypes = targetMethodParameterTypes;
ReflectorResolver.register(this); // ReflectorResolver.register(this);
} // }
//
public Method getTargetMethod() { // public Method getTargetMethod() {
if (this.checked) { // if (this.checked) {
return this.targetMethod; // return this.targetMethod;
} else { // } else {
this.checked = true; // this.checked = true;
Class oclass = this.reflectorClass.getTargetClass(); // Class oclass = this.reflectorClass.getTargetClass();
//
if (oclass == null) { // if (oclass == null) {
return null; // return null;
} else { // } else {
try { // try {
if (this.targetMethodParameterTypes == null) { // if (this.targetMethodParameterTypes == null) {
Method[] amethod = getMethods(oclass, this.targetMethodName); // Method[] amethod = getMethods(oclass, this.targetMethodName);
//
if (amethod.length <= 0) { // if (amethod.length <= 0) {
Config.log("(Reflector) Method not present: " + oclass.getName() + "." + this.targetMethodName); // Config.log("(Reflector) Method not present: " + oclass.getName() + "." + this.targetMethodName);
return null; // return null;
} // }
//
if (amethod.length > 1) { // if (amethod.length > 1) {
Config.warn("(Reflector) More than one method found: " + oclass.getName() + "." + this.targetMethodName); // Config.warn("(Reflector) More than one method found: " + oclass.getName() + "." + this.targetMethodName);
//
for (int i = 0; i < amethod.length; ++i) { // for (int i = 0; i < amethod.length; ++i) {
Method method = amethod[i]; // Method method = amethod[i];
Config.warn("(Reflector) - " + method); // Config.warn("(Reflector) - " + method);
} // }
//
return null; // return null;
} // }
//
this.targetMethod = amethod[0]; // this.targetMethod = amethod[0];
} else { // } else {
this.targetMethod = getMethod(oclass, this.targetMethodName, this.targetMethodParameterTypes); // this.targetMethod = getMethod(oclass, this.targetMethodName, this.targetMethodParameterTypes);
} // }
//
if (this.targetMethod == null) { // if (this.targetMethod == null) {
Config.log("(Reflector) Method not present: " + oclass.getName() + "." + this.targetMethodName); // Config.log("(Reflector) Method not present: " + oclass.getName() + "." + this.targetMethodName);
return null; // return null;
} else { // } else {
this.targetMethod.setAccessible(true); // this.targetMethod.setAccessible(true);
return this.targetMethod; // return this.targetMethod;
} // }
} catch (Throwable throwable) { // } catch (Throwable throwable) {
throwable.printStackTrace(); // throwable.printStackTrace();
return null; // return null;
} // }
} // }
} // }
} // }
//
public boolean exists() { // public boolean exists() {
return this.checked ? this.targetMethod != null : this.getTargetMethod() != null; // return this.checked ? this.targetMethod != null : this.getTargetMethod() != null;
} // }
//
public Class getReturnType() { // public Class getReturnType() {
Method method = this.getTargetMethod(); // Method method = this.getTargetMethod();
return method == null ? null : method.getReturnType(); // return method == null ? null : method.getReturnType();
} // }
//
public void deactivate() { // public void deactivate() {
this.checked = true; // this.checked = true;
this.targetMethod = null; // this.targetMethod = null;
} // }
//
public Object call(Object...params) { // public Object call(Object...params) {
return Reflector.call(this, params); // return Reflector.call(this, params);
} // }
//
public boolean callBoolean(Object...params) { // public boolean callBoolean(Object...params) {
return Reflector.callBoolean(this, params); // return Reflector.callBoolean(this, params);
} // }
//
public int callInt(Object...params) { // public int callInt(Object...params) {
return Reflector.callInt(this, params); // return Reflector.callInt(this, params);
} // }
//
public float callFloat(Object...params) { // public float callFloat(Object...params) {
return Reflector.callFloat(this, params); // return Reflector.callFloat(this, params);
} // }
//
public double callDouble(Object...params) { // public double callDouble(Object...params) {
return Reflector.callDouble(this, params); // return Reflector.callDouble(this, params);
} // }
//
public String callString(Object...params) { // public String callString(Object...params) {
return Reflector.callString(this, params); // return Reflector.callString(this, params);
} // }
//
public Object call(Object param) { // public Object call(Object param) {
return Reflector.call(this, new Object[] { // return Reflector.call(this, new Object[] {
param // param
}); // });
} // }
//
public boolean callBoolean(Object param) { // public boolean callBoolean(Object param) {
return Reflector.callBoolean(this, new Object[] { // return Reflector.callBoolean(this, new Object[] {
param // param
}); // });
} // }
//
public int callInt(Object param) { // public int callInt(Object param) {
return Reflector.callInt(this, new Object[] { // return Reflector.callInt(this, new Object[] {
param // param
}); // });
} // }
//
public float callFloat(Object param) { // public float callFloat(Object param) {
return Reflector.callFloat(this, new Object[] { // return Reflector.callFloat(this, new Object[] {
param // param
}); // });
} // }
//
public double callDouble(Object param) { // public double callDouble(Object param) {
return Reflector.callDouble(this, new Object[] { // return Reflector.callDouble(this, new Object[] {
param // param
}); // });
} // }
//
public String callString1(Object param) { // public String callString1(Object param) {
return Reflector.callString(this, new Object[] { // return Reflector.callString(this, new Object[] {
param // param
}); // });
} // }
//
public void callVoid(Object...params) { // public void callVoid(Object...params) {
Reflector.callVoid(this, params); // Reflector.callVoid(this, params);
} // }
//
public static Method getMethod(Class cls, String methodName, Class[] paramTypes) { // public static Method getMethod(Class cls, String methodName, Class[] paramTypes) {
Method[] amethod = cls.getDeclaredMethods(); // Method[] amethod = cls.getDeclaredMethods();
//
for (int i = 0; i < amethod.length; ++i) { // for (int i = 0; i < amethod.length; ++i) {
Method method = amethod[i]; // Method method = amethod[i];
//
if (method.getName().equals(methodName)) { // if (method.getName().equals(methodName)) {
Class[] aclass = method.getParameterTypes(); // Class[] aclass = method.getParameterTypes();
//
if (Reflector.matchesTypes(paramTypes, aclass)) { // if (Reflector.matchesTypes(paramTypes, aclass)) {
return method; // return method;
} // }
} // }
} // }
//
return null; // return null;
} // }
//
public static Method[] getMethods(Class cls, String methodName) { // public static Method[] getMethods(Class cls, String methodName) {
List list = new ArrayList(); // List list = new ArrayList();
Method[] amethod = cls.getDeclaredMethods(); // Method[] amethod = cls.getDeclaredMethods();
//
for (int i = 0; i < amethod.length; ++i) { // for (int i = 0; i < amethod.length; ++i) {
Method method = amethod[i]; // Method method = amethod[i];
//
if (method.getName().equals(methodName)) { // if (method.getName().equals(methodName)) {
list.add(method); // list.add(method);
} // }
} // }
//
Method[] amethod1 = (Method[])((Method[]) list.toArray(new Method[list.size()])); // Method[] amethod1 = (Method[])((Method[]) list.toArray(new Method[list.size()]));
return amethod1; // return amethod1;
} // }
//
public void resolve() { // public void resolve() {
Method method = this.getTargetMethod(); // Method method = this.getTargetMethod();
} // }
} //}

View File

@ -1,157 +1,157 @@
package net.PeytonPlayz585.shadow.reflect; //package net.PeytonPlayz585.shadow.reflect;
//
import java.lang.reflect.Field; //import java.lang.reflect.Field;
import java.lang.reflect.Modifier; //import java.lang.reflect.Modifier;
import java.util.ArrayList; //import java.util.ArrayList;
import java.util.Arrays; //import java.util.Arrays;
import java.util.List; //import java.util.List;
//
public class ReflectorRaw { //public class ReflectorRaw {
public static Field getField(Class cls, Class fieldType) { // public static Field getField(Class cls, Class fieldType) {
try { // try {
Field[] afield = cls.getDeclaredFields(); // Field[] afield = cls.getDeclaredFields();
//
for (int i = 0; i < afield.length; ++i) { // for (int i = 0; i < afield.length; ++i) {
Field field = afield[i]; // Field field = afield[i];
//
if (field.getType() == fieldType) { // if (field.getType() == fieldType) {
field.setAccessible(true); // field.setAccessible(true);
return field; // return field;
} // }
} // }
//
return null; // return null;
} catch (Exception var5) { // } catch (Exception var5) {
return null; // return null;
} // }
} // }
//
public static Field[] getFields(Class cls, Class fieldType) { // public static Field[] getFields(Class cls, Class fieldType) {
try { // try {
Field[] afield = cls.getDeclaredFields(); // Field[] afield = cls.getDeclaredFields();
return getFields(afield, fieldType); // return getFields(afield, fieldType);
} catch (Exception var3) { // } catch (Exception var3) {
return null; // return null;
} // }
} // }
//
public static Field[] getFields(Field[] fields, Class fieldType) { // public static Field[] getFields(Field[] fields, Class fieldType) {
try { // try {
List list = new ArrayList(); // List list = new ArrayList();
//
for (int i = 0; i < fields.length; ++i) { // for (int i = 0; i < fields.length; ++i) {
Field field = fields[i]; // Field field = fields[i];
//
if (field.getType() == fieldType) { // if (field.getType() == fieldType) {
field.setAccessible(true); // field.setAccessible(true);
list.add(field); // list.add(field);
} // }
} // }
//
Field[] afield = (Field[])((Field[]) list.toArray(new Field[list.size()])); // Field[] afield = (Field[])((Field[]) list.toArray(new Field[list.size()]));
return afield; // return afield;
} catch (Exception var5) { // } catch (Exception var5) {
return null; // return null;
} // }
} // }
//
public static Field[] getFieldsAfter(Class cls, Field field, Class fieldType) { // public static Field[] getFieldsAfter(Class cls, Field field, Class fieldType) {
try { // try {
Field[] afield = cls.getDeclaredFields(); // Field[] afield = cls.getDeclaredFields();
List < Field > list = Arrays. < Field > asList(afield); // List < Field > list = Arrays. < Field > asList(afield);
int i = list.indexOf(field); // int i = list.indexOf(field);
//
if (i < 0) { // if (i < 0) {
return new Field[0]; // return new Field[0];
} else { // } else {
List < Field > list1 = list.subList(i + 1, list.size()); // List < Field > list1 = list.subList(i + 1, list.size());
Field[] afield1 = (Field[])((Field[]) list1.toArray(new Field[list1.size()])); // Field[] afield1 = (Field[])((Field[]) list1.toArray(new Field[list1.size()]));
return getFields(afield1, fieldType); // return getFields(afield1, fieldType);
} // }
} catch (Exception var8) { // } catch (Exception var8) {
return null; // return null;
} // }
} // }
//
public static Field[] getFields(Object obj, Field[] fields, Class fieldType, Object value) { // public static Field[] getFields(Object obj, Field[] fields, Class fieldType, Object value) {
try { // try {
List < Field > list = new ArrayList(); // List < Field > list = new ArrayList();
//
for (int i = 0; i < fields.length; ++i) { // for (int i = 0; i < fields.length; ++i) {
Field field = fields[i]; // Field field = fields[i];
//
if (field.getType() == fieldType) { // if (field.getType() == fieldType) {
boolean flag = Modifier.isStatic(field.getModifiers()); // boolean flag = Modifier.isStatic(field.getModifiers());
//
if ((obj != null || flag) && (obj == null || !flag)) { // if ((obj != null || flag) && (obj == null || !flag)) {
field.setAccessible(true); // field.setAccessible(true);
Object object = field.get(obj); // Object object = field.get(obj);
//
if (object == value) { // if (object == value) {
list.add(field); // list.add(field);
} else if (object != null && value != null && object.equals(value)) { // } else if (object != null && value != null && object.equals(value)) {
list.add(field); // list.add(field);
} // }
} // }
} // }
} // }
//
Field[] afield = (Field[])((Field[]) list.toArray(new Field[list.size()])); // Field[] afield = (Field[])((Field[]) list.toArray(new Field[list.size()]));
return afield; // return afield;
} catch (Exception var9) { // } catch (Exception var9) {
return null; // return null;
} // }
} // }
//
public static Field getField(Class cls, Class fieldType, int index) { // public static Field getField(Class cls, Class fieldType, int index) {
Field[] afield = getFields(cls, fieldType); // Field[] afield = getFields(cls, fieldType);
return index >= 0 && index < afield.length ? afield[index] : null; // return index >= 0 && index < afield.length ? afield[index] : null;
} // }
//
public static Field getFieldAfter(Class cls, Field field, Class fieldType, int index) { // public static Field getFieldAfter(Class cls, Field field, Class fieldType, int index) {
Field[] afield = getFieldsAfter(cls, field, fieldType); // Field[] afield = getFieldsAfter(cls, field, fieldType);
return index >= 0 && index < afield.length ? afield[index] : null; // return index >= 0 && index < afield.length ? afield[index] : null;
} // }
//
public static Object getFieldValue(Object obj, Class cls, Class fieldType) { // public static Object getFieldValue(Object obj, Class cls, Class fieldType) {
ReflectorField reflectorfield = getReflectorField(cls, fieldType); // ReflectorField reflectorfield = getReflectorField(cls, fieldType);
return reflectorfield == null ? null : (!reflectorfield.exists() ? null : Reflector.getFieldValue(obj, reflectorfield)); // return reflectorfield == null ? null : (!reflectorfield.exists() ? null : Reflector.getFieldValue(obj, reflectorfield));
} // }
//
public static Object getFieldValue(Object obj, Class cls, Class fieldType, int index) { // public static Object getFieldValue(Object obj, Class cls, Class fieldType, int index) {
ReflectorField reflectorfield = getReflectorField(cls, fieldType, index); // ReflectorField reflectorfield = getReflectorField(cls, fieldType, index);
return reflectorfield == null ? null : (!reflectorfield.exists() ? null : Reflector.getFieldValue(obj, reflectorfield)); // return reflectorfield == null ? null : (!reflectorfield.exists() ? null : Reflector.getFieldValue(obj, reflectorfield));
} // }
//
public static boolean setFieldValue(Object obj, Class cls, Class fieldType, Object value) { // public static boolean setFieldValue(Object obj, Class cls, Class fieldType, Object value) {
ReflectorField reflectorfield = getReflectorField(cls, fieldType); // ReflectorField reflectorfield = getReflectorField(cls, fieldType);
return reflectorfield == null ? false : (!reflectorfield.exists() ? false : Reflector.setFieldValue(obj, reflectorfield, value)); // 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) { // public static boolean setFieldValue(Object obj, Class cls, Class fieldType, int index, Object value) {
ReflectorField reflectorfield = getReflectorField(cls, fieldType, index); // ReflectorField reflectorfield = getReflectorField(cls, fieldType, index);
return reflectorfield == null ? false : (!reflectorfield.exists() ? false : Reflector.setFieldValue(obj, reflectorfield, value)); // return reflectorfield == null ? false : (!reflectorfield.exists() ? false : Reflector.setFieldValue(obj, reflectorfield, value));
} // }
//
public static ReflectorField getReflectorField(Class cls, Class fieldType) { // public static ReflectorField getReflectorField(Class cls, Class fieldType) {
Field field = getField(cls, fieldType); // Field field = getField(cls, fieldType);
//
if (field == null) { // if (field == null) {
return null; // return null;
} else { // } else {
ReflectorClass reflectorclass = new ReflectorClass(cls); // ReflectorClass reflectorclass = new ReflectorClass(cls);
return new ReflectorField(reflectorclass, field.getName()); // return new ReflectorField(reflectorclass, field.getName());
} // }
} // }
//
public static ReflectorField getReflectorField(Class cls, Class fieldType, int index) { // public static ReflectorField getReflectorField(Class cls, Class fieldType, int index) {
Field field = getField(cls, fieldType, index); // Field field = getField(cls, fieldType, index);
//
if (field == null) { // if (field == null) {
return null; // return null;
} else { // } else {
ReflectorClass reflectorclass = new ReflectorClass(cls); // ReflectorClass reflectorclass = new ReflectorClass(cls);
return new ReflectorField(reflectorclass, field.getName()); // return new ReflectorField(reflectorclass, field.getName());
} // }
} // }
} //}

View File

@ -1,28 +1,28 @@
package net.PeytonPlayz585.shadow.reflect; //package net.PeytonPlayz585.shadow.reflect;
//
import java.util.ArrayList; //import java.util.ArrayList;
import java.util.Collections; //import java.util.Collections;
import java.util.List; //import java.util.List;
//
public class ReflectorResolver { //public class ReflectorResolver {
private static final List < IResolvable > RESOLVABLES = Collections. < IResolvable > synchronizedList(new ArrayList()); // private static final List < IResolvable > RESOLVABLES = Collections. < IResolvable > synchronizedList(new ArrayList());
private static boolean resolved = false; // private static boolean resolved = false;
//
protected static void register(IResolvable resolvable) { // protected static void register(IResolvable resolvable) {
if (!resolved) { // if (!resolved) {
RESOLVABLES.add(resolvable); // RESOLVABLES.add(resolvable);
} else { // } else {
resolvable.resolve(); // resolvable.resolve();
} // }
} // }
//
public static void resolve() { // public static void resolve() {
if (!resolved) { // if (!resolved) {
for (IResolvable iresolvable: RESOLVABLES) { // for (IResolvable iresolvable: RESOLVABLES) {
iresolvable.resolve(); // iresolvable.resolve();
} // }
//
resolved = true; // resolved = true;
} // }
} // }
} //}

View File

@ -10,6 +10,7 @@ import org.json.JSONObject;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import net.PeytonPlayz585.shadow.json.JSONUtils;
import net.lax1dude.eaglercraft.v1_8.IOUtils; import net.lax1dude.eaglercraft.v1_8.IOUtils;
import net.minecraft.client.resources.data.IMetadataSection; import net.minecraft.client.resources.data.IMetadataSection;
import net.minecraft.client.resources.data.IMetadataSerializer; import net.minecraft.client.resources.data.IMetadataSerializer;
@ -89,11 +90,20 @@ public class SimpleResource implements IResource {
try { try {
imetadatasection = this.srMetadataSerializer.parseMetadataSection(s, this.mcmetaJson); imetadatasection = this.srMetadataSerializer.parseMetadataSection(s, this.mcmetaJson);
} catch(Exception e) { } catch(Exception e) {
//Temp fix, no frame time :( if(this.srResourceLocation.toString().contains("mcpatcher") || this.srResourceLocation.toString().contains("optifine")) {
imetadatasection = this.srMetadataSerializer.parseMetadataSection(s, new JSONObject("{\"animation\":{}}")); 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; return (T) imetadatasection;
} }
} }