Command Block : Testing For Entities
This might not be possible, but i wanted to see if anybody had an answer before i tried something else.
So in one of my worlds, i have a Minecart Command block which, gets triggered as it rides round a track, but is there a way to actually Test For it existing?
I have tried /testfor @e[type=MinecartCommandBlock]
But it just outputs[00:44:19] Unknown command. Try /help for a list of commands. When it works just fine in the in-game console:
Found entity.Minecart.Command.Block.name
Does anybody know a way to solve or know of a way around this?
Best Answer
This command should work. If the time is always the same in the output and doesn't change, the command might be succeeding but not outputting to the console. Try using a comparator directly next to the command block to check whether it is finding the Minecart Command Block. If the comparator is lit, the command is succeeding. If the comparator is not lit, the command is either incorrect or the block could not find the entity you're looking for. If it continues outputting
[00:44:19] Unknown command. Try /help for a list of commands
then try opening the command block, pressing CTRL + A to highlight all, then pressing CTRL + C to copy. Next, break the block and place a new one, then open this new block and do CTRL + V to paste. Sometimes when I have this problem it helps to "reset" the block in this way.
Pictures about "Command Block : Testing For Entities"



How do you test entity in Minecraft?
2. Type the CommandPlayer/Entity movement detector! - Minecraft command block testing world
More answers regarding command Block : Testing For Entities
Answer 2
You will need to use the appropriate name of the block/item dependant on your Minecraft Version.
Minecraft 1.11 and Later
Now, I'm going to assume that you are using the newest version yet, Minecraft 1.11.2 .
If so, perfect.
You'll want to modify your command so it looks a bit like this:
/testfor @e[type=Commandblock_minecart,r=5]
The Radius-Parameter isn't necessary, but useful for when you are in an area hosting many Command-Block-Minecarts (As you'll be able to detect and maybe get rid of the ones you don't need with the Radius-Parameter).
The:
type=Commandblock_minecart
... bit, is to specify that It Is Indeed a Command-Block-Minecart; the new ID was introduced in the early 1.11 Release (Snapshot 16w32a), because... well, Mojang haven't specified a reason yet, but it's assumable that it's to prevent typos.
Link to the Gamepedia-Wiki page on it: Command Block Minecarts
(Note: that the capitalisation of 'Command' is in place by standard. If it does not work for you, change the first letter to a lowercase 'c'. That goes for all items/blocks referenced in commands.)
Minecraft 1.10 and Versions Before
If your version is, as said above, 1.10 or before, you'll have to use the original in-place name for it:
MinecartCommandBlock
... and in a /testfor command:
/testfor @e[type=MinecartCommandBlock,r=5]
Again, the Radius-Parameter isn't necessary, I regularly insert them for clarity and by-tradition.
(Second Note: The ' /testfor '-Command is only present in Minecraft Versions 1.5 (Snapshot 13w03a) and Higher!)
Summary
In short, different names are used to improve readability, portability and general mark-up.
' commandblock_minecart ' for Minecraft 1.11 and Later,
whilst,
' MinecartCommandBlock ' for Minecraft 1.5 to 1.10 .
I hope my answer has helped solve your conundrum.
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Pavel Danilyuk, Alex Tepetidis, Alex Tepetidis, Rizki Koto
