本文整理汇总了Java中net.minecraft.entity.ai.attributes.AttributeModifier.getAmount方法的典型用法代码示例。如果您正苦于以下问题:Java AttributeModifier.getAmount方法的具体用法?Java AttributeModifier.getAmount怎么用?Java AttributeModifier.getAmount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.ai.attributes.AttributeModifier
的用法示例。
在下文中一共展示了AttributeModifier.getAmount方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDamage
import net.minecraft.entity.ai.attributes.AttributeModifier; //导入方法依赖的package包/类
public float getDamage()
{
Multimap<String, AttributeModifier> modifiersMap = this.getRenderStack().getAttributeModifiers(EntityEquipmentSlot.MAINHAND);
double ret = 1;
if (modifiersMap.containsKey(SharedMonsterAttributes.ATTACK_DAMAGE.getName()))
{
for (AttributeModifier mod : modifiersMap.get(SharedMonsterAttributes.ATTACK_DAMAGE.getName()))
{
ret = mod.getOperation() == 0 ? ret + mod.getAmount() : ret * mod.getAmount();
}
}
return (float) ret;
}
示例2: addPotionEffectTooltip
import net.minecraft.entity.ai.attributes.AttributeModifier; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
public static void addPotionEffectTooltip(List<PotionEffect> list, List<String> lores, float durationFactor)
{
List<Tuple<String, AttributeModifier>> attributeModifiers = Lists.newArrayList();
if (list.isEmpty())
{
String s = I18n.translateToLocal("effect.none").trim();
lores.add(TextFormatting.GRAY + s);
}
else
{
for (PotionEffect potioneffect : list)
{
String s1 = I18n.translateToLocal(potioneffect.getEffectName()).trim();
Potion potion = potioneffect.getPotion();
Map<IAttribute, AttributeModifier> map = potion.getAttributeModifierMap();
if (!map.isEmpty())
{
for (Map.Entry<IAttribute, AttributeModifier> entry : map.entrySet())
{
AttributeModifier attributemodifier = entry.getValue();
AttributeModifier attributemodifier1 = new AttributeModifier(attributemodifier.getName(), potion.getAttributeModifierAmount(potioneffect.getAmplifier(), attributemodifier), attributemodifier.getOperation());
attributeModifiers.add(new Tuple(((IAttribute)entry.getKey()).getName(), attributemodifier1));
}
}
if (potioneffect.getAmplifier() > 0)
{
s1 = s1 + " " + I18n.translateToLocal("potion.potency." + potioneffect.getAmplifier()).trim();
}
if (potioneffect.getDuration() > 20)
{
s1 = s1 + " (" + Potion.getPotionDurationString(potioneffect, durationFactor) + ")";
}
if (potion.isBadEffect())
{
lores.add(TextFormatting.RED + s1);
}
else
{
lores.add(TextFormatting.BLUE + s1);
}
}
}
if (!attributeModifiers.isEmpty())
{
lores.add("");
lores.add(TextFormatting.DARK_PURPLE + I18n.translateToLocal("potion.whenDrank"));
for (Tuple<String, AttributeModifier> tuple : attributeModifiers)
{
AttributeModifier attributemodifier2 = tuple.getSecond();
double d0 = attributemodifier2.getAmount();
double d1;
if (attributemodifier2.getOperation() != 1 && attributemodifier2.getOperation() != 2)
{
d1 = attributemodifier2.getAmount();
}
else
{
d1 = attributemodifier2.getAmount() * 100.0D;
}
if (d0 > 0.0D)
{
lores.add(TextFormatting.BLUE + I18n.translateToLocalFormatted("attribute.modifier.plus." + attributemodifier2.getOperation(), ItemStack.DECIMALFORMAT.format(d1), I18n.translateToLocal("attribute.name." + (String)tuple.getFirst())));
}
else if (d0 < 0.0D)
{
d1 = d1 * -1.0D;
lores.add(TextFormatting.RED + I18n.translateToLocalFormatted("attribute.modifier.take." + attributemodifier2.getOperation(), ItemStack.DECIMALFORMAT.format(d1), I18n.translateToLocal("attribute.name." + (String)tuple.getFirst())));
}
}
}
}
示例3: getAttributeModifierAmount
import net.minecraft.entity.ai.attributes.AttributeModifier; //导入方法依赖的package包/类
public double getAttributeModifierAmount(int p_111183_1_, AttributeModifier modifier)
{
return modifier.getAmount() * (double)(p_111183_1_ + 1);
}
示例4: addInformation
import net.minecraft.entity.ai.attributes.AttributeModifier; //导入方法依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "rawtypes", "unchecked" })
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isComplex) {
if (stack.getItemDamage() == 0)
return;
List<PotionEffect> effects = getEffects(stack);
HashMultimap<String, AttributeModifier> attributes = HashMultimap.create();
if (effects == null || effects.isEmpty()) {
String s = StatCollector.translateToLocal("potion.empty").trim();
list.add(EnumChatFormatting.GRAY + s);
} else
for (PotionEffect potioneffect : effects) {
String s1 = StatCollector.translateToLocal(potioneffect.getEffectName()).trim();
Potion potion = Potion.potionTypes[potioneffect.getPotionID()];
Map<IAttribute, AttributeModifier> map = potion.func_111186_k();
if (map != null && map.size() > 0)
for (Entry<IAttribute, AttributeModifier> entry : map.entrySet()) {
AttributeModifier attributemodifier = entry.getValue();
AttributeModifier attributemodifier1 = new AttributeModifier(attributemodifier.getName(), potion.func_111183_a(potioneffect.getAmplifier(), attributemodifier), attributemodifier.getOperation());
attributes.put(entry.getKey().getAttributeUnlocalizedName(), attributemodifier1);
}
if (potioneffect.getAmplifier() > 0)
s1 = s1 + " " + StatCollector.translateToLocal("potion.potency." + potioneffect.getAmplifier()).trim();
if (potioneffect.getDuration() > 20)
s1 = s1 + " (" + Potion.getDurationString(potioneffect) + ")";
if (potion.isBadEffect())
list.add(EnumChatFormatting.RED + s1);
else
list.add(EnumChatFormatting.GRAY + s1);
}
if (!attributes.isEmpty()) {
list.add("");
list.add(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("potion.effects.whenDrank"));
for (Entry<String, AttributeModifier> entry1 : attributes.entries()) {
AttributeModifier attributemodifier2 = entry1.getValue();
double d0 = attributemodifier2.getAmount();
double d1;
if (attributemodifier2.getOperation() != 1 && attributemodifier2.getOperation() != 2)
d1 = attributemodifier2.getAmount();
else
d1 = attributemodifier2.getAmount() * 100.0D;
if (d0 > 0.0D)
list.add(EnumChatFormatting.BLUE + StatCollector.translateToLocalFormatted("attribute.modifier.plus." + attributemodifier2.getOperation(), new Object[] { ItemStack.field_111284_a.format(d1), StatCollector.translateToLocal("attribute.name." + entry1.getKey()) }));
else if (d0 < 0.0D) {
d1 *= -1.0D;
list.add(EnumChatFormatting.RED + StatCollector.translateToLocalFormatted("attribute.modifier.take." + attributemodifier2.getOperation(), new Object[] { ItemStack.field_111284_a.format(d1), StatCollector.translateToLocal("attribute.name." + entry1.getKey()) }));
}
}
}
}
示例5: getAttributeModifierAmount
import net.minecraft.entity.ai.attributes.AttributeModifier; //导入方法依赖的package包/类
public double getAttributeModifierAmount(int amplifier, AttributeModifier modifier)
{
return modifier.getAmount() * (double)(amplifier + 1);
}
示例6: addPotionTooltip
import net.minecraft.entity.ai.attributes.AttributeModifier; //导入方法依赖的package包/类
public static void addPotionTooltip(ItemStack itemIn, List<String> lores, float durationFactor)
{
List<PotionEffect> list = getEffectsFromStack(itemIn);
List<Tuple<String, AttributeModifier>> list1 = Lists.<Tuple<String, AttributeModifier>>newArrayList();
if (list.isEmpty())
{
String s = I18n.translateToLocal("effect.none").trim();
lores.add(TextFormatting.GRAY + s);
}
else
{
for (PotionEffect potioneffect : list)
{
String s1 = I18n.translateToLocal(potioneffect.getEffectName()).trim();
Potion potion = potioneffect.getPotion();
Map<IAttribute, AttributeModifier> map = potion.getAttributeModifierMap();
if (!map.isEmpty())
{
for (Entry<IAttribute, AttributeModifier> entry : map.entrySet())
{
AttributeModifier attributemodifier = (AttributeModifier)entry.getValue();
AttributeModifier attributemodifier1 = new AttributeModifier(attributemodifier.getName(), potion.getAttributeModifierAmount(potioneffect.getAmplifier(), attributemodifier), attributemodifier.getOperation());
list1.add(new Tuple(((IAttribute)entry.getKey()).getAttributeUnlocalizedName(), attributemodifier1));
}
}
if (potioneffect.getAmplifier() > 0)
{
s1 = s1 + " " + I18n.translateToLocal("potion.potency." + potioneffect.getAmplifier()).trim();
}
if (potioneffect.getDuration() > 20)
{
s1 = s1 + " (" + Potion.getPotionDurationString(potioneffect, durationFactor) + ")";
}
if (potion.isBadEffect())
{
lores.add(TextFormatting.RED + s1);
}
else
{
lores.add(TextFormatting.BLUE + s1);
}
}
}
if (!list1.isEmpty())
{
lores.add("");
lores.add(TextFormatting.DARK_PURPLE + I18n.translateToLocal("potion.whenDrank"));
for (Tuple<String, AttributeModifier> tuple : list1)
{
AttributeModifier attributemodifier2 = (AttributeModifier)tuple.getSecond();
double d0 = attributemodifier2.getAmount();
double d1;
if (attributemodifier2.getOperation() != 1 && attributemodifier2.getOperation() != 2)
{
d1 = attributemodifier2.getAmount();
}
else
{
d1 = attributemodifier2.getAmount() * 100.0D;
}
if (d0 > 0.0D)
{
lores.add(TextFormatting.BLUE + I18n.translateToLocalFormatted("attribute.modifier.plus." + attributemodifier2.getOperation(), new Object[] {ItemStack.DECIMALFORMAT.format(d1), I18n.translateToLocal("attribute.name." + (String)tuple.getFirst())}));
}
else if (d0 < 0.0D)
{
d1 = d1 * -1.0D;
lores.add(TextFormatting.RED + I18n.translateToLocalFormatted("attribute.modifier.take." + attributemodifier2.getOperation(), new Object[] {ItemStack.DECIMALFORMAT.format(d1), I18n.translateToLocal("attribute.name." + (String)tuple.getFirst())}));
}
}
}
}
示例7: handleArmorProtection
import net.minecraft.entity.ai.attributes.AttributeModifier; //导入方法依赖的package包/类
public static float handleArmorProtection(EntityPlayer player, DamageSource source, float amount, ItemStack armor, BodyPart damaged, EntityEquipmentSlot slotDamaged)
{
if (source.isUnblockable())
{
return amount;
}
Item armorItem = armor.getItem();
if (armorItem instanceof ISpecialArmor)
{
ISpecialArmor specialArmor = (ISpecialArmor) armorItem;
float value = ArmorProperties.applyArmor(player, NonNullList.withSize(1, armor), source, amount);
specialArmor.damageArmor(player, armor, source, (int) amount / 2, slotDamaged.getSlotIndex());
return value;
}
else
{
Multimap<String, AttributeModifier> modifiers = armor.getAttributeModifiers(slotDamaged);
float toughnessMod = 1;
for (AttributeModifier mod : modifiers.get(SharedMonsterAttributes.ARMOR_TOUGHNESS.getName()))
{
if (mod.getOperation() == 0)
{
toughnessMod += mod.getAmount();
}
else
{
toughnessMod *= mod.getAmount();
}
}
if (player instanceof EntityPlayerMP)
{
if (armor.attemptDamageItem((int) (amount / 2), player.world.rand, (EntityPlayerMP) player))
{
armor.setCount(0);
}
}
return amount * (1 / toughnessMod);
}
}