mojira.dev
MC-271786

Empty block states in noise_provider does not cause validation to fail, causing crash

Summary
When noise_provider block state provider has empty states, it should cause pack validation to fail; currently it does not, instead causing a crash. (This issue exists in 1.20.6 as well.)

Steps to Reproduce

  • Add the attached pack.

  • Get a pair of boots with the enchantment test:noise.

  • Wear it.

Expected Result
The data pack should fail to validate.

Actual Result
Game crashes.

Attachments

Comments 1

This also affects the minecraft:noise_threshold_provider block state provider's low_states and high_states fields, though the code paths are unrelated.

Code analysis (Yarn mappings)

These issues come from unchecked list sizes in the NoiseBlockStateProvider#getStateAtValue and NoiseThresholdBlockStateProvider#get methods.

The fix is the same for both: replacing the Codec.list(BlockState.CODEC) fields with Codecs.nonEmptyList(BlockState.CODEC). This is the same approach that, for example, world generation features take.

apple502j

(Unassigned)

Confirmed

Platform

Important

Crash

1.20.6, 24w18a, 1.21

24w45a

Retrieved