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

I'm aware of the many threads regarding adding custom death messages, replacing existing ones, etc..

 

But I'm more interested in replacing how the game grabs death messages. I can't even seem to find in the source where it pulls the death message from.

 

I tried overriding the getDeathMessage method from DamageSource and its sister classes, but that method doesn't even seem to fire on player death.

 

any ideas?

Hi

 

The death messages come from the .lang file, eg

death.attack.lava=%1$s tried to swim in lava

 

I think the code that reads the death message is in DamageSource as you said.

 

    public IChatComponent func_151519_b(EntityLivingBase p_151519_1_)
    {
        EntityLivingBase entitylivingbase1 = p_151519_1_.func_94060_bK();
        String s = "death.attack." + this.damageType;
        String s1 = s + ".player";
        return entitylivingbase1 != null && StatCollector.canTranslate(s1) 
                  ? new ChatComponentTranslation(s1, new Object[] {p_151519_1_.func_145748_c_(), entitylivingbase1.func_145748_c_()})
                  : new ChatComponentTranslation(s, new Object[] {p_151519_1_.func_145748_c_()});
    }

 

When the player dies, this code in EntityPlayerMP is called, which eventually gets to the method above

 

    public void onDeath(DamageSource p_70645_1_)
    {
        if (ForgeHooks.onLivingDeath(this, p_70645_1_)) return;  // you can hook in here using LivingDeathEvent
        this.mcServer.getConfigurationManager().sendChatMsg(this.func_110142_aN().func_151521_b());

 

What do you mean "overriding" getDeathMessage()?  Show the code you tried?

 

-TGG

  • Author

Created my own class which extends DamageSource, then used @Override for replacing the method, basically..

 

that onDeath thing may be what I'm looking for..

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.