summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author alemi <me@alemi.dev>2023-02-19 23:48:08 +0100
committer alemi <me@alemi.dev>2023-02-19 23:48:08 +0100
commit36dfda2d4cf42fd46a41796a3189f6820aa7acc7 (patch)
treebe0556c89810ac21ab2c830b2874ba311f5b0bcc
parent184aa773bad91975f3309d4408f308437ca17e2a (diff)
fix: try to consider attack speed for tool dps0.3.0
-rw-r--r--src/main/java/ftbsc/bscv/tools/Inventory.java13
1 files 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<AttributeModifier> attrs =
+ Collection<AttributeModifier> 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<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;
}
}