[Bug]: [1.19.2][Crash] Negative value passed to Mth.randomBetweenInclusive() placing jigsaw structure - Exception generating new chunk - Bound must be positive
TigerWalts opened this issue ยท 2 comments
Describe the issue
While generating a structure in The End* Minecraft crashes due to a negative value being passed as a range value to a random number generator:
*On editing the save of the player triggering the crash, they were still in the overworld.
Description: Exception generating new chunk
java.lang.IllegalArgumentException: Bound must be positive
at net.minecraft.world.level.levelgen.BitRandomSource.m_188503_(BitRandomSource.java:22) ~[server-1.19.2-20220805.130853-srg.jar%23269!/:?] {re:classloading}
at net.minecraft.util.Mth.m_216287_(Mth.java:937) ~[server-1.19.2-20220805.130853-srg.jar%23269!/:?] {re:classloading,re:mixin}
at com.stal111.valhelsia_structures.common.world.structures.height.BelowSurfaceHeight.sample(BelowSurfaceHeight.java:36) ~[valhelsia_structures-forge-1.19.2-0.1.0-dev4.jar%23258!/:1.19.2-0.1.0] {re:classloading}
at com.stal111.valhelsia_structures.common.world.structures.ValhelsiaJigsawStructure.m_214086_(ValhelsiaJigsawStructure.java:173) ~[valhelsia_structures-forge-1.19.2-0.1.0-dev4.jar%23258!/:1.19.2-0.1.0] {re:classloading}
at net.minecraft.world.level.levelgen.structure.Structure.m_226596_(Structure.java:84) ~[server-1.19.2-20220805.130853-srg.jar%23269!/:?] {re:mixin,xf:fml:forge:structure,re:classloading,xf:fml:forge:structure,pl:mixin:APP:structure_gel.mixins.json:StructureMixin,pl:mixin:A}
at net.minecraft.world.level.chunk.ChunkGenerator.m_223104_(ChunkGenerator.java:638) ~[server-1.19.2-20220805.130853-srg.jar%23269!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:citadel.mixins.json:ChunkGeneratorMixin,pl:mixin:APP:structure_gel.mixins.json:ChunkGeneratorMixin,pl:mixin:APP:betterstrongholds.mixins.json:DisableVanillaStrongholdsMixin,pl:mixin:APP:bettermineshafts.mixins.json:DisableVanillaMineshaftsMixin,pl:mixin:APP:terrablender_forge.mixins.json:MixinChunkGenerator,pl:mixin:A}
at net.minecraft.world.level.chunk.ChunkGenerator.m_223066_(ChunkGenerator.java:591) ~[server-1.19.2-20220805.130853-srg.jar%23269!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:citadel.mixins.json:ChunkGeneratorMixin,pl:mixin:APP:structure_gel.mixins.json:ChunkGeneratorMixin,pl:mixin:APP:betterstrongholds.mixins.json:DisableVanillaStrongholdsMixin,pl:mixin:APP:bettermineshafts.mixins.json:DisableVanillaMineshaftsMixin,pl:mixin:APP:terrablender_forge.mixins.json:MixinChunkGenerator,pl:mixin:A}
Translating min
and max
to a range where min
is 0
and then translating the result back should avoid the issue:
@Override
public int sample(BlockPos pos, Structure.GenerationContext context, Heightmap.Types heightmapType) {
int min = this.minY(pos, context, heightmapType);
int max = this.maxY(pos, context, heightmapType);
return Mth.randomBetweenInclusive(context.random(), 0, max - min) + min;
}
Minecraft Version
1.19.2
Mods Version
- Modpack:
Valhelsia 5 5.0.5
- Forge:
forge-1.19.2-43.1.47
- Valhelsia Structures:
1.19.2-0.1.0-dev4
- Valhelsia Core:
1.19.2-0.4.0
Log
https://gist.github.com/TigerWalts/84127109337b26be4d28ef66350c66a8