aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/features
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2025-09-14 19:46:52 +0200
committerLinnea Gräf <nea@nea.moe>2025-09-14 19:46:52 +0200
commit0a96dd618acba15269627c7eae8a2291fb2dc84a (patch)
treef31a66cbd13cefbfb2d006f07d3ef3da1010f7e7 /src/main/kotlin/features
parent9abe9f46f04f188037687adb2740b32220ad21b2 (diff)
downloadFirmament-0a96dd618acba15269627c7eae8a2291fb2dc84a.tar.gz
Firmament-0a96dd618acba15269627c7eae8a2291fb2dc84a.tar.bz2
Firmament-0a96dd618acba15269627c7eae8a2291fb2dc84a.zip
snapshot
Diffstat (limited to 'src/main/kotlin/features')
-rw-r--r--src/main/kotlin/features/FeatureManager.kt107
-rw-r--r--src/main/kotlin/features/FirmamentFeature.kt23
-rw-r--r--src/main/kotlin/features/chat/AutoCompletions.kt13
-rw-r--r--src/main/kotlin/features/chat/ChatLinks.kt11
-rw-r--r--src/main/kotlin/features/chat/CopyChat.kt16
-rw-r--r--src/main/kotlin/features/chat/PartyCommands.kt2
-rw-r--r--src/main/kotlin/features/chat/QuickCommands.kt41
-rw-r--r--src/main/kotlin/features/debug/DebugLogger.kt4
-rw-r--r--src/main/kotlin/features/debug/DebugView.kt29
-rw-r--r--src/main/kotlin/features/debug/DeveloperFeatures.kt13
-rw-r--r--src/main/kotlin/features/debug/MinorTrolling.kt6
-rw-r--r--src/main/kotlin/features/debug/PowerUserTools.kt12
-rw-r--r--src/main/kotlin/features/diana/AncestralSpadeSolver.kt9
-rw-r--r--src/main/kotlin/features/diana/DianaWaypoints.kt38
-rw-r--r--src/main/kotlin/features/diana/NearbyBurrowsSolver.kt7
-rw-r--r--src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt392
-rw-r--r--src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt2
-rw-r--r--src/main/kotlin/features/events/carnival/CarnivalFeatures.kt7
-rw-r--r--src/main/kotlin/features/fixes/CompatibliltyFeatures.kt10
-rw-r--r--src/main/kotlin/features/fixes/Fixes.kt10
-rw-r--r--src/main/kotlin/features/garden/HideComposterNoises.kt2
-rw-r--r--src/main/kotlin/features/inventory/CraftingOverlay.kt5
-rw-r--r--src/main/kotlin/features/inventory/ItemHotkeys.kt3
-rw-r--r--src/main/kotlin/features/inventory/ItemRarityCosmetics.kt16
-rw-r--r--src/main/kotlin/features/inventory/JunkHighlighter.kt7
-rw-r--r--src/main/kotlin/features/inventory/PetFeatures.kt10
-rw-r--r--src/main/kotlin/features/inventory/PriceData.kt9
-rw-r--r--src/main/kotlin/features/inventory/REIDependencyWarner.kt6
-rw-r--r--src/main/kotlin/features/inventory/SaveCursorPosition.kt93
-rw-r--r--src/main/kotlin/features/inventory/SlotLocking.kt16
-rw-r--r--src/main/kotlin/features/inventory/TimerInLore.kt2
-rw-r--r--src/main/kotlin/features/inventory/WardrobeKeybinds.kt3
-rw-r--r--src/main/kotlin/features/inventory/buttons/InventoryButtonTemplates.kt1
-rw-r--r--src/main/kotlin/features/inventory/buttons/InventoryButtons.kt109
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverlay.kt12
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt10
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/VirtualInventory.kt1
-rw-r--r--src/main/kotlin/features/items/BlockZapperOverlay.kt15
-rw-r--r--src/main/kotlin/features/items/BonemerangOverlay.kt16
-rw-r--r--src/main/kotlin/features/items/EtherwarpOverlay.kt10
-rw-r--r--src/main/kotlin/features/macros/ComboProcessor.kt1
-rw-r--r--src/main/kotlin/features/macros/MacroData.kt2
-rw-r--r--src/main/kotlin/features/mining/CommissionFeatures.kt2
-rw-r--r--src/main/kotlin/features/mining/Histogram.kt3
-rw-r--r--src/main/kotlin/features/mining/HotmPresets.kt1
-rw-r--r--src/main/kotlin/features/mining/MiningBlockInfoUi.kt1
-rw-r--r--src/main/kotlin/features/mining/PickaxeAbility.kt10
-rw-r--r--src/main/kotlin/features/mining/PristineProfitTracker.kt36
-rw-r--r--src/main/kotlin/features/misc/CustomCapes.kt20
-rw-r--r--src/main/kotlin/features/misc/Hud.kt19
-rw-r--r--src/main/kotlin/features/misc/ModAnnouncer.kt1
-rw-r--r--src/main/kotlin/features/notifications/Notifications.kt7
-rw-r--r--src/main/kotlin/features/world/FairySouls.kt200
-rw-r--r--src/main/kotlin/features/world/TemporaryWaypoints.kt2
-rw-r--r--src/main/kotlin/features/world/Waypoints.kt70
55 files changed, 592 insertions, 881 deletions
diff --git a/src/main/kotlin/features/FeatureManager.kt b/src/main/kotlin/features/FeatureManager.kt
index 3e235f5..d474d65 100644
--- a/src/main/kotlin/features/FeatureManager.kt
+++ b/src/main/kotlin/features/FeatureManager.kt
@@ -1,102 +1,18 @@
package moe.nea.firmament.features
-import kotlinx.serialization.Serializable
-import kotlinx.serialization.serializer
-import moe.nea.firmament.Firmament
-import moe.nea.firmament.events.FeaturesInitializedEvent
import moe.nea.firmament.events.FirmamentEvent
import moe.nea.firmament.events.subscription.Subscription
import moe.nea.firmament.events.subscription.SubscriptionList
-import moe.nea.firmament.features.chat.AutoCompletions
-import moe.nea.firmament.features.chat.ChatLinks
-import moe.nea.firmament.features.chat.QuickCommands
-import moe.nea.firmament.features.debug.DebugView
-import moe.nea.firmament.features.debug.DeveloperFeatures
-import moe.nea.firmament.features.debug.MinorTrolling
-import moe.nea.firmament.features.debug.PowerUserTools
-import moe.nea.firmament.features.diana.DianaWaypoints
-import moe.nea.firmament.features.events.anniversity.AnniversaryFeatures
-import moe.nea.firmament.features.events.carnival.CarnivalFeatures
-import moe.nea.firmament.features.fixes.CompatibliltyFeatures
-import moe.nea.firmament.features.fixes.Fixes
-import moe.nea.firmament.features.inventory.CraftingOverlay
-import moe.nea.firmament.features.inventory.ItemRarityCosmetics
-import moe.nea.firmament.features.inventory.PetFeatures
-import moe.nea.firmament.features.inventory.PriceData
-import moe.nea.firmament.features.inventory.SaveCursorPosition
-import moe.nea.firmament.features.inventory.SlotLocking
-import moe.nea.firmament.features.inventory.WardrobeKeybinds
-import moe.nea.firmament.features.inventory.buttons.InventoryButtons
-import moe.nea.firmament.features.inventory.storageoverlay.StorageOverlay
-import moe.nea.firmament.features.items.EtherwarpOverlay
-import moe.nea.firmament.features.mining.PickaxeAbility
-import moe.nea.firmament.features.mining.PristineProfitTracker
-import moe.nea.firmament.features.misc.CustomCapes
-import moe.nea.firmament.features.misc.Hud
-import moe.nea.firmament.features.world.FairySouls
-import moe.nea.firmament.features.world.Waypoints
import moe.nea.firmament.util.ErrorUtil
import moe.nea.firmament.util.compatloader.ICompatMeta
-import moe.nea.firmament.util.data.DataHolder
-object FeatureManager : DataHolder<FeatureManager.Config>(serializer(), "features", ::Config) {
- @Serializable
- data class Config(
- val enabledFeatures: MutableMap<String, Boolean> = mutableMapOf()
- )
-
- private val features = mutableMapOf<String, FirmamentFeature>()
-
- val allFeatures: Collection<FirmamentFeature> get() = features.values
-
- private var hasAutoloaded = false
-
- fun autoload() {
- synchronized(this) {
- if (hasAutoloaded) return
- loadFeature(MinorTrolling)
- loadFeature(FairySouls)
- loadFeature(AutoCompletions)
- // TODO: loadFeature(FishingWarning)
- loadFeature(SlotLocking)
- loadFeature(StorageOverlay)
- loadFeature(PristineProfitTracker)
- loadFeature(CraftingOverlay)
- loadFeature(PowerUserTools)
- loadFeature(Waypoints)
- loadFeature(ChatLinks)
- loadFeature(CompatibliltyFeatures)
- loadFeature(AnniversaryFeatures)
- loadFeature(QuickCommands)
- loadFeature(PetFeatures)
- loadFeature(SaveCursorPosition)
- loadFeature(PriceData)
- loadFeature(Fixes)
- loadFeature(CustomCapes)
- loadFeature(Hud)
- loadFeature(EtherwarpOverlay)
- loadFeature(DianaWaypoints)
- loadFeature(ItemRarityCosmetics)
- loadFeature(PickaxeAbility)
- loadFeature(CarnivalFeatures)
- if (Firmament.DEBUG) {
- loadFeature(DeveloperFeatures)
- loadFeature(DebugView)
- }
- allFeatures.forEach { it.config }
- FeaturesInitializedEvent.publish(FeaturesInitializedEvent(allFeatures.toList()))
- hasAutoloaded = true
- }
- }
+object FeatureManager {
fun subscribeEvents() {
SubscriptionList.allLists.forEach { list ->
if (ICompatMeta.shouldLoad(list.javaClass.name))
ErrorUtil.catch("Error while loading events from $list") {
list.provideSubscriptions {
- it.owner.javaClass.classes.forEach {
- runCatching { it.getDeclaredField("INSTANCE").get(null) }
- }
subscribeSingleEvent(it)
}
}
@@ -106,25 +22,4 @@ object FeatureManager : DataHolder<FeatureManager.Config>(serializer(), "feature
private fun <T : FirmamentEvent> subscribeSingleEvent(it: Subscription<T>) {
it.eventBus.subscribe(false, "${it.owner.javaClass.simpleName}:${it.methodName}", it.invoke)
}
-
- fun loadFeature(feature: FirmamentFeature) {
- synchronized(features) {
- if (feature.identifier in features) {
- Firmament.logger.error("Double registering feature ${feature.identifier}. Ignoring second instance $feature")
- return
- }
- features[feature.identifier] = feature
- feature.onLoad()
- }
- }
-
- fun isEnabled(identifier: String): Boolean? =
- data.enabledFeatures[identifier]
-
-
- fun setEnabled(identifier: String, value: Boolean) {
- data.enabledFeatures[identifier] = value
- markDirty()
- }
-
}
diff --git a/src/main/kotlin/features/FirmamentFeature.kt b/src/main/kotlin/features/FirmamentFeature.kt
deleted file mode 100644
index 08e7019..0000000
--- a/src/main/kotlin/features/FirmamentFeature.kt
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-package moe.nea.firmament.features
-
-import moe.nea.firmament.events.subscription.SubscriptionOwner
-import moe.nea.firmament.util.data.ManagedConfig
-
-// TODO: remove this entire feature system and revamp config
-interface FirmamentFeature : SubscriptionOwner {
- val identifier: String
- val defaultEnabled: Boolean
- get() = true
- var isEnabled: Boolean
- get() = FeatureManager.isEnabled(identifier) ?: defaultEnabled
- set(value) {
- FeatureManager.setEnabled(identifier, value)
- }
- override val delegateFeature: FirmamentFeature
- get() = this
- val config: ManagedConfig? get() = null
- fun onLoad() {}
-
-}
diff --git a/src/main/kotlin/features/chat/AutoCompletions.kt b/src/main/kotlin/features/chat/AutoCompletions.kt
index dac1daa..b48069d 100644
--- a/src/main/kotlin/features/chat/AutoCompletions.kt
+++ b/src/main/kotlin/features/chat/AutoCompletions.kt
@@ -8,13 +8,12 @@ import moe.nea.firmament.commands.thenArgument
import moe.nea.firmament.commands.thenExecute
import moe.nea.firmament.events.CommandEvent
import moe.nea.firmament.events.MaskCommands
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.repo.RepoManager
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.data.Config
+import moe.nea.firmament.util.data.ManagedConfig
-object AutoCompletions : FirmamentFeature {
+object AutoCompletions {
@Config
object TConfig : ManagedConfig(identifier, Category.CHAT) {
@@ -22,9 +21,7 @@ object AutoCompletions : FirmamentFeature {
val replaceWarpIsByWarpIsland by toggle("warp-is") { true }
}
- override val config: ManagedConfig?
- get() = TConfig
- override val identifier: String
+ val identifier: String
get() = "auto-completions"
@Subscribe
@@ -46,9 +43,9 @@ object AutoCompletions : FirmamentFeature {
thenExecute {
val warpName = get(toArg)
if (warpName == "is" && TConfig.replaceWarpIsByWarpIsland) {
- MC.sendServerCommand("warp island")
+ MC.sendCommand("warp island")
} else {
- MC.sendServerCommand("warp $warpName")
+ MC.sendCommand("warp $warpName")
}
}
}
diff --git a/src/main/kotlin/features/chat/ChatLinks.kt b/src/main/kotlin/features/chat/ChatLinks.kt
index 6ea07d6..b05a3a0 100644
--- a/src/main/kotlin/features/chat/ChatLinks.kt
+++ b/src/main/kotlin/features/chat/ChatLinks.kt
@@ -7,7 +7,6 @@ import java.net.URI
import java.net.URL
import java.util.Collections
import java.util.concurrent.atomic.AtomicInteger
-import moe.nea.jarvis.api.Point
import org.joml.Vector2i
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -26,17 +25,16 @@ import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ModifyChatEvent
import moe.nea.firmament.events.ScreenRenderPostEvent
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.jarvis.JarvisIntegration
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.render.drawTexture
import moe.nea.firmament.util.transformEachRecursively
import moe.nea.firmament.util.unformattedString
-object ChatLinks : FirmamentFeature {
- override val identifier: String
+object ChatLinks {
+ val identifier: String
get() = "chat-links"
@Config
@@ -54,7 +52,6 @@ object ChatLinks : FirmamentFeature {
private fun isUrlAllowed(url: String) = isHostAllowed(url.removePrefix("https://").substringBefore("/"))
- override val config get() = TConfig
val urlRegex = "https://[^. ]+\\.[^ ]+(\\.?(\\s|$))".toRegex()
val nextTexId = AtomicInteger(0)
@@ -76,7 +73,7 @@ object ChatLinks : FirmamentFeature {
}
imageCache[url] = Firmament.coroutineScope.async {
try {
- val response = Firmament.httpClient.get(URL(url))
+ val response = Firmament.httpClient.get(URI.create(url).toURL())
if (response.status.value == 200) {
val inputStream = response.bodyAsChannel().toInputStream(Firmament.globalJob)
val image = NativeImage.read(inputStream)
diff --git a/src/main/kotlin/features/chat/CopyChat.kt b/src/main/kotlin/features/chat/CopyChat.kt
index 5cd847a..5c46465 100644
--- a/src/main/kotlin/features/chat/CopyChat.kt
+++ b/src/main/kotlin/features/chat/CopyChat.kt
@@ -1,16 +1,13 @@
package moe.nea.firmament.features.chat
import net.minecraft.text.OrderedText
-import moe.nea.firmament.annotations.Subscribe
-import moe.nea.firmament.events.ClientStartedEvent
-import moe.nea.firmament.features.FirmamentFeature
import moe.nea.firmament.util.data.Config
import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.reconstitute
-object CopyChat : FirmamentFeature {
- override val identifier: String
+object CopyChat {
+ val identifier: String
get() = "copy-chat"
@Config
@@ -18,16 +15,7 @@ object CopyChat : FirmamentFeature {
val copyChat by toggle("copy-chat") { false }
}
- @Subscribe
- fun onInit(event: ClientStartedEvent) {
- }
-
- override val config: ManagedConfig?
- get() = TConfig
-
fun orderedTextToString(orderedText: OrderedText): String {
return orderedText.reconstitute().string
}
-
-
}
diff --git a/src/main/kotlin/features/chat/PartyCommands.kt b/src/main/kotlin/features/chat/PartyCommands.kt
index 5a80013..1b34946 100644
--- a/src/main/kotlin/features/chat/PartyCommands.kt
+++ b/src/main/kotlin/features/chat/PartyCommands.kt
@@ -12,11 +12,11 @@ import moe.nea.firmament.commands.thenExecute
import moe.nea.firmament.events.CommandEvent
import moe.nea.firmament.events.PartyMessageReceivedEvent
import moe.nea.firmament.events.ProcessChatEvent
-import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.ErrorUtil
import moe.nea.firmament.util.MC
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.tr
import moe.nea.firmament.util.useMatch
diff --git a/src/main/kotlin/features/chat/QuickCommands.kt b/src/main/kotlin/features/chat/QuickCommands.kt
index 88218b4..5221205 100644
--- a/src/main/kotlin/features/chat/QuickCommands.kt
+++ b/src/main/kotlin/features/chat/QuickCommands.kt
@@ -15,18 +15,19 @@ import moe.nea.firmament.commands.get
import moe.nea.firmament.commands.thenArgument
import moe.nea.firmament.commands.thenExecute
import moe.nea.firmament.events.CommandEvent
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.gui.config.ManagedOption
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.SBData
+import moe.nea.firmament.util.data.Config
+import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.grey
import moe.nea.firmament.util.tr
-object QuickCommands : FirmamentFeature {
- override val identifier: String
+object QuickCommands {
+ val identifier: String
get() = "quick-commands"
+ @Config
object TConfig : ManagedConfig("quick-commands", Category.CHAT) {
val enableJoin by toggle("join") { true }
val enableDh by toggle("dh") { true }
@@ -43,8 +44,12 @@ object QuickCommands : FirmamentFeature {
val dispatcher = CommandDispatcher<FabricClientCommandSource>()
ClientCommandInternals.setActiveDispatcher(dispatcher)
ClientCommandRegistrationCallback.EVENT.invoker()
- .register(dispatcher, CommandRegistryAccess.of(network.combinedDynamicRegistries,
- network.enabledFeatures))
+ .register(
+ dispatcher, CommandRegistryAccess.of(
+ network.combinedDynamicRegistries,
+ network.enabledFeatures
+ )
+ )
ClientCommandInternals.finalizeInit()
network.onCommandTree(lastPacket)
} catch (ex: Exception) {
@@ -100,8 +105,12 @@ object QuickCommands : FirmamentFeature {
if (joinName == null) {
source.sendFeedback(Text.stringifiedTranslatable("firmament.quick-commands.join.unknown", what))
} else {
- source.sendFeedback(Text.stringifiedTranslatable("firmament.quick-commands.join.success",
- joinName))
+ source.sendFeedback(
+ Text.stringifiedTranslatable(
+ "firmament.quick-commands.join.success",
+ joinName
+ )
+ )
MC.sendCommand("joininstance $joinName")
}
}
@@ -122,8 +131,12 @@ object QuickCommands : FirmamentFeature {
)
}
if (l !in kuudraLevelNames.indices) {
- source.sendFeedback(Text.stringifiedTranslatable("firmament.quick-commands.join.unknown-kuudra",
- kuudraLevel))
+ source.sendFeedback(
+ Text.stringifiedTranslatable(
+ "firmament.quick-commands.join.unknown-kuudra",
+ kuudraLevel
+ )
+ )
return null
}
return "KUUDRA_${kuudraLevelNames[l]}"
@@ -143,8 +156,12 @@ object QuickCommands : FirmamentFeature {
return "CATACOMBS_ENTRANCE"
}
if (l !in dungeonLevelNames.indices) {
- source.sendFeedback(Text.stringifiedTranslatable("firmament.quick-commands.join.unknown-catacombs",
- kuudraLevel))
+ source.sendFeedback(
+ Text.stringifiedTranslatable(
+ "firmament.quick-commands.join.unknown-catacombs",
+ kuudraLevel
+ )
+ )
return null
}
return "${if (masterLevel != null) "MASTER_" else ""}CATACOMBS_FLOOR_${dungeonLevelNames[l]}"
diff --git a/src/main/kotlin/features/debug/DebugLogger.kt b/src/main/kotlin/features/debug/DebugLogger.kt
index 9115956..02073b7 100644
--- a/src/main/kotlin/features/debug/DebugLogger.kt
+++ b/src/main/kotlin/features/debug/DebugLogger.kt
@@ -4,6 +4,7 @@ import kotlinx.serialization.serializer
import net.minecraft.text.Text
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.collections.InstanceList
+import moe.nea.firmament.util.data.Config
import moe.nea.firmament.util.data.DataHolder
class DebugLogger(val tag: String) {
@@ -11,13 +12,14 @@ class DebugLogger(val tag: String) {
val allInstances = InstanceList<DebugLogger>("DebugLogger")
}
+ @Config
object EnabledLogs : DataHolder<MutableSet<String>>(serializer(), "DebugLogs", ::mutableSetOf)
init {
allInstances.add(this)
}
- fun isEnabled() = DeveloperFeatures.isEnabled && EnabledLogs.data.contains(tag)
+ fun isEnabled() = EnabledLogs.data.contains(tag)
fun log(text: String) = log { text }
fun log(text: () -> String) {
if (!isEnabled()) return
diff --git a/src/main/kotlin/features/debug/DebugView.kt b/src/main/kotlin/features/debug/DebugView.kt
deleted file mode 100644
index ee54260..0000000
--- a/src/main/kotlin/features/debug/DebugView.kt
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-package moe.nea.firmament.features.debug
-
-import moe.nea.firmament.Firmament
-import moe.nea.firmament.annotations.Subscribe
-import moe.nea.firmament.events.TickEvent
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.TimeMark
-
-object DebugView : FirmamentFeature {
- private data class StoredVariable<T>(
- val obj: T,
- val timer: TimeMark,
- )
-
- private val storedVariables: MutableMap<String, StoredVariable<*>> = sortedMapOf()
- override val identifier: String
- get() = "debug-view"
- override val defaultEnabled: Boolean
- get() = Firmament.DEBUG
-
- fun <T : Any?> showVariable(label: String, obj: T) {
- synchronized(this) {
- storedVariables[label] = StoredVariable(obj, TimeMark.now())
- }
- }
-
-}
diff --git a/src/main/kotlin/features/debug/DeveloperFeatures.kt b/src/main/kotlin/features/debug/DeveloperFeatures.kt
index cb9cf00..e86c6ad 100644
--- a/src/main/kotlin/features/debug/DeveloperFeatures.kt
+++ b/src/main/kotlin/features/debug/DeveloperFeatures.kt
@@ -16,23 +16,18 @@ import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.DebugInstantiateEvent
import moe.nea.firmament.events.TickEvent
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.init.MixinPlugin
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.TimeMark
import moe.nea.firmament.util.asm.AsmAnnotationUtil
import moe.nea.firmament.util.data.Config
+import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.iterate
-object DeveloperFeatures : FirmamentFeature {
+object DeveloperFeatures {
val DEVELOPER_SUBCOMMAND: String = "dev"
- override val identifier: String
+ val identifier: String
get() = "developer"
- override val config: TConfig
- get() = TConfig
- override val defaultEnabled: Boolean
- get() = Firmament.DEBUG
val gradleDir =
Path.of(".").absolute()
@@ -98,7 +93,7 @@ object DeveloperFeatures : FirmamentFeature {
@JvmStatic
fun hookOnBeforeResourceReload(client: MinecraftClient): CompletableFuture<Void> {
- val reloadFuture = if (TConfig.autoRebuildResources && isEnabled && gradleDir != null) {
+ val reloadFuture = if (TConfig.autoRebuildResources && Firmament.DEBUG && gradleDir != null) {
val builder = ProcessBuilder("./gradlew", ":processResources")
builder.directory(gradleDir.toFile())
builder.inheritIO()
diff --git a/src/main/kotlin/features/debug/MinorTrolling.kt b/src/main/kotlin/features/debug/MinorTrolling.kt
index 32035a6..d802d40 100644
--- a/src/main/kotlin/features/debug/MinorTrolling.kt
+++ b/src/main/kotlin/features/debug/MinorTrolling.kt
@@ -5,12 +5,10 @@ package moe.nea.firmament.features.debug
import net.minecraft.text.Text
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ModifyChatEvent
-import moe.nea.firmament.features.FirmamentFeature
-
// In memorian Dulkir
-object MinorTrolling : FirmamentFeature {
- override val identifier: String
+object MinorTrolling {
+ val identifier: String
get() = "minor-trolling"
val trollers = listOf("nea89o", "lrg89")
diff --git a/src/main/kotlin/features/debug/PowerUserTools.kt b/src/main/kotlin/features/debug/PowerUserTools.kt
index 90b73bb..049a0fb 100644
--- a/src/main/kotlin/features/debug/PowerUserTools.kt
+++ b/src/main/kotlin/features/debug/PowerUserTools.kt
@@ -27,13 +27,13 @@ import moe.nea.firmament.events.ItemTooltipEvent
import moe.nea.firmament.events.ScreenChangeEvent
import moe.nea.firmament.events.TickEvent
import moe.nea.firmament.events.WorldKeyboardEvent
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.data.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.data.Config
+import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.focusedItemStack
+import moe.nea.firmament.util.grey
import moe.nea.firmament.util.mc.IntrospectableItemModelManager
import moe.nea.firmament.util.mc.SNbtFormatter
import moe.nea.firmament.util.mc.SNbtFormatter.Companion.toPrettyString
@@ -42,10 +42,9 @@ import moe.nea.firmament.util.mc.iterableArmorItems
import moe.nea.firmament.util.mc.loreAccordingToNbt
import moe.nea.firmament.util.skyBlockId
import moe.nea.firmament.util.tr
-import moe.nea.firmament.util.grey
-object PowerUserTools : FirmamentFeature {
- override val identifier: String
+object PowerUserTools {
+ val identifier: String
get() = "power-user"
@Config
@@ -66,9 +65,6 @@ object PowerUserTools : FirmamentFeature {
val dontHighlightSemicolonItems by toggle("dont-highlight-semicolon-items") { false }
}
- override val config
- get() = TConfig
-
var lastCopiedStack: Pair<ItemStack, Text>? = null
set(value) {
field = value
diff --git a/src/main/kotlin/features/diana/AncestralSpadeSolver.kt b/src/main/kotlin/features/diana/AncestralSpadeSolver.kt
index 48004e8..a2869f0 100644
--- a/src/main/kotlin/features/diana/AncestralSpadeSolver.kt
+++ b/src/main/kotlin/features/diana/AncestralSpadeSolver.kt
@@ -10,19 +10,16 @@ import moe.nea.firmament.events.SoundReceiveEvent
import moe.nea.firmament.events.WorldKeyboardEvent
import moe.nea.firmament.events.WorldReadyEvent
import moe.nea.firmament.events.WorldRenderLastEvent
-import moe.nea.firmament.events.subscription.SubscriptionOwner
-import moe.nea.firmament.features.FirmamentFeature
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.SBData
import moe.nea.firmament.util.SkyBlockIsland
-import moe.nea.firmament.util.SkyblockId
import moe.nea.firmament.util.TimeMark
import moe.nea.firmament.util.WarpUtil
import moe.nea.firmament.util.render.RenderInWorldContext
import moe.nea.firmament.util.skyBlockId
import moe.nea.firmament.util.skyblock.SkyBlockItems
-object AncestralSpadeSolver : SubscriptionOwner {
+object AncestralSpadeSolver {
var lastDing = TimeMark.farPast()
private set
private val pitches = mutableListOf<Float>()
@@ -122,8 +119,4 @@ object AncestralSpadeSolver : SubscriptionOwner {
pitches.clear()
lastDing = TimeMark.farPast()
}
-
- override val delegateFeature: FirmamentFeature
- get() = DianaWaypoints
-
}
diff --git a/src/main/kotlin/features/diana/DianaWaypoints.kt b/src/main/kotlin/features/diana/DianaWaypoints.kt
index 68ee1ea..650e6f9 100644
--- a/src/main/kotlin/features/diana/DianaWaypoints.kt
+++ b/src/main/kotlin/features/diana/DianaWaypoints.kt
@@ -3,31 +3,29 @@ package moe.nea.firmament.features.diana
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.AttackBlockEvent
import moe.nea.firmament.events.UseBlockEvent
-import moe.nea.firmament.features.FirmamentFeature
import moe.nea.firmament.util.data.Config
import moe.nea.firmament.util.data.ManagedConfig
-object DianaWaypoints : FirmamentFeature {
- override val identifier get() = "diana"
- override val config get() = TConfig
+object DianaWaypoints {
+ val identifier get() = "diana"
@Config
- object TConfig : ManagedConfig(identifier, Category.EVENTS) {
- val ancestralSpadeSolver by toggle("ancestral-spade") { true }
- val ancestralSpadeTeleport by keyBindingWithDefaultUnbound("ancestral-teleport")
- val nearbyWaypoints by toggle("nearby-waypoints") { true }
- }
-
-
- @Subscribe
- fun onBlockUse(event: UseBlockEvent) {
- NearbyBurrowsSolver.onBlockClick(event.hitResult.blockPos)
- }
-
- @Subscribe
- fun onBlockAttack(event: AttackBlockEvent) {
- NearbyBurrowsSolver.onBlockClick(event.blockPos)
- }
+ object TConfig : ManagedConfig(identifier, Category.EVENTS) {
+ val ancestralSpadeSolver by toggle("ancestral-spade") { true }
+ val ancestralSpadeTeleport by keyBindingWithDefaultUnbound("ancestral-teleport")
+ val nearbyWaypoints by toggle("nearby-waypoints") { true }
+ }
+
+
+ @Subscribe
+ fun onBlockUse(event: UseBlockEvent) {
+ NearbyBurrowsSolver.onBlockClick(event.hitResult.blockPos)
+ }
+
+ @Subscribe
+ fun onBlockAttack(event: AttackBlockEvent) {
+ NearbyBurrowsSolver.onBlockClick(event.blockPos)
+ }
}
diff --git a/src/main/kotlin/features/diana/NearbyBurrowsSolver.kt b/src/main/kotlin/features/diana/NearbyBurrowsSolver.kt
index 2fb4002..e1fb856 100644
--- a/src/main/kotlin/features/diana/NearbyBurrowsSolver.kt
+++ b/src/main/kotlin/features/diana/NearbyBurrowsSolver.kt
@@ -11,13 +11,11 @@ import moe.nea.firmament.events.ParticleSpawnEvent
import moe.nea.firmament.events.ProcessChatEvent
import moe.nea.firmament.events.WorldReadyEvent
import moe.nea.firmament.events.WorldRenderLastEvent
-import moe.nea.firmament.events.subscription.SubscriptionOwner
-import moe.nea.firmament.features.FirmamentFeature
import moe.nea.firmament.util.TimeMark
import moe.nea.firmament.util.collections.mutableMapWithMaxSize
import moe.nea.firmament.util.render.RenderInWorldContext.Companion.renderInWorld
-object NearbyBurrowsSolver : SubscriptionOwner {
+object NearbyBurrowsSolver {
private val recentlyDugBurrows: MutableMap<BlockPos, TimeMark> = mutableMapWithMaxSize(20)
@@ -134,9 +132,6 @@ object NearbyBurrowsSolver : SubscriptionOwner {
burrows.remove(blockPos)
lastBlockClick = blockPos
}
-
- override val delegateFeature: FirmamentFeature
- get() = DianaWaypoints
}
fun Position.toBlockPos(): BlockPos {
diff --git a/src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt b/src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt
index e26b4c9..80b30ee 100644
--- a/src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt
+++ b/src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt
@@ -1,9 +1,7 @@
-
package moe.nea.firmament.features.events.anniversity
import io.github.notenoughupdates.moulconfig.observer.ObservableList
import io.github.notenoughupdates.moulconfig.xml.Bind
-import moe.nea.jarvis.api.Point
import org.joml.Vector2i
import kotlin.time.Duration.Companion.seconds
import net.minecraft.entity.passive.PigEntity
@@ -13,8 +11,6 @@ import moe.nea.firmament.events.EntityInteractionEvent
import moe.nea.firmament.events.ProcessChatEvent
import moe.nea.firmament.events.TickEvent
import moe.nea.firmament.events.WorldReadyEvent
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.gui.hud.MoulConfigHud
import moe.nea.firmament.repo.ExpensiveItemCacheApi
import moe.nea.firmament.repo.ItemNameLookup
@@ -24,206 +20,204 @@ import moe.nea.firmament.util.SHORT_NUMBER_FORMAT
import moe.nea.firmament.util.SkyblockId
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.parseShortNumber
import moe.nea.firmament.util.useMatch
-object AnniversaryFeatures : FirmamentFeature {
- override val identifier: String
- get() = "anniversary"
+object AnniversaryFeatures {
+ val identifier: String
+ get() = "anniversary"
@Config
- object TConfig : ManagedConfig(identifier, Category.EVENTS) {
- val enableShinyPigTracker by toggle("shiny-pigs") {true}
- val trackPigCooldown by position("pig-hud", 200, 300) { Vector2i(100, 200) }
- }
-
- override val config: ManagedConfig?
- get() = TConfig
-
- data class ClickedPig(
- val clickedAt: TimeMark,
- val startLocation: BlockPos,
- val pigEntity: PigEntity
- ) {
- @Bind("timeLeft")
- fun getTimeLeft(): Double = 1 - clickedAt.passedTime() / pigDuration
- }
-
- val clickedPigs = ObservableList<ClickedPig>(mutableListOf())
- var lastClickedPig: PigEntity? = null
-
- val pigDuration = 90.seconds
-
- @Subscribe
- fun onTick(event: TickEvent) {
- clickedPigs.removeIf { it.clickedAt.passedTime() > pigDuration }
- }
-
- val pattern = "SHINY! You extracted (?<reward>.*) from the piglet's orb!".toPattern()
-
- @Subscribe
- fun onChat(event: ProcessChatEvent) {
- if(!TConfig.enableShinyPigTracker)return
- if (event.unformattedString == "Oink! Bring the pig back to the Shiny Orb!") {
- val pig = lastClickedPig ?: return
- // TODO: store proper location based on the orb location, maybe
- val startLocation = pig.blockPos ?: return
- clickedPigs.add(ClickedPig(TimeMark.now(), startLocation, pig))
- lastClickedPig = null
- }
- if (event.unformattedString == "SHINY! The orb is charged! Click on it for loot!") {
- val player = MC.player ?: return
- val lowest =
- clickedPigs.minByOrNull { it.startLocation.getSquaredDistance(player.pos) } ?: return
- clickedPigs.remove(lowest)
- }
- pattern.useMatch(event.unformattedString) {
- val reward = group("reward")
- val parsedReward = parseReward(reward)
- addReward(parsedReward)
- PigCooldown.rewards.atOnce {
- PigCooldown.rewards.clear()
- rewards.mapTo(PigCooldown.rewards) { PigCooldown.DisplayReward(it) }
- }
- }
- }
-
- fun addReward(reward: Reward) {
- val it = rewards.listIterator()
- while (it.hasNext()) {
- val merged = reward.mergeWith(it.next()) ?: continue
- it.set(merged)
- return
- }
- rewards.add(reward)
- }
-
- val rewards = mutableListOf<Reward>()
-
- fun <T> ObservableList<T>.atOnce(block: () -> Unit) {
- val oldObserver = observer
- observer = null
- block()
- observer = oldObserver
- update()
- }
-
- sealed interface Reward {
- fun mergeWith(other: Reward): Reward?
- data class EXP(val amount: Double, val skill: String) : Reward {
- override fun mergeWith(other: Reward): Reward? {
- if (other is EXP && other.skill == skill)
- return EXP(amount + other.amount, skill)
- return null
- }
- }
-
- data class Coins(val amount: Double) : Reward {
- override fun mergeWith(other: Reward): Reward? {
- if (other is Coins)
- return Coins(other.amount + amount)
- return null
- }
- }
-
- data class Items(val amount: Int, val item: SkyblockId) : Reward {
- override fun mergeWith(other: Reward): Reward? {
- if (other is Items && other.item == item)
- return Items(amount + other.amount, item)
- return null
- }
- }
-
- data class Unknown(val text: String) : Reward {
- override fun mergeWith(other: Reward): Reward? {
- return null
- }
- }
- }
-
- val expReward = "\\+(?<exp>$SHORT_NUMBER_FORMAT) (?<kind>[^ ]+) XP".toPattern()
- val coinReward = "(?i)\\+(?<amount>$SHORT_NUMBER_FORMAT) Coins".toPattern()
- val itemReward = "(?:(?<amount>[0-9]+)x )?(?<name>.*)".toPattern()
- fun parseReward(string: String): Reward {
- expReward.useMatch<Unit>(string) {
- val exp = parseShortNumber(group("exp"))
- val kind = group("kind")
- return Reward.EXP(exp, kind)
- }
- coinReward.useMatch<Unit>(string) {
- val coins = parseShortNumber(group("amount"))
- return Reward.Coins(coins)
- }
- itemReward.useMatch(string) {
- val amount = group("amount")?.toIntOrNull() ?: 1
- val name = group("name")
- val item = ItemNameLookup.guessItemByName(name, false) ?: return@useMatch
- return Reward.Items(amount, item)
- }
- return Reward.Unknown(string)
- }
-
- @Subscribe
- fun onWorldClear(event: WorldReadyEvent) {
- lastClickedPig = null
- clickedPigs.clear()
- }
-
- @Subscribe
- fun onEntityClick(event: EntityInteractionEvent) {
- if (event.entity is PigEntity) {
- lastClickedPig = event.entity
- }
- }
-
- @Subscribe
- fun init(event: WorldReadyEvent) {
- PigCooldown.forceInit()
- }
-
- object PigCooldown : MoulConfigHud("anniversary_pig", TConfig.trackPigCooldown) {
- override fun shouldRender(): Boolean {
- return clickedPigs.isNotEmpty() && TConfig.enableShinyPigTracker
- }
-
- @Bind("pigs")
- fun getPigs() = clickedPigs
-
- class DisplayReward(val backedBy: Reward) {
- @Bind
- fun count(): String {
- return when (backedBy) {
- is Reward.Coins -> backedBy.amount
- is Reward.EXP -> backedBy.amount
- is Reward.Items -> backedBy.amount
- is Reward.Unknown -> 0
- }.toString()
- }
-
- val itemStack = if (backedBy is Reward.Items) {
- SBItemStack(backedBy.item, backedBy.amount)
- } else {
- SBItemStack(SkyblockId.NULL)
- }
-
- @OptIn(ExpensiveItemCacheApi::class)
+ object TConfig : ManagedConfig(identifier, Category.EVENTS) {
+ val enableShinyPigTracker by toggle("shiny-pigs") { true }
+ val trackPigCooldown by position("pig-hud", 200, 300) { Vector2i(100, 200) }
+ }
+
+ data class ClickedPig(
+ val clickedAt: TimeMark,
+ val startLocation: BlockPos,
+ val pigEntity: PigEntity
+ ) {
+ @Bind("timeLeft")
+ fun getTimeLeft(): Double = 1 - clickedAt.passedTime() / pigDuration
+ }
+
+ val clickedPigs = ObservableList<ClickedPig>(mutableListOf())
+ var lastClickedPig: PigEntity? = null
+
+ val pigDuration = 90.seconds
+
+ @Subscribe
+ fun onTick(event: TickEvent) {
+ clickedPigs.removeIf { it.clickedAt.passedTime() > pigDuration }
+ }
+
+ val pattern = "SHINY! You extracted (?<reward>.*) from the piglet's orb!".toPattern()
+
+ @Subscribe
+ fun onChat(event: ProcessChatEvent) {
+ if (!TConfig.enableShinyPigTracker) return
+ if (event.unformattedString == "Oink! Bring the pig back to the Shiny Orb!") {
+ val pig = lastClickedPig ?: return
+ // TODO: store proper location based on the orb location, maybe
+ val startLocation = pig.blockPos ?: return
+ clickedPigs.add(ClickedPig(TimeMark.now(), startLocation, pig))
+ lastClickedPig = null
+ }
+ if (event.unformattedString == "SHINY! The orb is charged! Click on it for loot!") {
+ val player = MC.player ?: return
+ val lowest =
+ clickedPigs.minByOrNull { it.startLocation.getSquaredDistance(player.pos) } ?: return
+ clickedPigs.remove(lowest)
+ }
+ pattern.useMatch(event.unformattedString) {
+ val reward = group("reward")
+ val parsedReward = parseReward(reward)
+ addReward(parsedReward)
+ PigCooldown.rewards.atOnce {
+ PigCooldown.rewards.clear()
+ rewards.mapTo(PigCooldown.rewards) { PigCooldown.DisplayReward(it) }
+ }
+ }
+ }
+
+ fun addReward(reward: Reward) {
+ val it = rewards.listIterator()
+ while (it.hasNext()) {
+ val merged = reward.mergeWith(it.next()) ?: continue
+ it.set(merged)
+ return
+ }
+ rewards.add(reward)
+ }
+
+ val rewards = mutableListOf<Reward>()
+
+ fun <T> ObservableList<T>.atOnce(block: () -> Unit) {
+ val oldObserver = observer
+ observer = null
+ block()
+ observer = oldObserver
+ update()
+ }
+
+ sealed interface Reward {
+ fun mergeWith(other: Reward): Reward?
+ data class EXP(val amount: Double, val skill: String) : Reward {
+ override fun mergeWith(other: Reward): Reward? {
+ if (other is EXP && other.skill == skill)
+ return EXP(amount + other.amount, skill)
+ return null
+ }
+ }
+
+ data class Coins(val amount: Double) : Reward {
+ override fun mergeWith(other: Reward): Reward? {
+ if (other is Coins)
+ return Coins(other.amount + amount)
+ return null
+ }
+ }
+
+ data class Items(val amount: Int, val item: SkyblockId) : Reward {
+ override fun mergeWith(other: Reward): Reward? {
+ if (other is Items && other.item == item)
+ return Items(amount + other.amount, item)
+ return null
+ }
+ }
+
+ data class Unknown(val text: String) : Reward {
+ override fun mergeWith(other: Reward): Reward? {
+ return null
+ }
+ }
+ }
+
+ val expReward = "\\+(?<exp>$SHORT_NUMBER_FORMAT) (?<kind>[^ ]+) XP".toPattern()
+ val coinReward = "(?i)\\+(?<amount>$SHORT_NUMBER_FORMAT) Coins".toPattern()
+ val itemReward = "(?:(?<amount>[0-9]+)x )?(?<name>.*)".toPattern()
+ fun parseReward(string: String): Reward {
+ expReward.useMatch<Unit>(string) {
+ val exp = parseShortNumber(group("exp"))
+ val kind = group("kind")
+ return Reward.EXP(exp, kind)
+ }
+ coinReward.useMatch<Unit>(string) {
+ val coins = parseShortNumber(group("amount"))
+ return Reward.Coins(coins)
+ }
+ itemReward.useMatch(string) {
+ val amount = group("amount")?.toIntOrNull() ?: 1
+ val name = group("name")
+ val item = ItemNameLookup.guessItemByName(name, false) ?: return@useMatch
+ return Reward.Items(amount, item)
+ }
+ return Reward.Unknown(string)
+ }
+
+ @Subscribe
+ fun onWorldClear(event: WorldReadyEvent) {
+ lastClickedPig = null
+ clickedPigs.clear()
+ }
+
+ @Subscribe
+ fun onEntityClick(event: EntityInteractionEvent) {
+ if (event.entity is PigEntity) {
+ lastClickedPig = event.entity
+ }
+ }
+
+ @Subscribe
+ fun init(event: WorldReadyEvent) {
+ PigCooldown.forceInit()
+ }
+
+ object PigCooldown : MoulConfigHud("anniversary_pig", TConfig.trackPigCooldown) {
+ override fun shouldRender(): Boolean {
+ return clickedPigs.isNotEmpty() && TConfig.enableShinyPigTracker
+ }
+
+ @Bind("pigs")
+ fun getPigs() = clickedPigs
+
+ class DisplayReward(val backedBy: Reward) {
+ @Bind
+ fun count(): String {
+ return when (backedBy) {
+ is Reward.Coins -> backedBy.amount
+ is Reward.EXP -> backedBy.amount
+ is Reward.Items -> backedBy.amount
+ is Reward.Unknown -> 0
+ }.toString()
+ }
+
+ val itemStack = if (backedBy is Reward.Items) {
+ SBItemStack(backedBy.item, backedBy.amount)
+ } else {
+ SBItemStack(SkyblockId.NULL)
+ }
+
+ @OptIn(ExpensiveItemCacheApi::class)
@Bind
- fun name(): String {
- return when (backedBy) {
- is Reward.Coins -> "Coins"
- is Reward.EXP -> backedBy.skill
- is Reward.Items -> itemStack.asImmutableItemStack().name.string
- is Reward.Unknown -> backedBy.text
- }
- }
-
- @Bind
- fun isKnown() = backedBy !is Reward.Unknown
- }
-
- @get:Bind("rewards")
- val rewards = ObservableList<DisplayReward>(mutableListOf())
-
- }
+ fun name(): String {
+ return when (backedBy) {
+ is Reward.Coins -> "Coins"
+ is Reward.EXP -> backedBy.skill
+ is Reward.Items -> itemStack.asImmutableItemStack().name.string
+ is Reward.Unknown -> backedBy.text
+ }
+ }
+
+ @Bind
+ fun isKnown() = backedBy !is Reward.Unknown
+ }
+
+ @get:Bind("rewards")
+ val rewards = ObservableList<DisplayReward>(mutableListOf())
+
+ }
}
diff --git a/src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt b/src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt
index 9eb098a..13ecd7b 100644
--- a/src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt
+++ b/src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt
@@ -8,10 +8,10 @@ import net.minecraft.text.Style
import net.minecraft.util.Formatting
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.EntityRenderTintEvent
-import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.SkyblockId
import moe.nea.firmament.util.data.Config
+import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.render.TintedOverlayTexture
import moe.nea.firmament.util.skyBlockId
import moe.nea.firmament.util.skyblock.SkyBlockItems
diff --git a/src/main/kotlin/features/events/carnival/CarnivalFeatures.kt b/src/main/kotlin/features/events/carnival/CarnivalFeatures.kt
index 877b54b..3f149ff 100644
--- a/src/main/kotlin/features/events/carnival/CarnivalFeatures.kt
+++ b/src/main/kotlin/features/events/carnival/CarnivalFeatures.kt
@@ -1,19 +1,16 @@
package moe.nea.firmament.features.events.carnival
-import moe.nea.firmament.features.FirmamentFeature
import moe.nea.firmament.util.data.Config
import moe.nea.firmament.util.data.ManagedConfig
-object CarnivalFeatures : FirmamentFeature {
+object CarnivalFeatures {
@Config
object TConfig : ManagedConfig(identifier, Category.EVENTS) {
val enableBombSolver by toggle("bombs-solver") { true }
val displayTutorials by toggle("tutorials") { true }
}
- override val config: ManagedConfig?
- get() = TConfig
- override val identifier: String
+ val identifier: String
get() = "carnival"
}
diff --git a/src/main/kotlin/features/fixes/CompatibliltyFeatures.kt b/src/main/kotlin/features/fixes/CompatibliltyFeatures.kt
index 1858e87..55592c5 100644
--- a/src/main/kotlin/features/fixes/CompatibliltyFeatures.kt
+++ b/src/main/kotlin/features/fixes/CompatibliltyFeatures.kt
@@ -4,13 +4,12 @@ import net.minecraft.particle.ParticleTypes
import net.minecraft.util.math.Vec3d
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ParticleSpawnEvent
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.compatloader.CompatLoader
import moe.nea.firmament.util.data.Config
+import moe.nea.firmament.util.data.ManagedConfig
-object CompatibliltyFeatures : FirmamentFeature {
- override val identifier: String
+object CompatibliltyFeatures {
+ val identifier: String
get() = "compatibility"
@Config
@@ -19,9 +18,6 @@ object CompatibliltyFeatures : FirmamentFeature {
val explosionSize by integer("explosion-power", 10, 50) { 1 }
}
- override val config: ManagedConfig?
- get() = TConfig
-
interface ExplosiveApiWrapper {
fun spawnParticle(vec3d: Vec3d, power: Float)
diff --git a/src/main/kotlin/features/fixes/Fixes.kt b/src/main/kotlin/features/fixes/Fixes.kt
index d3876a7..e7027ac 100644
--- a/src/main/kotlin/features/fixes/Fixes.kt
+++ b/src/main/kotlin/features/fixes/Fixes.kt
@@ -8,14 +8,13 @@ import net.minecraft.text.Text
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HudRenderEvent
import moe.nea.firmament.events.WorldKeyboardEvent
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.data.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.tr
-object Fixes : FirmamentFeature {
- override val identifier: String
+object Fixes {
+ val identifier: String
get() = "fixes"
@Config
@@ -34,9 +33,6 @@ object Fixes : FirmamentFeature {
val hideOffHand by toggle("hide-off-hand") { false }
}
- override val config: ManagedConfig
- get() = TConfig
-
fun handleIsPressed(
keyBinding: KeyBinding,
cir: CallbackInfoReturnable<Boolean>
diff --git a/src/main/kotlin/features/garden/HideComposterNoises.kt b/src/main/kotlin/features/garden/HideComposterNoises.kt
index 2e8eb76..843e4f9 100644
--- a/src/main/kotlin/features/garden/HideComposterNoises.kt
+++ b/src/main/kotlin/features/garden/HideComposterNoises.kt
@@ -5,10 +5,10 @@ import net.minecraft.sound.SoundEvent
import net.minecraft.sound.SoundEvents
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.SoundReceiveEvent
-import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.SBData
import moe.nea.firmament.util.SkyBlockIsland
import moe.nea.firmament.util.data.Config
+import moe.nea.firmament.util.data.ManagedConfig
object HideComposterNoises {
@Config
diff --git a/src/main/kotlin/features/inventory/CraftingOverlay.kt b/src/main/kotlin/features/inventory/CraftingOverlay.kt
index f823086..30d2c6b 100644
--- a/src/main/kotlin/features/inventory/CraftingOverlay.kt
+++ b/src/main/kotlin/features/inventory/CraftingOverlay.kt
@@ -7,13 +7,12 @@ import net.minecraft.util.Formatting
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ScreenChangeEvent
import moe.nea.firmament.events.SlotRenderEvents
-import moe.nea.firmament.features.FirmamentFeature
import moe.nea.firmament.repo.ExpensiveItemCacheApi
import moe.nea.firmament.repo.SBItemStack
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.skyblockId
-object CraftingOverlay : FirmamentFeature {
+object CraftingOverlay {
private var screen: GenericContainerScreen? = null
private var recipe: NEUCraftingRecipe? = null
@@ -43,7 +42,7 @@ object CraftingOverlay : FirmamentFeature {
}
}
- override val identifier: String
+ val identifier: String
get() = "crafting-overlay"
@OptIn(ExpensiveItemCacheApi::class)
diff --git a/src/main/kotlin/features/inventory/ItemHotkeys.kt b/src/main/kotlin/features/inventory/ItemHotkeys.kt
index c6b5ca6..e9d0631 100644
--- a/src/main/kotlin/features/inventory/ItemHotkeys.kt
+++ b/src/main/kotlin/features/inventory/ItemHotkeys.kt
@@ -2,16 +2,15 @@ package moe.nea.firmament.features.inventory
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HandledScreenKeyPressedEvent
-import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.repo.ExpensiveItemCacheApi
import moe.nea.firmament.repo.HypixelStaticData
-import moe.nea.firmament.repo.ItemCache
import moe.nea.firmament.repo.ItemCache.asItemStack
import moe.nea.firmament.repo.ItemCache.isBroken
import moe.nea.firmament.repo.RepoManager
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.asBazaarStock
import moe.nea.firmament.util.data.Config
+import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.focusedItemStack
import moe.nea.firmament.util.skyBlockId
import moe.nea.firmament.util.skyblock.SBItemUtil.getSearchName
diff --git a/src/main/kotlin/features/inventory/ItemRarityCosmetics.kt b/src/main/kotlin/features/inventory/ItemRarityCosmetics.kt
index 196f948..7a474f9 100644
--- a/src/main/kotlin/features/inventory/ItemRarityCosmetics.kt
+++ b/src/main/kotlin/features/inventory/ItemRarityCosmetics.kt
@@ -3,24 +3,17 @@ package moe.nea.firmament.features.inventory
import java.awt.Color
import net.minecraft.client.gl.RenderPipelines
import net.minecraft.client.gui.DrawContext
-import net.minecraft.client.render.RenderLayer
import net.minecraft.item.ItemStack
-import net.minecraft.util.Formatting
import net.minecraft.util.Identifier
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HotbarItemRenderEvent
import moe.nea.firmament.events.SlotRenderEvents
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.data.ManagedConfig
-import moe.nea.firmament.util.collections.lastNotNullOfOrNull
-import moe.nea.firmament.util.collections.memoizeIdentity
import moe.nea.firmament.util.data.Config
-import moe.nea.firmament.util.mc.loreAccordingToNbt
+import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.skyblock.Rarity
-import moe.nea.firmament.util.unformattedString
-object ItemRarityCosmetics : FirmamentFeature {
- override val identifier: String
+object ItemRarityCosmetics {
+ val identifier: String
get() = "item-rarity-cosmetics"
@Config
@@ -29,9 +22,6 @@ object ItemRarityCosmetics : FirmamentFeature {
val showItemRarityInHotbar by toggle("background-hotbar") { false }
}
- override val config: ManagedConfig
- get() = TConfig
-
private val rarityToColor = Rarity.colourMap.mapValues {
val c = Color(it.value.colorValue!!)
c.rgb
diff --git a/src/main/kotlin/features/inventory/JunkHighlighter.kt b/src/main/kotlin/features/inventory/JunkHighlighter.kt
index e5ab036..45d265e 100644
--- a/src/main/kotlin/features/inventory/JunkHighlighter.kt
+++ b/src/main/kotlin/features/inventory/JunkHighlighter.kt
@@ -3,14 +3,13 @@ package moe.nea.firmament.features.inventory
import org.lwjgl.glfw.GLFW
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.SlotRenderEvents
-import moe.nea.firmament.features.FirmamentFeature
import moe.nea.firmament.util.data.Config
import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.skyblock.SBItemUtil.getSearchName
import moe.nea.firmament.util.useMatch
-object JunkHighlighter : FirmamentFeature {
- override val identifier: String
+object JunkHighlighter {
+ val identifier: String
get() = "junk-highlighter"
@Config
@@ -21,7 +20,7 @@ object JunkHighlighter : FirmamentFeature {
@Subscribe
fun onDrawSlot(event: SlotRenderEvents.After) {
- if(!TConfig.highlightBind.isPressed() || TConfig.junkRegex.isEmpty()) return
+ if (!TConfig.highlightBind.isPressed() || TConfig.junkRegex.isEmpty()) return
val junkRegex = TConfig.junkRegex.toPattern()
val slot = event.slot
junkRegex.useMatch(slot.stack.getSearchName()) {
diff --git a/src/main/kotlin/features/inventory/PetFeatures.kt b/src/main/kotlin/features/inventory/PetFeatures.kt
index 5df4bc4..965e705 100644
--- a/src/main/kotlin/features/inventory/PetFeatures.kt
+++ b/src/main/kotlin/features/inventory/PetFeatures.kt
@@ -8,14 +8,13 @@ import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HudRenderEvent
import moe.nea.firmament.events.SlotRenderEvents
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.jarvis.JarvisIntegration
import moe.nea.firmament.util.FirmFormatters.formatPercent
import moe.nea.firmament.util.FirmFormatters.shortFormat
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.SBData
import moe.nea.firmament.util.data.Config
+import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.petData
import moe.nea.firmament.util.render.drawGuiTexture
import moe.nea.firmament.util.skyblock.Rarity
@@ -23,13 +22,10 @@ import moe.nea.firmament.util.titleCase
import moe.nea.firmament.util.useMatch
import moe.nea.firmament.util.withColor
-object PetFeatures : FirmamentFeature {
- override val identifier: String
+object PetFeatures {
+ val identifier: String
get() = "pets"
- override val config: ManagedConfig?
- get() = TConfig
-
@Config
object TConfig : ManagedConfig(identifier, Category.INVENTORY) {
val highlightEquippedPet by toggle("highlight-pet") { true }
diff --git a/src/main/kotlin/features/inventory/PriceData.kt b/src/main/kotlin/features/inventory/PriceData.kt
index ce5c7ea..5f9268e 100644
--- a/src/main/kotlin/features/inventory/PriceData.kt
+++ b/src/main/kotlin/features/inventory/PriceData.kt
@@ -5,22 +5,21 @@ import net.minecraft.text.Text
import net.minecraft.util.StringIdentifiable
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ItemTooltipEvent
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.repo.HypixelStaticData
import moe.nea.firmament.util.FirmFormatters.formatCommas
import moe.nea.firmament.util.asBazaarStock
import moe.nea.firmament.util.bold
import moe.nea.firmament.util.darkGrey
import moe.nea.firmament.util.data.Config
+import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.getLogicalStackSize
import moe.nea.firmament.util.gold
import moe.nea.firmament.util.skyBlockId
import moe.nea.firmament.util.tr
import moe.nea.firmament.util.yellow
-object PriceData : FirmamentFeature {
- override val identifier: String
+object PriceData {
+ val identifier: String
get() = "price-data"
@Config
@@ -46,8 +45,6 @@ object PriceData : FirmamentFeature {
}
}
- override val config get() = TConfig
-
fun formatPrice(label: Text, price: Double): Text {
return Text.literal("")
.yellow()
diff --git a/src/main/kotlin/features/inventory/REIDependencyWarner.kt b/src/main/kotlin/features/inventory/REIDependencyWarner.kt
index 4bb93ee..9e8a4db 100644
--- a/src/main/kotlin/features/inventory/REIDependencyWarner.kt
+++ b/src/main/kotlin/features/inventory/REIDependencyWarner.kt
@@ -52,7 +52,7 @@ object REIDependencyWarner {
@Subscribe
fun checkREIDependency(event: SkyblockServerUpdateEvent) {
if (!SBData.isOnSkyblock) return
- if (!RepoManager.Config.warnForMissingItemListMod) return
+ if (!RepoManager.TConfig.warnForMissingItemListMod) return
if (hasREI) return
if (sentWarning) return
sentWarning = true
@@ -76,8 +76,8 @@ object REIDependencyWarner {
if (hasREI) return
event.subcommand("disablereiwarning") {
thenExecute {
- RepoManager.Config.warnForMissingItemListMod = false
- RepoManager.Config.markDirty()
+ RepoManager.TConfig.warnForMissingItemListMod = false
+ RepoManager.TConfig.markDirty()
MC.sendChat(Text.translatable("firmament.reiwarning.disabled").yellow())
}
}
diff --git a/src/main/kotlin/features/inventory/SaveCursorPosition.kt b/src/main/kotlin/features/inventory/SaveCursorPosition.kt
index 2a08730..3e55d02 100644
--- a/src/main/kotlin/features/inventory/SaveCursorPosition.kt
+++ b/src/main/kotlin/features/inventory/SaveCursorPosition.kt
@@ -1,64 +1,57 @@
-
-
package moe.nea.firmament.features.inventory
import org.lwjgl.glfw.GLFW
import kotlin.math.absoluteValue
import kotlin.time.Duration.Companion.milliseconds
-import net.minecraft.client.util.InputUtil
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.TimeMark
import moe.nea.firmament.util.assertNotNullOr
import moe.nea.firmament.util.data.Config
+import moe.nea.firmament.util.data.ManagedConfig
-object SaveCursorPosition : FirmamentFeature {
- override val identifier: String
- get() = "save-cursor-position"
+object SaveCursorPosition {
+ val identifier: String
+ get() = "save-cursor-position"
@Config
- object TConfig : ManagedConfig(identifier, Category.INVENTORY) {
- val enable by toggle("enable") { true }
- val tolerance by duration("tolerance", 10.milliseconds, 5000.milliseconds) { 500.milliseconds }
- }
-
- override val config: TConfig
- get() = TConfig
-
- var savedPositionedP1: Pair<Double, Double>? = null
- var savedPosition: SavedPosition? = null
-
- data class SavedPosition(
- val middle: Pair<Double, Double>,
- val cursor: Pair<Double, Double>,
- val savedAt: TimeMark = TimeMark.now()
- )
-
- @JvmStatic
- fun saveCursorOriginal(positionedX: Double, positionedY: Double) {
- savedPositionedP1 = Pair(positionedX, positionedY)
- }
-
- @JvmStatic
- fun loadCursor(middleX: Double, middleY: Double): Pair<Double, Double>? {
- if (!TConfig.enable) return null
- val lastPosition = savedPosition?.takeIf { it.savedAt.passedTime() < TConfig.tolerance }
- savedPosition = null
- if (lastPosition != null &&
- (lastPosition.middle.first - middleX).absoluteValue < 1 &&
- (lastPosition.middle.second - middleY).absoluteValue < 1
- ) {
+ object TConfig : ManagedConfig(identifier, Category.INVENTORY) {
+ val enable by toggle("enable") { true }
+ val tolerance by duration("tolerance", 10.milliseconds, 5000.milliseconds) { 500.milliseconds }
+ }
+
+ var savedPositionedP1: Pair<Double, Double>? = null
+ var savedPosition: SavedPosition? = null
+
+ data class SavedPosition(
+ val middle: Pair<Double, Double>,
+ val cursor: Pair<Double, Double>,
+ val savedAt: TimeMark = TimeMark.now()
+ )
+
+ @JvmStatic
+ fun saveCursorOriginal(positionedX: Double, positionedY: Double) {
+ savedPositionedP1 = Pair(positionedX, positionedY)
+ }
+
+ @JvmStatic
+ fun loadCursor(middleX: Double, middleY: Double): Pair<Double, Double>? {
+ if (!TConfig.enable) return null
+ val lastPosition = savedPosition?.takeIf { it.savedAt.passedTime() < TConfig.tolerance }
+ savedPosition = null
+ if (lastPosition != null &&
+ (lastPosition.middle.first - middleX).absoluteValue < 1 &&
+ (lastPosition.middle.second - middleY).absoluteValue < 1
+ ) {
GLFW.glfwSetCursorPos(MC.window.handle, lastPosition.cursor.first, lastPosition.cursor.second);
- return lastPosition.cursor
- }
- return null
- }
-
- @JvmStatic
- fun saveCursorMiddle(middleX: Double, middleY: Double) {
- if (!TConfig.enable) return
- val cursorPos = assertNotNullOr(savedPositionedP1) { return }
- savedPosition = SavedPosition(Pair(middleX, middleY), cursorPos)
- }
+ return lastPosition.cursor
+ }
+ return null
+ }
+
+ @JvmStatic
+ fun saveCursorMiddle(middleX: Double, middleY: Double) {
+ if (!TConfig.enable) return
+ val cursorPos = assertNotNullOr(savedPositionedP1) { return }
+ savedPosition = SavedPosition(Pair(middleX, middleY), cursorPos)
+ }
}
diff --git a/src/main/kotlin/features/inventory/SlotLocking.kt b/src/main/kotlin/features/inventory/SlotLocking.kt
index 8be7bdb..bae6a5e 100644
--- a/src/main/kotlin/features/inventory/SlotLocking.kt
+++ b/src/main/kotlin/features/inventory/SlotLocking.kt
@@ -26,15 +26,13 @@ import net.minecraft.screen.slot.SlotActionType
import net.minecraft.util.Identifier
import net.minecraft.util.StringIdentifiable
import moe.nea.firmament.annotations.Subscribe
-import moe.nea.firmament.events.FeaturesInitializedEvent
+import moe.nea.firmament.events.ClientInitEvent
import moe.nea.firmament.events.HandledScreenForegroundEvent
import moe.nea.firmament.events.HandledScreenKeyPressedEvent
import moe.nea.firmament.events.HandledScreenKeyReleasedEvent
import moe.nea.firmament.events.IsSlotProtectedEvent
import moe.nea.firmament.events.ScreenChangeEvent
import moe.nea.firmament.events.SlotRenderEvents
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.keybindings.InputModifiers
import moe.nea.firmament.keybindings.SavedKeyBinding
import moe.nea.firmament.mixins.accessor.AccessorHandledScreen
@@ -43,6 +41,7 @@ import moe.nea.firmament.util.MC
import moe.nea.firmament.util.SBData
import moe.nea.firmament.util.SkyBlockIsland
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.extraAttributes
import moe.nea.firmament.util.json.DashlessUUIDSerializer
@@ -60,8 +59,8 @@ import moe.nea.firmament.util.skyblockUUID
import moe.nea.firmament.util.tr
import moe.nea.firmament.util.unformattedString
-object SlotLocking : FirmamentFeature {
- override val identifier: String
+object SlotLocking {
+ val identifier: String
get() = "slot-locking"
@Serializable
@@ -166,15 +165,14 @@ object SlotLocking : FirmamentFeature {
}
}
- override val config: TConfig
- get() = TConfig
-
+ @Config
object DConfig : ProfileSpecificDataHolder<Data>(serializer(), "locked-slots", ::Data)
val lockedUUIDs get() = DConfig.data?.lockedUUIDs
val lockedSlots
get() = currentWorldData?.lockedSlots
+
fun isSalvageScreen(screen: HandledScreen<*>?): Boolean {
if (screen == null) return false
return screen.title.unformattedString.contains("Salvage Item")
@@ -259,7 +257,7 @@ object SlotLocking : FirmamentFeature {
}
@Subscribe
- fun onEvent(event: FeaturesInitializedEvent) {
+ fun onEvent(event: ClientInitEvent) {
IsSlotProtectedEvent.subscribe(receivesCancelled = true, "SlotLocking:unlockInDungeons") {
if (it.isProtected
&& it.origin == IsSlotProtectedEvent.MoveOrigin.DROP_FROM_HOTBAR
diff --git a/src/main/kotlin/features/inventory/TimerInLore.kt b/src/main/kotlin/features/inventory/TimerInLore.kt
index eb1463b..d8eebda 100644
--- a/src/main/kotlin/features/inventory/TimerInLore.kt
+++ b/src/main/kotlin/features/inventory/TimerInLore.kt
@@ -11,10 +11,10 @@ import net.minecraft.text.Text
import net.minecraft.util.StringIdentifiable
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ItemTooltipEvent
-import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.SBData
import moe.nea.firmament.util.aqua
import moe.nea.firmament.util.data.Config
+import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.grey
import moe.nea.firmament.util.mc.displayNameAccordingToNbt
import moe.nea.firmament.util.timestamp
diff --git a/src/main/kotlin/features/inventory/WardrobeKeybinds.kt b/src/main/kotlin/features/inventory/WardrobeKeybinds.kt
index ca5ff3a..cdd646e 100644
--- a/src/main/kotlin/features/inventory/WardrobeKeybinds.kt
+++ b/src/main/kotlin/features/inventory/WardrobeKeybinds.kt
@@ -4,10 +4,9 @@ import org.lwjgl.glfw.GLFW
import net.minecraft.item.Items
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HandledScreenKeyPressedEvent
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.data.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.SlotUtils.clickLeftMouseButton
object WardrobeKeybinds {
diff --git a/src/main/kotlin/features/inventory/buttons/InventoryButtonTemplates.kt b/src/main/kotlin/features/inventory/buttons/InventoryButtonTemplates.kt
index d282157..082673e 100644
--- a/src/main/kotlin/features/inventory/buttons/InventoryButtonTemplates.kt
+++ b/src/main/kotlin/features/inventory/buttons/InventoryButtonTemplates.kt
@@ -1,6 +1,5 @@
package moe.nea.firmament.features.inventory.buttons
-import kotlinx.serialization.encodeToString
import net.minecraft.text.Text
import moe.nea.firmament.Firmament
import moe.nea.firmament.util.ErrorUtil
diff --git a/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt b/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt
index f49e6ab..47fdbe9 100644
--- a/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt
+++ b/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt
@@ -1,5 +1,3 @@
-
-
package moe.nea.firmament.features.inventory.buttons
import me.shedaniel.math.Rectangle
@@ -13,32 +11,33 @@ import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HandledScreenClickEvent
import moe.nea.firmament.events.HandledScreenForegroundEvent
import moe.nea.firmament.events.HandledScreenPushREIEvent
-import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.ScreenUtil
import moe.nea.firmament.util.TimeMark
-import moe.nea.firmament.util.data.DataHolder
import moe.nea.firmament.util.accessors.getRectangle
import moe.nea.firmament.util.data.Config
+import moe.nea.firmament.util.data.DataHolder
+import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.gold
object InventoryButtons {
@Config
- object TConfig : ManagedConfig("inventory-buttons-config", Category.INVENTORY) {
- val _openEditor by button("open-editor") {
- openEditor()
- }
+ object TConfig : ManagedConfig("inventory-buttons-config", Category.INVENTORY) {
+ val _openEditor by button("open-editor") {
+ openEditor()
+ }
val hoverText by toggle("hover-text") { true }
val onlyInv by toggle("only-inv") { false }
- }
+ }
- object DConfig : DataHolder<Data>(serializer(), "inventory-buttons", ::Data)
+ @Config
+ object DConfig : DataHolder<Data>(serializer(), "inventory-buttons", ::Data)
- @Serializable
- data class Data(
- var buttons: MutableList<InventoryButton> = mutableListOf()
- )
+ @Serializable
+ data class Data(
+ var buttons: MutableList<InventoryButton> = mutableListOf()
+ )
fun getValidButtons(screen: HandledScreen<*>): Sequence<InventoryButton> {
return DConfig.data.buttons.asSequence().filter { button ->
@@ -47,41 +46,41 @@ object InventoryButtons {
}
- @Subscribe
- fun onRectangles(it: HandledScreenPushREIEvent) {
- val bounds = it.screen.getRectangle()
- for (button in getValidButtons(it.screen)) {
- val buttonBounds = button.getBounds(bounds)
- it.block(buttonBounds)
- }
- }
+ @Subscribe
+ fun onRectangles(it: HandledScreenPushREIEvent) {
+ val bounds = it.screen.getRectangle()
+ for (button in getValidButtons(it.screen)) {
+ val buttonBounds = button.getBounds(bounds)
+ it.block(buttonBounds)
+ }
+ }
- @Subscribe
- fun onClickScreen(it: HandledScreenClickEvent) {
- val bounds = it.screen.getRectangle()
- for (button in getValidButtons(it.screen)) {
- val buttonBounds = button.getBounds(bounds)
- if (buttonBounds.contains(it.mouseX, it.mouseY)) {
- MC.sendCommand(button.command!! /* non null invariant covered by getValidButtons */)
- break
- }
- }
- }
+ @Subscribe
+ fun onClickScreen(it: HandledScreenClickEvent) {
+ val bounds = it.screen.getRectangle()
+ for (button in getValidButtons(it.screen)) {
+ val buttonBounds = button.getBounds(bounds)
+ if (buttonBounds.contains(it.mouseX, it.mouseY)) {
+ MC.sendCommand(button.command!! /* non null invariant covered by getValidButtons */)
+ break
+ }
+ }
+ }
var lastHoveredComponent: InventoryButton? = null
var lastMouseMove = TimeMark.farPast()
- @Subscribe
- fun onRenderForeground(it: HandledScreenForegroundEvent) {
+ @Subscribe
+ fun onRenderForeground(it: HandledScreenForegroundEvent) {
val bounds = it.screen.getRectangle()
var hoveredComponent: InventoryButton? = null
for (button in getValidButtons(it.screen)) {
- val buttonBounds = button.getBounds(bounds)
- it.context.matrices.pushMatrix()
- it.context.matrices.translate(buttonBounds.minX.toFloat(), buttonBounds.minY.toFloat())
- button.render(it.context)
- it.context.matrices.popMatrix()
+ val buttonBounds = button.getBounds(bounds)
+ it.context.matrices.pushMatrix()
+ it.context.matrices.translate(buttonBounds.minX.toFloat(), buttonBounds.minY.toFloat())
+ button.render(it.context)
+ it.context.matrices.popMatrix()
if (buttonBounds.contains(it.mouseX, it.mouseY) && TConfig.hoverText && hoveredComponent == null) {
hoveredComponent = button
@@ -94,23 +93,23 @@ object InventoryButtons {
)
}
}
- }
+ }
if (hoveredComponent !== lastHoveredComponent)
lastMouseMove = TimeMark.now()
lastHoveredComponent = hoveredComponent
- lastRectangle = bounds
- }
+ lastRectangle = bounds
+ }
- var lastRectangle: Rectangle? = null
- fun openEditor() {
- ScreenUtil.setScreenLater(
- InventoryButtonEditor(
- lastRectangle ?: Rectangle(
- MC.window.scaledWidth / 2 - 88,
- MC.window.scaledHeight / 2 - 83,
- 176, 166,
- )
- )
- )
- }
+ var lastRectangle: Rectangle? = null
+ fun openEditor() {
+ ScreenUtil.setScreenLater(
+ InventoryButtonEditor(
+ lastRectangle ?: Rectangle(
+ MC.window.scaledWidth / 2 - 88,
+ MC.window.scaledHeight / 2 - 83,
+ 176, 166,
+ )
+ )
+ )
+ }
}
diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlay.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlay.kt
index 3734024..6043335 100644
--- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlay.kt
+++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlay.kt
@@ -13,19 +13,18 @@ import moe.nea.firmament.events.ScreenChangeEvent
import moe.nea.firmament.events.SlotClickEvent
import moe.nea.firmament.events.SlotRenderEvents
import moe.nea.firmament.events.TickEvent
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.customgui.customGui
import moe.nea.firmament.util.data.Config
+import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.data.ProfileSpecificDataHolder
-object StorageOverlay : FirmamentFeature {
-
+object StorageOverlay {
+ @Config
object Data : ProfileSpecificDataHolder<StorageData>(serializer(), "storage-data", ::StorageData)
- override val identifier: String
+ val identifier: String
get() = "storage-overlay"
@Config
@@ -86,9 +85,6 @@ object StorageOverlay : FirmamentFeature {
return amount * TConfig.scrollSpeed * (if (TConfig.inverseScroll) 1 else -1)
}
- override val config: TConfig
- get() = TConfig
-
var lastStorageOverlay: StorageOverviewScreen? = null
var skipNextStorageOverlayBackflip = false
var currentHandler: StorageBackingHandle? = null
diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt
index e383d29..65d7e8c 100644
--- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt
+++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt
@@ -53,18 +53,18 @@ class StorageOverviewScreen() : Screen(Text.empty()) {
inline fun layoutedForEach(onEach: (data: Pair<StoragePageSlot, StorageData.StorageInventory>, offsetX: Int, offsetY: Int) -> Unit) {
var offsetY = 0
- var currentMaxHeight = StorageOverlay.config.margin - StorageOverlay.config.padding - scroll
+ var currentMaxHeight = StorageOverlay.TConfig.margin - StorageOverlay.TConfig.padding - scroll
var totalHeight = -currentMaxHeight
content.storageInventories.onEachIndexed { index, (key, value) ->
- val pageX = (index % StorageOverlay.config.columns)
+ val pageX = (index % StorageOverlay.TConfig.columns)
if (pageX == 0) {
- currentMaxHeight += StorageOverlay.config.padding
+ currentMaxHeight += StorageOverlay.TConfig.padding
offsetY += currentMaxHeight
totalHeight += currentMaxHeight
currentMaxHeight = 0
}
val xPosition =
- width / 2 - (StorageOverlay.config.columns * (pageWidth + StorageOverlay.config.padding) - StorageOverlay.config.padding) / 2 + pageX * (pageWidth + StorageOverlay.config.padding)
+ width / 2 - (StorageOverlay.TConfig.columns * (pageWidth + StorageOverlay.TConfig.padding) - StorageOverlay.TConfig.padding) / 2 + pageX * (pageWidth + StorageOverlay.TConfig.padding)
onEach(Pair(key, value), xPosition, offsetY)
val height = getStorePageHeight(value)
currentMaxHeight = max(currentMaxHeight, height)
@@ -102,7 +102,7 @@ class StorageOverviewScreen() : Screen(Text.empty()) {
return true
}
- private fun getMaxScroll() = lastRenderedHeight - height + 2 * StorageOverlay.config.margin
+ private fun getMaxScroll() = lastRenderedHeight - height + 2 * StorageOverlay.TConfig.margin
private fun renderStoragePage(context: DrawContext, page: StorageData.StorageInventory, mouseX: Int, mouseY: Int) {
context.drawText(MC.font, page.title, 2, 2, -1, true)
diff --git a/src/main/kotlin/features/inventory/storageoverlay/VirtualInventory.kt b/src/main/kotlin/features/inventory/storageoverlay/VirtualInventory.kt
index d99acd7..83e0d19 100644
--- a/src/main/kotlin/features/inventory/storageoverlay/VirtualInventory.kt
+++ b/src/main/kotlin/features/inventory/storageoverlay/VirtualInventory.kt
@@ -18,7 +18,6 @@ import net.minecraft.nbt.NbtIo
import net.minecraft.nbt.NbtList
import net.minecraft.nbt.NbtOps
import net.minecraft.nbt.NbtSizeTracker
-import net.minecraft.registry.RegistryOps
import moe.nea.firmament.util.ErrorUtil
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.mc.TolerantRegistriesOps
diff --git a/src/main/kotlin/features/items/BlockZapperOverlay.kt b/src/main/kotlin/features/items/BlockZapperOverlay.kt
index ad96b8e..a853012 100644
--- a/src/main/kotlin/features/items/BlockZapperOverlay.kt
+++ b/src/main/kotlin/features/items/BlockZapperOverlay.kt
@@ -9,19 +9,17 @@ import net.minecraft.util.hit.BlockHitResult
import net.minecraft.util.hit.HitResult
import net.minecraft.util.math.BlockPos
import moe.nea.firmament.annotations.Subscribe
-import moe.nea.firmament.events.ClientStartedEvent
import moe.nea.firmament.events.WorldKeyboardEvent
import moe.nea.firmament.events.WorldRenderLastEvent
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.data.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.render.RenderInWorldContext
import moe.nea.firmament.util.skyBlockId
import moe.nea.firmament.util.skyblock.SkyBlockItems
-object BlockZapperOverlay : FirmamentFeature {
- override val identifier: String
+object BlockZapperOverlay {
+ val identifier: String
get() = "block-zapper-overlay"
@Config
@@ -31,13 +29,6 @@ object BlockZapperOverlay : FirmamentFeature {
var undoKey by keyBindingWithDefaultUnbound("undo-key")
}
- @Subscribe
- fun onInit(event: ClientStartedEvent) {
- }
-
- override val config: ManagedConfig
- get() = TConfig
-
val bannedZapper: List<Block> = listOf<Block>(
Blocks.WHEAT,
Blocks.CARROTS,
diff --git a/src/main/kotlin/features/items/BonemerangOverlay.kt b/src/main/kotlin/features/items/BonemerangOverlay.kt
index 80019c0..1310154 100644
--- a/src/main/kotlin/features/items/BonemerangOverlay.kt
+++ b/src/main/kotlin/features/items/BonemerangOverlay.kt
@@ -1,7 +1,6 @@
package moe.nea.firmament.features.items
import me.shedaniel.math.Color
-import moe.nea.jarvis.api.Point
import org.joml.Vector2i
import net.minecraft.entity.LivingEntity
import net.minecraft.entity.decoration.ArmorStandEntity
@@ -9,20 +8,18 @@ import net.minecraft.entity.player.PlayerEntity
import net.minecraft.util.Formatting
import net.minecraft.util.math.Box
import moe.nea.firmament.annotations.Subscribe
-import moe.nea.firmament.events.ClientStartedEvent
import moe.nea.firmament.events.EntityRenderTintEvent
import moe.nea.firmament.events.HudRenderEvent
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.data.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.render.TintedOverlayTexture
import moe.nea.firmament.util.skyBlockId
import moe.nea.firmament.util.skyblock.SkyBlockItems
import moe.nea.firmament.util.tr
-object BonemerangOverlay : FirmamentFeature {
- override val identifier: String
+object BonemerangOverlay {
+ val identifier: String
get() = "bonemerang-overlay"
@Config
@@ -32,13 +29,6 @@ object BonemerangOverlay : FirmamentFeature {
var highlightHitEntities by toggle("highlight-hit-entities") { false }
}
- @Subscribe
- fun onInit(event: ClientStartedEvent) {
- }
-
- override val config: ManagedConfig
- get() = TConfig
-
fun getEntities(): MutableSet<LivingEntity> {
val entities = mutableSetOf<LivingEntity>()
val camera = MC.camera as? PlayerEntity ?: return entities
diff --git a/src/main/kotlin/features/items/EtherwarpOverlay.kt b/src/main/kotlin/features/items/EtherwarpOverlay.kt
index 640c8f5..ba712b3 100644
--- a/src/main/kotlin/features/items/EtherwarpOverlay.kt
+++ b/src/main/kotlin/features/items/EtherwarpOverlay.kt
@@ -13,19 +13,18 @@ import net.minecraft.util.math.Vec3d
import net.minecraft.world.BlockView
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.WorldRenderLastEvent
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.SBData
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.render.RenderInWorldContext
import moe.nea.firmament.util.skyBlockId
import moe.nea.firmament.util.skyblock.SkyBlockItems
import moe.nea.firmament.util.tr
-object EtherwarpOverlay : FirmamentFeature {
- override val identifier: String
+object EtherwarpOverlay {
+ val identifier: String
get() = "etherwarp-overlay"
@Config
@@ -41,9 +40,6 @@ object EtherwarpOverlay : FirmamentFeature {
var failureText by toggle("failure-text") { false }
}
- override val config: ManagedConfig
- get() = TConfig
-
enum class EtherwarpResult(val label: Text?, val color: () -> ChromaColour) {
SUCCESS(null, TConfig::cubeColour),
INTERACTION_BLOCKED(
diff --git a/src/main/kotlin/features/macros/ComboProcessor.kt b/src/main/kotlin/features/macros/ComboProcessor.kt
index 2b979c3..a01f8b7 100644
--- a/src/main/kotlin/features/macros/ComboProcessor.kt
+++ b/src/main/kotlin/features/macros/ComboProcessor.kt
@@ -1,7 +1,6 @@
package moe.nea.firmament.features.macros
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.client.util.InputUtil
import net.minecraft.text.Text
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HudRenderEvent
diff --git a/src/main/kotlin/features/macros/MacroData.kt b/src/main/kotlin/features/macros/MacroData.kt
index 447516e..af1b0e8 100644
--- a/src/main/kotlin/features/macros/MacroData.kt
+++ b/src/main/kotlin/features/macros/MacroData.kt
@@ -1,6 +1,7 @@
package moe.nea.firmament.features.macros
import kotlinx.serialization.Serializable
+import moe.nea.firmament.util.data.Config
import moe.nea.firmament.util.data.DataHolder
@Serializable
@@ -8,6 +9,7 @@ data class MacroData(
var comboActions: List<ComboKeyAction> = listOf(),
var wheels: List<MacroWheel> = listOf(),
) {
+ @Config
object DConfig : DataHolder<MacroData>(kotlinx.serialization.serializer(), "macros", ::MacroData) {
override fun onLoad() {
ComboProcessor.setActions(data.comboActions)
diff --git a/src/main/kotlin/features/mining/CommissionFeatures.kt b/src/main/kotlin/features/mining/CommissionFeatures.kt
index 05658cc..1041ae5 100644
--- a/src/main/kotlin/features/mining/CommissionFeatures.kt
+++ b/src/main/kotlin/features/mining/CommissionFeatures.kt
@@ -3,9 +3,9 @@ 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.util.data.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
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 763364e..aa45d82 100644
--- a/src/main/kotlin/features/mining/HotmPresets.kt
+++ b/src/main/kotlin/features/mining/HotmPresets.kt
@@ -18,7 +18,6 @@ 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.util.data.ManagedConfig
import moe.nea.firmament.mixins.accessor.AccessorHandledScreen
import moe.nea.firmament.util.ClipboardUtils
import moe.nea.firmament.util.MC
diff --git a/src/main/kotlin/features/mining/MiningBlockInfoUi.kt b/src/main/kotlin/features/mining/MiningBlockInfoUi.kt
index 5b58d4f..f4def44 100644
--- a/src/main/kotlin/features/mining/MiningBlockInfoUi.kt
+++ b/src/main/kotlin/features/mining/MiningBlockInfoUi.kt
@@ -1,7 +1,6 @@
package moe.nea.firmament.features.mining
import io.github.notenoughupdates.moulconfig.observer.ObservableList
-import io.github.notenoughupdates.moulconfig.observer.Property
import io.github.notenoughupdates.moulconfig.platform.MoulConfigPlatform
import io.github.notenoughupdates.moulconfig.xml.Bind
import net.minecraft.client.gui.screen.Screen
diff --git a/src/main/kotlin/features/mining/PickaxeAbility.kt b/src/main/kotlin/features/mining/PickaxeAbility.kt
index 3acdcc3..5bd85c5 100644
--- a/src/main/kotlin/features/mining/PickaxeAbility.kt
+++ b/src/main/kotlin/features/mining/PickaxeAbility.kt
@@ -18,8 +18,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.util.data.ManagedConfig
import moe.nea.firmament.util.DurabilityBarEvent
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.SBData
@@ -28,6 +26,7 @@ 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
@@ -44,8 +43,8 @@ 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>) : StringIdentifiable {
@@ -102,9 +101,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()
diff --git a/src/main/kotlin/features/mining/PristineProfitTracker.kt b/src/main/kotlin/features/mining/PristineProfitTracker.kt
index e63a107..ad864c1 100644
--- a/src/main/kotlin/features/mining/PristineProfitTracker.kt
+++ b/src/main/kotlin/features/mining/PristineProfitTracker.kt
@@ -1,7 +1,6 @@
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
@@ -9,20 +8,19 @@ import kotlin.time.Duration.Companion.seconds
import net.minecraft.text.Text
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ProcessChatEvent
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.data.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(
@@ -52,11 +50,9 @@ 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 }
@@ -117,20 +113,18 @@ object PristineProfitTracker : FirmamentFeature {
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)
}
diff --git a/src/main/kotlin/features/misc/CustomCapes.kt b/src/main/kotlin/features/misc/CustomCapes.kt
index f59f715..086f2fb 100644
--- a/src/main/kotlin/features/misc/CustomCapes.kt
+++ b/src/main/kotlin/features/misc/CustomCapes.kt
@@ -1,36 +1,25 @@
package moe.nea.firmament.features.misc
-import com.mojang.blaze3d.buffers.GpuBuffer
-import com.mojang.blaze3d.buffers.Std140Builder
-import com.mojang.blaze3d.systems.RenderSystem
-import java.nio.ByteBuffer
-import java.nio.ByteOrder
-import java.util.OptionalDouble
-import java.util.OptionalInt
-import org.joml.Vector4f
import util.render.CustomRenderPipelines
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
import net.minecraft.client.network.AbstractClientPlayerEntity
-import net.minecraft.client.render.BufferBuilder
import net.minecraft.client.render.RenderLayer
import net.minecraft.client.render.VertexConsumer
import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.render.entity.state.PlayerEntityRenderState
-import net.minecraft.client.util.BufferAllocator
import net.minecraft.client.util.SkinTextures
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.util.Identifier
import moe.nea.firmament.Firmament
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.MC
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.mc.CustomRenderPassHelper
-object CustomCapes : FirmamentFeature {
- override val identifier: String
+object CustomCapes {
+ val identifier: String
get() = "developer-capes"
@Config
@@ -38,9 +27,6 @@ object CustomCapes : FirmamentFeature {
val showCapes by toggle("show-cape") { true }
}
- override val config: ManagedConfig
- get() = TConfig
-
interface CustomCapeRenderer {
fun replaceRender(
renderLayer: RenderLayer,
diff --git a/src/main/kotlin/features/misc/Hud.kt b/src/main/kotlin/features/misc/Hud.kt
index 272c349..fb7c6cd 100644
--- a/src/main/kotlin/features/misc/Hud.kt
+++ b/src/main/kotlin/features/misc/Hud.kt
@@ -1,19 +1,17 @@
package moe.nea.firmament.features.misc
-import moe.nea.firmament.annotations.Subscribe
-import moe.nea.firmament.events.HudRenderEvent
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.data.ManagedConfig
-import moe.nea.firmament.util.MC
-import moe.nea.firmament.util.tr
-import moe.nea.jarvis.api.Point
import org.joml.Vector2i
import net.minecraft.client.network.PlayerListEntry
import net.minecraft.text.Text
+import moe.nea.firmament.annotations.Subscribe
+import moe.nea.firmament.events.HudRenderEvent
+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.tr
-object Hud : FirmamentFeature {
- override val identifier: String
+object Hud {
+ val identifier: String
get() = "hud"
@Config
@@ -26,9 +24,6 @@ object Hud : FirmamentFeature {
val pingCountHud by position("ping-count-hud", 80, 10) { Vector2i() }
}
- override val config: ManagedConfig
- get() = TConfig
-
@Subscribe
fun onRenderHud(it: HudRenderEvent) {
if (TConfig.dayCount) {
diff --git a/src/main/kotlin/features/misc/ModAnnouncer.kt b/src/main/kotlin/features/misc/ModAnnouncer.kt
index 0eae9d7..1047353 100644
--- a/src/main/kotlin/features/misc/ModAnnouncer.kt
+++ b/src/main/kotlin/features/misc/ModAnnouncer.kt
@@ -1,7 +1,6 @@
package moe.nea.firmament.features.misc
import io.netty.buffer.ByteBuf
-import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry
import net.fabricmc.loader.api.FabricLoader
diff --git a/src/main/kotlin/features/notifications/Notifications.kt b/src/main/kotlin/features/notifications/Notifications.kt
deleted file mode 100644
index 8d912d1..0000000
--- a/src/main/kotlin/features/notifications/Notifications.kt
+++ /dev/null
@@ -1,7 +0,0 @@
-
-package moe.nea.firmament.features.notifications
-
-import moe.nea.firmament.features.FirmamentFeature
-
-object Notifications {
-}
diff --git a/src/main/kotlin/features/world/FairySouls.kt b/src/main/kotlin/features/world/FairySouls.kt
index 477fbe6..9191a80 100644
--- a/src/main/kotlin/features/world/FairySouls.kt
+++ b/src/main/kotlin/features/world/FairySouls.kt
@@ -1,133 +1,123 @@
-
-
package moe.nea.firmament.features.world
import io.github.moulberry.repo.data.Coordinate
import me.shedaniel.math.Color
import kotlinx.serialization.Serializable
import kotlinx.serialization.serializer
-import net.minecraft.text.Text
-import net.minecraft.util.math.BlockPos
-import net.minecraft.util.math.Vec3d
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ProcessChatEvent
import moe.nea.firmament.events.SkyblockServerUpdateEvent
import moe.nea.firmament.events.WorldRenderLastEvent
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.repo.RepoManager
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.SBData
import moe.nea.firmament.util.SkyBlockIsland
import moe.nea.firmament.util.blockPos
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.render.RenderInWorldContext
import moe.nea.firmament.util.render.RenderInWorldContext.Companion.renderInWorld
import moe.nea.firmament.util.unformattedString
-object FairySouls : FirmamentFeature {
-
+object FairySouls {
- @Serializable
- data class Data(
- val foundSouls: MutableMap<SkyBlockIsland, MutableSet<Int>> = mutableMapOf()
- )
- override val config: ManagedConfig
- get() = TConfig
+ @Serializable
+ data class Data(
+ val foundSouls: MutableMap<SkyBlockIsland, MutableSet<Int>> = mutableMapOf()
+ )
@Config
- object DConfig : ProfileSpecificDataHolder<Data>(serializer(), "found-fairysouls", ::Data)
+ object DConfig : ProfileSpecificDataHolder<Data>(serializer(), "found-fairysouls", ::Data)
@Config
- object TConfig : ManagedConfig("fairy-souls", Category.MISC) {
- val displaySouls by toggle("show") { false }
- val resetSouls by button("reset") {
- DConfig.data?.foundSouls?.clear() != null
- updateMissingSouls()
- }
- }
-
-
- override val identifier: String get() = "fairy-souls"
-
- val playerReach = 5
- val playerReachSquared = playerReach * playerReach
-
- var currentLocationName: SkyBlockIsland? = null
- var currentLocationSouls: List<Coordinate> = emptyList()
- var currentMissingSouls: List<Coordinate> = emptyList()
-
- fun updateMissingSouls() {
- currentMissingSouls = emptyList()
- val c = DConfig.data ?: return
- val fi = c.foundSouls[currentLocationName] ?: setOf()
- val cms = currentLocationSouls.toMutableList()
- fi.asSequence().sortedDescending().filter { it in cms.indices }.forEach { cms.removeAt(it) }
- currentMissingSouls = cms
- }
-
- fun updateWorldSouls() {
- currentLocationSouls = emptyList()
- val loc = currentLocationName ?: return
- currentLocationSouls = RepoManager.neuRepo.constants.fairySouls.soulLocations[loc.locrawMode] ?: return
- }
-
- fun findNearestClickableSoul(): Coordinate? {
- val player = MC.player ?: return null
- val pos = player.pos
- val location = SBData.skyblockLocation ?: return null
- val soulLocations: List<Coordinate> =
- RepoManager.neuRepo.constants.fairySouls.soulLocations[location.locrawMode] ?: return null
- return soulLocations
- .map { it to it.blockPos.getSquaredDistance(pos) }
- .filter { it.second < playerReachSquared }
- .minByOrNull { it.second }
- ?.first
- }
-
- private fun markNearestSoul() {
- val nearestSoul = findNearestClickableSoul() ?: return
- val c = DConfig.data ?: return
- val loc = currentLocationName ?: return
- val idx = currentLocationSouls.indexOf(nearestSoul)
- c.foundSouls.computeIfAbsent(loc) { mutableSetOf() }.add(idx)
- DConfig.markDirty()
- updateMissingSouls()
- }
-
- @Subscribe
- fun onWorldRender(it: WorldRenderLastEvent) {
- if (!TConfig.displaySouls) return
- renderInWorld(it) {
- currentMissingSouls.forEach {
- block(it.blockPos, Color.ofRGBA(176, 0, 255, 128).color)
- }
- currentLocationSouls.forEach {
- wireframeCube(it.blockPos)
- }
- }
- }
-
- @Subscribe
- fun onProcessChat(it: ProcessChatEvent) {
- when (it.text.unformattedString) {
- "You have already found that Fairy Soul!" -> {
- markNearestSoul()
- }
-
- "SOUL! You found a Fairy Soul!" -> {
- markNearestSoul()
- }
- }
- }
-
- @Subscribe
- fun onLocationChange(it: SkyblockServerUpdateEvent) {
- currentLocationName = it.newLocraw?.skyblockLocation
- updateWorldSouls()
- updateMissingSouls()
- }
+ object TConfig : ManagedConfig("fairy-souls", Category.MISC) {
+ val displaySouls by toggle("show") { false }
+ val resetSouls by button("reset") {
+ DConfig.data?.foundSouls?.clear() != null
+ updateMissingSouls()
+ }
+ }
+
+
+ val identifier: String get() = "fairy-souls"
+
+ val playerReach = 5
+ val playerReachSquared = playerReach * playerReach
+
+ var currentLocationName: SkyBlockIsland? = null
+ var currentLocationSouls: List<Coordinate> = emptyList()
+ var currentMissingSouls: List<Coordinate> = emptyList()
+
+ fun updateMissingSouls() {
+ currentMissingSouls = emptyList()
+ val c = DConfig.data ?: return
+ val fi = c.foundSouls[currentLocationName] ?: setOf()
+ val cms = currentLocationSouls.toMutableList()
+ fi.asSequence().sortedDescending().filter { it in cms.indices }.forEach { cms.removeAt(it) }
+ currentMissingSouls = cms
+ }
+
+ fun updateWorldSouls() {
+ currentLocationSouls = emptyList()
+ val loc = currentLocationName ?: return
+ currentLocationSouls = RepoManager.neuRepo.constants.fairySouls.soulLocations[loc.locrawMode] ?: return
+ }
+
+ fun findNearestClickableSoul(): Coordinate? {
+ val player = MC.player ?: return null
+ val pos = player.pos
+ val location = SBData.skyblockLocation ?: return null
+ val soulLocations: List<Coordinate> =
+ RepoManager.neuRepo.constants.fairySouls.soulLocations[location.locrawMode] ?: return null
+ return soulLocations
+ .map { it to it.blockPos.getSquaredDistance(pos) }
+ .filter { it.second < playerReachSquared }
+ .minByOrNull { it.second }
+ ?.first
+ }
+
+ private fun markNearestSoul() {
+ val nearestSoul = findNearestClickableSoul() ?: return
+ val c = DConfig.data ?: return
+ val loc = currentLocationName ?: return
+ val idx = currentLocationSouls.indexOf(nearestSoul)
+ c.foundSouls.computeIfAbsent(loc) { mutableSetOf() }.add(idx)
+ DConfig.markDirty()
+ updateMissingSouls()
+ }
+
+ @Subscribe
+ fun onWorldRender(it: WorldRenderLastEvent) {
+ if (!TConfig.displaySouls) return
+ renderInWorld(it) {
+ currentMissingSouls.forEach {
+ block(it.blockPos, Color.ofRGBA(176, 0, 255, 128).color)
+ }
+ currentLocationSouls.forEach {
+ wireframeCube(it.blockPos)
+ }
+ }
+ }
+
+ @Subscribe
+ fun onProcessChat(it: ProcessChatEvent) {
+ when (it.text.unformattedString) {
+ "You have already found that Fairy Soul!" -> {
+ markNearestSoul()
+ }
+
+ "SOUL! You found a Fairy Soul!" -> {
+ markNearestSoul()
+ }
+ }
+ }
+
+ @Subscribe
+ fun onLocationChange(it: SkyblockServerUpdateEvent) {
+ currentLocationName = it.newLocraw?.skyblockLocation
+ updateWorldSouls()
+ updateMissingSouls()
+ }
}
diff --git a/src/main/kotlin/features/world/TemporaryWaypoints.kt b/src/main/kotlin/features/world/TemporaryWaypoints.kt
index 3c8e895..f5653ad 100644
--- a/src/main/kotlin/features/world/TemporaryWaypoints.kt
+++ b/src/main/kotlin/features/world/TemporaryWaypoints.kt
@@ -1,8 +1,6 @@
package moe.nea.firmament.features.world
import me.shedaniel.math.Color
-import kotlin.compareTo
-import kotlin.text.clear
import kotlin.time.Duration.Companion.seconds
import net.minecraft.text.Text
import net.minecraft.util.math.BlockPos
diff --git a/src/main/kotlin/features/world/Waypoints.kt b/src/main/kotlin/features/world/Waypoints.kt
index 72bd9e8..318b6c2 100644
--- a/src/main/kotlin/features/world/Waypoints.kt
+++ b/src/main/kotlin/features/world/Waypoints.kt
@@ -16,16 +16,15 @@ import moe.nea.firmament.events.CommandEvent
import moe.nea.firmament.events.TickEvent
import moe.nea.firmament.events.WorldReadyEvent
import moe.nea.firmament.events.WorldRenderLastEvent
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.util.data.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.asFakeServer
import moe.nea.firmament.util.render.RenderInWorldContext
import moe.nea.firmament.util.tr
-object Waypoints : FirmamentFeature {
- override val identifier: String
+object Waypoints {
+ val identifier: String
get() = "waypoints"
@Config
@@ -37,7 +36,6 @@ object Waypoints : FirmamentFeature {
// TODO: look ahead size
}
- override val config get() = TConfig
var waypoints: FirmWaypoints? = null
var orderedIndex = 0
@@ -56,11 +54,13 @@ object Waypoints : FirmamentFeature {
orderedIndex %= w.waypoints.size
val firstColor = Color.ofRGBA(0, 200, 40, 180)
tracer(w.waypoints[orderedIndex].blockPos.toCenterPos(), color = firstColor.color, lineWidth = 3f)
- w.waypoints.withIndex().toList().wrappingWindow(orderedIndex, 3).zip(listOf(
- firstColor,
- Color.ofRGBA(180, 200, 40, 150),
- Color.ofRGBA(180, 80, 20, 140),
- )).reversed().forEach { (waypoint, col) ->
+ w.waypoints.withIndex().toList().wrappingWindow(orderedIndex, 3).zip(
+ listOf(
+ firstColor,
+ Color.ofRGBA(180, 200, 40, 150),
+ Color.ofRGBA(180, 80, 20, 140),
+ )
+ ).reversed().forEach { (waypoint, col) ->
val (index, pos) = waypoint
block(pos.blockPos, col.color)
if (TConfig.showIndex) withFacingThePlayer(pos.blockPos.toCenterPos()) {
@@ -123,10 +123,14 @@ object Waypoints : FirmamentFeature {
val position = pos.get(this).toAbsoluteBlockPos(source.asFakeServer())
val w = useEditableWaypoints()
w.waypoints.add(FirmWaypoints.Waypoint.from(position))
- source.sendFeedback(Text.stringifiedTranslatable("firmament.command.waypoint.added",
- position.x,
- position.y,
- position.z))
+ source.sendFeedback(
+ Text.stringifiedTranslatable(
+ "firmament.command.waypoint.added",
+ position.x,
+ position.y,
+ position.z
+ )
+ )
}
}
}
@@ -134,9 +138,12 @@ object Waypoints : FirmamentFeature {
thenLiteral("reset") {
thenExecute {
orderedIndex = 0
- source.sendFeedback(tr(
- "firmament.command.waypoint.reset",
- "Reset your ordered waypoint index back to 0. If you want to delete all waypoints use /firm waypoints clear instead."))
+ source.sendFeedback(
+ tr(
+ "firmament.command.waypoint.reset",
+ "Reset your ordered waypoint index back to 0. If you want to delete all waypoints use /firm waypoints clear instead."
+ )
+ )
}
}
thenLiteral("changeindex") {
@@ -158,10 +165,13 @@ object Waypoints : FirmamentFeature {
w.waypoints.add(
if (toIndex > fromIndex) toIndex - 1
else toIndex,
- waypoint)
+ waypoint
+ )
source.sendFeedback(
- tr("firmament.command.waypoint.indexchange",
- "Moved waypoint from index $fromIndex to $toIndex. Note that this only matters for ordered waypoints.")
+ tr(
+ "firmament.command.waypoint.indexchange",
+ "Moved waypoint from index $fromIndex to $toIndex. Note that this only matters for ordered waypoints."
+ )
)
}
}
@@ -203,8 +213,12 @@ object Waypoints : FirmamentFeature {
val w = useNonEmptyWaypoints()
if (w != null && index in w.waypoints.indices) {
w.waypoints.removeAt(index)
- source.sendFeedback(Text.stringifiedTranslatable("firmament.command.waypoint.remove",
- index))
+ source.sendFeedback(
+ Text.stringifiedTranslatable(
+ "firmament.command.waypoint.remove",
+ index
+ )
+ )
} else {
source.sendError(Text.stringifiedTranslatable("firmament.command.waypoint.remove.error"))
}
@@ -215,12 +229,16 @@ object Waypoints : FirmamentFeature {
}
fun textInvalidIndex(index: Int) =
- tr("firmament.command.waypoint.invalid-index",
- "Invalid index $index provided.")
+ tr(
+ "firmament.command.waypoint.invalid-index",
+ "Invalid index $index provided."
+ )
fun textNothingToExport(): Text =
- tr("firmament.command.waypoint.export.nowaypoints",
- "No waypoints to export found. Add some with /firm waypoint ~ ~ ~.")
+ tr(
+ "firmament.command.waypoint.export.nowaypoints",
+ "No waypoints to export found. Add some with /firm waypoint ~ ~ ~."
+ )
}
fun <E> List<E>.wrappingWindow(startIndex: Int, windowSize: Int): List<E> {