Update tracers.js to use new method maps
This commit is contained in:
parent
51112a09ed
commit
e718d15439
|
@ -18,6 +18,15 @@ function initTracers() {
|
||||||
WorldRenderer: ModAPI.reflect.getClassByName("WorldRenderer")
|
WorldRenderer: ModAPI.reflect.getClassByName("WorldRenderer")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Build a method map object, to avoid searching for methods multiple times over.
|
||||||
|
const methodMaps = {};
|
||||||
|
var usedClasses = Object.keys(classes);
|
||||||
|
usedClasses.forEach((className)=>{
|
||||||
|
methodMaps[className] = ModAPI.reflect.getMethodMapFromClass(classes[className]);
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(methodMaps);
|
||||||
|
|
||||||
//Get the vertex format for 'POSITION'
|
//Get the vertex format for 'POSITION'
|
||||||
const positionVertexFormat = ModAPI.reflect.getClassByName("VertexFormat").class.$platformClass.$$enumConstants$$().data[5];
|
const positionVertexFormat = ModAPI.reflect.getClassByName("VertexFormat").class.$platformClass.$$enumConstants$$().data[5];
|
||||||
|
|
||||||
|
@ -43,41 +52,29 @@ function initTracers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Utility functions for running methods on classes/instances of classes
|
//Utility functions for running methods on classes/instances of classes by referencing the created methodMaps object.
|
||||||
function glFunction(name, args) {
|
function glFunction(name, args) {
|
||||||
return classes.GlStateManager.methods.filter((method) => {
|
return methodMaps["GlStateManager"][name].exec(args);
|
||||||
return method.methodName === name
|
|
||||||
})[0].exec(args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function gpuFunction(name, args) {
|
function gpuFunction(name, args) {
|
||||||
return classes.EaglercraftGPU.methods.filter((method) => {
|
return methodMaps["EaglercraftGPU"][name].exec(args);
|
||||||
return method.methodName === name
|
|
||||||
})[0].exec(args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function entityRendererFunction(name, args) {
|
function entityRendererFunction(name, args) {
|
||||||
return classes.EntityRenderer.methods.filter((method) => {
|
return methodMaps["EntityRenderer"][name].exec(args);
|
||||||
return method.methodName === name
|
|
||||||
})[0].exec(args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function mathHelperFunction(name, args) {
|
function mathHelperFunction(name, args) {
|
||||||
return classes.MathHelper.methods.filter((method) => {
|
return methodMaps["MathHelper"][name].exec(args);
|
||||||
return method.methodName === name
|
|
||||||
})[0].exec(args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function tessellatorFunction(name, args) {
|
function tessellatorFunction(name, args) {
|
||||||
return classes.Tessellator.methods.filter((method) => {
|
return methodMaps["Tessellator"][name].exec(args);
|
||||||
return method.methodName === name
|
|
||||||
})[0].exec(args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function worldRendererFunction(name, args) {
|
function worldRendererFunction(name, args) {
|
||||||
return classes.WorldRenderer.methods.filter((method) => {
|
return methodMaps["WorldRenderer"][name].exec(args);
|
||||||
return method.methodName === name
|
|
||||||
})[0].exec(args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue