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.

[1.15.2] Biome registered before EntityTypes

Featured Replies

Posted

Hi,

I tried adding my custom mobs to the spawn list of my custom biome but it crashes:

java.lang.NullPointerException: Registry Object not present on my entitytype

 

I guess it's because EntityTypes are registered after Biomes so what can I do ?

BinaryMod.java

Spoiler

@Mod(MOD_ID)
public class BinaryMod
{
    public static final String MOD_ID = "binarymod";
    public static final Logger LOGGER = LogManager.getLogger();

    public BinaryMod()
    {
        final IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();

        eventBus.addListener(this::setup);
        eventBus.addListener(this::clientSetup);

        BlockInit.BLOCKS.register(eventBus);
        ItemInit.ITEMS.register(eventBus);
        EntityInit.ENTITIES.register(eventBus);

        BiomeInit.BIOMES.register(eventBus);
        DimensionInit.MOD_DIMENSIONS.register(eventBus);

        MinecraftForge.EVENT_BUS.register(this);
    }

    private void setup(final FMLCommonSetupEvent event)
    {
        GenerationInit.initOres();
    }

    private void clientSetup(final FMLClientSetupEvent event)
    {
        RenderInit.initEntities();
    }
}

 

EntityInit.java

Spoiler

public class EntityInit
{
    public static DeferredRegister<EntityType<?>> ENTITIES = new DeferredRegister<>(ForgeRegistries.ENTITIES, MyMod.MOD_ID);

    public static RegistryObject<EntityType<OneEntity>> ONE = ENTITIES.register("one", () -> EntityType.Builder.<OneEntity>create(OneEntity::new, EntityClassification.CREATURE).size(0.6F, 2F).build(BinaryMod.MOD_ID + "one"));
}

 

BiomeInit.java

Spoiler

public class BiomeInit
{
    public static final DeferredRegister<Biome> BIOMES = new DeferredRegister<>(ForgeRegistries.BIOMES, BinaryMod.MOD_ID);

    public static final RegistryObject<Biome> BINARY_BIOME = BIOMES.register("binary_biome", () -> new BinaryBiome());
}

 

BinaryBiome.java

Spoiler

public class BinaryBiome extends Biome
{
    public BinaryBiome()
    {
        super(new Builder().surfaceBuilder(new BinarySurfaceBuilder(SurfaceBuilderConfig::deserialize), new SurfaceBuilderConfig(BlockInit.BINARY_BLOCK.get().getDefaultState(), BlockInit.ON_BINARY_BLOCK.get().getDefaultState(), null))
                .precipitation(Biome.RainType.NONE)
                .category(Category.NONE)
                .depth(0.1F)
                .downfall(0F)
                .scale(0.02F)
                .temperature(1.5F)
                .waterColor(0x00FF00).waterFogColor(0x00FF00)
                .parent(null));

        BinDimBiomeFeatures.addOres(this);
        BinDimBiomeFeatures.addStructures(this);
        this.addSpawn(EntityClassification.CREATURE, new SpawnListEntry(EntityInit.ONE.get(), 50, 1, 3));
		CRASHES HERE
	}
}

 

 

Thanks in advance.

 

 

Btw how do I add spawn eggs ?

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.