forum Forumsplay_arrow Minecraft fiber_manual_record Redstone

1

Help with testfor (@e)

1 emerald7 replies1,700 views
created 07/06/2014 3:16 pm by TheRedSkorpion
last reply 07/06/2014 4:15 pm
I tried to use /testfor to detect if a specific block was dropped on the ground. Here is my command:
/testfor @e[type=Item] {id:"minecraft:firework_charge"}
This command doesnt work and I dont know why.

Other possibility could be to have a custom name and testfor it instead (but I don't know if I can testfor a custom name for an item on the ground). Also, I didn't know if the custom name should go in the data tag or between the square brackets after the selector.
My item also have custom echantment.

Basicaly, I would like to know if it is possible to detect these data tags for an item on the ground: id (i know I can check the id, but it doesn't work for some reasons :/ ), name, ench.

Thanks for reading
Posted by avatar
TheRedSkorpion
Level 18 : Journeyman Engineer
10

comment Login or register to post a reply.

7 replies

07/06/2014 4:14 pm
Level 18 : Journeyman Engineer
TheRedSkorpion
I found the solution! Thanks for the help, I jsut didnt remember that when you write a data tag of an item entity, it's writen like so:
{Item:{data}}

Edit: You can also test for id, custom name and ench that way! You can also just use /testfor
/testfor @e[type=Item] {Item:{id:"minecraft:firework_charge",tag:{display:{Name:"TEST"},ench:[{id:1,lvl:1}]}}}
07/06/2014 4:10 pm
Level 7 : Apprentice Engineer
HawkpathAS
I was not aware that you can test for a datatag! When was that added?
07/06/2014 4:15 pm
Level 18 : Journeyman Engineer
TheRedSkorpion
Hum I think the one of the 1.8 snapshot
07/06/2014 3:46 pm
Level 18 : Journeyman Engineer
TheRedSkorpion
I tought about using scoreboard but I supposed that using id:"minecraft:firework_charge" in the data tag of my testfor should work. Before it worked...

And my item is a firework charge, not just a normal firework.

Thanks for the answer, really, I just wanted to know if it was possible so I'm gonna use scoreboard probaly.
07/06/2014 3:31 pm
Level 7 : Apprentice Engineer
HawkpathAS
Sadly, you can't check for a custom name even if you do rename it because the item entity doesn't retain this bit of information. This method is a bit more complicated than you might like, but it works.

First add an objective. It can have any name, for example, "fireworkItem".

/scoreboard objectives add fireworkItem dummy

Next, you want to make a redstone clock (any kind is fine really, just Google "hopper clock" if you want an efficient one). Connected to this clock should be a command block with the following command:

/scoreboard players set @e[type=Item] fireworkItem 1 {id:minecraft:fireworks}

Then, attach another command block to the same clock with the following command:

/testfor @e[type=Item,score_fireworkItem_min=1]

That's it! If you have any issues, feel free to ask me.
07/06/2014 3:47 pm
Level 14 : Journeyman Engineer
Skylinerw
As of 14w21a, most entities will accept the "CustomName" tag, which includes item entities. As well, the syntax is incorrect: item entities store its item data within the "Item" compound tag:

/testfor @e[type=Item] {Item:{id:minecraft:firework_charge}}
/scoreboard players set @e[type=Item] OBJECTIVE 1 {Item:{id:minecraft:firework_charge}}

/testfor would be used if you merely want to detect the presence, while /scoreboard would be used to both detect it and manipulate it via /execute and other commands.

EDIT: modified the item ID to match above post.
07/06/2014 3:21 pm
Level 15 : Journeyman Unicorn
TBGPrison
I think its minecraft:firework, not sure. (I suck at redstone/commandblocks)

Planet Minecraft

Browse

Site

© 2010 - 2019
planetminecraft.com

Welcome