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.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();

View File

@ -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;

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;
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];
}
}
//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];
// }
//}

View File

@ -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;
}
}
//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;
// }
//}

View File

@ -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);
}
}
}
//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);
// }
// }
//}

View File

@ -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;
}
}
}
}
//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;
// }
// }
// }
//}

View File

@ -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;
}
}
//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;
// }
//}

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -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();
}
}
//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();
// }
//}

View File

@ -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();
}
}
//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();
// }
//}

View File

@ -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();
}
}
//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();
// }
//}

View File

@ -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;
}
}
//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;
// }
//}

View File

@ -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();
}
}
//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();
// }
//}

View File

@ -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());
}
}
}
//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());
// }
// }
//}

View File

@ -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;
}
}
}
//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;
// }
// }
//}

View File

@ -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;
}
}