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

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

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)

there are much easyer ways. In your main class, add a new tool material, and make the sowrd extends ItemSword, not Item.

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)

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

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.