aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/notenoughupdates/NotEnoughUpdates.kt
diff options
context:
space:
mode:
authornea <romangraef@gmail.com>2022-07-29 23:09:36 +0200
committernea <romangraef@gmail.com>2022-07-29 23:09:36 +0200
commite45378fd6b61a5871c306ca8439c8ee3d7dec456 (patch)
treedb279da4205594ba4e5ac4b1bc235dd60b2096d1 /src/main/kotlin/moe/nea/notenoughupdates/NotEnoughUpdates.kt
parentf4bf70032a45b4daa7805ca38f2d820645dc9a6b (diff)
downloadfirmament-e45378fd6b61a5871c306ca8439c8ee3d7dec456.tar.gz
firmament-e45378fd6b61a5871c306ca8439c8ee3d7dec456.tar.bz2
firmament-e45378fd6b61a5871c306ca8439c8ee3d7dec456.zip
repo reloading
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/NotEnoughUpdates.kt')
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/NotEnoughUpdates.kt35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/NotEnoughUpdates.kt b/src/main/kotlin/moe/nea/notenoughupdates/NotEnoughUpdates.kt
index 79b8819..27c51e1 100644
--- a/src/main/kotlin/moe/nea/notenoughupdates/NotEnoughUpdates.kt
+++ b/src/main/kotlin/moe/nea/notenoughupdates/NotEnoughUpdates.kt
@@ -1,18 +1,47 @@
package moe.nea.notenoughupdates
+import com.mojang.brigadier.CommandDispatcher
import io.github.moulberry.repo.NEURepository
+import moe.nea.notenoughupdates.repo.ItemCache
+import net.fabricmc.api.ClientModInitializer
import net.fabricmc.api.ModInitializer
+import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager
+import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback
+import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
+import net.minecraft.client.Minecraft
+import net.minecraft.commands.CommandBuildContext
+import net.minecraft.network.chat.Component
+import net.minecraft.network.protocol.game.ClientboundUpdateRecipesPacket
import java.nio.file.Path
-object NotEnoughUpdates : ModInitializer {
+object NotEnoughUpdates : ModInitializer, ClientModInitializer {
val DATA_DIR = Path.of(".notenoughupdates")
const val MOD_ID = "notenoughupdates"
- val neuRepo = NEURepository.of(Path.of("NotEnoughUpdates-REPO")).also {
- it.reload()
+ val neuRepo: NEURepository = NEURepository.of(Path.of("NotEnoughUpdates-REPO")).apply {
+ registerReloadListener(ItemCache)
+ reload()
+ registerReloadListener {
+ Minecraft.getInstance().connection?.handleUpdateRecipes(ClientboundUpdateRecipesPacket(mutableListOf()))
+ }
+ }
+
+ fun registerCommands(
+ dispatcher: CommandDispatcher<FabricClientCommandSource>, registryAccess: CommandBuildContext
+ ) {
+ dispatcher.register(ClientCommandManager.literal("neureload").executes {
+ it.source.sendFeedback(Component.literal("Reloading repository from disk. This may lag a bit."))
+ neuRepo.reload()
+ 0
+ })
+
}
override fun onInitialize() {
+ ClientCommandRegistrationCallback.EVENT.register(this::registerCommands)
+ }
+
+ override fun onInitializeClient() {
}
}