@SideOnly(Side.CLIENT) public void addDetails(ItemStack itemstack, EntityPlayer player, @Nullable World worldIn, List<String> infos) { super.addDetails(itemstack, player, worldIn, infos); Multimap<String, AttributeModifier> multimap = getModifiers(MOPlayerCapabilityProvider.GetAndroidCapability(player), itemstack); if (multimap != null) { multimap.values() .forEach(modifier -> { switch (modifier.getOperation()) { case 0: infos.add(TextFormatting.GREEN + String.format("%s: +%s", modifier.getName(), modifier.getAmount())); break; case 1: infos.add(TextFormatting.GREEN + String.format("%s: %s", modifier.getName(), (modifier.getAmount() >= 0 ? "+" : "") + DecimalFormat.getPercentInstance().format(modifier.getAmount()))); break; default: infos.add(TextFormatting.GREEN + String.format("%s: %s", modifier.getName(), DecimalFormat.getPercentInstance().format(modifier.getAmount() + 1))); } }); } }
/** * Remove healthmodifier by name. * @param modifierName Name of the modifier to remove, see e.g. GUARD_HEALTH_MOD_LEVEL_NAME */ public void removeHealthModifier(final String modifierName) { for (final AttributeModifier mod : getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).getModifiers()) { if (mod.getName().equals(modifierName)) { getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).removeModifier(mod); } } if (getHealth() > getMaxHealth()) { setHealth(getMaxHealth()); } }
for (Entry<IAttribute, AttributeModifier> entry : map.entrySet()) { AttributeModifier attributemodifier = entry.getValue(); AttributeModifier attributemodifier1 = new AttributeModifier(attributemodifier.getName(), potion.getAttributeModifierAmount(effect.getAmplifier(), attributemodifier), attributemodifier.getOperation()); list1.add(new Tuple((entry.getKey()).getName(), attributemodifier1));
AttributeModifier modifier = entry.getValue(); attributeLines.add(new Tuple<>(entry.getKey().getName(), new AttributeModifier(modifier.getName(), potion.getAttributeModifierAmount(potionEffect.getAmplifier(), modifier), modifier.getOperation())));
for (Entry<IAttribute, AttributeModifier> entry : map.entrySet()) { AttributeModifier modifier = entry.getValue(); attributes.put(entry.getKey().getName(), new AttributeModifier(modifier.getName(), potion.getAttributeModifierAmount(effect.getAmplifier(), modifier), modifier.getOperation()));
public ItemStack addAttributeToPart(ItemStack part, AttributeModifier attribute) { if (part.getTagCompound() == null) { part.setTagCompound(new NBTTagCompound()); } NBTTagList attributeList = part.getTagCompound().getTagList("CustomAttributes", Constants.NBT.TAG_COMPOUND); NBTTagCompound attributeTag = new NBTTagCompound(); attributeTag.setString("Name", attribute.getName()); attributeTag.setDouble("Amount", attribute.getAmount()); attributeTag.setString("UUID", attribute.getID().toString()); attributeTag.setByte("Operation", (byte) attribute.getOperation()); attributeList.appendTag(attributeTag); part.setTagInfo("CustomAttributes", attributeList); return part; }