aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/features/mining
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/features/mining')
-rw-r--r--src/main/kotlin/features/mining/CommissionFeatures.kt10
-rw-r--r--src/main/kotlin/features/mining/Histogram.kt3
-rw-r--r--src/main/kotlin/features/mining/HotmPresets.kt69
-rw-r--r--src/main/kotlin/features/mining/MiningBlockInfoUi.kt53
-rw-r--r--src/main/kotlin/features/mining/PickaxeAbility.kt112
-rw-r--r--src/main/kotlin/features/mining/PristineProfitTracker.kt47
6 files changed, 201 insertions, 93 deletions
diff --git a/src/main/kotlin/features/mining/CommissionFeatures.kt b/src/main/kotlin/features/mining/CommissionFeatures.kt
index faba253..bfc635a 100644
--- a/src/main/kotlin/features/mining/CommissionFeatures.kt
+++ b/src/main/kotlin/features/mining/CommissionFeatures.kt
@@ -3,22 +3,24 @@ package moe.nea.firmament.features.mining
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.SlotRenderEvents
-import moe.nea.firmament.gui.config.ManagedConfig
import moe.nea.firmament.util.MC
+import moe.nea.firmament.util.data.Config
+import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.mc.loreAccordingToNbt
import moe.nea.firmament.util.unformattedString
object CommissionFeatures {
- object Config : ManagedConfig("commissions", Category.MINING) {
+ @Config
+ object TConfig : ManagedConfig("commissions", Category.MINING) {
val highlightCompletedCommissions by toggle("highlight-completed") { true }
}
@Subscribe
fun onSlotRender(event: SlotRenderEvents.Before) {
- if (!Config.highlightCompletedCommissions) return
+ 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/Histogram.kt b/src/main/kotlin/features/mining/Histogram.kt
index ed48437..08ee893 100644
--- a/src/main/kotlin/features/mining/Histogram.kt
+++ b/src/main/kotlin/features/mining/Histogram.kt
@@ -1,7 +1,8 @@
package moe.nea.firmament.features.mining
-import java.util.*
+import java.util.NavigableMap
+import java.util.TreeMap
import kotlin.time.Duration
import moe.nea.firmament.util.TimeMark
diff --git a/src/main/kotlin/features/mining/HotmPresets.kt b/src/main/kotlin/features/mining/HotmPresets.kt
index 2241fee..4930f90 100644
--- a/src/main/kotlin/features/mining/HotmPresets.kt
+++ b/src/main/kotlin/features/mining/HotmPresets.kt
@@ -3,14 +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.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
@@ -18,12 +19,12 @@ import moe.nea.firmament.events.ChestInventoryUpdateEvent
import moe.nea.firmament.events.CommandEvent
import moe.nea.firmament.events.ScreenChangeEvent
import moe.nea.firmament.events.SlotRenderEvents
-import moe.nea.firmament.gui.config.ManagedConfig
import moe.nea.firmament.mixins.accessor.AccessorHandledScreen
import moe.nea.firmament.util.ClipboardUtils
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.TemplateUtil
import moe.nea.firmament.util.TimeMark
+import moe.nea.firmament.util.accessors.castAccessor
import moe.nea.firmament.util.customgui.CustomGui
import moe.nea.firmament.util.customgui.customGui
import moe.nea.firmament.util.mc.CommonTextures
@@ -51,8 +52,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 +64,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,14 +101,14 @@ object HotmPresets {
var hasScrolled = false
var hasAll = false
- override fun mouseClick(mouseX: Double, mouseY: Double, button: Int): 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(mouseX, mouseY, button)
+ return super.mouseClick(click, doubled)
}
override fun shouldDrawForeground(): Boolean {
@@ -124,7 +125,7 @@ object HotmPresets {
screen.height / 2 - 100,
300, 200
)
- val screen = screen as AccessorHandledScreen
+ val screen = screen.castAccessor()
screen.x_Firmament = bounds.x
screen.y_Firmament = bounds.y
screen.backgroundWidth_Firmament = bounds.width
@@ -140,10 +141,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())
@@ -156,7 +157,9 @@ object HotmPresets {
}
}
if (allRows == coveredRows) {
- ClipboardUtils.setTextContent(TemplateUtil.encodeTemplate(SHARE_PREFIX, HotmPreset(
+ ClipboardUtils.setTextContent(
+ TemplateUtil.encodeTemplate(
+ SHARE_PREFIX, HotmPreset(
unlockedPerks.map { PerkPreset(it) }
)))
hasAll = true
@@ -169,7 +172,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 +188,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 +200,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 +208,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
new file mode 100644
index 0000000..6c50665
--- /dev/null
+++ b/src/main/kotlin/features/mining/MiningBlockInfoUi.kt
@@ -0,0 +1,53 @@
+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.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
+import moe.nea.firmament.util.SkyBlockIsland
+
+object MiningBlockInfoUi {
+ class MiningInfo(miningData: MiningRepoData) {
+ @field:Bind("search")
+ @JvmField
+ var search = ""
+
+ @get:Bind("ores")
+ val blocks = miningData.customMiningBlocks.mapTo(ObservableList(mutableListOf())) { OreInfo(it, this) }
+ }
+
+ class OreInfo(block: MiningRepoData.CustomMiningBlock, info: MiningInfo) {
+ @get:Bind("oreName")
+ val oreName = block.name ?: "No Name"
+
+ @get:Bind("blocks")
+ val res = ObservableList(block.blocks189.map { BlockInfo(it, info) })
+ }
+
+ class BlockInfo(val block: MiningRepoData.Block189, val info: MiningInfo) {
+ @get:Bind("item")
+ val item = MoulConfigPlatform.wrap(block.block?.let { ItemStack(it) } ?: ItemStack.EMPTY)
+
+ @get:Bind("isSelected")
+ val isSelected get() = info.search.let { block.isActiveIn(SkyBlockIsland.forMode(it)) }
+
+ @get:Bind("itemName")
+ val itemName get() = item.getDisplayName()
+
+ @get:Bind("restrictions")
+ val res = ObservableList(
+ if (block.onlyIn != null)
+ block.onlyIn.map { " §r- §a${it.userFriendlyName}" }
+ else
+ listOf("Everywhere")
+ )
+ }
+
+ fun makeScreen(): Screen {
+ return MoulConfigUtils.loadScreen("mining_block_info/index", MiningInfo(RepoManager.miningData), null)
+ }
+}
diff --git a/src/main/kotlin/features/mining/PickaxeAbility.kt b/src/main/kotlin/features/mining/PickaxeAbility.kt
index 94b49f9..23b55e5 100644
--- a/src/main/kotlin/features/mining/PickaxeAbility.kt
+++ b/src/main/kotlin/features/mining/PickaxeAbility.kt
@@ -1,13 +1,17 @@
package moe.nea.firmament.features.mining
+import io.github.notenoughupdates.moulconfig.ChromaColour
import java.util.regex.Pattern
+import kotlin.jvm.optionals.getOrNull
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
-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
@@ -15,8 +19,6 @@ import moe.nea.firmament.events.ProfileSwitchEvent
import moe.nea.firmament.events.SlotClickEvent
import moe.nea.firmament.events.UseItemEvent
import moe.nea.firmament.events.WorldReadyEvent
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.gui.config.ManagedConfig
import moe.nea.firmament.util.DurabilityBarEvent
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.SBData
@@ -24,6 +26,8 @@ import moe.nea.firmament.util.SHORT_NUMBER_FORMAT
import moe.nea.firmament.util.SkyBlockIsland
import moe.nea.firmament.util.TIME_PATTERN
import moe.nea.firmament.util.TimeMark
+import moe.nea.firmament.util.data.Config
+import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.extraAttributes
import moe.nea.firmament.util.mc.displayNameAccordingToNbt
import moe.nea.firmament.util.mc.loreAccordingToNbt
@@ -33,20 +37,40 @@ import moe.nea.firmament.util.red
import moe.nea.firmament.util.render.RenderCircleProgress
import moe.nea.firmament.util.render.lerp
import moe.nea.firmament.util.skyblock.AbilityUtils
+import moe.nea.firmament.util.skyblock.DungeonUtil
import moe.nea.firmament.util.skyblock.ItemType
import moe.nea.firmament.util.toShedaniel
import moe.nea.firmament.util.tr
import moe.nea.firmament.util.unformattedString
import moe.nea.firmament.util.useMatch
-object PickaxeAbility : FirmamentFeature {
- override val identifier: String
+object PickaxeAbility {
+ val identifier: String
get() = "pickaxe-info"
+ 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 getSerializedName(): String? {
+ return label
+ }
+
+ constructor(label: String, vararg items: ItemType) : this(label, items.toSet())
+
+ fun matches(type: ItemType) = items.contains(type)
+ }
+
+ @Config
object TConfig : ManagedConfig(identifier, Category.MINING) {
val cooldownEnabled by toggle("ability-cooldown") { false }
+ val disableInDungeons by toggle("disable-in-dungeons") { true }
+ val showOnTools by choice("show-on-tools") { ShowOnTools.PICKAXES_AND_DRILLS }
val cooldownScale by integer("ability-scale", 16, 64) { 16 }
+ val cooldownColour by colour("ability-colour") { ChromaColour.fromStaticRGB(187, 54, 44, 128) }
+ val cooldownReadyToast by toggle("ability-cooldown-toast") { false }
val drillFuelBar by toggle("fuel-bar") { true }
val blockOnPrivateIsland by choice(
"block-on-dynamic",
@@ -55,12 +79,12 @@ object PickaxeAbility : FirmamentFeature {
}
}
- enum class BlockPickaxeAbility : StringIdentifiable {
+ enum class BlockPickaxeAbility : StringRepresentable {
NEVER,
ALWAYS,
ONLY_DESTRUCTIVE;
- override fun asString(): String {
+ override fun getSerializedName(): String {
return name
}
}
@@ -79,9 +103,6 @@ object PickaxeAbility : FirmamentFeature {
val destructiveAbilities = setOf("Pickobulus")
val pickaxeTypes = setOf(ItemType.PICKAXE, ItemType.DRILL, ItemType.GAUNTLET)
- override val config: ManagedConfig
- get() = TConfig
-
fun getCooldownPercentage(name: String, cooldown: Duration): Double {
val sinceLastUsage = lastUsage[name]?.passedTime() ?: Duration.INFINITE
val sinceLobbyJoin = lobbyJoinTime.passedTime()
@@ -108,9 +129,12 @@ object PickaxeAbility : FirmamentFeature {
BlockPickaxeAbility.ONLY_DESTRUCTIVE -> ability.any { it.name in destructiveAbilities }
}
if (shouldBlock) {
- MC.sendChat(tr("firmament.pickaxe.blocked",
- "Firmament blocked a pickaxe ability from being used on a private island.")
- .red() // TODO: .clickCommand("firm confignavigate ${TConfig.identifier} block-on-dynamic")
+ MC.sendChat(
+ tr(
+ "firmament.pickaxe.blocked",
+ "Firmament blocked a pickaxe ability from being used on a private island."
+ )
+ .red() // TODO: .clickCommand("firm confignavigate ${TConfig.identifier} block-on-dynamic")
)
event.cancel()
}
@@ -140,9 +164,9 @@ object PickaxeAbility : FirmamentFeature {
}
} ?: return
val extra = it.item.extraAttributes
- if (!extra.contains("drill_fuel")) return
- val fuel = extra.getInt("drill_fuel")
- val percentage = fuel / maxFuel.toFloat()
+ val fuel = extra.getInt("drill_fuel").getOrNull() ?: return
+ var percentage = fuel / maxFuel.toFloat()
+ if (percentage > 1f) percentage = 1f
it.barOverride = DurabilityBarEvent.DurabilityBar(
lerp(
DyeColor.RED.toShedaniel(),
@@ -156,10 +180,31 @@ object PickaxeAbility : FirmamentFeature {
fun onChatMessage(it: ProcessChatEvent) {
abilityUsePattern.useMatch(it.unformattedString) {
lastUsage[group("name")] = TimeMark.now()
+ abilityOverride = group("name")
}
abilitySwitchPattern.useMatch(it.unformattedString) {
abilityOverride = group("ability")
}
+ pickaxeAbilityCooldownPattern.useMatch(it.unformattedString) {
+ val ability = abilityOverride ?: return@useMatch
+ val remainingCooldown = parseTimePattern(group("remainingCooldown"))
+ val length = defaultAbilityDurations[ability] ?: return@useMatch
+ lastUsage[ability] = TimeMark.ago(length - remainingCooldown)
+ }
+ nowAvailable.useMatch(it.unformattedString) {
+ val ability = group("name")
+ lastUsage[ability] = TimeMark.farPast()
+ if (!TConfig.cooldownReadyToast) return
+ val mc: Minecraft = Minecraft.getInstance()
+ mc.toastManager.addToast(
+ SystemToast.multiline(
+ mc,
+ SystemToast.SystemToastId.NARRATOR_TOGGLE,
+ tr("firmament.pickaxe.ability-ready", "Pickaxe Cooldown"),
+ tr("firmament.pickaxe.ability-ready.desc", "Pickaxe ability is ready!")
+ )
+ )
+ }
}
@Subscribe
@@ -179,6 +224,7 @@ object PickaxeAbility : FirmamentFeature {
val fuelPattern = Pattern.compile("Fuel: .*/(?<maxFuel>$SHORT_NUMBER_FORMAT)")
val pickaxeAbilityCooldownPattern =
Pattern.compile("Your pickaxe ability is on cooldown for (?<remainingCooldown>$TIME_PATTERN)\\.")
+ val nowAvailable = Pattern.compile("(?<name>[a-zA-Z0-9 ]+) is now available!")
data class PickaxeAbilityData(
val name: String,
@@ -200,21 +246,27 @@ object PickaxeAbility : FirmamentFeature {
@Subscribe
fun renderHud(event: HudRenderEvent) {
if (!TConfig.cooldownEnabled) return
+ if (TConfig.disableInDungeons && DungeonUtil.isInDungeonIsland) return
if (!event.isRenderingCursor) return
- var ability = getCooldownFromLore(MC.player?.getStackInHand(Hand.MAIN_HAND) ?: return) ?: return
- defaultAbilityDurations[ability.name] = ability.cooldown
+ 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 ->
+ defaultAbilityDurations[ability.name] = ability.cooldown
+ }
val ao = abilityOverride
- if (ao != ability.name && ao != null) {
- ability = PickaxeAbilityData(ao, defaultAbilityDurations[ao] ?: 120.seconds)
+ if (ability == null || (ao != ability.name && ao != null)) {
+ ability = PickaxeAbilityData(ao ?: return, defaultAbilityDurations[ao] ?: 120.seconds)
}
- event.context.matrices.push()
- event.context.matrices.translate(MC.window.scaledWidth / 2F, MC.window.scaledHeight / 2F, 0F)
- event.context.matrices.scale(TConfig.cooldownScale.toFloat(), TConfig.cooldownScale.toFloat(), 1F)
+ 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
+ 0f, 1f, 0f, 1f,
+ color = TConfig.cooldownColour.getEffectiveColourRGB()
)
- event.context.matrices.pop()
+ event.context.pose().popMatrix()
}
}
diff --git a/src/main/kotlin/features/mining/PristineProfitTracker.kt b/src/main/kotlin/features/mining/PristineProfitTracker.kt
index 377a470..0470702 100644
--- a/src/main/kotlin/features/mining/PristineProfitTracker.kt
+++ b/src/main/kotlin/features/mining/PristineProfitTracker.kt
@@ -1,26 +1,26 @@
package moe.nea.firmament.features.mining
import io.github.notenoughupdates.moulconfig.xml.Bind
-import moe.nea.jarvis.api.Point
+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.features.FirmamentFeature
-import moe.nea.firmament.gui.config.ManagedConfig
import moe.nea.firmament.gui.hud.MoulConfigHud
import moe.nea.firmament.util.BazaarPriceStrategy
import moe.nea.firmament.util.FirmFormatters.formatCommas
import moe.nea.firmament.util.SkyblockId
import moe.nea.firmament.util.StringUtil.parseIntWithComma
+import moe.nea.firmament.util.data.Config
+import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.data.ProfileSpecificDataHolder
import moe.nea.firmament.util.formattedString
import moe.nea.firmament.util.useMatch
-object PristineProfitTracker : FirmamentFeature {
- override val identifier: String
+object PristineProfitTracker {
+ val identifier: String
get() = "pristine-profit"
enum class GemstoneKind(
@@ -50,14 +50,13 @@ object PristineProfitTracker : FirmamentFeature {
var maxCollectionPerSecond: Double = 1.0,
)
+ @Config
object DConfig : ProfileSpecificDataHolder<Data>(serializer(), identifier, ::Data)
- override val config: ManagedConfig?
- get() = TConfig
-
+ @Config
object TConfig : ManagedConfig(identifier, Category.MINING) {
val timeout by duration("timeout", 0.seconds, 120.seconds) { 30.seconds }
- val gui by position("position", 100, 30) { Point(0.05, 0.2) }
+ val gui by position("position", 100, 30) { Vector2i() }
val useFineGemstones by toggle("fine-gemstones") { false }
}
@@ -106,28 +105,26 @@ object PristineProfitTracker : FirmamentFeature {
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
- if (data != null) {
- if (data.maxCollectionPerSecond < collectionPerSecond && collectionHistogram.oldestUpdate()
- .passedTime() > 30.seconds
- ) {
- data.maxCollectionPerSecond = collectionPerSecond
- DConfig.markDirty()
- }
- if (data.maxMoneyPerSecond < moneyPerSecond && moneyHistogram.oldestUpdate().passedTime() > 30.seconds) {
- data.maxMoneyPerSecond = moneyPerSecond
- DConfig.markDirty()
- }
- ProfitHud.collectionMax = maxOf(data.maxCollectionPerSecond, collectionPerSecond)
- ProfitHud.moneyMax = maxOf(data.maxMoneyPerSecond, moneyPerSecond)
+ if (data.maxCollectionPerSecond < collectionPerSecond && collectionHistogram.oldestUpdate()
+ .passedTime() > 30.seconds
+ ) {
+ data.maxCollectionPerSecond = collectionPerSecond
+ DConfig.markDirty()
+ }
+ if (data.maxMoneyPerSecond < moneyPerSecond && moneyHistogram.oldestUpdate().passedTime() > 30.seconds) {
+ data.maxMoneyPerSecond = moneyPerSecond
+ DConfig.markDirty()
}
+ ProfitHud.collectionMax = maxOf(data.maxCollectionPerSecond, collectionPerSecond)
+ ProfitHud.moneyMax = maxOf(data.maxMoneyPerSecond, moneyPerSecond)
}