Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.16.4]NullPointerException when using registered custom features
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
QWERTY 52 38

[1.16.4]NullPointerException when using registered custom features

By QWERTY 52 38, January 20 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

QWERTY 52 38    0

QWERTY 52 38

QWERTY 52 38    0

  • Tree Puncher
  • QWERTY 52 38
  • Members
  • 0
  • 7 posts
Posted January 20

Code repository: Here

 

I registered my custom feature in FeatureRegistry.java and McbbsWiki.java.

 

FeatureRegistry.java:

public static final DeferredRegister<Feature<?>> FEATURES = DeferredRegister.create(ForgeRegistries.FEATURES, "mcbbswiki");
public static RegistryObject<McbbsWikiLuckyBlockFeature> feature_lucky_block = FEATURES.register("feature_lucky_block", () -> new McbbsWikiLuckyBlockFeature(NoFeatureConfig.field_236558_a_));

 

McbbsWiki.java (the main class of this mod):

FeatureRegistry.FEATURES.register(
	FMLJavaModLoadingContext.get().getModEventBus()
);
 
But, when I used
FeatureRegistry.feature_lucky_block.get()

to get the object (in world.biome.McbbsWikiBiomeMaker.java:37), the game throwed a NullPointerException and crashed.

 

I found out "FeatureRegistry.feature_lucky_block.isPresent()" returned false and "FeatureRegistry.feature_lucky_block.value" is null, but do not know how to solve the problem.

 

The full logs are shown below.Please help me.

latest.log crash-2021-01-20_15.04.42-fml.txt

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7695

diesieben07

diesieben07    7695

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7695
  • 56356 posts
Posted January 20

Show this class: McbbsWikiBiomeMaker.makeMcbbsWikiNormalBiome

  • Quote

Share this post


Link to post
Share on other sites

QWERTY 52 38    0

QWERTY 52 38

QWERTY 52 38    0

  • Tree Puncher
  • QWERTY 52 38
  • Members
  • 0
  • 7 posts
Posted January 20
48 minutes ago, diesieben07 said:

Show this class: McbbsWikiBiomeMaker.makeMcbbsWikiNormalBiome

Attention:This is a method, not a class.

public static Biome makeMcbbsWikiNormalBiome(){
        MobSpawnInfo.Builder mobSpawnInfo = new MobSpawnInfo.Builder();
        mobSpawnInfo.isValidSpawnBiomeForPlayer();
        DefaultBiomeFeatures.withPassiveMobs(mobSpawnInfo);
        mobSpawnInfo.withSpawner(EntityClassification.CREATURE, new MobSpawnInfo.Spawners(EntityRegistry.entity_small_mcbbswiki_monster.get(), 10, 5, 7));
        mobSpawnInfo.withSpawner(EntityClassification.CREATURE, new MobSpawnInfo.Spawners(EntityRegistry.entity_middle_mcbbswiki_monster.get(), 7, 3, 5));
        mobSpawnInfo.withSpawner(EntityClassification.CREATURE, new MobSpawnInfo.Spawners(EntityRegistry.entity_large_mcbbswiki_monster.get(), 4, 1, 3));
        mobSpawnInfo.withSpawner(EntityClassification.CREATURE, new MobSpawnInfo.Spawners(EntityType.LLAMA, 5, 4, 6));
        BiomeGenerationSettings.Builder biomeGeneSettings = (new BiomeGenerationSettings.Builder()).withSurfaceBuilder(ConfiguredSurfaceBuilders.field_244181_m);

        DefaultBiomeFeatures.withStrongholdAndMineshaft(biomeGeneSettings);
        biomeGeneSettings.withStructure(StructureFeatures.RUINED_PORTAL);
        biomeGeneSettings.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, FeatureRegistry.feature_lucky_block.get().withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG));
        DefaultBiomeFeatures.withCavesAndCanyons(biomeGeneSettings);
        DefaultBiomeFeatures.withLavaAndWaterLakes(biomeGeneSettings);
        DefaultBiomeFeatures.withMonsterRoom(biomeGeneSettings);
        DefaultBiomeFeatures.withCommonOverworldBlocks(biomeGeneSettings);
        DefaultBiomeFeatures.withOverworldOres(biomeGeneSettings);
        DefaultBiomeFeatures.withDisks(biomeGeneSettings);
        DefaultBiomeFeatures.withMountainTrees(biomeGeneSettings);
        DefaultBiomeFeatures.withDefaultFlowers(biomeGeneSettings);
        DefaultBiomeFeatures.withBadlandsGrass(biomeGeneSettings);
        DefaultBiomeFeatures.withNormalMushroomGeneration(biomeGeneSettings);
        DefaultBiomeFeatures.withSugarCaneAndPumpkins(biomeGeneSettings);
        DefaultBiomeFeatures.withLavaAndWaterSprings(biomeGeneSettings);
        DefaultBiomeFeatures.withEmeraldOre(biomeGeneSettings);
        DefaultBiomeFeatures.withInfestedStone(biomeGeneSettings);
        DefaultBiomeFeatures.withFrozenTopLayer(biomeGeneSettings);
        return (new Biome.Builder())
                .precipitation(Biome.RainType.RAIN)
                .category(Biome.Category.EXTREME_HILLS)
                .depth(-0.5F)
                .scale(1.3F)
                .temperature(0.7F)
                .downfall(0.3F)
                .setEffects((new BiomeAmbience.Builder())
                        .setWaterColor(0x3f76e4)
                        .setWaterFogColor(0x050533)
                        .setFogColor(0xc0d8ff)
                        .withSkyColor(getSkyColorWithTemperatureModifier(0.7F))
                        .setMoodSound(MoodSoundAmbience.DEFAULT_CAVE).build())
                .withMobSpawnSettings(mobSpawnInfo.copy())
                .withGenerationSettings(biomeGeneSettings.build())
                .build();
    }

See https://github.com/QWERTY770/MCBBS-Wiki-Mod/tree/main/src/main/java/cn/mcbbswiki/qwerty5238/world

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7695

diesieben07

diesieben07    7695

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7695
  • 56356 posts
Posted January 20

You cannot access registry entries directly before FMLCommonSetupEvent. Here you are trying to access the features during the biome registry phase, which will not work.

  • Quote

Share this post


Link to post
Share on other sites

QWERTY 52 38    0

QWERTY 52 38

QWERTY 52 38    0

  • Tree Puncher
  • QWERTY 52 38
  • Members
  • 0
  • 7 posts
Posted January 20
23 minutes ago, diesieben07 said:

You cannot access registry entries directly before FMLCommonSetupEvent. Here you are trying to access the features during the biome registry phase, which will not work.

So, how can I do that?

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7695

diesieben07

diesieben07    7695

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7695
  • 56356 posts
Posted January 20

Do what?

  • Quote

Share this post


Link to post
Share on other sites

QWERTY 52 38    0

QWERTY 52 38

QWERTY 52 38    0

  • Tree Puncher
  • QWERTY 52 38
  • Members
  • 0
  • 7 posts
Posted January 20
2 minutes ago, diesieben07 said:

Do what?

Generate feature mcbbswiki:feature_lucky_block in Mcbbs Wiki Normal Biome

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • diesieben07
      Another freaking "error in currently selected datapacks prevented world from loading"

      By diesieben07 · Posted 1 minute ago

      Does the same occur with a fresh world?
    • Eksity
      Another freaking "error in currently selected datapacks prevented world from loading"

      By Eksity · Posted 3 minutes ago

      ok, now it'll run without optifine. here's the latest.log after I get the "Error in currently selected data packs prevented the world from loading" message. https://gist.github.com/Eksity/787c0b0a9b4a1d71d16ec79c5f906a3a
    • Eksity
      Another freaking "error in currently selected datapacks prevented world from loading"

      By Eksity · Posted 10 minutes ago

      I'll check it out. thanks!   
    • diesieben07
      Another freaking "error in currently selected datapacks prevented world from loading"

      By diesieben07 · Posted 12 minutes ago

      Problem with "Charm". Make sure it is up to date, report to the mod author if it already is.
    • diesieben07
      Do i need minecraft installed

      By diesieben07 · Posted 13 minutes ago

      You need Minecraft installed to install Forge, however you do not need Minecraft installed to set up the MDK.
  • Topics

    • Eksity
      8
      Another freaking "error in currently selected datapacks prevented world from loading"

      By Eksity
      Started 19 hours ago

    • Ariel David
      1
      Do i need minecraft installed

      By Ariel David
      Started 18 minutes ago

    • Skyriis
      12
      [1.16.5] Adding a Button to KeyBindings

      By Skyriis
      Started Wednesday at 04:07 PM

    • Deadlocked47
      1
      Can't get into forge discord

      By Deadlocked47
      Started 21 hours ago

    • IntentScarab
      6
      (SOLVED)[1.16.4] Block entity invalid

      By IntentScarab
      Started 1 hour ago

  • Who's Online (See full list)

    • diesieben07
    • Eksity
    • IntentScarab
    • Aviator737
    • KatiePandaEx
    • Beethoven92
    • Ariel David
    • loordgek
    • Breadabix
    • Cdog26530
    • Seika85
    • SackCastellon
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.16.4]NullPointerException when using registered custom features
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community