How to measure the y-axis size of the space under an entity's feet

Started by dbckswjs(cyc0706) on

Topic category: Help with Minecraft modding (Java Edition)

Joined Oct 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to measure the y-axis size of the space under an entity's feet

I'd like to add a feature to my mod that changes mob behavior based on the height of the ground beneath them. How do I do this?

 

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hi, this code snippet should…
Sat, 02/07/2026 - 19:27

Hi,

this code snippet should be able to measure the distance between an entity and the ground. I did not test it but I think this might work. Be careful with putting it into a tick procedure (On entity tick or sth like that) bc idk how it will behave. Also, I have no clue if the failsafe (the "break out of loop" thingy) is really necessary but I thought it might be a good idea. If you need an exact measurement you can also delete the "round" block for the output but this might give you too many decimal places so I recommend using it anyways.
For your purpose, you might have to change it here and there but I do hope I could help you with this.
https://imgur.com/a/etf1kNK