Jump to content

[1.17.1] Error when creating custom biome


Goosey

Recommended Posts

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?

Link to comment
Share on other sites

  • 2 weeks later...
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

Link to comment
Share on other sites

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);
    }
  }

 

 

Link to comment
Share on other sites

  • 2 weeks later...

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.