diff options
author | nea <romangraef@gmail.com> | 2022-07-29 23:09:36 +0200 |
---|---|---|
committer | nea <romangraef@gmail.com> | 2022-07-29 23:09:36 +0200 |
commit | e45378fd6b61a5871c306ca8439c8ee3d7dec456 (patch) | |
tree | db279da4205594ba4e5ac4b1bc235dd60b2096d1 /src/main/kotlin/moe | |
parent | f4bf70032a45b4daa7805ca38f2d820645dc9a6b (diff) | |
download | Firmament-e45378fd6b61a5871c306ca8439c8ee3d7dec456.tar.gz Firmament-e45378fd6b61a5871c306ca8439c8ee3d7dec456.tar.bz2 Firmament-e45378fd6b61a5871c306ca8439c8ee3d7dec456.zip |
repo reloading
Diffstat (limited to 'src/main/kotlin/moe')
3 files changed, 34 insertions, 8 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() { } } diff --git a/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt b/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt index cc4b0f1..69cca41 100644 --- a/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt +++ b/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt @@ -20,10 +20,8 @@ class NEUReiPlugin : REIClientPlugin { return EntryStack.of(VanillaEntryTypes.ITEM, value.asItemStack()) } - val SKYBLOCK_ITEM_TYPE_ID = ResourceLocation("notenoughupdates", "skyblockitems") } - override fun registerEntryTypes(registry: EntryTypeRegistry) { registry.register(SKYBLOCK_ITEM_TYPE_ID, SBItemEntryDefinition) } diff --git a/src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt b/src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt index 6726b4f..5ae154d 100644 --- a/src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt +++ b/src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt @@ -2,7 +2,6 @@ package moe.nea.notenoughupdates.rei import com.mojang.blaze3d.vertex.PoseStack import io.github.moulberry.repo.data.NEUItem -import me.shedaniel.math.Point import me.shedaniel.math.Rectangle import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer import me.shedaniel.rei.api.client.gui.widgets.Tooltip @@ -24,7 +23,7 @@ import java.util.stream.Stream object SBItemEntryDefinition : EntryDefinition<NEUItem> { override fun equals(o1: NEUItem?, o2: NEUItem?, context: ComparisonContext?): Boolean { - return o1 == o2 + return o1 === o2 } override fun cheatsAs(entry: EntryStack<NEUItem>?, value: NEUItem?): ItemStack? { @@ -71,7 +70,7 @@ object SBItemEntryDefinition : EntryDefinition<NEUItem> { } override fun hash(entry: EntryStack<NEUItem>, value: NEUItem, context: ComparisonContext): Long { - return value.skyblockItemId.hashCode().toLong() + return System.identityHashCode(value) * 31L } override fun wildcard(entry: EntryStack<NEUItem>, value: NEUItem): NEUItem { |