I am making a pvp map and i want to have it where if someone stands on a pressure plate with a colored wool block in their inventory a command block will test for lets say 35 5 (Lime wool) then tell another command block to clear the inventory of the person who owns that flag and teleport them to the spawn. If not i know you can definitely test for levels so any ideas on how i could incorporate that?
I don't think you can test for items, but you can test for a level. The argument would be
testfor @p[l=1337,lm=1337]
The "l" argument refers to the minimal level the person has to be and the "lm" argument refers to the max level the player has to be so that he'll be detected by the testfor command.
Actually it is possible to (indirectly) test if a player has an item via it's ID. I think this is due to an update to the /clear command.
What you do is use a cmd block to clear that specific item (/clear ###) and a comparator to check if the cmd succeeded. If it did, it means the player did have the specific item in their inventory, and the comparator will output a signal. Otherwise, if they did not have the item, the comparator will be off.
The quirk here is that the item will be taken away from the player, meaning you may need to give it back. This works for basic items, but not for items with unique data such as enchantments or custom names.
In your case however, I think this would work fine:
/clear @p 35 5
Put that in a cmd block, attach a comparator, followed by another cmd block that simply clears everything with basic /clear. It will clear the player's inventory of lime wool (35:5), and if they had any, will then clear everything else.
Example setup:
Left cmd block has /clear and right cmd block has /clear @p 35 5. Note: you need to unpower the comparator after a success if you need this to work multiple times in a row.
I think this would suit my needs perfectly, however the testfor command cant be limited or set to also check if the user is in gamemode 0 which is part of what i would want to help with grief protection in vanilla
You've awoken on this barren wasteland planet, a civilization once ruled and proud, but where is everyone? All the buildings are empty, nothing remains, all that can be seen is mass hordes in all directions of zombies, skeletons and other creatures never before seen. Inside isn't safe, Outside isn't safe, what will u do to survive this planet and escape? Can you survive the 1st day without death claiming you?
There is no natural light, when night time comes it's pitch black, no moon light and all that is heard is the scratching and moaning of whats around lurking to destroy you. Mining reveals unbeknownst horrors from the rocks just waiting to come out and devour your soul. Puddles of liquid blue or purple are not water, but also intent on harming you.
actually, you can ensure that the victim is not in creative mode. Set the command as "/clear @p[m=0] 35 5". The 'm' checks the players game mode. The value 0 corresponds to survival. 1 corresponds to creative and 2 corresponds to adventure.
Actually it is possible to (indirectly) test if a player has an item via it's ID. I think this is due to an update to the /clear command.
What you do is use a cmd block to clear that specific item (/clear ###) and a comparator to check if the cmd succeeded. If it did, it means the player did have the specific item in their inventory, and the comparator will output a signal. Otherwise, if they did not have the item, the comparator will be off.
The quirk here is that the item will be taken away from the player, meaning you may need to give it back. This works for basic items, but not for items with unique data such as enchantments or custom names.
In your case however, I think this would work fine:
/clear @p 35 5
Put that in a cmd block, attach a comparator, followed by another cmd block that simply clears everything with basic /clear. It will clear the player's inventory of lime wool (35:5), and if they had any, will then clear everything else.
Example setup:
Left cmd block has /clear and right cmd block has /clear @p 35 5. Note: you need to unpower the comparator after a success if you need this to work multiple times in a row.
but how does the second command block (or ones further down the line) know who's inventory to clear or who to TP?
The Meaning of Life, the Universe, and Everything.
Join Date:
4/20/2013
Posts:
276
Location:
memetopia
Minecraft:
WobbegongWachong
Member Details
Are you in a 1.8 snapshot? It doesn't appear so since you are using numeric IDs, but if you are, this is fairly simple (NBT data is now tightly knit with scoreboards!). First, create an objective called insertnamehere. Then, you'll want to make a fill clock. You can learn about fill clocks, how to make them, and their advantages here:
==================================
Then, create a command block with this command, somewhere early on in the fill clock (low x or z coordinate)
/scoreboard players set @a insertnamehere {Inventory:[{id:wool}]}
To test for a specific wool color, use damage values. For example,
/scoreboard players set @a insertnamehere {Inventory:[{id:wool,Damage:4b}]}
You can also test for count, data tags, and inventory slot if needed:
/scoreboard players set @a insertnamehere {Inventory:[{id:wool,Damage:4b,Count:64b,Slot:0b,tag:{display:{Name:"woolymammoth"}}}]}
================================
Next, you'll want to grab the coordinates of your pressure plate and grab another command block, placing it higher on the fill clock (larger x or z coordinate). In this command block, you can do a number of things by looking for a player standing on the pressure plate with the right score. For example, clear their inventory and/or tp them:
/clear @a[x,y,z,0,score_insertnamehere_min=1]
/tp @a[x,y,z,0,insertnamehere_min=1]
========================================
Finally, at the highest point on your fill clock, be 100% sure to place a command block setting all insertnamehere scores to 0, to reset the system.
/scoreboard players set @a insertnamehere 0
==========================================================
Buuutttt, if you're in 1.7. Sorry, I cant help.
The Meaning of Life, the Universe, and Everything.
Join Date:
4/20/2013
Posts:
276
Location:
memetopia
Minecraft:
WobbegongWachong
Member Details
You could try
/clear @p lever 0 1 {display:{}}
I believe this will clear any lever without a display tag, if it woris like anything I've done before. I can't test it now, but I'll let you know later today how it works.
I had a similar problem a few weeks ago. Check out this forum post:
Exactly... I managed to remove renamed items, it's really simple
The problem is that I'm trying to remove an item which hasn't got any custom name... and the command
/clear @p lever 0 1 {display:{}}
isn't working as for the dropper in Wobbegong post (I tested the testforblock command for the dropper, it worked fine).
Items will not contain extra data if that data isn't being used. If the item hasn't been renamed then there is no "display" tag whatsoever on the item. As a result, you simply cannot clear specific items based on the lack of a tag.
The "l" argument refers to the minimal level the person has to be and the "lm" argument refers to the max level the player has to be so that he'll be detected by the testfor command.
What you do is use a cmd block to clear that specific item (/clear ###) and a comparator to check if the cmd succeeded. If it did, it means the player did have the specific item in their inventory, and the comparator will output a signal. Otherwise, if they did not have the item, the comparator will be off.
The quirk here is that the item will be taken away from the player, meaning you may need to give it back. This works for basic items, but not for items with unique data such as enchantments or custom names.
In your case however, I think this would work fine:
/clear @p 35 5
Put that in a cmd block, attach a comparator, followed by another cmd block that simply clears everything with basic /clear. It will clear the player's inventory of lime wool (35:5), and if they had any, will then clear everything else.
Example setup:
Left cmd block has /clear and right cmd block has /clear @p 35 5. Note: you need to unpower the comparator after a success if you need this to work multiple times in a row.
Yes but in this case he wanted to clear all items as a result.
Arduous https://minecraft.curseforge.com/projects/arduous-lost-wasteland
You've awoken on this barren wasteland planet, a civilization once ruled and proud, but where is everyone? All the buildings are empty, nothing remains, all that can be seen is mass hordes in all directions of zombies, skeletons and other creatures never before seen. Inside isn't safe, Outside isn't safe, what will u do to survive this planet and escape? Can you survive the 1st day without death claiming you?
There is no natural light, when night time comes it's pitch black, no moon light and all that is heard is the scratching and moaning of whats around lurking to destroy you. Mining reveals unbeknownst horrors from the rocks just waiting to come out and devour your soul. Puddles of liquid blue or purple are not water, but also intent on harming you.
no, not even in the snapshots, could be added in the future, probaly not tho
- Endus322
but how does the second command block (or ones further down the line) know who's inventory to clear or who to TP?
==================================
Then, create a command block with this command, somewhere early on in the fill clock (low x or z coordinate)
/scoreboard players set @a insertnamehere {Inventory:[{id:wool}]}
To test for a specific wool color, use damage values. For example,
/scoreboard players set @a insertnamehere {Inventory:[{id:wool,Damage:4b}]}
You can also test for count, data tags, and inventory slot if needed:
/scoreboard players set @a insertnamehere {Inventory:[{id:wool,Damage:4b,Count:64b,Slot:0b,tag:{display:{Name:"woolymammoth"}}}]}
================================
Next, you'll want to grab the coordinates of your pressure plate and grab another command block, placing it higher on the fill clock (larger x or z coordinate). In this command block, you can do a number of things by looking for a player standing on the pressure plate with the right score. For example, clear their inventory and/or tp them:
/clear @a[x,y,z,0,score_insertnamehere_min=1]
/tp @a[x,y,z,0,insertnamehere_min=1]
========================================
Finally, at the highest point on your fill clock, be 100% sure to place a command block setting all insertnamehere scores to 0, to reset the system.
/scoreboard players set @a insertnamehere 0
==========================================================
Buuutttt, if you're in 1.7. Sorry, I cant help.
www.youtube.com/user/dinodude162
Bukkit my friend... Bukkit.
To answer the original question (14w32c):
/testfor @p {Inventory:[{id:wool,Damage:4b}]}
/clear @p lever 0 1 {display:{}}
I believe this will clear any lever without a display tag, if it woris like anything I've done before. I can't test it now, but I'll let you know later today how it works.
I had a similar problem a few weeks ago. Check out this forum post:
http://www.minecraftforum.net/forums/minecraft-discussion/redstone-discussion-and/2213521-empty-dropper
www.youtube.com/user/dinodude162
Items will not contain extra data if that data isn't being used. If the item hasn't been renamed then there is no "display" tag whatsoever on the item. As a result, you simply cannot clear specific items based on the lack of a tag.
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/
this is in 1.5.2 version pls help me