SpongePowered / Sponge

The SpongeAPI implementation targeting vanilla Minecraft and 3rd party platforms.
MIT License
384 stars 211 forks source link

BlockVolume's highestYAt throws an error if the height is negative value. #3924

Open masagameplay opened 10 months ago

masagameplay commented 10 months ago

Affected Product(s)

SpongeForge, SpongeVanilla

Version

1.19.4-10.0.0-RC1407

Operating System

Windows 10

Java Version

Java 17

Plugins/Mods

A plugin that is tries to get highest block of given coordinates

Describe the bug

When using BlockVolume's highestYAt in a world with heights lower than 0, the following error occurs

java.lang.IllegalArgumentException: The value -16 is not in the specified inclusive range of 0 to 255
    at org.apache.commons.lang3.Validate.inclusiveBetween(Validate.java:1032) ~[?:?]
    at net.minecraft.util.SimpleBitStorage.get(SimpleBitStorage.java:184) ~[?:?]
    at net.minecraft.world.level.levelgen.Heightmap.getFirstAvailable(Heightmap.java:166) ~[?:?]
    at net.minecraft.world.level.levelgen.Heightmap.getHighestTaken(Heightmap.java:162) ~[?:?]
    at net.minecraft.world.level.chunk.LevelChunk.highestYAt(LevelChunk.java:1548) ~[?:?]

Link to logs

No response

AlexandreArcil commented 9 months ago

Hello, I tested with SpongeVanilla and I didn't have the error.

Here is my test code:

@Listener
private void onLogin(final ServerSideConnectionEvent.Join event) {
    Task build = Task.builder().plugin(this.container).delay(Ticks.of(20))
            .execute(() -> event.player().sendMessage(Component.text(event.player().world().highestYAt(-100, -100)))
            ).build();
    Sponge.game().asyncScheduler().submit(build);
}

and the result: Capture

Try to update to the latest version of Sponge Vanilla, or give the plugin which throw the error please.