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

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

  • Author
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

  • Author
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?

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.