Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I've been trying to implement a custom biome and I've run across an error that crashes my game when trying to create a new world and disallows me to enter any existing worlds.

I followed this tutorial for making biomes (with one or two changes to class names and method names).

My code looks like this

Spoiler

 

public static final ResourceKey<Biome> MAPLE_BIOME = ResourceKey.create(Registry.BIOME_REGISTRY, new ResourceLocation(GooseMod.MODID, "maple_forest"));

private void setup(final FMLCommonSetupEvent event) {
   	event.enqueueWork(() -> {
        ModWorldGeneration.registerConfiguredFeatures();
        BiomeManager.addAdditionalOverworldBiomes(MAPLE_BIOME);
    });
}

@SubscribeEvent(priority = EventPriority.HIGH)
  public static void onBiomeLoad(BiomeLoadingEvent event) {
  ResourceKey<Biome> eventBiomeKey = ResourceKey.create(Registry.BIOME_REGISTRY, event.getName());
  if (eventBiomeKey == MAPLE_BIOME)
  {
    event.getGeneration().getFeatures(GenerationStep.Decoration.VEGETAL_DECORATION).add(() -> ORANGE_MAPLE);
    event.getGeneration().getFeatures(GenerationStep.Decoration.VEGETAL_DECORATION).add(() -> RED_MAPLE);
    event.getGeneration().getFeatures(GenerationStep.Decoration.VEGETAL_DECORATION).add(() -> YELLOW_MAPLE);
  }
}
}

 

and the exception is this

Spoiler

java.lang.IllegalStateException: Missing: ResourceKey[minecraft:worldgen/biome / goosemod:maple_forest]
    at net.minecraft.core.Registry.getOrThrow(Registry.java:476) ~[forge-1.17.1-37.0.104_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading}
    at net.minecraft.world.level.biome.OverworldBiomeSource.lambda$new$5(OverworldBiomeSource.java:36) ~[forge-1.17.1-37.0.104_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading}
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[?:?] {}
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[?:?] {}
    at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) ~[?:?] {}
    at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735) ~[?:?] {}
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[?:?] {}
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[?:?] {}
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[?:?] {}
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?] {}
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) ~[?:?] {}
    at net.minecraft.world.level.biome.BiomeSource.<init>(BiomeSource.java:29) ~[forge-1.17.1-37.0.104_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading}
    at net.minecraft.world.level.biome.OverworldBiomeSource.<init>(OverworldBiomeSource.java:34) ~[forge-1.17.1-37.0.104_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading}
    at net.minecraft.client.gui.screens.worldselection.WorldPreset$1.generator(WorldPreset.java:36) ~[forge-1.17.1-37.0.104_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading}
    at net.minecraft.client.gui.screens.worldselection.WorldPreset.create(WorldPreset.java:166) ~[forge-1.17.1-37.0.104_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.screens.worldselection.CreateWorldScreen.lambda$create$0(CreateWorldScreen.java:120) ~[forge-1.17.1-37.0.104_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:runtimedistcleaner:A}
    at java.util.Optional.map(Optional.java:260) ~[?:?] {}
    at net.minecraft.client.gui.screens.worldselection.CreateWorldScreen.create(CreateWorldScreen.java:120) ~[forge-1.17.1-37.0.104_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.screens.worldselection.SelectWorldScreen.lambda$init$4(SelectWorldScreen.java:58) ~[forge-1.17.1-37.0.104_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.components.Button.onPress(Button.java:29) ~[forge-1.17.1-37.0.104_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.components.AbstractButton.onClick(AbstractButton.java:17) ~[forge-1.17.1-37.0.104_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.components.AbstractWidget.mouseClicked(AbstractWidget.java:111) ~[forge-1.17.1-37.0.104_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.components.events.ContainerEventHandler.mouseClicked(ContainerEventHandler.java:28) ~[forge-1.17.1-37.0.104_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.MouseHandler.lambda$onPress$0(MouseHandler.java:87) ~[forge-1.17.1-37.0.104_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.screens.Screen.wrapScreenError(Screen.java:530) ~[forge-1.17.1-37.0.104_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.MouseHandler.onPress(MouseHandler.java:85) ~[forge-1.17.1-37.0.104_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.MouseHandler.lambda$setup$4(MouseHandler.java:181) ~[forge-1.17.1-37.0.104_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.util.thread.BlockableEventLoop.execute(BlockableEventLoop.java:90) ~[forge-1.17.1-37.0.104_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.client.MouseHandler.lambda$setup$5(MouseHandler.java:180) ~[forge-1.17.1-37.0.104_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:runtimedistcleaner:A}
    at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:36) ~[lwjgl-glfw-3.2.2.jar%2354!:build 10] {}

What exactly am I missing? I understand that the tutorial is for 1.16, but I couldn't find anything for 1.17 and so far it hasn't been that difficult to implement it into my project. Did they add a step in 1.17?

why on earth are you creating a ResourceKey in BiomeLoadingEvent, you should use the Name you get from the Event and the Location of the ResourceKey (you can get it from ResourceKey#location) instead also is your FMLCommonSetupEvent fierd?

  • Author
9 hours ago, Luis_ST said:

also is your FMLCommonSetupEvent fierd?

My FMLCommonSetupEvent is being fired, I've debugged the method call but nothing seems out of the ordinary.

12 hours ago, Luis_ST said:

why on earth are you creating a ResourceKey in BiomeLoadingEvent, you should use the Name you get from the Event and the Location of the ResourceKey (you can get it from ResourceKey#location) instead

Why?

  • Author
39 minutes ago, Luis_ST said:

Why?

It's what it said to do here. Again it was the only resource I had on this.

  • Author
12 hours ago, Luis_ST said:

yeah that's correct but you should call ResourceKey#get and not ResourceKey#create

I can't find any method named get in ResourceKey

sorry my mistake, did not see that the tutorial is for 1.16 and ResourceKey#get in 1.17 has been removed
i would recommend you to use the ResourceLocations instead,
one location you can get from the Event the other from your ResourceKey via ResourceKey#location

  • 2 weeks later...
  • Author
On 11/12/2021 at 4:09 PM, Luis_ST said:

sorry my mistake, did not see that the tutorial is for 1.16 and ResourceKey#get in 1.17 has been removed
i would recommend you to use the ResourceLocations instead,
one location you can get from the Event the other from your ResourceKey via ResourceKey#location

I've implemented this, but I am still getting errors when trying to add my custom biome

  • Author
21 hours ago, Luis_ST said:

post updated code

Spoiler
public static final ResourceKey<Biome> MAPLE_BIOME = ResourceKey.create(Registry.BIOME_REGISTRY, new ResourceLocation(GooseMod.MODID, "maple_forest"));

private void setup(final FMLCommonSetupEvent event) {
  event.enqueueWork(() -> {
    BiomeManager.addAdditionalOverworldBiomes(MAPLE_BIOME);
  });
}
  
  @SubscribeEvent(priority = EventPriority.HIGH)
  public static void onBiomeLoad(BiomeLoadingEvent event) {
    if (event.getName().equals(MAPLE_BIOME.location())) {
      event.getGeneration().getFeatures(GenerationStep.Decoration.VEGETAL_DECORATION).add(() -> ORANGE_MAPLE);
      event.getGeneration().getFeatures(GenerationStep.Decoration.VEGETAL_DECORATION).add(() -> RED_MAPLE);
      event.getGeneration().getFeatures(GenerationStep.Decoration.VEGETAL_DECORATION).add(() -> YELLOW_MAPLE);
    }
  }

 

 

  • 2 weeks later...

if you add your Biome to the Overworld via BiomeManager#addAdditionalOverworldBiomes,
you need to register your Biome via DeferredRegister or RegistryEvent

unfortunately a json only Biome does not work in this case

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.