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

So, title kinda explains it all in a nutshell.

 

So, I have made a datawatcher to keep track of my entity names, but I cannot for the life of me figure out how I would link it to the language file. Currently I am using the EntityList to get the names of the entities, but the names are displayed as modid.entity instead.

 

Not sure this is making any sense, so here is all the relevant code.

 

 

public abstract class EntityTest extends EntityCreature
{




    public EntityTest(World world)
    {
      super(world);
dataWatcher.addObject(4, ""); //Name


      newEntity();
    }


    public void newTest()
    {
        setName(EntityList.getEntityString(this));
        
    }


//Naming process
public String getName() {

return dataWatcher.getWatchableObjectString(4);
}

public void setName(String name) {
dataWatcher.updateObject(4, name);
}

public void writeEntityToNBT(NBTTagCompound nbt)
    {
        super.writeEntityToNBT(nbt);

        nbt.setString("name", getName());
       
    }
    
   

    public void readEntityFromNBT(NBTTagCompound nbt)
    {
       super.readEntityFromNBT(nbt);

       setName(nbt.getString("name"));
     
    }


 

 

And then the code adding the entity, as well as what it is marked down as in the language file

 

EntityRegistry.registerModEntity(EntityTest.class, "TestEntity", 1, testmod.instance, 80, 3, true);

entity.testmod.TestEntity.name=TestEntity

 

 

Now, this will give be the "Player has been slain by TestEntity" when killed, but when setName() is displayed in my render over the mob, it is shown as testmod.TestEntity

 

I figure this is somehow related to the way getEntityString() reads the names from mods. So is is possible to get setName() to read from the Lanuage file names?

 

Thanks for any help you can provide

 

 

 

  • Author

Bumping to see if there are any solutions

Consider reading "CustomNameTag" stuff. It is object 10 in the datawatcher for EntityLiving.

  • Author

Consider reading "CustomNameTag" stuff. It is object 10 in the datawatcher for EntityLiving.

 

Not necessarily what I am looking for.

 

I have a rather large amount of custom entities, and there is nothing there that really satisfies what I am trying to do. I would still need to go through and set each entities name individually in their respective files.

 

Which:

A) Is irrelevant. I am trying to figure out if there is a way I can use EntityList to return the names without it returning as "modid.mobname", as EntityList seems like the best way to set names for over 240 entities without individually going through each file.

 

B) Use the language registry, so it will reflect the language(I.E. Using a spanish lanuage file rendering "Pollo" over a chicken, rather than "Chicken"

You don't need the language registry. It is deprecated for a reason.

Server doesn't need to have any language related thing.

Use StatCollector.translateToLocal(String) on client side and make a .lang file for each language.

  • Author

Sorry sorry. I meant to say language file, instead of registry. Slight typo.

 

But I will definitely try the StatCollector, thanks.

 

 

 

EDIT: Works like a charm, many thanks.

Guest
This topic is now closed to further replies.

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.