Jump to content

Recommended Posts

Posted

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.

  • 3 weeks later...
Posted

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

Making mods is fun!!!

(sorry bad english, i'm from venezuela)

Posted

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!

Making mods is fun!!!

(sorry bad english, i'm from venezuela)

Posted

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;
    }

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.