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
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
Now look for example at the blocks at
3 70 165
and5 70 1
. Press F3 to displaay the state at the bottom right. In that case both blocks will beminecraft: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_)
:
ChunkGeneratorDebug.java
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_ * {color:red}GRID_WIDTH{color} + p_177461_1_);
should beint i = MathHelper.abs(p_177461_0_ * {color:green}GRID_HEIGHT{color} + p_177461_1_);
There is an off-by-one: a <=
at the southern edge which should be a <
.if (p_177461_0_ {color:red}<={color} GRID_WIDTH && p_177461_1_ {color:red}<={color} GRID_HEIGHT)
should beif (p_177461_0_ {color:green}<{color} GRID_WIDTH && p_177461_1_ {color:green}<{color} 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.
Linked issues
is duplicated by 6
Attachments
Comments 13
Actually, looking at it again, it seems like all blockstates at the end of a Z-axis-row (z=165) appear again at the next higher x-coordinate at Z=1.
The same code problem exists in 1.15-pre6, although conditions are not favorable to actually reproduce (by my calculations, with the current 11337 states, GRID_WIDTH is 107 and GRID_HEIGHT is 106, which I think hides the actual problem. But I'm not 100% sure)
@unknown, just to let you know, the bug tracker is not a discussion forum. If you'd like to talk about the outcome of a bug, please do so on either the Mojira Discord or Mojira Reddit.
this is only a guess but maybe one's the 'Entrance' and the others the 'Exit', as you yourself can make custom end gateways. another possibility is that there's a technical state for them that we the players cannot access and is purely for the game.