Posted July 3, 201312 yr 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]
July 3, 201312 yr 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...
July 3, 201312 yr 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]
July 3, 201312 yr If you're using Eclipse on Windows, use this key combo: CTRL + SHIFT + O It should sort your imports. Aspergers is annoying sometimes
July 3, 201312 yr 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]
July 25, 201312 yr 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
July 25, 201312 yr 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.