Topic category: User side tutorials
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
Uniqueness is measured by ideas, not by features and technology available ;)
sure... ur right
Am I just Stupid or why can't I find the "add localization entry" button? Where do I need to look
In Workspace -> Localization
I have updated the tutorial so as to add the recently attacked by another entity death message type I discorvered
Thanks this worked amazingly
np man!
Yay! It's an added feature! Thanks, Klemen & Shocking Artist!
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?
There is now a procedure for this, no longer need to do custom code
The "new" damage source doesn't seem to work anymore because it is already in the code.
As said, this is included in Creator itself now.