Jump to content

[1.19.2] Cannot get custom biome modifier to work


DinoPawz

Recommended Posts

This is log error:

Caused by: com.google.gson.JsonParseException: Error loading registry data: No key feature in MapLike[{"type":"epictrees:epic_trees_codec","replace":false,"entries":[{"biomes":["minecraft:plains","minecraft:meadow"],"feature":"epictrees:weep_tree"},{"biomes":"minecraft:beach","feature":"epictrees:beach_palm"}],"forge:registry_name":"forge:biome_modifier"}]; No key biomes in MapLike[{"type":"epictrees:epic_trees_codec","replace":false,"entries":[{"biomes":["minecraft:plains","minecraft:meadow"],"feature":"epictrees:weep_tree"},{"biomes":"minecraft:beach","feature":"epictrees:beach_palm"}],"forge:registry_name":"forge:biome_modifier"}]

 

This is my file located at data/epictrees/forge/biome_modifier/epic_trees_codec.json

{
  "type":"epictrees:epic_trees_codec",
  "replace":false,
  "entries": [
    {
      "biomes":["minecraft:plains","minecraft:meadow"],
      "feature":"epictrees:weep_tree"
    },
    {
      "biomes":"minecraft:beach",
      "feature":"epictrees:beach_palm"
    }
  ],"forge:registry_name":"epictrees:epic_trees_codec"
}

And I get the same error with this code:

{
  "type":"epictrees:epic_trees_codec",
  "replace":false,
  "entries": [
    {
      "biomes":["minecraft:plains","minecraft:meadow"],
      "feature":"epictrees:weep_tree"
    },
    {
      "biomes":"minecraft:beach",
      "feature":"epictrees:beach_palm"
    }
  ],"forge:registry_name":"forge:biome_modifier"
}

My main class:

  static DeferredRegister<Codec<? extends BiomeModifier>> BIOME_MODIFIER_SERIALIZERS = DeferredRegister.create(ForgeRegistries.Keys.BIOME_MODIFIER_SERIALIZERS, MODID);

    public static final RegistryObject<Codec<EpicTreesBiomeModifier>> EPIC_TREES_CODEC = BIOME_MODIFIER_SERIALIZERS.register("epic_trees_codec", () ->
            RecordCodecBuilder.create(builder -> builder.group(
                    // declare fields
                    Biome.LIST_CODEC.fieldOf("biomes").forGetter(EpicTreesBiomeModifier::biomes),
                    PlacedFeature.CODEC.fieldOf("feature").forGetter(EpicTreesBiomeModifier::feature)
                    // declare constructor
            ).apply(builder, EpicTreesBiomeModifier::new)));

    public EpicTrees()
    {
        final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();

        // Register the Deferred Register to the mod event bus so blocks get registered
        BLOCKS.register(modEventBus);
        // Register the Deferred Register to the mod event bus so items get registered
        ITEMS.register(modEventBus);
        BLOCK_ENTITIES.register(modEventBus);
        ModFeatures.register(modEventBus);
        BIOME_MODIFIER_SERIALIZERS.register(modEventBus);


        // Register ourselves for server and other game events we are interested in
        MinecraftForge.EVENT_BUS.register(this);

        //ModEntities.ENTITIES.register(modEventBus);
        //MinecraftForge.EVENT_BUS.register(WanderingArboristSpawner.class);


        //modEventBus.addListener(this::clientSetup);
        // Register the commonSetup method for modloading
        modEventBus.addListener(this::commonSetup);

    }
public record EpicTreesBiomeModifier(HolderSet<Biome> biomes, Holder<PlacedFeature> feature) implements BiomeModifier
{
    @Override
    public void modify(Holder<Biome> biome, Phase phase, ModifiableBiomeInfo.BiomeInfo.Builder builder) {
        if (phase == Phase.ADD && biomes.contains(biome))
        {
            // add things to biomes
            builder.getGenerationSettings().addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, feature);
        }
    }

    @NotNull
    public Codec<? extends BiomeModifier> codec()
    {
        // This must return a registered Codec, see Biome Modifier Serializers below.
        return EpicTrees.EPIC_TREES_CODEC.get();
    }

}

And I have printed out the names of the Deferred Register objects to confirm the feature names are specified correctly and each feature, configured feature and the placed feature versions are registered with the same name.

Link to comment
Share on other sites

You don't need to write your write your own biome modifier for this.

https://github.com/MinecraftForge/MinecraftForge/blob/b0caea8e204a7f026646396558d6d58a02bff9d6/src/main/java/net/minecraftforge/common/world/ForgeBiomeModifiers.java#L31

You put your "entries" in different files. Example from the testsuite:

https://github.com/MinecraftForge/MinecraftForge/blob/1.19.x/src/generated_test/resources/data/biome_modifiers_test/forge/biome_modifier/add_basalt.json

 

If you want to get yours to work with that json format, then you will need to change your codec and BiomeModifier implementation so it knows what you mean by "entries"s.

Edited by warjort
  • Thanks 1

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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.

Announcements



×
×
  • Create New...

Important Information

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