diff --git a/src/main/java/com/bibireden/playerex/mixin/ItemStackMixin.java b/src/main/java/com/bibireden/playerex/mixin/ItemStackMixin.java index 71da4f4c..eb7cc61b 100644 --- a/src/main/java/com/bibireden/playerex/mixin/ItemStackMixin.java +++ b/src/main/java/com/bibireden/playerex/mixin/ItemStackMixin.java @@ -10,13 +10,10 @@ import com.llamalad7.mixinextras.sugar.Local; import net.fabric_extras.ranged_weapon.api.EntityAttributes_RangedWeapon; import net.minecraft.ChatFormatting; -import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; -import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.tags.TagKey; import net.minecraft.util.RandomSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; @@ -115,7 +112,7 @@ public void modifyAttributeModifiers(EquipmentSlot slot, CallbackInfoReturnable< HashMultimap hashmap = HashMultimap.create(cir.getReturnValue()); if (PlayerEX.CONFIG.getWeaponLevelingSettings().getEnabled() && PlayerEXUtil.isWeapon(stack)) { PlayerEXUtil.addToModifier(hashmap, Attributes.ATTACK_DAMAGE, getLevel() * PlayerEX.CONFIG.getWeaponLevelingSettings().getDamagePerLevel()); - if (stack.is(TagKey.create(Registries.ITEM, ResourceLocation.tryBuild("c", "bows")))) { + if (hashmap.containsKey(EntityAttributes_RangedWeapon.DAMAGE.attribute)) { PlayerEXUtil.addToModifier(hashmap, EntityAttributes_RangedWeapon.DAMAGE.attribute, getLevel() * PlayerEX.CONFIG.getWeaponLevelingSettings().getDamagePerLevel()); } } diff --git a/src/main/kotlin/com/bibireden/playerex/api/PlayerEXTags.kt b/src/main/kotlin/com/bibireden/playerex/api/PlayerEXTags.kt index 7e109687..ce0fed97 100644 --- a/src/main/kotlin/com/bibireden/playerex/api/PlayerEXTags.kt +++ b/src/main/kotlin/com/bibireden/playerex/api/PlayerEXTags.kt @@ -14,4 +14,7 @@ object PlayerEXTags { @JvmField val ARMOR: TagKey = TagKey.create(Registries.ITEM, PlayerEX.id("armor")) + + @JvmField + val ARMOR_BLACKLIST: TagKey = TagKey.create(Registries.ITEM, PlayerEX.id("armor_blacklist")) } diff --git a/src/main/kotlin/com/bibireden/playerex/util/PlayerEXUtil.kt b/src/main/kotlin/com/bibireden/playerex/util/PlayerEXUtil.kt index 69afed4f..2f16e138 100644 --- a/src/main/kotlin/com/bibireden/playerex/util/PlayerEXUtil.kt +++ b/src/main/kotlin/com/bibireden/playerex/util/PlayerEXUtil.kt @@ -9,7 +9,11 @@ import com.google.common.collect.Multimap import net.minecraft.world.entity.ai.attributes.Attribute import net.minecraft.world.entity.ai.attributes.AttributeModifier import net.minecraft.world.entity.player.Player +import net.minecraft.world.item.ArmorItem +import net.minecraft.world.item.BowItem +import net.minecraft.world.item.CrossbowItem import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.SwordItem import net.objecthunter.exp4j.Expression import net.objecthunter.exp4j.ExpressionBuilder import net.objecthunter.exp4j.function.Function @@ -104,12 +108,12 @@ object PlayerEXUtil { @JvmStatic fun isWeapon(stack: ItemStack): Boolean { - return stack.`is`(PlayerEXTags.WEAPONS) + return stack.item is BowItem || stack.item is CrossbowItem || stack.item is SwordItem || stack.`is`(PlayerEXTags.WEAPONS) } @JvmStatic fun isArmor(stack: ItemStack): Boolean { - return stack.`is`(PlayerEXTags.ARMOR) + return (stack.item is ArmorItem || stack.`is`(PlayerEXTags.ARMOR)) && !stack.`is`(PlayerEXTags.ARMOR_BLACKLIST) } @JvmStatic diff --git a/src/main/resources/data/playerex/tags/items/weapons.json b/src/main/resources/data/playerex/tags/items/weapons.json index 587cfc5d..e0df7d72 100644 --- a/src/main/resources/data/playerex/tags/items/weapons.json +++ b/src/main/resources/data/playerex/tags/items/weapons.json @@ -5,6 +5,14 @@ "id": "#c:swords", "required": false }, + { + "id": "#fabric:swords", + "required": false + }, + { + "id": "#c:weapons", + "required": false + }, { "id": "#c:axes", "required": false @@ -14,11 +22,11 @@ "required": false }, { - "id": "#c:shields", + "id": "#c:bows", "required": false }, { - "id": "#c:bows", + "id": "#fabric:bows", "required": false }, "#minecraft:swords",