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.
Created Issue:
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.
Added Attachments:
Removed Category: (Unassigned)
Added Affects Versions: 1.21
Added Mojang Priority:
Important
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.