Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Item detection changes #60

Merged
merged 6 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
bibi-reden marked this conversation as resolved.
Show resolved Hide resolved
(it is ArmorItem || it.defaultInstance.`is`(PlayerEXTags.ARMOR)) && !it.defaultInstance.`is`(PlayerEXTags.ARMOR_BLACKLIST)
}.anyMatch { stack.`is`(it) };
}

@JvmStatic
Expand Down