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    7697

diesieben07

diesieben07    7697

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7697
  • 56382 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    7697

diesieben07

diesieben07    7697

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7697
  • 56382 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    7697

diesieben07

diesieben07    7697

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7697
  • 56382 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

    • GhostGamesFSM
      1.16 Ore generation.

      By GhostGamesFSM · Posted 10 minutes ago

      sorry for the txt, but thanks for the comment. I don't have a BiomeLoadingEvent, but I just have to see how I do that. When I have that I send you a message if that works.
    • HOTSAUCEMAN
      help with loading my world

      By HOTSAUCEMAN · Posted 11 minutes ago

      just ran it again to get more updated logs  debug-1.log.gz
    • HOTSAUCEMAN
      help with loading my world

      By HOTSAUCEMAN · Posted 15 minutes ago

      when loading into my world it says its loading, and then changes to a dirt background with no text; i've looked at multiple threads, forums and videos but i can't find any issue similar to mine (at least on a similar version)  debug-1.log.gz
    • Beethoven92
      [1.16.5] Beacon Overwrite (Screen Error)

      By Beethoven92 · Posted 22 minutes ago

      I apologize...i misread the part where you say that your custom beacon inventory actually opens fine! Yeah, the proximity check is doing its job, the problem seems to be that when pressing the confirm button you are sending a vanilla CUpdateBeaconPacket, then handled by the server, which will check if your open container is a BeaconContainer. It would be helpful to see the complete code you have, please post a link to your repository
    • Beethoven92
      [1.16.5] How to make EnchantedBook go to Custom ItemGroup

      By Beethoven92 · Posted 40 minutes ago

      Show what you tried then. It should be "enchantment.your_mod_id.your_enchantment_id"
  • Topics

    • GhostGamesFSM
      2
      1.16 Ore generation.

      By GhostGamesFSM
      Started 17 hours ago

    • HOTSAUCEMAN
      1
      help with loading my world

      By HOTSAUCEMAN
      Started 15 minutes ago

    • Nyko
      3
      [1.16.5] Beacon Overwrite (Screen Error)

      By Nyko
      Started Yesterday at 07:22 AM

    • samjviana
      5
      [1.16.5] How to make EnchantedBook go to Custom ItemGroup

      By samjviana
      Started Sunday at 10:00 PM

    • DrigglyEast
      0
      Fatally Missing Registry Entries

      By DrigglyEast
      Started 2 hours ago

  • Who's Online (See full list)

    • alexro871
    • GhostGamesFSM
    • Beethoven92
    • IntentScarab
    • CookieLukas
    • Tavi007
    • HOTSAUCEMAN
    • zlappedx3
    • am pro
  • 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