if (attributemodifier.getOperation() != 1 && attributemodifier.getOperation() != 2) { d1 = d0; } else { ret.add(new TextComponentString(" " + StringHelper.LIGHT_BLUE + I18n.translateToLocalFormatted("attribute.modifier.plus." + attributemodifier.getOperation(), ItemStack.DECIMALFORMAT.format(d1), I18n.translateToLocal("attribute.name." + entry.getKey())))); } else if (d0 < 0.0D) { d1 = -d1; ret.add(new TextComponentString(" " + StringHelper.LIGHT_RED + I18n.translateToLocalFormatted("attribute.modifier.take." + attributemodifier.getOperation(), ItemStack.DECIMALFORMAT.format(d1), I18n.translateToLocal("attribute.name." + entry.getKey()))));
@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))); } }); } }
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)); double d1; if (attributemodifier2.getOperation() != 1 && attributemodifier2.getOperation() != 2) { d1 = attributemodifier2.getAmount(); } else { list.add(TextFormatting.BLUE + StringHelper.localizeFormat("attribute.modifier.plus." + attributemodifier2.getOperation(), ItemStack.DECIMALFORMAT.format(d1), StringHelper.localize("attribute.name." + tuple.getFirst()))); } else if (d0 < 0.0D) { d1 = d1 * -1.0D; list.add(TextFormatting.RED + StringHelper.localizeFormat("attribute.modifier.take." + attributemodifier2.getOperation(), ItemStack.DECIMALFORMAT.format(d1), StringHelper.localize("attribute.name." + tuple.getFirst())));
new AttributeModifier(modifier.getName(), potion.getAttributeModifierAmount(potionEffect.getAmplifier(), modifier), modifier.getOperation()))); double d0 = modifier.getAmount(); double d1; if (modifier.getOperation() != 1 && modifier.getOperation() != 2) { d1 = modifier.getAmount(); } else { lines.add(TextFormatting.BLUE + I18n.format("attribute.modifier.plus." + modifier.getOperation(), ItemStack.DECIMALFORMAT.format(d1), I18n.format("attribute.name." + tuple.getFirst()))); } else if (d0 < 0.0D) { d1 = d1 * -1.0D; lines.add(TextFormatting.RED + I18n.format("attribute.modifier.take." + modifier.getOperation(), ItemStack.DECIMALFORMAT.format(d1), I18n.format("attribute.name." + tuple.getFirst())));
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())); double amount1; if (modifier.getOperation() != 1 && modifier.getOperation() != 2) amount1 = modifier.getAmount(); else list.add(TextFormatting.BLUE + new TextComponentTranslation("attribute.modifier.plus." + modifier.getOperation(), new Object[] { ItemStack.DECIMALFORMAT.format(amount1), new TextComponentTranslation("attribute.name." + entry.getKey()) }).getFormattedText()); else if (amount0 < 0.0D) { amount1 *= -1.0D; list.add(TextFormatting.RED + new TextComponentTranslation("attribute.modifier.take." + modifier.getOperation(), new Object[] { ItemStack.DECIMALFORMAT.format(amount1), new TextComponentTranslation("attribute.name." + entry.getKey()) }).getFormattedText());
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; }