From 2fd09206dd56b195bbdd26d507438f9bf7c5ced9 Mon Sep 17 00:00:00 2001 From: Indyuce Date: Sat, 26 Jun 2021 19:20:30 +0200 Subject: [PATCH] Fixed an attack speed issue with MythicLib --- pom.xml | 17 +++++++------- .../mmoitems/api/player/PlayerStats.java | 23 ++++++++----------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/pom.xml b/pom.xml index f1638a77..93662d30 100644 --- a/pom.xml +++ b/pom.xml @@ -95,6 +95,14 @@ + + + org.spigotmc + spigot-api + 1.17-R0.1-SNAPSHOT + provided + + net.Indyuce.mmoitems.lib GoogleGSON @@ -179,14 +187,7 @@ provided - - - org.spigotmc - spigot-api - 1.17-R0.1-SNAPSHOT - provided - - + com.github.Eniripsa96 SkillAPI diff --git a/src/main/java/net/Indyuce/mmoitems/api/player/PlayerStats.java b/src/main/java/net/Indyuce/mmoitems/api/player/PlayerStats.java index 8c7fd98d..9858f608 100644 --- a/src/main/java/net/Indyuce/mmoitems/api/player/PlayerStats.java +++ b/src/main/java/net/Indyuce/mmoitems/api/player/PlayerStats.java @@ -65,13 +65,6 @@ public class PlayerStats { */ StatInstance.ModifierPacket packet = getInstance(stat).newPacket(); - /** - * Some stats including Atk Damage and Speed have stat offsets, when equipping - * at least one item which grants this stat the final value must be lowered - * by a flat amount - */ - boolean isHoldingWeapon = false; - /** * The index of the mmoitem stat modifier being added */ @@ -80,21 +73,25 @@ public class PlayerStats { for (EquippedPlayerItem item : playerData.getInventory().getEquipped()) { double value = item.getItem().getNBT().getStat(stat.getId()); + if (value != 0) { + Type type = item.getItem().getType(); ModifierSource source = type == null ? ModifierSource.OTHER : type.getItemSet().getModifierSource(); + /** + * Apply main hand weapon stat offset ie 4 for attack speed and 1 for attack damage. + */ + if (item.getSlot() == EquipmentSlot.MAIN_HAND && stat instanceof AttributeStat) + value -= ((AttributeStat) stat).getOffset(); + packet.addModifier("MMOItem-" + index++, new StatModifier(value, ModifierType.FLAT, item.getSlot(), source)); - if (!isHoldingWeapon && item.getSlot().isHand()) - isHoldingWeapon = true; } } - if (isHoldingWeapon && stat instanceof AttributeStat) - packet.addModifier("MMOItemOffset", new StatModifier(-((AttributeStat) stat).getOffset())); - /** - * Finally run a stat update + * Finally run a stat update after all modifiers + * have been gathered by MythicLib */ packet.runUpdate(); }