From e97e7a6ccdbddee2256d7b9cdceb4fdaa32d7f11 Mon Sep 17 00:00:00 2001 From: Jules Date: Wed, 31 Jul 2024 14:42:17 -0700 Subject: [PATCH] Fixed MI bows dealing 3x damage in 1.21 --- .../main/java/net/Indyuce/mmoitems/listener/ItemUse.java | 3 ++- .../src/main/java/net/Indyuce/mmoitems/util/MMOUtils.java | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/listener/ItemUse.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/listener/ItemUse.java index ee0a64a6..a1e068d5 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/listener/ItemUse.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/listener/ItemUse.java @@ -20,6 +20,7 @@ import net.Indyuce.mmoitems.api.interaction.projectile.ArrowParticles; import net.Indyuce.mmoitems.api.interaction.weapon.Weapon; import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.api.util.message.Message; +import net.Indyuce.mmoitems.util.MMOUtils; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -247,7 +248,7 @@ public class ItemUse implements Listener { final ProjectileMetadata proj = ProjectileMetadata.create(playerData.getMMOPlayerData(), bowSlot, ProjectileType.ARROW, event.getProjectile()); proj.setSourceItem(item); proj.setCustomDamage(true); - proj.setDamageMultiplier(event.getForce()); + proj.setDamageMultiplier(MMOUtils.getForce(event)); if (item.hasTag("MMOITEMS_ARROW_PARTICLES")) new ArrowParticles((AbstractArrow) event.getProjectile(), item); final AbstractArrow arrow = (AbstractArrow) event.getProjectile(); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/MMOUtils.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/MMOUtils.java index 1bdd8e1c..5f060d73 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/MMOUtils.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/MMOUtils.java @@ -7,6 +7,7 @@ import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.skill.trigger.TriggerType; +import io.lumine.mythic.lib.util.annotation.BackwardsCompatibility; import io.lumine.mythic.lib.version.VPotionEffectType; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.Type; @@ -18,6 +19,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; @@ -36,6 +38,12 @@ public class MMOUtils { return particle.getDataType() == Particle.DustOptions.class; } + @BackwardsCompatibility(version = "1.21") + public static double getForce(@NotNull EntityShootBowEvent event) { + final double force = event.getForce(); + return MythicLib.plugin.getVersion().isUnder(1, 21) ? force : force / 3; + } + /** * Optimized Soulbound check based on the fact that the * compressed item Soulbound data contains only one UUID,