Flockshot Posted May 30, 2014 Posted May 30, 2014 So i am making a custom sword but i dont know how to change its damage i dont want to change the DamagevsEntity of the material because that will increase others tools as well.Can anyone tell me how can set damage to my sword. Quote
pirulo259 Posted June 18, 2014 Posted June 18, 2014 So i am making a custom sword but i dont know how to change its damage i dont want to change the DamagevsEntity of the material because that will increase others tools as well.Can anyone tell me how can set damage to my sword. (sorry for bad english, i'm from venezuela) public class ItemSword extends Item { private float field_150934_a; private final Item.ToolMaterial field_150933_b; public ItemSword(Item.ToolMaterial p_i45356_1_) { this.field_150933_b = p_i45356_1_; this.maxStackSize = 1; this.setMaxDamage(p_i45356_1_.getMaxUses()); this.setCreativeTab(CreativeTabs.tabCombat); this.field_150934_a = 4.0F + p_i45356_1_.getDamageVsEntity(); } ... /** * Gets a map of item attribute modifiers, used by ItemSword to increase hit damage. */ public Multimap getItemAttributeModifiers() { Multimap multimap = super.getItemAttributeModifiers(); multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", (double)this.field_150934_a, 0)); return multimap; } } where 4.0F is the damage of the sword plus the tool material damage change 4.0F to whatever you want Quote Making mods is fun!!! (sorry bad english, i'm from venezuela)
pta2002 Posted June 20, 2014 Posted June 20, 2014 there are much easyer ways. In your main class, add a new tool material, and make the sowrd extends ItemSword, not Item. Quote
pirulo259 Posted June 20, 2014 Posted June 20, 2014 there are much easyer ways. In your main class, add a new tool material, and make the sowrd extends ItemSword, not Item. He don't want to add a new tool material because that will change the damage of the entire tool set. And obviously, the sword must extends ItemSword, i only was showing the field "field_150934_a". You only need add this to your custom sword constructor: public YourCustomSword(Item.ToolMaterial material) { ... this.field_150934_a = mySwordDamage + material.getDamageVsEntity(); } where "field_150934_a" is the damageVsEntity of the Item itself, and "mySwordDamage"(float) will be your custom damage only for your sword. you can assign your sword damage directly in your class or passing it as parameter. hope this helps! Quote Making mods is fun!!! (sorry bad english, i'm from venezuela)
coolboy4531 Posted June 20, 2014 Posted June 20, 2014 Guys guys guys. Stop confusing him. Like pirulo259 said, use getItemAttributeModifiers(). BUT BE SURE TO CREATE A NEW HASHMAP, NOT THE ONE ItemSword USES!!!! It should be this: public Multimap getItemAttributeModifiers() { Multimap multimap = HashMultimap.create(); // this part, you need to create a new hash-multimap! multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", (double)this.field_150934_a, 0)); return multimap; } Quote
Recommended Posts
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.