diff options
author | Linnea Gräf <nea@nea.moe> | 2025-03-11 12:44:59 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2025-03-11 12:44:59 +0100 |
commit | 17a855a4bdfcca00b29f85981d8fb86968d9038c (patch) | |
tree | 4ecde192607e1b6fea54fc264a6b79a197ae8619 /src/main/kotlin/repo/item/SBBreakingPower.kt | |
parent | 0765c8aee181dda89b08f89c4a7deb301f00f656 (diff) | |
download | Firmament-17a855a4bdfcca00b29f85981d8fb86968d9038c.tar.gz Firmament-17a855a4bdfcca00b29f85981d8fb86968d9038c.tar.bz2 Firmament-17a855a4bdfcca00b29f85981d8fb86968d9038c.zip |
feat: add SBItemData implementation
Diffstat (limited to 'src/main/kotlin/repo/item/SBBreakingPower.kt')
-rw-r--r-- | src/main/kotlin/repo/item/SBBreakingPower.kt | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main/kotlin/repo/item/SBBreakingPower.kt b/src/main/kotlin/repo/item/SBBreakingPower.kt new file mode 100644 index 0000000..4c88a48 --- /dev/null +++ b/src/main/kotlin/repo/item/SBBreakingPower.kt @@ -0,0 +1,31 @@ +package moe.nea.firmament.repo.item + +import com.google.auto.service.AutoService +import io.github.moulberry.repo.data.NEUItem +import net.minecraft.item.ItemStack +import moe.nea.firmament.util.mc.loreAccordingToNbt +import moe.nea.firmament.util.removeColorCodes +import moe.nea.firmament.util.unformattedString +import moe.nea.firmament.util.useMatch + +@AutoService(SBItemProperty::class) +object SBBreakingPower : SBItemProperty<Int>() { + private val BREAKING_POWER_REGEX = "Breaking Power (?<power>[0-9]+)".toPattern() + + fun fromLore(string: String?): Int? { + return BREAKING_POWER_REGEX.useMatch(string) { + group("power").toInt() + } + } + + override fun fromNeuItem(neuItem: NEUItem, store: SBItemData): Int? { + return fromLore(neuItem.lore.firstOrNull()?.removeColorCodes()) + } + + override fun fromStack( + stack: ItemStack, + store: SBItemData + ): Int? { + return fromLore(stack.loreAccordingToNbt.firstOrNull()?.unformattedString) + } +} |