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

Some blockstates appear twice in a debug world



    • Bug
    • Resolution: Won't Fix
    • None
    • Minecraft 1.12.2, Minecraft 17w47b, Minecraft 17w48a, Minecraft 17w49a, Minecraft 17w49b, Minecraft 17w50a, Minecraft 18w02a, Minecraft 18w03b, Minecraft 18w07a, Minecraft 18w14b, Minecraft 1.13, Minecraft 18w30b, Minecraft 18w31a, Minecraft 1.13.1, Minecraft 1.13.2, Minecraft 19w03c, Minecraft 19w04a, Minecraft 19w09a, 1.14.4, 1.15 Pre-release 6, 20w13b, 20w17a, 20w21a, 1.16 Pre-release 8, 1.16.1, 1.16.4, 20w46a, 21w16a
    • None
    • Confirmed
    • Debug, World generation
    • Low


      The bug

      In a Debug world setting, where every block with every states generates. However, all blocks will appear a second time with the exact same states, if they are happen to generate ar the end of the z-axis (z=165). They will then appear again at the beginning of the next row (x-coordinate + 2, z=1).

      How to reproduce

      1. When creating a new world, go to more world options click the world type button holding shift until it says "Debug Mode" to create a debug world
      2. Now look for example at the blocks at 3 70 165 and 5 70 1. Press F3 to displaay the state at the bottom right. In that case both blocks will be minecraft:dispenser[facing=west,triggered=false]

      Code analysis

      In (MCP 9.40 naming) the function net.minecraft.world.gen.ChunkGeneratorDebug.getBlockStateFor(int p_177461_0_, int p_177461_1_):

      if (p_177461_0_ > 0 && p_177461_1_ > 0 && p_177461_0_ % 2 != 0 && p_177461_1_ % 2 != 0)
      	p_177461_0_ = p_177461_0_ / 2;
      	p_177461_1_ = p_177461_1_ / 2;
      	if (p_177461_0_ <= GRID_WIDTH && p_177461_1_ <= GRID_HEIGHT)
      		int i = MathHelper.abs(p_177461_0_ * GRID_WIDTH + p_177461_1_);
      		if (i < ALL_VALID_STATES.size())
      			iblockstate = ALL_VALID_STATES.get(i);

      The west-east grid size is used in a place that should be using the north-south grid size.
      int i = MathHelper.abs(p_177461_0_ * GRID_WIDTH + p_177461_1_);
      should be
      int i = MathHelper.abs(p_177461_0_ * GRID_HEIGHT + p_177461_1_);

      There is an off-by-one: a <= at the southern edge which should be a <.
      if (p_177461_0_ <= GRID_WIDTH && p_177461_1_ <= GRID_HEIGHT)
      should be
      if (p_177461_0_ < GRID_WIDTH && p_177461_1_ < GRID_HEIGHT)

      The off-by-one is what makes this bug visible; without it, you just have a slightly wrong grid size, and no-one would care or notice. It only causes it to show up when the two switched sizes are unequal, like in these snapshots or 1.10.2 for example, and not in 1.11.2 or 1.12.2 for example.


        Issue Links



              Unassigned Unassigned
              Schortan [Mod] NeunEinser
              17 Vote for this issue
              12 Start watching this issue