samolego / GolfIV

An anti-exploit attempt for Fabric
https://modrinth.com/mod/golfiv
MIT License
49 stars 13 forks source link

Banning Custom Named Items #65

Closed hinzyboii closed 1 year ago

hinzyboii commented 1 year ago

Is there any way to ban a custom named item but not the item itself? For example player heads, i have a datapack installed which adds player heads into the game, but id like to ban my head from peoples inventory's which would read "Hinzy's Head"?

Ive tried "minecraft:player_head{display:{Name:'{"text":"Hinzy\'s Head"}'}}" in the survival banned items section and i just get this error when i reload the config "An unexpected error occurred trying to execute that command" as the output ingame.

samolego commented 1 year ago

What shows up upon hovering over the error?

hinzyboii commented 1 year ago

What shows up upon hovering over the error?

image

And this is how i have the config set up }, "items": { "survival": { "_comment_legalise": "// Whether to enable 'legalising' survival items.", "_comment_legaliseWholeInventory": "// Whether to check whole inventory when connecting / changing dimensions, etc.", "legaliseWholeInventory": true, "_comment_bannedSurvivalItems": "// Which items should be cleared when clicked in survival inventory", "bannedItems": [ "minecraft:barrier", "minecraft:spawner", "minecraft:structure_void", "minecraft:bedrock", "minecraft:command_block", "minecraft:spawn_egg" "minecraft:player_head{display:{Name:'{"text":"Hinzy\'s Head"}'}}" ],

Ampflower commented 1 year ago

This line isn't valid "minecraft:player_head{display:{Name:'{"text":"Hinzy's Head"}'}}" Use only "minecraft:player_head"; there's no NBT parser hooked up there, tho, note, this will delete all heads in survival inventories.

If you do not want to delete all player heads, do not specify this, and instead remove the line.

Also, you're missing a comma after "minecraft:spawn_egg" if you're going to be keeping that entry.

The real cause is most likely the missing comma or lacks of escapes (that probably can't be seen because GitHub merged \" to show as \".) Although, since specifying NBT is currently not possible via that mechanism, it's either all or nothing right now.