Jump to content

how do I add attributes so that they are only added to the mainhand?


Recommended Posts

How can I make the attributes be added only for the mainhand. Currently it adds the values for Head, Legs, Chest, Mainhand, offhand and boots. The second problem is that it overwrites the standard values of the sword. I solved this by writing the values at the very front of amountIn and adding the actual calculation to it.

       public Multimap<Attribute, AttributeModifier> getAttributeModifiers(EquipmentSlotType slot,
               ItemStack stack) {
           Multimap<Attribute, AttributeModifier> attss = LinkedHashMultimap.create();
            if (stack.hasTag()){

                        new AttributeModifier(ATTACK_SPEED_MODIFIER, Soulharvest.MOD_ID + ":speed_bonus", 2+((Math.sqrt((stack.getTag().getInt("KillCounterPhobos") +stack.getTag().getInt("KillCounterPhobosMob"))*2) + (stack.getTag().getInt("KillCounterPhobos") +stack.getTag().getInt("KillCounterPhobosMob"))) / 12.5)* ATTACK_SPEED_MULTIPLY_twin.get(),


                        new AttributeModifier(ATTACK_DAMAGE_MODIFIER, Soulharvest.MOD_ID + ":damage_bonus", 4+((Math.sqrt((stack.getTag().getInt("KillCounterPhobos") + stack.getTag().getInt("KillCounterPhobosMob"))*2) + (stack.getTag().getInt("KillCounterPhobos") + stack.getTag().getInt("KillCounterPhobosMob"))) / 25)*Damage_MULTIPLY_twin.get(),
                return attss;
           return attss;


Link to comment
Share on other sites

Could you not just wrap your attss.put method in a if statement ?



if(slot == EquipmentSlotType.MAINHAND) {

// DO your attss.put code here.




or even add it to your current if statement

if (stack.hasTag() && slot == EquipmentSlotType.MAINHAND){

// Do Code





  • Like 1
Link to comment
Share on other sites

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.

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.


  • Create New...

Important Information

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