aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/PrimitiveIngredient.kt
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2024-09-23 15:48:19 +1000
committerGitHub <noreply@github.com>2024-09-23 07:48:19 +0200
commitb0735ffc3ed655838de6d0d0eb6376cde92483d1 (patch)
treeb98308044ce17e6df360bfc4058756fed4594b64 /src/main/java/at/hannibal2/skyhanni/utils/PrimitiveIngredient.kt
parent8f7b79a0b4953bb64f342ccc21d962c8aacbc169 (diff)
downloadskyhanni-b0735ffc3ed655838de6d0d0eb6376cde92483d1.tar.gz
skyhanni-b0735ffc3ed655838de6d0d0eb6376cde92483d1.tar.bz2
skyhanni-b0735ffc3ed655838de6d0d0eb6376cde92483d1.zip
Backend: Create and use primitive recipe and ingredient (#2460)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/PrimitiveIngredient.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/PrimitiveIngredient.kt26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/PrimitiveIngredient.kt b/src/main/java/at/hannibal2/skyhanni/utils/PrimitiveIngredient.kt
new file mode 100644
index 000000000..e8d1edefc
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/utils/PrimitiveIngredient.kt
@@ -0,0 +1,26 @@
+package at.hannibal2.skyhanni.utils
+
+import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.SKYBLOCK_COIN
+import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
+import io.github.moulberry.notenoughupdates.recipes.Ingredient
+
+class PrimitiveIngredient(val internalName: NEUInternalName, val count: Double = 1.0) {
+
+ constructor(internalName: NEUInternalName, count: Int) : this(internalName, count.toDouble())
+
+ constructor(ingredientIdentifier: String) : this(
+ ingredientIdentifier.substringBefore(':').asInternalName(),
+ ingredientIdentifier.substringAfter(':').toDoubleOrNull() ?: 1.0,
+ )
+
+ companion object {
+ fun coinIngredient(count: Double = 1.0) = PrimitiveIngredient(SKYBLOCK_COIN, count)
+
+ fun fromNeuIngredient(neuIngredient: Ingredient) = PrimitiveIngredient(neuIngredient.internalItemId.asInternalName(), neuIngredient.count)
+ }
+
+ fun isCoin() = internalName == SKYBLOCK_COIN
+
+
+ override fun toString() = "$internalName x$count"
+}