aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/notenoughupdates/repo
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-05-04 18:23:54 +0200
committernea <nea@nea.moe>2023-05-04 18:23:54 +0200
commit508b8352cfbc066b025943cf1cbf8be5e5edb88a (patch)
tree6551a7fcdcaa90cd19aa5ce0025837eeedfa948b /src/main/kotlin/moe/nea/notenoughupdates/repo
parenta9f4aed56bed61f621a3a3faca2b77a085caabb6 (diff)
downloadFirmament-508b8352cfbc066b025943cf1cbf8be5e5edb88a.tar.gz
Firmament-508b8352cfbc066b025943cf1cbf8be5e5edb88a.tar.bz2
Firmament-508b8352cfbc066b025943cf1cbf8be5e5edb88a.zip
Add somewhat faulty crafting recipes
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/repo')
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt b/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt
index 6470914..acaaacd 100644
--- a/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt
+++ b/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt
@@ -1,20 +1,22 @@
package moe.nea.notenoughupdates.repo
import io.github.cottonmc.cotton.gui.client.CottonHud
+import io.github.moulberry.repo.NEURecipeCache
import io.github.moulberry.repo.NEURepository
import io.github.moulberry.repo.NEURepositoryException
+import io.github.moulberry.repo.data.NEURecipe
+import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
import kotlinx.coroutines.launch
import kotlinx.serialization.Serializable
import kotlinx.serialization.serializer
-import moe.nea.notenoughupdates.NotEnoughUpdates
-import moe.nea.notenoughupdates.NotEnoughUpdates.logger
-import moe.nea.notenoughupdates.hud.ProgressBar
-import moe.nea.notenoughupdates.util.data.DataHolder
-import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
import net.minecraft.client.MinecraftClient
import net.minecraft.network.packet.s2c.play.SynchronizeRecipesS2CPacket
import net.minecraft.text.Text
+import moe.nea.notenoughupdates.NotEnoughUpdates
+import moe.nea.notenoughupdates.NotEnoughUpdates.logger
+import moe.nea.notenoughupdates.hud.ProgressBar
import moe.nea.notenoughupdates.util.SkyblockId
+import moe.nea.notenoughupdates.util.data.DataHolder
object RepoManager : DataHolder<RepoManager.Config>(serializer(), "repo", ::Config) {
@Serializable
@@ -43,6 +45,13 @@ object RepoManager : DataHolder<RepoManager.Config>(serializer(), "repo", ::Conf
}
}
+ private val recipeCache = NEURecipeCache.forRepo(neuRepo)
+
+ fun getAllRecipes() = neuRepo.items.items.values.asSequence().flatMap { it.recipes }
+
+ fun getRecipesFor(skyblockId: SkyblockId): Set<NEURecipe> = recipeCache.recipes[skyblockId.neuItem] ?: setOf()
+ fun getUsagesFor(skyblockId: SkyblockId): Set<NEURecipe> = recipeCache.usages[skyblockId.neuItem] ?: setOf()
+
private fun trySendClientboundUpdateRecipesPacket(): Boolean {
return MinecraftClient.getInstance().world != null && MinecraftClient.getInstance().networkHandler?.onSynchronizeRecipes(
SynchronizeRecipesS2CPacket(mutableListOf())