But, i can't clear only the original torches and it make infinite loop with the first torch.
I would like a solution like clear @p minecraft:torch{!CanPlaceOn} or similarly, but if you find an other vanilla way it's okay, only the result count
Thx by advance
Ps: I want to do the same with wheat seeds
(EDIT) (SPOILER) SOLUTION :
For dropped item :
/execute as @e[type=item,nbt={Item:{id:"minecraft:wheat_seeds"}}] unless entity @s[nbt={Item:{tag:{CanPlaceOn:["minecraft:farmland"]}}}] run data merge entity @s {Item:{tag:{CanPlaceOn:["minecraft:farmland"]}}}
All seeds on the ground are modified unless they are already modified
I can't find any way to do exactly what you're asking. Sadly there isn't any way to remove an item that doesn't have an NBT tag (although you can remove items with NBT tags). If you want to do something similar you could remove one item and then give the player a different similar item (like torches to redstone torches). The following would work for that (repeating):
Thanks for your answer, I could effectively use Redstone torches but I must make a system that change them into normal torches when placed... Or make a tool (flint and steel?) that transform torches with a right clic... Any ideas?
For the seeds, I need that the player can farm wheat and plant seeds (canplaceon farmland)... How could I add the tag when they pop?
OK I found out how make automatically placable seeds.
In a command block on repetitive mode and always active :
/execute as @e[type=item,nbt={Item:{id:"minecraft:wheat_seeds"}}] unless entity @s[nbt={Item:{tag:{CanPlaceOn:["minecraft:farmland"]}}}] run data merge entity @s {Item:{tag:{CanPlaceOn:["minecraft:farmland"]}}}
All seeds on the ground are modified unless they are already modified 😁
I'm searching for a similar way for the torches... Or maybe with scoreboards
OK I found out how make automatically placable seeds.
In a command block on repetitive mode and always active :
/execute as @e[type=item,nbt={Item:{id:"minecraft:wheat_seeds"}}] unless entity @s[nbt={Item:{tag:{CanPlaceOn:["minecraft:farmland"]}}}] run data merge entity @s {Item:{tag:{CanPlaceOn:["minecraft:farmland"]}}}
All seeds on the ground are modified unless they are already modified 😁
I'm searching for a similar way for the torches... Or maybe with scoreboards
Items in the player's inventory cannot be modified, so torches would have to be on the ground in order to modify them. But I guess that's not an option so maybe use what bbnumber2 said.
I effectively want it the most transparent for the player. Transforming every Redstone torches near the player is pretty risky because I have some Redstone mechanism in the map...
Can the player have an unlimited amount of torches?
Like an achievement, if the player crafts a torch, he gets an unlimited amount of torches (one torch and a command gives him another one when he places it) I Can't think of anything else other than that.
No, the player can mine coal in mines, and rods in bushes, and he have to make torches to go through the mines...
I'm actually looking for an execute command, where I check what is selected in his inventory, and if it's torch(es) but not tagged with canplaceon, I modify it.
I have to find how to data merge an item in the intentory...
No, the player can mine coal in mines, and rods in bushes, and he have to make torches to go through the mines...
I'm actually looking for an execute command, where I check what is selected in his inventory, and if it's torch(es) but not tagged with canplaceon, I modify it.
I have to find how to data merge an item in the intentory...
You're wasting your time with that because you can't modify an item in an inventory, you can only replace it with a new one.
But in order to replace it, you would have to know how many items are in that slot.
Hi everybody.
I'm "working" on a adventure map where the player can craft torches and place them on wooden planks in mines.
After a lot of research, I find this with 2 commandblock in loop chain with condition :
/clear @p minecraft:torch 1
/give @p minecraft:torch{CanPlaceOn["dark_oak_plank"]} 1
But, i can't clear only the original torches and it make infinite loop with the first torch.
I would like a solution like clear @p minecraft:torch{!CanPlaceOn} or similarly, but if you find an other vanilla way it's okay, only the result count
Thx by advance
Ps: I want to do the same with wheat seeds
(EDIT) (SPOILER) SOLUTION :
For dropped item :
/execute as @e[type=item,nbt={Item:{id:"minecraft:wheat_seeds"}}] unless entity @s[nbt={Item:{tag:{CanPlaceOn:["minecraft:farmland"]}}}] run data merge entity @s {Item:{tag:{CanPlaceOn:["minecraft:farmland"]}}}
All seeds on the ground are modified unless they are already modified
For Crafted item :
First, create 2 scoreboards :
Then, 4 command blocks :
1st command block, activated by Redstone clock:
/execute store result score @p[scores={craft=1..}] lumiere run clear @p[scores={craft=1..}] minecraft:torch</span>
2nd, chained to the 1st (conditional)
3rd always active, loop
/give @p[scores={lumiere=1..}] minecraft:torch{CanPlaceOn:["dark_oak_planks"]}
4th always active, chained to the 3rd (Conditional) :
Every time a player make the craft, the items are cleared then replaced by tagged ones.
I can't find any way to do exactly what you're asking. Sadly there isn't any way to remove an item that doesn't have an NBT tag (although you can remove items with NBT tags). If you want to do something similar you could remove one item and then give the player a different similar item (like torches to redstone torches). The following would work for that (repeating):
Chained:
Sorry that I couldn't find a way to do your exact request.
Thanks for your answer, I could effectively use Redstone torches but I must make a system that change them into normal torches when placed... Or make a tool (flint and steel?) that transform torches with a right clic... Any ideas?
For the seeds, I need that the player can farm wheat and plant seeds (canplaceon farmland)... How could I add the tag when they pop?
I don't think you can detect a right click with a flint and steel because you can't detect which block you clicked.
You could use:
Command block engineer // Developer // #TeamTrees
OK I found out how make automatically placable seeds.
In a command block on repetitive mode and always active :
All seeds on the ground are modified unless they are already modified 😁
I'm searching for a similar way for the torches... Or maybe with scoreboards
Items in the player's inventory cannot be modified, so torches would have to be on the ground in order to modify them. But I guess that's not an option so maybe use what bbnumber2 said.
Command block engineer // Developer // #TeamTrees
I effectively want it the most transparent for the player. Transforming every Redstone torches near the player is pretty risky because I have some Redstone mechanism in the map...
I don't give up, research in progress...
Can the player have an unlimited amount of torches?
Like an achievement, if the player crafts a torch, he gets an unlimited amount of torches (one torch and a command gives him another one when he places it) I Can't think of anything else other than that.
Command block engineer // Developer // #TeamTrees
No, the player can mine coal in mines, and rods in bushes, and he have to make torches to go through the mines...
I'm actually looking for an execute command, where I check what is selected in his inventory, and if it's torch(es) but not tagged with canplaceon, I modify it.
I have to find how to data merge an item in the intentory...
You're wasting your time with that because you can't modify an item in an inventory, you can only replace it with a new one.
But in order to replace it, you would have to know how many items are in that slot.
Command block engineer // Developer // #TeamTrees
I have something... It use scoreboard :
1st command block, activated by Redstone :
2nd always active, loop
3rd always active, chained to the 2nd :
I can make 1st command block actived every minutes and it work but that's dirty if the player have only special torches...
How could I detect if player have normal torches in his inventory? Or just made a craft?
Command block engineer // Developer // #TeamTrees
OK, it work!
1st command block, activated by Redstone clock:
2nd, chained to the 1st (conditional)
3rd always active, loop
4th always active, chained to the 3rd (Conditional) :
Before, I have to create 2 scoreboard :
Thanks for your help. The last thing I could improve would be to make ONE "give" with the scoreboard value instead if this ugly loop... Any ideas?
This is something that a lot of players would like to do but cannot.
You can't insert a scoreboard value into a given command.
Command block engineer // Developer // #TeamTrees
OK. Everything sounds good for me, thanks for your help. I close the thread