Liahim Posted January 4, 2022 Share Posted January 4, 2022 (edited) I am trying to do this: @OnlyIn(Dist.CLIENT) @SubscribeEvent public void onChunkLoaded(ChunkEvent.Load event) { if (event.getWorld().isClientSide()) { if (event.getWorld() instanceof Level) { Level world = (Level) event.getWorld(); DataLayer sky = world.getLightEngine().getLayerListener(LightLayer.SKY).getDataLayerData(SectionPos.of(event.getChunk().getPos().x, 64 >> 4, event.getChunk().getPos().z)); if (sky != null) System.out.println(sky.get(8, 8, 8)); } } } But I get zero all the time. If I try to do this at any other time after loading the chunk, the result will be correct. In addition, everything worked correctly on version 1.17.x Edited January 4, 2022 by Liahim Quote Sorry, I don't speak English very well... Link to comment Share on other sites More sharing options...
Liahim Posted January 4, 2022 Author Share Posted January 4, 2022 (edited) No, that doesn't work either. @SubscribeEvent public void onChunkLoaded(ChunkEvent.Load event) { if (event.getWorld().isClientSide()) { if (event.getWorld() instanceof Level) { Level world = (Level) event.getWorld(); LayerLightEventListener sky = world.getLightEngine().getLayerListener(LightLayer.SKY); BlockPos pos = new BlockPos(event.getChunk().getPos().getWorldPosition().above(70)); //Tried at different heights MutableBlockPos mPos = BlockPos.ZERO.mutable(); for (int x = 0; x < 16; ++x) { for (int z = 0; z < 16; ++z) { int s = sky.getLightValue(mPos.set(pos).move(x, 0, z)); System.out.println(pos + "_" + s); } } } } } Location? I've tried this in a lot of locations. It outputs either zero or 15 (obviously in empty chunk sections) to the console... Edited January 4, 2022 by Liahim Quote Sorry, I don't speak English very well... Link to comment Share on other sites More sharing options...
Liahim Posted January 4, 2022 Author Share Posted January 4, 2022 1 minute ago, diesieben07 said: It's not what I told you to do. This is exactly what you said. If we look into the Level#getBrightness method, we can see the same thing. default int getBrightness(LightLayer type, BlockPos pos) { return this.getLightEngine().getLayerListener(type).getLightValue(pos); } 5 minutes ago, diesieben07 said: I meant show this code: For example: @SubscribeEvent public void playerTick(PlayerTickEvent event) { if (event.side == LogicalSide.CLIENT && event.phase == Phase.START ) { if (event.player.tickCount % 20 == 0) { Level world = event.player.level; LayerLightEventListener sky = world.getLightEngine().getLayerListener(LightLayer.SKY); BlockPos pos = new BlockPos(event.player.blockPosition()); MutableBlockPos mPos = BlockPos.ZERO.mutable(); for (int x = 0; x < 16; ++x) { for (int z = 0; z < 16; ++z) { int s = sky.getLightValue(mPos.set(pos).move(x, 0, z)); System.out.println(pos + "_" + s); } } } } } It doesn't matter where and how to do it. I see incorrect data only during the chunk load event. And this happens only at 1.18.x Quote Sorry, I don't speak English very well... Link to comment Share on other sites More sharing options...
Liahim Posted January 4, 2022 Author Share Posted January 4, 2022 (edited) 16 minutes ago, diesieben07 said: Then why did you copy it instead of calling getBrightness? In order not to receive the LayerLightEventListener 256 times, but to receive it only once. 16 minutes ago, diesieben07 said: Then Mojang changed something about the chunk loading. And if you look into the code then you will see that chunk loading and light update are now two separate packets (as opposed to 1.17 and earlier). So first the chunk is loaded and then it later receives its light data. Not much you can do about this. Could you point me to where the light data is being retrieved? Perhaps I can somehow intercept this packet or add a mixin call to it. I really need to know this exactly at the time of loading the chunk, since I am making a lightmap. Maybe I should ask the forge team to add a special event for this? Or is it easier for me to add my own ticker for each chunk and retrieve data one tick after loading? 😄 Edited January 4, 2022 by Liahim Quote Sorry, I don't speak English very well... Link to comment Share on other sites More sharing options...
Liahim Posted January 4, 2022 Author Share Posted January 4, 2022 Thanks! I'll see what I can do about it. Quote Sorry, I don't speak English very well... Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.