aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt
diff options
context:
space:
mode:
authornea <romangraef@gmail.com>2022-07-30 04:55:04 +0200
committernea <romangraef@gmail.com>2022-07-30 04:55:04 +0200
commitb9455467863f194accf30a89b2c2998822f2c105 (patch)
tree5fb27bf4b8b8b00c7ed7ce414858733a595d3847 /src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt
parente45378fd6b61a5871c306ca8439c8ee3d7dec456 (diff)
downloadFirmament-b9455467863f194accf30a89b2c2998822f2c105.tar.gz
Firmament-b9455467863f194accf30a89b2c2998822f2c105.tar.bz2
Firmament-b9455467863f194accf30a89b2c2998822f2c105.zip
repo downloading
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt')
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt b/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt
new file mode 100644
index 0000000..f3d53e8
--- /dev/null
+++ b/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt
@@ -0,0 +1,31 @@
+package moe.nea.notenoughupdates.repo
+
+import io.github.moulberry.repo.NEURepository
+import kotlinx.coroutines.launch
+import moe.nea.notenoughupdates.NotEnoughUpdates
+import moe.nea.notenoughupdates.NotEnoughUpdates.logger
+import net.minecraft.client.Minecraft
+import net.minecraft.network.protocol.game.ClientboundUpdateRecipesPacket
+
+object RepoManager {
+
+
+ val neuRepo: NEURepository = NEURepository.of(RepoDownloadManager.repoSavedLocation).apply {
+ registerReloadListener(ItemCache)
+ registerReloadListener {
+ if (Minecraft.getInstance().connection?.handleUpdateRecipes(ClientboundUpdateRecipesPacket(mutableListOf())) == null) {
+ logger.warn("Failed to issue a ClientboundUpdateRecipesPacket (to reload REI). This may lead to an outdated item list.")
+ }
+ }
+ }
+
+
+ fun launchAsyncUpdate() {
+ NotEnoughUpdates.coroutineScope.launch {
+ if (RepoDownloadManager.downloadUpdate()) {
+ neuRepo.reload()
+ }
+ }
+ }
+
+}