Skip to content

Instantly share code, notes, and snippets.

@orblazer
Last active April 13, 2018 13:12
Show Gist options
  • Save orblazer/d4b4894b5a5dc0aa5cb276af7e0b871b to your computer and use it in GitHub Desktop.
Save orblazer/d4b4894b5a5dc0aa5cb276af7e0b871b to your computer and use it in GitHub Desktop.
Minecraft entity counts

Count the entities (execpt player) on the world

Setup

Note : All .mcfunction files is on folder entityCount (on world/data/functions)

  1. Run once time init command :
/function entitycount:init
  1. Set loop function :
/gamerule entitycount:gameLoopFunction loop

Result

The result of that is show scoreboard by :

/scoreboard objectives setdisplay sidebar EntityCount

Is here : https://imgur.com/a/ON6cy

# Init scoreboard
scoreboard objectives add EntityCount dummy
scoreboard players set Entities EntityCount 0
scoreboard players set Items EntityCount 0
# Filter entity
scoreboard players tag @e[type=!player] add noCountEntity
scoreboard players tag @e[type=item] add noCountEntity
# Summon exetor
summon minecraft:armor_stand ~ ~2 ~ {NoGravity:1b,CustomName:"§1Executor test Entities",CustomNameVisible:1b,Tags:["exclude_EntityCount","Entities_testEntity"]}
summon minecraft:armor_stand ~ ~1 ~ {NoGravity:1b,CustomName:"§2Executor test Items",CustomNameVisible:1b,Tags:["exclude_EntityCount","Item_testEntity"]}
# Count entities
stats entity @e[type=armor_stand,tag=Entities_testEntity,c=1] set AffectedEntities Entities EntityCount
stats entity @e[type=armor_stand,tag=Item_testEntity,c=1] set AffectedEntities Items EntityCount
# Exclude player
scoreboard players tag @a add exclude_EntityCount
# Updates
execute @e[type=armor_stand,tag=Entities_testEntity,c=1] 0 0 0 testfor @e[type=!item,tag=!exclude_EntityCount]
execute @e[type=armor_stand,tag=Item_testEntity,c=1] 0 0 0 testfor @e[type=item,tag=!exclude_EntityCount]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment