mark codecs stable

This commit is contained in:
dfsek
2022-04-04 18:07:45 -07:00
parent 4b8efd1a36
commit ef95b25c2d

View File

@@ -19,13 +19,16 @@ import com.dfsek.terra.fabric.generation.TerraBiomeSource;
public final class Codecs {
public static final Codec<RegistryKey> TERRA_REGISTRY_KEY = RecordCodecBuilder
.create(registryKey -> registryKey.group(Codec.STRING.fieldOf("namespace")
.stable()
.forGetter(RegistryKey::getNamespace),
Codec.STRING.fieldOf("id")
.stable()
.forGetter(RegistryKey::getID))
.apply(registryKey, registryKey.stable(RegistryKey::of)));
public static final Codec<ConfigPack> CONFIG_PACK = RecordCodecBuilder
.create(config -> config.group(TERRA_REGISTRY_KEY.fieldOf("pack")
.stable()
.forGetter(ConfigPack::getRegistryKey))
.apply(config, config.stable(id -> FabricEntryPoint.getPlatform()
.getConfigRegistry()
@@ -37,10 +40,13 @@ public final class Codecs {
public static final Codec<TerraBiomeSource> TERRA_BIOME_SOURCE = RecordCodecBuilder
.create(instance -> instance.group(RegistryCodecs.dynamicRegistry(Registry.BIOME_KEY, Lifecycle.stable(), Biome.CODEC)
.fieldOf("biome_registry")
.stable()
.forGetter(TerraBiomeSource::getBiomeRegistry),
Codec.LONG.fieldOf("seed").stable()
Codec.LONG.fieldOf("seed")
.stable()
.forGetter(TerraBiomeSource::getSeed),
CONFIG_PACK.fieldOf("pack").stable()
CONFIG_PACK.fieldOf("pack")
.stable()
.forGetter(TerraBiomeSource::getPack))
.apply(instance, instance.stable(TerraBiomeSource::new)));
@@ -48,14 +54,19 @@ public final class Codecs {
instance -> instance.group(
RegistryCodecs.dynamicRegistry(Registry.STRUCTURE_SET_KEY, Lifecycle.stable(), StructureSet.CODEC)
.fieldOf("structures")
.stable()
.forGetter(FabricChunkGeneratorWrapper::getNoiseRegistry),
TERRA_BIOME_SOURCE.fieldOf("biome_source")
.stable()
.forGetter(FabricChunkGeneratorWrapper::getBiomeSource),
Codec.LONG.fieldOf("seed").stable()
Codec.LONG.fieldOf("seed")
.stable()
.forGetter(FabricChunkGeneratorWrapper::getSeed),
CONFIG_PACK.fieldOf("pack").stable()
CONFIG_PACK.fieldOf("pack")
.stable()
.forGetter(FabricChunkGeneratorWrapper::getPack),
ChunkGeneratorSettings.REGISTRY_CODEC.fieldOf("settings")
.stable()
.forGetter(FabricChunkGeneratorWrapper::getSettings)
).apply(instance, instance.stable(FabricChunkGeneratorWrapper::new))
);