Jump to content

Using Vanilla Biome inside a BiomeSource CODEC


GamerMine

Recommended Posts

Hello everyone,

I currently have a class to create a BiomeSource to test my dimension. I want to use vanilla biomes in this dimension. The problem is that everytime I try to get a Biome and execute runData I get the following error :
 

[minecraft/RegistriesDatapackGenerator]: Couldn't serialize element /home/maxime/Programming/Java/Deepworld/src/generated/resources/data/deepworld/dimension/deepworld_dimension.json: Unknown registry element in ResourceKey[minecraft:root / minecraft:worldgen/biome_source]:RecordCodec[UnitDecoder[fr.dwightstudio.deepworld.common.dimension.DeepworldBiomeSource$$Lambda$4739/0x00000008016f8b18@68009f48] * Field[lush_caves: RegistryFileCodec[ResourceKey[minecraft:root / minecraft:worldgen/biome] net.minecraftforge.registries.ForgeRegistry$RegistryCodec@ac570e0]]]

So I tried several things and all of them gets into this error when trying to generate data with datagens.

If you want to take a look at my BiomeSource class here it is ( I have removed the imports ):

public class DeepworldBiomeSource extends BiomeSource {

    public static final Codec<DeepworldBiomeSource> CODEC = RecordCodecBuilder.create((instance) -> instance.group(
            Biome.CODEC.fieldOf("lush_caves").forGetter(o -> o.biome1)
    ).apply(instance, instance.stable(DeepworldBiomeSource::new)));

    private final Holder<Biome> biome1;

    public DeepworldBiomeSource(Holder<Biome> biome1) {
        System.out.printf(biome1.toString());
        this.biome1 = biome1;
    }

    public static BiomeSource create(HolderGetter<Biome> biomes) {
        return new DeepworldBiomeSource(biomes.getOrThrow(Biomes.LUSH_CAVES));
    }

    @Override
    protected @NotNull Codec<? extends BiomeSource> codec() {
        return CODEC;
    }

    @Override
    protected @NotNull Stream<Holder<Biome>> collectPossibleBiomes() {
        return Stream.of(this.biome1);
    }

    @Override
    public @NotNull Set<Holder<Biome>> possibleBiomes() {
        return Set.of(this.biome1);
    }

    @Override
    public @NotNull Holder<Biome> getNoiseBiome(int x, int y, int z, Climate.@NotNull Sampler sampler) {
        return this.biome1;
    }
}

If you need any additional informations, ask me.

 

Thank you very much,
Maxime

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.