Codota Logo
AttributeModifier
Code IndexAdd Codota to your IDE (free)

How to use
AttributeModifier
in
net.minecraft.entity.ai.attributes

Best Java code snippets using net.minecraft.entity.ai.attributes.AttributeModifier (Showing top 20 results out of 315)

  • Common ways to obtain AttributeModifier
private void myMethod () {
AttributeModifier a =
  • Codota IconIAttributeInstance iAttributeInstance;UUID uUID;iAttributeInstance.getModifier(uUID)
  • Smart code suggestions by Codota
}
origin: SlimeKnights/TinkersConstruct

 @Override
 public void getAttributeModifiers(@Nonnull EntityEquipmentSlot slot, ItemStack stack, Multimap<String, AttributeModifier> attributeMap) {
  if(slot == EntityEquipmentSlot.MAINHAND || slot == EntityEquipmentSlot.OFFHAND) {
   attributeMap.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getName(), new AttributeModifier(KNOCKBACK_MODIFIER, "Knockback modifier", 1, 0));
  }
 }
}
origin: WesCook/Nutrition

  @Override
  public double getAttributeModifierAmount(int amplifier, AttributeModifier modifier) {
    // Increase health
    if (modifier.getID().equals(ModPotions.NOURISHMENT_HEALTH))
      return (amplifier + 1); // Half-heart per level

    return 0D;
  }
}
origin: Vazkii/Botania

@Override
void fillModifiers(Multimap<String, AttributeModifier> attributes, ItemStack stack) {
  attributes.put(EntityPlayer.REACH_DISTANCE.getName(), new AttributeModifier(getBaubleUUID(stack), "Reach Ring", 3.5, 0).setSaved(false));
}
origin: CoFH/CoFHCore

  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 d0 = attributemodifier2.getAmount();
double d1;
if (attributemodifier2.getOperation() != 1 && attributemodifier2.getOperation() != 2) {
  d1 = attributemodifier2.getAmount();
} else {
  d1 = attributemodifier2.getAmount() * 100.0D;
  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())));
origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

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;
}
origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

@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)));
          }
        });
  }
}
origin: CoFH/CoFHCore

double d0 = attributemodifier.getAmount();
if (field_111210_e.equals(attributemodifier.getID())) {
  d0 += EnchantmentHelper.getModifierForCreature(stack, EnumCreatureAttribute.UNDEFINED);
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()))));
origin: Vazkii/Quark

private double getAttribute(EntityPlayer player, ItemStack stack, Multimap<String, AttributeModifier> map, String key) {
  if(player == null) // apparently this can happen
    return 0;
  
  Collection<AttributeModifier> collection = map.get(key);
  if(collection.isEmpty())
    return 0;
  
  AttributeModifier attributemodifier = collection.iterator().next();
  double d0 = attributemodifier.getAmount();
  boolean flag = false;
  if(key.equals("generic.attackDamage")) {
    d0 += player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getBaseValue();
    d0 += (double) EnchantmentHelper.getModifierForCreature(stack, EnumCreatureAttribute.UNDEFINED);
  }
  else if(key.equals("generic.attackSpeed"))
    d0 += player.getEntityAttribute(SharedMonsterAttributes.ATTACK_SPEED).getBaseValue();
  
  return d0;
}

origin: ldtteam/minecolonies

/**
 * 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());
  }
}
origin: GregTechCE/GregTech

  AttributeModifier modifier = entry.getValue();
  attributeLines.add(new Tuple<>(entry.getKey().getName(),
      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 {
  d1 = modifier.getAmount() * 100.0D;
  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())));
origin: Vazkii/Botania

@Override
void fillModifiers(Multimap<String, AttributeModifier> attributes, ItemStack stack) {
  if(stack.isEmpty()) // workaround for Azanor/Baubles#156
    return;
  
  attributes.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getName(), new AttributeModifier(getBaubleUUID(stack), "Knockback Belt", 1, 0).setSaved(false));
}
origin: Zyin055/zyinhud

/**
 * 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;
}

origin: Vazkii/Botania

@Nonnull
@Override
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) {
  Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
  if (equipmentSlot == EntityEquipmentSlot.MAINHAND) {
    multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -1.25, 0));
  }
  return multimap;
}
origin: vadis365/TheErebus

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 amount0 = modifier.getAmount();
double amount1;
if (modifier.getOperation() != 1 && modifier.getOperation() != 2)
  amount1 = modifier.getAmount();
else
  amount1 = modifier.getAmount() * 100.0D;
  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());
origin: Vazkii/Botania

private void fillModifiers(Multimap<String, AttributeModifier> attributes, ItemStack stack) {
  if(stack.isEmpty()) // workaround for Azanor/Baubles#156
    return;
  
  attributes.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(getBaubleUUID(stack), "Odin Ring", 20, 0).setSaved(false));
}
origin: PrinceOfAmber/Cyclic

public static double getMaxHealth(EntityLivingBase living) {
 IAttributeInstance healthAttribute = living.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH);
 double maxHealth = healthAttribute.getBaseValue();
 AttributeModifier modifier = healthAttribute.getModifier(HEALTH_MODIFIER_ID);
 if (modifier != null) {
  maxHealth += modifier.getAmount();
 }
 return maxHealth;
}
origin: WesCook/Nutrition

  @Override
  public double getAttributeModifierAmount(int amplifier, AttributeModifier modifier) {
    // Reduce health
    if (modifier.getID().equals(ModPotions.MALNOURISHMENT_HEALTH))
      return 0 - (amplifier + 1); // Half-heart per level

    return 0D;
  }
}
origin: SlimeKnights/TinkersConstruct

@Override
public void modifyProjectileAttributes(Multimap<String, AttributeModifier> projectileAttributes, @Nullable ItemStack launcher, ItemStack projectile, float power) {
 double dmg = baseProjectileDamage() * power;
 dmg += ProjectileLauncherNBT.from(launcher).bonusDamage;
 if(dmg != 0) {
  projectileAttributes.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(LAUNCHER_BONUS_DAMAGE, "Launcher bonus damage", dmg, 0));
 }
 if(projectileDamageModifier() != 0f) {
  projectileAttributes.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(LAUNCHER_DAMAGE_MODIFIER, "Launcher damage modifier", projectileDamageModifier() - 1f, 1));
 }
}
origin: P3pp3rF1y/AncientWarfare2

public NpcAIRideHorse(T npc, double speedFactor) {
  super(npc);
  this.moveSpeedModifier = new AttributeModifier("modifier.npc_ride_speed", speedFactor, 1);
  this.moveSpeedModifier.setSaved(false);
  this.followRangeModifier = new AttributeModifier("modifier.npc_horse_path_extension", 24.d, 0);
  this.followRangeModifier.setSaved(false);
}
origin: WesCook/Nutrition

  @Override
  public double getAttributeModifierAmount(int amplifier, AttributeModifier modifier) {
    // Multiply health
    if (modifier.getID().equals(ModPotions.TOUGHNESS_HEALTH))
      return (amplifier + 1) * 4D; // 4 = two hearts

    // Multiply armor toughness
    if (modifier.getID().equals(ModPotions.TOUGHNESS_ARMOR))
      return (amplifier + 1) * 2D;

    // Multiply attack speed
    if (modifier.getID().equals(ModPotions.TOUGHNESS_ATTACK_SPEED))
      return (amplifier + 1) * 0.1D;

    return 0D;
  }
}
net.minecraft.entity.ai.attributesAttributeModifier

Most used methods

  • <init>
  • getAmount
  • getName
  • getID
  • getOperation
  • setSaved
  • equals

Popular in Java

  • Making http post requests using okhttp
  • getExternalFilesDir (Context)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • orElseThrow (Optional)
  • FileInputStream (java.io)
    A FileInputStream obtains input bytes from a file in a file system. What files are available depends
  • URI (java.net)
    Represents a Uniform Resource Identifier (URI) reference. Aside from some minor deviations noted bel
  • DecimalFormat (java.text)
    DecimalFormat is a concrete subclass ofNumberFormat that formats decimal numbers. It has a variety o
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • JCheckBox (javax.swing)
  • JOptionPane (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now