mojira.dev
MC-258191

Root system feature allows hanging root vertical span of 0, causing error

minecraft:root_system feature allows hanging_roots_vertical_span to be set to 0. If a data pack is used to generate such feature, however, this actually causes an error during world generation.

Code analysis (yarn 1.19.2)

RootSystemFeatureConfig's config describes hanging_roots_vertical_span as a value between 0 and 16. (See Codec.intRange(0, 16).fieldOf("hanging_roots_vertical_span"))

In RootSystemFeature#generateHangingRoots, however, random.nextInt is called with the vertical span value. This crashes when the value is 0. (See also MC-254774 for crash with similar cause)

int i = config.hangingRootRadius;
    int j = config.hangingRootVerticalSpan;
    for (int k = 0; k < config.hangingRootPlacementAttempts; k++) {
      mutablePos.set((Vec3i)pos, random.nextInt(i) - random.nextInt(i), random.nextInt(j) - random.nextInt(j), random.nextInt(i) - random.nextInt(i));
int i = config.hangingRootRadius;
    int j = config.hangingRootVerticalSpan;
    for (int k = 0; k < config.hangingRootPlacementAttempts; k++) {
      mutablePos.set((Vec3i)pos, random.nextInt(i) - random.nextInt(i), random.nextInt(j) - random.nextInt(j), random.nextInt(i) - random.nextInt(i));

Attachments

Comments 0

No comments.

apple502j

bl4ckscor3

Plausible

Platform

Low

Custom Worlds, Data Packs

1.19.2, 1.19.3 Pre-release 2

25w36a

Retrieved