Minecraft – How to testfor a donkey in Minecraft

minecraft-commandsminecraft-java-edition

I am trying to testfor a donkey in Minecraft, but if I do \

/testfor @e[type=EntityHorse] {Type:2}

then it won't work. The only way I can think of doing it is testing if the donkey has anything in its chest inventory, but I don't want the player to be able to assess the chest on the donkey, so would there be any way to maybe have a locked chest on a donkey? Also, how would I testfor if the donkey was being ridden by a player?

Best Answer

To "lock" the inventory, you could summon a mule with a saddle: /summon EntityHorse ~ ~ ~ {Type:2,Tame:0,SaddleItem:{id:329},ChestedHorse:1}. Summoning a horse that is not tame and giving it a saddle will make it rideable, with an inaccessable inventory. Also, testing for a mule will work using the /testfor @e[type=EntityHorse] {Type:2} syntax, so you may simply have an issue with your setup. I hope this helps!