@Override public Multimap<String, AttributeModifier> getAttributeModifiers(ItemStack stack) { Multimap<String, AttributeModifier> multimap = super.getAttributeModifiers(stack); multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(itemModifierUUID, "Weapon modifier", weaponDamage, 0)); return multimap; } }
/** * Gets the amount of melee damage delt by the specified item * @param itemStack * @return -1 if it doesn't have a damage modifier */ public static double GetItemWeaponDamage(ItemStack itemStack) { Multimap multimap = itemStack.getItem().getAttributeModifiers(itemStack); if (multimap.containsKey(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName())) { Collection attributes = multimap.get(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName()); if (attributes.size() > 0) { Object attribute = attributes.iterator().next(); if (attribute instanceof AttributeModifier) { AttributeModifier weaponModifier = (AttributeModifier)attribute; return weaponModifier.getAmount(); } } } return -1; }
private void renderAttributes() { EntityTameableDragon dragon = getSelectedDragon(); if (dragon == null) { return; } text.setOrigin(text.getX() + 180, 8); text.setColor(YELLOW); text.println("Attributes"); text.setColor(WHITE); Collection<IAttributeInstance> attribs = dragon.getAttributeMap().getAllAttributes(); attribs.forEach(attrib -> { String attribName = I18n.translateToLocal("attribute.name." + attrib.getAttribute().getAttributeUnlocalizedName()); String attribValue = dfShort.format(attrib.getAttributeValue()); String attribBase = dfShort.format(attrib.getBaseValue()); text.println(attribName + " = " + attribValue + " (" + attribBase + ")"); }); text.println(); }