CraftTweaker

CraftTweaker

151M Downloads

Getting the java.lang.ClassFormatError: Truncated class file error

farnoods opened this issue ยท 9 comments

commented

As you know, there are a few types of planks in minecraft (such as natura planks) that can be used to craft "special" wooden tools (for e.g. bloodwood sword). But as these planks belong to the oredict entry ore:plankWood, the oredict treats them as any other boring plank and as such crafts them into normal vanilla wooden tools (for e.g crafts a vanilla wooden sword from bloodwood planks instead of a bloodwood sword.) Anyway, I wrote a function to basically bypass this by iterating over the entire oredict entry ore:plankWood and assigning any planks that are not natura planks to a secondary oredict entry called ore:boringPlanks, so that I can then remove the recipe for vanilla wooden tools and add them again using the ore:boringPlanks entry instead. But I don't know if there is a problem with my logic or what, but I'm getting this error. Hopefully someone here can help. Thanks.

P.S. Don't mind the thermalfoundation errors from recipeConflictFix.zs. There is a typo. I miss-spelt thermal foundation lol

oreDictHandler.zs: https://pastebin.com/xpAXqY1q
oreDict.zs: https://pastebin.com/Wj1D2M73
postinit.zs: https://pastebin.com/EtZCwci1
Crafttweaker log: https://pastebin.com/28qUusB0

MC Version: 1.12.2
Forge Version: 14.23.5.2854
Crafttweaker Version: 1.12-4.1.20.574

commented

You need to specify the types of all parameters:

//so change
function createSeparateOreDictEnt(bigOreDictEnt, smallOreDictEnt, newOreDictEnt as IOreDictEntry) {...}

//to
function createSeparateOreDictEnt(bigOreDictEnt as IOreDictEntry, smallOreDictEnt as IOreDictEntry, newOreDictEnt as IOreDictEntry) {...}

//And I recomment also specifying the return type but that is optional if you don't need to use the return value
function createSeparateOreDictEnt(bigOreDictEnt as IOreDictEntry, smallOreDictEnt as IOreDictEntry, newOreDictEnt as IOreDictEntry) as void {...}
commented

Oh I see, I thought I could specify the datatype for multiple parameters at once if they were all of the same datatype. Thank you so much!

commented

I think my logic for the createSeparateOreDictEnt function was wrong. I changed my logic. This one should work, I followed the documentation word by word but now I'm getting a different error.

oreDictHandler.zs: https://pastebin.com/z4NbajQ1
oreDict.zs: https://pastebin.com/pCDVc7HK

crafttweaker log: https://pastebin.com/CDs5fc5m

commented

I just tested the code, and now I'm not getting any error and the "boring" planks are being correctly assigned to the ore:boringPlanks entry but the special planks (i.e. natura planks) are also being assigned to the ore:boringPlanks entry which is not supposed to happen. Any idea what the issue is and how I can fix it. It seems like my logic is wrong yet again but I don't see how that could be, according to the documentation, this logic should work like a charm :(

commented

Any updates on this? It seems like this is a bug with the scripting language. I've tried multiple other methods to achieve the same thing, neither worked. Any help would be greatly appreciated.

commented

It is possible that by the time CraftTweaker runs, the oredict in question is not filled yet.
Check which items exist in the ordict at first and see if that's the issue

commented

I'm not sure I'm following. How do I do that? The problem is that all the planks, from natura and otherwise, are being added the the ore:boringPlanks entry and the if statement is not skipping over the natura planks like it's supposed to. I even tried to manually remove the natura planks from the ore:boringPlanks entry using the oredict remove function but that didn't work either. And when I checked the crafttweaker logs, all the alterations to the oredict from the scripts were applied to the oredict but it's like it just skipped over the removal of natura planks from the ore:boringPlanks entry. There was no mention of them in the logs, and no errors either.

commented

You can check all items in an oredict by using a loop like

for item in <ore:myoredict>.items {
    print(item.commandString);
}

Another thing that may be possible is, that natura added the planks as "wildcard" metadata to the oredict.
In that case you would need to use <natura:plank:*> instead of <natura:plank:0>, <natura:plank:1>, ...

Edit:
I apologize for the late answer, is this still an issue?

commented

Closing this due to inactivity.

If this is still an issue, then please let me know.