Jump to content

Recommended Posts

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?

Posted

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

Posted

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...

×   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.