[SPIGOT-7498] ChunkSnapshot.getBlockEmittedLight() gets 64 blocks upper in Overworld Created: 04/Oct/23 Updated: 25/Dec/24 Resolved: 05/Oct/23 |
|
| Status: | Resolved |
| Project: | Spigot |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor |
| Reporter: | Han GoHoon | Assignee: | Marvin Rieple |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | bug | ||
| Environment: |
Apple M2 Max macOS sonoma 14 openjdk 17.0.8 2023-07-18 Spigot 1.20.2 (Described in Version field){} |
||
| Attachments: |
|
| Version: | This server is running CraftBukkit version 3904-Spigot-224dad5-1bf30a4 (MC: 1.20.2) (Implementing API version 1.20.2-R0.1-SNAPSHOT) |
| Guidelines Read: | Yes |
| Description |
|
To summarize, If I use below code(0, 0, 0), api actually gets emitted light of (0, 64, 0).
getServer()
.getWorlds()
.stream()
.filter(world -> world.getEnvironment() == World.Environment.NORMAL)
.findFirst()
.get()
.getChunkAt(0, 0, true)
.getChunkSnapshot()
.getBlockEmittedLight(0, 0, 0) // results block emitted light of 0, 64, 0
As a result, the lowest 4 sections (in 64 height) are clipped(cannot retrieve), and top-most 4 sections (in 64 height) are filled unknown values.
I attached:
To reproduce:
This will prints result of ChunkSnapshot.getBlockEmittedLights() from (0, -64, 0) to (0, 319, 0) of Overworld when plugin enable phase in server startup.
This may be overly intrusive, but I'll try to describe the likely cause of the issue. I think there is a mistake in CraftChunk.getChunkSnapshot(boolean, boolean, boolean) Implementation. It initializes emitLightArray(+skyLightArray) with SectionPosition.of, but the second argument used in SectionPosition.of is index instead of position. Overworld's section position starts from -4(Math.floor(chunk.getMinBuildHeight() / 16.0f)), but implementation always starts from 0. Described above may not the main cause of this issue, but the picture of 'expected' behaviour was taken after modification of described lines.
I'm not native English speaker, sorry about poor english. If you need any more information, please comment below.
Below is answer of Issue Report Guideline.
|
| Comments |
| Comment by Marvin Rieple [ 05/Oct/23 ] |
|
Made a PR for this: craftbukkit#1271 You can test it with BuildTools: java -jar BuildTools.jar --rev 3904 --compile SPIGOT --pr craftbukkit:1271 And thanks for this very good issue report! |