Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-116480

Structure Block Integrity not consistently random (pseudo-random) over time

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • Minecraft 1.11.2, Minecraft 17w16a, Minecraft 17w16b, Minecraft 17w17a, Minecraft 17w17b, Minecraft 17w18a, Minecraft 17w18b, Minecraft 1.12 Pre-Release 1, Minecraft 1.12 Pre-Release 2, Minecraft 1.12 Pre-Release 5, Minecraft 1.12.2, Minecraft 18w07c, Minecraft 18w11a, 1.16.3, 20w49a, 1.17, 22w15a
    • Confirmed
    • (Unassigned)

      The bug

      When you let a structure block with integrity lower than 1.0 and seed of 0 (= random seed) load a structure every tick, the block at the lowest X, Y and Z coordinate of the structure appears to be less random over time. Compared to the other blocks of the structure, there are longer "streaks" where the block is either loaded or not loaded.

      An extreme example (and reproduction steps) can be seen in this video: https://youtu.be/N8azjRO4KM0
      Every tick a 8x8x8 cube of blocks is placed and afterwards a structure block loads a 8x8x8 cube with an integrity of 0.5. The block at the lowest X, Y and Z coordinates of the resulting cube stays for a significant amount of time the same.

      Code analysis

      20w49a, Mojang names

      When a random seed is used (value 0) the method net.minecraft.world.level.block.entity.StructureBlockEntity.createRandom(long) creates a new Random instance based on the current milliseconds. Despite the milliseconds value being different every tick, the values are too similar as seed for the JDK Random implementation, as described in Earthcomputer's comment.
      A better solution might be to have only one static Random instance which is reused.

            Unassigned Unassigned
            BossCrafter2018 M. C.
            Votes:
            6 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              CHK: