CraftTweaker / CraftTweaker

Tweak your minecraft experience
MIT License
295 stars 124 forks source link

[1.16] Could not modify int map #1198

Closed friendlyhj closed 3 years ago

friendlyhj commented 3 years ago

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:

kindlich commented 3 years ago

Does this happen on the put or the get?

friendlyhj commented 3 years ago

put

kindlich commented 3 years ago

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();
jaredlll08 commented 3 years ago

Merged in ZC