SpongeAPI: Get Highest Block at Specific Location

In Bukkit there was a World.getHighestBlockAt(Location) and World.getHighestBlockYAt(Location) method, which returned the highest non air block at the given location and the Y position of that block respectively.

Unless there is some other really easy way to do this, I think these methods should be added to API

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 20 (15 by maintainers)

Commits related to this issue

Most upvoted comments

World.getHeight(BlockPos) does not iterate, it returns the current value from an internal height map of the chunk.

There are actually 2 height values that may be useful, one of them is the one that ignores transparent blocks (including glass) and the other that is called precipitation heightmap which ignores non-solid blocks like tall grass or torches but doesn’t ignore glass.

Both of them make sense in different situation. It seems like precipitation heightmap is actually more useful - it’s the top block that entities won’t fall through.

Minecraft implements both of them by simply getting value from internal heighmap so it would always be more efficient than iterating.

PS for any devs looking at this, Internally it is net.minecraft.world.getHeight(BlockPos)