Closed Foxite closed 3 years ago
Transfered to the right repo as that one is for 1.12 zenscript.
Can you please add
#debug
Somewhere in the script, when you run it, it will generate a folder called "classes", zip that folder up and attach it here please
classes-before-loading-world.zip
classes-after-loading-world.zip
The error is logged to chat and crafttweaker.log when I load the world.
The full log file if it helps
So your script is fine, like it is "valid" zenscript in terms of how everything is structured.
The issue was that IData (which is what IsBaby
returns) could not be casted to a boolean.
I have fixed that in 2cce4411fbe586f0240c60d0b18f4f793e4b344f and changing your code to be:
import crafttweaker.api.events.CTEventManager;
import crafttweaker.api.entity.MCEntity;
import crafttweaker.api.event.entity.MCEntityJoinWorldEvent;
CTEventManager.register<MCEntityJoinWorldEvent>((event) => {
if event.entity.type.registryName as string == "minecraft:zombie" {
if event.getEntity().getData()."IsBaby" as bool {
event.cancel();
}
}
});
will now work.
As for:
however I still think that the ZenScript compiler should have complained about it first, rather than successfully compiling ZS into invalid java bytecode.
While I do agree with you, unfortunately I don't know how feasible that is to do right now.
Let me preface this by saying that I have no idea if this code is even close to a valid piece of ZenScript, however I still think that the ZenScript compiler should have complained about it first, rather than successfully compiling ZS into invalid java bytecode.