1

I am trying to make a cool minigame. In the minigame each player has snowballs and they can set up wool combinations in their inventory which will change their snowball abilities. So far my command string for 1 combination is:

Command block 1, repeating replaceitem entity @p[nbt={Inventory:[{Slot:6b,id:"minecraft:red_wool"}]},nbt={Inventory:[{Slot:7b,id:"minecraft:blue_wool"}]},nbt={Inventory:[{Slot:8b,id:"minecraft:yellow_wool"}]}] container 0 snowball{Tags:["Path"]}

Command block 2, repeating execute @e[tag=Path,type=snowball] run setblock ~ ~-2 ~ white_wool keep

With these commands the snowball will leave behind a path for the player to walk across when he has red wool in his 6'th slot, blue wool in his 7'th slot, and yellow wool in his 8'th slot. The problem is that once the snowball is in the air it looses its tag and is just a snowball. I got it to work for all snowballs (not just when the player has a specific combination) with the command:

Command block 1, repeating execute @e[type=snowball] run setblock ~ ~-2 ~ white_wool keep

It just refuses to work with tags. I also got it to work with combinations, but not tags:

command block 1, repeating execute @e[type=arrow] if entity @p[nbt={Inventory:[{Slot:6b,id:"minecraft:red_wool"}]},nbt={Inventory:[{Slot:7b,id:"minecraft:blue_wool"}]},nbt={Inventory:[{Slot:8b,id:"minecraft:yellow_wool"}]}] run setblock ~ ~-2 ~ white_wool keep

The problem with this is that if one player has this combination all players' will leave a path behind. Please let me know if you figure out how to get it to work, I'll let you know if I figure out how to.

  • Why "container"? Players aren't chests. :D – Fabian Röling Mar 15 at 23:48
  • Thats the way the commands work, if you say "container 1" it will be placed in the players second slot, "container 2" will place it in the third slot, etc. – IHaveQuistion Mar 16 at 4:45
  • Maybe it does actually work because the numbers randomly happen to be same, but the intended slot names are "hotbar", "inventory", "armor" and "offhand", at least that's how it was in 1.12. – Fabian Röling Mar 16 at 5:07
  • I'm using 1.13, I think they changed it in that. – IHaveQuistion Mar 16 at 5:14
  • The Minecraft wiki says that both work, but only with a dot between "container" and the number and there are more descriptive titles, as I said. minecraft.gamepedia.com/Commands/replaceitem – Fabian Röling Mar 16 at 10:44
1

Apart from the NBT error (Tags needs to be in EntityTag), this is caused by the bug MC-123289: Snowball entities don't copy the NBT tags of their item when thrown, so the tag you have given it simply gets deleted when the snowball is thrown.

A workaround for this would be to tag the snowball based on a nearby player who matches conditions. Be careful to only apply that to new snowballs (not yet tagged), otherwise it could change from passing by other players. Even with that, it could still happen that a player throws a snowball in the direction of another player and that player gets selected instead, but only if they are really close, which shouldn't be a problem for your usecase.

  • Thanks, that works. Do you think it would also be possible to name the snowball and have all of snowballs of that name tagged? – IHaveQuistion Mar 16 at 4:43
  • You mean naming the snowball item? No, that doesn't work with any item that spawns stuff, not even spawn eggs. Item display names and to-be-spawned entity names are separate things. – Fabian Röling Mar 16 at 5:05
  • No, really, ask a new question if you have a question. This will just get deleted here, you won't get an answer. – Fabian Röling Mar 16 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.