ModAPI.reflect supplies a user friendly wrapper for accessing and interacting with java classes from javascript.
Properties:
classes: ReflectClass[]
ModAPI.reflect.classes is an array of ReflectClasses, representing (almost) every java class.classMap: Map<String, ReflectClass> is a map of every class.Methods:
ModAPI.reflect.getClassById(classId: String) : ReflectClass
Minecraft class, you can use ModAPI.reflect.getClassById("net.minecraft.client.Minecraft")ModAPI.reflect.getClassByName(className: String) : ReflectClass
Minecraft class, you can use ModAPI.reflect.getClassById("Minecraft")getClassById because it has to filter through all classes. Make sure to cache the result rather than calling it over and over again.ModAPI.reflect.getSuper(rClass: ReflectClass, filter: Function?) : Function
ModAPI.reflect.prototypeStack(rClass: ReflectClass, target: Class/ConstructorFunction) : void
ModAPI.util.asClassModAPI.reflect.implements(target: Class/ConstructorFunction, interface: ReflectClass)
implements keyword
Each ReflectClass has the following properties:
binaryName: String?
Lnet.minecraft.client.entity.EntityPlayerSP;null if hasMeta is equal to falseclass: Class?
new keyword, this is mostly useful for extending using prototype.null if hasMeta is equal to falsecompiledName: String
nmce_EntityPlayerSPconstructors: Function[]
hasMeta: Boolean
id: String?
net.minecraft.client.entity.EntityPlayerSPnull if hasMeta is equal to falsename: String
EntityPlayerSPmethods: Map<String, ReflectMethod>staticMethods: Map<String, ReflectMethod>staticVariableNames: String[]
staticVariables: Map<String, *>
superclass: ReflectClass?
Each ReflectClass has the following methods:
instanceOf(object: Object)
object is an instance of the class.getConstructorByArgs(...argumentNames) : Function
ModAPI.reflect.getClassByName("ItemStack").getConstructorByArgs("blockIn", "amount")Each ReflectMethod has the following properties:
methodName: String
nmce_EntityPlayerSP_closeScreen.methodNameShort: String
closeScreen.Each ReflectClass has the following methods:
method(...)
methods property), the first argument should be an instance of the class. Eg: ModAPI.reflect.getClassByName("EntityPlayerSP").methods.closeScreen.method(ModAPI.player.getRef())staticMethods property), call the method as usual. Eg: ModAPI.reflect.getClassById("net.minecraft.init.Items").staticMethods.getRegisteredItem.method(ModAPI.util.str("apple"))Keep in mind that you need to wrap strings using ModAPI.util.str("MyString"), convert booleans into respective numbers (true->1, false->0), and get references of ModAPI proxies (ModAPI.player->ModAPI.player.getRef());