forum Forumsplay_arrow Minecraft fiber_manual_record Redstone

1

[1.13] How to detect if a player doesn't have an item in their inventory

1 emerald7 replies150 views
created 11/14/2018 6:13 pm by Dudamesh
last reply 12/01/2018 6:50 am


Title sums it up


basically I need to test if a player (with a certain tag) doesn't have that item in their inventory


I'm using it as a detector for shooting arrows instead of tagging the arrow as it spawns from the player, I'm using it to detect if a player has shot an arrow.


Basically what I've already done is run this command in a loop:


```execute if entity @a[tag=hasGun,nbt={Inventory:{id:"minecraft:arrow"}]}] run scoreboard players set @a[tag=hasGun,nbt={Inventory:{id:"minecraft:arrow"}]}] hasArrow 1```




which sets all players' score tagged "hasGun" with an arrow in their inventory to 1 meaning they have an arrow




then I need to detect when that player has shot their bow (and used up the arrow in their inventory) and then set their score to 0




how exactly does one do that
Posted by avatar
Dudamesh
Level 41 : Master Technomancer
47

7 replies

1
11/19/2018 11:37 am
Level 35 Artisan Engineer
ShelLuser
avatar
Normally you'd also use a Count property when checking for an inventory item. So if you set Count to 0 you'd check if no items are present in the players inventory.
1
11/15/2018 2:06 pm
Level 6 Apprentice Engineer
brobie1kanobi
avatar
I do that all the time man! Sometimes it just takes a "stepping back" second and you usually realize you are over-complicating stuff. lol
1
11/14/2018 8:21 pm
Level 2 Apprentice Architect
Frozy--
avatar
i do remember im most languages including command blocks the "!" indicates a negative


so maybe try putting a ! infront of one of those things


it might just work you never know
1
11/14/2018 8:51 pm
Level 41 Master Technomancer
Dudamesh
avatar
it does work for [tag=!abc] but not for NBT tags




Also I found out a way to fix my problem as I only need to set all players score to 0 on a repeat command block

and set all with arrows to 1, it's a really simple fix I'm quite disappointed in myself for not thinking of it much more earlier
1
11/30/2018 5:31 pm
Level 8 Apprentice Engineer
SUPERIONtheKnight
avatar
It does work for NBT tags, have you tried the following?
/say @s[nbt=!{Inventory:[{id:"minecraft:arrow"}]}]
Also, that is a good solution you found. I use it a lot. :)

~SUPERIONtheKnight
1
12/01/2018 6:50 am
Level 41 Master Technomancer
Dudamesh
avatar
I've already quite gotten over this but it's nice to see people eager to help, even though they are 16 days late xP
1
11/15/2018 4:18 am
Level 2 Apprentice Architect
Frozy--
avatar
hehe the best can make the dumbest mistakes XD

Search

Browse

Site

© 2010 - 2018
planetminecraft.com

Welcome