SpyglassMC / Spyglass

Development tools for vanilla Minecraft: Java Edition data pack developers.
https://spyglassmc.com
MIT License
302 stars 31 forks source link

Cannot change Spyglass loaded version and key "tag" is unknown #1577

Closed ChainDev162 closed 1 month ago

ChainDev162 commented 1 month ago

Hello, I was making a modpack for my world which is on 1.20.6, and I tried to change the loaded Spyglass version to 1.20.6, it kept bugging me with this error message: image When I tried to change it using .spyglassrc.json to 1.20.6, it said this when i hovered over execute: image image image I reloaded it not once, not twice, but three times so far, and i tried using spyglass.json, nothing. Please help as I'm just trying to have fun as a beginner to minecraft technicality.

### Tasks
- [ ] Fix version changing
- [ ] Fix weird bug with `execute`
ChainDev162 commented 1 month ago

For anyone wondering, the command which has the weird execute message was execute as @a[nbt={SelectedItem:{id:"minecraft:sugar",tag:{display:{Name:"{\"text\":\"Crack\"}"}}}}] at @s run function crack:apply_effects, also here's my file structure: image

Ellivers commented 1 month ago

The Spyglass config file needs to be at the root of your workspace, meaning at the same level as your python file there. Also, the pack format for 1.20.6 is 41, as can be seen here.

misode commented 1 month ago

Adding to what Ellivers said, even in 1.20.6 your command would not be valid anymore. The tag field no longer exists. Instead you should probably use execute if items.

Ellivers commented 1 month ago

As Misode pointed out, the tag warning will still show in 1.20.6, since it was removed in 1.20.5. You need to use the components tag or execute if items command to select based on item data. For more information and help regarding that, I'd recommend joining the Minecraft Commands discord server.

ChainDev162 commented 1 month ago

As Misode pointed out, the tag warning will still show in 1.20.6, since it was removed in 1.20.5. You need to use the components tag or execute if items command to select based on item data. For more information and help regarding that, I'd recommend joining the Minecraft Commands discord server.

so this? execute as @a if data entity @s {SelectedItem:{id:"minecraft:sugar",display:{Name:'{"text":"Crack"}'}}} run function crack:apply_effects

Ellivers commented 1 month ago

With execute if items, the command would be execute as @a if items entity @s weapon.mainhand minecraft:sugar[minecraft:custom_name='{"text":"Crack"}'] run function crack:apply_effects. However, for most cases, I wouldn't recommend checking for the name of the item. It depends on your use case, but most of the time it's a better idea to give it a tag within the minecraft:custom_data component and check for that instead, since text components can be unreliable. This isn't really a place for command help, so if you have more questions, please join the Discord server I linked.