Jump to content

[1.15.2] Biome registered before EntityTypes


QuantumSoul

Recommended Posts

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 ?

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