-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using a function as a parameter for a custom function causes ArrayIndexOutOfBoundsException #26
Comments
ZS does not allow for functions as parameters because internally it uses different types. |
Short of forking CT, can we register a functional interface using ZenClasses? |
Take this example (the 2nd function parameter for recipes) |
So it's like using lambda needs an interface? |
You can use lambdas when you have registered a functional interface using Java Code. |
Hey there, I apologize for the late reply. var myTestFun as function(string)void = function(s as string) as void {print(s);};
myTestFun('Hello World');
function myAcceptFun(consumer as function(string)void) as void {
consumer('hello from inside myAcceptFun');
}
myAcceptFun(myTestFun);
myAcceptFun(function(s as string) as void {print('Another thing: ' ~ s);}); Would print
And zenClass myClass {
var consumer as function(string)void;
zenConstructor(consumer as function(string)void) {
this.consumer = consumer;
}
function acceptString(x as string) as void {
consumer(x);
}
}
myClass(function(x as string) as void {print('inside fun: ' ~ x);}).acceptString('abc'); Would print
|
Creating a custom function that accepts a function causes a java.lang.ArrayIndexOutOfBoundsException
Example Script
Exception in crafttweaker.log
CraftTweaker version: CraftTweaker2-1.12-4.1.15
The text was updated successfully, but these errors were encountered: