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.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
Each ReflectClass
has the following properties:
binaryName: String?
Lnet.minecraft.client.entity.EntityPlayerSP;
null
if hasMeta
is equal to false
class: Class?
new
keyword, this is mostly useful for extending using prototype
.null
if hasMeta
is equal to false
compiledName: String
nmce_EntityPlayerSP
constructors: Function[]
hasMeta: Boolean
id: String?
net.minecraft.client.entity.EntityPlayerSP
null
if hasMeta
is equal to false
name: String
EntityPlayerSP
methods: Map<String, ReflectMethod>
staticMethods: Map<String, ReflectMethod>
staticVariableNames: String[]
staticVariables: Map<String, *>
superclass: Class?
superclassName: String?
net.minecraft.client.entity.AbstractClientPlayer
null
if hasMeta
is equal to false
Each ReflectClass
has the following methods:
instanceOf(object: Object)
object
is an instance of the class.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()
);