Mojira Archive
MC-219035

Fossil structures can't generate in far east and south blocks of a chunk

When generating a fossil feature the structure is placed at a random position in the chunk. However this position never includes the far east and south blocks in that chunk (chunk coordinates X=15 or Z=15). This is most obvious when generating structures with size 15x15 as those are always placed at chunk coordinate 0, 0 leaving a one block gap.

(Note that the placement in a grid is not a bug as the feature explicitly makes sure that the structures do not cross chunk boundaries.)

How to reproduce:

  1. Create a world with the attached datapack
  2. Teleport to a savanna
  3. Go into spectator mode and fly downwards
  4. You will see the structures as in the image above

(Note that while this reproduction involves a datapack the bug also affects the vanilla fossils, although its much less obvious because of their smaller size and rarity)

Code analysis:

(using the official mappings and some variable renaming)

The position to place the structure in the chunk is calculated by

int x = random.nextInt(16 - size.getX());
int z = random.nextInt(16 - size.getZ());

However, as the upper bound of random.nextInt is exclusive, the maximum value of x is 16 - size.getX() - 1. The structure would then reach to x + size.get(X) - 1 = 16 - 1 - 1 = 14

Fixed

jacobsjo

2021-03-11, 03:22 PM

2021-11-16, 08:59 PM

2021-11-10, 04:06 PM

17

8

Confirmed

Low

Custom Worlds, World generation

world-generation

21w10a, 21w11a

1.18 Pre-release 1