Variable within NBT tag throws exception
chimericdream opened this issue · 3 comments
Issue Description:
Using a variable within an NBT tag does not appear to work correctly. Specifically, I am working on a script to add enchanted books up to "(Some Enchant) X" and am attempting to use a loop to reduce the amount of copy/pasta in my script. But attempting to use variables for either the level or enchantment ID results in an exception with the following message:
Type 'java/lang/Short' (current frame, stack[11]) is not assignable to integer
What happens:
The script throws an exception while trying to create the NBT tag, and the item is not created.
What you expected to happen:
The NBT tag should be created using the values stored in the given variables, allowing the enchanted books to be added.
Script and Log files
enchanted-books.zs
crafttweaker.log
Affected Versions (Do not use "latest"):
- Minecraft: 1.12.2
- Forge: 14.23.1.2584
- Crafttweaker: 4.1.0
Your most recent log file where the issue was present:
Same result, unfortunately. Getting an error that Short can't be assigned to integer.
Tested around, a bit:
The issue is that Maps can't accept primitives, which is why ZS casts them as ther Wrapper type which isn't implemented that well into ZS.
This script ↓ works:
https://gist.github.com/kindlich/8a61763a31f1d2b2fa70c896bf879504
Alternatively, you could go for IData Maps, and use the asInt() where you need the integer. Added a working copy for that solution to the gist above