1

So I am making a kit based map, and I want to allow people to get items back if they accidentally drop them. I have set up scores which activate when someone drops an item. I am able to give them the item with no hitch. The problem comes when I want to reset the score. I tried just setting the score of all players for that score to zero, but for some reason it was always giveing me too little or too much. Right now I have

/scoreboard players set @a[scores={backbow=1},nbt={Iventory:[{id:"minecraft_bow}] backbow 0

which should set all players with a backbow(the score for when someone drops a bow) of 1 and a bow in the inventory to 0, but it doesn't work. There are no error messages. I am completely stumped.

  • There are no error messages? But you didn't even close the string with a second quotation mark! – Fabian Röling Jul 17 at 21:39
1

Using these commands (BOTH!) will prevent players from picking up any item that was dropped by a different player while allowing players to pick up items that they dropped.

/execute as @e[type=minecraft:item] if data entity @s Thrower run data modify entity @s Owner.L set from entity @s Thrower.L
/execute as @e[type=minecraft:item] if data entity @s Owner run data modify entity @s Owner.M set from entity @s Thrower.M

Using this command will set the pickup delay of dropped items to 0, so the item can be picked up imidiately and you really have to try to not pick it up:

/execute as @e[type=minecraft:item] if data entity @s Thrower run data modify entity @s PickupDelay set value 0

Using all 3 of these commands would make items really hard to accidentally get lost by dropping them. I recommend a repeating command block and then 2 chain command blocks.

If you want to be really sure that items don't get lost, then you can create a scoreboard objective that keeps track of item Owner-tags and player UUIDs. And then teleport any item that was dropped by a player to the player who dropped it.

This is how you would set up the scoreboard objective:

/scoreboard objectives add UUIDs dummy

You would then want to set the score for all items and all players:

/execute as @e[type=minecraft:item] if data entity @s Thrower store result score @s UUIDs run data get entity @s Thrower.M 0.0000000001
/execute as @a store result score @s UUIDs run data get entity @s UUIDMost 0.0000000001

When you are done with that you can teleport all thrown items to whatever player threw it:

/execute as @e[type=item] at @a if score @s UUIDs = @p UUIDs run tp ~ ~ ~
  • The scoreboard cannot hold values as high as the UUIDs of a player, it is possible, though incredibly unlikely, that two players have the same number after multiplying the ID by 0.0000000001. – user232393 Aug 25 at 19:30
0

I'm not sure if you retyped it or copy-pasted, but Inventory is missing an 'n' in your command. That might be the problem. Otherwise, I recommend simplifying the command just to test it by running an execute command as @a[scores={backbow=1},nbt={Inventory:[{id:"minecraft_bow}] saying 'Test' or something similar, just to see if it recognizes the person who dropped the bow but also received an item. That way, you can tell if your logic is broken or your command is broken in some way (entity selector or something else).

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.