Item Attribute API
- Tested Minecraft Versions:
- 1.8
- 1.9
This library offers you the opportunity to handle attribute modifiers on item stacks.
Background:
Attributes are properties of mobs and players (http://minecraft.gamepedia.com/Attribute).
These attributes can be modified (http://minecraft.gamepedia.com/Attribute#Modifiers).
These attribut modifiers can be deposited on items (http://minecraft.gamepedia.com/Player.dat_format#Attribute_Modifiers).
This library allows to handle such modifiers on items.
Features:
For a detailed description of attributes and their modifiers see the MC wiki (Links above)
- Define your own modifiers with custom definable variables:
- attribute name
- modifier name
- effected slot
- modifier operation
- modifier amount
- modifier UUID
- Combine any modifiers together into an set of modifiers
- Apply these modifiers on item stacks
- Get modifiers back out of item stacks (modify them and apply it again)
- Well documented
Javadoc + Javadoc websites
How to use:
This is not a plugin. Don't paste it into a plugins folder of a MC server.
Download the JAR and import it into your IDE.
How to Import a external library in Eclipse -> TUTORIAL
Code (Java):import minecraft.spigot.community.michel_0.api.Attribute;
import minecraft.spigot.community.michel_0.api.AttributeModifier;
import minecraft.spigot.community.michel_0.api.ItemAttributes;
import minecraft.spigot.community.michel_0.api.Slot;
ItemStack item = /* ...some item you want to modify... */;
// First you need a new instance of ItemAttributes
ItemAttributes attributeModifiers = new ItemAttributes();
// Then you need to define your modifiers
AttributeModifier speedModifier = new AttributeModifier(Attribute.MOVEMENT_SPEED, "AdditionalSpeed", Slot.MAIN_HAND, 0, 1.0d, UUID.randomUUID());
AttributeModifier attackModifier = new AttributeModifier(Attribute.ATTACK_DAMAGE, "AdditionalDamage", Slot.MAIN_HAND, 0, 4.0d, UUID.randomUUID());
// Next is to add these modifiers to the attribut modifiers set
attributeModifiers.addModifier(speedModifier);
attributeModifiers.addModifier(attackModifier);
// Finally apply it on a item stack
item = attributeModifiers.apply(item);Need additional Features or got some interesting ideas?
- No external APIs used (only Spigot and vanilla Minecraft)
- No other plugins necessary
- Tested on Spigot 1.8.8 & 1.9 without any Problems
- Should also be compatible with older server versions pre 1.8
If you test it on 1.7, let me know so i can add it as supported version- Compiled by Java 8 SDK, your Server should be running on Java 8 JRE to use this plugin
Leave a reply and i'll add this or other functions if requested.
Special thanks @wd40bomber7 who gave me the idea for this API (here).
Replys and ratings and suggestions welcome.
- Add extra attack damage, on some weapon (e.g. sword)
- Add special armor or knockback defense on some armor parts
- Add speed boost on a special fastwalk item
- Add additional horse jump power on horse armor
- ... endless possibillities ...

Item attribute modifier API Library 1.1
Create, modify and apply entity attribut modifiers on item stacks