Jump to content

1.12 What is the use of this ResourceLocation Parameter in EntityRegistry.registerModEntity?


TheRPGAdventurer

Recommended Posts

Hi! I just updated my mod form 1.10.2 to 1.12 I fixed some issues but what is the use of this new ResourceLocation parameter in EntityRegistry.registerModEntity? It doesn't exist in 1.10.2

/**
     * Register the mod entity type with FML

     * @param entityClass The entity class
     * @param entityName A unique name for the entity
     * @param id A mod specific ID for the entity
     * @param mod The mod
     * @param trackingRange The range at which MC will send tracking updates
     * @param updateFrequency The frequency of tracking updates
     * @param sendsVelocityUpdates Whether to send velocity information packets as well
     */
    public static void registerModEntity(ResourceLocation registryName, Class<? extends Entity> entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates)
    {
        instance().doModEntityRegistration(registryName, entityClass, entityName, id, mod, trackingRange, updateFrequency, sendsVelocityUpdates);
    }

 

Link to comment
Share on other sites

Just now, V0idWa1k3r said:

It is used as a registry name for the EntityEntry(ForgeRegistries.ENTITIES) registry. It is simply a registry name just as the one your blocks/items/biomes/potions/whatever have, that's all. You can put anything you want in there, just as you do for your blocks/items/etc.

private void registerEntities() {
        EntityRegistry.registerModEntity(dragon, EntityTameableDragon.class, "RealmOfTheDragon",
                ENTITY_ID, RealmOfTheDragons.instance, ENTITY_TRACKING_RANGE, ENTITY_UPDATE_FREQ,
                ENTITY_SEND_VELO_UPDATES);
    }

I tried this and gave me an error to create a variable, add "" in dragon becames unapplicable, tried to like ResourceLocation dragon, it stops the error yet crashes the game. Same thing when I change it to null. 

Edited by TheRPGAdventurer
forgot something
Link to comment
Share on other sites

4 minutes ago, TheRPGAdventurer said:

EntityRegistry.registerModEntity(dragon, EntityTameableDragon.class, "RealmOfTheDragon", ENTITY_ID, RealmOfTheDragons.instance, ENTITY_TRACKING_RANGE, ENTITY_UPDATE_FREQ, ENTITY_SEND_VELO_UPDATES);

you don't have a local/field named dragon, hence the error. This is basic java.

 

5 minutes ago, TheRPGAdventurer said:

add "" in dragon becames unapplicable

Could you please clarify this? I do not think I understand you here.

 

5 minutes ago, TheRPGAdventurer said:

tried to like ResourceLocation dragon, it stops the error yet crashes the game

Post your code with this try and the crashreport then.

 

5 minutes ago, TheRPGAdventurer said:

Same thing when I change it to null. 

You can't have a null registry name for anything, including entities. 

Link to comment
Share on other sites

add "" in dragon becames unapplicable

I mean "dragon" like "RealmOfTheDragon",

 

Here is the crash error: https://pastebin.com/zPrP5PC6

This is ClienProxy: Java 74

private void registerEntities(ResourceLocation registryName) {  // 73
        EntityRegistry.registerModEntity(registryName, EntityTameableDragon.class, "RealmOfTheDragon", // 74
                ENTITY_ID, RealmOfTheDragons.instance, ENTITY_TRACKING_RANGE, ENTITY_UPDATE_FREQ, // 75
                ENTITY_SEND_VELO_UPDATES); //76
    }

This is ClientProxy : 60 // registerEntities(null) =line 60

@Override
    public void onInit(FMLInitializationEvent evt) {
        super.onInit(evt);
        
        registerEntities(null);

    }

This is RealmOfTheDragons: java 91

@EventHandler
    public void onInit(FMLInitializationEvent evt) { //90
        proxy.onInit(evt); //91
       
    }

 

Edited by TheRPGAdventurer
Update
Link to comment
Share on other sites

26 minutes ago, TheRPGAdventurer said:

EntityRegistry.registerModEntity(registryName

26 minutes ago, TheRPGAdventurer said:

registerEntities(ResourceLocation registryName)

26 minutes ago, TheRPGAdventurer said:

registerEntities(null);

 

28 minutes ago, V0idWa1k3r said:

You can't have a null registry name for anything, including entities. 

 

Additionally registering your entities in your client proxy makes zero sense - entities are common, the server must know about them.

Edited by V0idWa1k3r
Link to comment
Share on other sites

2 minutes ago, TheRPGAdventurer said:

When I removed in my 1.10.2 version, It made my entity invisible or at least didn't exist.

I'm sorry, I don't think I understand you here, What did you remove? If you mean the method you were not supposed to remove it, you were supposed to relocate the call to it to the code that gets executed on both server and the client(aka common code).

Link to comment
Share on other sites

Just now, V0idWa1k3r said:

I'm sorry, I don't think I understand you here, What did you remove? If you mean the method you were not supposed to remove it, you were supposed to relocate the call to it to the code that gets executed on both server and the client(aka common code).

 

Just now, V0idWa1k3r said:

I'm sorry, I don't think I understand you here, What did you remove? If you mean the method you were not supposed to remove it, you were supposed to relocate the call to it to the code that gets executed on both server and the client(aka common code).

registerEntities(); (SHITTY LAGGY INTERNET FROM MY COUNTRY)
Link to comment
Share on other sites

24 minutes ago, V0idWa1k3r said:

you were not supposed to remove it, you were supposed to relocate the call to it to the code that gets executed on both server and the client(aka common code).

The client proxy is for executing the code on the client-side only. Just call this method from your mod class or somewhere else where the code is executed on both the server and the client.

Link to comment
Share on other sites

EntityRegistry.registerModEntity(new ResourceLocation("modid:name"), EntityTameableDragon.class, "RealmOfTheDragon",
                ENTITY_ID, RealmOfTheDragons.instance, ENTITY_TRACKING_RANGE, ENTITY_UPDATE_FREQ,
                ENTITY_SEND_VELO_UPDATES);

It's as simple as that. Have you not used ResourceLocations when registering your items?

  • Like 1
Link to comment
Share on other sites

Just now, Silly511 said:

EntityRegistry.registerModEntity(new ResourceLocation("modid:name"), EntityTameableDragon.class, "RealmOfTheDragon",
                ENTITY_ID, RealmOfTheDragons.instance, ENTITY_TRACKING_RANGE, ENTITY_UPDATE_FREQ,
                ENTITY_SEND_VELO_UPDATES);

It's as simple as that. Have you not used ResourceLocations when registering your items?

Ok thanks.

Link to comment
Share on other sites

Just now, Silly511 said:

EntityRegistry.registerModEntity(new ResourceLocation("modid:name"), EntityTameableDragon.class, "RealmOfTheDragon",
                ENTITY_ID, RealmOfTheDragons.instance, ENTITY_TRACKING_RANGE, ENTITY_UPDATE_FREQ,
                ENTITY_SEND_VELO_UPDATES);

It's as simple as that. Have you not used ResourceLocations when registering your items?

[09:50:13] [main/WARN]: Skipping Entity with id -1

what do you think causes this error?

Link to comment
Share on other sites

2 minutes ago, TheRPGAdventurer said:

in the proxies client proxy and server proxy.

 

RealmOfTheDragons#onPostInit is never called because it has more than one parameter, there should be a warning in the log telling you this.

 

This means that CommonProxy#onPostInit is never called and your entity is never registered.

 

Proxies are for sided code, common code belongs in your @Mod class (or classes called from it). I recommend using an interface rather than a class as the common type of your proxies (i.e. the type of the @SidedProxy field).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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.