CraftTweaker

CraftTweaker

151M Downloads

[1.16] Could not modify int map

friendlyhj opened this issue ยท 4 comments

commented

Intro:

Could not modify int map

What you expected to happen:

Can modify int map

Script used:

var item_values = {} as int[string];
item_values["box"] = 1;
item_values["test"] = 9;
print(item_values["box"]);

crafttweaker.log file:

https://paste.ubuntu.com/p/NQdZnGth3m/


Environment:

  • Minecraft Version: 1.16.5
  • Forge Version: 36.0.42
  • CraftTweaker Version: 7.1.0.145
  • Are you using a server: no
commented

Does this happen on the put or the get?

commented

put

commented

Then it's a missed Boxing of the int.

https://github.com/ZenCodeLang/ZenCode/blob/580b84124eeb05a6b22198f1bfa78d77ab6a9a1e/JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaExpressionVisitor.java#L925

In there, a call to the unboxingTypeVisitor is missing.
You'll most likely find that in more than one occasion when it comes to boxing, since ZC doesn't distinguish between them and in some cases I forgot to add that (since it was added later).

That specific place would need something like

AssocTypeID type = expression.target.type;
type.value.accept(type.value, boxingTypeVisistor);
javaWriter.invokeVirtual(...);
javaWriter.pop();
commented

Merged in ZC