[TUTORIAL] Custom death messages

Started by Shocking Artist on

Topic category: User side tutorials

Last seen on 19:21, 24. Apr 2024
Joined May 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[TUTORIAL] Custom death messages
Sat, 08/21/2021 - 13:44 (edited)

This feature is now included in core, custom code is no longer needed

 

Define the damage source

First, create a procedure and choose the block name deal damage with source, input a number for amount (it would not matter as the code will be changed) and click on GENERIC.

Then, find this line of code:

entity.attackEntityFrom(DamageSource.GENERIC, (float) amount);

and change it to this:

DamageSource source = new DamageSource("sourcename").setDamageBypassesArmor();

You will need to rename source and sourcename yourself

 

Deal the damage

Below that line, add this:

entity.attackEntityFrom(source,amount);

Change amount to the amount you want the damage to deal (1 heart = 2) and source should be the same as defined above

 

Now we need to add the translation keys

Head over to localization on the sidebar and click on add localization entry

In the popup input box (Key name), type

death.attack.sourcename

Where sourcename should be the same as defined above

In the localized text field, type:

%1$s whatever you want the death message to be

%1$s will be translated to the player name

So if you typed

%1$s died from MCreator

And the player is Mike, the death message will be "Mike died from MCreator"

Heads Up! You will also need to add a second death message that appears when the player has been attacked by another entity in the last few seconds before death:

Example:

%1$s died from diabetes whilst fighting %2$s
Edited by Shocking Artist on Sat, 08/21/2021 - 13:44
Klemen, Don't add this in…
Fri, 07/31/2020 - 06:33

Klemen, Don't add this in Mcreator, so as to keep some mods unique

Uniqueness is measured by ideas, not by features and technology available ;)

Last seen on 19:44, 25. May 2021
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Am I just Stupid or why can…
Wed, 08/19/2020 - 20:34

Am I just Stupid or why can't I find the "add localization entry" button? Where do I need to look

Last seen on 19:21, 24. Apr 2024
Joined May 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I have updated the tutorial…
Tue, 08/25/2020 - 13:53

I have updated the tutorial so as to add the recently attacked by another entity death message type I discorvered

Last seen on 02:08, 13. Dec 2020
Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks this worked amazingly
Tue, 10/20/2020 - 19:06

Thanks this worked amazingly

Last seen on 18:11, 2. May 2021
Joined Jan 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yay! It's an added feature!…
Sun, 04/11/2021 - 15:40

Yay! It's an added feature! Thanks, Klemen & Shocking Artist!

Last seen on 20:59, 7. Oct 2022
Joined Oct 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'm so confused what should…
Sat, 08/21/2021 - 09:24

I'm so confused what should I make the sourcename in DamageSource source = new DamageSource("sourcename").setDamageBypassesArmor();? does it even matter? What do you mean "100 will be the amount of damage you want to be"? Damage for what? Where would I put the second death message? In a different localization entry or in the same one? And if it's the same entry how would it know if it's a different death message or the same one?

Last seen on 15:18, 21. Oct 2023
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The "new" damage source…
Sun, 09/04/2022 - 14:28

The "new" damage source doesn't seem to work anymore because it is already in the code.

Last seen on 19:21, 24. Apr 2024
Joined May 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
As said, this is included in…
Thu, 09/22/2022 - 22:48

As said, this is included in Creator itself now.