From 0c15c93dcd9d98d8da3920d61c5b0746e02ecd53 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 5 Mar 2025 10:25:17 +0700 Subject: [PATCH] Disallow to specify seed mix as zero to avoid EXTREMELY unlikely case where world's seed is zero, and we are generating chunk at 0, 0, in which Xoshiro256 will generate an exception --- .../mc/otm/worldgen/placement/AbstractEnormousPlacement.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/placement/AbstractEnormousPlacement.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/placement/AbstractEnormousPlacement.kt index defd2c7c4..750d6263b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/placement/AbstractEnormousPlacement.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/placement/AbstractEnormousPlacement.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.worldgen.placement import com.github.benmanes.caffeine.cache.Caffeine import com.github.benmanes.caffeine.cache.Scheduler import com.mojang.serialization.Codec +import com.mojang.serialization.DataResult import com.mojang.serialization.MapCodec import com.mojang.serialization.codecs.RecordCodecBuilder import it.unimi.dsi.fastutil.HashCommon @@ -102,7 +103,7 @@ abstract class AbstractEnormousPlacement(val parameters: Parameters) : Placement val PARAMETERS_CODEC: MapCodec = RecordCodecBuilder.mapCodec { it.group( Codec.INT.minRange(0).fieldOf("chunk_scan_range").forGetter(Parameters::chunkScanRange), - Codec.LONG.fieldOf("seed_mix").forGetter(Parameters::seedMix), + Codec.LONG.validate { if (it == 0L) DataResult.error { "Due to technical limitations, seed_mix can not be zero" } else DataResult.success(it) }.fieldOf("seed_mix").forGetter(Parameters::seedMix), CODEC.listOf().fieldOf("placement").forGetter(Parameters::placementModifiers), ).apply(it, ::Parameters) }