[SPIGOT-5523] world#getHighestBlockAt and world#getHighestBlockYAt no longer ignore transparent blocks, returning a higher value Created: 17/Jan/20  Updated: 21/Jan/20  Resolved: 21/Jan/20

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

Type: Bug Priority: Minor
Reporter: Zedadias Wick Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: World, getHighestBlockAt, getHighestBlockYAt

Attachments: Java Archive File SpigotTestPlugin-0.1-SNAPSHOT.jar    
Version: This server is running CraftBukkit version git-Spigot-037559e-752cf95 (MC: 1.15.1) (Implementing API version 1.15.1-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

world#getHighestBlockAt and world#getHighestBlockYAt both return the block above the highest block, including transparent blocks. Previously it only returned the highest fully opaque block.

The JavaDocs seems to indicate that this should not include transparent blocks:

https://hub.spigotmc.org/javadocs/spigot/org/bukkit/World.html#getHighestBlockAt-org.bukkit.Location-

"Gets the lowest block at the given Location such that the block and all blocks above it are transparent for lighting purposes."

https://hub.spigotmc.org/javadocs/spigot/org/bukkit/World.html#getHighestBlockYAt-org.bukkit.Location-

"Gets the y coordinate of the lowest block at the given Location such that the block and all blocks above it are transparent for lighting purposes."

In earlier versions (I believe 1.13.2 and below), these methods would return the highest full block, rather than the highest non-air block.

I have attached a simple plugin to test this. With the plugin installed, stand on any block and toggle shift to see the returned y value of both methods returned in chat.

I have tested this in 1.15.1, but I believe this change occurred in 1.14.



 Comments   
Comment by md_5 [ 17/Jan/20 ]

See SPIGOT-2595 where the doc was changed to match behaviour at the time

Comment by Zedadias Wick [ 17/Jan/20 ]

Sure. Arguably a new method could be made to maintain support for older plugins, but I think you're right. If we need to ignore transparent blocks we can easily check if the block below isn't opaque and search down from there. The reverse isn't quite so easy.

Comment by md_5 [ 17/Jan/20 ]

Honestly I think this is better / more useful behaviour and the doc should be changed.

The only reason it was the other way is previously that was the only way the method could be more useful / faster than a simple for loop.

Generated at Tue Apr 22 07:16:06 UTC 2025 using Jira 10.3.5#10030005-sha1:190c783f2bd6c69cd5accdb70f97e48812a78d14.