SpongePowered / Sponge

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

Issue with world.Light and Schedule Task #3933

Closed Cleardragonf closed 5 months ago

Cleardragonf commented 10 months ago

Affected Product(s)

SpongeForge

Version

1.16.5

Operating System

11

Java Version

1.8

Plugins/Mods

None

Describe the bug

[20Dec2023 15:09:40] [Server thread/ERROR] [sponge/]: The Scheduler tried to run the task 'hellonblocks-2-S-#0' owned by 'hellonblocks' but an error occurred. java.lang.AbstractMethodError: Method net/minecraft/server/level/ServerLevel.light(Lorg/spongepowered/api/world/LightType;III)I is abstract at net.minecraft.server.level.ServerLevel.light(ServerLevel.java) ~[?:?] at org.spongepowered.api.world.volume.game.EnvironmentalVolume.light(EnvironmentalVolume.java:42) ~[EnvironmentalVolume.class:1.16.5-8.0.0-RC1133] at net.cleardragonf.hellonblock.Spawning.SpawnTesting.isDarkEnough(SpawnTesting.java:33) ~[SpawnTesting.class:?] at net.cleardragonf.hellonblock.Spawning.SpawnTesting.getSpace(SpawnTesting.java:121) ~[SpawnTesting.class:?] at net.cleardragonf.hellonblock.HOB.lambda$payPlayers$1(HOB.java:167) ~[HOB.class:?] at org.spongepowered.common.scheduler.SpongeScheduler.lambda$startTask$1(SpongeScheduler.java:278) ~[SpongeScheduler.class:1.16.5-8.0.0-RC1133] at org.spongepowered.common.scheduler.SpongeScheduler.executeRunnable(SpongeScheduler.java:307) ~[SpongeScheduler.class:1.16.5-8.0.0-RC1133] at org.spongepowered.common.scheduler.SpongeScheduler.startTask(SpongeScheduler.java:271) ~[SpongeScheduler.class:1.16.5-8.0.0-RC1133] at org.spongepowered.common.scheduler.SpongeScheduler.processTask(SpongeScheduler.java:257) ~[SpongeScheduler.class:1.16.5-8.0.0-RC1133] at java.util.concurrent.ConcurrentHashMap$ValuesView.forEach(ConcurrentHashMap.java:4707) ~[?:1.8.0_201] at org.spongepowered.common.scheduler.SpongeScheduler.runTick(SpongeScheduler.java:188) ~[SpongeScheduler.class:1.16.5-8.0.0-RC1133] at org.spongepowered.common.scheduler.SyncScheduler.tick(SyncScheduler.java:41) ~[SyncScheduler.class:1.16.5-8.0.0-RC1133] at org.spongepowered.common.scheduler.ServerScheduler.tick(ServerScheduler.java:42) ~[ServerScheduler.class:1.16.5-8.0.0-RC1133] at net.minecraft.server.MinecraftServer.handler$zfi000$impl$onServerTickStart(MinecraftServer.java:3847) ~[?:?] at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java) ~[?:?] at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:670) ~[?:?] at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:257) ~[?:?] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_201] is the error i get for

` public boolean isDarkEnough(Location spawnLocation) { try { World world = spawnLocation.world();

        int skyLightLevel = world.light(LightTypes.SKY, spawnLocation.blockX(), spawnLocation.blockY(), spawnLocation.blockZ());
        int blockLightLevel = world.light(LightTypes.BLOCK, spawnLocation.blockX(), spawnLocation.blockY(), spawnLocation.blockZ());

        if (skyLightLevel < 5 && blockLightLevel < 5) {
            Sponge.server().broadcastAudience().sendMessage(Component.text("Dark Enough"));
            return true;
        }
    } catch (PositionOutOfBoundsException e) {
        // Handle exception if the location is outside the world boundaries
        return false;
    }
    return false;
}`

Link to logs

No response

mosemister commented 10 months ago

Can confirm this only crashes on API 8.

API 10+ doesn't crash

Cleardragonf commented 10 months ago

...except i'm using spongeforge as my server has mods too...

mosemister commented 10 months ago

That part doesnt matter. Its a case on what to target.

Recently found our that api 8 is end of life so sadly this one wont be fixed. But you probably could use the api 10 implementation code to get the lighting. Ill send a link in a mo

mosemister commented 10 months ago

https://github.com/SpongePowered/Sponge/blob/d469dbd976d860e45af0db8a86afb768d1fafd2f/src/mixins/java/org/spongepowered/common/mixin/api/minecraft/world/level/LevelMixin_API.java#L524

ImMorpheus commented 5 months ago

Hey! You seem to be running an unsupported version (API 8) of SpongeAPI. Support for API 8 ended in October 2023.

API-8 is now end-of-life. We will not be issuing any more API updates for version 8 of our API^1

As part of our legacy cleanup we are closing issues relating to API8/1.16


Since the issue is fixed in API 10, I'll close the issue.