How do I select all but two types of entities in Minecraft with the type selector?

I’ve asked this question towards a developer for Minecraft and I thought I’d ask here too since they might not see the question.

How do I select all but two types of entities in Minecraft?

For example, something like: /say @e[type=![Player,Item],r=50] (to clarify I also tried type=Item,Player, type=Item,type=Player etc)

Should select any entity that does not match players or items, so things like Creepers, Ghasts, XPOrbs, PrimedTNT and so on within a radius of 50 blocks and print them to the chat.

Instead it ignores one of the flags, and works with the other instead.

Answer

First, create a dummy scoreboard objective:

/scoreboard objectives add selectMe dummy

Then, on a fast redstone clock, give all entities a selectMe score of 1:

/scoreboard players set @e selectMe 1

Give all players and items a selectMe score of 0 with these two command blocks:

/scoreboard players set @e[type=Player] selectMe 0

/scoreboard players set @e[type=Item] selectMe 0

Now, you can select them by targeting all entities within a 50 block radius that have a selectMe score of 1:

/say @e[score_selectMe_min=1,r=50]

Hope this helped! 🙂

Attribution
Source : Link , Question Author : Codingale , Answer Author : idtownie

Leave a Comment