Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7498

ChunkSnapshot.getBlockEmittedLight() gets 64 blocks upper in Overworld

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • This server is running CraftBukkit version 3904-Spigot-224dad5-1bf30a4 (MC: 1.20.2) (Implementing API version 1.20.2-R0.1-SNAPSHOT)
    • Yes

      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:

      • Entry.java : Minimal reproduce source code(without any build files included in plugin), which used in reproduce plugin jar.
      • LightsFromChunkSnapshot-1.0-SNAPSHOT.jar : reproduce plugin jar
      • world : Tested void world. torch placed in (0, -63, 0), (0, 129, 0) over stones in (0, -64, 0), (0, 128, 0)
      • actual.png : The actual behaviour of API (plugin)
      • expected.png : The expected behaviour of API (plugin)

      To reproduce:

      1. Place spigot-*.jar in server directory
      2. run spigot-*.jar with `java -jar`
      3. modify eula.txt, from `eula=false` to `eula=true`
      4. Paste attached 'world' world into server directory
      5. Paste attached plugin into plugins directory
      6. rerun spigot-*.jar with 'java -jar'

      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.

      1. All bugs which occur on Vanilla must FIRST be reported to https://bugs.mojang.com/.
        -> This isn't related with vanilla I think. I cannot use APIs in Vanilla...?
      2. All bugs must be tested on the latest version of Vanilla, CraftBukkit, and Spigot.
        +-> Tested Spigot built right before posting this issue.
        +
      3. You must first make sure the bug has not already been reported by checking the list of open 1.14.x bugs: https://hub.spigotmc.org/jira/issues/?filter=12200
        -> I searched with 'ChunkSnapshot' and 'getBlockEmittedLight' keyword, but none matched.
      4. All bugs must identify the version(s) they occur on
        -> described in Version, but: Spigot 1.20.2
      5. All bugs must include complete written reproduction steps that may be followed by someone that does not necessarily understand the aspect of Minecraft you are talking about.
        1. eg do not assume that the reader understands how to tame and saddle a horse, or build a specific redstone device.
          -> I tried to do this, but I don't know I did well...
        2. Videos may be included, but should only supplement the written information.
          -> Not related.
        3. If your world is causing a crash, then you need to actually upload a copy of your world or at least the relevant parts.
          -> Not related.
      6. All behavioural bugs must be reproducible without any plugins installed on the server.
        -> Yes.
      7. All API bugs must include a reproducer plugin jar and source code that does nothing except the bare minimum to show the bug you are reporting.
        -> I attached.
      8. All feature requests must include an example of how you plan to use that feature.
        -> Not related.
      9. All bugs should include the amount of time you spent on steps 1-8.
        -> I hope this means THIS paragraph.

        1. actual.png
          actual.png
          303 kB
        2. Entry.java
          1 kB
        3. expected.png
          expected.png
          302 kB
        4. LightsFromChunkSnapshot-1.0-SNAPSHOT.jar
          2 kB
        5. world.zip
          811 kB

            DerFrZocker Marvin Rieple
            hoonkun Han GoHoon
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: