I'm trying to make a command that gives a player a prismarine shard with a name if they have a prismarine shard that isn't named. I've gotten it to work with the first one, but once it detects both a named and unnamed prismarine shard, the command no longer works. Does anyone know how I can make a selector test for items with no name rather than a selector that applies to any version of the item?
Repeating command block:
/execute at @a[nbt={Inventory:[{id:"minecraft:prismarine_shard"}]}] unless entity @a[nbt={Inventory:[{id:"minecraft:prismarine_shard",tag:{display:{Name:"{\"text\":\"example\"}"}}}]}] run give @a prismarine_shard{display:{Name:"{\"text\":\"example\"}"}}
I'm trying to make a command that gives a player a prismarine shard with a name if they have a prismarine shard that isn't named. I've gotten it to work with the first one, but once it detects both a named and unnamed prismarine shard, the command no longer works. Does anyone know how I can make a selector test for items with no name rather than a selector that applies to any version of the item?
Repeating command block:
/execute at @a[nbt={Inventory:[{id:"minecraft:prismarine_shard"}]}] unless entity @a[nbt={Inventory:[{id:"minecraft:prismarine_shard",tag:{display:{Name:"{\"text\":\"example\"}"}}}]}] run give @a prismarine_shard{display:{Name:"{\"text\":\"example\"}"}}
Conditional chain command block:
/clear @a minecraft:prismarine_shard 1
Well yeah. Cuz the repeating command won't execute as soon as you have the special shard on you.
That would work if I spawned in the item using
/give @p prismarine_shard{display:{Name:"{\"text\":\"Prismarine Shard\"}"}}
The problem is I'm making it the item with a custom crafting recipe in a datapack, so I can't make it give you the item with any form of nbt data (as far as I know) to test for.
That would work if I spawned in the item using
/give @p prismarine_shard{display:{Name:"{\"text\":\"Prismarine Shard\"}"}}
The problem is I'm making it the item with a custom crafting recipe in a datapack, so I can't make it give you the item with any form of nbt data (as far as I know) to test for.
Ok. I did some testing. There IS a method. But... I guess I'll consult you before I do anything.
1. Whenever the player picks up 1+ shard (yes, just one), all the items will be refreshed. It might cause lag and inconvenience.
2. I need to know whether you're putting this in a command block world or a function file. The refreshing part takes 22 commands so it's not wise to run them all in repeating mode.
3. Tell me how they pick up the shards. And tell if it's possible to grab a whole inventory of items (including offhand) in 1 go. If it is, 22+ command it is. If they can only get the shard one by one, it can be reduced to 2-10.
3. That's the only method I can think of. If you can't take it, just say it and I'll consider this question unsolvable.
Edit: The custom crafting thing sounds unclear. Do you mean a few vanilla shard + a few extra items -> A custom shard? Or changing vanilla recipe like dirt + stone -> shard?
The Latter; I'm using a data pack to make a prismarine shard craftable by using a few prismarine crystals in the crafting table (so they could make as many as 64 at once, but the prismarine crystals are harder to come by, so it's likely that they'll only be making about 10 shards at once). I planned on using command blocks for it, but I don't really mind switching to a function if that performs better.
The Latter; I'm using a data pack to make a prismarine shard craftable by using a few prismarine crystals in the crafting table (so they could make as many as 64 at once, but the prismarine crystals are harder to come by, so it's likely that they'll only be making about 10 shards at once). I planned on using command blocks for it, but I don't really mind switching to a function if that performs better.
Function performs better.
So, from what I've interpreted, you want to make (maybe... 4?) prismarine crystal into a prismarine shard? I don't see why you need to give custom shards :/
How would I go about naming the product of the crafting recipe?
Sorry bout that. apparently custom recipe doesn't support nbt yet.
On the time being, to prevent that 22 commands, can you actually make players use a custom crafting machine? LIke a dispenser placed in a certain location?
If your game is a survival one where ppl can place the crafting table anywhere, that's another case.
I'm trying to make a command that gives a player a prismarine shard with a name if they have a prismarine shard that isn't named. I've gotten it to work with the first one, but once it detects both a named and unnamed prismarine shard, the command no longer works. Does anyone know how I can make a selector test for items with no name rather than a selector that applies to any version of the item?
Repeating command block:
/execute at @a[nbt={Inventory:[{id:"minecraft:prismarine_shard"}]}] unless entity @a[nbt={Inventory:[{id:"minecraft:prismarine_shard",tag:{display:{Name:"{\"text\":\"example\"}"}}}]}] run give @a prismarine_shard{display:{Name:"{\"text\":\"example\"}"}}
Conditional chain command block:
/clear @a minecraft:prismarine_shard 1
Well yeah. Cuz the repeating command won't execute as soon as you have the special shard on you.
I don't know if this works, but give it a try.
Repeating
/give @a[nbt={Inventory:[{id:"minecraft:prismarine_shard",tag:{display:{Name:"{\"text\":\"Prismarine Shard\"}"}}}]}] prismarine_shard{display:{Name:"{\"text\":\"example\"}"}}
Edit: No it doesn't work.
That would work if I spawned in the item using
/give @p prismarine_shard{display:{Name:"{\"text\":\"Prismarine Shard\"}"}}
The problem is I'm making it the item with a custom crafting recipe in a datapack, so I can't make it give you the item with any form of nbt data (as far as I know) to test for.
Ok. I did some testing. There IS a method. But... I guess I'll consult you before I do anything.
1. Whenever the player picks up 1+ shard (yes, just one), all the items will be refreshed. It might cause lag and inconvenience.
2. I need to know whether you're putting this in a command block world or a function file. The refreshing part takes 22 commands so it's not wise to run them all in repeating mode.
3. Tell me how they pick up the shards. And tell if it's possible to grab a whole inventory of items (including offhand) in 1 go. If it is, 22+ command it is. If they can only get the shard one by one, it can be reduced to 2-10.
3. That's the only method I can think of. If you can't take it, just say it and I'll consider this question unsolvable.
Edit: The custom crafting thing sounds unclear. Do you mean a few vanilla shard + a few extra items -> A custom shard? Or changing vanilla recipe like dirt + stone -> shard?
The Latter; I'm using a data pack to make a prismarine shard craftable by using a few prismarine crystals in the crafting table (so they could make as many as 64 at once, but the prismarine crystals are harder to come by, so it's likely that they'll only be making about 10 shards at once). I planned on using command blocks for it, but I don't really mind switching to a function if that performs better.
Function performs better.
So, from what I've interpreted, you want to make (maybe... 4?) prismarine crystal into a prismarine shard? I don't see why you need to give custom shards :/
Edit: Nothing~
How would I go about naming the product of the crafting recipe?
Sorry bout that. apparently custom recipe doesn't support nbt yet.
On the time being, to prevent that 22 commands, can you actually make players use a custom crafting machine? LIke a dispenser placed in a certain location?
If your game is a survival one where ppl can place the crafting table anywhere, that's another case.
This is not yet supported (stated by Dinnerbone)
Command block engineer // Developer // #TeamTrees