fix: try to consider attack speed for tool dps

This commit is contained in:
əlemi 2023-02-19 23:48:08 +01:00
parent 184aa773ba
commit 36dfda2d4c
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -21,11 +21,16 @@ public class Inventory implements ICommons {
// TODO ????????????? wtf is this is there an easier way? // TODO ????????????? wtf is this is there an easier way?
public static double itemDamage(ItemStack item) { public static double itemDamage(ItemStack item) {
Collection<AttributeModifier> attrs = Collection<AttributeModifier> damage_attrs =
item.getAttributeModifiers(EquipmentSlotType.MAINHAND) item.getAttributeModifiers(EquipmentSlotType.MAINHAND)
.get(Attributes.ATTACK_DAMAGE); .get(Attributes.ATTACK_DAMAGE);
if (attrs.isEmpty()) return 0.; if (damage_attrs.isEmpty()) return 0.;
return Math.abs(attrs.iterator().next().getAmount()); double damage = Math.abs(damage_attrs.iterator().next().getAmount());
Collection<AttributeModifier> speed_attrs =
item.getAttributeModifiers(EquipmentSlotType.MAINHAND)
.get(Attributes.ATTACK_SPEED);
if (speed_attrs.isEmpty()) return damage;
double speed = Math.abs(speed_attrs.iterator().next().getAmount());
return damage * speed;
} }
} }