From 36dfda2d4cf42fd46a41796a3189f6820aa7acc7 Mon Sep 17 00:00:00 2001 From: alemi Date: Sun, 19 Feb 2023 23:48:08 +0100 Subject: [PATCH] fix: try to consider attack speed for tool dps --- src/main/java/ftbsc/bscv/tools/Inventory.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/ftbsc/bscv/tools/Inventory.java b/src/main/java/ftbsc/bscv/tools/Inventory.java index 23eb4a1..b47950f 100644 --- a/src/main/java/ftbsc/bscv/tools/Inventory.java +++ b/src/main/java/ftbsc/bscv/tools/Inventory.java @@ -21,11 +21,16 @@ public class Inventory implements ICommons { // TODO ????????????? wtf is this is there an easier way? public static double itemDamage(ItemStack item) { - Collection attrs = + Collection damage_attrs = item.getAttributeModifiers(EquipmentSlotType.MAINHAND) .get(Attributes.ATTACK_DAMAGE); - if (attrs.isEmpty()) return 0.; - return Math.abs(attrs.iterator().next().getAmount()); - + if (damage_attrs.isEmpty()) return 0.; + double damage = Math.abs(damage_attrs.iterator().next().getAmount()); + Collection 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; } }