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

Coordinate math error causes structure not to generate and possibly other issues

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: Minecraft 1.13-pre2, Minecraft 1.13-pre10, Minecraft 1.13
    • Labels:
      None
    • Confirmation Status:
      Confirmed

      Description

      The bug

      A mistake in coordinate conversion math reduces the likelihood of structures spawning in negative coordinates. This might also cause the /locate command and cartographer maps to direct you to a non-existent structure. It may also be causing other glitches with structures (and other things) along chunk boundaries.

      The correct way to find out which structure region a chunk belongs to requires special handling for negative numbers. E.g. for temples with a region size of 32 (pseudocode):

      offsetChunk = chunk < 0 ? chunk - 32 + 1 : chunk;
      region = offsetChunk / 32;

      That puts chunks -32 to -1 in region -1. This is how it's been computed in previous Minecraft versions.

      But the new code flipped that +1 to a -1. But then when converting back after selecting the random chunk for structure spawning, it does it the same way it did before.

      chunkForStructure = region*32 + random(24);
      

      So, let's say you're chunk -31, 0. You end up in region -2, 0 instead of -1, 0. If the RNG had picked 1, you should have been the lucky chunk and gotten an igloo or something. But instead, it thinks it should put the igloo in chunk -63. But chunk -63 is part of region -3. Any time the RNG ever picks 0 or 1, it cannot generate a structure.

      The other changes to structure generation are clearly deliberate, so this appears to be inadvertent.

      I believe this was introduced in 18w06a.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ProfMobius [Mojang] ProfMobius (Thomas Guimbretiere)
                Reporter:
                AdmiralFwiffo Admiral Fwiffo
              • Votes:
                50 Vote for this issue
                Watchers:
                25 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  CHK: