Jump to content

[1.12] Registering Entities


Anagkai

Recommended Posts

The old method for registering entities doesn't work any more. I saw there was a new method that which takes a Resource Location.

 I was wondering, if someone could tell me, what kind of ResourceLocation I need and if there is anything else I need to pay attention to. Obviously I know I should use the Registry Events but I'm kinda lazy and I'll have to write everything from scratch anyway when forge is done. Anyway, if someone can link me on a write-up or example on the entity registry, I'll happily take that, too.

 

EntityRegistry.registerModEntity(EntityGargoyle.class, "biodiversityGargoyle", 0, Biodiversity.MODID, 128, 1, true, 0x262626, 0x666666);

 

One other random question:

How does the setting of spawner base logic work nowadays? Not like this (there is a Resource Location missing as well).

		if(ConfigHandler.genvespiaryspawner){
        TileEntityMobSpawner tileEntity = (TileEntityMobSpawner) world.getTileEntity(new BlockPos((i + 4), (j + 1), (k + 4)));

        if (tileEntity != null) {
                (tileEntity).getSpawnerBaseLogic().setEntityId("biodiversity.biodiversityWasp");
        }

 

Any help is appreciated. Thanks in advance.

Link to comment
Share on other sites

Entities are registered through the EntityEntry registry event. This can be accessed using EntityEntryBuilder#create and finished with EntityEntryBuilder#build to get the EntityEntry. There are a number of optional and required parameters such as EntityEntryBuilder#spawn or EntityEntryBuilder#id respectively that can be chained before ending with EntityEntryBuilder#build.

 

Spawners are set using MobSpawnerBaseLogic#setEntityId like the one used in your example. However, you need the resourcelocation such as "skeleton" or "modid:entityid" if you are not using a Minecraft entity. You can set the id of your entity by chaining EntityEntryBuilder#id to the created instance.

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.