gnembon / scarpet

Public Repository of scarpet programs for Minecraft
Creative Commons Zero v1.0 Universal
359 stars 162 forks source link

auto_lighter not working anymore in 1.21 #405

Open PlasmaHH opened 3 months ago

PlasmaHH commented 3 months ago

Describe the bug For a long while now I tried to use auto_lighter again but upon clicking with the torch it vanishes and I get the error:

Tried to load invalid item: 'No key id in MapLike[{Enchantments:[{id:"minecraft:protection",lvl:1s}]}]'

My knowledge of minecraft internals, let alone scarpet are very limited so I have no idea what exactly that means ( I can only guess that at some point the data was required to have an id field and somehow it is missing )

It seems that this is happening from within the __on_player_uses_item function, whose logic I have no idea what it does, I have ever since wondered why the torch for that script is enchanted afterwards...

When printing the item object in that function before editing it says (notice its a stack of 33 there )

[torch, 33, {count:33,id:"minecraft:torch"}]

After editing it says

[torch, 33, {Enchantments:[{id:"minecraft:protection",lvl:1}]}]

so it looks like the id part is gone...

So I tried adding the line

put(item:2:'id','torch')

after the Enchantments part is added, and then it seems to work but I have no idea if thats the right way

Environment

roblem here.