Search in sources :

Example 6 with AttributeModifier

use of net.minecraft.server.v1_15_R1.AttributeModifier in project NoCheatPlus by NoCheatPlus.

the class AttributeAccess method getSpeedAttributeMultiplier.

@Override
public double getSpeedAttributeMultiplier(Player player) {
    final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
    final double val = attr.getValue() / attr.b();
    final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
    if (mod == null) {
        return val;
    } else {
        return val / AttribUtil.getMultiplier(mod.c(), mod.d());
    }
}
Also used : AttributeInstance(net.minecraft.server.v1_8_R1.AttributeInstance) AttributeModifier(net.minecraft.server.v1_8_R1.AttributeModifier)

Example 7 with AttributeModifier

use of net.minecraft.server.v1_15_R1.AttributeModifier in project NoCheatPlus by NoCheatPlus.

the class AttributeAccess method getSpeedAttributeMultiplier.

@Override
public double getSpeedAttributeMultiplier(Player player) {
    final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
    final double val = attr.getValue() / attr.b();
    final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
    if (mod == null) {
        return val;
    } else {
        return val / AttribUtil.getMultiplier(mod.c(), mod.d());
    }
}
Also used : AttributeInstance(net.minecraft.server.v1_7_R2.AttributeInstance) AttributeModifier(net.minecraft.server.v1_7_R2.AttributeModifier)

Example 8 with AttributeModifier

use of net.minecraft.server.v1_15_R1.AttributeModifier in project NoCheatPlus by NoCheatPlus.

the class AttributeAccess method getSpeedAttributeMultiplier.

@Override
public double getSpeedAttributeMultiplier(Player player) {
    final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().a(GenericAttributes.d);
    double val = attr.e() / attr.b();
    final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
    if (mod == null) {
        return val;
    } else {
        return val / AttribUtil.getMultiplier(mod.c(), mod.d());
    }
}
Also used : AttributeInstance(net.minecraft.server.v1_6_R1.AttributeInstance) AttributeModifier(net.minecraft.server.v1_6_R1.AttributeModifier)

Example 9 with AttributeModifier

use of net.minecraft.server.v1_15_R1.AttributeModifier in project solinia3-core by mixxit.

the class ItemStackUtils method getWeaponDamageFromItemStack.

public static int getWeaponDamageFromItemStack(ItemStack itemStack, EnumItemSlot itemSlot) {
    double attackDamage = 1.0;
    UUID uuid = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF");
    net.minecraft.server.v1_15_R1.ItemStack craftItemStack = CraftItemStack.asNMSCopy(itemStack);
    net.minecraft.server.v1_15_R1.Item item = craftItemStack.getItem();
    if (item instanceof net.minecraft.server.v1_15_R1.ItemSword || item instanceof net.minecraft.server.v1_15_R1.ItemTool || item instanceof net.minecraft.server.v1_15_R1.ItemHoe) {
        Multimap<String, AttributeModifier> map = item.a(itemSlot);
        Collection<AttributeModifier> attributes = map.get(GenericAttributes.ATTACK_DAMAGE.getName());
        if (!attributes.isEmpty()) {
            for (AttributeModifier am : attributes) {
                if (am.getUniqueId().toString().equalsIgnoreCase(uuid.toString()) && am.getOperation() == AttributeModifier.Operation.ADDITION)
                    attackDamage += am.getAmount();
            }
            double y = 1;
            for (AttributeModifier am : attributes) {
                if (am.getUniqueId().toString().equalsIgnoreCase(uuid.toString()) && am.getOperation() == AttributeModifier.Operation.MULTIPLY_BASE)
                    y += am.getAmount();
            }
            attackDamage *= y;
            for (AttributeModifier am : attributes) {
                if (am.getUniqueId().toString().equalsIgnoreCase(uuid.toString()) && am.getOperation() == AttributeModifier.Operation.MULTIPLY_TOTAL)
                    attackDamage *= (1 + am.getAmount());
            }
        }
    }
    Long rounded = Math.round(attackDamage);
    if (rounded > Integer.MAX_VALUE)
        rounded = (long) Integer.MAX_VALUE;
    int damage = Integer.valueOf(rounded.intValue());
    return damage;
}
Also used : AttributeModifier(net.minecraft.server.v1_15_R1.AttributeModifier) UUID(java.util.UUID)

Example 10 with AttributeModifier

use of net.minecraft.server.v1_15_R1.AttributeModifier in project NoCheatPlus by NoCheatPlus.

the class AttributeAccess method getSpeedAttributeMultiplier.

@Override
public double getSpeedAttributeMultiplier(Player player) {
    final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
    final double val = attr.getValue() / attr.b();
    final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
    if (mod == null) {
        return val;
    } else {
        return val / AttribUtil.getMultiplier(mod.c(), mod.d());
    }
}
Also used : AttributeInstance(net.minecraft.server.v1_7_R1.AttributeInstance) AttributeModifier(net.minecraft.server.v1_7_R1.AttributeModifier)

Aggregations

UUID (java.util.UUID)1 AttributeInstance (net.minecraft.server.v1_10_R1.AttributeInstance)1 AttributeModifier (net.minecraft.server.v1_10_R1.AttributeModifier)1 AttributeInstance (net.minecraft.server.v1_11_R1.AttributeInstance)1 AttributeModifier (net.minecraft.server.v1_11_R1.AttributeModifier)1 AttributeInstance (net.minecraft.server.v1_12_R1.AttributeInstance)1 AttributeModifier (net.minecraft.server.v1_12_R1.AttributeModifier)1 AttributeModifier (net.minecraft.server.v1_15_R1.AttributeModifier)1 AttributeInstance (net.minecraft.server.v1_6_R1.AttributeInstance)1 AttributeModifier (net.minecraft.server.v1_6_R1.AttributeModifier)1 AttributeInstance (net.minecraft.server.v1_6_R2.AttributeInstance)1 AttributeModifier (net.minecraft.server.v1_6_R2.AttributeModifier)1 AttributeInstance (net.minecraft.server.v1_6_R3.AttributeInstance)1 AttributeModifier (net.minecraft.server.v1_6_R3.AttributeModifier)1 AttributeInstance (net.minecraft.server.v1_7_R1.AttributeInstance)1 AttributeModifier (net.minecraft.server.v1_7_R1.AttributeModifier)1 AttributeInstance (net.minecraft.server.v1_7_R2.AttributeInstance)1 AttributeModifier (net.minecraft.server.v1_7_R2.AttributeModifier)1 AttributeInstance (net.minecraft.server.v1_7_R3.AttributeInstance)1 AttributeModifier (net.minecraft.server.v1_7_R3.AttributeModifier)1