diff options
| author | Linnea Gräf <nea@nea.moe> | 2025-11-17 19:55:02 +0100 |
|---|---|---|
| committer | Linnea Gräf <nea@nea.moe> | 2025-11-17 19:55:02 +0100 |
| commit | c93a04a001b0f66b2724d46b04b6d1ed49a08d07 (patch) | |
| tree | 5869ca70acc482ef0362f27785c3d3f1cbb9ffae /src/main/kotlin/features/mining | |
| parent | af9893b59407c69d31ebd2ed513f0396ab4d2dc9 (diff) | |
| download | Firmament-c93a04a001b0f66b2724d46b04b6d1ed49a08d07.tar.gz Firmament-c93a04a001b0f66b2724d46b04b6d1ed49a08d07.tar.bz2 Firmament-c93a04a001b0f66b2724d46b04b6d1ed49a08d07.zip | |
refactor: port to mojmaps
Diffstat (limited to 'src/main/kotlin/features/mining')
5 files changed, 57 insertions, 57 deletions
diff --git a/src/main/kotlin/features/mining/CommissionFeatures.kt b/src/main/kotlin/features/mining/CommissionFeatures.kt index 1041ae5..bfc635a 100644 --- a/src/main/kotlin/features/mining/CommissionFeatures.kt +++ b/src/main/kotlin/features/mining/CommissionFeatures.kt @@ -20,7 +20,7 @@ object CommissionFeatures { fun onSlotRender(event: SlotRenderEvents.Before) { if (!TConfig.highlightCompletedCommissions) return if (MC.screenName != "Commissions") return - val stack = event.slot.stack + val stack = event.slot.item if (stack.loreAccordingToNbt.any { it.unformattedString == "COMPLETED" }) { event.highlight(Firmament.identifier("completed_commission_background")) } diff --git a/src/main/kotlin/features/mining/HotmPresets.kt b/src/main/kotlin/features/mining/HotmPresets.kt index 97c9a7c..5316211 100644 --- a/src/main/kotlin/features/mining/HotmPresets.kt +++ b/src/main/kotlin/features/mining/HotmPresets.kt @@ -3,15 +3,15 @@ package moe.nea.firmament.features.mining import me.shedaniel.math.Rectangle import kotlinx.serialization.Serializable import kotlin.time.Duration.Companion.seconds -import net.minecraft.block.Blocks -import net.minecraft.client.gui.Click -import net.minecraft.client.gui.DrawContext -import net.minecraft.client.gui.screen.ingame.HandledScreen -import net.minecraft.entity.player.PlayerInventory -import net.minecraft.item.Items -import net.minecraft.screen.GenericContainerScreenHandler -import net.minecraft.screen.slot.Slot -import net.minecraft.text.Text +import net.minecraft.world.level.block.Blocks +import net.minecraft.client.input.MouseButtonEvent +import net.minecraft.client.gui.GuiGraphics +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen +import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.item.Items +import net.minecraft.world.inventory.ChestMenu +import net.minecraft.world.inventory.Slot +import net.minecraft.network.chat.Component import moe.nea.firmament.Firmament import moe.nea.firmament.annotations.Subscribe import moe.nea.firmament.commands.thenExecute @@ -51,8 +51,8 @@ object HotmPresets { fun onScreenOpen(event: ScreenChangeEvent) { val title = event.new?.title?.unformattedString if (title != hotmInventoryName) return - val screen = event.new as? HandledScreen<*> ?: return - val oldHandler = (event.old as? HandledScreen<*>)?.customGui + val screen = event.new as? AbstractContainerScreen<*> ?: return + val oldHandler = (event.old as? AbstractContainerScreen<*>)?.customGui if (oldHandler is HotmScrollPrompt) { event.new.customGui = oldHandler oldHandler.setNewScreen(screen) @@ -63,32 +63,32 @@ object HotmPresets { screen.customGui = HotmScrollPrompt(screen) } - class HotmScrollPrompt(var screen: HandledScreen<*>) : CustomGui() { + class HotmScrollPrompt(var screen: AbstractContainerScreen<*>) : CustomGui() { var bounds = Rectangle( 0, 0, 0, 0 ) - fun setNewScreen(screen: HandledScreen<*>) { + fun setNewScreen(screen: AbstractContainerScreen<*>) { this.screen = screen onInit() hasScrolled = false } - override fun render(drawContext: DrawContext, delta: Float, mouseX: Int, mouseY: Int) { + override fun render(drawContext: GuiGraphics, delta: Float, mouseX: Int, mouseY: Int) { drawContext.drawGuiTexture( CommonTextures.genericWidget(), bounds.x, bounds.y, bounds.width, bounds.height, ) - drawContext.drawCenteredTextWithShadow( + drawContext.drawCenteredString( MC.font, if (hasAll) { - Text.translatable("firmament.hotmpreset.copied") + Component.translatable("firmament.hotmpreset.copied") } else if (!hasScrolled) { - Text.translatable("firmament.hotmpreset.scrollprompt") + Component.translatable("firmament.hotmpreset.scrollprompt") } else { - Text.translatable("firmament.hotmpreset.scrolled") + Component.translatable("firmament.hotmpreset.scrolled") }, bounds.centerX, bounds.centerY - 5, @@ -100,11 +100,11 @@ object HotmPresets { var hasScrolled = false var hasAll = false - override fun mouseClick(click: Click, doubled: Boolean): Boolean { + override fun mouseClick(click: MouseButtonEvent, doubled: Boolean): Boolean { if (!hasScrolled) { - val slot = screen.screenHandler.getSlot(8) - println("Clicking ${slot.stack}") - slot.clickRightMouseButton(screen.screenHandler) + val slot = screen.menu.getSlot(8) + println("Clicking ${slot.item}") + slot.clickRightMouseButton(screen.menu) } hasScrolled = true return super.mouseClick(click, doubled) @@ -140,10 +140,10 @@ object HotmPresets { val allRows = (1..10).toSet() fun onNewItems(event: ChestInventoryUpdateEvent) { - val handler = screen.screenHandler as? GenericContainerScreenHandler ?: return + val handler = screen.menu as? ChestMenu ?: return for (it in handler.slots) { - if (it.inventory is PlayerInventory) continue - val stack = it.stack + if (it.container is Inventory) continue + val stack = it.item val name = stack.displayNameAccordingToNbt.unformattedString tierRegex.useMatch(name) { coveredRows.add(group("tier").toInt()) @@ -169,7 +169,7 @@ object HotmPresets { @Subscribe fun onSlotUpdates(event: ChestInventoryUpdateEvent) { - val customGui = (event.inventory as? HandledScreen<*>)?.customGui + val customGui = (event.inventory as? AbstractContainerScreen<*>)?.customGui if (customGui is HotmScrollPrompt) { customGui.onNewItems(event) } @@ -185,7 +185,7 @@ object HotmPresets { @Subscribe fun onSlotRender(event: SlotRenderEvents.Before) { if (hotmInventoryName == MC.screenName - && event.slot.stack.displayNameAccordingToNbt.unformattedString in highlightedPerks + && event.slot.item.displayNameAccordingToNbt.unformattedString in highlightedPerks ) { event.highlight((Firmament.identifier("hotm_perk_preset"))) } @@ -197,7 +197,7 @@ object HotmPresets { thenExecute { hotmCommandSent = TimeMark.now() MC.sendCommand("hotm") - source.sendFeedback(Text.translatable("firmament.hotmpreset.openinghotm")) + source.sendFeedback(Component.translatable("firmament.hotmpreset.openinghotm")) } } event.subcommand("importhotm") { @@ -205,10 +205,10 @@ object HotmPresets { val template = TemplateUtil.maybeDecodeTemplate<HotmPreset>(SHARE_PREFIX, ClipboardUtils.getTextContents()) if (template == null) { - source.sendFeedback(Text.translatable("firmament.hotmpreset.failedimport")) + source.sendFeedback(Component.translatable("firmament.hotmpreset.failedimport")) } else { highlightedPerks = template.perks.mapTo(mutableSetOf()) { it.perkName } - source.sendFeedback(Text.translatable("firmament.hotmpreset.okayimport")) + source.sendFeedback(Component.translatable("firmament.hotmpreset.okayimport")) MC.sendCommand("hotm") } } diff --git a/src/main/kotlin/features/mining/MiningBlockInfoUi.kt b/src/main/kotlin/features/mining/MiningBlockInfoUi.kt index f4def44..6c50665 100644 --- a/src/main/kotlin/features/mining/MiningBlockInfoUi.kt +++ b/src/main/kotlin/features/mining/MiningBlockInfoUi.kt @@ -3,8 +3,8 @@ package moe.nea.firmament.features.mining import io.github.notenoughupdates.moulconfig.observer.ObservableList import io.github.notenoughupdates.moulconfig.platform.MoulConfigPlatform import io.github.notenoughupdates.moulconfig.xml.Bind -import net.minecraft.client.gui.screen.Screen -import net.minecraft.item.ItemStack +import net.minecraft.client.gui.screens.Screen +import net.minecraft.world.item.ItemStack import moe.nea.firmament.repo.MiningRepoData import moe.nea.firmament.repo.RepoManager import moe.nea.firmament.util.MoulConfigUtils diff --git a/src/main/kotlin/features/mining/PickaxeAbility.kt b/src/main/kotlin/features/mining/PickaxeAbility.kt index 862d979..23b55e5 100644 --- a/src/main/kotlin/features/mining/PickaxeAbility.kt +++ b/src/main/kotlin/features/mining/PickaxeAbility.kt @@ -5,13 +5,13 @@ import java.util.regex.Pattern import kotlin.jvm.optionals.getOrNull import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds -import net.minecraft.client.MinecraftClient -import net.minecraft.client.toast.SystemToast -import net.minecraft.item.ItemStack -import net.minecraft.util.DyeColor -import net.minecraft.util.Hand -import net.minecraft.util.Identifier -import net.minecraft.util.StringIdentifiable +import net.minecraft.client.Minecraft +import net.minecraft.client.gui.components.toasts.SystemToast +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.DyeColor +import net.minecraft.world.InteractionHand +import net.minecraft.resources.ResourceLocation +import net.minecraft.util.StringRepresentable import moe.nea.firmament.annotations.Subscribe import moe.nea.firmament.events.HudRenderEvent import moe.nea.firmament.events.ProcessChatEvent @@ -48,13 +48,13 @@ object PickaxeAbility { val identifier: String get() = "pickaxe-info" - enum class ShowOnTools(val label: String, val items: Set<ItemType>) : StringIdentifiable { + enum class ShowOnTools(val label: String, val items: Set<ItemType>) : StringRepresentable { ALL("all", ItemType.DRILL, ItemType.PICKAXE, ItemType.SHOVEL, ItemType.AXE), PICKAXES_AND_DRILLS("pick-and-drill", ItemType.PICKAXE, ItemType.DRILL), DRILLS("drills", ItemType.DRILL), ; - override fun asString(): String? { + override fun getSerializedName(): String? { return label } @@ -79,12 +79,12 @@ object PickaxeAbility { } } - enum class BlockPickaxeAbility : StringIdentifiable { + enum class BlockPickaxeAbility : StringRepresentable { NEVER, ALWAYS, ONLY_DESTRUCTIVE; - override fun asString(): String { + override fun getSerializedName(): String { return name } } @@ -195,11 +195,11 @@ object PickaxeAbility { val ability = group("name") lastUsage[ability] = TimeMark.farPast() if (!TConfig.cooldownReadyToast) return - val mc: MinecraftClient = MinecraftClient.getInstance() - mc.toastManager.add( - SystemToast.create( + val mc: Minecraft = Minecraft.getInstance() + mc.toastManager.addToast( + SystemToast.multiline( mc, - SystemToast.Type.NARRATOR_TOGGLE, + SystemToast.SystemToastId.NARRATOR_TOGGLE, tr("firmament.pickaxe.ability-ready", "Pickaxe Cooldown"), tr("firmament.pickaxe.ability-ready.desc", "Pickaxe ability is ready!") ) @@ -248,7 +248,7 @@ object PickaxeAbility { if (!TConfig.cooldownEnabled) return if (TConfig.disableInDungeons && DungeonUtil.isInDungeonIsland) return if (!event.isRenderingCursor) return - val stack = MC.player?.getStackInHand(Hand.MAIN_HAND) ?: return + val stack = MC.player?.getItemInHand(InteractionHand.MAIN_HAND) ?: return if (!TConfig.showOnTools.matches(ItemType.fromItemStack(stack) ?: ItemType.NIL)) return var ability = getCooldownFromLore(stack)?.also { ability -> @@ -258,15 +258,15 @@ object PickaxeAbility { if (ability == null || (ao != ability.name && ao != null)) { ability = PickaxeAbilityData(ao ?: return, defaultAbilityDurations[ao] ?: 120.seconds) } - event.context.matrices.pushMatrix() - event.context.matrices.translate(MC.window.scaledWidth / 2F, MC.window.scaledHeight / 2F) - event.context.matrices.scale(TConfig.cooldownScale.toFloat(), TConfig.cooldownScale.toFloat()) + event.context.pose().pushMatrix() + event.context.pose().translate(MC.window.guiScaledWidth / 2F, MC.window.guiScaledHeight / 2F) + event.context.pose().scale(TConfig.cooldownScale.toFloat(), TConfig.cooldownScale.toFloat()) RenderCircleProgress.renderCircle( - event.context, Identifier.of("firmament", "textures/gui/circle.png"), + event.context, ResourceLocation.fromNamespaceAndPath("firmament", "textures/gui/circle.png"), getCooldownPercentage(ability.name, ability.cooldown).toFloat(), 0f, 1f, 0f, 1f, color = TConfig.cooldownColour.getEffectiveColourRGB() ) - event.context.matrices.popMatrix() + event.context.pose().popMatrix() } } diff --git a/src/main/kotlin/features/mining/PristineProfitTracker.kt b/src/main/kotlin/features/mining/PristineProfitTracker.kt index ad864c1..0470702 100644 --- a/src/main/kotlin/features/mining/PristineProfitTracker.kt +++ b/src/main/kotlin/features/mining/PristineProfitTracker.kt @@ -5,7 +5,7 @@ import org.joml.Vector2i import kotlinx.serialization.Serializable import kotlinx.serialization.serializer import kotlin.time.Duration.Companion.seconds -import net.minecraft.text.Text +import net.minecraft.network.chat.Component import moe.nea.firmament.annotations.Subscribe import moe.nea.firmament.events.ProcessChatEvent import moe.nea.firmament.gui.hud.MoulConfigHud @@ -105,11 +105,11 @@ object PristineProfitTracker { val moneyPerSecond = moneyHistogram.averagePer({ it }, 1.seconds) if (collectionPerSecond == null || moneyPerSecond == null) return ProfitHud.collectionCurrent = collectionPerSecond - ProfitHud.collectionText = Text.stringifiedTranslatable("firmament.pristine-profit.collection", + ProfitHud.collectionText = Component.translatableEscape("firmament.pristine-profit.collection", formatCommas(collectionPerSecond * SECONDS_PER_HOUR, 1)).formattedString() ProfitHud.moneyCurrent = moneyPerSecond - ProfitHud.moneyText = Text.stringifiedTranslatable("firmament.pristine-profit.money", + ProfitHud.moneyText = Component.translatableEscape("firmament.pristine-profit.money", formatCommas(moneyPerSecond * SECONDS_PER_HOUR, 1)) .formattedString() val data = DConfig.data |
