From 0a96dd618acba15269627c7eae8a2291fb2dc84a Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Sun, 14 Sep 2025 19:46:52 +0200 Subject: snapshot --- .../nea/firmament/compat/rei/FirmamentReiPlugin.kt | 4 +- .../firmament/compat/rei/NEUItemEntryRenderer.kt | 4 +- .../firmament/compat/rei/SBItemEntryDefinition.kt | 2 +- .../moe/nea/firmament/util/data/ManagedConfig.kt | 2 +- src/main/kotlin/Firmament.kt | 3 +- src/main/kotlin/apis/Profiles.kt | 8 +- src/main/kotlin/apis/Routes.kt | 14 +- src/main/kotlin/apis/UrsaManager.kt | 16 +- src/main/kotlin/commands/Duration.kt | 1 - src/main/kotlin/commands/dsl.kt | 8 +- src/main/kotlin/commands/rome.kt | 2 +- src/main/kotlin/events/AllowChatEvent.kt | 2 +- src/main/kotlin/events/EntityRenderTintEvent.kt | 1 + src/main/kotlin/events/FeaturesInitializedEvent.kt | 8 - src/main/kotlin/events/IsSlotProtectedEvent.kt | 1 - src/main/kotlin/events/ModifyChatEvent.kt | 2 +- src/main/kotlin/events/SlotRenderEvents.kt | 3 - src/main/kotlin/events/WorldRenderLastEvent.kt | 4 - .../kotlin/events/subscription/Subscription.kt | 4 - src/main/kotlin/features/FeatureManager.kt | 107 +----- src/main/kotlin/features/FirmamentFeature.kt | 23 -- src/main/kotlin/features/chat/AutoCompletions.kt | 13 +- src/main/kotlin/features/chat/ChatLinks.kt | 11 +- src/main/kotlin/features/chat/CopyChat.kt | 16 +- src/main/kotlin/features/chat/PartyCommands.kt | 2 +- src/main/kotlin/features/chat/QuickCommands.kt | 41 ++- src/main/kotlin/features/debug/DebugLogger.kt | 4 +- src/main/kotlin/features/debug/DebugView.kt | 29 -- .../kotlin/features/debug/DeveloperFeatures.kt | 13 +- src/main/kotlin/features/debug/MinorTrolling.kt | 6 +- src/main/kotlin/features/debug/PowerUserTools.kt | 12 +- .../kotlin/features/diana/AncestralSpadeSolver.kt | 9 +- src/main/kotlin/features/diana/DianaWaypoints.kt | 38 +- .../kotlin/features/diana/NearbyBurrowsSolver.kt | 7 +- .../events/anniversity/AnniversaryFeatures.kt | 392 ++++++++++----------- .../events/anniversity/CenturyRaffleFeatures.kt | 2 +- .../features/events/carnival/CarnivalFeatures.kt | 7 +- .../kotlin/features/fixes/CompatibliltyFeatures.kt | 10 +- src/main/kotlin/features/fixes/Fixes.kt | 10 +- .../kotlin/features/garden/HideComposterNoises.kt | 2 +- .../kotlin/features/inventory/CraftingOverlay.kt | 5 +- src/main/kotlin/features/inventory/ItemHotkeys.kt | 3 +- .../features/inventory/ItemRarityCosmetics.kt | 16 +- .../kotlin/features/inventory/JunkHighlighter.kt | 7 +- src/main/kotlin/features/inventory/PetFeatures.kt | 10 +- src/main/kotlin/features/inventory/PriceData.kt | 9 +- .../features/inventory/REIDependencyWarner.kt | 6 +- .../features/inventory/SaveCursorPosition.kt | 93 +++-- src/main/kotlin/features/inventory/SlotLocking.kt | 16 +- src/main/kotlin/features/inventory/TimerInLore.kt | 2 +- .../kotlin/features/inventory/WardrobeKeybinds.kt | 3 +- .../inventory/buttons/InventoryButtonTemplates.kt | 1 - .../features/inventory/buttons/InventoryButtons.kt | 109 +++--- .../inventory/storageoverlay/StorageOverlay.kt | 12 +- .../storageoverlay/StorageOverviewScreen.kt | 10 +- .../inventory/storageoverlay/VirtualInventory.kt | 1 - .../kotlin/features/items/BlockZapperOverlay.kt | 15 +- .../kotlin/features/items/BonemerangOverlay.kt | 16 +- src/main/kotlin/features/items/EtherwarpOverlay.kt | 10 +- src/main/kotlin/features/macros/ComboProcessor.kt | 1 - src/main/kotlin/features/macros/MacroData.kt | 2 + .../kotlin/features/mining/CommissionFeatures.kt | 2 +- src/main/kotlin/features/mining/Histogram.kt | 3 +- src/main/kotlin/features/mining/HotmPresets.kt | 1 - .../kotlin/features/mining/MiningBlockInfoUi.kt | 1 - src/main/kotlin/features/mining/PickaxeAbility.kt | 10 +- .../features/mining/PristineProfitTracker.kt | 36 +- src/main/kotlin/features/misc/CustomCapes.kt | 20 +- src/main/kotlin/features/misc/Hud.kt | 19 +- src/main/kotlin/features/misc/ModAnnouncer.kt | 1 - .../kotlin/features/notifications/Notifications.kt | 7 - src/main/kotlin/features/world/FairySouls.kt | 200 +++++------ .../kotlin/features/world/TemporaryWaypoints.kt | 2 - src/main/kotlin/features/world/Waypoints.kt | 70 ++-- src/main/kotlin/gui/BarComponent.kt | 4 - src/main/kotlin/gui/CheckboxComponent.kt | 1 - src/main/kotlin/gui/config/AllConfigsGui.kt | 2 +- src/main/kotlin/gui/config/ChoiceHandler.kt | 2 +- src/main/kotlin/gui/config/DurationHandler.kt | 3 +- src/main/kotlin/gui/config/HudMetaHandler.kt | 2 +- src/main/kotlin/gui/config/IntegerHandler.kt | 2 +- src/main/kotlin/gui/config/KeyBindingHandler.kt | 8 +- src/main/kotlin/gui/config/ManagedOption.kt | 2 +- src/main/kotlin/gui/config/StringHandler.kt | 2 +- .../kotlin/gui/config/storage/ConfigLoadContext.kt | 16 +- .../gui/config/storage/FirmamentConfigLoader.kt | 4 +- .../kotlin/gui/config/storage/LegacyImporter.kt | 3 - src/main/kotlin/gui/entity/GuiPlayer.kt | 2 - src/main/kotlin/gui/entity/ModifyEquipment.kt | 2 +- src/main/kotlin/gui/entity/ModifyHorse.kt | 3 - src/main/kotlin/jarvis/JarvisIntegration.kt | 8 +- src/main/kotlin/repo/ItemCache.kt | 1 - src/main/kotlin/repo/MiningRepoData.kt | 3 - src/main/kotlin/repo/RepoDownloadManager.kt | 9 +- src/main/kotlin/repo/RepoManager.kt | 12 +- src/main/kotlin/repo/RepoModResourcePack.kt | 2 +- .../repo/recipes/SBEssenceUpgradeRecipeRenderer.kt | 2 - src/main/kotlin/util/LegacyTagParser.kt | 2 +- src/main/kotlin/util/MoulConfigUtils.kt | 1 - src/main/kotlin/util/TemplateUtil.kt | 3 +- src/main/kotlin/util/WarpUtil.kt | 141 ++++---- src/main/kotlin/util/accessors/GetRectangle.kt | 2 +- src/main/kotlin/util/data/DataHolder.kt | 5 - src/main/kotlin/util/data/IDataHolder.kt | 20 +- .../kotlin/util/json/DashlessUUIDSerializer.kt | 1 - src/main/kotlin/util/json/jsonConversion.kt | 1 - src/main/kotlin/util/mc/NbtPrism.kt | 6 - src/main/kotlin/util/render/DrawContextExt.kt | 1 - .../kotlin/util/render/FacingThePlayerContext.kt | 2 - src/main/kotlin/util/render/FirmamentShaders.kt | 8 - .../util/render/MultiSpecialGuiRenderState.kt | 1 - .../kotlin/util/render/RenderCircleProgress.kt | 1 - .../kotlin/util/render/RenderInWorldContext.kt | 1 - src/main/kotlin/util/render/TranslatedScissors.kt | 1 - src/main/kotlin/util/skyblock/SackUtil.kt | 2 + .../features/texturepack/CustomGlobalTextures.kt | 19 +- .../features/texturepack/CustomSkyBlockTextures.kt | 10 +- 117 files changed, 767 insertions(+), 1118 deletions(-) delete mode 100644 src/main/kotlin/events/FeaturesInitializedEvent.kt delete mode 100644 src/main/kotlin/features/FirmamentFeature.kt delete mode 100644 src/main/kotlin/features/debug/DebugView.kt delete mode 100644 src/main/kotlin/features/notifications/Notifications.kt (limited to 'src') diff --git a/src/compat/rei/java/moe/nea/firmament/compat/rei/FirmamentReiPlugin.kt b/src/compat/rei/java/moe/nea/firmament/compat/rei/FirmamentReiPlugin.kt index 3a494b9..1c97738 100644 --- a/src/compat/rei/java/moe/nea/firmament/compat/rei/FirmamentReiPlugin.kt +++ b/src/compat/rei/java/moe/nea/firmament/compat/rei/FirmamentReiPlugin.kt @@ -64,7 +64,7 @@ class FirmamentReiPlugin : REIClientPlugin { if (recipe !is NEUCraftingRecipe) return@TransferHandler TransferHandler.Result.createNotApplicable() val neuItem = RepoManager.getNEUItem(SkyblockId(recipe.output.itemId)) ?: error("Could not find neu item ${recipe.output.itemId} which is used in a recipe output") - val useSuperCraft = context.isStackedCrafting || RepoManager.Config.alwaysSuperCraft + val useSuperCraft = context.isStackedCrafting || RepoManager.TConfig.alwaysSuperCraft if (neuItem.isVanilla && useSuperCraft) return@TransferHandler TransferHandler.Result.createFailed( Text.translatable( "firmament.recipe.novanilla" @@ -138,7 +138,7 @@ class FirmamentReiPlugin : REIClientPlugin { override fun registerCollapsibleEntries(registry: CollapsibleEntryRegistry) { if (!RepoManager.shouldLoadREI()) return - if (!RepoManager.Config.disableItemGroups) + if (!RepoManager.TConfig.disableItemGroups) RepoManager.neuRepo.constants.parents.parents .forEach { (parent, children) -> registry.group( diff --git a/src/compat/rei/java/moe/nea/firmament/compat/rei/NEUItemEntryRenderer.kt b/src/compat/rei/java/moe/nea/firmament/compat/rei/NEUItemEntryRenderer.kt index f881f77..e273020 100644 --- a/src/compat/rei/java/moe/nea/firmament/compat/rei/NEUItemEntryRenderer.kt +++ b/src/compat/rei/java/moe/nea/firmament/compat/rei/NEUItemEntryRenderer.kt @@ -45,7 +45,7 @@ object NEUItemEntryRenderer : EntryRenderer { delta: Float ) { val neuItem = entry.value.neuItem - val itemToRender = if(!RepoManager.Config.perfectRenders.rendersPerfectVisuals() && !entry.value.isWarm() && neuItem != null) { + val itemToRender = if(!RepoManager.TConfig.perfectRenders.rendersPerfectVisuals() && !entry.value.isWarm() && neuItem != null) { ItemCache.recacheSoon(neuItem) ItemStack(Items.PAINTING) } else { @@ -72,7 +72,7 @@ object NEUItemEntryRenderer : EntryRenderer { @OptIn(ExpensiveItemCacheApi::class) override fun getTooltip(entry: EntryStack, tooltipContext: TooltipContext): Tooltip? { - if (!entry.value.isWarm() && !RepoManager.Config.perfectRenders.rendersPerfectText()) { + if (!entry.value.isWarm() && !RepoManager.TConfig.perfectRenders.rendersPerfectText()) { val neuItem = entry.value.neuItem if (neuItem != null) { val lore = mutableListOf() diff --git a/src/compat/rei/java/moe/nea/firmament/compat/rei/SBItemEntryDefinition.kt b/src/compat/rei/java/moe/nea/firmament/compat/rei/SBItemEntryDefinition.kt index 740eeeb..1027ece 100644 --- a/src/compat/rei/java/moe/nea/firmament/compat/rei/SBItemEntryDefinition.kt +++ b/src/compat/rei/java/moe/nea/firmament/compat/rei/SBItemEntryDefinition.kt @@ -46,7 +46,7 @@ object SBItemEntryDefinition : EntryDefinition { @OptIn(ExpensiveItemCacheApi::class) override fun asFormattedText(entry: EntryStack, value: SBItemStack): Text { val neuItem = entry.value.neuItem - return if (!RepoManager.Config.perfectRenders.rendersPerfectText() || entry.value.isWarm() || neuItem == null) { + return if (!RepoManager.TConfig.perfectRenders.rendersPerfectText() || entry.value.isWarm() || neuItem == null) { VanillaEntryTypes.ITEM.definition.asFormattedText(entry.asItemEntry(), value.asImmutableItemStack()) } else { Text.literal(neuItem.displayName) diff --git a/src/main/java/moe/nea/firmament/util/data/ManagedConfig.kt b/src/main/java/moe/nea/firmament/util/data/ManagedConfig.kt index 169dad1..032784a 100644 --- a/src/main/java/moe/nea/firmament/util/data/ManagedConfig.kt +++ b/src/main/java/moe/nea/firmament/util/data/ManagedConfig.kt @@ -46,7 +46,7 @@ import moe.nea.firmament.gui.config.storage.ConfigStorageClass abstract class ManagedConfig( val name: String, val category: Category, -) : IDataHolder { +) : IDataHolder() { enum class Category { // Böse Kategorie, nicht benutzten lol MISC, diff --git a/src/main/kotlin/Firmament.kt b/src/main/kotlin/Firmament.kt index 198defa..3ac01c0 100644 --- a/src/main/kotlin/Firmament.kt +++ b/src/main/kotlin/Firmament.kt @@ -51,7 +51,6 @@ import moe.nea.firmament.repo.HypixelStaticData import moe.nea.firmament.repo.RepoManager import moe.nea.firmament.util.MC import moe.nea.firmament.util.SBData -import moe.nea.firmament.util.data.IDataHolder import moe.nea.firmament.util.mc.InitLevel import moe.nea.firmament.util.tr @@ -144,7 +143,7 @@ object Firmament { }) RepoManager.initialize() SBData.init() - FeatureManager.autoload() + FeatureManager.subscribeEvents() HypixelStaticData.spawnDataCollectionLoop() ClientCommandRegistrationCallback.EVENT.register(this::registerCommands) ClientLifecycleEvents.CLIENT_STARTED.register(ClientLifecycleEvents.ClientStarted { diff --git a/src/main/kotlin/apis/Profiles.kt b/src/main/kotlin/apis/Profiles.kt index a6c334b..ec4a6e4 100644 --- a/src/main/kotlin/apis/Profiles.kt +++ b/src/main/kotlin/apis/Profiles.kt @@ -7,19 +7,19 @@ package moe.nea.firmament.apis import io.github.moulberry.repo.constants.Leveling import io.github.moulberry.repo.data.Rarity import java.time.Instant +import java.util.UUID import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import kotlinx.serialization.UseSerializers +import kotlin.reflect.KProperty1 +import net.minecraft.util.DyeColor +import net.minecraft.util.Formatting import moe.nea.firmament.repo.RepoManager import moe.nea.firmament.util.LegacyFormattingCode import moe.nea.firmament.util.SkyblockId import moe.nea.firmament.util.assertNotNullOr import moe.nea.firmament.util.json.DashlessUUIDSerializer import moe.nea.firmament.util.json.InstantAsLongSerializer -import net.minecraft.util.DyeColor -import net.minecraft.util.Formatting -import java.util.* -import kotlin.reflect.KProperty1 @Serializable diff --git a/src/main/kotlin/apis/Routes.kt b/src/main/kotlin/apis/Routes.kt index 5e29402..737763d 100644 --- a/src/main/kotlin/apis/Routes.kt +++ b/src/main/kotlin/apis/Routes.kt @@ -2,19 +2,15 @@ package moe.nea.firmament.apis -import io.ktor.client.call.* -import io.ktor.client.request.* -import io.ktor.http.* -import io.ktor.util.* -import java.util.* +import io.ktor.client.call.body +import io.ktor.client.request.get +import io.ktor.http.isSuccess +import io.ktor.util.CaseInsensitiveMap +import java.util.UUID import kotlinx.coroutines.Deferred import kotlinx.coroutines.async import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -import kotlin.collections.MutableMap -import kotlin.collections.listOf -import kotlin.collections.mutableMapOf -import kotlin.collections.set import moe.nea.firmament.Firmament import moe.nea.firmament.util.MinecraftDispatcher diff --git a/src/main/kotlin/apis/UrsaManager.kt b/src/main/kotlin/apis/UrsaManager.kt index 13f7aef..19e030c 100644 --- a/src/main/kotlin/apis/UrsaManager.kt +++ b/src/main/kotlin/apis/UrsaManager.kt @@ -2,17 +2,19 @@ package moe.nea.firmament.apis -import io.ktor.client.request.* -import io.ktor.client.statement.* -import io.ktor.http.* +import io.ktor.client.request.get +import io.ktor.client.request.header +import io.ktor.client.statement.HttpResponse +import io.ktor.client.statement.bodyAsText +import io.ktor.http.appendPathSegments +import java.time.Duration +import java.time.Instant +import java.util.UUID import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.withContext -import moe.nea.firmament.Firmament import net.minecraft.client.MinecraftClient -import java.time.Duration -import java.time.Instant -import java.util.* +import moe.nea.firmament.Firmament object UrsaManager { private data class Token( diff --git a/src/main/kotlin/commands/Duration.kt b/src/main/kotlin/commands/Duration.kt index 42f143d..58ce5d8 100644 --- a/src/main/kotlin/commands/Duration.kt +++ b/src/main/kotlin/commands/Duration.kt @@ -7,7 +7,6 @@ import com.mojang.brigadier.exceptions.DynamicCommandExceptionType import com.mojang.brigadier.suggestion.Suggestions import com.mojang.brigadier.suggestion.SuggestionsBuilder import java.util.concurrent.CompletableFuture -import java.util.function.Function import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds import kotlin.time.DurationUnit diff --git a/src/main/kotlin/commands/dsl.kt b/src/main/kotlin/commands/dsl.kt index d1f0d8c..c5955d7 100644 --- a/src/main/kotlin/commands/dsl.kt +++ b/src/main/kotlin/commands/dsl.kt @@ -7,14 +7,14 @@ import com.mojang.brigadier.builder.ArgumentBuilder import com.mojang.brigadier.builder.RequiredArgumentBuilder import com.mojang.brigadier.context.CommandContext import com.mojang.brigadier.suggestion.SuggestionProvider +import java.lang.reflect.ParameterizedType +import java.lang.reflect.Type +import java.lang.reflect.TypeVariable +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource import kotlinx.coroutines.launch import moe.nea.firmament.Firmament import moe.nea.firmament.util.MinecraftDispatcher import moe.nea.firmament.util.iterate -import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource -import java.lang.reflect.ParameterizedType -import java.lang.reflect.Type -import java.lang.reflect.TypeVariable typealias DefaultSource = FabricClientCommandSource diff --git a/src/main/kotlin/commands/rome.kt b/src/main/kotlin/commands/rome.kt index d12da44..b1b2aa2 100644 --- a/src/main/kotlin/commands/rome.kt +++ b/src/main/kotlin/commands/rome.kt @@ -20,7 +20,6 @@ import moe.nea.firmament.features.inventory.storageoverlay.StorageOverviewScreen import moe.nea.firmament.features.mining.MiningBlockInfoUi import moe.nea.firmament.gui.config.AllConfigsGui import moe.nea.firmament.gui.config.BooleanHandler -import moe.nea.firmament.util.data.ManagedConfig import moe.nea.firmament.gui.config.ManagedOption import moe.nea.firmament.init.MixinPlugin import moe.nea.firmament.repo.HypixelStaticData @@ -38,6 +37,7 @@ import moe.nea.firmament.util.accessors.messages import moe.nea.firmament.util.asBazaarStock import moe.nea.firmament.util.collections.InstanceList import moe.nea.firmament.util.collections.WeakCache +import moe.nea.firmament.util.data.ManagedConfig import moe.nea.firmament.util.mc.SNbtFormatter import moe.nea.firmament.util.tr import moe.nea.firmament.util.unformattedString diff --git a/src/main/kotlin/events/AllowChatEvent.kt b/src/main/kotlin/events/AllowChatEvent.kt index 3069843..a1b4828 100644 --- a/src/main/kotlin/events/AllowChatEvent.kt +++ b/src/main/kotlin/events/AllowChatEvent.kt @@ -2,8 +2,8 @@ package moe.nea.firmament.events -import moe.nea.firmament.util.unformattedString import net.minecraft.text.Text +import moe.nea.firmament.util.unformattedString /** * Filter whether the user should see a chat message altogether. May or may not be called for every chat packet sent by diff --git a/src/main/kotlin/events/EntityRenderTintEvent.kt b/src/main/kotlin/events/EntityRenderTintEvent.kt index 29b888b..54cbff2 100644 --- a/src/main/kotlin/events/EntityRenderTintEvent.kt +++ b/src/main/kotlin/events/EntityRenderTintEvent.kt @@ -5,6 +5,7 @@ import net.minecraft.client.render.OverlayTexture import net.minecraft.client.render.entity.state.EntityRenderState import net.minecraft.entity.Entity import net.minecraft.entity.LivingEntity +import moe.nea.firmament.events.EntityRenderTintEvent.Companion.overlayOverride import moe.nea.firmament.util.render.TintedOverlayTexture /** diff --git a/src/main/kotlin/events/FeaturesInitializedEvent.kt b/src/main/kotlin/events/FeaturesInitializedEvent.kt deleted file mode 100644 index ad2ad8a..0000000 --- a/src/main/kotlin/events/FeaturesInitializedEvent.kt +++ /dev/null @@ -1,8 +0,0 @@ - -package moe.nea.firmament.events - -import moe.nea.firmament.features.FirmamentFeature - -data class FeaturesInitializedEvent(val features: List) : FirmamentEvent() { - companion object : FirmamentEventBus() -} diff --git a/src/main/kotlin/events/IsSlotProtectedEvent.kt b/src/main/kotlin/events/IsSlotProtectedEvent.kt index 8fe0a96..6ab0174 100644 --- a/src/main/kotlin/events/IsSlotProtectedEvent.kt +++ b/src/main/kotlin/events/IsSlotProtectedEvent.kt @@ -3,7 +3,6 @@ package moe.nea.firmament.events import net.minecraft.item.ItemStack import net.minecraft.screen.slot.Slot import net.minecraft.screen.slot.SlotActionType -import net.minecraft.text.Text import moe.nea.firmament.util.CommonSoundEffects import moe.nea.firmament.util.MC import moe.nea.firmament.util.grey diff --git a/src/main/kotlin/events/ModifyChatEvent.kt b/src/main/kotlin/events/ModifyChatEvent.kt index a5868e8..4a7025c 100644 --- a/src/main/kotlin/events/ModifyChatEvent.kt +++ b/src/main/kotlin/events/ModifyChatEvent.kt @@ -2,8 +2,8 @@ package moe.nea.firmament.events -import moe.nea.firmament.util.unformattedString import net.minecraft.text.Text +import moe.nea.firmament.util.unformattedString /** * Allow modification of a chat message before it is sent off to the user. Intended for display purposes. diff --git a/src/main/kotlin/events/SlotRenderEvents.kt b/src/main/kotlin/events/SlotRenderEvents.kt index 5234176..9076d53 100644 --- a/src/main/kotlin/events/SlotRenderEvents.kt +++ b/src/main/kotlin/events/SlotRenderEvents.kt @@ -3,11 +3,8 @@ package moe.nea.firmament.events import net.minecraft.client.gui.DrawContext -import net.minecraft.client.render.RenderLayer -import net.minecraft.client.texture.Sprite import net.minecraft.screen.slot.Slot import net.minecraft.util.Identifier -import moe.nea.firmament.util.MC import moe.nea.firmament.util.render.drawGuiTexture interface SlotRenderEvents { diff --git a/src/main/kotlin/events/WorldRenderLastEvent.kt b/src/main/kotlin/events/WorldRenderLastEvent.kt index 3c2103d..93d7e8c 100644 --- a/src/main/kotlin/events/WorldRenderLastEvent.kt +++ b/src/main/kotlin/events/WorldRenderLastEvent.kt @@ -3,13 +3,9 @@ package moe.nea.firmament.events import net.minecraft.client.render.Camera -import net.minecraft.client.render.GameRenderer -import net.minecraft.client.render.LightmapTextureManager import net.minecraft.client.render.RenderTickCounter import net.minecraft.client.render.VertexConsumerProvider import net.minecraft.client.util.math.MatrixStack -import net.minecraft.util.math.Position -import net.minecraft.util.math.Vec3d /** * This event is called after all world rendering is done, but before any GUI rendering (including hand) has been done. diff --git a/src/main/kotlin/events/subscription/Subscription.kt b/src/main/kotlin/events/subscription/Subscription.kt index 1c1d3bd..812da92 100644 --- a/src/main/kotlin/events/subscription/Subscription.kt +++ b/src/main/kotlin/events/subscription/Subscription.kt @@ -3,11 +3,7 @@ package moe.nea.firmament.events.subscription import moe.nea.firmament.events.FirmamentEvent import moe.nea.firmament.events.FirmamentEventBus -import moe.nea.firmament.features.FirmamentFeature -interface SubscriptionOwner { - val delegateFeature: FirmamentFeature -} data class Subscription( val owner: Any, 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(serializer(), "features", ::Config) { - @Serializable - data class Config( - val enabledFeatures: MutableMap = mutableMapOf() - ) - - private val features = mutableMapOf() - - val allFeatures: Collection 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(serializer(), "feature private fun subscribeSingleEvent(it: Subscription) { 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() 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") } + @Config object EnabledLogs : DataHolder>(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( - val obj: T, - val timer: TimeMark, - ) - - private val storedVariables: MutableMap> = sortedMapOf() - override val identifier: String - get() = "debug-view" - override val defaultEnabled: Boolean - get() = Firmament.DEBUG - - fun 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 { - 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? = 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() @@ -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 = 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(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 (?.*) 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() - - fun ObservableList.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 = "\\+(?$SHORT_NUMBER_FORMAT) (?[^ ]+) XP".toPattern() - val coinReward = "(?i)\\+(?$SHORT_NUMBER_FORMAT) Coins".toPattern() - val itemReward = "(?:(?[0-9]+)x )?(?.*)".toPattern() - fun parseReward(string: String): Reward { - expReward.useMatch(string) { - val exp = parseShortNumber(group("exp")) - val kind = group("kind") - return Reward.EXP(exp, kind) - } - coinReward.useMatch(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(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 (?.*) 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() + + fun ObservableList.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 = "\\+(?$SHORT_NUMBER_FORMAT) (?[^ ]+) XP".toPattern() + val coinReward = "(?i)\\+(?$SHORT_NUMBER_FORMAT) Coins".toPattern() + val itemReward = "(?:(?[0-9]+)x )?(?.*)".toPattern() + fun parseReward(string: String): Reward { + expReward.useMatch(string) { + val exp = parseShortNumber(group("exp")) + val kind = group("kind") + return Reward.EXP(exp, kind) + } + coinReward.useMatch(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(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(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