[SPIGOT-2595] World.getHighestBlockYAt returns Y of block above the top non-air block instead of Y of the top non-air block Created: 12/Aug/16  Updated: 13/Aug/16  Resolved: 13/Aug/16

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Bartosz Skrzypczak Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None


 Description   

Documentation of World.getHighestBlockYAt says:

Gets the highest non-air coordinate at the given coordinates

But it actually returns Y of the block above. It also ignores trasparent block (opacity == 0). So the result is that if the top block is tall grass or snow it correctly returns Y of the top block, but if it's not - it returns Y of the block above.

It also causes world.getHighestBlockAt to return incorrect block.

This behavior has been there for a long time and all plugins using these methods probably already rely on the wrong behavior (at least my plugin does and it would break if the behavior changed).



 Comments   
Comment by md_5 [ 13/Aug/16 ]

This method is used by the light map internally.
Docs updated to reflecct that it returns the first transparent block

Comment by Bartosz Skrzypczak [ 12/Aug/16 ]

Probably the best approach would be changing documentation to reflect current behavior (at least to avois further confusion, I was really confused when I noticed that my automated test didn't work because my stub world implementation didn't work the same as craftbukkit implementation)

Comment by Dave Goldsmith [ 12/Aug/16 ]

These two behaviors have definitely been around for a while, and I agree that changing them will break some plugins (including a couple of mine).

Generated at Tue Apr 22 03:30:26 UTC 2025 using Jira 10.3.5#10030005-sha1:190c783f2bd6c69cd5accdb70f97e48812a78d14.