From c93a04a001b0f66b2724d46b04b6d1ed49a08d07 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Mon, 17 Nov 2025 19:55:02 +0100 Subject: refactor: port to mojmaps --- src/main/kotlin/Firmament.kt | 10 +- src/main/kotlin/apis/Profiles.kt | 6 +- src/main/kotlin/apis/UrsaManager.kt | 8 +- src/main/kotlin/commands/rome.kt | 94 +++++----- src/main/kotlin/events/AllowChatEvent.kt | 4 +- src/main/kotlin/events/AttackBlockEvent.kt | 16 +- .../kotlin/events/ChestInventoryUpdateEvent.kt | 2 +- src/main/kotlin/events/CommandEvent.kt | 6 +- src/main/kotlin/events/CustomItemModelEvent.kt | 36 ++-- src/main/kotlin/events/EarlyResourceReloadEvent.kt | 2 +- src/main/kotlin/events/EntityDespawnEvent.kt | 2 +- src/main/kotlin/events/EntityInteractionEvent.kt | 6 +- src/main/kotlin/events/EntityRenderTintEvent.kt | 14 +- src/main/kotlin/events/EntityUpdateEvent.kt | 26 +-- .../kotlin/events/FinalizeResourceManagerEvent.kt | 20 +- src/main/kotlin/events/HandledScreenClickEvent.kt | 4 +- .../kotlin/events/HandledScreenForegroundEvent.kt | 8 +- .../kotlin/events/HandledScreenKeyPressedEvent.kt | 16 +- .../kotlin/events/HandledScreenPushREIEvent.kt | 4 +- src/main/kotlin/events/HotbarItemRenderEvent.kt | 16 +- src/main/kotlin/events/HudRenderEvent.kt | 12 +- src/main/kotlin/events/IsSlotProtectedEvent.kt | 28 +-- src/main/kotlin/events/ItemTooltipEvent.kt | 10 +- src/main/kotlin/events/JoinServerEvent.kt | 6 +- src/main/kotlin/events/ModifyChatEvent.kt | 6 +- src/main/kotlin/events/OutgoingPacketEvent.kt | 2 +- src/main/kotlin/events/ParticleSpawnEvent.kt | 8 +- src/main/kotlin/events/PlayerInventoryUpdate.kt | 2 +- src/main/kotlin/events/ProcessChatEvent.kt | 4 +- src/main/kotlin/events/ScreenChangeEvent.kt | 2 +- src/main/kotlin/events/ScreenRenderPostEvent.kt | 6 +- src/main/kotlin/events/ServerConnectedEvent.kt | 10 +- src/main/kotlin/events/SlotClickEvent.kt | 8 +- src/main/kotlin/events/SlotRenderEvents.kt | 14 +- src/main/kotlin/events/SoundReceiveEvent.kt | 14 +- src/main/kotlin/events/UseBlockEvent.kt | 10 +- src/main/kotlin/events/UseItemEvent.kt | 12 +- src/main/kotlin/events/WorldRenderLastEvent.kt | 14 +- src/main/kotlin/events/registration/ChatEvents.kt | 22 +-- src/main/kotlin/features/chat/AutoCompletions.kt | 2 +- src/main/kotlin/features/chat/ChatLinks.kt | 48 ++--- src/main/kotlin/features/chat/CopyChat.kt | 4 +- src/main/kotlin/features/chat/PartyCommands.kt | 4 +- src/main/kotlin/features/chat/QuickCommands.kt | 26 +-- .../features/debug/AnimatedClothingScanner.kt | 34 ++-- src/main/kotlin/features/debug/DebugLogger.kt | 4 +- .../kotlin/features/debug/DeveloperFeatures.kt | 12 +- .../features/debug/ExportedTestConstantMeta.kt | 2 +- src/main/kotlin/features/debug/MinorTrolling.kt | 4 +- src/main/kotlin/features/debug/PowerUserTools.kt | 134 +++++++------- src/main/kotlin/features/debug/SkinPreviews.kt | 18 +- src/main/kotlin/features/debug/SoundVisualizer.kt | 4 +- .../features/debug/itemeditor/ExportRecipe.kt | 30 +-- .../features/debug/itemeditor/ItemExporter.kt | 20 +- .../features/debug/itemeditor/LegacyItemData.kt | 8 +- .../debug/itemeditor/LegacyItemExporter.kt | 98 +++++----- .../kotlin/features/diana/AncestralSpadeSolver.kt | 16 +- .../kotlin/features/diana/NearbyBurrowsSolver.kt | 12 +- .../events/anniversity/AnniversaryFeatures.kt | 30 +-- .../events/anniversity/CenturyRaffleFeatures.kt | 28 +-- .../features/events/carnival/MinesweeperHelper.kt | 38 ++-- src/main/kotlin/features/fixes/Fixes.kt | 30 +-- .../kotlin/features/garden/HideComposterNoises.kt | 14 +- .../kotlin/features/inventory/CraftingOverlay.kt | 26 +-- .../features/inventory/ItemRarityCosmetics.kt | 18 +- .../kotlin/features/inventory/JunkHighlighter.kt | 2 +- src/main/kotlin/features/inventory/PetFeatures.kt | 134 +++++++------- src/main/kotlin/features/inventory/PriceData.kt | 18 +- .../features/inventory/REIDependencyWarner.kt | 26 +-- .../features/inventory/SaveCursorPosition.kt | 6 +- src/main/kotlin/features/inventory/SlotLocking.kt | 128 ++++++------- src/main/kotlin/features/inventory/TimerInLore.kt | 12 +- .../kotlin/features/inventory/WardrobeKeybinds.kt | 12 +- .../features/inventory/buttons/InventoryButton.kt | 42 ++--- .../inventory/buttons/InventoryButtonEditor.kt | 116 ++++++------ .../inventory/buttons/InventoryButtonTemplates.kt | 4 +- .../features/inventory/buttons/InventoryButtons.kt | 30 +-- .../storageoverlay/StorageBackingHandle.kt | 20 +- .../inventory/storageoverlay/StorageOverlay.kt | 30 +-- .../storageoverlay/StorageOverlayCustom.kt | 52 +++--- .../storageoverlay/StorageOverlayScreen.kt | 142 +++++++------- .../storageoverlay/StorageOverviewScreen.kt | 54 +++--- .../inventory/storageoverlay/VirtualInventory.kt | 22 +-- .../kotlin/features/items/BlockZapperOverlay.kt | 24 +-- .../kotlin/features/items/BonemerangOverlay.kt | 36 ++-- src/main/kotlin/features/items/EtherwarpOverlay.kt | 76 ++++---- src/main/kotlin/features/macros/ComboProcessor.kt | 22 +-- src/main/kotlin/features/macros/HotkeyAction.kt | 8 +- src/main/kotlin/features/macros/KeyComboTrie.kt | 10 +- src/main/kotlin/features/macros/MacroUI.kt | 8 +- src/main/kotlin/features/macros/RadialMenu.kt | 14 +- .../kotlin/features/mining/CommissionFeatures.kt | 2 +- src/main/kotlin/features/mining/HotmPresets.kt | 60 +++--- .../kotlin/features/mining/MiningBlockInfoUi.kt | 4 +- src/main/kotlin/features/mining/PickaxeAbility.kt | 42 ++--- .../features/mining/PristineProfitTracker.kt | 6 +- src/main/kotlin/features/misc/CustomCapes.kt | 80 ++++---- src/main/kotlin/features/misc/Hud.kt | 46 ++--- src/main/kotlin/features/misc/LicenseViewer.kt | 16 +- src/main/kotlin/features/misc/ModAnnouncer.kt | 28 +-- src/main/kotlin/features/world/ColeWeightCompat.kt | 24 +-- src/main/kotlin/features/world/FairySouls.kt | 4 +- .../kotlin/features/world/FirmWaypointManager.kt | 10 +- src/main/kotlin/features/world/FirmWaypoints.kt | 2 +- .../kotlin/features/world/NavigableWaypoint.kt | 2 +- src/main/kotlin/features/world/NavigationHelper.kt | 24 +-- src/main/kotlin/features/world/NpcWaypointGui.kt | 4 +- .../kotlin/features/world/TemporaryWaypoints.kt | 14 +- src/main/kotlin/features/world/Waypoints.kt | 46 ++--- src/main/kotlin/gui/BarComponent.kt | 32 ++-- src/main/kotlin/gui/CheckboxComponent.kt | 4 +- src/main/kotlin/gui/config/AllConfigsGui.kt | 8 +- .../gui/config/BuiltInConfigScreenProvider.kt | 2 +- src/main/kotlin/gui/config/ChoiceHandler.kt | 6 +- src/main/kotlin/gui/config/EnumRenderer.kt | 8 +- .../gui/config/FirmamentConfigScreenProvider.kt | 2 +- src/main/kotlin/gui/config/GuiAppender.kt | 6 +- src/main/kotlin/gui/config/HudMetaHandler.kt | 18 +- src/main/kotlin/gui/config/JAnyHud.kt | 18 +- .../kotlin/gui/config/KeyBindingStateManager.kt | 10 +- src/main/kotlin/gui/config/ManagedOption.kt | 6 +- src/main/kotlin/gui/config/StringHandler.kt | 4 +- src/main/kotlin/gui/entity/EntityModifier.kt | 2 +- src/main/kotlin/gui/entity/EntityRenderer.kt | 68 +++---- src/main/kotlin/gui/entity/GuiPlayer.kt | 22 +-- src/main/kotlin/gui/entity/ModifyAge.kt | 16 +- src/main/kotlin/gui/entity/ModifyCharged.kt | 8 +- src/main/kotlin/gui/entity/ModifyEquipment.kt | 18 +- src/main/kotlin/gui/entity/ModifyHorse.kt | 42 +++-- src/main/kotlin/gui/entity/ModifyInvisible.kt | 2 +- src/main/kotlin/gui/entity/ModifyName.kt | 6 +- src/main/kotlin/gui/entity/ModifyPlayerSkin.kt | 38 ++-- src/main/kotlin/gui/entity/ModifyRiding.kt | 2 +- src/main/kotlin/gui/entity/ModifyWither.kt | 8 +- src/main/kotlin/gui/hud/MoulConfigHud.kt | 20 +- src/main/kotlin/jarvis/JarvisIntegration.kt | 8 +- .../kotlin/keybindings/FirmamentKeyBindings.kt | 12 +- .../kotlin/keybindings/FirmamentKeyboardState.kt | 4 +- src/main/kotlin/keybindings/GenericInputButton.kt | 80 ++++---- src/main/kotlin/keybindings/SavedKeyBinding.kt | 6 +- src/main/kotlin/repo/ItemCache.kt | 82 ++++---- src/main/kotlin/repo/MiningRepoData.kt | 14 +- src/main/kotlin/repo/Reforge.kt | 18 +- src/main/kotlin/repo/ReforgeStore.kt | 8 +- src/main/kotlin/repo/RepoManager.kt | 16 +- src/main/kotlin/repo/RepoModResourcePack.kt | 74 ++++---- src/main/kotlin/repo/SBItemStack.kt | 146 +++++++-------- .../kotlin/repo/recipes/GenericRecipeRenderer.kt | 10 +- src/main/kotlin/repo/recipes/RecipeLayouter.kt | 6 +- .../repo/recipes/SBCraftingRecipeRenderer.kt | 14 +- .../repo/recipes/SBEssenceUpgradeRecipeRenderer.kt | 10 +- .../kotlin/repo/recipes/SBForgeRecipeRenderer.kt | 20 +- src/main/kotlin/util/CommonSoundEffects.kt | 14 +- src/main/kotlin/util/DurabilityBarEvent.kt | 2 +- src/main/kotlin/util/FirmFormatters.kt | 14 +- src/main/kotlin/util/FragmentGuiScreen.kt | 28 +-- src/main/kotlin/util/HoveredItemStack.kt | 12 +- src/main/kotlin/util/IdentifierSerializer.kt | 10 +- src/main/kotlin/util/LegacyFormattingCode.kt | 4 +- src/main/kotlin/util/LegacyTagParser.kt | 52 +++--- src/main/kotlin/util/LegacyTagWriter.kt | 54 +++--- src/main/kotlin/util/LoadResource.kt | 6 +- src/main/kotlin/util/MC.kt | 126 ++++++------- src/main/kotlin/util/MinecraftDispatcher.kt | 4 +- src/main/kotlin/util/MoulConfigFragment.kt | 14 +- src/main/kotlin/util/MoulConfigUtils.kt | 26 +-- src/main/kotlin/util/ScoreboardUtil.kt | 42 ++--- src/main/kotlin/util/ScreenUtil.kt | 10 +- src/main/kotlin/util/SkyblockId.kt | 46 ++--- src/main/kotlin/util/WarpUtil.kt | 22 +-- src/main/kotlin/util/accessors/GetRectangle.kt | 4 +- src/main/kotlin/util/accessors/chathud.kt | 6 +- src/main/kotlin/util/async/input.kt | 2 +- src/main/kotlin/util/colorconversion.kt | 8 +- .../kotlin/util/customgui/CoordRememberingSlot.kt | 2 +- src/main/kotlin/util/customgui/CustomGui.kt | 34 ++-- src/main/kotlin/util/customgui/HasCustomGui.kt | 4 +- src/main/kotlin/util/json/BlockPosSerializer.kt | 2 +- src/main/kotlin/util/json/FirmCodecs.kt | 4 +- src/main/kotlin/util/math/Projections.kt | 12 +- src/main/kotlin/util/mc/ArmorUtil.kt | 6 +- src/main/kotlin/util/mc/CustomRenderPassHelper.kt | 46 ++--- src/main/kotlin/util/mc/FakeInventory.kt | 24 +-- src/main/kotlin/util/mc/FakeSlot.kt | 12 +- .../kotlin/util/mc/FirmamentDataComponentTypes.kt | 28 +-- .../util/mc/IntrospectableItemModelManager.kt | 4 +- src/main/kotlin/util/mc/InventoryUtil.kt | 14 +- src/main/kotlin/util/mc/ItemUtil.kt | 18 +- src/main/kotlin/util/mc/MCTabListAPI.kt | 32 ++-- src/main/kotlin/util/mc/NbtItemData.kt | 24 +-- src/main/kotlin/util/mc/NbtPrism.kt | 20 +- src/main/kotlin/util/mc/NbtUtil.kt | 10 +- src/main/kotlin/util/mc/PlayerUtil.kt | 6 +- src/main/kotlin/util/mc/SNbtFormatter.kt | 80 ++++---- src/main/kotlin/util/mc/ScreenUtil.kt | 16 +- src/main/kotlin/util/mc/SkullItemData.kt | 12 +- src/main/kotlin/util/mc/SlotUtils.kt | 44 ++--- src/main/kotlin/util/mc/TolerantRegistriesOps.kt | 24 +-- src/main/kotlin/util/mc/asFakeServer.kt | 24 +-- src/main/kotlin/util/render/CustomRenderLayers.kt | 68 +++---- src/main/kotlin/util/render/DrawContextExt.kt | 108 +++++------ src/main/kotlin/util/render/DumpTexture.kt | 6 +- .../kotlin/util/render/FacingThePlayerContext.kt | 94 +++++----- .../util/render/MultiSpecialGuiRenderState.kt | 36 ++-- .../kotlin/util/render/RenderCircleProgress.kt | 88 ++++----- .../kotlin/util/render/RenderInWorldContext.kt | 206 ++++++++++----------- .../kotlin/util/render/TintedOverlayTexture.kt | 10 +- src/main/kotlin/util/render/TranslatedScissors.kt | 8 +- src/main/kotlin/util/skyblock/AbilityUtils.kt | 12 +- src/main/kotlin/util/skyblock/ItemType.kt | 2 +- src/main/kotlin/util/skyblock/PartyUtil.kt | 6 +- src/main/kotlin/util/skyblock/Rarity.kt | 34 ++-- src/main/kotlin/util/skyblock/SBItemUtil.kt | 4 +- src/main/kotlin/util/skyblock/SackUtil.kt | 18 +- .../kotlin/util/skyblock/ScreenIdentification.kt | 14 +- src/main/kotlin/util/skyblock/TabListAPI.kt | 6 +- src/main/kotlin/util/textutil.kt | 114 ++++++------ 217 files changed, 2682 insertions(+), 2680 deletions(-) (limited to 'src/main/kotlin') diff --git a/src/main/kotlin/Firmament.kt b/src/main/kotlin/Firmament.kt index e707667..72f386d 100644 --- a/src/main/kotlin/Firmament.kt +++ b/src/main/kotlin/Firmament.kt @@ -27,8 +27,8 @@ import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.json.Json import kotlinx.serialization.json.decodeFromStream import kotlin.coroutines.EmptyCoroutineContext -import net.minecraft.command.CommandRegistryAccess -import net.minecraft.util.Identifier +import net.minecraft.commands.CommandBuildContext +import net.minecraft.resources.ResourceLocation import moe.nea.firmament.commands.registerFirmamentCommand import moe.nea.firmament.events.ClientInitEvent import moe.nea.firmament.events.ClientStartedEvent @@ -93,10 +93,10 @@ object Firmament { private fun registerCommands( dispatcher: CommandDispatcher, @Suppress("UNUSED_PARAMETER") - ctx: CommandRegistryAccess + ctx: CommandBuildContext ) { registerFirmamentCommand(dispatcher, ctx) - CommandEvent.publish(CommandEvent(dispatcher, ctx, MC.networkHandler?.commandDispatcher)) + CommandEvent.publish(CommandEvent(dispatcher, ctx, MC.networkHandler?.commands)) } @JvmStatic @@ -142,7 +142,7 @@ object Firmament { } - fun identifier(path: String) = Identifier.of(MOD_ID, path) + fun identifier(path: String) = ResourceLocation.fromNamespaceAndPath(MOD_ID, path) inline fun tryDecodeJsonFromStream(inputStream: InputStream): Result { return runCatching { json.decodeFromStream(inputStream) diff --git a/src/main/kotlin/apis/Profiles.kt b/src/main/kotlin/apis/Profiles.kt index ec4a6e4..f36fbb2 100644 --- a/src/main/kotlin/apis/Profiles.kt +++ b/src/main/kotlin/apis/Profiles.kt @@ -12,8 +12,8 @@ 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 net.minecraft.world.item.DyeColor +import net.minecraft.ChatFormatting import moe.nea.firmament.repo.RepoManager import moe.nea.firmament.util.LegacyFormattingCode import moe.nea.firmament.util.SkyblockId @@ -182,7 +182,7 @@ data class PlayerData( fun getDisplayName(name: String = playerName) = rankData?.let { ("§${it.color}[${it.tag}${rankPlusDyeColor.modern}" + "${it.plus ?: ""}§${it.color}] $name") - } ?: "${Formatting.GRAY}$name" + } ?: "${ChatFormatting.GRAY}$name" } diff --git a/src/main/kotlin/apis/UrsaManager.kt b/src/main/kotlin/apis/UrsaManager.kt index e5d519e..31ac36b 100644 --- a/src/main/kotlin/apis/UrsaManager.kt +++ b/src/main/kotlin/apis/UrsaManager.kt @@ -12,7 +12,7 @@ import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.withContext import kotlinx.serialization.DeserializationStrategy import kotlin.jvm.optionals.getOrNull -import net.minecraft.client.MinecraftClient +import net.minecraft.client.Minecraft import moe.nea.firmament.Firmament import moe.nea.firmament.util.net.HttpUtil @@ -46,10 +46,10 @@ object UrsaManager { val request = HttpUtil.request(url) if (token == null) { withContext(Dispatchers.IO) { - val mc = MinecraftClient.getInstance() + val mc = Minecraft.getInstance() val serverId = UUID.randomUUID().toString() - mc.apiServices.sessionService.joinServer(mc.session.uuidOrNull, mc.session.accessToken, serverId) - request.header("x-ursa-username", mc.session.username) + mc.services().sessionService.joinServer(mc.user.profileId, mc.user.accessToken, serverId) + request.header("x-ursa-username", mc.user.name) request.header("x-ursa-serverid", serverId) } } else { diff --git a/src/main/kotlin/commands/rome.kt b/src/main/kotlin/commands/rome.kt index af2cebb..727e039 100644 --- a/src/main/kotlin/commands/rome.kt +++ b/src/main/kotlin/commands/rome.kt @@ -6,10 +6,10 @@ import com.mojang.brigadier.arguments.StringArgumentType.string import java.net.http.HttpResponse import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource import kotlinx.coroutines.launch -import net.minecraft.command.CommandRegistryAccess +import net.minecraft.commands.CommandBuildContext import net.minecraft.nbt.NbtOps -import net.minecraft.text.Text -import net.minecraft.text.TextCodecs +import net.minecraft.network.chat.Component +import net.minecraft.network.chat.ComponentSerialization import moe.nea.firmament.Firmament import moe.nea.firmament.apis.UrsaManager import moe.nea.firmament.events.CommandEvent @@ -46,7 +46,7 @@ import moe.nea.firmament.util.tr import moe.nea.firmament.util.unformattedString -fun firmamentCommand(ctx: CommandRegistryAccess) = literal("firmament") { +fun firmamentCommand(ctx: CommandBuildContext) = literal("firmament") { thenLiteral("config") { thenExecute { AllConfigsGui.showAllGuis() @@ -71,7 +71,7 @@ fun firmamentCommand(ctx: CommandRegistryAccess) = literal("firmament") { val configObj = ManagedConfig.allManagedConfigs.getAll().find { it.name == config } if (configObj == null) { source.sendFeedback( - Text.stringifiedTranslatable( + Component.translatableEscape( "firmament.command.toggle.no-config-found", config ) @@ -81,13 +81,13 @@ fun firmamentCommand(ctx: CommandRegistryAccess) = literal("firmament") { val propertyObj = configObj.allOptions[property] if (propertyObj == null) { source.sendFeedback( - Text.stringifiedTranslatable("firmament.command.toggle.no-property-found", property) + Component.translatableEscape("firmament.command.toggle.no-property-found", property) ) return@thenExecute } if (propertyObj.handler !is BooleanHandler) { source.sendFeedback( - Text.stringifiedTranslatable("firmament.command.toggle.not-a-toggle", property) + Component.translatableEscape("firmament.command.toggle.not-a-toggle", property) ) return@thenExecute } @@ -95,10 +95,10 @@ fun firmamentCommand(ctx: CommandRegistryAccess) = literal("firmament") { propertyObj.value = !propertyObj.value configObj.markDirty() source.sendFeedback( - Text.stringifiedTranslatable( + Component.translatableEscape( "firmament.command.toggle.toggled", configObj.labelText, propertyObj.labelText, - Text.translatable("firmament.toggle.${propertyObj.value}") + Component.translatable("firmament.toggle.${propertyObj.value}") ) ) } @@ -126,13 +126,13 @@ fun firmamentCommand(ctx: CommandRegistryAccess) = literal("firmament") { thenLiteral("storageoverview") { thenExecute { ScreenUtil.setScreenLater(StorageOverviewScreen()) - MC.player?.networkHandler?.sendChatCommand("storage") + MC.player?.connection?.sendCommand("storage") } } thenLiteral("storage") { thenExecute { ScreenUtil.setScreenLater(StorageOverlayScreen()) - MC.player?.networkHandler?.sendChatCommand("storage") + MC.player?.connection?.sendCommand("storage") } } thenLiteral("repo") { @@ -148,12 +148,12 @@ fun firmamentCommand(ctx: CommandRegistryAccess) = literal("firmament") { thenLiteral("reload") { thenLiteral("fetch") { thenExecute { - source.sendFeedback(Text.translatable("firmament.repo.reload.network")) // TODO better reporting + source.sendFeedback(Component.translatable("firmament.repo.reload.network")) // TODO better reporting RepoManager.launchAsyncUpdate() } } thenExecute { - source.sendFeedback(Text.translatable("firmament.repo.reload.disk")) + source.sendFeedback(Component.translatable("firmament.repo.reload.disk")) Firmament.coroutineScope.launch { RepoManager.reload() } } } @@ -163,33 +163,33 @@ fun firmamentCommand(ctx: CommandRegistryAccess) = literal("firmament") { suggestsList { RepoManager.neuRepo.items.items.keys } thenExecute { val itemName = SkyblockId(get(item)) - source.sendFeedback(Text.stringifiedTranslatable("firmament.price", itemName.neuItem)) + source.sendFeedback(Component.translatableEscape("firmament.price", itemName.neuItem)) val bazaarData = HypixelStaticData.bazaarData[itemName.asBazaarStock] if (bazaarData != null) { - source.sendFeedback(Text.translatable("firmament.price.bazaar")) + source.sendFeedback(Component.translatable("firmament.price.bazaar")) source.sendFeedback( - Text.stringifiedTranslatable("firmament.price.bazaar.productid", bazaarData.productId.bazaarId) + Component.translatableEscape("firmament.price.bazaar.productid", bazaarData.productId.bazaarId) ) source.sendFeedback( - Text.stringifiedTranslatable( + Component.translatableEscape( "firmament.price.bazaar.buy.price", FirmFormatters.formatCommas(bazaarData.quickStatus.buyPrice, 1) ) ) source.sendFeedback( - Text.stringifiedTranslatable( + Component.translatableEscape( "firmament.price.bazaar.buy.order", bazaarData.quickStatus.buyOrders ) ) source.sendFeedback( - Text.stringifiedTranslatable( + Component.translatableEscape( "firmament.price.bazaar.sell.price", FirmFormatters.formatCommas(bazaarData.quickStatus.sellPrice, 1) ) ) source.sendFeedback( - Text.stringifiedTranslatable( + Component.translatableEscape( "firmament.price.bazaar.sell.order", bazaarData.quickStatus.sellOrders ) @@ -198,7 +198,7 @@ fun firmamentCommand(ctx: CommandRegistryAccess) = literal("firmament") { val lowestBin = HypixelStaticData.lowestBin[itemName] if (lowestBin != null) { source.sendFeedback( - Text.stringifiedTranslatable( + Component.translatableEscape( "firmament.price.lowestbin", FirmFormatters.formatCommas(lowestBin, 1) ) @@ -211,7 +211,7 @@ fun firmamentCommand(ctx: CommandRegistryAccess) = literal("firmament") { thenLiteral("simulate") { thenArgument("message", RestArgumentType) { message -> thenExecute { - MC.instance.messageHandler.onGameMessage(Text.literal(get(message)), false) + MC.instance.chatListener.handleSystemMessage(Component.literal(get(message)), false) } } } @@ -224,10 +224,10 @@ fun firmamentCommand(ctx: CommandRegistryAccess) = literal("firmament") { val enabled = DebugLogger.EnabledLogs.data if (tagText in enabled) { enabled.remove(tagText) - source.sendFeedback(Text.literal("Disabled $tagText debug logging")) + source.sendFeedback(Component.literal("Disabled $tagText debug logging")) } else { enabled.add(tagText) - source.sendFeedback(Text.literal("Enabled $tagText debug logging")) + source.sendFeedback(Component.literal("Enabled $tagText debug logging")) } } } @@ -236,11 +236,11 @@ fun firmamentCommand(ctx: CommandRegistryAccess) = literal("firmament") { thenLiteral("screens") { thenExecute { MC.sendChat( - Text.literal( + Component.literal( """ |Screen: ${MC.screen} (${MC.screen?.title}) - |Screen Handler: ${MC.handledScreen?.screenHandler} ${MC.handledScreen?.screenHandler?.syncId} - |Player Screen Handler: ${MC.player?.currentScreenHandler} ${MC.player?.currentScreenHandler?.syncId} + |Screen Handler: ${MC.handledScreen?.menu} ${MC.handledScreen?.menu?.containerId} + |Player Screen Handler: ${MC.player?.containerMenu} ${MC.player?.containerMenu?.containerId} """.trimMargin() ) ) @@ -253,17 +253,17 @@ fun firmamentCommand(ctx: CommandRegistryAccess) = literal("firmament") { } thenLiteral("dumpchat") { thenExecute { - MC.inGameHud.chatHud.messages.forEach { - val nbt = TextCodecs.CODEC.encodeStart(NbtOps.INSTANCE, it.content).orThrow + MC.inGameHud.chat.messages.forEach { + val nbt = ComponentSerialization.CODEC.encodeStart(NbtOps.INSTANCE, it.content).orThrow println(nbt) } } thenArgument("search", string()) { search -> thenExecute { - MC.inGameHud.chatHud.messages + MC.inGameHud.chat.messages .filter { this[search] in it.content.unformattedString } .forEach { - val nbt = TextCodecs.CODEC.encodeStart(NbtOps.INSTANCE, it.content).orThrow + val nbt = ComponentSerialization.CODEC.encodeStart(NbtOps.INSTANCE, it.content).orThrow println(SNbtFormatter.prettify(nbt)) } } @@ -271,15 +271,15 @@ fun firmamentCommand(ctx: CommandRegistryAccess) = literal("firmament") { } thenLiteral("sbdata") { thenExecute { - source.sendFeedback(Text.stringifiedTranslatable("firmament.sbinfo.profile", SBData.profileId)) + source.sendFeedback(Component.translatableEscape("firmament.sbinfo.profile", SBData.profileId)) val locrawInfo = SBData.locraw if (locrawInfo == null) { - source.sendFeedback(Text.translatable("firmament.sbinfo.nolocraw")) + source.sendFeedback(Component.translatable("firmament.sbinfo.nolocraw")) } else { - source.sendFeedback(Text.stringifiedTranslatable("firmament.sbinfo.server", locrawInfo.server)) - source.sendFeedback(Text.stringifiedTranslatable("firmament.sbinfo.gametype", locrawInfo.gametype)) - source.sendFeedback(Text.stringifiedTranslatable("firmament.sbinfo.mode", locrawInfo.mode)) - source.sendFeedback(Text.stringifiedTranslatable("firmament.sbinfo.map", locrawInfo.map)) + source.sendFeedback(Component.translatableEscape("firmament.sbinfo.server", locrawInfo.server)) + source.sendFeedback(Component.translatableEscape("firmament.sbinfo.gametype", locrawInfo.gametype)) + source.sendFeedback(Component.translatableEscape("firmament.sbinfo.mode", locrawInfo.mode)) + source.sendFeedback(Component.translatableEscape("firmament.sbinfo.map", locrawInfo.map)) source.sendFeedback( tr( "firmament.sbinfo.custommining", @@ -292,7 +292,7 @@ fun firmamentCommand(ctx: CommandRegistryAccess) = literal("firmament") { thenLiteral("copyEntities") { thenExecute { val player = MC.player ?: return@thenExecute - player.world.getOtherEntities(player, player.boundingBox.expand(12.0)) + player.level.getEntities(player, player.boundingBox.inflate(12.0)) .forEach(PowerUserTools::showEntity) PowerUserTools.showEntity(player) } @@ -301,9 +301,9 @@ fun firmamentCommand(ctx: CommandRegistryAccess) = literal("firmament") { thenArgument("path", string()) { path -> thenExecute { Firmament.coroutineScope.launch { - source.sendFeedback(Text.translatable("firmament.ursa.debugrequest.start")) + source.sendFeedback(Component.translatable("firmament.ursa.debugrequest.start")) val text = UrsaManager.request(get(path).split("/"), HttpResponse.BodyHandlers.ofString()) - source.sendFeedback(Text.stringifiedTranslatable("firmament.ursa.debugrequest.result", text)) + source.sendFeedback(Component.translatableEscape("firmament.ursa.debugrequest.result", text)) } } } @@ -332,13 +332,13 @@ fun firmamentCommand(ctx: CommandRegistryAccess) = literal("firmament") { } thenLiteral("caches") { thenExecute { - source.sendFeedback(Text.literal("Caches:")) + source.sendFeedback(Component.literal("Caches:")) WeakCache.allInstances.getAll().forEach { - source.sendFeedback(Text.literal(" - ${it.name}: ${it.size}")) + source.sendFeedback(Component.literal(" - ${it.name}: ${it.size}")) } - source.sendFeedback(Text.translatable("Instance lists:")) + source.sendFeedback(Component.translatable("Instance lists:")) InstanceList.allInstances.getAll().forEach { - source.sendFeedback(Text.literal(" - ${it.name}: ${it.size}")) + source.sendFeedback(Component.literal(" - ${it.name}: ${it.size}")) } } } @@ -350,8 +350,8 @@ fun firmamentCommand(ctx: CommandRegistryAccess) = literal("firmament") { .map { it.removePrefix(plugin.mixinPackage) } .forEach { source.sendFeedback( - Text.literal(" - ").withColor(0xD020F0) - .append(Text.literal(it).withColor(0xF6BA20)) + Component.literal(" - ").withColor(0xD020F0) + .append(Component.literal(it).withColor(0xF6BA20)) ) } } @@ -417,7 +417,7 @@ fun firmamentCommand(ctx: CommandRegistryAccess) = literal("firmament") { } -fun registerFirmamentCommand(dispatcher: CommandDispatcher, ctx: CommandRegistryAccess) { +fun registerFirmamentCommand(dispatcher: CommandDispatcher, ctx: CommandBuildContext) { val firmament = dispatcher.register(firmamentCommand(ctx)) dispatcher.register(literal("firm") { redirect(firmament) diff --git a/src/main/kotlin/events/AllowChatEvent.kt b/src/main/kotlin/events/AllowChatEvent.kt index a1b4828..86395c9 100644 --- a/src/main/kotlin/events/AllowChatEvent.kt +++ b/src/main/kotlin/events/AllowChatEvent.kt @@ -2,14 +2,14 @@ package moe.nea.firmament.events -import net.minecraft.text.Text +import net.minecraft.network.chat.Component 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 * the server. When that quality is desired, consider [ProcessChatEvent] instead. */ -data class AllowChatEvent(val text: Text) : FirmamentEvent.Cancellable() { +data class AllowChatEvent(val text: Component) : FirmamentEvent.Cancellable() { val unformattedString = text.unformattedString companion object : FirmamentEventBus() diff --git a/src/main/kotlin/events/AttackBlockEvent.kt b/src/main/kotlin/events/AttackBlockEvent.kt index bbaa81d..81a2952 100644 --- a/src/main/kotlin/events/AttackBlockEvent.kt +++ b/src/main/kotlin/events/AttackBlockEvent.kt @@ -1,16 +1,16 @@ package moe.nea.firmament.events -import net.minecraft.entity.player.PlayerEntity -import net.minecraft.util.Hand -import net.minecraft.util.math.BlockPos -import net.minecraft.util.math.Direction -import net.minecraft.world.World +import net.minecraft.world.entity.player.Player +import net.minecraft.world.InteractionHand +import net.minecraft.core.BlockPos +import net.minecraft.core.Direction +import net.minecraft.world.level.Level data class AttackBlockEvent( - val player: PlayerEntity, - val world: World, - val hand: Hand, + val player: Player, + val world: Level, + val hand: InteractionHand, val blockPos: BlockPos, val direction: Direction ) : FirmamentEvent.Cancellable() { diff --git a/src/main/kotlin/events/ChestInventoryUpdateEvent.kt b/src/main/kotlin/events/ChestInventoryUpdateEvent.kt index ddf54fc..e3acd12 100644 --- a/src/main/kotlin/events/ChestInventoryUpdateEvent.kt +++ b/src/main/kotlin/events/ChestInventoryUpdateEvent.kt @@ -1,6 +1,6 @@ package moe.nea.firmament.events -import net.minecraft.item.ItemStack +import net.minecraft.world.item.ItemStack import moe.nea.firmament.util.MC sealed class ChestInventoryUpdateEvent : FirmamentEvent() { diff --git a/src/main/kotlin/events/CommandEvent.kt b/src/main/kotlin/events/CommandEvent.kt index 63ed115..bdd63ca 100644 --- a/src/main/kotlin/events/CommandEvent.kt +++ b/src/main/kotlin/events/CommandEvent.kt @@ -4,7 +4,7 @@ package moe.nea.firmament.events import com.mojang.brigadier.CommandDispatcher import com.mojang.brigadier.tree.LiteralCommandNode -import net.minecraft.command.CommandRegistryAccess +import net.minecraft.commands.CommandBuildContext import moe.nea.firmament.commands.CaseInsensitiveLiteralCommandNode import moe.nea.firmament.commands.DefaultSource import moe.nea.firmament.commands.literal @@ -12,7 +12,7 @@ import moe.nea.firmament.commands.thenLiteral data class CommandEvent( val dispatcher: CommandDispatcher, - val ctx: CommandRegistryAccess, + val ctx: CommandBuildContext, val serverCommands: CommandDispatcher<*>?, ) : FirmamentEvent() { companion object : FirmamentEventBus() @@ -23,7 +23,7 @@ data class CommandEvent( */ data class SubCommand( val builder: CaseInsensitiveLiteralCommandNode.Builder, - val commandRegistryAccess: CommandRegistryAccess, + val commandRegistryAccess: CommandBuildContext, ) : FirmamentEvent() { companion object : FirmamentEventBus() diff --git a/src/main/kotlin/events/CustomItemModelEvent.kt b/src/main/kotlin/events/CustomItemModelEvent.kt index 7b86980..3d96b34 100644 --- a/src/main/kotlin/events/CustomItemModelEvent.kt +++ b/src/main/kotlin/events/CustomItemModelEvent.kt @@ -3,34 +3,34 @@ package moe.nea.firmament.events import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -import net.minecraft.component.DataComponentTypes -import net.minecraft.item.ItemStack -import net.minecraft.util.Identifier +import net.minecraft.core.component.DataComponents +import net.minecraft.world.item.ItemStack +import net.minecraft.resources.ResourceLocation import moe.nea.firmament.util.collections.WeakCache import moe.nea.firmament.util.collections.WeakCache.CacheFunction import moe.nea.firmament.util.mc.IntrospectableItemModelManager // TODO: assert an order on these events data class CustomItemModelEvent( - val itemStack: ItemStack, - val itemModelManager: IntrospectableItemModelManager, - var overrideModel: Identifier? = null, + val itemStack: ItemStack, + val itemModelManager: IntrospectableItemModelManager, + var overrideModel: ResourceLocation? = null, ) : FirmamentEvent() { companion object : FirmamentEventBus() { val weakCache = - object : WeakCache>("ItemModelIdentifier") { + object : WeakCache>("ItemModelIdentifier") { override fun mkRef( - key: ItemStack, - extraData: IntrospectableItemModelManager - ): WeakCache>.Ref { + key: ItemStack, + extraData: IntrospectableItemModelManager + ): WeakCache>.Ref { return IRef(key, extraData) } inner class IRef(weakInstance: ItemStack, data: IntrospectableItemModelManager) : Ref(weakInstance, data) { override fun shouldBeEvicted(): Boolean = false - val isSimpleStack = weakInstance.componentChanges.isEmpty || (weakInstance.componentChanges.size() == 1 && weakInstance.get( - DataComponentTypes.CUSTOM_DATA)?.isEmpty == true) + val isSimpleStack = weakInstance.componentsPatch.isEmpty || (weakInstance.componentsPatch.size() == 1 && weakInstance.get( + DataComponents.CUSTOM_DATA)?.isEmpty == true) val item = weakInstance.item override fun hashCode(): Int { if (isSimpleStack) @@ -49,26 +49,26 @@ data class CustomItemModelEvent( val cache = CacheFunction.WithExtraData(weakCache, ::getModelIdentifier0) @JvmStatic - fun getModelIdentifier(itemStack: ItemStack?, itemModelManager: IntrospectableItemModelManager): Identifier? { + fun getModelIdentifier(itemStack: ItemStack?, itemModelManager: IntrospectableItemModelManager): ResourceLocation? { if (itemStack == null) return null return cache.invoke(itemStack, itemModelManager).getOrNull() } fun getModelIdentifier0( - itemStack: ItemStack, - itemModelManager: IntrospectableItemModelManager - ): Optional { + itemStack: ItemStack, + itemModelManager: IntrospectableItemModelManager + ): Optional { // TODO: add an error / warning if the model does not exist return Optional.ofNullable(publish(CustomItemModelEvent(itemStack, itemModelManager)).overrideModel) } } - fun overrideIfExists(overrideModel: Identifier) { + fun overrideIfExists(overrideModel: ResourceLocation) { if (itemModelManager.hasModel_firmament(overrideModel)) this.overrideModel = overrideModel } - fun overrideIfEmpty(identifier: Identifier) { + fun overrideIfEmpty(identifier: ResourceLocation) { if (overrideModel == null) overrideModel = identifier } diff --git a/src/main/kotlin/events/EarlyResourceReloadEvent.kt b/src/main/kotlin/events/EarlyResourceReloadEvent.kt index ec8377a..b9cf717 100644 --- a/src/main/kotlin/events/EarlyResourceReloadEvent.kt +++ b/src/main/kotlin/events/EarlyResourceReloadEvent.kt @@ -2,7 +2,7 @@ package moe.nea.firmament.events import java.util.concurrent.Executor -import net.minecraft.resource.ResourceManager +import net.minecraft.server.packs.resources.ResourceManager data class EarlyResourceReloadEvent(val resourceManager: ResourceManager, val preparationExecutor: Executor) : FirmamentEvent() { diff --git a/src/main/kotlin/events/EntityDespawnEvent.kt b/src/main/kotlin/events/EntityDespawnEvent.kt index 93dc477..d007f96 100644 --- a/src/main/kotlin/events/EntityDespawnEvent.kt +++ b/src/main/kotlin/events/EntityDespawnEvent.kt @@ -1,7 +1,7 @@ package moe.nea.firmament.events -import net.minecraft.entity.Entity +import net.minecraft.world.entity.Entity data class EntityDespawnEvent( val entity: Entity?, val entityId: Int, diff --git a/src/main/kotlin/events/EntityInteractionEvent.kt b/src/main/kotlin/events/EntityInteractionEvent.kt index 123ea39..8285e1b 100644 --- a/src/main/kotlin/events/EntityInteractionEvent.kt +++ b/src/main/kotlin/events/EntityInteractionEvent.kt @@ -1,13 +1,13 @@ package moe.nea.firmament.events -import net.minecraft.entity.Entity -import net.minecraft.util.Hand +import net.minecraft.world.entity.Entity +import net.minecraft.world.InteractionHand data class EntityInteractionEvent( val kind: InteractionKind, val entity: Entity, - val hand: Hand, + val hand: InteractionHand, ) : FirmamentEvent() { companion object : FirmamentEventBus() enum class InteractionKind { diff --git a/src/main/kotlin/events/EntityRenderTintEvent.kt b/src/main/kotlin/events/EntityRenderTintEvent.kt index 54cbff2..63528bc 100644 --- a/src/main/kotlin/events/EntityRenderTintEvent.kt +++ b/src/main/kotlin/events/EntityRenderTintEvent.kt @@ -1,10 +1,10 @@ package moe.nea.firmament.events -import net.minecraft.client.render.GameRenderer -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 net.minecraft.client.renderer.GameRenderer +import net.minecraft.client.renderer.texture.OverlayTexture +import net.minecraft.client.renderer.entity.state.EntityRenderState +import net.minecraft.world.entity.Entity +import net.minecraft.world.entity.LivingEntity import moe.nea.firmament.events.EntityRenderTintEvent.Companion.overlayOverride import moe.nea.firmament.util.render.TintedOverlayTexture @@ -12,8 +12,8 @@ import moe.nea.firmament.util.render.TintedOverlayTexture * Change the tint color of a [LivingEntity] */ class EntityRenderTintEvent( - val entity: Entity, - val renderState: HasTintRenderState + val entity: Entity, + val renderState: HasTintRenderState ) : FirmamentEvent.Cancellable() { init { if (entity !is LivingEntity) { diff --git a/src/main/kotlin/events/EntityUpdateEvent.kt b/src/main/kotlin/events/EntityUpdateEvent.kt index fec2fa5..9f5a101 100644 --- a/src/main/kotlin/events/EntityUpdateEvent.kt +++ b/src/main/kotlin/events/EntityUpdateEvent.kt @@ -1,12 +1,12 @@ package moe.nea.firmament.events import com.mojang.datafixers.util.Pair -import net.minecraft.entity.Entity -import net.minecraft.entity.EquipmentSlot -import net.minecraft.entity.LivingEntity -import net.minecraft.entity.data.DataTracker -import net.minecraft.item.ItemStack -import net.minecraft.network.packet.s2c.play.EntityAttributesS2CPacket +import net.minecraft.world.entity.Entity +import net.minecraft.world.entity.EquipmentSlot +import net.minecraft.world.entity.LivingEntity +import net.minecraft.network.syncher.SynchedEntityData +import net.minecraft.world.item.ItemStack +import net.minecraft.network.protocol.game.ClientboundUpdateAttributesPacket import moe.nea.firmament.annotations.Subscribe import moe.nea.firmament.util.MC @@ -29,7 +29,7 @@ sealed class EntityUpdateEvent : FirmamentEvent() { EquipmentSlot.OFFHAND to 40, EquipmentSlot.MAINHAND to p.inventory.selectedSlot, // TODO: also equipment update when you swap your selected slot perhaps ).mapNotNull { (slot, stackIndex) -> - val slotIndex = p.playerScreenHandler.getSlotIndex(p.inventory, stackIndex).asInt + val slotIndex = p.inventoryMenu.findSlot(p.inventory, stackIndex).asInt event.getOrNull(slotIndex)?.let { Pair.of(slot, it) } @@ -42,18 +42,18 @@ sealed class EntityUpdateEvent : FirmamentEvent() { abstract val entity: Entity data class AttributeUpdate( - override val entity: LivingEntity, - val attributes: List, + override val entity: LivingEntity, + val attributes: List, ) : EntityUpdateEvent() data class TrackedDataUpdate( - override val entity: Entity, - val trackedValues: List>, + override val entity: Entity, + val trackedValues: List>, ) : EntityUpdateEvent() data class EquipmentUpdate( - override val entity: Entity, - val newEquipment: List>, + override val entity: Entity, + val newEquipment: List>, ) : EntityUpdateEvent() // TODO: onEntityPassengersSet, onEntityAttach?, onEntityStatusEffect diff --git a/src/main/kotlin/events/FinalizeResourceManagerEvent.kt b/src/main/kotlin/events/FinalizeResourceManagerEvent.kt index df1c3eb..72fa9c4 100644 --- a/src/main/kotlin/events/FinalizeResourceManagerEvent.kt +++ b/src/main/kotlin/events/FinalizeResourceManagerEvent.kt @@ -2,25 +2,25 @@ package moe.nea.firmament.events import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor -import net.minecraft.resource.ReloadableResourceManagerImpl -import net.minecraft.resource.ResourceManager -import net.minecraft.resource.ResourceReloader +import net.minecraft.server.packs.resources.ReloadableResourceManager +import net.minecraft.server.packs.resources.ResourceManager +import net.minecraft.server.packs.resources.PreparableReloadListener data class FinalizeResourceManagerEvent( - val resourceManager: ReloadableResourceManagerImpl, + val resourceManager: ReloadableResourceManager, ) : FirmamentEvent() { companion object : FirmamentEventBus() inline fun registerOnApply(name: String, crossinline function: () -> Unit) { - resourceManager.registerReloader(object : ResourceReloader { + resourceManager.registerReloadListener(object : PreparableReloadListener { override fun reload( - store: ResourceReloader.Store, - prepareExecutor: Executor, - reloadSynchronizer: ResourceReloader.Synchronizer, - applyExecutor: Executor + store: PreparableReloadListener.SharedState, + prepareExecutor: Executor, + reloadSynchronizer: PreparableReloadListener.PreparationBarrier, + applyExecutor: Executor ): CompletableFuture { return CompletableFuture.completedFuture(Unit) - .thenCompose(reloadSynchronizer::whenPrepared) + .thenCompose(reloadSynchronizer::wait) .thenAcceptAsync({ function() }, applyExecutor) } diff --git a/src/main/kotlin/events/HandledScreenClickEvent.kt b/src/main/kotlin/events/HandledScreenClickEvent.kt index 4c3003c..b937907 100644 --- a/src/main/kotlin/events/HandledScreenClickEvent.kt +++ b/src/main/kotlin/events/HandledScreenClickEvent.kt @@ -2,9 +2,9 @@ package moe.nea.firmament.events -import net.minecraft.client.gui.screen.ingame.HandledScreen +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen -data class HandledScreenClickEvent(val screen: HandledScreen<*>, val mouseX: Double, val mouseY: Double, val button: Int) : +data class HandledScreenClickEvent(val screen: AbstractContainerScreen<*>, val mouseX: Double, val mouseY: Double, val button: Int) : FirmamentEvent.Cancellable() { companion object : FirmamentEventBus() } diff --git a/src/main/kotlin/events/HandledScreenForegroundEvent.kt b/src/main/kotlin/events/HandledScreenForegroundEvent.kt index f16d30e..3a3d7f6 100644 --- a/src/main/kotlin/events/HandledScreenForegroundEvent.kt +++ b/src/main/kotlin/events/HandledScreenForegroundEvent.kt @@ -2,12 +2,12 @@ package moe.nea.firmament.events -import net.minecraft.client.gui.DrawContext -import net.minecraft.client.gui.screen.ingame.HandledScreen +import net.minecraft.client.gui.GuiGraphics +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen data class HandledScreenForegroundEvent( - val screen: HandledScreen<*>, - val context: DrawContext, + val screen: AbstractContainerScreen<*>, + val context: GuiGraphics, val mouseX: Int, val mouseY: Int, val delta: Float diff --git a/src/main/kotlin/events/HandledScreenKeyPressedEvent.kt b/src/main/kotlin/events/HandledScreenKeyPressedEvent.kt index 34aebe6..b9e23a2 100644 --- a/src/main/kotlin/events/HandledScreenKeyPressedEvent.kt +++ b/src/main/kotlin/events/HandledScreenKeyPressedEvent.kt @@ -1,21 +1,21 @@ package moe.nea.firmament.events import org.lwjgl.glfw.GLFW -import net.minecraft.client.gui.screen.ingame.HandledScreen +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen import moe.nea.firmament.keybindings.GenericInputAction import moe.nea.firmament.keybindings.InputModifiers import moe.nea.firmament.keybindings.SavedKeyBinding sealed interface HandledScreenInputEvent { - val screen: HandledScreen<*> + val screen: AbstractContainerScreen<*> val input: GenericInputAction val modifiers: InputModifiers } data class HandledScreenKeyPressedEvent( - override val screen: HandledScreen<*>, - override val input: GenericInputAction, - override val modifiers: InputModifiers, + override val screen: AbstractContainerScreen<*>, + override val input: GenericInputAction, + override val modifiers: InputModifiers, // TODO: val isRepeat: Boolean, ) : FirmamentEvent.Cancellable(), HandledScreenInputEvent { fun matches(keyBinding: SavedKeyBinding, atLeast: Boolean = false): Boolean { @@ -27,9 +27,9 @@ data class HandledScreenKeyPressedEvent( } data class HandledScreenKeyReleasedEvent( - override val screen: HandledScreen<*>, - override val input: GenericInputAction, - override val modifiers: InputModifiers, + override val screen: AbstractContainerScreen<*>, + override val input: GenericInputAction, + override val modifiers: InputModifiers, ) : FirmamentEvent.Cancellable(), HandledScreenInputEvent { fun matches(keyBinding: SavedKeyBinding, atLeast: Boolean = false): Boolean { return keyBinding.matches(input, modifiers, atLeast) diff --git a/src/main/kotlin/events/HandledScreenPushREIEvent.kt b/src/main/kotlin/events/HandledScreenPushREIEvent.kt index 1bb495a..e2b5a40 100644 --- a/src/main/kotlin/events/HandledScreenPushREIEvent.kt +++ b/src/main/kotlin/events/HandledScreenPushREIEvent.kt @@ -3,10 +3,10 @@ package moe.nea.firmament.events import me.shedaniel.math.Rectangle -import net.minecraft.client.gui.screen.ingame.HandledScreen +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen data class HandledScreenPushREIEvent( - val screen: HandledScreen<*>, + val screen: AbstractContainerScreen<*>, val rectangles: MutableList = mutableListOf() ) : FirmamentEvent() { diff --git a/src/main/kotlin/events/HotbarItemRenderEvent.kt b/src/main/kotlin/events/HotbarItemRenderEvent.kt index a1940e6..0d4e75b 100644 --- a/src/main/kotlin/events/HotbarItemRenderEvent.kt +++ b/src/main/kotlin/events/HotbarItemRenderEvent.kt @@ -2,16 +2,16 @@ package moe.nea.firmament.events -import net.minecraft.client.gui.DrawContext -import net.minecraft.client.render.RenderTickCounter -import net.minecraft.item.ItemStack +import net.minecraft.client.gui.GuiGraphics +import net.minecraft.client.DeltaTracker +import net.minecraft.world.item.ItemStack data class HotbarItemRenderEvent( - val item: ItemStack, - val context: DrawContext, - val x: Int, - val y: Int, - val tickDelta: RenderTickCounter, + val item: ItemStack, + val context: GuiGraphics, + val x: Int, + val y: Int, + val tickDelta: DeltaTracker, ) : FirmamentEvent() { companion object : FirmamentEventBus() } diff --git a/src/main/kotlin/events/HudRenderEvent.kt b/src/main/kotlin/events/HudRenderEvent.kt index 5919dae..a397378 100644 --- a/src/main/kotlin/events/HudRenderEvent.kt +++ b/src/main/kotlin/events/HudRenderEvent.kt @@ -1,16 +1,16 @@ package moe.nea.firmament.events -import net.minecraft.client.gui.DrawContext -import net.minecraft.client.render.RenderTickCounter -import net.minecraft.world.GameMode +import net.minecraft.client.gui.GuiGraphics +import net.minecraft.client.DeltaTracker +import net.minecraft.world.level.GameType import moe.nea.firmament.util.MC /** * Called when hud elements should be rendered, before the screen, but after the world. */ -data class HudRenderEvent(val context: DrawContext, val tickDelta: RenderTickCounter) : FirmamentEvent.Cancellable() { - val isRenderingHud = !MC.options.hudHidden - val isRenderingCursor = MC.interactionManager?.currentGameMode != GameMode.SPECTATOR && isRenderingHud +data class HudRenderEvent(val context: GuiGraphics, val tickDelta: DeltaTracker) : FirmamentEvent.Cancellable() { + val isRenderingHud = !MC.options.hideGui + val isRenderingCursor = MC.interactionManager?.playerMode != GameType.SPECTATOR && isRenderingHud init { if (!isRenderingHud) diff --git a/src/main/kotlin/events/IsSlotProtectedEvent.kt b/src/main/kotlin/events/IsSlotProtectedEvent.kt index 6ab0174..bda1bb3 100644 --- a/src/main/kotlin/events/IsSlotProtectedEvent.kt +++ b/src/main/kotlin/events/IsSlotProtectedEvent.kt @@ -1,8 +1,8 @@ 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.world.item.ItemStack +import net.minecraft.world.inventory.Slot +import net.minecraft.world.inventory.ClickType import moe.nea.firmament.util.CommonSoundEffects import moe.nea.firmament.util.MC import moe.nea.firmament.util.grey @@ -11,14 +11,14 @@ import moe.nea.firmament.util.red import moe.nea.firmament.util.tr data class IsSlotProtectedEvent( - val slot: Slot?, - val actionType: SlotActionType, - var isProtected: Boolean, - val itemStackOverride: ItemStack?, - val origin: MoveOrigin, - var silent: Boolean = false, + val slot: Slot?, + val actionType: ClickType, + var isProtected: Boolean, + val itemStackOverride: ItemStack?, + val origin: MoveOrigin, + var silent: Boolean = false, ) : FirmamentEvent() { - val itemStack get() = itemStackOverride ?: slot!!.stack + val itemStack get() = itemStackOverride ?: slot!!.item fun protect() { isProtected = true @@ -43,15 +43,15 @@ data class IsSlotProtectedEvent( @JvmStatic @JvmOverloads fun shouldBlockInteraction( - slot: Slot?, action: SlotActionType, - origin: MoveOrigin, - itemStackOverride: ItemStack? = null, + slot: Slot?, action: ClickType, + origin: MoveOrigin, + itemStackOverride: ItemStack? = null, ): Boolean { if (slot == null && itemStackOverride == null) return false val event = IsSlotProtectedEvent(slot, action, false, itemStackOverride, origin) publish(event) if (event.isProtected && !event.silent) { - MC.sendChat(tr("firmament.protectitem", "Firmament protected your item: ${event.itemStack.name}.\n") + MC.sendChat(tr("firmament.protectitem", "Firmament protected your item: ${event.itemStack.hoverName}.\n") .red() .append(tr("firmament.protectitem.hoverhint", "Hover for more info.").grey()) .hover(tr("firmament.protectitem.hint", diff --git a/src/main/kotlin/events/ItemTooltipEvent.kt b/src/main/kotlin/events/ItemTooltipEvent.kt index d86e06f..9acd9bf 100644 --- a/src/main/kotlin/events/ItemTooltipEvent.kt +++ b/src/main/kotlin/events/ItemTooltipEvent.kt @@ -2,13 +2,13 @@ package moe.nea.firmament.events -import net.minecraft.item.Item.TooltipContext -import net.minecraft.item.ItemStack -import net.minecraft.item.tooltip.TooltipType -import net.minecraft.text.Text +import net.minecraft.world.item.Item.TooltipContext +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.TooltipFlag +import net.minecraft.network.chat.Component data class ItemTooltipEvent( - val stack: ItemStack, val context: TooltipContext, val type: TooltipType, val lines: MutableList + val stack: ItemStack, val context: TooltipContext, val type: TooltipFlag, val lines: MutableList ) : FirmamentEvent() { companion object : FirmamentEventBus() } diff --git a/src/main/kotlin/events/JoinServerEvent.kt b/src/main/kotlin/events/JoinServerEvent.kt index 225a2c1..6fafbd7 100644 --- a/src/main/kotlin/events/JoinServerEvent.kt +++ b/src/main/kotlin/events/JoinServerEvent.kt @@ -1,11 +1,11 @@ package moe.nea.firmament.events import net.fabricmc.fabric.api.networking.v1.PacketSender -import net.minecraft.client.network.ClientPlayNetworkHandler +import net.minecraft.client.multiplayer.ClientPacketListener data class JoinServerEvent( - val networkHandler: ClientPlayNetworkHandler, - val packetSender: PacketSender, + val networkHandler: ClientPacketListener, + val packetSender: PacketSender, ) : FirmamentEvent() { companion object : FirmamentEventBus() } diff --git a/src/main/kotlin/events/ModifyChatEvent.kt b/src/main/kotlin/events/ModifyChatEvent.kt index 4a7025c..5432490 100644 --- a/src/main/kotlin/events/ModifyChatEvent.kt +++ b/src/main/kotlin/events/ModifyChatEvent.kt @@ -2,16 +2,16 @@ package moe.nea.firmament.events -import net.minecraft.text.Text +import net.minecraft.network.chat.Component import moe.nea.firmament.util.unformattedString /** * Allow modification of a chat message before it is sent off to the user. Intended for display purposes. */ -data class ModifyChatEvent(val originalText: Text) : FirmamentEvent() { +data class ModifyChatEvent(val originalText: Component) : FirmamentEvent() { var unformattedString = originalText.unformattedString private set - var replaceWith: Text = originalText + var replaceWith: Component = originalText set(value) { field = value unformattedString = value.unformattedString diff --git a/src/main/kotlin/events/OutgoingPacketEvent.kt b/src/main/kotlin/events/OutgoingPacketEvent.kt index 93890ea..0385647 100644 --- a/src/main/kotlin/events/OutgoingPacketEvent.kt +++ b/src/main/kotlin/events/OutgoingPacketEvent.kt @@ -2,7 +2,7 @@ package moe.nea.firmament.events -import net.minecraft.network.packet.Packet +import net.minecraft.network.protocol.Packet data class OutgoingPacketEvent(val packet: Packet<*>) : FirmamentEvent.Cancellable() { companion object : FirmamentEventBus() diff --git a/src/main/kotlin/events/ParticleSpawnEvent.kt b/src/main/kotlin/events/ParticleSpawnEvent.kt index 9359e4b..578fa0d 100644 --- a/src/main/kotlin/events/ParticleSpawnEvent.kt +++ b/src/main/kotlin/events/ParticleSpawnEvent.kt @@ -3,12 +3,12 @@ package moe.nea.firmament.events import org.joml.Vector3f -import net.minecraft.particle.ParticleEffect -import net.minecraft.util.math.Vec3d +import net.minecraft.core.particles.ParticleOptions +import net.minecraft.world.phys.Vec3 data class ParticleSpawnEvent( - val particleEffect: ParticleEffect, - val position: Vec3d, + val particleEffect: ParticleOptions, + val position: Vec3, val offset: Vector3f, val longDistance: Boolean, val count: Int, diff --git a/src/main/kotlin/events/PlayerInventoryUpdate.kt b/src/main/kotlin/events/PlayerInventoryUpdate.kt index 88439a9..99bce9b 100644 --- a/src/main/kotlin/events/PlayerInventoryUpdate.kt +++ b/src/main/kotlin/events/PlayerInventoryUpdate.kt @@ -1,6 +1,6 @@ package moe.nea.firmament.events -import net.minecraft.item.ItemStack +import net.minecraft.world.item.ItemStack sealed class PlayerInventoryUpdate : FirmamentEvent() { companion object : FirmamentEventBus() diff --git a/src/main/kotlin/events/ProcessChatEvent.kt b/src/main/kotlin/events/ProcessChatEvent.kt index 76c0b27..a276951 100644 --- a/src/main/kotlin/events/ProcessChatEvent.kt +++ b/src/main/kotlin/events/ProcessChatEvent.kt @@ -2,14 +2,14 @@ package moe.nea.firmament.events -import net.minecraft.text.Text +import net.minecraft.network.chat.Component import moe.nea.firmament.util.unformattedString /** * Behaves like [AllowChatEvent], but is triggered even when cancelled by other mods. Intended for data collection. * Make sure to subscribe to cancellable events as well when using. */ -data class ProcessChatEvent(val text: Text, val wasExternallyCancelled: Boolean) : FirmamentEvent.Cancellable() { +data class ProcessChatEvent(val text: Component, val wasExternallyCancelled: Boolean) : FirmamentEvent.Cancellable() { val unformattedString = text.unformattedString val nameHeuristic: String? = run { diff --git a/src/main/kotlin/events/ScreenChangeEvent.kt b/src/main/kotlin/events/ScreenChangeEvent.kt index 489e487..8193186 100644 --- a/src/main/kotlin/events/ScreenChangeEvent.kt +++ b/src/main/kotlin/events/ScreenChangeEvent.kt @@ -2,7 +2,7 @@ package moe.nea.firmament.events -import net.minecraft.client.gui.screen.Screen +import net.minecraft.client.gui.screens.Screen data class ScreenChangeEvent(val old: Screen?, val new: Screen?) : FirmamentEvent.Cancellable() { var overrideScreen: Screen? = null diff --git a/src/main/kotlin/events/ScreenRenderPostEvent.kt b/src/main/kotlin/events/ScreenRenderPostEvent.kt index 79f4913..43b7c01 100644 --- a/src/main/kotlin/events/ScreenRenderPostEvent.kt +++ b/src/main/kotlin/events/ScreenRenderPostEvent.kt @@ -2,15 +2,15 @@ package moe.nea.firmament.events -import net.minecraft.client.gui.DrawContext -import net.minecraft.client.gui.screen.Screen +import net.minecraft.client.gui.GuiGraphics +import net.minecraft.client.gui.screens.Screen data class ScreenRenderPostEvent( val screen: Screen, val mouseX: Int, val mouseY: Int, val tickDelta: Float, - val drawContext: DrawContext + val drawContext: GuiGraphics ) : FirmamentEvent() { companion object : FirmamentEventBus() } diff --git a/src/main/kotlin/events/ServerConnectedEvent.kt b/src/main/kotlin/events/ServerConnectedEvent.kt index 26897f2..c9bc5e4 100644 --- a/src/main/kotlin/events/ServerConnectedEvent.kt +++ b/src/main/kotlin/events/ServerConnectedEvent.kt @@ -1,16 +1,16 @@ package moe.nea.firmament.events import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents -import net.minecraft.client.MinecraftClient -import net.minecraft.client.network.ClientPlayNetworkHandler -import net.minecraft.network.ClientConnection +import net.minecraft.client.Minecraft +import net.minecraft.client.multiplayer.ClientPacketListener +import net.minecraft.network.Connection data class ServerConnectedEvent( - val connection: ClientConnection + val connection: Connection ) : FirmamentEvent() { companion object : FirmamentEventBus() { init { - ClientPlayConnectionEvents.INIT.register(ClientPlayConnectionEvents.Init { clientPlayNetworkHandler: ClientPlayNetworkHandler, minecraftClient: MinecraftClient -> + ClientPlayConnectionEvents.INIT.register(ClientPlayConnectionEvents.Init { clientPlayNetworkHandler: ClientPacketListener, minecraftClient: Minecraft -> publishSync(ServerConnectedEvent(clientPlayNetworkHandler.connection)) }) } diff --git a/src/main/kotlin/events/SlotClickEvent.kt b/src/main/kotlin/events/SlotClickEvent.kt index d4abfb0..bfeadf9 100644 --- a/src/main/kotlin/events/SlotClickEvent.kt +++ b/src/main/kotlin/events/SlotClickEvent.kt @@ -1,15 +1,15 @@ 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.world.item.ItemStack +import net.minecraft.world.inventory.Slot +import net.minecraft.world.inventory.ClickType data class SlotClickEvent( val slot: Slot, val stack: ItemStack, val button: Int, - val actionType: SlotActionType, + val actionType: ClickType, ) : FirmamentEvent() { companion object : FirmamentEventBus() } diff --git a/src/main/kotlin/events/SlotRenderEvents.kt b/src/main/kotlin/events/SlotRenderEvents.kt index 9076d53..c938ffc 100644 --- a/src/main/kotlin/events/SlotRenderEvents.kt +++ b/src/main/kotlin/events/SlotRenderEvents.kt @@ -2,16 +2,16 @@ package moe.nea.firmament.events -import net.minecraft.client.gui.DrawContext -import net.minecraft.screen.slot.Slot -import net.minecraft.util.Identifier +import net.minecraft.client.gui.GuiGraphics +import net.minecraft.world.inventory.Slot +import net.minecraft.resources.ResourceLocation import moe.nea.firmament.util.render.drawGuiTexture interface SlotRenderEvents { - val context: DrawContext + val context: GuiGraphics val slot: Slot - fun highlight(sprite: Identifier) { + fun highlight(sprite: ResourceLocation) { context.drawGuiTexture( slot.x, slot.y, 0, 16, 16, sprite @@ -19,14 +19,14 @@ interface SlotRenderEvents { } data class Before( - override val context: DrawContext, override val slot: Slot, + override val context: GuiGraphics, override val slot: Slot, ) : FirmamentEvent(), SlotRenderEvents { companion object : FirmamentEventBus() } data class After( - override val context: DrawContext, override val slot: Slot, + override val context: GuiGraphics, override val slot: Slot, ) : FirmamentEvent(), SlotRenderEvents { companion object : FirmamentEventBus() diff --git a/src/main/kotlin/events/SoundReceiveEvent.kt b/src/main/kotlin/events/SoundReceiveEvent.kt index d1b85b6..063f657 100644 --- a/src/main/kotlin/events/SoundReceiveEvent.kt +++ b/src/main/kotlin/events/SoundReceiveEvent.kt @@ -1,15 +1,15 @@ package moe.nea.firmament.events -import net.minecraft.registry.entry.RegistryEntry -import net.minecraft.sound.SoundCategory -import net.minecraft.