How To Count Entities In A Given Area [1.14]? - Minecraft: Java Edition
Maybe your like
Help Sign In/Register
- Home
- Minecraft Forum
- Minecraft: Java Edition
- Redstone Discussion and Mechanisms
- Commands, Command Blocks and Functions
- How to count entities in a given area [1.14]?
- Home
- Minecraft Forum
- Minecraft: Java Edition
- Redstone Discussion and Mechanisms
- Commands, Command Blocks and Functions
- How to count entities in a given area [1.14]?
Tag » How To Count Entities In Minecraft
-
How To Count Entities With Commands/check If There Are Only One Or A ...
-
How To Count Players/mobs In Minecraft - YouTube
-
How To Use Commands To Count The Number Of Mobs? - Reddit
-
Block/entity/ Player Count Command - Minecraft Feedback
-
Count Entities And Add To Scoreboard - Planet Minecraft
-
Minecraft Count Entities ~ Arqade
-
Entity - Minecraft Wiki - Fandom
-
Entity Count | SpigotMC - High Performance Minecraft - Spigot
-
Minecraft Entity List (Java Edition 1.19) - DigMinecraft
-
Counting Mobs In A Small Area. - MCreator
-
Useful Guide For Minecraft Bedrock Commands And MCFunction
-
Mob And Entity Counter (No Command Block Needed) - MCPEDL
-
[1.16.5] Count Entities For Exporting - Modder Support - Forge Forums
-
10 Cool Minecraft Console Commands For 2022 | HP® Tech Takes
I would like to count the number of entities of a given type in an area. Preferably by issuing a redstone signal proportional to that number. I've seen that thread, that Arqade StackExchange answer and a couple of other similar resources, but they all are using the testfor command which was removed in MC1.13. I'm running MC1.14 Java Edition. So in MC1.14, how to count entities in a given area?
Last edited by s_leroux: Aug 27, 2019 Rollback Post to Revision RollBackPlease, support the sledgehammer tool! I ♥ Linux. Thanks Mojang for providing a game that runs natively on that OS!
/testfor is now a part of /execute and is used like this:
/execute if entity @e[type=sheep]if you don't add a command to run at the end of the "if" statement, it will give out a comparator output if a comparator is attached to the command block.
A more reliable way is to use scoreboard objectives.
create an objective to hold the number of entities:
/scoreboard objectives add entity_count dummyand then run this command to store the amount of sheep around you into your "entity_count" objective:
/execute store result score @s entity_count run execute if entity @e[type=sheep]"store" is a subcommand of the /entity command which can be used to modify variables such as scores, entity data...
once you run this command, you can do:
/scoreboard players get @s entity_countto show how many entities were counted.
Rollback Post to Revision RollBackCommand block engineer // Developer // #TeamTrees
Thanks a lot for your detailed reply Megacrafter107.
It is puzzling me, since when I run this command the output of an attached comparator doesn't seem to reflect the number of entities found. For example, in the image below, the comparator output power is 1 whereas the command output claims having found 2 entities.
I didn't look at scoreboards yet. But assuming I am using a scoreboard like you explained it, how can I get back a redstone power proportional to the stored value?
ATTACHMENTS-
2019-08-28_19.38.49
Rollback Post to Revision RollBackPlease, support the sledgehammer tool! I ♥ Linux. Thanks Mojang for providing a game that runs natively on that OS!
I don't know the answer to that one as I noticed the redstone signal strength did not match my entity count either.
Rollback Post to Revision RollBackCommand block engineer // Developer // #TeamTrees
Thank you for having taken the time to test that.
On my side, I noticed I can have an output signal strength matching the entity count if I use "execute as" and if the execute statement actually runs a command:
--ok-- execute as @e[type=villager,distance=..20] run me "" execute as @e[type=villager,distance=..20] run execute if entity @s --not ok-- execute if @e[type=villager,distance=..20] execute as @e[type=villager,distance=..20] execute as @e[type=villager,distance=..20] runI suspect the output value is the sum of the output values of the commands: if you run for 5 entities a command returning 1, the result is 1+1+1+1+1 and that is what reflects the output signal strength. It is somewhat confirmed by the contrived command below:
[/p] [p]execute as @e[type=villager,distance=..20] run execute if entity @s[tag=T][/p] [p]Here, the nested `execute` command is run once for each villager in the range. And that nested command will return either 0 or 1 depending if the villager is tagged. In my tests, the result value of the outer `execute` command is the number of tagged villagers.
Last edited by s_leroux: Aug 28, 2019 Rollback Post to Revision RollBackPlease, support the sledgehammer tool! I ♥ Linux. Thanks Mojang for providing a game that runs natively on that OS!
It's been a while since I've used a redstone signal as a command block output so I didn't know this worked that way. Thanks for the info
Rollback Post to Revision RollBackCommand block engineer // Developer // #TeamTrees