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 have a custom weapon and was wondering if their is any way to have a unique death message when killed by it?

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

If you make a new instance of a DamageSource, you can add a custom death message for it via the LanguageRegistry.

 

DamageSourceSword class:

 

package you.modname;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.ChatMessageComponent;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityDamageSourceIndirect;
import net.minecraft.util.StatCollector;

public class DamageSourceSword extends DamageSource
{

protected DamageSourceSword(String par1Str) 
{
	super(par1Str);
}

public static DamageSource causeSwordDamage(Entity par0Entity, Entity par1Entity)
{
	return (new EntityDamageSourceIndirect("sword", par0Entity, par1Entity));
}

@Override
public ChatMessageComponent func_111181_b(EntityLivingBase par1EntityLivingBase)
    {
	EntityLivingBase entitylivingbase1 = par1EntityLivingBase.func_94060_bK();
        String s = "death.attack." + this.damageType;
        String s1 = s + ".player";
        return entitylivingbase1 != null && StatCollector.func_94522_b(s1) ? ChatMessageComponent.func_111082_b(s1, new Object[] {par1EntityLivingBase.getTranslatedEntityName(), entitylivingbase1.getTranslatedEntityName()}): ChatMessageComponent.func_111082_b(s, new Object[] {par1EntityLivingBase.getTranslatedEntityName()});
    }
}

 

 

In your mod file, preferably in @PreInit():

 

LanguageRegistry.instance().addStringLocalization("death.attack.sword", "%1$s was sliced to death"); //This shouldn't happen, but add anyway.
LanguageRegistry.instance().addStringLocalization("death.attack.sword.player", "%1$s was sliced to death by %2$s"); //Death from the damagesource, because of a player. Should always be this.
LanguageRegistry.instance().addStringLocalization("death.attack.sword.item", "%1$s was sliced to death by %2$s using %3$s"); //Death from the damagesource of they renamed the sword

 

 

The enders are everywhere. You can't escape...

  • Author

If you make a new instance of a DamageSource, you can add a custom death message for it via the LanguageRegistry.

 

DamageSourceSword class:

 

package you.modname;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.ChatMessageComponent;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityDamageSourceIndirect;
import net.minecraft.util.StatCollector;

public class DamageSourceSword extends DamageSource
{

protected DamageSourceSword(String par1Str) 
{
	super(par1Str);
}

public static DamageSource causeSwordDamage(Entity par0Entity, Entity par1Entity)
{
	return (new EntityDamageSourceIndirect("sword", par0Entity, par1Entity));
}

@Override
public ChatMessageComponent func_111181_b(EntityLivingBase par1EntityLivingBase)
    {
	EntityLivingBase entitylivingbase1 = par1EntityLivingBase.func_94060_bK();
        String s = "death.attack." + this.damageType;
        String s1 = s + ".player";
        return entitylivingbase1 != null && StatCollector.func_94522_b(s1) ? ChatMessageComponent.func_111082_b(s1, new Object[] {par1EntityLivingBase.getTranslatedEntityName(), entitylivingbase1.getTranslatedEntityName()}): ChatMessageComponent.func_111082_b(s, new Object[] {par1EntityLivingBase.getTranslatedEntityName()});
    }
}

 

 

In your mod file, preferably in @PreInit():

 

LanguageRegistry.instance().addStringLocalization("death.attack.sword", "%1$s was sliced to death"); //This shouldn't happen, but add anyway.
LanguageRegistry.instance().addStringLocalization("death.attack.sword.player", "%1$s was sliced to death by %2$s"); //Death from the damagesource, because of a player. Should always be this.
LanguageRegistry.instance().addStringLocalization("death.attack.sword.item", "%1$s was sliced to death by %2$s using %3$s"); //Death from the damagesource of they renamed the sword

 

 

It says the following imports don't exist:

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.ChatMessageComponent;

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

If you're using Eclipse on Windows, use this key combo:

CTRL + SHIFT + O

It should sort your imports.

Aspergers is annoying sometimes :(

  • Author

If you're using Eclipse on Windows, use this key combo:

CTRL + SHIFT + O

It should sort your imports.

That does not solve my issue...

it actually makes it worse.

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

  • 3 weeks later...

If you're using Eclipse on Windows, use this key combo:

CTRL + SHIFT + O

It should sort your imports.

That does not solve my issue...

it actually makes it worse.

Is this in 1.6.2?  I believe both of those classes were added as of the 1.6.2 update

ctrl+shift+o will never make it worst, if you're getting more error because of it it means that the fix you were trying to do is actuallly wayyy worst then the result after ctrol sihft o

 

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

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.