Skip to content

Commit

Permalink
[fix] Implement extra check for armour
Browse files Browse the repository at this point in the history
- As `#c:armor` tag didn't officially exist in this version, almost 0 mods use it.
  • Loading branch information
naomieow committed Dec 16, 2024
1 parent 1232246 commit d9d0e61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/main/kotlin/com/bibireden/playerex/api/PlayerEXTags.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ object PlayerEXTags {

@JvmField
val ARMOR: TagKey<Item> = TagKey.create(Registries.ITEM, PlayerEX.id("armor"))

@JvmField
val ARMOR_BLACKLIST: TagKey<Item> = TagKey.create(Registries.ITEM, PlayerEX.id("armor_blacklist"))
}
6 changes: 5 additions & 1 deletion src/main/kotlin/com/bibireden/playerex/util/PlayerEXUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import com.bibireden.playerex.api.PlayerEXTags
import com.bibireden.playerex.ext.level
import com.bibireden.playerex.ext.xp
import com.google.common.collect.Multimap
import net.minecraft.core.registries.BuiltInRegistries
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.ItemStack
import net.objecthunter.exp4j.Expression
import net.objecthunter.exp4j.ExpressionBuilder
Expand Down Expand Up @@ -109,7 +111,9 @@ object PlayerEXUtil {

@JvmStatic
fun isArmor(stack: ItemStack): Boolean {
return stack.`is`(PlayerEXTags.ARMOR)
return BuiltInRegistries.ITEM.stream().filter {
(it is ArmorItem || it.defaultInstance.`is`(PlayerEXTags.ARMOR)) && !it.defaultInstance.`is`(PlayerEXTags.ARMOR_BLACKLIST)
}.anyMatch { stack.`is`(it) };
}

@JvmStatic
Expand Down

0 comments on commit d9d0e61

Please sign in to comment.