Check for amount of specific entity in area

Started by afk on

Topic category: Help with MCreator software

Last seen on 02:29, 23. Jul 2024
Joined Mar 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Check for amount of specific entity in area

I'm working on a mod that adds a creature that can be commanded around en masse, much like pikmin. I've got an item that shows an overlay, and I wanted to include how many of this entity are within 24 blocks of this player in the overlay as text.

I feel like i'm extremely close to figuring this out, but can't seem to get it quite right, especially since I've never worked with variables before.

I know how to check for an entity in a box, but not detect how many of a specific entity are in said box, and output it as a variable. Preferably, this would work with multiple players, so not everyone gets the same variable, or the combined total of all players..

Any help is appreciated. I'm honestly not 100% sure this is even possible. but I may as well ask. Variables aren't documented very well..

Last seen on 20:18, 12. Mar 2024
Joined Nov 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Start with a variable set to…
Sat, 07/08/2023 - 22:30

Start with a variable set to zero. For each entity in the box, check whether it is of a specific kind. If it is, increase the variable by one.