aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/moe/nea/firmament/init/HandledScreenRiser.java22
-rw-r--r--src/main/java/moe/nea/firmament/init/SectionBuilderRiser.java16
-rw-r--r--src/main/java/moe/nea/firmament/mixins/AppendRepoAsResourcePack.java4
-rw-r--r--src/main/java/moe/nea/firmament/mixins/BandAidResourcePackPatch.java10
-rw-r--r--src/main/java/moe/nea/firmament/mixins/ChatPeekingPatch.java6
-rw-r--r--src/main/java/moe/nea/firmament/mixins/CopyChatPatch.java32
-rw-r--r--src/main/java/moe/nea/firmament/mixins/CustomDurabilityBarPatch.java30
-rw-r--r--src/main/java/moe/nea/firmament/mixins/DFUEntityIdFixPatch.java8
-rw-r--r--src/main/java/moe/nea/firmament/mixins/DisableHurtCam.java4
-rw-r--r--src/main/java/moe/nea/firmament/mixins/DispatchMouseInputEventsPatch.java10
-rw-r--r--src/main/java/moe/nea/firmament/mixins/EarlyResourceReloadPatch.java14
-rw-r--r--src/main/java/moe/nea/firmament/mixins/EntityDespawnPatch.java6
-rw-r--r--src/main/java/moe/nea/firmament/mixins/EntityInteractEventPatch.java28
-rw-r--r--src/main/java/moe/nea/firmament/mixins/EntityUpdateEventListener.java48
-rw-r--r--src/main/java/moe/nea/firmament/mixins/FirmKeybindsInVanillaControlsPatch.java32
-rw-r--r--src/main/java/moe/nea/firmament/mixins/HideStatusEffectsPatch.java14
-rw-r--r--src/main/java/moe/nea/firmament/mixins/HudRenderEventsPatch.java20
-rw-r--r--src/main/java/moe/nea/firmament/mixins/IncomingPacketListenerPatches.java24
-rw-r--r--src/main/java/moe/nea/firmament/mixins/KeyPressInWorldEventPatch.java12
-rw-r--r--src/main/java/moe/nea/firmament/mixins/MainWindowFirstLoadPatch.java8
-rw-r--r--src/main/java/moe/nea/firmament/mixins/MaintainKeyboardStatePatch.java10
-rw-r--r--src/main/java/moe/nea/firmament/mixins/MinecraftInitLevelListener.java6
-rw-r--r--src/main/java/moe/nea/firmament/mixins/MixinHandledScreen.java72
-rw-r--r--src/main/java/moe/nea/firmament/mixins/MixinPlayerScreenHandler.java14
-rw-r--r--src/main/java/moe/nea/firmament/mixins/MixinRecipeBookScreen.java6
-rw-r--r--src/main/java/moe/nea/firmament/mixins/MousePressInWorldEventPatch.java12
-rw-r--r--src/main/java/moe/nea/firmament/mixins/OutgoingPacketEventPatch.java8
-rw-r--r--src/main/java/moe/nea/firmament/mixins/PlayerDropEventPatch.java16
-rw-r--r--src/main/java/moe/nea/firmament/mixins/ResourceReloaderRegistrationPatch.java14
-rw-r--r--src/main/java/moe/nea/firmament/mixins/SaveCursorPositionPatch.java24
-rw-r--r--src/main/java/moe/nea/firmament/mixins/SaveOriginalCommandTreePacket.java10
-rw-r--r--src/main/java/moe/nea/firmament/mixins/ScreenChangeEventPatch.java10
-rw-r--r--src/main/java/moe/nea/firmament/mixins/SlotClickEventPatch.java22
-rw-r--r--src/main/java/moe/nea/firmament/mixins/SlotUpdateListener.java48
-rw-r--r--src/main/java/moe/nea/firmament/mixins/SoundReceiveEventPatch.java22
-rw-r--r--src/main/java/moe/nea/firmament/mixins/ToggleSprintPatch.java8
-rw-r--r--src/main/java/moe/nea/firmament/mixins/TolerateFirmamentTolerateRegistryOwners.java8
-rw-r--r--src/main/java/moe/nea/firmament/mixins/WorldReadyEventPatch.java6
-rw-r--r--src/main/java/moe/nea/firmament/mixins/WorldRenderLastEventPatch.java41
-rw-r--r--src/main/java/moe/nea/firmament/mixins/accessor/AccessorAbstractClientPlayerEntity.java10
-rw-r--r--src/main/java/moe/nea/firmament/mixins/accessor/AccessorChatHud.java18
-rw-r--r--src/main/java/moe/nea/firmament/mixins/accessor/AccessorHandledScreen.java26
-rw-r--r--src/main/java/moe/nea/firmament/mixins/accessor/AccessorNbtComponent.java10
-rw-r--r--src/main/java/moe/nea/firmament/mixins/accessor/AccessorPlayerListHud.java20
-rw-r--r--src/main/java/moe/nea/firmament/mixins/accessor/AccessorScreenHandler.java10
-rw-r--r--src/main/java/moe/nea/firmament/mixins/accessor/AccessorWorldRenderer.java10
-rw-r--r--src/main/java/moe/nea/firmament/mixins/customgui/OriginalSlotCoords.java2
-rw-r--r--src/main/java/moe/nea/firmament/mixins/customgui/PatchHandledScreen.java90
-rw-r--r--src/main/java/moe/nea/firmament/mixins/devenv/DisableCommonPacketWarnings.java20
-rw-r--r--src/main/java/moe/nea/firmament/mixins/devenv/DisableInvalidFishingHook.java6
-rw-r--r--src/main/java/moe/nea/firmament/mixins/devenv/EarlyInstantiateTranslations.java8
-rw-r--r--src/main/java/moe/nea/firmament/mixins/devenv/IdentifyCloser.java2
-rw-r--r--src/main/java/moe/nea/firmament/mixins/devenv/IdentifyStopperPatch.java6
-rw-r--r--src/main/java/moe/nea/firmament/mixins/devenv/MixinKeyboard.java10
-rw-r--r--src/main/java/moe/nea/firmament/mixins/devenv/MixinScoreboard.java5
-rw-r--r--src/main/java/moe/nea/firmament/mixins/devenv/WarnForUnknownCustomPayloadSends.java8
-rw-r--r--src/main/java/moe/nea/firmament/mixins/devenv/WarnOnMissingTranslations.java14
-rw-r--r--src/main/java/moe/nea/firmament/mixins/feature/DisableSlotHighlights.java12
-rw-r--r--src/main/java/moe/nea/firmament/mixins/feature/devcosmetics/CustomCapeFeatureRenderer.java40
-rw-r--r--src/main/java/moe/nea/firmament/mixins/feature/devcosmetics/CustomCapeStorage.java4
-rw-r--r--src/main/java/moe/nea/firmament/mixins/render/IncreaseStackLimitSizeInDrawContext.java6
-rw-r--r--src/main/java/moe/nea/firmament/mixins/render/entitytints/ChangeColorOfLivingEntities.java30
-rw-r--r--src/main/java/moe/nea/firmament/mixins/render/entitytints/EntityRenderStateTint.java2
-rw-r--r--src/main/java/moe/nea/firmament/mixins/render/entitytints/InjectIntoRenderState.java8
-rw-r--r--src/main/java/moe/nea/firmament/mixins/render/entitytints/ReplaceOverlayTexture.java8
-rw-r--r--src/main/java/moe/nea/firmament/mixins/render/entitytints/UseOverlayableEquipmentRenderer.java26
-rw-r--r--src/main/java/moe/nea/firmament/mixins/render/entitytints/UseOverlayableHeadFeatureRenderer.java16
-rw-r--r--src/main/java/moe/nea/firmament/mixins/render/entitytints/UseOverlayableItemRenderer.java20
-rw-r--r--src/main/java/moe/nea/firmament/mixins/render/entitytints/UseOverlayableSkullBlockEntityRenderer.java16
-rw-r--r--src/main/java/moe/nea/firmament/mixins/render/renderer/MultipleSpecialGuiRenderStates.java24
-rw-r--r--src/main/java/moe/nea/firmament/util/data/ManagedConfig.kt28
-rw-r--r--src/main/kotlin/Firmament.kt10
-rw-r--r--src/main/kotlin/apis/Profiles.kt6
-rw-r--r--src/main/kotlin/apis/UrsaManager.kt8
-rw-r--r--src/main/kotlin/commands/rome.kt94
-rw-r--r--src/main/kotlin/events/AllowChatEvent.kt4
-rw-r--r--src/main/kotlin/events/AttackBlockEvent.kt16
-rw-r--r--src/main/kotlin/events/ChestInventoryUpdateEvent.kt2
-rw-r--r--src/main/kotlin/events/CommandEvent.kt6
-rw-r--r--src/main/kotlin/events/CustomItemModelEvent.kt36
-rw-r--r--src/main/kotlin/events/EarlyResourceReloadEvent.kt2
-rw-r--r--src/main/kotlin/events/EntityDespawnEvent.kt2
-rw-r--r--src/main/kotlin/events/EntityInteractionEvent.kt6
-rw-r--r--src/main/kotlin/events/EntityRenderTintEvent.kt14
-rw-r--r--src/main/kotlin/events/EntityUpdateEvent.kt26
-rw-r--r--src/main/kotlin/events/FinalizeResourceManagerEvent.kt20
-rw-r--r--src/main/kotlin/events/HandledScreenClickEvent.kt4
-rw-r--r--src/main/kotlin/events/HandledScreenForegroundEvent.kt8
-rw-r--r--src/main/kotlin/events/HandledScreenKeyPressedEvent.kt16
-rw-r--r--src/main/kotlin/events/HandledScreenPushREIEvent.kt4
-rw-r--r--src/main/kotlin/events/HotbarItemRenderEvent.kt16
-rw-r--r--src/main/kotlin/events/HudRenderEvent.kt12
-rw-r--r--src/main/kotlin/events/IsSlotProtectedEvent.kt28
-rw-r--r--src/main/kotlin/events/ItemTooltipEvent.kt10
-rw-r--r--src/main/kotlin/events/JoinServerEvent.kt6
-rw-r--r--src/main/kotlin/events/ModifyChatEvent.kt6
-rw-r--r--src/main/kotlin/events/OutgoingPacketEvent.kt2
-rw-r--r--src/main/kotlin/events/ParticleSpawnEvent.kt8
-rw-r--r--src/main/kotlin/events/PlayerInventoryUpdate.kt2
-rw-r--r--src/main/kotlin/events/ProcessChatEvent.kt4
-rw-r--r--src/main/kotlin/events/ScreenChangeEvent.kt2
-rw-r--r--src/main/kotlin/events/ScreenRenderPostEvent.kt6
-rw-r--r--src/main/kotlin/events/ServerConnectedEvent.kt10
-rw-r--r--src/main/kotlin/events/SlotClickEvent.kt8
-rw-r--r--src/main/kotlin/events/SlotRenderEvents.kt14
-rw-r--r--src/main/kotlin/events/SoundReceiveEvent.kt14
-rw-r--r--src/main/kotlin/events/UseBlockEvent.kt10
-rw-r--r--src/main/kotlin/events/UseItemEvent.kt12
-rw-r--r--src/main/kotlin/events/WorldRenderLastEvent.kt14
-rw-r--r--src/main/kotlin/events/registration/ChatEvents.kt22
-rw-r--r--src/main/kotlin/features/chat/AutoCompletions.kt2
-rw-r--r--src/main/kotlin/features/chat/ChatLinks.kt48
-rw-r--r--src/main/kotlin/features/chat/CopyChat.kt4
-rw-r--r--src/main/kotlin/features/chat/PartyCommands.kt4
-rw-r--r--src/main/kotlin/features/chat/QuickCommands.kt26
-rw-r--r--src/main/kotlin/features/debug/AnimatedClothingScanner.kt34
-rw-r--r--src/main/kotlin/features/debug/DebugLogger.kt4
-rw-r--r--src/main/kotlin/features/debug/DeveloperFeatures.kt12
-rw-r--r--src/main/kotlin/features/debug/ExportedTestConstantMeta.kt2
-rw-r--r--src/main/kotlin/features/debug/MinorTrolling.kt4
-rw-r--r--src/main/kotlin/features/debug/PowerUserTools.kt134
-rw-r--r--src/main/kotlin/features/debug/SkinPreviews.kt18
-rw-r--r--src/main/kotlin/features/debug/SoundVisualizer.kt4
-rw-r--r--src/main/kotlin/features/debug/itemeditor/ExportRecipe.kt30
-rw-r--r--src/main/kotlin/features/debug/itemeditor/ItemExporter.kt20
-rw-r--r--src/main/kotlin/features/debug/itemeditor/LegacyItemData.kt8
-rw-r--r--src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt98
-rw-r--r--src/main/kotlin/features/diana/AncestralSpadeSolver.kt16
-rw-r--r--src/main/kotlin/features/diana/NearbyBurrowsSolver.kt12
-rw-r--r--src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt30
-rw-r--r--src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt28
-rw-r--r--src/main/kotlin/features/events/carnival/MinesweeperHelper.kt38
-rw-r--r--src/main/kotlin/features/fixes/Fixes.kt30
-rw-r--r--src/main/kotlin/features/garden/HideComposterNoises.kt14
-rw-r--r--src/main/kotlin/features/inventory/CraftingOverlay.kt26
-rw-r--r--src/main/kotlin/features/inventory/ItemRarityCosmetics.kt18
-rw-r--r--src/main/kotlin/features/inventory/JunkHighlighter.kt2
-rw-r--r--src/main/kotlin/features/inventory/PetFeatures.kt134
-rw-r--r--src/main/kotlin/features/inventory/PriceData.kt18
-rw-r--r--src/main/kotlin/features/inventory/REIDependencyWarner.kt26
-rw-r--r--src/main/kotlin/features/inventory/SaveCursorPosition.kt6
-rw-r--r--src/main/kotlin/features/inventory/SlotLocking.kt128
-rw-r--r--src/main/kotlin/features/inventory/TimerInLore.kt12
-rw-r--r--src/main/kotlin/features/inventory/WardrobeKeybinds.kt12
-rw-r--r--src/main/kotlin/features/inventory/buttons/InventoryButton.kt42
-rw-r--r--src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt116
-rw-r--r--src/main/kotlin/features/inventory/buttons/InventoryButtonTemplates.kt4
-rw-r--r--src/main/kotlin/features/inventory/buttons/InventoryButtons.kt30
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageBackingHandle.kt20
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverlay.kt30
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt52
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt142
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt54
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/VirtualInventory.kt22
-rw-r--r--src/main/kotlin/features/items/BlockZapperOverlay.kt24
-rw-r--r--src/main/kotlin/features/items/BonemerangOverlay.kt36
-rw-r--r--src/main/kotlin/features/items/EtherwarpOverlay.kt76
-rw-r--r--src/main/kotlin/features/macros/ComboProcessor.kt22
-rw-r--r--src/main/kotlin/features/macros/HotkeyAction.kt8
-rw-r--r--src/main/kotlin/features/macros/KeyComboTrie.kt10
-rw-r--r--src/main/kotlin/features/macros/MacroUI.kt8
-rw-r--r--src/main/kotlin/features/macros/RadialMenu.kt14
-rw-r--r--src/main/kotlin/features/mining/CommissionFeatures.kt2
-rw-r--r--src/main/kotlin/features/mining/HotmPresets.kt60
-rw-r--r--src/main/kotlin/features/mining/MiningBlockInfoUi.kt4
-rw-r--r--src/main/kotlin/features/mining/PickaxeAbility.kt42
-rw-r--r--src/main/kotlin/features/mining/PristineProfitTracker.kt6
-rw-r--r--src/main/kotlin/features/misc/CustomCapes.kt80
-rw-r--r--src/main/kotlin/features/misc/Hud.kt46
-rw-r--r--src/main/kotlin/features/misc/LicenseViewer.kt16
-rw-r--r--src/main/kotlin/features/misc/ModAnnouncer.kt28
-rw-r--r--src/main/kotlin/features/world/ColeWeightCompat.kt24
-rw-r--r--src/main/kotlin/features/world/FairySouls.kt4
-rw-r--r--src/main/kotlin/features/world/FirmWaypointManager.kt10
-rw-r--r--src/main/kotlin/features/world/FirmWaypoints.kt2
-rw-r--r--src/main/kotlin/features/world/NavigableWaypoint.kt2
-rw-r--r--src/main/kotlin/features/world/NavigationHelper.kt24
-rw-r--r--src/main/kotlin/features/world/NpcWaypointGui.kt4
-rw-r--r--src/main/kotlin/features/world/TemporaryWaypoints.kt14
-rw-r--r--src/main/kotlin/features/world/Waypoints.kt46
-rw-r--r--src/main/kotlin/gui/BarComponent.kt32
-rw-r--r--src/main/kotlin/gui/CheckboxComponent.kt4
-rw-r--r--src/main/kotlin/gui/config/AllConfigsGui.kt8
-rw-r--r--src/main/kotlin/gui/config/BuiltInConfigScreenProvider.kt2
-rw-r--r--src/main/kotlin/gui/config/ChoiceHandler.kt6
-rw-r--r--src/main/kotlin/gui/config/EnumRenderer.kt8
-rw-r--r--src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt2
-rw-r--r--src/main/kotlin/gui/config/GuiAppender.kt6
-rw-r--r--src/main/kotlin/gui/config/HudMetaHandler.kt18
-rw-r--r--src/main/kotlin/gui/config/JAnyHud.kt18
-rw-r--r--src/main/kotlin/gui/config/KeyBindingStateManager.kt10
-rw-r--r--src/main/kotlin/gui/config/ManagedOption.kt6
-rw-r--r--src/main/kotlin/gui/config/StringHandler.kt4
-rw-r--r--src/main/kotlin/gui/entity/EntityModifier.kt2
-rw-r--r--src/main/kotlin/gui/entity/EntityRenderer.kt68
-rw-r--r--src/main/kotlin/gui/entity/GuiPlayer.kt22
-rw-r--r--src/main/kotlin/gui/entity/ModifyAge.kt16
-rw-r--r--src/main/kotlin/gui/entity/ModifyCharged.kt8
-rw-r--r--src/main/kotlin/gui/entity/ModifyEquipment.kt18
-rw-r--r--src/main/kotlin/gui/entity/ModifyHorse.kt42
-rw-r--r--src/main/kotlin/gui/entity/ModifyInvisible.kt2
-rw-r--r--src/main/kotlin/gui/entity/ModifyName.kt6
-rw-r--r--src/main/kotlin/gui/entity/ModifyPlayerSkin.kt38
-rw-r--r--src/main/kotlin/gui/entity/ModifyRiding.kt2
-rw-r--r--src/main/kotlin/gui/entity/ModifyWither.kt8
-rw-r--r--src/main/kotlin/gui/hud/MoulConfigHud.kt20
-rw-r--r--src/main/kotlin/jarvis/JarvisIntegration.kt8
-rw-r--r--src/main/kotlin/keybindings/FirmamentKeyBindings.kt12
-rw-r--r--src/main/kotlin/keybindings/FirmamentKeyboardState.kt4
-rw-r--r--src/main/kotlin/keybindings/GenericInputButton.kt80
-rw-r--r--src/main/kotlin/keybindings/SavedKeyBinding.kt6
-rw-r--r--src/main/kotlin/repo/ItemCache.kt82
-rw-r--r--src/main/kotlin/repo/MiningRepoData.kt14
-rw-r--r--src/main/kotlin/repo/Reforge.kt18
-rw-r--r--src/main/kotlin/repo/ReforgeStore.kt8
-rw-r--r--src/main/kotlin/repo/RepoManager.kt16
-rw-r--r--src/main/kotlin/repo/RepoModResourcePack.kt74
-rw-r--r--src/main/kotlin/repo/SBItemStack.kt146
-rw-r--r--src/main/kotlin/repo/recipes/GenericRecipeRenderer.kt10
-rw-r--r--src/main/kotlin/repo/recipes/RecipeLayouter.kt6
-rw-r--r--src/main/kotlin/repo/recipes/SBCraftingRecipeRenderer.kt14
-rw-r--r--src/main/kotlin/repo/recipes/SBEssenceUpgradeRecipeRenderer.kt10
-rw-r--r--src/main/kotlin/repo/recipes/SBForgeRecipeRenderer.kt20
-rw-r--r--src/main/kotlin/util/CommonSoundEffects.kt14
-rw-r--r--src/main/kotlin/util/DurabilityBarEvent.kt2
-rw-r--r--src/main/kotlin/util/FirmFormatters.kt14
-rw-r--r--src/main/kotlin/util/FragmentGuiScreen.kt28
-rw-r--r--src/main/kotlin/util/HoveredItemStack.kt12
-rw-r--r--src/main/kotlin/util/IdentifierSerializer.kt10
-rw-r--r--src/main/kotlin/util/LegacyFormattingCode.kt4
-rw-r--r--src/main/kotlin/util/LegacyTagParser.kt52
-rw-r--r--src/main/kotlin/util/LegacyTagWriter.kt54
-rw-r--r--src/main/kotlin/util/LoadResource.kt6
-rw-r--r--src/main/kotlin/util/MC.kt126
-rw-r--r--src/main/kotlin/util/MinecraftDispatcher.kt4
-rw-r--r--src/main/kotlin/util/MoulConfigFragment.kt14
-rw-r--r--src/main/kotlin/util/MoulConfigUtils.kt26
-rw-r--r--src/main/kotlin/util/ScoreboardUtil.kt42
-rw-r--r--src/main/kotlin/util/ScreenUtil.kt10
-rw-r--r--src/main/kotlin/util/SkyblockId.kt46
-rw-r--r--src/main/kotlin/util/WarpUtil.kt22
-rw-r--r--src/main/kotlin/util/accessors/GetRectangle.kt4
-rw-r--r--src/main/kotlin/util/accessors/chathud.kt6
-rw-r--r--src/main/kotlin/util/async/input.kt2
-rw-r--r--src/main/kotlin/util/colorconversion.kt8
-rw-r--r--src/main/kotlin/util/customgui/CoordRememberingSlot.kt2
-rw-r--r--src/main/kotlin/util/customgui/CustomGui.kt34
-rw-r--r--src/main/kotlin/util/customgui/HasCustomGui.kt4
-rw-r--r--src/main/kotlin/util/json/BlockPosSerializer.kt2
-rw-r--r--src/main/kotlin/util/json/FirmCodecs.kt4
-rw-r--r--src/main/kotlin/util/math/Projections.kt12
-rw-r--r--src/main/kotlin/util/mc/ArmorUtil.kt6
-rw-r--r--src/main/kotlin/util/mc/CustomRenderPassHelper.kt46
-rw-r--r--src/main/kotlin/util/mc/FakeInventory.kt24
-rw-r--r--src/main/kotlin/util/mc/FakeSlot.kt12
-rw-r--r--src/main/kotlin/util/mc/FirmamentDataComponentTypes.kt28
-rw-r--r--src/main/kotlin/util/mc/IntrospectableItemModelManager.kt4
-rw-r--r--src/main/kotlin/util/mc/InventoryUtil.kt14
-rw-r--r--src/main/kotlin/util/mc/ItemUtil.kt18
-rw-r--r--src/main/kotlin/util/mc/MCTabListAPI.kt32
-rw-r--r--src/main/kotlin/util/mc/NbtItemData.kt24
-rw-r--r--src/main/kotlin/util/mc/NbtPrism.kt20
-rw-r--r--src/main/kotlin/util/mc/NbtUtil.kt10
-rw-r--r--src/main/kotlin/util/mc/PlayerUtil.kt6
-rw-r--r--src/main/kotlin/util/mc/SNbtFormatter.kt80
-rw-r--r--src/main/kotlin/util/mc/ScreenUtil.kt16
-rw-r--r--src/main/kotlin/util/mc/SkullItemData.kt12
-rw-r--r--src/main/kotlin/util/mc/SlotUtils.kt44
-rw-r--r--src/main/kotlin/util/mc/TolerantRegistriesOps.kt24
-rw-r--r--src/main/kotlin/util/mc/asFakeServer.kt24
-rw-r--r--src/main/kotlin/util/render/CustomRenderLayers.kt68
-rw-r--r--src/main/kotlin/util/render/DrawContextExt.kt108
-rw-r--r--src/main/kotlin/util/render/DumpTexture.kt6
-rw-r--r--src/main/kotlin/util/render/FacingThePlayerContext.kt94
-rw-r--r--src/main/kotlin/util/render/MultiSpecialGuiRenderState.kt36
-rw-r--r--src/main/kotlin/util/render/RenderCircleProgress.kt88
-rw-r--r--src/main/kotlin/util/render/RenderInWorldContext.kt206
-rw-r--r--src/main/kotlin/util/render/TintedOverlayTexture.kt10
-rw-r--r--src/main/kotlin/util/render/TranslatedScissors.kt8
-rw-r--r--src/main/kotlin/util/skyblock/AbilityUtils.kt12
-rw-r--r--src/main/kotlin/util/skyblock/ItemType.kt2
-rw-r--r--src/main/kotlin/util/skyblock/PartyUtil.kt6
-rw-r--r--src/main/kotlin/util/skyblock/Rarity.kt34
-rw-r--r--src/main/kotlin/util/skyblock/SBItemUtil.kt4
-rw-r--r--src/main/kotlin/util/skyblock/SackUtil.kt18
-rw-r--r--src/main/kotlin/util/skyblock/ScreenIdentification.kt14
-rw-r--r--src/main/kotlin/util/skyblock/TabListAPI.kt6
-rw-r--r--src/main/kotlin/util/textutil.kt114
-rw-r--r--src/main/resources/firmament.accesswidener74
289 files changed, 3328 insertions, 3328 deletions
diff --git a/src/main/java/moe/nea/firmament/init/HandledScreenRiser.java b/src/main/java/moe/nea/firmament/init/HandledScreenRiser.java
index 605e7ac..881990c 100644
--- a/src/main/java/moe/nea/firmament/init/HandledScreenRiser.java
+++ b/src/main/java/moe/nea/firmament/init/HandledScreenRiser.java
@@ -2,11 +2,11 @@
package moe.nea.firmament.init;
import me.shedaniel.mm.api.ClassTinkerers;
-import net.minecraft.client.gui.Element;
-import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.client.gui.screen.ingame.HandledScreen;
-import net.minecraft.client.input.CharInput;
-import net.minecraft.client.input.KeyInput;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
+import net.minecraft.client.input.CharacterEvent;
+import net.minecraft.client.input.KeyEvent;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.ClassNode;
@@ -24,11 +24,11 @@ import java.util.function.Consumer;
public class HandledScreenRiser extends RiserUtils {
Intermediary.InterClass Screen = Intermediary.<Screen>intermediaryClass();
- Intermediary.InterClass KeyInput = Intermediary.<KeyInput>intermediaryClass();
- Intermediary.InterClass CharInput = Intermediary.<CharInput>intermediaryClass();
- Intermediary.InterClass HandledScreen = Intermediary.<HandledScreen>intermediaryClass();
+ Intermediary.InterClass KeyInput = Intermediary.<KeyEvent>intermediaryClass();
+ Intermediary.InterClass CharInput = Intermediary.<CharacterEvent>intermediaryClass();
+ Intermediary.InterClass HandledScreen = Intermediary.<AbstractContainerScreen>intermediaryClass();
Intermediary.InterMethod mouseScrolled = Intermediary.intermediaryMethod(
- Element::mouseScrolled,
+ GuiEventListener::mouseScrolled,
Intermediary.ofClass(boolean.class),
Intermediary.ofClass(double.class),
Intermediary.ofClass(double.class),
@@ -36,12 +36,12 @@ public class HandledScreenRiser extends RiserUtils {
Intermediary.ofClass(double.class)
);
Intermediary.InterMethod keyReleased = Intermediary.intermediaryMethod(
- Element::keyReleased,
+ GuiEventListener::keyReleased,
Intermediary.ofClass(boolean.class),
KeyInput
);
Intermediary.InterMethod charTyped = Intermediary.intermediaryMethod(
- Element::charTyped,
+ GuiEventListener::charTyped,
Intermediary.ofClass(boolean.class),
CharInput
);
diff --git a/src/main/java/moe/nea/firmament/init/SectionBuilderRiser.java b/src/main/java/moe/nea/firmament/init/SectionBuilderRiser.java
index 03c63b3..a5d5c1d 100644
--- a/src/main/java/moe/nea/firmament/init/SectionBuilderRiser.java
+++ b/src/main/java/moe/nea/firmament/init/SectionBuilderRiser.java
@@ -1,11 +1,11 @@
package moe.nea.firmament.init;
import net.fabricmc.loader.api.FabricLoader;
-import net.minecraft.block.BlockState;
-import net.minecraft.client.render.block.BlockRenderManager;
-import net.minecraft.client.render.chunk.SectionBuilder;
-import net.minecraft.client.render.model.BlockStateModel;
-import net.minecraft.util.math.BlockPos;
+import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.client.renderer.block.BlockRenderDispatcher;
+import net.minecraft.client.renderer.chunk.SectionCompiler;
+import net.minecraft.client.renderer.block.model.BlockStateModel;
+import net.minecraft.core.BlockPos;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AbstractInsnNode;
@@ -18,16 +18,16 @@ import org.objectweb.asm.tree.VarInsnNode;
public class SectionBuilderRiser extends RiserUtils {
- Intermediary.InterClass SectionBuilder = Intermediary.<SectionBuilder>intermediaryClass();
+ Intermediary.InterClass SectionBuilder = Intermediary.<SectionCompiler>intermediaryClass();
Intermediary.InterClass BlockPos = Intermediary.<BlockPos>intermediaryClass();
- Intermediary.InterClass BlockRenderManager = Intermediary.<BlockRenderManager>intermediaryClass();
+ Intermediary.InterClass BlockRenderManager = Intermediary.<BlockRenderDispatcher>intermediaryClass();
Intermediary.InterClass BlockState = Intermediary.<BlockState>intermediaryClass();
Intermediary.InterClass BlockStateModel = Intermediary.<BlockStateModel>intermediaryClass();
String CustomBlockTextures = "moe.nea.firmament.features.texturepack.CustomBlockTextures";
Intermediary.InterMethod getModel =
Intermediary.intermediaryMethod(
- net.minecraft.client.render.block.BlockRenderManager::getModel,
+ net.minecraft.client.renderer.block.BlockRenderDispatcher::getBlockModel,
BlockStateModel,
BlockState
);
diff --git a/src/main/java/moe/nea/firmament/mixins/AppendRepoAsResourcePack.java b/src/main/java/moe/nea/firmament/mixins/AppendRepoAsResourcePack.java
index d8e35d7..30b5020 100644
--- a/src/main/java/moe/nea/firmament/mixins/AppendRepoAsResourcePack.java
+++ b/src/main/java/moe/nea/firmament/mixins/AppendRepoAsResourcePack.java
@@ -7,7 +7,7 @@ import net.fabricmc.fabric.api.resource.ModResourcePack;
import net.fabricmc.fabric.impl.resource.loader.ModResourcePackSorter;
import net.fabricmc.fabric.impl.resource.loader.ModResourcePackUtil;
import net.fabricmc.loader.api.FabricLoader;
-import net.minecraft.resource.ResourceType;
+import net.minecraft.server.packs.PackType;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@@ -25,7 +25,7 @@ public class AppendRepoAsResourcePack {
require = 0
)
private static void onAppendModResourcePack(
- FabricLoader fabricLoader, ResourceType type, @Nullable String subPath, CallbackInfoReturnable<List<ModResourcePack>> cir,
+ FabricLoader fabricLoader, PackType type, @Nullable String subPath, CallbackInfoReturnable<List<ModResourcePack>> cir,
@Local ModResourcePackSorter sorter
) {
RepoModResourcePack.Companion.append(sorter);
diff --git a/src/main/java/moe/nea/firmament/mixins/BandAidResourcePackPatch.java b/src/main/java/moe/nea/firmament/mixins/BandAidResourcePackPatch.java
index d898c44..8e591bd 100644
--- a/src/main/java/moe/nea/firmament/mixins/BandAidResourcePackPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/BandAidResourcePackPatch.java
@@ -4,22 +4,22 @@ package moe.nea.firmament.mixins;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.llamalad7.mixinextras.sugar.Local;
import moe.nea.firmament.repo.RepoModResourcePack;
-import net.minecraft.resource.ReloadableResourceManagerImpl;
-import net.minecraft.resource.Resource;
-import net.minecraft.util.Identifier;
+import net.minecraft.server.packs.resources.ReloadableResourceManager;
+import net.minecraft.server.packs.resources.Resource;
+import net.minecraft.resources.ResourceLocation;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import java.util.Optional;
-@Mixin(ReloadableResourceManagerImpl.class)
+@Mixin(ReloadableResourceManager.class)
public class BandAidResourcePackPatch {
@ModifyReturnValue(
method = "getResource",
at = @At("RETURN")
)
- private Optional<Resource> injectOurCustomResourcesInCaseExistingMethodsFailed(Optional<Resource> original, @Local Identifier identifier) {
+ private Optional<Resource> injectOurCustomResourcesInCaseExistingMethodsFailed(Optional<Resource> original, @Local ResourceLocation identifier) {
return original.or(() -> RepoModResourcePack.Companion.createResourceDirectly(identifier));
}
}
diff --git a/src/main/java/moe/nea/firmament/mixins/ChatPeekingPatch.java b/src/main/java/moe/nea/firmament/mixins/ChatPeekingPatch.java
index 9f6fb4d..2bc1374 100644
--- a/src/main/java/moe/nea/firmament/mixins/ChatPeekingPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/ChatPeekingPatch.java
@@ -4,12 +4,12 @@ package moe.nea.firmament.mixins;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import moe.nea.firmament.features.fixes.Fixes;
-import net.minecraft.client.gui.hud.ChatHud;
+import net.minecraft.client.gui.components.ChatComponent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
-@Mixin(ChatHud.class)
+@Mixin(ChatComponent.class)
public class ChatPeekingPatch {
@ModifyVariable(method = "render", at = @At(value = "HEAD"), index = 5, argsOnly = true)
@@ -17,7 +17,7 @@ public class ChatPeekingPatch {
return old || Fixes.INSTANCE.shouldPeekChat();
}
- @ModifyExpressionValue(method = "getHeight()I", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;isChatFocused()Z"))
+ @ModifyExpressionValue(method = "getHeight()I", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/ChatComponent;isChatFocused()Z"))
public boolean onGetChatHudHeight(boolean old) {
return old || Fixes.INSTANCE.shouldPeekChat();
}
diff --git a/src/main/java/moe/nea/firmament/mixins/CopyChatPatch.java b/src/main/java/moe/nea/firmament/mixins/CopyChatPatch.java
index ba337da..9079fc9 100644
--- a/src/main/java/moe/nea/firmament/mixins/CopyChatPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/CopyChatPatch.java
@@ -3,14 +3,14 @@ package moe.nea.firmament.mixins;
import moe.nea.firmament.features.chat.CopyChat;
import moe.nea.firmament.mixins.accessor.AccessorChatHud;
import moe.nea.firmament.util.ClipboardUtils;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.Click;
-import net.minecraft.client.gui.hud.ChatHud;
-import net.minecraft.client.gui.hud.ChatHudLine;
-import net.minecraft.client.gui.screen.ChatScreen;
-import net.minecraft.text.Text;
-import net.minecraft.util.Formatting;
-import net.minecraft.util.math.MathHelper;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.input.MouseButtonEvent;
+import net.minecraft.client.gui.components.ChatComponent;
+import net.minecraft.client.GuiMessage;
+import net.minecraft.client.gui.screens.ChatScreen;
+import net.minecraft.network.chat.Component;
+import net.minecraft.ChatFormatting;
+import net.minecraft.util.Mth;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
@@ -21,25 +21,25 @@ import java.util.List;
@Mixin(ChatScreen.class)
public class CopyChatPatch {
@Inject(method = "mouseClicked", at = @At("HEAD"), cancellable = true)
- private void onRightClick(Click click, boolean doubled, CallbackInfoReturnable<Boolean> cir) throws NoSuchFieldException, IllegalAccessException {
+ private void onRightClick(MouseButtonEvent click, boolean doubled, CallbackInfoReturnable<Boolean> cir) throws NoSuchFieldException, IllegalAccessException {
if (click.button() != 1 || !CopyChat.TConfig.INSTANCE.getCopyChat()) return;
- MinecraftClient client = MinecraftClient.getInstance();
- ChatHud chatHud = client.inGameHud.getChatHud();
+ Minecraft client = Minecraft.getInstance();
+ ChatComponent chatHud = client.gui.getChat();
int lineIndex = getChatLineIndex(chatHud, click.y());
if (lineIndex < 0) return;
- List<ChatHudLine.Visible> visible = ((AccessorChatHud) chatHud).getVisibleMessages_firmament();
+ List<GuiMessage.Line> visible = ((AccessorChatHud) chatHud).getVisibleMessages_firmament();
if (lineIndex >= visible.size()) return;
- ChatHudLine.Visible line = visible.get(lineIndex);
+ GuiMessage.Line line = visible.get(lineIndex);
String text = CopyChat.INSTANCE.orderedTextToString(line.content());
ClipboardUtils.INSTANCE.setTextContent(text);
- chatHud.addMessage(Text.literal("Copied: ").append(text).formatted(Formatting.GRAY));
+ chatHud.addMessage(Component.literal("Copied: ").append(text).withStyle(ChatFormatting.GRAY));
cir.setReturnValue(true);
cir.cancel();
}
@Unique
- private int getChatLineIndex(ChatHud chatHud, double mouseY) {
+ private int getChatLineIndex(ChatComponent chatHud, double mouseY) {
double chatLineY = ((AccessorChatHud) chatHud).toChatLineY_firmament(mouseY);
- return MathHelper.floor(chatLineY + ((AccessorChatHud) chatHud).getScrolledLines_firmament());
+ return Mth.floor(chatLineY + ((AccessorChatHud) chatHud).getScrolledLines_firmament());
}
}
diff --git a/src/main/java/moe/nea/firmament/mixins/CustomDurabilityBarPatch.java b/src/main/java/moe/nea/firmament/mixins/CustomDurabilityBarPatch.java
index fde3580..2299068 100644
--- a/src/main/java/moe/nea/firmament/mixins/CustomDurabilityBarPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/CustomDurabilityBarPatch.java
@@ -6,20 +6,20 @@ import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Share;
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
import moe.nea.firmament.util.DurabilityBarEvent;
-import net.minecraft.client.gui.DrawContext;
-import net.minecraft.item.ItemStack;
+import net.minecraft.client.gui.GuiGraphics;
+import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
-@Mixin(DrawContext.class)
+@Mixin(GuiGraphics.class)
public class CustomDurabilityBarPatch {
@WrapOperation(
- method = "drawItemBar",
- at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;isItemBarVisible()Z")
+ method = "renderItemBar",
+ at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;isBarVisible()Z")
)
private boolean onIsItemBarVisible(
- ItemStack instance, Operation<Boolean> original,
- @Share("barOverride") LocalRef<DurabilityBarEvent.DurabilityBar> barOverride
+ ItemStack instance, Operation<Boolean> original,
+ @Share("barOverride") LocalRef<DurabilityBarEvent.DurabilityBar> barOverride
) {
if (original.call(instance))
return true;
@@ -29,22 +29,22 @@ public class CustomDurabilityBarPatch {
return barOverride.get() != null;
}
- @WrapOperation(method = "drawItemBar",
- at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getItemBarStep()I"))
+ @WrapOperation(method = "renderItemBar",
+ at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;getBarWidth()I"))
private int overrideItemStep(
- ItemStack instance, Operation<Integer> original,
- @Share("barOverride") LocalRef<DurabilityBarEvent.DurabilityBar> barOverride
+ ItemStack instance, Operation<Integer> original,
+ @Share("barOverride") LocalRef<DurabilityBarEvent.DurabilityBar> barOverride
) {
if (barOverride.get() != null)
return Math.round(barOverride.get().getPercentage() * 13);
return original.call(instance);
}
- @WrapOperation(method = "drawItemBar",
- at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getItemBarColor()I"))
+ @WrapOperation(method = "renderItemBar",
+ at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;getBarColor()I"))
private int overrideItemColor(
- ItemStack instance, Operation<Integer> original,
- @Share("barOverride") LocalRef<DurabilityBarEvent.DurabilityBar> barOverride
+ ItemStack instance, Operation<Integer> original,
+ @Share("barOverride") LocalRef<DurabilityBarEvent.DurabilityBar> barOverride
) {
if (barOverride.get() != null)
return barOverride.get().getColor().getColor();
diff --git a/src/main/java/moe/nea/firmament/mixins/DFUEntityIdFixPatch.java b/src/main/java/moe/nea/firmament/mixins/DFUEntityIdFixPatch.java
index 717d404..8503411 100644
--- a/src/main/java/moe/nea/firmament/mixins/DFUEntityIdFixPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/DFUEntityIdFixPatch.java
@@ -6,8 +6,8 @@ import com.mojang.datafixers.DataFix;
import com.mojang.datafixers.TypeRewriteRule;
import com.mojang.datafixers.schemas.Schema;
import com.mojang.datafixers.util.Pair;
-import net.minecraft.datafixer.TypeReferences;
-import net.minecraft.datafixer.fix.EntityIdFix;
+import net.minecraft.util.datafix.fixes.References;
+import net.minecraft.util.datafix.fixes.EntityIdFix;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -22,7 +22,7 @@ import java.util.Map;
public abstract class DFUEntityIdFixPatch extends DataFix {
@Shadow
@Final
- private static Map<String, String> RENAMED_ENTITIES;
+ private static Map<String, String> ID_MAP;
public DFUEntityIdFixPatch(Schema outputSchema, boolean changesType) {
super(outputSchema, changesType);
@@ -30,6 +30,6 @@ public abstract class DFUEntityIdFixPatch extends DataFix {
@Inject(method = "makeRule", at = @At("RETURN"), cancellable = true)
public void onMakeRule(CallbackInfoReturnable<TypeRewriteRule> cir) {
- cir.setReturnValue(TypeRewriteRule.seq(fixTypeEverywhere("EntityIdFix", getInputSchema().findChoiceType(TypeReferences.ENTITY), getOutputSchema().findChoiceType(TypeReferences.ENTITY), dynamicOps -> pair -> ((Pair) pair).mapFirst(string -> RENAMED_ENTITIES.getOrDefault(string, (String) string))), convertUnchecked("Fix Type", getInputSchema().getType(TypeReferences.ITEM_STACK), getOutputSchema().getType(TypeReferences.ITEM_STACK))));
+ cir.setReturnValue(TypeRewriteRule.seq(fixTypeEverywhere("EntityIdFix", getInputSchema().findChoiceType(References.ENTITY), getOutputSchema().findChoiceType(References.ENTITY), dynamicOps -> pair -> ((Pair) pair).mapFirst(string -> ID_MAP.getOrDefault(string, (String) string))), convertUnchecked("Fix Type", getInputSchema().getType(References.ITEM_STACK), getOutputSchema().getType(References.ITEM_STACK))));
}
}
diff --git a/src/main/java/moe/nea/firmament/mixins/DisableHurtCam.java b/src/main/java/moe/nea/firmament/mixins/DisableHurtCam.java
index ed7a2d4..3a53ab1 100644
--- a/src/main/java/moe/nea/firmament/mixins/DisableHurtCam.java
+++ b/src/main/java/moe/nea/firmament/mixins/DisableHurtCam.java
@@ -2,14 +2,14 @@ package moe.nea.firmament.mixins;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import moe.nea.firmament.features.fixes.Fixes;
-import net.minecraft.client.render.GameRenderer;
+import net.minecraft.client.renderer.GameRenderer;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@Mixin(GameRenderer.class)
public class DisableHurtCam {
- @ModifyExpressionValue(method = "tiltViewWhenHurt", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/LivingEntity;hurtTime:I", opcode = Opcodes.GETFIELD))
+ @ModifyExpressionValue(method = "bobHurt", at = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/LivingEntity;hurtTime:I", opcode = Opcodes.GETFIELD))
private int replaceHurtTime(int original) {
if (Fixes.TConfig.INSTANCE.getNoHurtCam())
return 0;
diff --git a/src/main/java/moe/nea/firmament/mixins/DispatchMouseInputEventsPatch.java b/src/main/java/moe/nea/firmament/mixins/DispatchMouseInputEventsPatch.java
index f1b07bb..8b9a28c 100644
--- a/src/main/java/moe/nea/firmament/mixins/DispatchMouseInputEventsPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/DispatchMouseInputEventsPatch.java
@@ -2,15 +2,15 @@ package moe.nea.firmament.mixins;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import moe.nea.firmament.events.WorldMouseMoveEvent;
-import net.minecraft.client.Mouse;
-import net.minecraft.client.network.ClientPlayerEntity;
+import net.minecraft.client.MouseHandler;
+import net.minecraft.client.player.LocalPlayer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
-@Mixin(Mouse.class)
+@Mixin(MouseHandler.class)
public class DispatchMouseInputEventsPatch {
- @WrapWithCondition(method = "updateMouse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;changeLookDirection(DD)V"))
- public boolean onRotatePlayer(ClientPlayerEntity instance, double deltaX, double deltaY) {
+ @WrapWithCondition(method = "turnPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;changeLookDirection(DD)V"))
+ public boolean onRotatePlayer(LocalPlayer instance, double deltaX, double deltaY) {
var event = WorldMouseMoveEvent.Companion.publish(new WorldMouseMoveEvent(deltaX, deltaY));
return !event.getCancelled();
}
diff --git a/src/main/java/moe/nea/firmament/mixins/EarlyResourceReloadPatch.java b/src/main/java/moe/nea/firmament/mixins/EarlyResourceReloadPatch.java
index e98faf6..b8460a7 100644
--- a/src/main/java/moe/nea/firmament/mixins/EarlyResourceReloadPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/EarlyResourceReloadPatch.java
@@ -2,10 +2,10 @@
package moe.nea.firmament.mixins;
import moe.nea.firmament.events.EarlyResourceReloadEvent;
-import net.minecraft.resource.ReloadableResourceManagerImpl;
-import net.minecraft.resource.ResourceManager;
-import net.minecraft.resource.ResourcePack;
-import net.minecraft.resource.ResourceReload;
+import net.minecraft.server.packs.resources.ReloadableResourceManager;
+import net.minecraft.server.packs.resources.ResourceManager;
+import net.minecraft.server.packs.PackResources;
+import net.minecraft.server.packs.resources.ReloadInstance;
import net.minecraft.util.Unit;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@@ -16,10 +16,10 @@ import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
-@Mixin(ReloadableResourceManagerImpl.class)
+@Mixin(ReloadableResourceManager.class)
public abstract class EarlyResourceReloadPatch implements ResourceManager {
- @Inject(method = "reload", at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/SimpleResourceReload;start(Lnet/minecraft/resource/ResourceManager;Ljava/util/List;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;Ljava/util/concurrent/CompletableFuture;Z)Lnet/minecraft/resource/ResourceReload;", shift = At.Shift.BEFORE))
- public void onResourceReload(Executor prepareExecutor, Executor applyExecutor, CompletableFuture<Unit> initialStage, List<ResourcePack> packs, CallbackInfoReturnable<ResourceReload> cir) {
+ @Inject(method = "createReload", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/packs/resources/SimpleReloadInstance;create(Lnet/minecraft/server/packs/resources/ResourceManager;Ljava/util/List;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;Ljava/util/concurrent/CompletableFuture;Z)Lnet/minecraft/server/packs/resources/ReloadInstance;", shift = At.Shift.BEFORE))
+ public void onResourceReload(Executor prepareExecutor, Executor applyExecutor, CompletableFuture<Unit> initialStage, List<PackResources> packs, CallbackInfoReturnable<ReloadInstance> cir) {
EarlyResourceReloadEvent.Companion.publish(new EarlyResourceReloadEvent(this, prepareExecutor));
}
}
diff --git a/src/main/java/moe/nea/firmament/mixins/EntityDespawnPatch.java b/src/main/java/moe/nea/firmament/mixins/EntityDespawnPatch.java
index 22bebec..c286226 100644
--- a/src/main/java/moe/nea/firmament/mixins/EntityDespawnPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/EntityDespawnPatch.java
@@ -3,15 +3,15 @@ package moe.nea.firmament.mixins;
import com.llamalad7.mixinextras.sugar.Local;
import moe.nea.firmament.events.EntityDespawnEvent;
-import net.minecraft.client.world.ClientWorld;
-import net.minecraft.entity.Entity;
+import net.minecraft.client.multiplayer.ClientLevel;
+import net.minecraft.world.entity.Entity;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(ClientWorld.class)
+@Mixin(ClientLevel.class)
public class EntityDespawnPatch {
@Inject(method = "removeEntity", at = @At(value = "TAIL"))
private void onRemoved(int entityId, Entity.RemovalReason removalReason, CallbackInfo ci, @Local @Nullable Entity entity) {
diff --git a/src/main/java/moe/nea/firmament/mixins/EntityInteractEventPatch.java b/src/main/java/moe/nea/firmament/mixins/EntityInteractEventPatch.java
index 8ade59b..4138389 100644
--- a/src/main/java/moe/nea/firmament/mixins/EntityInteractEventPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/EntityInteractEventPatch.java
@@ -2,32 +2,32 @@
package moe.nea.firmament.mixins;
import moe.nea.firmament.events.EntityInteractionEvent;
-import net.minecraft.client.network.ClientPlayerInteractionManager;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.util.ActionResult;
-import net.minecraft.util.Hand;
-import net.minecraft.util.hit.EntityHitResult;
+import net.minecraft.client.multiplayer.MultiPlayerGameMode;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.InteractionResult;
+import net.minecraft.world.InteractionHand;
+import net.minecraft.world.phys.EntityHitResult;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-@Mixin(ClientPlayerInteractionManager.class)
+@Mixin(MultiPlayerGameMode.class)
public class EntityInteractEventPatch {
- @Inject(method = "attackEntity", at = @At("HEAD"))
- private void onAttack(PlayerEntity player, Entity target, CallbackInfo ci) {
- EntityInteractionEvent.Companion.publish(new EntityInteractionEvent(EntityInteractionEvent.InteractionKind.ATTACK, target, Hand.MAIN_HAND));
+ @Inject(method = "attack", at = @At("HEAD"))
+ private void onAttack(Player player, Entity target, CallbackInfo ci) {
+ EntityInteractionEvent.Companion.publish(new EntityInteractionEvent(EntityInteractionEvent.InteractionKind.ATTACK, target, InteractionHand.MAIN_HAND));
}
- @Inject(method = "interactEntity", at = @At("HEAD"))
- private void onInteract(PlayerEntity player, Entity entity, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
+ @Inject(method = "interact", at = @At("HEAD"))
+ private void onInteract(Player player, Entity entity, InteractionHand hand, CallbackInfoReturnable<InteractionResult> cir) {
EntityInteractionEvent.Companion.publish(new EntityInteractionEvent(EntityInteractionEvent.InteractionKind.INTERACT, entity, hand));
}
- @Inject(method = "interactEntityAtLocation", at = @At("HEAD"))
- private void onInteractAtLocation(PlayerEntity player, Entity entity, EntityHitResult hitResult, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
+ @Inject(method = "interactAt", at = @At("HEAD"))
+ private void onInteractAtLocation(Player player, Entity entity, EntityHitResult hitResult, InteractionHand hand, CallbackInfoReturnable<InteractionResult> cir) {
EntityInteractionEvent.Companion.publish(new EntityInteractionEvent(EntityInteractionEvent.InteractionKind.INTERACT_AT_LOCATION, entity, hand));
}
diff --git a/src/main/java/moe/nea/firmament/mixins/EntityUpdateEventListener.java b/src/main/java/moe/nea/firmament/mixins/EntityUpdateEventListener.java
index d956da9..0021099 100644
--- a/src/main/java/moe/nea/firmament/mixins/EntityUpdateEventListener.java
+++ b/src/main/java/moe/nea/firmament/mixins/EntityUpdateEventListener.java
@@ -3,46 +3,46 @@ package moe.nea.firmament.mixins;
import com.llamalad7.mixinextras.sugar.Local;
import moe.nea.firmament.events.EntityUpdateEvent;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.network.ClientCommonNetworkHandler;
-import net.minecraft.client.network.ClientConnectionState;
-import net.minecraft.client.network.ClientPlayNetworkHandler;
-import net.minecraft.client.world.ClientWorld;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.LivingEntity;
-import net.minecraft.network.ClientConnection;
-import net.minecraft.network.packet.s2c.play.EntityAttributesS2CPacket;
-import net.minecraft.network.packet.s2c.play.EntityEquipmentUpdateS2CPacket;
-import net.minecraft.network.packet.s2c.play.EntityTrackerUpdateS2CPacket;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
+import net.minecraft.client.multiplayer.CommonListenerCookie;
+import net.minecraft.client.multiplayer.ClientPacketListener;
+import net.minecraft.client.multiplayer.ClientLevel;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.entity.LivingEntity;
+import net.minecraft.network.Connection;
+import net.minecraft.network.protocol.game.ClientboundUpdateAttributesPacket;
+import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
+import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(ClientPlayNetworkHandler.class)
-public abstract class EntityUpdateEventListener extends ClientCommonNetworkHandler {
+@Mixin(ClientPacketListener.class)
+public abstract class EntityUpdateEventListener extends ClientCommonPacketListenerImpl {
@Shadow
- private ClientWorld world;
+ private ClientLevel level;
- protected EntityUpdateEventListener(MinecraftClient client, ClientConnection connection, ClientConnectionState connectionState) {
+ protected EntityUpdateEventListener(Minecraft client, Connection connection, CommonListenerCookie connectionState) {
super(client, connection, connectionState);
}
- @Inject(method = "onEntityEquipmentUpdate", at = @At(value = "INVOKE", target = "Ljava/util/List;forEach(Ljava/util/function/Consumer;)V", shift = At.Shift.AFTER))
- private void onEquipmentUpdate(EntityEquipmentUpdateS2CPacket packet, CallbackInfo ci, @Local LivingEntity entity) {
- EntityUpdateEvent.Companion.publish(new EntityUpdateEvent.EquipmentUpdate(entity, packet.getEquipmentList()));
+ @Inject(method = "handleSetEquipment", at = @At(value = "INVOKE", target = "Ljava/util/List;forEach(Ljava/util/function/Consumer;)V", shift = At.Shift.AFTER))
+ private void onEquipmentUpdate(ClientboundSetEquipmentPacket packet, CallbackInfo ci, @Local LivingEntity entity) {
+ EntityUpdateEvent.Companion.publish(new EntityUpdateEvent.EquipmentUpdate(entity, packet.getSlots()));
}
- @Inject(method = "onEntityAttributes", at = @At("TAIL"))
- private void onAttributeUpdate(EntityAttributesS2CPacket packet, CallbackInfo ci) {
+ @Inject(method = "handleUpdateAttributes", at = @At("TAIL"))
+ private void onAttributeUpdate(ClientboundUpdateAttributesPacket packet, CallbackInfo ci) {
EntityUpdateEvent.Companion.publish(new EntityUpdateEvent.AttributeUpdate(
- (LivingEntity) world.getEntityById(packet.getEntityId()), packet.getEntries()));
+ (LivingEntity) level.getEntity(packet.getEntityId()), packet.getValues()));
}
- @Inject(method = "onEntityTrackerUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/data/DataTracker;writeUpdatedEntries(Ljava/util/List;)V", shift = At.Shift.AFTER))
- private void onEntityTracker(EntityTrackerUpdateS2CPacket packet, CallbackInfo ci, @Local Entity entity) {
- EntityUpdateEvent.Companion.publish(new EntityUpdateEvent.TrackedDataUpdate(entity, packet.trackedValues()));
+ @Inject(method = "handleSetEntityData", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/syncher/SynchedEntityData;assignValues(Ljava/util/List;)V", shift = At.Shift.AFTER))
+ private void onEntityTracker(ClientboundSetEntityDataPacket packet, CallbackInfo ci, @Local Entity entity) {
+ EntityUpdateEvent.Companion.publish(new EntityUpdateEvent.TrackedDataUpdate(entity, packet.packedItems()));
}
}
diff --git a/src/main/java/moe/nea/firmament/mixins/FirmKeybindsInVanillaControlsPatch.java b/src/main/java/moe/nea/firmament/mixins/FirmKeybindsInVanillaControlsPatch.java
index 4c9f925..5d8484f 100644
--- a/src/main/java/moe/nea/firmament/mixins/FirmKeybindsInVanillaControlsPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/FirmKeybindsInVanillaControlsPatch.java
@@ -4,11 +4,11 @@ package moe.nea.firmament.mixins;
import moe.nea.firmament.gui.config.KeyBindingHandler;
import moe.nea.firmament.keybindings.FirmamentKeyBindings;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.screen.option.ControlsListWidget;
-import net.minecraft.client.gui.widget.ButtonWidget;
-import net.minecraft.client.option.KeyBinding;
-import net.minecraft.text.Text;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.screens.options.controls.KeyBindsList;
+import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.KeyMapping;
+import net.minecraft.network.chat.Component;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
@@ -18,39 +18,39 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(ControlsListWidget.KeyBindingEntry.class)
+@Mixin(KeyBindsList.KeyEntry.class)
public class FirmKeybindsInVanillaControlsPatch {
@Mutable
@Shadow
@Final
- private ButtonWidget editButton;
+ private Button changeButton;
@Shadow
@Final
- private KeyBinding binding;
+ private KeyMapping key;
@Shadow
@Final
- private ButtonWidget resetButton;
+ private Button resetButton;
- @ModifyArg(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/ButtonWidget;builder(Lnet/minecraft/text/Text;Lnet/minecraft/client/gui/widget/ButtonWidget$PressAction;)Lnet/minecraft/client/gui/widget/ButtonWidget$Builder;"))
- public ButtonWidget.PressAction onInit(ButtonWidget.PressAction action) {
- var config = FirmamentKeyBindings.INSTANCE.getKeyBindings().get(binding);
+ @ModifyArg(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/Button;builder(Lnet/minecraft/network/chat/Component;Lnet/minecraft/client/gui/components/Button$OnPress;)Lnet/minecraft/client/gui/components/Button$Builder;"))
+ public Button.OnPress onInit(Button.OnPress action) {
+ var config = FirmamentKeyBindings.INSTANCE.getKeyBindings().get(key);
if (config == null) return action;
return button -> {
((KeyBindingHandler) config.getHandler())
.getManagedConfig()
- .showConfigEditor(MinecraftClient.getInstance().currentScreen);
+ .showConfigEditor(Minecraft.getInstance().screen);
};
}
- @Inject(method = "update", at = @At("HEAD"), cancellable = true)
+ @Inject(method = "refreshEntry", at = @At("HEAD"), cancellable = true)
public void onUpdate(CallbackInfo ci) {
- var config = FirmamentKeyBindings.INSTANCE.getKeyBindings().get(binding);
+ var config = FirmamentKeyBindings.INSTANCE.getKeyBindings().get(key);
if (config == null) return;
resetButton.active = false;
- editButton.setMessage(Text.translatable("firmament.keybinding.external", config.getValue().format()));
+ changeButton.setMessage(Component.translatable("firmament.keybinding.external", config.getValue().format()));
ci.cancel();
}
diff --git a/src/main/java/moe/nea/firmament/mixins/HideStatusEffectsPatch.java b/src/main/java/moe/nea/firmament/mixins/HideStatusEffectsPatch.java
index 58f52f4..b2884cd 100644
--- a/src/main/java/moe/nea/firmament/mixins/HideStatusEffectsPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/HideStatusEffectsPatch.java
@@ -2,8 +2,8 @@ package moe.nea.firmament.mixins;
import moe.nea.firmament.features.fixes.Fixes;
import moe.nea.firmament.util.SBData;
-import net.minecraft.client.gui.DrawContext;
-import net.minecraft.client.gui.screen.ingame.StatusEffectsDisplay;
+import net.minecraft.client.gui.GuiGraphics;
+import net.minecraft.client.gui.screens.inventory.EffectsInInventory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@@ -11,20 +11,20 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-@Mixin(StatusEffectsDisplay.class)
+@Mixin(EffectsInInventory.class)
public abstract class HideStatusEffectsPatch {
@Shadow
- public abstract boolean shouldHideStatusEffectHud();
+ public abstract boolean canSeeEffects();
- @Inject(method = "shouldHideStatusEffectHud", at = @At("HEAD"), cancellable = true)
+ @Inject(method = "canSeeEffects", at = @At("HEAD"), cancellable = true)
private void hideStatusEffects(CallbackInfoReturnable<Boolean> cir) {
if (Fixes.TConfig.INSTANCE.getHidePotionEffects()) {
cir.setReturnValue(false);
}
}
- @Inject(method = "drawStatusEffects", at = @At("HEAD"), cancellable = true)
- private void conditionalRenderStatuses(DrawContext context, int mouseX, int mouseY, CallbackInfo ci) {
+ @Inject(method = "renderEffects", at = @At("HEAD"), cancellable = true)
+ private void conditionalRenderStatuses(GuiGraphics context, int mouseX, int mouseY, CallbackInfo ci) {
if (Fixes.TConfig.INSTANCE.getHidePotionEffects()) {
ci.cancel();
}
diff --git a/src/main/java/moe/nea/firmament/mixins/HudRenderEventsPatch.java b/src/main/java/moe/nea/firmament/mixins/HudRenderEventsPatch.java
index 3ec5a0e..1f7e07a 100644
--- a/src/main/java/moe/nea/firmament/mixins/HudRenderEventsPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/HudRenderEventsPatch.java
@@ -6,30 +6,30 @@ import moe.nea.firmament.events.HotbarItemRenderEvent;
import moe.nea.firmament.events.HudRenderEvent;
import moe.nea.firmament.features.fixes.Fixes;
import moe.nea.firmament.util.SBData;
-import net.minecraft.client.gui.DrawContext;
-import net.minecraft.client.gui.hud.InGameHud;
-import net.minecraft.client.render.RenderTickCounter;
-import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.item.ItemStack;
+import net.minecraft.client.gui.GuiGraphics;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.DeltaTracker;
+import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(InGameHud.class)
+@Mixin(Gui.class)
public class HudRenderEventsPatch {
@Inject(method = "renderSleepOverlay", at = @At(value = "HEAD"))
- public void renderCallBack(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) {
+ public void renderCallBack(GuiGraphics context, DeltaTracker tickCounter, CallbackInfo ci) {
HudRenderEvent.Companion.publish(new HudRenderEvent(context, tickCounter));
}
- @Inject(method = "renderHotbarItem", at = @At("HEAD"))
- public void onRenderHotbarItem(DrawContext context, int x, int y, RenderTickCounter tickCounter, PlayerEntity player, ItemStack stack, int seed, CallbackInfo ci) {
+ @Inject(method = "renderSlot", at = @At("HEAD"))
+ public void onRenderHotbarItem(GuiGraphics context, int x, int y, DeltaTracker tickCounter, Player player, ItemStack stack, int seed, CallbackInfo ci) {
if (stack != null && !stack.isEmpty())
HotbarItemRenderEvent.Companion.publish(new HotbarItemRenderEvent(stack, context, x, y, tickCounter));
}
- @Inject(method = "renderStatusEffectOverlay", at = @At("HEAD"), cancellable = true)
+ @Inject(method = "renderEffects", at = @At("HEAD"), cancellable = true)
public void hideStatusEffects(CallbackInfo ci) {
if (Fixes.TConfig.INSTANCE.getHidePotionEffectsHud() && SBData.INSTANCE.isOnSkyblock()) ci.cancel();
}
diff --git a/src/main/java/moe/nea/firmament/mixins/IncomingPacketListenerPatches.java b/src/main/java/moe/nea/firmament/mixins/IncomingPacketListenerPatches.java
index 5ba38c7..9f338f5 100644
--- a/src/main/java/moe/nea/firmament/mixins/IncomingPacketListenerPatches.java
+++ b/src/main/java/moe/nea/firmament/mixins/IncomingPacketListenerPatches.java
@@ -6,33 +6,33 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.mojang.brigadier.CommandDispatcher;
import moe.nea.firmament.events.MaskCommands;
import moe.nea.firmament.events.ParticleSpawnEvent;
-import net.minecraft.client.network.ClientPlayNetworkHandler;
-import net.minecraft.network.packet.s2c.play.ParticleS2CPacket;
-import net.minecraft.util.math.Vec3d;
+import net.minecraft.client.multiplayer.ClientPacketListener;
+import net.minecraft.network.protocol.game.ClientboundLevelParticlesPacket;
+import net.minecraft.world.phys.Vec3;
import org.joml.Vector3f;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(ClientPlayNetworkHandler.class)
+@Mixin(ClientPacketListener.class)
public abstract class IncomingPacketListenerPatches {
- @ModifyExpressionValue(method = "onCommandTree", at = @At(value = "NEW", target = "(Lcom/mojang/brigadier/tree/RootCommandNode;)Lcom/mojang/brigadier/CommandDispatcher;", remap = false))
+ @ModifyExpressionValue(method = "handleCommands", at = @At(value = "NEW", target = "(Lcom/mojang/brigadier/tree/RootCommandNode;)Lcom/mojang/brigadier/CommandDispatcher;", remap = false))
public CommandDispatcher onOnCommandTree(CommandDispatcher dispatcher) {
MaskCommands.Companion.publish(new MaskCommands(dispatcher));
return dispatcher;
}
- @Inject(method = "onParticle", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkThreadUtils;forceMainThread(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/listener/PacketListener;Lnet/minecraft/network/PacketApplyBatcher;)V", shift = At.Shift.AFTER), cancellable = true)
- public void onParticleSpawn(ParticleS2CPacket packet, CallbackInfo ci) {
+ @Inject(method = "handleParticleEvent", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/protocol/PacketUtils;ensureRunningOnSameThread(Lnet/minecraft/network/protocol/Packet;Lnet/minecraft/network/PacketListener;Lnet/minecraft/network/PacketProcessor;)V", shift = At.Shift.AFTER), cancellable = true)
+ public void onParticleSpawn(ClientboundLevelParticlesPacket packet, CallbackInfo ci) {
var event = new ParticleSpawnEvent(
- packet.getParameters(),
- new Vec3d(packet.getX(), packet.getY(), packet.getZ()),
- new Vector3f(packet.getOffsetX(), packet.getOffsetY(), packet.getOffsetZ()),
- packet.isImportant(),
+ packet.getParticle(),
+ new Vec3(packet.getX(), packet.getY(), packet.getZ()),
+ new Vector3f(packet.getXDist(), packet.getYDist(), packet.getZDist()),
+ packet.alwaysShow(),
packet.getCount(),
- packet.getSpeed()
+ packet.getMaxSpeed()
);
ParticleSpawnEvent.Companion.publish(event);
if (event.getCancelled())
diff --git a/src/main/java/moe/nea/firmament/mixins/KeyPressInWorldEventPatch.java b/src/main/java/moe/nea/firmament/mixins/KeyPressInWorldEventPatch.java
index 836aee8..ee7f570 100644
--- a/src/main/java/moe/nea/firmament/mixins/KeyPressInWorldEventPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/KeyPressInWorldEventPatch.java
@@ -7,17 +7,17 @@ import com.llamalad7.mixinextras.sugar.Local;
import moe.nea.firmament.events.WorldKeyboardEvent;
import moe.nea.firmament.keybindings.GenericInputAction;
import moe.nea.firmament.keybindings.InputModifiers;
-import net.minecraft.client.Keyboard;
-import net.minecraft.client.input.KeyInput;
-import net.minecraft.client.util.InputUtil;
+import net.minecraft.client.KeyboardHandler;
+import net.minecraft.client.input.KeyEvent;
+import com.mojang.blaze3d.platform.InputConstants;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
-@Mixin(Keyboard.class)
+@Mixin(KeyboardHandler.class)
public class KeyPressInWorldEventPatch {
- @WrapWithCondition(method = "onKey", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBinding;onKeyPressed(Lnet/minecraft/client/util/InputUtil$Key;)V"))
- public boolean onKeyBoardInWorld(InputUtil.Key key, @Local(argsOnly = true) KeyInput keyInput) {
+ @WrapWithCondition(method = "keyPress", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/KeyMapping;click(Lcom/mojang/blaze3d/platform/InputConstants$Key;)V"))
+ public boolean onKeyBoardInWorld(InputConstants.Key key, @Local(argsOnly = true) KeyEvent keyInput) {
var event = WorldKeyboardEvent.Companion.publish(new WorldKeyboardEvent(GenericInputAction.of(keyInput), InputModifiers.of(keyInput)));
return !event.getCancelled();
}
diff --git a/src/main/java/moe/nea/firmament/mixins/MainWindowFirstLoadPatch.java b/src/main/java/moe/nea/firmament/mixins/MainWindowFirstLoadPatch.java
index 9e42b20..2f82fd9 100644
--- a/src/main/java/moe/nea/firmament/mixins/MainWindowFirstLoadPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/MainWindowFirstLoadPatch.java
@@ -2,8 +2,8 @@ package moe.nea.firmament.mixins;
import moe.nea.firmament.Firmament;
import moe.nea.firmament.events.DebugInstantiateEvent;
-import net.minecraft.client.gui.LogoDrawer;
-import net.minecraft.client.gui.screen.TitleScreen;
+import net.minecraft.client.gui.components.LogoRenderer;
+import net.minecraft.client.gui.screens.TitleScreen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
@@ -15,8 +15,8 @@ public class MainWindowFirstLoadPatch {
@Unique
private static boolean hasInited = false;
- @Inject(method = "<init>(ZLnet/minecraft/client/gui/LogoDrawer;)V", at = @At("RETURN"))
- private void onCreate(boolean doBackgroundFade, LogoDrawer logoDrawer, CallbackInfo ci) {
+ @Inject(method = "<init>(ZLnet/minecraft/client/gui/components/LogoRenderer;)V", at = @At("RETURN"))
+ private void onCreate(boolean doBackgroundFade, LogoRenderer logoDrawer, CallbackInfo ci) {
if (!hasInited && Firmament.INSTANCE.getDEBUG()) {
try {
DebugInstantiateEvent.Companion.publish(new DebugInstantiateEvent());
diff --git a/src/main/java/moe/nea/firmament/mixins/MaintainKeyboardStatePatch.java b/src/main/java/moe/nea/firmament/mixins/MaintainKeyboardStatePatch.java
index 15fc5df..97d524a 100644
--- a/src/main/java/moe/nea/firmament/mixins/MaintainKeyboardStatePatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/MaintainKeyboardStatePatch.java
@@ -1,17 +1,17 @@
package moe.nea.firmament.mixins;
import moe.nea.firmament.keybindings.FirmamentKeyboardState;
-import net.minecraft.client.Keyboard;
-import net.minecraft.client.input.KeyInput;
+import net.minecraft.client.KeyboardHandler;
+import net.minecraft.client.input.KeyEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(Keyboard.class)
+@Mixin(KeyboardHandler.class)
public class MaintainKeyboardStatePatch {
- @Inject(method = "onKey", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/InactivityFpsLimiter;onInput()V"))
- private void onKeyInput(long window, int action, KeyInput input, CallbackInfo ci) {
+ @Inject(method = "keyPress", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/FramerateLimitTracker;onInputReceived()V"))
+ private void onKeyInput(long window, int action, KeyEvent input, CallbackInfo ci) {
FirmamentKeyboardState.INSTANCE.maintainState(input, action);
}
}
diff --git a/src/main/java/moe/nea/firmament/mixins/MinecraftInitLevelListener.java b/src/main/java/moe/nea/firmament/mixins/MinecraftInitLevelListener.java
index 1673987..7c1189b 100644
--- a/src/main/java/moe/nea/firmament/mixins/MinecraftInitLevelListener.java
+++ b/src/main/java/moe/nea/firmament/mixins/MinecraftInitLevelListener.java
@@ -1,15 +1,15 @@
package moe.nea.firmament.mixins;
import moe.nea.firmament.util.mc.InitLevel;
-import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.Minecraft;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(MinecraftClient.class)
+@Mixin(Minecraft.class)
public class MinecraftInitLevelListener {
- @Inject(method = "<init>", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;initBackendSystem()Lnet/minecraft/util/TimeSupplier$Nanoseconds;"))
+ @Inject(method = "<init>", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;initBackendSystem()Lnet/minecraft/util/TimeSource$NanoTimeSource;"))
private void onInitRenderBackend(CallbackInfo ci) {
InitLevel.bump(InitLevel.RENDER_INIT);
}
diff --git a/src/main/java/moe/nea/firmament/mixins/MixinHandledScreen.java b/src/main/java/moe/nea/firmament/mixins/MixinHandledScreen.java
index 409fb6b..bd2b594 100644
--- a/src/main/java/moe/nea/firmament/mixins/MixinHandledScreen.java
+++ b/src/main/java/moe/nea/firmament/mixins/MixinHandledScreen.java
@@ -8,16 +8,16 @@ import moe.nea.firmament.events.*;
import moe.nea.firmament.events.HandledScreenClickEvent;
import moe.nea.firmament.keybindings.GenericInputAction;
import moe.nea.firmament.keybindings.InputModifiers;
-import net.minecraft.client.gui.Click;
-import net.minecraft.client.gui.DrawContext;
-import net.minecraft.client.gui.screen.ingame.HandledScreen;
-import net.minecraft.client.input.KeyInput;
-import net.minecraft.entity.player.PlayerInventory;
-import net.minecraft.item.ItemStack;
-import net.minecraft.screen.ScreenHandler;
-import net.minecraft.screen.slot.Slot;
-import net.minecraft.screen.slot.SlotActionType;
-import net.minecraft.text.Text;
+import net.minecraft.client.input.MouseButtonEvent;
+import net.minecraft.client.gui.GuiGraphics;
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
+import net.minecraft.client.input.KeyEvent;
+import net.minecraft.world.entity.player.Inventory;
+import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.inventory.AbstractContainerMenu;
+import net.minecraft.world.inventory.Slot;
+import net.minecraft.world.inventory.ClickType;
+import net.minecraft.network.chat.Component;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -27,32 +27,32 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-@Mixin(value = HandledScreen.class, priority = 990)
-public abstract class MixinHandledScreen<T extends ScreenHandler> {
+@Mixin(value = AbstractContainerScreen.class, priority = 990)
+public abstract class MixinHandledScreen<T extends AbstractContainerMenu> {
@Shadow
@Final
- protected T handler;
+ protected T menu;
@Shadow
- public abstract T getScreenHandler();
+ public abstract T getMenu();
@Shadow
- protected int y;
+ protected int topPos;
@Shadow
- protected int x;
+ protected int leftPos;
@Unique
- PlayerInventory playerInventory;
+ Inventory playerInventory;
@Inject(method = "<init>", at = @At("TAIL"))
- public void savePlayerInventory(ScreenHandler handler, PlayerInventory inventory, Text title, CallbackInfo ci) {
+ public void savePlayerInventory(AbstractContainerMenu handler, Inventory inventory, Component title, CallbackInfo ci) {
this.playerInventory = inventory;
}
- @Inject(method = "keyPressed", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;keyPressed(Lnet/minecraft/client/input/KeyInput;)Z", shift = At.Shift.BEFORE), cancellable = true)
- public void onKeyPressed(KeyInput input, CallbackInfoReturnable<Boolean> cir) {
+ @Inject(method = "keyPressed", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/Screen;keyPressed(Lnet/minecraft/client/input/KeyEvent;)Z", shift = At.Shift.BEFORE), cancellable = true)
+ public void onKeyPressed(KeyEvent input, CallbackInfoReturnable<Boolean> cir) {
if (HandledScreenKeyPressedEvent.Companion.publish(new HandledScreenKeyPressedEvent(
- (HandledScreen<?>) (Object) this,
+ (AbstractContainerScreen<?>) (Object) this,
GenericInputAction.of(input),
InputModifiers.of(input))).getCancelled()) {
cir.setReturnValue(true);
@@ -60,16 +60,16 @@ public abstract class MixinHandledScreen<T extends ScreenHandler> {
}
@Inject(method = "mouseClicked", at = @At("HEAD"), cancellable = true)
- public void onMouseClicked(Click click, boolean doubled, CallbackInfoReturnable<Boolean> cir) {
- if (HandledScreenKeyPressedEvent.Companion.publish(new HandledScreenKeyPressedEvent((HandledScreen<?>) (Object) this,
+ public void onMouseClicked(MouseButtonEvent click, boolean doubled, CallbackInfoReturnable<Boolean> cir) {
+ if (HandledScreenKeyPressedEvent.Companion.publish(new HandledScreenKeyPressedEvent((AbstractContainerScreen<?>) (Object) this,
GenericInputAction.mouse(click), InputModifiers.current())).getCancelled()) {
cir.setReturnValue(true);
}
}
@Inject(method = "mouseReleased", at = @At("HEAD"), cancellable = true)
- private void onMouseReleased(Click click, CallbackInfoReturnable<Boolean> cir) {
- var self = (HandledScreen<?>) (Object) this;
+ private void onMouseReleased(MouseButtonEvent click, CallbackInfoReturnable<Boolean> cir) {
+ var self = (AbstractContainerScreen<?>) (Object) this;
var clickEvent = new HandledScreenClickEvent(self, click.x(), click.y(), click.button());
var keyEvent = new HandledScreenKeyReleasedEvent(self, GenericInputAction.mouse(click), InputModifiers.current());
if (HandledScreenClickEvent.Companion.publish(clickEvent).getCancelled()
@@ -78,16 +78,16 @@ public abstract class MixinHandledScreen<T extends ScreenHandler> {
}
}
- @Inject(method = "renderMain", at = @At("HEAD"))
- public void onAfterRenderForeground(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
- HandledScreenForegroundEvent.Companion.publish(new HandledScreenForegroundEvent((HandledScreen<?>) (Object) this, context, mouseX, mouseY, delta));
+ @Inject(method = "renderContents", at = @At("HEAD"))
+ public void onAfterRenderForeground(GuiGraphics context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
+ HandledScreenForegroundEvent.Companion.publish(new HandledScreenForegroundEvent((AbstractContainerScreen<?>) (Object) this, context, mouseX, mouseY, delta));
}
- @Inject(method = "onMouseClick(Lnet/minecraft/screen/slot/Slot;IILnet/minecraft/screen/slot/SlotActionType;)V", at = @At("HEAD"), cancellable = true)
- public void onMouseClickedSlot(Slot slot, int slotId, int button, SlotActionType actionType, CallbackInfo ci) {
- if (slotId == -999 && getScreenHandler() != null && actionType == SlotActionType.PICKUP) { // -999 is code for "clicked outside the main window"
- ItemStack cursorStack = getScreenHandler().getCursorStack();
- if (cursorStack != null && IsSlotProtectedEvent.shouldBlockInteraction(slot, SlotActionType.THROW, IsSlotProtectedEvent.MoveOrigin.INVENTORY_MOVE, cursorStack)) {
+ @Inject(method = "slotClicked(Lnet/minecraft/world/inventory/Slot;IILnet/minecraft/world/inventory/ClickType;)V", at = @At("HEAD"), cancellable = true)
+ public void onMouseClickedSlot(Slot slot, int slotId, int button, ClickType actionType, CallbackInfo ci) {
+ if (slotId == -999 && getMenu() != null && actionType == ClickType.PICKUP) { // -999 is code for "clicked outside the main window"
+ ItemStack cursorStack = getMenu().getCarried();
+ if (cursorStack != null && IsSlotProtectedEvent.shouldBlockInteraction(slot, ClickType.THROW, IsSlotProtectedEvent.MoveOrigin.INVENTORY_MOVE, cursorStack)) {
ci.cancel();
return;
}
@@ -96,7 +96,7 @@ public abstract class MixinHandledScreen<T extends ScreenHandler> {
ci.cancel();
return;
}
- if (actionType == SlotActionType.SWAP && 0 <= button && button < 9) {
+ if (actionType == ClickType.SWAP && 0 <= button && button < 9) {
if (IsSlotProtectedEvent.shouldBlockInteraction(new Slot(playerInventory, button, 0, 0), actionType, IsSlotProtectedEvent.MoveOrigin.INVENTORY_MOVE)) {
ci.cancel();
}
@@ -104,8 +104,8 @@ public abstract class MixinHandledScreen<T extends ScreenHandler> {
}
- @WrapOperation(method = "drawSlots", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;drawSlot(Lnet/minecraft/client/gui/DrawContext;Lnet/minecraft/screen/slot/Slot;)V"))
- public void onDrawSlots(HandledScreen instance, DrawContext context, Slot slot, Operation<Void> original) {
+ @WrapOperation(method = "renderSlots", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/inventory/AbstractContainerScreen;renderSlot(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/world/inventory/Slot;)V"))
+ public void onDrawSlots(AbstractContainerScreen instance, GuiGraphics context, Slot slot, Operation<Void> original) {
var before = new SlotRenderEvents.Before(context, slot);
SlotRenderEvents.Before.Companion.publish(before);
original.call(instance, context, slot);
diff --git a/src/main/java/moe/nea/firmament/mixins/MixinPlayerScreenHandler.java b/src/main/java/moe/nea/firmament/mixins/MixinPlayerScreenHandler.java
index 12455f4..2210c9e 100644
--- a/src/main/java/moe/nea/firmament/mixins/MixinPlayerScreenHandler.java
+++ b/src/main/java/moe/nea/firmament/mixins/MixinPlayerScreenHandler.java
@@ -1,27 +1,27 @@
package moe.nea.firmament.mixins;
import moe.nea.firmament.features.fixes.Fixes;
-import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.entity.player.PlayerInventory;
-import net.minecraft.screen.PlayerScreenHandler;
+import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.entity.player.Inventory;
+import net.minecraft.world.inventory.InventoryMenu;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(PlayerScreenHandler.class)
+@Mixin(InventoryMenu.class)
public class MixinPlayerScreenHandler {
@Unique
private static final int OFF_HAND_SLOT = 40;
@Inject(method = "<init>", at = @At("TAIL"))
- private void moveOffHandSlot(PlayerInventory inventory, boolean onServer, PlayerEntity owner, CallbackInfo ci) {
+ private void moveOffHandSlot(Inventory inventory, boolean onServer, Player owner, CallbackInfo ci) {
if (Fixes.TConfig.INSTANCE.getHideOffHand()) {
- PlayerScreenHandler self = (PlayerScreenHandler) (Object) this;
+ InventoryMenu self = (InventoryMenu) (Object) this;
self.slots.stream()
- .filter(slot -> slot.getIndex() == OFF_HAND_SLOT)
+ .filter(slot -> slot.getContainerSlot() == OFF_HAND_SLOT)
.forEach(slot -> {
slot.x = -1000;
slot.y = -1000;
diff --git a/src/main/java/moe/nea/firmament/mixins/MixinRecipeBookScreen.java b/src/main/java/moe/nea/firmament/mixins/MixinRecipeBookScreen.java
index 2dbe738..d0ec17c 100644
--- a/src/main/java/moe/nea/firmament/mixins/MixinRecipeBookScreen.java
+++ b/src/main/java/moe/nea/firmament/mixins/MixinRecipeBookScreen.java
@@ -1,15 +1,15 @@
package moe.nea.firmament.mixins;
import moe.nea.firmament.features.fixes.Fixes;
-import net.minecraft.client.gui.screen.ingame.RecipeBookScreen;
+import net.minecraft.client.gui.screens.inventory.AbstractRecipeBookScreen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(value = RecipeBookScreen.class, priority = 999)
+@Mixin(value = AbstractRecipeBookScreen.class, priority = 999)
public class MixinRecipeBookScreen {
- @Inject(method = "addRecipeBook", at = @At("HEAD"), cancellable = true)
+ @Inject(method = "initButton", at = @At("HEAD"), cancellable = true)
public void addRecipeBook(CallbackInfo ci) {
if (Fixes.TConfig.INSTANCE.getHideRecipeBook()) ci.cancel();
}
diff --git a/src/main/java/moe/nea/firmament/mixins/MousePressInWorldEventPatch.java b/src/main/java/moe/nea/firmament/mixins/MousePressInWorldEventPatch.java
index fd2de97..e0ae61b 100644
--- a/src/main/java/moe/nea/firmament/mixins/MousePressInWorldEventPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/MousePressInWorldEventPatch.java
@@ -5,16 +5,16 @@ import com.llamalad7.mixinextras.sugar.Local;
import moe.nea.firmament.events.WorldKeyboardEvent;
import moe.nea.firmament.keybindings.GenericInputAction;
import moe.nea.firmament.keybindings.InputModifiers;
-import net.minecraft.client.Mouse;
-import net.minecraft.client.input.MouseInput;
-import net.minecraft.client.util.InputUtil;
+import net.minecraft.client.MouseHandler;
+import net.minecraft.client.input.MouseButtonInfo;
+import com.mojang.blaze3d.platform.InputConstants;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
-@Mixin(Mouse.class)
+@Mixin(MouseHandler.class)
public class MousePressInWorldEventPatch {
- @WrapWithCondition(method = "onMouseButton", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBinding;onKeyPressed(Lnet/minecraft/client/util/InputUtil$Key;)V"))
- public boolean onKeyBoardInWorld(InputUtil.Key key, @Local(argsOnly = true) MouseInput input) { // TODO: handle modified mouse click instead
+ @WrapWithCondition(method = "onButton", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/KeyMapping;click(Lcom/mojang/blaze3d/platform/InputConstants$Key;)V"))
+ public boolean onKeyBoardInWorld(InputConstants.Key key, @Local(argsOnly = true) MouseButtonInfo input) { // TODO: handle modified mouse click instead
var event = WorldKeyboardEvent.Companion.publish(new WorldKeyboardEvent(GenericInputAction.of(input),
InputModifiers.of(input)));
return !event.getCancelled();
diff --git a/src/main/java/moe/nea/firmament/mixins/OutgoingPacketEventPatch.java b/src/main/java/moe/nea/firmament/mixins/OutgoingPacketEventPatch.java
index 25505b7..fd6869c 100644
--- a/src/main/java/moe/nea/firmament/mixins/OutgoingPacketEventPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/OutgoingPacketEventPatch.java
@@ -3,16 +3,16 @@
package moe.nea.firmament.mixins;
import moe.nea.firmament.events.OutgoingPacketEvent;
-import net.minecraft.client.network.ClientCommonNetworkHandler;
-import net.minecraft.network.packet.Packet;
+import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
+import net.minecraft.network.protocol.Packet;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(ClientCommonNetworkHandler.class)
+@Mixin(ClientCommonPacketListenerImpl.class)
public class OutgoingPacketEventPatch {
- @Inject(method = "sendPacket(Lnet/minecraft/network/packet/Packet;)V", at = @At("HEAD"), cancellable = true)
+ @Inject(method = "send(Lnet/minecraft/network/protocol/Packet;)V", at = @At("HEAD"), cancellable = true)
public void onSendPacket(Packet<?> packet, CallbackInfo ci) {
if (OutgoingPacketEvent.Companion.publish(new OutgoingPacketEvent(packet)).getCancelled()) {
ci.cancel();
diff --git a/src/main/java/moe/nea/firmament/mixins/PlayerDropEventPatch.java b/src/main/java/moe/nea/firmament/mixins/PlayerDropEventPatch.java
index 86f6806..9ee271d 100644
--- a/src/main/java/moe/nea/firmament/mixins/PlayerDropEventPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/PlayerDropEventPatch.java
@@ -3,25 +3,25 @@
package moe.nea.firmament.mixins;
import moe.nea.firmament.events.IsSlotProtectedEvent;
-import net.minecraft.client.network.ClientPlayerEntity;
-import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.screen.slot.Slot;
-import net.minecraft.screen.slot.SlotActionType;
+import net.minecraft.client.player.LocalPlayer;
+import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.inventory.Slot;
+import net.minecraft.world.inventory.ClickType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-@Mixin(ClientPlayerEntity.class)
-public abstract class PlayerDropEventPatch extends PlayerEntity {
+@Mixin(LocalPlayer.class)
+public abstract class PlayerDropEventPatch extends Player {
public PlayerDropEventPatch() {
super(null, null);
}
- @Inject(method = "dropSelectedItem", at = @At("HEAD"), cancellable = true)
+ @Inject(method = "drop", at = @At("HEAD"), cancellable = true)
public void onDropSelectedItem(boolean entireStack, CallbackInfoReturnable<Boolean> cir) {
Slot fakeSlot = new Slot(getInventory(), getInventory().getSelectedSlot(), 0, 0);
- if (IsSlotProtectedEvent.shouldBlockInteraction(fakeSlot, SlotActionType.THROW, IsSlotProtectedEvent.MoveOrigin.DROP_FROM_HOTBAR)) {
+ if (IsSlotProtectedEvent.shouldBlockInteraction(fakeSlot, ClickType.THROW, IsSlotProtectedEvent.MoveOrigin.DROP_FROM_HOTBAR)) {
cir.setReturnValue(false);
}
}
diff --git a/src/main/java/moe/nea/firmament/mixins/ResourceReloaderRegistrationPatch.java b/src/main/java/moe/nea/firmament/mixins/ResourceReloaderRegistrationPatch.java
index 28fe3d9..a29cdc0 100644
--- a/src/main/java/moe/nea/firmament/mixins/ResourceReloaderRegistrationPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/ResourceReloaderRegistrationPatch.java
@@ -2,9 +2,9 @@
package moe.nea.firmament.mixins;
import moe.nea.firmament.events.FinalizeResourceManagerEvent;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.RunArgs;
-import net.minecraft.resource.ReloadableResourceManagerImpl;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.main.GameConfig;
+import net.minecraft.server.packs.resources.ReloadableResourceManager;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -12,14 +12,14 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(MinecraftClient.class)
+@Mixin(Minecraft.class)
public class ResourceReloaderRegistrationPatch {
@Shadow
@Final
- private ReloadableResourceManagerImpl resourceManager;
+ private ReloadableResourceManager resourceManager;
- @Inject(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/ResourcePackManager;createResourcePacks()Ljava/util/List;", shift = At.Shift.BEFORE))
- private void onBeforeResourcePackCreation(RunArgs args, CallbackInfo ci) {
+ @Inject(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/packs/repository/PackRepository;openAllSelected()Ljava/util/List;", shift = At.Shift.BEFORE))
+ private void onBeforeResourcePackCreation(GameConfig args, CallbackInfo ci) {
FinalizeResourceManagerEvent.Companion.publish(new FinalizeResourceManagerEvent(this.resourceManager));
}
}
diff --git a/src/main/java/moe/nea/firmament/mixins/SaveCursorPositionPatch.java b/src/main/java/moe/nea/firmament/mixins/SaveCursorPositionPatch.java
index 3659066..3cfd0d6 100644
--- a/src/main/java/moe/nea/firmament/mixins/SaveCursorPositionPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/SaveCursorPositionPatch.java
@@ -4,7 +4,7 @@ package moe.nea.firmament.mixins;
import kotlin.Pair;
import moe.nea.firmament.features.inventory.SaveCursorPosition;
-import net.minecraft.client.Mouse;
+import net.minecraft.client.MouseHandler;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -12,29 +12,29 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(Mouse.class)
+@Mixin(MouseHandler.class)
public class SaveCursorPositionPatch {
@Shadow
- private double x;
+ private double xpos;
@Shadow
- private double y;
+ private double ypos;
- @Inject(method = "lockCursor", at = @At(value = "HEAD"))
+ @Inject(method = "grabMouse", at = @At(value = "HEAD"))
public void onLockCursor(CallbackInfo ci) {
- SaveCursorPosition.saveCursorOriginal(x, y);
+ SaveCursorPosition.saveCursorOriginal(xpos, ypos);
}
- @Inject(method = "lockCursor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;getWindow()Lnet/minecraft/client/util/Window;", ordinal = 2))
+ @Inject(method = "grabMouse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getWindow()Lcom/mojang/blaze3d/platform/Window;", ordinal = 2))
public void onLockCursorAfter(CallbackInfo ci) {
- SaveCursorPosition.saveCursorMiddle(x, y);
+ SaveCursorPosition.saveCursorMiddle(xpos, ypos);
}
- @Inject(method = "unlockCursor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;getWindow()Lnet/minecraft/client/util/Window;", ordinal = 2))
+ @Inject(method = "releaseMouse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getWindow()Lcom/mojang/blaze3d/platform/Window;", ordinal = 2))
public void onUnlockCursor(CallbackInfo ci) {
- Pair<Double, Double> cursorPosition = SaveCursorPosition.loadCursor(this.x, this.y);
+ Pair<Double, Double> cursorPosition = SaveCursorPosition.loadCursor(this.xpos, this.ypos);
if (cursorPosition == null) return;
- this.x = cursorPosition.getFirst();
- this.y = cursorPosition.getSecond();
+ this.xpos = cursorPosition.getFirst();
+ this.ypos = cursorPosition.getSecond();
}
}
diff --git a/src/main/java/moe/nea/firmament/mixins/SaveOriginalCommandTreePacket.java b/src/main/java/moe/nea/firmament/mixins/SaveOriginalCommandTreePacket.java
index 2f2f188..5974277 100644
--- a/src/main/java/moe/nea/firmament/mixins/SaveOriginalCommandTreePacket.java
+++ b/src/main/java/moe/nea/firmament/mixins/SaveOriginalCommandTreePacket.java
@@ -1,17 +1,17 @@
package moe.nea.firmament.mixins;
import moe.nea.firmament.features.chat.QuickCommands;
-import net.minecraft.client.network.ClientPlayNetworkHandler;
-import net.minecraft.network.packet.s2c.play.CommandTreeS2CPacket;
+import net.minecraft.client.multiplayer.ClientPacketListener;
+import net.minecraft.network.protocol.game.ClientboundCommandsPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(ClientPlayNetworkHandler.class)
+@Mixin(ClientPacketListener.class)
public class SaveOriginalCommandTreePacket {
- @Inject(method = "onCommandTree", at = @At(value = "RETURN"))
- private void saveUnmodifiedCommandTree(CommandTreeS2CPacket packet, CallbackInfo ci) {
+ @Inject(method = "handleCommands", at = @At(value = "RETURN"))
+ private void saveUnmodifiedCommandTree(ClientboundCommandsPacket packet, CallbackInfo ci) {
QuickCommands.INSTANCE.setLastReceivedTreePacket(packet);
}
}
diff --git a/src/main/java/moe/nea/firmament/mixins/ScreenChangeEventPatch.java b/src/main/java/moe/nea/firmament/mixins/ScreenChangeEventPatch.java
index 6d19405..37423f0 100644
--- a/src/main/java/moe/nea/firmament/mixins/ScreenChangeEventPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/ScreenChangeEventPatch.java
@@ -5,8 +5,8 @@ package moe.nea.firmament.mixins;
import com.llamalad7.mixinextras.sugar.Local;
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
import moe.nea.firmament.events.ScreenChangeEvent;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.screen.Screen;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.screens.Screen;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -14,15 +14,15 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(MinecraftClient.class)
+@Mixin(Minecraft.class)
public abstract class ScreenChangeEventPatch {
@Shadow
@Nullable
- public Screen currentScreen;
+ public Screen screen;
@Inject(method = "setScreen", at = @At("HEAD"), cancellable = true)
public void onScreenChange(Screen screen, CallbackInfo ci, @Local(argsOnly = true) LocalRef<Screen> screenLocalRef) {
- var event = new ScreenChangeEvent(currentScreen, screen);
+ var event = new ScreenChangeEvent(screen, screen);
if (ScreenChangeEvent.Companion.publish(event).getCancelled()) {
ci.cancel();
} else if (event.getOverrideScreen() != null) {
diff --git a/src/main/java/moe/nea/firmament/mixins/SlotClickEventPatch.java b/src/main/java/moe/nea/firmament/mixins/SlotClickEventPatch.java
index 21e7899..71cb05a 100644
--- a/src/main/java/moe/nea/firmament/mixins/SlotClickEventPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/SlotClickEventPatch.java
@@ -5,11 +5,11 @@ import com.llamalad7.mixinextras.sugar.Local;
import com.llamalad7.mixinextras.sugar.Share;
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
import moe.nea.firmament.events.SlotClickEvent;
-import net.minecraft.client.network.ClientPlayerInteractionManager;
-import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.item.ItemStack;
-import net.minecraft.screen.ScreenHandler;
-import net.minecraft.screen.slot.SlotActionType;
+import net.minecraft.client.multiplayer.MultiPlayerGameMode;
+import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.inventory.AbstractContainerMenu;
+import net.minecraft.world.inventory.ClickType;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -17,18 +17,18 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(ClientPlayerInteractionManager.class)
+@Mixin(MultiPlayerGameMode.class)
public class SlotClickEventPatch {
- @Inject(method = "clickSlot", at = @At(value = "FIELD", target = "Lnet/minecraft/screen/ScreenHandler;slots:Lnet/minecraft/util/collection/DefaultedList;", opcode = Opcodes.GETFIELD))
- private void onSlotClickSaveSlot(int syncId, int slotId, int button, SlotActionType actionType, PlayerEntity player, CallbackInfo ci, @Local ScreenHandler handler, @Share("slotContent") LocalRef<ItemStack> slotContent) {
+ @Inject(method = "handleInventoryMouseClick", at = @At(value = "FIELD", target = "Lnet/minecraft/world/inventory/AbstractContainerMenu;slots:Lnet/minecraft/core/NonNullList;", opcode = Opcodes.GETFIELD))
+ private void onSlotClickSaveSlot(int syncId, int slotId, int button, ClickType actionType, Player player, CallbackInfo ci, @Local AbstractContainerMenu handler, @Share("slotContent") LocalRef<ItemStack> slotContent) {
if (0 <= slotId && slotId < handler.slots.size()) {
- slotContent.set(handler.getSlot(slotId).getStack().copy());
+ slotContent.set(handler.getSlot(slotId).getItem().copy());
}
}
- @Inject(method = "clickSlot", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;)V"))
- private void onSlotClick(int syncId, int slotId, int button, SlotActionType actionType, PlayerEntity player, CallbackInfo ci, @Local ScreenHandler handler, @Share("slotContent") LocalRef<ItemStack> slotContent) {
+ @Inject(method = "handleInventoryMouseClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientPacketListener;sendPacket(Lnet/minecraft/network/protocol/Packet;)V"))
+ private void onSlotClick(int syncId, int slotId, int button, ClickType actionType, Player player, CallbackInfo ci, @Local AbstractContainerMenu handler, @Share("slotContent") LocalRef<ItemStack> slotContent) {
if (0 <= slotId && slotId < handler.slots.size()) {
SlotClickEvent.Companion.publish(new SlotClickEvent(
handler.getSlot(slotId),
diff --git a/src/main/java/moe/nea/firmament/mixins/SlotUpdateListener.java b/src/main/java/moe/nea/firmament/mixins/SlotUpdateListener.java
index a4ae931..49661d0 100644
--- a/src/main/java/moe/nea/firmament/mixins/SlotUpdateListener.java
+++ b/src/main/java/moe/nea/firmament/mixins/SlotUpdateListener.java
@@ -3,51 +3,51 @@ package moe.nea.firmament.mixins;
import moe.nea.firmament.events.ChestInventoryUpdateEvent;
import moe.nea.firmament.events.PlayerInventoryUpdate;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.network.ClientCommonNetworkHandler;
-import net.minecraft.client.network.ClientConnectionState;
-import net.minecraft.client.network.ClientPlayNetworkHandler;
-import net.minecraft.network.ClientConnection;
-import net.minecraft.network.packet.s2c.play.InventoryS2CPacket;
-import net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
+import net.minecraft.client.multiplayer.CommonListenerCookie;
+import net.minecraft.client.multiplayer.ClientPacketListener;
+import net.minecraft.network.Connection;
+import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket;
+import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(ClientPlayNetworkHandler.class)
-public abstract class SlotUpdateListener extends ClientCommonNetworkHandler {
- protected SlotUpdateListener(MinecraftClient client, ClientConnection connection, ClientConnectionState connectionState) {
+@Mixin(ClientPacketListener.class)
+public abstract class SlotUpdateListener extends ClientCommonPacketListenerImpl {
+ protected SlotUpdateListener(Minecraft client, Connection connection, CommonListenerCookie connectionState) {
super(client, connection, connectionState);
}
@Inject(
- method = "onScreenHandlerSlotUpdate",
+ method = "handleContainerSetSlot",
at = @At(value = "TAIL"))
private void onSingleSlotUpdate(
- ScreenHandlerSlotUpdateS2CPacket packet,
+ ClientboundContainerSetSlotPacket packet,
CallbackInfo ci) {
- var player = this.client.player;
+ var player = this.minecraft.player;
assert player != null;
- if (packet.getSyncId() == 0) {
- PlayerInventoryUpdate.Companion.publish(new PlayerInventoryUpdate.Single(packet.getSlot(), packet.getStack()));
- } else if (packet.getSyncId() == player.currentScreenHandler.syncId) {
+ if (packet.getContainerId() == 0) {
+ PlayerInventoryUpdate.Companion.publish(new PlayerInventoryUpdate.Single(packet.getSlot(), packet.getItem()));
+ } else if (packet.getContainerId() == player.containerMenu.containerId) {
ChestInventoryUpdateEvent.Companion.publish(
- new ChestInventoryUpdateEvent.Single(packet.getSlot(), packet.getStack())
+ new ChestInventoryUpdateEvent.Single(packet.getSlot(), packet.getItem())
);
}
}
- @Inject(method = "onInventory",
+ @Inject(method = "handleContainerContent",
at = @At("TAIL"))
- private void onMultiSlotUpdate(InventoryS2CPacket packet, CallbackInfo ci) {
- var player = this.client.player;
+ private void onMultiSlotUpdate(ClientboundContainerSetContentPacket packet, CallbackInfo ci) {
+ var player = this.minecraft.player;
assert player != null;
- if (packet.syncId() == 0) {
- PlayerInventoryUpdate.Companion.publish(new PlayerInventoryUpdate.Multi(packet.contents()));
- } else if (packet.syncId() == player.currentScreenHandler.syncId) {
+ if (packet.containerId() == 0) {
+ PlayerInventoryUpdate.Companion.publish(new PlayerInventoryUpdate.Multi(packet.items()));
+ } else if (packet.containerId() == player.containerMenu.containerId) {
ChestInventoryUpdateEvent.Companion.publish(
- new ChestInventoryUpdateEvent.Multi(packet.contents())
+ new ChestInventoryUpdateEvent.Multi(packet.items())
);
}
}
diff --git a/src/main/java/moe/nea/firmament/mixins/SoundReceiveEventPatch.java b/src/main/java/moe/nea/firmament/mixins/SoundReceiveEventPatch.java
index b8cba80..af80325 100644
--- a/src/main/java/moe/nea/firmament/mixins/SoundReceiveEventPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/SoundReceiveEventPatch.java
@@ -3,25 +3,25 @@ package moe.nea.firmament.mixins;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import moe.nea.firmament.events.SoundReceiveEvent;
-import net.minecraft.client.network.ClientPlayNetworkHandler;
-import net.minecraft.client.world.ClientWorld;
-import net.minecraft.entity.Entity;
-import net.minecraft.registry.entry.RegistryEntry;
-import net.minecraft.sound.SoundCategory;
-import net.minecraft.sound.SoundEvent;
-import net.minecraft.util.math.Vec3d;
+import net.minecraft.client.multiplayer.ClientPacketListener;
+import net.minecraft.client.multiplayer.ClientLevel;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.core.Holder;
+import net.minecraft.sounds.SoundSource;
+import net.minecraft.sounds.SoundEvent;
+import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
-@Mixin(ClientPlayNetworkHandler.class)
+@Mixin(ClientPacketListener.class)
public class SoundReceiveEventPatch {
- @WrapWithCondition(method = "onPlaySound", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;playSound(Lnet/minecraft/entity/Entity;DDDLnet/minecraft/registry/entry/RegistryEntry;Lnet/minecraft/sound/SoundCategory;FFJ)V"))
- private boolean postEventWhenSoundIsPlayed(ClientWorld instance, @Nullable Entity source, double x, double y, double z, RegistryEntry<SoundEvent> sound, SoundCategory category, float volume, float pitch, long seed) {
+ @WrapWithCondition(method = "handleSoundEvent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;playSound(Lnet/minecraft/world/entity/Entity;DDDLnet/minecraft/core/Holder;Lnet/minecraft/sounds/SoundSource;FFJ)V"))
+ private boolean postEventWhenSoundIsPlayed(ClientLevel instance, @Nullable Entity source, double x, double y, double z, Holder<SoundEvent> sound, SoundSource category, float volume, float pitch, long seed) {
var event = new SoundReceiveEvent(
sound,
category,
- new Vec3d(x,y,z),
+ new Vec3(x,y,z),
pitch,
volume,
seed
diff --git a/src/main/java/moe/nea/firmament/mixins/ToggleSprintPatch.java b/src/main/java/moe/nea/firmament/mixins/ToggleSprintPatch.java
index 1acbf20..96d03bd 100644
--- a/src/main/java/moe/nea/firmament/mixins/ToggleSprintPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/ToggleSprintPatch.java
@@ -3,16 +3,16 @@
package moe.nea.firmament.mixins;
import moe.nea.firmament.features.fixes.Fixes;
-import net.minecraft.client.option.KeyBinding;
+import net.minecraft.client.KeyMapping;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-@Mixin(KeyBinding.class)
+@Mixin(KeyMapping.class)
public class ToggleSprintPatch {
- @Inject(method = "isPressed", at = @At("HEAD"), cancellable = true)
+ @Inject(method = "isDown", at = @At("HEAD"), cancellable = true)
public void onIsPressed(CallbackInfoReturnable<Boolean> cir) {
- Fixes.INSTANCE.handleIsPressed((KeyBinding) (Object) this, cir);
+ Fixes.INSTANCE.handleIsPressed((KeyMapping) (Object) this, cir);
}
}
diff --git a/src/main/java/moe/nea/firmament/mixins/TolerateFirmamentTolerateRegistryOwners.java b/src/main/java/moe/nea/firmament/mixins/TolerateFirmamentTolerateRegistryOwners.java
index ac6f614..bc0ece5 100644
--- a/src/main/java/moe/nea/firmament/mixins/TolerateFirmamentTolerateRegistryOwners.java
+++ b/src/main/java/moe/nea/firmament/mixins/TolerateFirmamentTolerateRegistryOwners.java
@@ -1,16 +1,16 @@
package moe.nea.firmament.mixins;
import moe.nea.firmament.util.mc.TolerantRegistriesOps;
-import net.minecraft.registry.entry.RegistryEntryOwner;
+import net.minecraft.core.HolderOwner;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-@Mixin(RegistryEntryOwner.class)
+@Mixin(HolderOwner.class)
public interface TolerateFirmamentTolerateRegistryOwners<T> {
- @Inject(method = "ownerEquals", at = @At("HEAD"), cancellable = true)
- private void equalTolerantRegistryOwners(RegistryEntryOwner<T> other, CallbackInfoReturnable<Boolean> cir) {
+ @Inject(method = "canSerializeIn", at = @At("HEAD"), cancellable = true)
+ private void equalTolerantRegistryOwners(HolderOwner<T> other, CallbackInfoReturnable<Boolean> cir) {
if (other instanceof TolerantRegistriesOps.TolerantOwner<?>) {
cir.setReturnValue(true);
}
diff --git a/src/main/java/moe/nea/firmament/mixins/WorldReadyEventPatch.java b/src/main/java/moe/nea/firmament/mixins/WorldReadyEventPatch.java
index f05eb05..70ef9cb 100644
--- a/src/main/java/moe/nea/firmament/mixins/WorldReadyEventPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/WorldReadyEventPatch.java
@@ -3,15 +3,15 @@
package moe.nea.firmament.mixins;
import moe.nea.firmament.events.WorldReadyEvent;
-import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.Minecraft;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(MinecraftClient.class)
+@Mixin(Minecraft.class)
public class WorldReadyEventPatch {
- @Inject(method = "joinWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;setWorld(Lnet/minecraft/client/world/ClientWorld;)V", shift = At.Shift.AFTER))
+ @Inject(method = "setLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;updateLevelInEngines(Lnet/minecraft/client/multiplayer/ClientLevel;)V", shift = At.Shift.AFTER))
public void onClose(CallbackInfo ci) {
WorldReadyEvent.Companion.publish(new WorldReadyEvent());
}
diff --git a/src/main/java/moe/nea/firmament/mixins/WorldRenderLastEventPatch.java b/src/main/java/moe/nea/firmament/mixins/WorldRenderLastEventPatch.java
index 162d1dc..a875bcf 100644
--- a/src/main/java/moe/nea/firmament/mixins/WorldRenderLastEventPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/WorldRenderLastEventPatch.java
@@ -4,13 +4,15 @@ package moe.nea.firmament.mixins;
import com.mojang.blaze3d.buffers.GpuBufferSlice;
import moe.nea.firmament.events.WorldRenderLastEvent;
-import net.minecraft.client.render.*;
-import net.minecraft.client.render.fog.FogRenderer;
-import net.minecraft.client.render.state.WorldRenderState;
-import net.minecraft.client.util.Handle;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.client.world.ClientWorld;
-import net.minecraft.util.profiler.Profiler;
+import net.minecraft.client.renderer.LevelRenderer;
+import net.minecraft.client.renderer.LevelTargetBundle;
+import net.minecraft.client.renderer.RenderBuffers;
+import net.minecraft.client.renderer.culling.Frustum;
+import net.minecraft.client.renderer.state.LevelRenderState;
+import com.mojang.blaze3d.resource.ResourceHandle;
+import com.mojang.blaze3d.vertex.PoseStack;
+import net.minecraft.client.multiplayer.ClientLevel;
+import net.minecraft.util.profiling.ProfilerFiller;
import org.jetbrains.annotations.Nullable;
import org.joml.Matrix4f;
import org.spongepowered.asm.mixin.Final;
@@ -20,29 +22,22 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(WorldRenderer.class)
+@Mixin(LevelRenderer.class)
public abstract class WorldRenderLastEventPatch {
@Shadow
@Final
- private BufferBuilderStorage bufferBuilders;
+ private RenderBuffers renderBuffers;
@Shadow
- @Final
- private DefaultFramebufferSet framebufferSet;
-
- @Shadow
- protected abstract void checkEmpty(MatrixStack matrices);
-
- @Shadow
- private @Nullable ClientWorld world;
+ protected abstract void checkPoseStack(PoseStack matrices);
@Shadow
private int ticks;
- @Inject(method = "method_62214", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;pop()V", shift = At.Shift.AFTER))
- public void onWorldRenderLast(GpuBufferSlice gpuBufferSlice, WorldRenderState worldRenderState, Profiler profiler, Matrix4f matrix4f, Handle handle, Handle handle2, boolean bl, Frustum frustum, Handle handle3, Handle handle4, CallbackInfo ci) {
- var imm = this.bufferBuilders.getEntityVertexConsumers();
- var stack = new MatrixStack();
+ @Inject(method = "method_62214", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiling/ProfilerFiller;pop()V", shift = At.Shift.AFTER))
+ public void onWorldRenderLast(GpuBufferSlice gpuBufferSlice, LevelRenderState worldRenderState, ProfilerFiller profiler, Matrix4f matrix4f, ResourceHandle handle, ResourceHandle handle2, boolean bl, Frustum frustum, ResourceHandle handle3, ResourceHandle handle4, CallbackInfo ci) {
+ var imm = this.renderBuffers.bufferSource();
+ var stack = new PoseStack();
// TODO: pre-cancel this event if F1 is active
var event = new WorldRenderLastEvent(
stack, ticks,
@@ -50,7 +45,7 @@ public abstract class WorldRenderLastEventPatch {
imm
);
WorldRenderLastEvent.Companion.publish(event);
- imm.draw();
- checkEmpty(stack);
+ imm.endBatch();
+ checkPoseStack(stack);
}
}
diff --git a/src/main/java/moe/nea/firmament/mixins/accessor/AccessorAbstractClientPlayerEntity.java b/src/main/java/moe/nea/firmament/mixins/accessor/AccessorAbstractClientPlayerEntity.java
index 0a10046..cbd143d 100644
--- a/src/main/java/moe/nea/firmament/mixins/accessor/AccessorAbstractClientPlayerEntity.java
+++ b/src/main/java/moe/nea/firmament/mixins/accessor/AccessorAbstractClientPlayerEntity.java
@@ -1,13 +1,13 @@
package moe.nea.firmament.mixins.accessor;
-import net.minecraft.client.network.AbstractClientPlayerEntity;
-import net.minecraft.client.network.PlayerListEntry;
+import net.minecraft.client.player.AbstractClientPlayer;
+import net.minecraft.client.multiplayer.PlayerInfo;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
-@Mixin(AbstractClientPlayerEntity.class)
+@Mixin(AbstractClientPlayer.class)
public interface AccessorAbstractClientPlayerEntity {
- @Accessor("playerListEntry")
- void setPlayerListEntry_firmament(PlayerListEntry playerListEntry);
+ @Accessor("playerInfo")
+ void setPlayerListEntry_firmament(PlayerInfo playerListEntry);
}
diff --git a/src/main/java/moe/nea/firmament/mixins/accessor/AccessorChatHud.java b/src/main/java/moe/nea/firmament/mixins/accessor/AccessorChatHud.java
index d164aac..0b986ef 100644
--- a/src/main/java/moe/nea/firmament/mixins/accessor/AccessorChatHud.java
+++ b/src/main/java/moe/nea/firmament/mixins/accessor/AccessorChatHud.java
@@ -1,24 +1,24 @@
package moe.nea.firmament.mixins.accessor;
-import net.minecraft.client.gui.hud.ChatHud;
-import net.minecraft.client.gui.hud.ChatHudLine;
+import net.minecraft.client.gui.components.ChatComponent;
+import net.minecraft.client.GuiMessage;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.gen.Invoker;
import java.util.List;
-@Mixin(ChatHud.class)
+@Mixin(ChatComponent.class)
public interface AccessorChatHud {
- @Accessor("messages")
- List<ChatHudLine> getMessages_firmament();
+ @Accessor("allMessages")
+ List<GuiMessage> getMessages_firmament();
- @Accessor("visibleMessages")
- List<ChatHudLine.Visible> getVisibleMessages_firmament();
+ @Accessor("trimmedMessages")
+ List<GuiMessage.Line> getVisibleMessages_firmament();
- @Accessor("scrolledLines")
+ @Accessor("chatScrollbarPos")
int getScrolledLines_firmament();
- @Invoker("toChatLineY")
+ @Invoker("screenToChatY")
double toChatLineY_firmament(double y);
}
diff --git a/src/main/java/moe/nea/firmament/mixins/accessor/AccessorHandledScreen.java b/src/main/java/moe/nea/firmament/mixins/accessor/AccessorHandledScreen.java
index f55ef4f..5e0c669 100644
--- a/src/main/java/moe/nea/firmament/mixins/accessor/AccessorHandledScreen.java
+++ b/src/main/java/moe/nea/firmament/mixins/accessor/AccessorHandledScreen.java
@@ -1,39 +1,39 @@
package moe.nea.firmament.mixins.accessor;
-import net.minecraft.client.gui.screen.ingame.HandledScreen;
-import net.minecraft.screen.slot.Slot;
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
+import net.minecraft.world.inventory.Slot;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
-@Mixin(HandledScreen.class)
+@Mixin(AbstractContainerScreen.class)
public interface AccessorHandledScreen {
- @Accessor("focusedSlot")
+ @Accessor("hoveredSlot")
@Nullable
- Slot getFocusedSlot_Firmament();
+ Slot getFocusedSlot_Firmament();
- @Accessor("backgroundWidth")
+ @Accessor("imageWidth")
int getBackgroundWidth_Firmament();
- @Accessor("backgroundWidth")
+ @Accessor("imageWidth")
void setBackgroundWidth_Firmament(int newBackgroundWidth);
- @Accessor("backgroundHeight")
+ @Accessor("imageHeight")
int getBackgroundHeight_Firmament();
- @Accessor("backgroundHeight")
+ @Accessor("imageHeight")
void setBackgroundHeight_Firmament(int newBackgroundHeight);
- @Accessor("x")
+ @Accessor("leftPos")
int getX_Firmament();
- @Accessor("x")
+ @Accessor("leftPos")
void setX_Firmament(int newX);
- @Accessor("y")
+ @Accessor("topPos")
int getY_Firmament();
- @Accessor("y")
+ @Accessor("topPos")
void setY_Firmament(int newY);
}
diff --git a/src/main/java/moe/nea/firmament/mixins/accessor/AccessorNbtComponent.java b/src/main/java/moe/nea/firmament/mixins/accessor/AccessorNbtComponent.java
index 8ce981c..672badf 100644
--- a/src/main/java/moe/nea/firmament/mixins/accessor/AccessorNbtComponent.java
+++ b/src/main/java/moe/nea/firmament/mixins/accessor/AccessorNbtComponent.java
@@ -1,12 +1,12 @@
package moe.nea.firmament.mixins.accessor;
-import net.minecraft.component.type.NbtComponent;
-import net.minecraft.nbt.NbtCompound;
+import net.minecraft.world.item.component.CustomData;
+import net.minecraft.nbt.CompoundTag;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
-@Mixin(NbtComponent.class)
+@Mixin(CustomData.class)
public interface AccessorNbtComponent {
- @Accessor("nbt")
- NbtCompound getUnsafeNbt_firmament();
+ @Accessor("tag")
+ CompoundTag getUnsafeNbt_firmament();
}
diff --git a/src/main/java/moe/nea/firmament/mixins/accessor/AccessorPlayerListHud.java b/src/main/java/moe/nea/firmament/mixins/accessor/AccessorPlayerListHud.java
index 81ea0fd..58c9ad9 100644
--- a/src/main/java/moe/nea/firmament/mixins/accessor/AccessorPlayerListHud.java
+++ b/src/main/java/moe/nea/firmament/mixins/accessor/AccessorPlayerListHud.java
@@ -1,8 +1,8 @@
package moe.nea.firmament.mixins.accessor;
-import net.minecraft.client.gui.hud.PlayerListHud;
-import net.minecraft.client.network.PlayerListEntry;
-import net.minecraft.text.Text;
+import net.minecraft.client.gui.components.PlayerTabOverlay;
+import net.minecraft.client.multiplayer.PlayerInfo;
+import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@@ -11,21 +11,21 @@ import org.spongepowered.asm.mixin.gen.Invoker;
import java.util.Comparator;
import java.util.List;
-@Mixin(PlayerListHud.class)
+@Mixin(PlayerTabOverlay.class)
public interface AccessorPlayerListHud {
- @Accessor("ENTRY_ORDERING")
- static Comparator<PlayerListEntry> getEntryOrdering() {
+ @Accessor("PLAYER_COMPARATOR")
+ static Comparator<PlayerInfo> getEntryOrdering() {
throw new AssertionError();
}
- @Invoker("collectPlayerEntries")
- List<PlayerListEntry> collectPlayerEntries_firmament();
+ @Invoker("getPlayerInfos")
+ List<PlayerInfo> collectPlayerEntries_firmament();
@Accessor("footer")
- @Nullable Text getFooter_firmament();
+ @Nullable Component getFooter_firmament();
@Accessor("header")
- @Nullable Text getHeader_firmament();
+ @Nullable Component getHeader_firmament();
}
diff --git a/src/main/java/moe/nea/firmament/mixins/accessor/AccessorScreenHandler.java b/src/main/java/moe/nea/firmament/mixins/accessor/AccessorScreenHandler.java
index a022d8e..0a75ea1 100644
--- a/src/main/java/moe/nea/firmament/mixins/accessor/AccessorScreenHandler.java
+++ b/src/main/java/moe/nea/firmament/mixins/accessor/AccessorScreenHandler.java
@@ -1,12 +1,12 @@
package moe.nea.firmament.mixins.accessor;
-import net.minecraft.screen.ScreenHandler;
-import net.minecraft.screen.ScreenHandlerType;
+import net.minecraft.world.inventory.AbstractContainerMenu;
+import net.minecraft.world.inventory.MenuType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
-@Mixin(ScreenHandler.class)
+@Mixin(AbstractContainerMenu.class)
public interface AccessorScreenHandler {
- @Accessor("type")
- ScreenHandlerType<?> getType_firmament();
+ @Accessor("menuType")
+ MenuType<?> getType_firmament();
}
diff --git a/src/main/java/moe/nea/firmament/mixins/accessor/AccessorWorldRenderer.java b/src/main/java/moe/nea/firmament/mixins/accessor/AccessorWorldRenderer.java
index 8b25562..9164af0 100644
--- a/src/main/java/moe/nea/firmament/mixins/accessor/AccessorWorldRenderer.java
+++ b/src/main/java/moe/nea/firmament/mixins/accessor/AccessorWorldRenderer.java
@@ -1,17 +1,17 @@
package moe.nea.firmament.mixins.accessor;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
-import net.minecraft.client.render.WorldRenderer;
-import net.minecraft.entity.player.BlockBreakingInfo;
+import net.minecraft.client.renderer.LevelRenderer;
+import net.minecraft.server.level.BlockDestructionProgress;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.SortedSet;
-@Mixin(WorldRenderer.class)
+@Mixin(LevelRenderer.class)
public interface AccessorWorldRenderer {
- @Accessor("blockBreakingProgressions")
+ @Accessor("destructionProgress")
@NotNull
- Long2ObjectMap<SortedSet<BlockBreakingInfo>> getBlockBreakingProgressions_firmament();
+ Long2ObjectMap<SortedSet<BlockDestructionProgress>> getBlockBreakingProgressions_firmament();
}
diff --git a/src/main/java/moe/nea/firmament/mixins/customgui/OriginalSlotCoords.java b/src/main/java/moe/nea/firmament/mixins/customgui/OriginalSlotCoords.java
index c705625..203b87e 100644
--- a/src/main/java/moe/nea/firmament/mixins/customgui/OriginalSlotCoords.java
+++ b/src/main/java/moe/nea/firmament/mixins/customgui/OriginalSlotCoords.java
@@ -2,7 +2,7 @@
package moe.nea.firmament.mixins.customgui;
import moe.nea.firmament.util.customgui.CoordRememberingSlot;
-import net.minecraft.screen.slot.Slot;
+import net.minecraft.world.inventory.Slot;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
diff --git a/src/main/java/moe/nea/firmament/mixins/customgui/PatchHandledScreen.java b/src/main/java/moe/nea/firmament/mixins/customgui/PatchHandledScreen.java
index 3769ceb..41787e4 100644
--- a/src/main/java/moe/nea/firmament/mixins/customgui/PatchHandledScreen.java
+++ b/src/main/java/moe/nea/firmament/mixins/customgui/PatchHandledScreen.java
@@ -10,15 +10,15 @@ import moe.nea.firmament.keybindings.InputModifiers;
import moe.nea.firmament.util.customgui.CoordRememberingSlot;
import moe.nea.firmament.util.customgui.CustomGui;
import moe.nea.firmament.util.customgui.HasCustomGui;
-import net.minecraft.client.gui.Click;
-import net.minecraft.client.gui.DrawContext;
-import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.client.gui.screen.ingame.HandledScreen;
-import net.minecraft.client.input.CharInput;
-import net.minecraft.client.input.KeyInput;
-import net.minecraft.screen.ScreenHandler;
-import net.minecraft.screen.slot.Slot;
-import net.minecraft.text.Text;
+import net.minecraft.client.input.MouseButtonEvent;
+import net.minecraft.client.gui.GuiGraphics;
+import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
+import net.minecraft.client.input.CharacterEvent;
+import net.minecraft.client.input.KeyEvent;
+import net.minecraft.world.inventory.AbstractContainerMenu;
+import net.minecraft.world.inventory.Slot;
+import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@@ -29,19 +29,19 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-@Mixin(HandledScreen.class)
-public class PatchHandledScreen<T extends ScreenHandler> extends Screen implements HasCustomGui {
+@Mixin(AbstractContainerScreen.class)
+public class PatchHandledScreen<T extends AbstractContainerMenu> extends Screen implements HasCustomGui {
@Shadow
@Final
- protected T handler;
+ protected T menu;
@Shadow
- protected int x;
+ protected int leftPos;
@Shadow
- protected int y;
+ protected int topPos;
@Shadow
- protected int backgroundHeight;
+ protected int imageHeight;
@Shadow
- protected int backgroundWidth;
+ protected int imageWidth;
@Unique
public CustomGui override;
@Unique
@@ -51,7 +51,7 @@ public class PatchHandledScreen<T extends ScreenHandler> extends Screen implemen
@Unique
private int originalBackgroundHeight;
- protected PatchHandledScreen(Text title) {
+ protected PatchHandledScreen(Component title) {
super(title);
}
@@ -64,12 +64,12 @@ public class PatchHandledScreen<T extends ScreenHandler> extends Screen implemen
@Override
public void setCustomGui_Firmament(@Nullable CustomGui gui) {
if (this.override != null) {
- backgroundHeight = originalBackgroundHeight;
- backgroundWidth = originalBackgroundWidth;
+ imageHeight = originalBackgroundHeight;
+ imageWidth = originalBackgroundWidth;
}
if (gui != null) {
- originalBackgroundHeight = backgroundHeight;
- originalBackgroundWidth = backgroundWidth;
+ originalBackgroundHeight = imageHeight;
+ originalBackgroundWidth = imageWidth;
}
this.override = gui;
}
@@ -78,16 +78,16 @@ public class PatchHandledScreen<T extends ScreenHandler> extends Screen implemen
return override != null && override.mouseScrolled(mouseX, mouseY, horizontalAmount, verticalAmount);
}
- public boolean keyReleased_firmament(KeyInput input) {
+ public boolean keyReleased_firmament(KeyEvent input) {
if (HandledScreenKeyReleasedEvent.Companion.publish(new HandledScreenKeyReleasedEvent(
- (HandledScreen<?>) (Object) this,
+ (AbstractContainerScreen<?>) (Object) this,
GenericInputAction.of(input),
InputModifiers.of(input))).getCancelled())
return true;
return override != null && override.keyReleased(input);
}
- public boolean charTyped_firmament(CharInput input) {
+ public boolean charTyped_firmament(CharacterEvent input) {
return override != null && override.charTyped(input);
}
@@ -98,19 +98,19 @@ public class PatchHandledScreen<T extends ScreenHandler> extends Screen implemen
}
}
- @Inject(method = "drawForeground", at = @At("HEAD"), cancellable = true)
- private void onDrawForeground(DrawContext context, int mouseX, int mouseY, CallbackInfo ci) {
+ @Inject(method = "renderLabels", at = @At("HEAD"), cancellable = true)
+ private void onDrawForeground(GuiGraphics context, int mouseX, int mouseY, CallbackInfo ci) {
if (override != null && !override.shouldDrawForeground())
ci.cancel();
}
@WrapOperation(
- method = "drawSlots",
+ method = "renderSlots",
at = @At(
value = "INVOKE",
- target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;drawSlot(Lnet/minecraft/client/gui/DrawContext;Lnet/minecraft/screen/slot/Slot;)V"))
- private void beforeSlotRender(HandledScreen instance, DrawContext context, Slot slot, Operation<Void> original) {
+ target = "Lnet/minecraft/client/gui/screens/inventory/AbstractContainerScreen;renderSlot(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/world/inventory/Slot;)V"))
+ private void beforeSlotRender(AbstractContainerScreen instance, GuiGraphics context, Slot slot, Operation<Void> original) {
if (override != null) {
override.beforeSlotRender(context, slot);
}
@@ -120,7 +120,7 @@ public class PatchHandledScreen<T extends ScreenHandler> extends Screen implemen
}
}
- @Inject(method = "isClickOutsideBounds", at = @At("HEAD"), cancellable = true)
+ @Inject(method = "hasClickedOutside", at = @At("HEAD"), cancellable = true)
public void onIsClickOutsideBounds(
double mouseX, double mouseY, int left, int top,
CallbackInfoReturnable<Boolean> cir) {
@@ -129,24 +129,24 @@ public class PatchHandledScreen<T extends ScreenHandler> extends Screen implemen
}
}
- @Inject(method = "isPointWithinBounds", at = @At("HEAD"), cancellable = true)
+ @Inject(method = "isHovering", at = @At("HEAD"), cancellable = true)
public void onIsPointWithinBounds(int x, int y, int width, int height, double pointX, double pointY, CallbackInfoReturnable<Boolean> cir) {
if (override != null) {
- cir.setReturnValue(override.isPointWithinBounds(x + this.x, y + this.y, width, height, pointX, pointY));
+ cir.setReturnValue(override.isPointWithinBounds(x + this.leftPos, y + this.topPos, width, height, pointX, pointY));
}
}
- @Inject(method = "isPointOverSlot", at = @At("HEAD"), cancellable = true)
+ @Inject(method = "isHovering", at = @At("HEAD"), cancellable = true)
public void onIsPointOverSlot(Slot slot, double pointX, double pointY, CallbackInfoReturnable<Boolean> cir) {
if (override != null) {
- cir.setReturnValue(override.isPointOverSlot(slot, this.x, this.y, pointX, pointY));
+ cir.setReturnValue(override.isPointOverSlot(slot, this.leftPos, this.topPos, pointX, pointY));
}
}
@Inject(method = "renderBackground", at = @At("HEAD"))
- public void moveSlots(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
+ public void moveSlots(GuiGraphics context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
if (override != null) {
- for (Slot slot : handler.slots) {
+ for (Slot slot : menu.slots) {
if (!hasRememberedSlots) {
((CoordRememberingSlot) slot).rememberCoords_firmament();
}
@@ -155,7 +155,7 @@ public class PatchHandledScreen<T extends ScreenHandler> extends Screen implemen
hasRememberedSlots = true;
} else {
if (hasRememberedSlots) {
- for (Slot slot : handler.slots) {
+ for (Slot slot : menu.slots) {
((CoordRememberingSlot) slot).restoreCoords_firmament();
}
hasRememberedSlots = false;
@@ -163,7 +163,7 @@ public class PatchHandledScreen<T extends ScreenHandler> extends Screen implemen
}
}
- @Inject(at = @At("HEAD"), method = "close", cancellable = true)
+ @Inject(at = @At("HEAD"), method = "onClose", cancellable = true)
private void onVoluntaryExit(CallbackInfo ci) {
if (override != null) {
if (!override.onVoluntaryExit())
@@ -171,8 +171,8 @@ public class PatchHandledScreen<T extends ScreenHandler> extends Screen implemen
}
}
- @WrapWithCondition(method = "renderBackground", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;drawBackground(Lnet/minecraft/client/gui/DrawContext;FII)V"))
- public boolean preventDrawingBackground(HandledScreen instance, DrawContext drawContext, float delta, int mouseX, int mouseY) {
+ @WrapWithCondition(method = "renderBackground", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/inventory/AbstractContainerScreen;renderBg(Lnet/minecraft/client/gui/GuiGraphics;FII)V"))
+ public boolean preventDrawingBackground(AbstractContainerScreen instance, GuiGraphics drawContext, float delta, int mouseX, int mouseY) {
if (override != null) {
override.render(drawContext, delta, mouseX, mouseY);
}
@@ -181,8 +181,8 @@ public class PatchHandledScreen<T extends ScreenHandler> extends Screen implemen
@WrapOperation(
method = "mouseClicked",
- at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;mouseClicked(Lnet/minecraft/client/gui/Click;Z)Z"))
- public boolean overrideMouseClicks(HandledScreen instance, Click click, boolean doubled, Operation<Boolean> original) {
+ at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/Screen;mouseClicked(Lnet/minecraft/client/input/MouseButtonEvent;Z)Z"))
+ public boolean overrideMouseClicks(AbstractContainerScreen instance, MouseButtonEvent click, boolean doubled, Operation<Boolean> original) {
if (override != null) {
if (override.mouseClick(click, doubled))
return true;
@@ -191,7 +191,7 @@ public class PatchHandledScreen<T extends ScreenHandler> extends Screen implemen
}
@Inject(method = "mouseDragged", at = @At("HEAD"), cancellable = true)
- public void overrideMouseDrags(Click click, double offsetX, double offsetY, CallbackInfoReturnable<Boolean> cir) {
+ public void overrideMouseDrags(MouseButtonEvent click, double offsetX, double offsetY, CallbackInfoReturnable<Boolean> cir) {
if (override != null) {
if (override.mouseDragged(click, offsetX, offsetY))
cir.setReturnValue(true);
@@ -199,7 +199,7 @@ public class PatchHandledScreen<T extends ScreenHandler> extends Screen implemen
}
@Inject(method = "keyPressed", at = @At("HEAD"), cancellable = true)
- private void overrideKeyPressed(KeyInput input, CallbackInfoReturnable<Boolean> cir) {
+ private void overrideKeyPressed(KeyEvent input, CallbackInfoReturnable<Boolean> cir) {
if (override != null) {
if (override.keyPressed(input)) {
cir.setReturnValue(true);
@@ -211,7 +211,7 @@ public class PatchHandledScreen<T extends ScreenHandler> extends Screen implemen
@Inject(
method = "mouseReleased",
at = @At("HEAD"), cancellable = true)
- public void overrideMouseReleases(Click click, CallbackInfoReturnable<Boolean> cir) {
+ public void overrideMouseReleases(MouseButtonEvent click, CallbackInfoReturnable<Boolean> cir) {
if (override != null) {
if (override.mouseReleased(click))
cir.setReturnValue(true);
diff --git a/src/main/java/moe/nea/firmament/mixins/devenv/DisableCommonPacketWarnings.java b/src/main/java/moe/nea/firmament/mixins/devenv/DisableCommonPacketWarnings.java
index a15d825..2744fb4 100644
--- a/src/main/java/moe/nea/firmament/mixins/devenv/DisableCommonPacketWarnings.java
+++ b/src/main/java/moe/nea/firmament/mixins/devenv/DisableCommonPacketWarnings.java
@@ -2,9 +2,9 @@
package moe.nea.firmament.mixins.devenv;
-import net.minecraft.client.network.ClientPlayNetworkHandler;
-import net.minecraft.network.packet.CustomPayload;
-import net.minecraft.util.Identifier;
+import net.minecraft.client.multiplayer.ClientPacketListener;
+import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
+import net.minecraft.resources.ResourceLocation;
import org.slf4j.Logger;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@@ -14,27 +14,27 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Objects;
-@Mixin(ClientPlayNetworkHandler.class)
+@Mixin(ClientPacketListener.class)
public class DisableCommonPacketWarnings {
- @Inject(method = "warnOnUnknownPayload", at = @At("HEAD"), cancellable = true)
- public void onCustomPacketError(CustomPayload customPayload, CallbackInfo ci) {
- if (Objects.equals(customPayload.getId(), Identifier.of("badlion", "mods"))) {
+ @Inject(method = "handleUnknownCustomPayload", at = @At("HEAD"), cancellable = true)
+ public void onCustomPacketError(CustomPacketPayload customPayload, CallbackInfo ci) {
+ if (Objects.equals(customPayload.type(), ResourceLocation.fromNamespaceAndPath("badlion", "mods"))) {
ci.cancel();
}
}
- @Redirect(method = "onEntityPassengersSet", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;)V", remap = false))
+ @Redirect(method = "handleSetEntityPassengersPacket", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;)V", remap = false))
public void onUnknownPassenger(Logger instance, String s) {
// Ignore passenger data for unknown entities, since HyPixel just sends a lot of those.
}
- @Redirect(method = "onTeam", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;[Ljava/lang/Object;)V", remap = false))
+ @Redirect(method = "handleSetPlayerTeamPacket", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;[Ljava/lang/Object;)V", remap = false))
public void onOnTeam(Logger instance, String s, Object[] objects) {
// Ignore data for unknown teams, since HyPixel just sends a lot of invalid team data.
}
- @Redirect(method = "onPlayerList", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V", remap = false))
+ @Redirect(method = "handlePlayerInfoUpdate", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V", remap = false))
public void onOnPlayerList(Logger instance, String s, Object o, Object o2) {
// Ignore invalid player info, since HyPixel just sends a lot of invalid player info
}
diff --git a/src/main/java/moe/nea/firmament/mixins/devenv/DisableInvalidFishingHook.java b/src/main/java/moe/nea/firmament/mixins/devenv/DisableInvalidFishingHook.java
index 689a757..ffcfefa 100644
--- a/src/main/java/moe/nea/firmament/mixins/devenv/DisableInvalidFishingHook.java
+++ b/src/main/java/moe/nea/firmament/mixins/devenv/DisableInvalidFishingHook.java
@@ -2,15 +2,15 @@
package moe.nea.firmament.mixins.devenv;
-import net.minecraft.entity.projectile.FishingBobberEntity;
+import net.minecraft.world.entity.projectile.FishingHook;
import org.slf4j.Logger;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
-@Mixin(FishingBobberEntity.class)
+@Mixin(FishingHook.class)
public class DisableInvalidFishingHook {
- @Redirect(method = "onSpawnPacket", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V", remap = false))
+ @Redirect(method = "recreateFromPacket", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V", remap = false))
public void onOnSpawnPacket(Logger instance, String s, Object o, Object o1) {
// Don't warn for broken fishing hooks, since HyPixel sends a bunch of those
}
diff --git a/src/main/java/moe/nea/firmament/mixins/devenv/EarlyInstantiateTranslations.java b/src/main/java/moe/nea/firmament/mixins/devenv/EarlyInstantiateTranslations.java
index ef8c9eb..849525f 100644
--- a/src/main/java/moe/nea/firmament/mixins/devenv/EarlyInstantiateTranslations.java
+++ b/src/main/java/moe/nea/firmament/mixins/devenv/EarlyInstantiateTranslations.java
@@ -1,19 +1,19 @@
package moe.nea.firmament.mixins.devenv;
-import net.minecraft.text.TranslatableTextContent;
+import net.minecraft.network.chat.contents.TranslatableContents;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(TranslatableTextContent.class)
+@Mixin(TranslatableContents.class)
public abstract class EarlyInstantiateTranslations {
@Shadow
- protected abstract void updateTranslations();
+ protected abstract void decompose();
@Inject(method = "<init>", at = @At("TAIL"))
private void onInit(String key, String fallback, Object[] args, CallbackInfo ci) {
- updateTranslations();
+ decompose();
}
}
diff --git a/src/main/java/moe/nea/firmament/mixins/devenv/IdentifyCloser.java b/src/main/java/moe/nea/firmament/mixins/devenv/IdentifyCloser.java
index 6620b47..c71f337 100644
--- a/src/main/java/moe/nea/firmament/mixins/devenv/IdentifyCloser.java
+++ b/src/main/java/moe/nea/firmament/mixins/devenv/IdentifyCloser.java
@@ -1,7 +1,7 @@
package moe.nea.firmament.mixins.devenv;
-import net.minecraft.client.util.Window;
+import com.mojang.blaze3d.platform.Window;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
diff --git a/src/main/java/moe/nea/firmament/mixins/devenv/IdentifyStopperPatch.java b/src/main/java/moe/nea/firmament/mixins/devenv/IdentifyStopperPatch.java
index cedfb95..cc04493 100644
--- a/src/main/java/moe/nea/firmament/mixins/devenv/IdentifyStopperPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/devenv/IdentifyStopperPatch.java
@@ -1,19 +1,19 @@
package moe.nea.firmament.mixins.devenv;
-import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.Minecraft;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(MinecraftClient.class)
+@Mixin(Minecraft.class)
public class IdentifyStopperPatch {
@Shadow
private volatile boolean running;
- @Inject(method = "scheduleStop", at = @At("HEAD"))
+ @Inject(method = "stop", at = @At("HEAD"))
private void onStop(CallbackInfo ci) {
if (this.running)
Thread.dumpStack();
diff --git a/src/main/java/moe/nea/firmament/mixins/devenv/MixinKeyboard.java b/src/main/java/moe/nea/firmament/mixins/devenv/MixinKeyboard.java
index d7b6cc3..7d5fc80 100644
--- a/src/main/java/moe/nea/firmament/mixins/devenv/MixinKeyboard.java
+++ b/src/main/java/moe/nea/firmament/mixins/devenv/MixinKeyboard.java
@@ -3,18 +3,18 @@
package moe.nea.firmament.mixins.devenv;
import moe.nea.firmament.features.debug.DeveloperFeatures;
-import net.minecraft.client.Keyboard;
-import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.KeyboardHandler;
+import net.minecraft.client.Minecraft;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import java.util.concurrent.CompletableFuture;
-@Mixin(Keyboard.class)
+@Mixin(KeyboardHandler.class)
public class MixinKeyboard {
- @Redirect(method = "processF3", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;reloadResources()Ljava/util/concurrent/CompletableFuture;"))
- public CompletableFuture<Void> redirectReloadResources(MinecraftClient instance) {
+ @Redirect(method = "handleDebugKeys", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;reloadResourcePacks()Ljava/util/concurrent/CompletableFuture;"))
+ public CompletableFuture<Void> redirectReloadResources(Minecraft instance) {
return DeveloperFeatures.hookOnBeforeResourceReload(instance);
}
}
diff --git a/src/main/java/moe/nea/firmament/mixins/devenv/MixinScoreboard.java b/src/main/java/moe/nea/firmament/mixins/devenv/MixinScoreboard.java
index 34a733c..d96cac9 100644
--- a/src/main/java/moe/nea/firmament/mixins/devenv/MixinScoreboard.java
+++ b/src/main/java/moe/nea/firmament/mixins/devenv/MixinScoreboard.java
@@ -2,7 +2,7 @@
package moe.nea.firmament.mixins.devenv;
-import net.minecraft.scoreboard.Scoreboard;
+import net.minecraft.world.scores.Scoreboard;
import org.slf4j.Logger;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@@ -10,7 +10,8 @@ import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(Scoreboard.class)
public class MixinScoreboard {
- @Redirect(method = "addTeam", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V", remap = false))
+ // TODO(Ravel): target method addTeam is ambiguous
+ @Redirect(method = "addTeam", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V", remap = false))
public void onExistingteam(Logger instance, String s, Object o) {
// Ignore creations of existing teams
}
diff --git a/src/main/java/moe/nea/firmament/mixins/devenv/WarnForUnknownCustomPayloadSends.java b/src/main/java/moe/nea/firmament/mixins/devenv/WarnForUnknownCustomPayloadSends.java
index 6d44e29..9a96df2 100644
--- a/src/main/java/moe/nea/firmament/mixins/devenv/WarnForUnknownCustomPayloadSends.java
+++ b/src/main/java/moe/nea/firmament/mixins/devenv/WarnForUnknownCustomPayloadSends.java
@@ -2,17 +2,17 @@
package moe.nea.firmament.mixins.devenv;
import moe.nea.firmament.Firmament;
-import net.minecraft.network.PacketByteBuf;
-import net.minecraft.network.packet.UnknownCustomPayload;
+import net.minecraft.network.FriendlyByteBuf;
+import net.minecraft.network.protocol.common.custom.DiscardedPayload;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-@Mixin(UnknownCustomPayload.class)
+@Mixin(DiscardedPayload.class)
public class WarnForUnknownCustomPayloadSends {
@Inject(method = "method_56493", at = @At("HEAD"))
- private static void warn(UnknownCustomPayload value, PacketByteBuf buf, CallbackInfo ci) {
+ private static void warn(DiscardedPayload value, FriendlyByteBuf buf, CallbackInfo ci) {
Firmament.INSTANCE.getLogger().warn("Unknown custom payload is being sent: {}", value);
}
}
diff --git a/src/main/java/moe/nea/firmament/mixins/devenv/WarnOnMissingTranslations.java b/src/main/java/moe/nea/firmament/mixins/devenv/WarnOnMissingTranslations.java
index 33840c1..e513a97 100644
--- a/src/main/java/moe/nea/firmament/mixins/devenv/WarnOnMissingTranslations.java
+++ b/src/main/java/moe/nea/firmament/mixins/devenv/WarnOnMissingTranslations.java
@@ -2,8 +2,8 @@ package moe.nea.firmament.mixins.devenv;
import moe.nea.firmament.features.debug.DeveloperFeatures;
import moe.nea.firmament.util.MC;
-import net.minecraft.client.resource.language.TranslationStorage;
-import net.minecraft.text.Text;
+import net.minecraft.client.resources.language.ClientLanguage;
+import net.minecraft.network.chat.Component;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
@@ -14,15 +14,15 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Set;
import java.util.TreeSet;
-@Mixin(TranslationStorage.class)
+@Mixin(ClientLanguage.class)
public abstract class WarnOnMissingTranslations {
@Shadow
- public abstract boolean hasTranslation(String key);
+ public abstract boolean has(String key);
@Unique
private final Set<String> missingTranslations = new TreeSet<>();
- @Inject(method = "get", at = @At("HEAD"))
+ @Inject(method = "getOrDefault", at = @At("HEAD"))
private void onGetTranslationKey(String key, String fallback, CallbackInfoReturnable<String> cir) {
warnForMissingTranslation(key);
}
@@ -30,9 +30,9 @@ public abstract class WarnOnMissingTranslations {
@Unique
private void warnForMissingTranslation(String key) {
if (!key.contains("firmament")) return;
- if (hasTranslation(key)) return;
+ if (has(key)) return;
if (!missingTranslations.add(key)) return;
- MC.INSTANCE.sendChat(Text.literal("Missing firmament translation: " + key));
+ MC.INSTANCE.sendChat(Component.literal("Missing firmament translation: " + key));
DeveloperFeatures.hookMissingTranslations(missingTranslations);
}
}
diff --git a/src/main/java/moe/nea/firmament/mixins/feature/DisableSlotHighlights.java b/src/main/java/moe/nea/firmament/mixins/feature/DisableSlotHighlights.java
index 0abed22..475a5bf 100644
--- a/src/main/java/moe/nea/firmament/mixins/feature/DisableSlotHighlights.java
+++ b/src/main/java/moe/nea/firmament/mixins/feature/DisableSlotHighlights.java
@@ -1,9 +1,9 @@
package moe.nea.firmament.mixins.feature;
import moe.nea.firmament.features.fixes.Fixes;
-import net.minecraft.component.DataComponentTypes;
-import net.minecraft.item.ItemStack;
-import net.minecraft.screen.slot.Slot;
+import net.minecraft.core.component.DataComponents;
+import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.inventory.Slot;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@@ -13,12 +13,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(Slot.class)
public abstract class DisableSlotHighlights {
@Shadow
- public abstract ItemStack getStack();
+ public abstract ItemStack getItem();
- @Inject(method = "canBeHighlighted", at = @At("HEAD"), cancellable = true)
+ @Inject(method = "isHighlightable", at = @At("HEAD"), cancellable = true)
private void dontHighlight(CallbackInfoReturnable<Boolean> cir) {
if (!Fixes.TConfig.INSTANCE.getHideSlotHighlights()) return;
- var display = getStack().get(DataComponentTypes.TOOLTIP_DISPLAY);
+ var display = getItem().get(DataComponents.TOOLTIP_DISPLAY);
if (display != null && display.hideTooltip())
cir.setReturnValue(false);
}
diff --git a/src/main/java/moe/nea/firmament/mixins/feature/devcosmetics/CustomCapeFeatureRenderer.java b/src/main/java/moe/nea/firmament/mixins/feature/devcosmetics/CustomCapeFeatureRenderer.java
index 5d69e96..7852fc3 100644
--- a/src/main/java/moe/nea/firmament/mixins/feature/devcosmetics/CustomCapeFeatureRenderer.java
+++ b/src/main/java/moe/nea/firmament/mixins/feature/devcosmetics/CustomCapeFeatureRenderer.java
@@ -6,34 +6,34 @@ import com.llamalad7.mixinextras.sugar.Local;
import kotlin.Unit;
import moe.nea.firmament.features.misc.CustomCapes;
import net.minecraft.client.model.Model;
-import net.minecraft.client.render.RenderLayer;
-import net.minecraft.client.render.VertexConsumer;
-import net.minecraft.client.render.VertexConsumerProvider;
-import net.minecraft.client.render.command.ModelCommandRenderer;
-import net.minecraft.client.render.command.OrderedRenderCommandQueue;
-import net.minecraft.client.render.entity.feature.CapeFeatureRenderer;
-import net.minecraft.client.render.entity.feature.FeatureRenderer;
-import net.minecraft.client.render.entity.feature.FeatureRendererContext;
-import net.minecraft.client.render.entity.model.BipedEntityModel;
-import net.minecraft.client.render.entity.model.PlayerEntityModel;
-import net.minecraft.client.render.entity.state.PlayerEntityRenderState;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.entity.player.SkinTextures;
+import net.minecraft.client.renderer.RenderType;
+import com.mojang.blaze3d.vertex.VertexConsumer;
+import net.minecraft.client.renderer.MultiBufferSource;
+import net.minecraft.client.renderer.feature.ModelFeatureRenderer;
+import net.minecraft.client.renderer.SubmitNodeCollector;
+import net.minecraft.client.renderer.entity.layers.CapeLayer;
+import net.minecraft.client.renderer.entity.layers.RenderLayer;
+import net.minecraft.client.renderer.entity.RenderLayerParent;
+import net.minecraft.client.model.HumanoidModel;
+import net.minecraft.client.model.PlayerModel;
+import net.minecraft.client.renderer.entity.state.AvatarRenderState;
+import com.mojang.blaze3d.vertex.PoseStack;
+import net.minecraft.world.entity.player.PlayerSkin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
-@Mixin(CapeFeatureRenderer.class)
-public abstract class CustomCapeFeatureRenderer extends FeatureRenderer<PlayerEntityRenderState, PlayerEntityModel> {
- public CustomCapeFeatureRenderer(FeatureRendererContext<PlayerEntityRenderState, PlayerEntityModel> context) {
+@Mixin(CapeLayer.class)
+public abstract class CustomCapeFeatureRenderer extends RenderLayer<AvatarRenderState, PlayerModel> {
+ public CustomCapeFeatureRenderer(RenderLayerParent<AvatarRenderState, PlayerModel> context) {
super(context);
}
@WrapOperation(
- method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;ILnet/minecraft/client/render/entity/state/PlayerEntityRenderState;FF)V",
- at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;submitModel(Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/RenderLayer;IIILnet/minecraft/client/render/command/ModelCommandRenderer$CrumblingOverlayCommand;)V")
+ method = "submit(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;ILnet/minecraft/client/renderer/entity/state/AvatarRenderState;FF)V",
+ at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/SubmitNodeCollector;submitModel(Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/RenderType;IIILnet/minecraft/client/renderer/feature/ModelFeatureRenderer$CrumblingOverlay;)V")
)
- private void onRender(OrderedRenderCommandQueue instance, Model model, Object o, MatrixStack matrixStack, RenderLayer renderLayer, int light, int overlay, int outlineColor, ModelCommandRenderer.CrumblingOverlayCommand crumblingOverlayCommand, Operation<Void> original,
- @Local(argsOnly = true) PlayerEntityRenderState playerEntityRenderState, @Local SkinTextures skinTextures) {
+ private void onRender(SubmitNodeCollector instance, Model model, Object o, PoseStack matrixStack, RenderType renderLayer, int light, int overlay, int outlineColor, ModelFeatureRenderer.CrumblingOverlay crumblingOverlayCommand, Operation<Void> original,
+ @Local(argsOnly = true) AvatarRenderState playerEntityRenderState, @Local PlayerSkin skinTextures) {
// TODO: 1.21.10 custom capes by pre rendering the texture id. this is more viable on this version i am fairly sure, without clogging up all of the cached image render layers
// CustomCapes.render(
// playerEntityRenderState,
diff --git a/src/main/java/moe/nea/firmament/mixins/feature/devcosmetics/CustomCapeStorage.java b/src/main/java/moe/nea/firmament/mixins/feature/devcosmetics/CustomCapeStorage.java
index 428d7ec..dc933ce 100644
--- a/src/main/java/moe/nea/firmament/mixins/feature/devcosmetics/CustomCapeStorage.java
+++ b/src/main/java/moe/nea/firmament/mixins/feature/devcosmetics/CustomCapeStorage.java
@@ -1,12 +1,12 @@
package moe.nea.firmament.mixins.feature.devcosmetics;
import moe.nea.firmament.features.misc.CustomCapes;
-import net.minecraft.client.render.entity.state.PlayerEntityRenderState;
+import net.minecraft.client.renderer.entity.state.AvatarRenderState;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
-@Mixin(PlayerEntityRenderState.class)
+@Mixin(AvatarRenderState.class)
public class CustomCapeStorage implements CustomCapes.CapeStorage {
@Unique
CustomCapes.CustomCape customCape;
diff --git a/src/main/java/moe/nea/firmament/mixins/render/IncreaseStackLimitSizeInDrawContext.java b/src/main/java/moe/nea/firmament/mixins/render/IncreaseStackLimitSizeInDrawContext.java
index 61ad8a3..2352dfa 100644
--- a/src/main/java/moe/nea/firmament/mixins/render/IncreaseStackLimitSizeInDrawContext.java
+++ b/src/main/java/moe/nea/firmament/mixins/render/IncreaseStackLimitSizeInDrawContext.java
@@ -1,18 +1,18 @@
package moe.nea.firmament.mixins.render;
-import net.minecraft.client.gui.DrawContext;
+import net.minecraft.client.gui.GuiGraphics;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;
-@Mixin(DrawContext.class)
+@Mixin(GuiGraphics.class)
public class IncreaseStackLimitSizeInDrawContext {
// [22:00:57] [Render thread/ERROR] (Minecraft) Couldn't compile program for pipeline firmament:gui_textured_overlay_tris_circle:
// net.minecraft.client.gl.ShaderLoader$LoadException: Error encountered when linking program containing
// VS minecraft:core/position_tex_color and FS firmament:circle_discard_color.
// Log output: error: declarations for uniform `ColorModulator` are inside block `DynamicTransforms` and outside a block
@ModifyArg(
- method = "<init>(Lnet/minecraft/client/MinecraftClient;Lnet/minecraft/client/gui/render/state/GuiRenderState;)V",
+ method = "<init>(Lnet/minecraft/client/Minecraft;Lnet/minecraft/client/gui/render/state/GuiRenderState;)V",
at = @At(value = "INVOKE", target = "Lorg/joml/Matrix3x2fStack;<init>(I)V"))
private static int increaseStackSize(int stackSize) {
return Math.max(stackSize, 48);
diff --git a/src/main/java/moe/nea/firmament/mixins/render/entitytints/ChangeColorOfLivingEntities.java b/src/main/java/moe/nea/firmament/mixins/render/entitytints/ChangeColorOfLivingEntities.java
index 79958c0..53353e2 100644
--- a/src/main/java/moe/nea/firmament/mixins/render/entitytints/ChangeColorOfLivingEntities.java
+++ b/src/main/java/moe/nea/firmament/mixins/render/entitytints/ChangeColorOfLivingEntities.java
@@ -3,14 +3,14 @@ package moe.nea.firmament.mixins.render.entitytints;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.llamalad7.mixinextras.sugar.Local;
import moe.nea.firmament.events.EntityRenderTintEvent;
-import net.minecraft.client.render.VertexConsumerProvider;
-import net.minecraft.client.render.command.OrderedRenderCommandQueue;
-import net.minecraft.client.render.entity.LivingEntityRenderer;
-import net.minecraft.client.render.entity.model.EntityModel;
-import net.minecraft.client.render.entity.state.LivingEntityRenderState;
-import net.minecraft.client.render.state.CameraRenderState;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.entity.LivingEntity;
+import net.minecraft.client.renderer.MultiBufferSource;
+import net.minecraft.client.renderer.SubmitNodeCollector;
+import net.minecraft.client.renderer.entity.LivingEntityRenderer;
+import net.minecraft.client.model.EntityModel;
+import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
+import net.minecraft.client.renderer.state.CameraRenderState;
+import com.mojang.blaze3d.vertex.PoseStack;
+import net.minecraft.world.entity.LivingEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@@ -22,7 +22,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
*/
@Mixin(LivingEntityRenderer.class)
public class ChangeColorOfLivingEntities<T extends LivingEntity, S extends LivingEntityRenderState, M extends EntityModel<? super S>> {
- @ModifyReturnValue(method = "getMixColor", at = @At("RETURN"))
+ @ModifyReturnValue(method = "getModelTint", at = @At("RETURN"))
private int changeColor(int original, @Local(argsOnly = true) S state) {
var tintState = EntityRenderTintEvent.HasTintRenderState.cast(state);
if (tintState.getHasTintOverride_firmament())
@@ -31,8 +31,8 @@ public class ChangeColorOfLivingEntities<T extends LivingEntity, S extends Livin
}
@ModifyArg(
- method = "getOverlay",
- at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/OverlayTexture;getU(F)I"),
+ method = "getOverlayCoords",
+ at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/texture/OverlayTexture;u(F)I"),
allow = 1
)
private static float modifyLightOverlay(float originalWhiteOffset, @Local(argsOnly = true) LivingEntityRenderState state) {
@@ -43,8 +43,8 @@ public class ChangeColorOfLivingEntities<T extends LivingEntity, S extends Livin
return originalWhiteOffset;
}
- @Inject(method = "render(Lnet/minecraft/client/render/entity/state/LivingEntityRenderState;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;Lnet/minecraft/client/render/state/CameraRenderState;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;pop()V"))
- private void afterRender(S livingEntityRenderState, MatrixStack matrixStack, OrderedRenderCommandQueue orderedRenderCommandQueue, CameraRenderState cameraRenderState, CallbackInfo ci) {
+ @Inject(method = "submit(Lnet/minecraft/client/renderer/entity/state/LivingEntityRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/state/CameraRenderState;)V", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;popPose()V"))
+ private void afterRender(S livingEntityRenderState, PoseStack matrixStack, SubmitNodeCollector orderedRenderCommandQueue, CameraRenderState cameraRenderState, CallbackInfo ci) {
// var tintState = EntityRenderTintEvent.HasTintRenderState.cast(livingEntityRenderState);
// var overlayTexture = tintState.getOverlayTexture_firmament();
// if (overlayTexture != null && vertexConsumerProvider instanceof VertexConsumerProvider.Immediate imm) {
@@ -54,8 +54,8 @@ public class ChangeColorOfLivingEntities<T extends LivingEntity, S extends Livin
// TODO: 1.21.10
}
- @Inject(method = "render(Lnet/minecraft/client/render/entity/state/LivingEntityRenderState;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;Lnet/minecraft/client/render/state/CameraRenderState;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;push()V"))
- private void beforeRender(S livingEntityRenderState, MatrixStack matrixStack, OrderedRenderCommandQueue orderedRenderCommandQueue, CameraRenderState cameraRenderState, CallbackInfo ci) {
+ @Inject(method = "submit(Lnet/minecraft/client/renderer/entity/state/LivingEntityRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/state/CameraRenderState;)V", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;pushPose()V"))
+ private void beforeRender(S livingEntityRenderState, PoseStack matrixStack, SubmitNodeCollector orderedRenderCommandQueue, CameraRenderState cameraRenderState, CallbackInfo ci) {
var tintState = EntityRenderTintEvent.HasTintRenderState.cast(livingEntityRenderState);
var overlayTexture = tintState.getOverlayTexture_firmament();
if (overlayTexture != null) {
diff --git a/src/main/java/moe/nea/firmament/mixins/render/entitytints/EntityRenderStateTint.java b/src/main/java/moe/nea/firmament/mixins/render/entitytints/EntityRenderStateTint.java
index 1019027..1745fc9 100644
--- a/src/main/java/moe/nea/firmament/mixins/render/entitytints/EntityRenderStateTint.java
+++ b/src/main/java/moe/nea/firmament/mixins/render/entitytints/EntityRenderStateTint.java
@@ -2,7 +2,7 @@ package moe.nea.firmament.mixins.render.entitytints;
import moe.nea.firmament.events.EntityRenderTintEvent;
import moe.nea.firmament.util.render.TintedOverlayTexture;
-import net.minecraft.client.render.entity.state.EntityRenderState;
+import net.minecraft.client.renderer.entity.state.EntityRenderState;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
diff --git a/src/main/java/moe/nea/firmament/mixins/render/entitytints/InjectIntoRenderState.java b/src/main/java/moe/nea/firmament/mixins/render/entitytints/InjectIntoRenderState.java
index 7938340..c84dbb6 100644
--- a/src/main/java/moe/nea/firmament/mixins/render/entitytints/InjectIntoRenderState.java
+++ b/src/main/java/moe/nea/firmament/mixins/render/entitytints/InjectIntoRenderState.java
@@ -1,9 +1,9 @@
package moe.nea.firmament.mixins.render.entitytints;
import moe.nea.firmament.events.EntityRenderTintEvent;
-import net.minecraft.client.render.entity.EntityRenderer;
-import net.minecraft.client.render.entity.state.EntityRenderState;
-import net.minecraft.entity.Entity;
+import net.minecraft.client.renderer.entity.EntityRenderer;
+import net.minecraft.client.renderer.entity.state.EntityRenderState;
+import net.minecraft.world.entity.Entity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@@ -16,7 +16,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
public class InjectIntoRenderState<T extends Entity, S extends EntityRenderState> {
@Inject(
- method = "updateRenderState",
+ method = "extractRenderState",
at = @At("RETURN"))
private void onUpdateRenderState(T entity, S state, float tickDelta, CallbackInfo ci) {
var renderState = EntityRenderTintEvent.HasTintRenderState.cast(state);
diff --git a/src/main/java/moe/nea/firmament/mixins/render/entitytints/ReplaceOverlayTexture.java b/src/main/java/moe/nea/firmament/mixins/render/entitytints/ReplaceOverlayTexture.java
index 61e5c65..ef8b371 100644
--- a/src/main/java/moe/nea/firmament/mixins/render/entitytints/ReplaceOverlayTexture.java
+++ b/src/main/java/moe/nea/firmament/mixins/render/entitytints/ReplaceOverlayTexture.java
@@ -2,20 +2,20 @@ package moe.nea.firmament.mixins.render.entitytints;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import moe.nea.firmament.events.EntityRenderTintEvent;
-import net.minecraft.client.render.OverlayTexture;
-import net.minecraft.client.render.RenderLayer;
+import net.minecraft.client.renderer.texture.OverlayTexture;
+import net.minecraft.client.renderer.RenderType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
/**
* Replaces the overlay texture used by rendering with the override specified in {@link EntityRenderTintEvent#overlayOverride}
*/
-@Mixin(RenderLayer.Overlay.class)
+@Mixin(RenderType.OverlayStateShard.class)
public class ReplaceOverlayTexture {
@ModifyExpressionValue(
method = {"method_23555", "method_23556"},
expect = 2,
- at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/GameRenderer;getOverlayTexture()Lnet/minecraft/client/render/OverlayTexture;"))
+ at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GameRenderer;overlayTexture()Lnet/minecraft/client/renderer/texture/OverlayTexture;"))
private static OverlayTexture replaceOverlayTexture(OverlayTexture original) {
if (EntityRenderTintEvent.overlayOverride != null)
return EntityRenderTintEvent.overlayOverride;
diff --git a/src/main/java/moe/nea/firmament/mixins/render/entitytints/UseOverlayableEquipmentRenderer.java b/src/main/java/moe/nea/firmament/mixins/render/entitytints/UseOverlayableEquipmentRenderer.java
index 8671bda..0cceea3 100644
--- a/src/main/java/moe/nea/firmament/mixins/render/entitytints/UseOverlayableEquipmentRenderer.java
+++ b/src/main/java/moe/nea/firmament/mixins/render/entitytints/UseOverlayableEquipmentRenderer.java
@@ -4,31 +4,31 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import moe.nea.firmament.events.EntityRenderTintEvent;
-import net.minecraft.client.render.OverlayTexture;
-import net.minecraft.client.render.RenderLayer;
-import net.minecraft.client.render.entity.equipment.EquipmentRenderer;
-import net.minecraft.util.Identifier;
+import net.minecraft.client.renderer.texture.OverlayTexture;
+import net.minecraft.client.renderer.RenderType;
+import net.minecraft.client.renderer.entity.layers.EquipmentLayerRenderer;
+import net.minecraft.resources.ResourceLocation;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
/**
- * Patch to make {@link EquipmentRenderer} use a {@link RenderLayer} that allows uses Minecraft's overlay texture, if a {@link EntityRenderTintEvent#overlayOverride} is specified.
+ * Patch to make {@link EquipmentLayerRenderer} use a {@link RenderType} that allows uses Minecraft's overlay texture, if a {@link EntityRenderTintEvent#overlayOverride} is specified.
*/
-@Mixin(EquipmentRenderer.class)
+@Mixin(EquipmentLayerRenderer.class)
public class UseOverlayableEquipmentRenderer {
- @WrapOperation(method = "render(Lnet/minecraft/client/render/entity/equipment/EquipmentModel$LayerType;Lnet/minecraft/registry/RegistryKey;Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;ILnet/minecraft/util/Identifier;II)V",
- at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/RenderLayer;getArmorCutoutNoCull(Lnet/minecraft/util/Identifier;)Lnet/minecraft/client/render/RenderLayer;"))
- private RenderLayer replace(Identifier texture, Operation<RenderLayer> original) {
+ @WrapOperation(method = "renderLayers(Lnet/minecraft/client/resources/model/EquipmentClientInfo$LayerType;Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lnet/minecraft/world/item/ItemStack;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;ILnet/minecraft/resources/ResourceLocation;II)V",
+ at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderType;armorCutoutNoCull(Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/renderer/RenderType;"))
+ private RenderType replace(ResourceLocation texture, Operation<RenderType> original) {
if (EntityRenderTintEvent.overlayOverride != null)
- return RenderLayer.getEntityTranslucent(texture);
+ return RenderType.entityTranslucent(texture);
return original.call(texture);
}
- @ModifyExpressionValue(method = "render(Lnet/minecraft/client/render/entity/equipment/EquipmentModel$LayerType;Lnet/minecraft/registry/RegistryKey;Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;ILnet/minecraft/util/Identifier;II)V",
- at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/OverlayTexture;DEFAULT_UV:I"))
+ @ModifyExpressionValue(method = "renderLayers(Lnet/minecraft/client/resources/model/EquipmentClientInfo$LayerType;Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lnet/minecraft/world/item/ItemStack;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;ILnet/minecraft/resources/ResourceLocation;II)V",
+ at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/texture/OverlayTexture;NO_OVERLAY:I"))
private int replaceUvIndex(int original) {
if (EntityRenderTintEvent.overlayOverride != null)
- return OverlayTexture.packUv(15, 10); // TODO: store this info in a global alongside overlayOverride
+ return OverlayTexture.pack(15, 10); // TODO: store this info in a global alongside overlayOverride
return original;
}
}
diff --git a/src/main/java/moe/nea/firmament/mixins/render/entitytints/UseOverlayableHeadFeatureRenderer.java b/src/main/java/moe/nea/firmament/mixins/render/entitytints/UseOverlayableHeadFeatureRenderer.java
index 0422a66..a867c81 100644
--- a/src/main/java/moe/nea/firmament/mixins/render/entitytints/UseOverlayableHeadFeatureRenderer.java
+++ b/src/main/java/moe/nea/firmament/mixins/render/entitytints/UseOverlayableHeadFeatureRenderer.java
@@ -2,25 +2,25 @@ package moe.nea.firmament.mixins.render.entitytints;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import moe.nea.firmament.events.EntityRenderTintEvent;
-import net.minecraft.client.render.OverlayTexture;
-import net.minecraft.client.render.RenderLayer;
-import net.minecraft.client.render.entity.feature.HeadFeatureRenderer;
+import net.minecraft.client.renderer.texture.OverlayTexture;
+import net.minecraft.client.renderer.RenderType;
+import net.minecraft.client.renderer.entity.layers.CustomHeadLayer;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
/**
- * Patch to make {@link HeadFeatureRenderer} use a {@link RenderLayer} that allows uses Minecraft's overlay texture, if a {@link EntityRenderTintEvent#overlayOverride} is specified.
+ * Patch to make {@link CustomHeadLayer} use a {@link RenderType} that allows uses Minecraft's overlay texture, if a {@link EntityRenderTintEvent#overlayOverride} is specified.
* @see UseOverlayableItemRenderer
*/
-@Mixin(HeadFeatureRenderer.class)
+@Mixin(CustomHeadLayer.class)
public class UseOverlayableHeadFeatureRenderer {
- @ModifyExpressionValue(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;ILnet/minecraft/client/render/entity/state/LivingEntityRenderState;FF)V",
- at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/OverlayTexture;DEFAULT_UV:I", opcode = Opcodes.GETSTATIC))
+ @ModifyExpressionValue(method = "submit(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;ILnet/minecraft/client/renderer/entity/state/LivingEntityRenderState;FF)V",
+ at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/texture/OverlayTexture;NO_OVERLAY:I", opcode = Opcodes.GETSTATIC))
private int replaceUvIndex(int original) {
if (EntityRenderTintEvent.overlayOverride != null)
- return OverlayTexture.packUv(15, 10); // TODO: store this info in a global alongside overlayOverride
+ return OverlayTexture.pack(15, 10); // TODO: store this info in a global alongside overlayOverride
return original;
}
}
diff --git a/src/main/java/moe/nea/firmament/mixins/render/entitytints/UseOverlayableItemRenderer.java b/src/main/java/moe/nea/firmament/mixins/render/entitytints/UseOverlayableItemRenderer.java
index 739fc5f..dcac77c 100644
--- a/src/main/java/moe/nea/firmament/mixins/render/entitytints/UseOverlayableItemRenderer.java
+++ b/src/main/java/moe/nea/firmament/mixins/render/entitytints/UseOverlayableItemRenderer.java
@@ -2,25 +2,25 @@ package moe.nea.firmament.mixins.render.entitytints;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import moe.nea.firmament.events.EntityRenderTintEvent;
-import net.minecraft.client.render.OverlayTexture;
-import net.minecraft.client.render.RenderLayer;
-import net.minecraft.client.render.RenderPhase;
-import net.minecraft.client.render.item.ItemRenderState;
+import net.minecraft.client.renderer.texture.OverlayTexture;
+import net.minecraft.client.renderer.RenderType;
+import net.minecraft.client.renderer.RenderStateShard;
+import net.minecraft.client.renderer.item.ItemStackRenderState;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
/**
- * Patch to make {@link ItemRenderState} use a {@link RenderLayer} that allows uses Minecraft's overlay texture.
+ * Patch to make {@link ItemStackRenderState} use a {@link RenderType} that allows uses Minecraft's overlay texture.
*
* @see UseOverlayableHeadFeatureRenderer
*/
-@Mixin(ItemRenderState.LayerRenderState.class)
+@Mixin(ItemStackRenderState.LayerRenderState.class)
public class UseOverlayableItemRenderer {
- @ModifyExpressionValue(method = "render", at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/item/ItemRenderState$LayerRenderState;renderLayer:Lnet/minecraft/client/render/RenderLayer;", opcode = Opcodes.GETFIELD))
- private RenderLayer replace(RenderLayer original) {
- if (EntityRenderTintEvent.overlayOverride != null && original instanceof RenderLayer.MultiPhase multiPhase && multiPhase.phases.texture instanceof RenderPhase.Texture texture && texture.getId().isPresent())
- return RenderLayer.getEntityTranslucent(texture.getId().get());
+ @ModifyExpressionValue(method = "submit", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/item/ItemStackRenderState$LayerRenderState;renderType:Lnet/minecraft/client/renderer/RenderType;", opcode = Opcodes.GETFIELD))
+ private RenderType replace(RenderType original) {
+ if (EntityRenderTintEvent.overlayOverride != null && original instanceof RenderType.CompositeRenderType multiPhase && multiPhase.state.textureState instanceof RenderStateShard.TextureStateShard texture && texture.cutoutTexture().isPresent())
+ return RenderType.entityTranslucent(texture.cutoutTexture().get());
return original;
}
}
diff --git a/src/main/java/moe/nea/firmament/mixins/render/entitytints/UseOverlayableSkullBlockEntityRenderer.java b/src/main/java/moe/nea/firmament/mixins/render/entitytints/UseOverlayableSkullBlockEntityRenderer.java
index 2a15e8c..ac102ed 100644
--- a/src/main/java/moe/nea/firmament/mixins/render/entitytints/UseOverlayableSkullBlockEntityRenderer.java
+++ b/src/main/java/moe/nea/firmament/mixins/render/entitytints/UseOverlayableSkullBlockEntityRenderer.java
@@ -2,23 +2,23 @@ package moe.nea.firmament.mixins.render.entitytints;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import moe.nea.firmament.events.EntityRenderTintEvent;
-import net.minecraft.client.render.OverlayTexture;
-import net.minecraft.client.render.RenderLayer;
-import net.minecraft.client.render.block.entity.SkullBlockEntityRenderer;
+import net.minecraft.client.renderer.texture.OverlayTexture;
+import net.minecraft.client.renderer.RenderType;
+import net.minecraft.client.renderer.blockentity.SkullBlockRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
/**
- * Patch to make {@link SkullBlockEntityRenderer} use a {@link RenderLayer} that allows uses Minecraft's overlay texture, if a {@link EntityRenderTintEvent#overlayOverride} is specified.
+ * Patch to make {@link SkullBlockRenderer} use a {@link RenderType} that allows uses Minecraft's overlay texture, if a {@link EntityRenderTintEvent#overlayOverride} is specified.
*/
-@Mixin(SkullBlockEntityRenderer.class)
+@Mixin(SkullBlockRenderer.class)
public class UseOverlayableSkullBlockEntityRenderer {
- @ModifyExpressionValue(method = "render(Lnet/minecraft/util/math/Direction;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;ILnet/minecraft/client/render/block/entity/SkullBlockEntityModel;Lnet/minecraft/client/render/RenderLayer;ILnet/minecraft/client/render/command/ModelCommandRenderer$CrumblingOverlayCommand;)V",
- at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/OverlayTexture;DEFAULT_UV:I"))
+ @ModifyExpressionValue(method = "submitSkull(Lnet/minecraft/core/Direction;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;ILnet/minecraft/client/model/SkullModelBase;Lnet/minecraft/client/renderer/RenderType;ILnet/minecraft/client/renderer/feature/ModelFeatureRenderer$CrumblingOverlay;)V",
+ at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/texture/OverlayTexture;NO_OVERLAY:I"))
private static int replaceUvIndex(int original) {
if (EntityRenderTintEvent.overlayOverride != null)
- return OverlayTexture.packUv(15, 10); // TODO: store this info in a global alongside overlayOverride
+ return OverlayTexture.pack(15, 10); // TODO: store this info in a global alongside overlayOverride
return original;
}
diff --git a/src/main/java/moe/nea/firmament/mixins/render/renderer/MultipleSpecialGuiRenderStates.java b/src/main/java/moe/nea/firmament/mixins/render/renderer/MultipleSpecialGuiRenderStates.java
index cc79591..7c37684 100644
--- a/src/main/java/moe/nea/firmament/mixins/render/renderer/MultipleSpecialGuiRenderStates.java
+++ b/src/main/java/moe/nea/firmament/mixins/render/renderer/MultipleSpecialGuiRenderStates.java
@@ -9,10 +9,10 @@ import com.mojang.blaze3d.buffers.GpuBufferSlice;
import moe.nea.firmament.util.render.MultiSpecialGuiRenderState;
import moe.nea.firmament.util.render.MultiSpecialGuiRenderer;
import net.minecraft.client.gui.render.GuiRenderer;
-import net.minecraft.client.gui.render.SpecialGuiElementRenderer;
+import net.minecraft.client.gui.render.pip.PictureInPictureRenderer;
import net.minecraft.client.gui.render.state.GuiRenderState;
-import net.minecraft.client.gui.render.state.special.SpecialGuiElementRenderState;
-import net.minecraft.client.render.VertexConsumerProvider;
+import net.minecraft.client.gui.render.state.pip.PictureInPictureRenderState;
+import net.minecraft.client.renderer.MultiBufferSource;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -31,30 +31,30 @@ import java.util.Map;
public class MultipleSpecialGuiRenderStates {
@Shadow
@Final
- private VertexConsumerProvider.Immediate vertexConsumers;
+ private MultiBufferSource.BufferSource bufferSource;
@Shadow
@Final
- GuiRenderState state;
+ GuiRenderState renderState;
@Unique
Map<MultiSpecialGuiRenderState, MultiSpecialGuiRenderer<?>> multiRenderers = new HashMap<>();
- @Inject(method = "prepareSpecialElement", at = @At("HEAD"), cancellable = true)
- private <T extends SpecialGuiElementRenderState> void onPrepareElement(T elementState, int windowScaleFactor, CallbackInfo ci) {
+ @Inject(method = "preparePictureInPictureState", at = @At("HEAD"), cancellable = true)
+ private <T extends PictureInPictureRenderState> void onPrepareElement(T elementState, int windowScaleFactor, CallbackInfo ci) {
if (elementState instanceof MultiSpecialGuiRenderState multiState) {
@SuppressWarnings({"resource", "unchecked"})
- var renderer = (SpecialGuiElementRenderer<T>) multiRenderers
- .computeIfAbsent(multiState, elementState$ -> elementState$.createRenderer(this.vertexConsumers));
- renderer.render(elementState, state, windowScaleFactor);
+ var renderer = (PictureInPictureRenderer<T>) multiRenderers
+ .computeIfAbsent(multiState, elementState$ -> elementState$.createRenderer(this.bufferSource));
+ renderer.prepare(elementState, renderState, windowScaleFactor);
ci.cancel();
}
}
@Inject(method = "close", at = @At("TAIL"))
private void onClose(CallbackInfo ci) {
- multiRenderers.values().forEach(SpecialGuiElementRenderer::close);
+ multiRenderers.values().forEach(PictureInPictureRenderer::close);
}
- @Inject(method = "render(Lcom/mojang/blaze3d/buffers/GpuBufferSlice;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/render/GuiRenderer;clearOversizedItems()V"))
+ @Inject(method = "render(Lcom/mojang/blaze3d/buffers/GpuBufferSlice;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/render/GuiRenderer;clearUnusedOversizedItemRenderers()V"))
private void onAfterRender(GpuBufferSlice fogBuffer, CallbackInfo ci) {
multiRenderers.values().removeIf(it -> {
if (it.consumeRender()) {
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 4d22d71..29c7f15 100644
--- a/src/main/java/moe/nea/firmament/util/data/ManagedConfig.kt
+++ b/src/main/java/moe/nea/firmament/util/data/ManagedConfig.kt
@@ -32,9 +32,9 @@ import moe.nea.firmament.gui.config.StringHandler
import moe.nea.firmament.keybindings.SavedKeyBinding
import moe.nea.firmament.util.ScreenUtil
import moe.nea.firmament.util.collections.InstanceList
-import net.minecraft.client.gui.screen.Screen
-import net.minecraft.text.Text
-import net.minecraft.util.StringIdentifiable
+import net.minecraft.client.gui.screens.Screen
+import net.minecraft.network.chat.Component
+import net.minecraft.util.StringRepresentable
import org.joml.Vector2i
import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.jsonObject
@@ -63,8 +63,8 @@ abstract class ManagedConfig(
DEV,
;
- val labelText: Text = Text.translatable("firmament.config.category.${name.lowercase()}")
- val description: Text = Text.translatable("firmament.config.category.${name.lowercase()}.description")
+ val labelText: Component = Component.translatable("firmament.config.category.${name.lowercase()}")
+ val description: Component = Component.translatable("firmament.config.category.${name.lowercase()}.description")
val configs: MutableList<ManagedConfig> = mutableListOf()
}
@@ -152,19 +152,19 @@ abstract class ManagedConfig(
propertyName: String,
enumClass: Class<E>,
default: () -> E
- ): ManagedOption<E> where E : Enum<E>, E : StringIdentifiable {
+ ): ManagedOption<E> where E : Enum<E>, E : StringRepresentable {
return option(propertyName, default, ChoiceHandler(enumClass, enumClass.enumConstants.toList()))
}
protected inline fun <reified E> choice(
propertyName: String,
noinline default: () -> E
- ): ManagedOption<E> where E : Enum<E>, E : StringIdentifiable {
+ ): ManagedOption<E> where E : Enum<E>, E : StringRepresentable {
return choice(propertyName, E::class.java, default)
}
- private fun <E> createStringIdentifiable(x: () -> Array<out E>): Codec<E> where E : Enum<E>, E : StringIdentifiable {
- return StringIdentifiable.createCodec { x() }
+ private fun <E> createStringIdentifiable(x: () -> Array<out E>): Codec<E> where E : Enum<E>, E : StringRepresentable {
+ return StringRepresentable.fromEnum { x() }
}
// TODO: wait on https://youtrack.jetbrains.com/issue/KT-73434
@@ -199,7 +199,7 @@ abstract class ManagedConfig(
height: Int,
default: () -> Vector2i,
): ManagedOption<HudMeta> {
- val label = Text.translatable("firmament.config.${name}.${propertyName}")
+ val label = Component.translatable("firmament.config.${name}.${propertyName}")
return option(propertyName, {
val p = default()
HudMeta(HudPosition(p.x(), p.y(), 1F), Firmament.identifier(propertyName), label, width, height)
@@ -249,7 +249,7 @@ abstract class ManagedConfig(
}
val translationKey get() = "firmament.config.${name}"
- val labelText: Text = Text.translatable(translationKey)
+ val labelText: Component = Component.translatable(translationKey)
fun getConfigEditor(parent: Screen? = null): Screen {
var screen: Screen? = null
@@ -275,10 +275,10 @@ abstract class ManagedConfig(
PanelComponent.DefaultBackgroundRenderer.VANILLA
)
)
- screen = object : MoulConfigScreenComponent(Text.empty(), GuiContext(component), parent) {
- override fun close() {
+ screen = object : MoulConfigScreenComponent(Component.empty(), GuiContext(component), parent) {
+ override fun onClose() {
if (guiContext.onBeforeClose() == CloseEventListener.CloseAction.NO_OBJECTIONS_TO_CLOSE) {
- client!!.setScreen(parent)
+ minecraft!!.setScreen(parent)
}
}
}
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<FabricClientCommandSource>,
@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 <reified T : Any> tryDecodeJsonFromStream(inputStream: InputStream): Result<T> {
return runCatching {
json.decodeFromStream<T>(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<FabricClientCommandSource>, ctx: CommandRegistryAccess) {
+fun registerFirmamentCommand(dispatcher: CommandDispatcher<FabricClientCommandSource>, 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<AllowChatEvent>()
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<DefaultSource>,
- val ctx: CommandRegistryAccess,
+ val ctx: CommandBuildContext,
val serverCommands: CommandDispatcher<*>?,
) : FirmamentEvent() {
companion object : FirmamentEventBus<CommandEvent>()
@@ -23,7 +23,7 @@ data class CommandEvent(
*/
data class SubCommand(
val builder: CaseInsensitiveLiteralCommandNode.Builder<DefaultSource>,
- val commandRegistryAccess: CommandRegistryAccess,
+ val commandRegistryAccess: CommandBuildContext,
) : FirmamentEvent() {
companion object : FirmamentEventBus<SubCommand>()
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<CustomItemModelEvent>() {
val weakCache =
- object : WeakCache<ItemStack, IntrospectableItemModelManager, Optional<Identifier>>("ItemModelIdentifier") {
+ object : WeakCache<ItemStack, IntrospectableItemModelManager, Optional<ResourceLocation>>("ItemModelIdentifier") {
override fun mkRef(
- key: ItemStack,
- extraData: IntrospectableItemModelManager
- ): WeakCache<ItemStack, IntrospectableItemModelManager, Optional<Identifier>>.Ref {
+ key: ItemStack,
+ extraData: IntrospectableItemModelManager
+ ): WeakCache<ItemStack, IntrospectableItemModelManager, Optional<ResourceLocation>>.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<Identifier> {
+ itemStack: ItemStack,
+ itemModelManager: IntrospectableItemModelManager
+ ): Optional<ResourceLocation> {
// 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<EntityInteractionEvent>()
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<EntityAttributesS2CPacket.Entry>,
+ override val entity: LivingEntity,
+ val attributes: List<ClientboundUpdateAttributesPacket.AttributeSnapshot>,
) : EntityUpdateEvent()
data class TrackedDataUpdate(
- override val entity: Entity,
- val trackedValues: List<DataTracker.SerializedEntry<*>>,
+ override val entity: Entity,
+ val trackedValues: List<SynchedEntityData.DataValue<*>>,
) : EntityUpdateEvent()
data class EquipmentUpdate(
- override val entity: Entity,
- val newEquipment: List<Pair<EquipmentSlot, ItemStack>>,
+ override val entity: Entity,
+ val newEquipment: List<Pair<EquipmentSlot, ItemStack>>,
) : 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<FinalizeResourceManagerEvent>()
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<Void> {
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<HandledScreenClickEvent>()
}
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<Rectangle> = 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<HotbarItemRenderEvent>()
}
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<Text>
+ val stack: ItemStack, val context: TooltipContext, val type: TooltipFlag, val lines: MutableList<Component>
) : FirmamentEvent() {
companion object : FirmamentEventBus<ItemTooltipEvent>()
}
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<JoinServerEvent>()
}
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<OutgoingPacketEvent>()
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<PlayerInventoryUpdate>()
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<ScreenRenderPostEvent>()
}
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<ServerConnectedEvent>() {
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<SlotClickEvent>()
}
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<Before>()
}
data class After(
- override val context: DrawContext, override val slot: Slot,
+ override val context: GuiGraphics, override val slot: Slot,
) : FirmamentEvent(),
SlotRenderEvents {
companion object : FirmamentEventBus<After>()
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.sound.SoundEvent
-import net.minecraft.util.math.Vec3d
+import net.minecraft.core.Holder
+import net.minecraft.sounds.SoundSource
+import net.minecraft.sounds.SoundEvent
+import net.minecraft.world.phys.Vec3
data class SoundReceiveEvent(
- val sound: RegistryEntry<SoundEvent>,
- val category: SoundCategory,
- val position: Vec3d,
+ val sound: Holder<SoundEvent>,
+ val category: SoundSource,
+ val position: Vec3,
val pitch: Float,
val volume: Float,
val seed: Long
diff --git a/src/main/kotlin/events/UseBlockEvent.kt b/src/main/kotlin/events/UseBlockEvent.kt
index 8bbe0de..f229931 100644
--- a/src/main/kotlin/events/UseBlockEvent.kt
+++ b/src/main/kotlin/events/UseBlockEvent.kt
@@ -1,11 +1,11 @@
package moe.nea.firmament.events
-import net.minecraft.entity.player.PlayerEntity
-import net.minecraft.util.Hand
-import net.minecraft.util.hit.BlockHitResult
-import net.minecraft.world.World
+import net.minecraft.world.entity.player.Player
+import net.minecraft.world.InteractionHand
+import net.minecraft.world.phys.BlockHitResult
+import net.minecraft.world.level.Level
-data class UseBlockEvent(val player: PlayerEntity, val world: World, val hand: Hand, val hitResult: BlockHitResult) : FirmamentEvent.Cancellable() {
+data class UseBlockEvent(val player: Player, val world: Level, val hand: InteractionHand, val hitResult: BlockHitResult) : FirmamentEvent.Cancellable() {
companion object : FirmamentEventBus<UseBlockEvent>()
}
diff --git a/src/main/kotlin/events/UseItemEvent.kt b/src/main/kotlin/events/UseItemEvent.kt
index e294bb1..5174a51 100644
--- a/src/main/kotlin/events/UseItemEvent.kt
+++ b/src/main/kotlin/events/UseItemEvent.kt
@@ -1,11 +1,11 @@
package moe.nea.firmament.events
-import net.minecraft.entity.player.PlayerEntity
-import net.minecraft.item.ItemStack
-import net.minecraft.util.Hand
-import net.minecraft.world.World
+import net.minecraft.world.entity.player.Player
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.InteractionHand
+import net.minecraft.world.level.Level
-data class UseItemEvent(val playerEntity: PlayerEntity, val world: World, val hand: Hand) : FirmamentEvent.Cancellable() {
+data class UseItemEvent(val playerEntity: Player, val world: Level, val hand: InteractionHand) : FirmamentEvent.Cancellable() {
companion object : FirmamentEventBus<UseItemEvent>()
- val item: ItemStack = playerEntity.getStackInHand(hand)
+ val item: ItemStack = playerEntity.getItemInHand(hand)
}
diff --git a/src/main/kotlin/events/WorldRenderLastEvent.kt b/src/main/kotlin/events/WorldRenderLastEvent.kt
index e9d44fe..394a674 100644
--- a/src/main/kotlin/events/WorldRenderLastEvent.kt
+++ b/src/main/kotlin/events/WorldRenderLastEvent.kt
@@ -2,20 +2,20 @@
package moe.nea.firmament.events
-import net.minecraft.client.render.Camera
-import net.minecraft.client.render.RenderTickCounter
-import net.minecraft.client.render.VertexConsumerProvider
-import net.minecraft.client.render.state.CameraRenderState
-import net.minecraft.client.util.math.MatrixStack
+import net.minecraft.client.Camera
+import net.minecraft.client.DeltaTracker
+import net.minecraft.client.renderer.MultiBufferSource
+import net.minecraft.client.renderer.state.CameraRenderState
+import com.mojang.blaze3d.vertex.PoseStack
/**
* This event is called after all world rendering is done, but before any GUI rendering (including hand) has been done.
*/
data class WorldRenderLastEvent(
- val matrices: MatrixStack,
+ val matrices: PoseStack,
val tickCounter: Int,
val camera: CameraRenderState,
- val vertexConsumers: VertexConsumerProvider.Immediate,
+ val vertexConsumers: MultiBufferSource.BufferSource,
) : FirmamentEvent() {
companion object : FirmamentEventBus<WorldRenderLastEvent>()
}
diff --git a/src/main/kotlin/events/registration/ChatEvents.kt b/src/main/kotlin/events/registration/ChatEvents.kt
index 7fe040a..93a0f1a 100644
--- a/src/main/kotlin/events/registration/ChatEvents.kt
+++ b/src/main/kotlin/events/registration/ChatEvents.kt
@@ -5,8 +5,8 @@ import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents
import net.fabricmc.fabric.api.event.player.AttackBlockCallback
import net.fabricmc.fabric.api.event.player.UseBlockCallback
import net.fabricmc.fabric.api.event.player.UseItemCallback
-import net.minecraft.text.Text
-import net.minecraft.util.ActionResult
+import net.minecraft.network.chat.Component
+import net.minecraft.world.InteractionResult
import moe.nea.firmament.events.AllowChatEvent
import moe.nea.firmament.events.AttackBlockEvent
import moe.nea.firmament.events.JoinServerEvent
@@ -15,7 +15,7 @@ import moe.nea.firmament.events.ProcessChatEvent
import moe.nea.firmament.events.UseBlockEvent
import moe.nea.firmament.events.UseItemEvent
-private var lastReceivedMessage: Text? = null
+private var lastReceivedMessage: Component? = null
fun registerFirmamentEvents() {
ClientReceiveMessageEvents.ALLOW_CHAT.register(ClientReceiveMessageEvents.AllowChat { message, signedMessage, sender, params, receptionTimestamp ->
@@ -45,22 +45,22 @@ fun registerFirmamentEvents() {
AttackBlockCallback.EVENT.register(AttackBlockCallback { player, world, hand, pos, direction ->
if (AttackBlockEvent.publish(AttackBlockEvent(player, world, hand, pos, direction)).cancelled)
- ActionResult.FAIL
- else ActionResult.PASS
+ InteractionResult.FAIL
+ else InteractionResult.PASS
})
UseBlockCallback.EVENT.register(UseBlockCallback { player, world, hand, hitResult ->
if (UseBlockEvent.publish(UseBlockEvent(player, world, hand, hitResult)).cancelled)
- ActionResult.FAIL
- else ActionResult.PASS
+ InteractionResult.FAIL
+ else InteractionResult.PASS
})
UseBlockCallback.EVENT.register(UseBlockCallback { player, world, hand, hitResult ->
if (UseItemEvent.publish(UseItemEvent(player, world, hand)).cancelled)
- ActionResult.FAIL
- else ActionResult.PASS
+ InteractionResult.FAIL
+ else InteractionResult.PASS
})
UseItemCallback.EVENT.register(UseItemCallback { playerEntity, world, hand ->
- if (UseItemEvent.publish(UseItemEvent(playerEntity, world, hand)).cancelled) ActionResult.FAIL
- else ActionResult.PASS
+ if (UseItemEvent.publish(UseItemEvent(playerEntity, world, hand)).cancelled) InteractionResult.FAIL
+ else InteractionResult.PASS
})
ClientPlayConnectionEvents.JOIN.register { networkHandler, packetSender, _ ->
JoinServerEvent.publish(JoinServerEvent(networkHandler, packetSender))
diff --git a/src/main/kotlin/features/chat/AutoCompletions.kt b/src/main/kotlin/features/chat/AutoCompletions.kt
index c9fd133..f13fe7e 100644
--- a/src/main/kotlin/features/chat/AutoCompletions.kt
+++ b/src/main/kotlin/features/chat/AutoCompletions.kt
@@ -9,7 +9,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType
import kotlin.concurrent.thread
import net.minecraft.SharedConstants
-import net.minecraft.command.TranslatableBuiltInExceptions
+import net.minecraft.commands.BrigadierExceptions
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.get
import moe.nea.firmament.commands.suggestsList
diff --git a/src/main/kotlin/features/chat/ChatLinks.kt b/src/main/kotlin/features/chat/ChatLinks.kt
index 76eb48d..aca7af8 100644
--- a/src/main/kotlin/features/chat/ChatLinks.kt
+++ b/src/main/kotlin/features/chat/ChatLinks.kt
@@ -9,15 +9,15 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.async
import kotlinx.coroutines.future.await
import kotlin.math.min
-import net.minecraft.client.gui.screen.ChatScreen
-import net.minecraft.client.texture.NativeImage
-import net.minecraft.client.texture.NativeImageBackedTexture
-import net.minecraft.text.ClickEvent
-import net.minecraft.text.HoverEvent
-import net.minecraft.text.Style
-import net.minecraft.text.Text
-import net.minecraft.util.Formatting
-import net.minecraft.util.Identifier
+import net.minecraft.client.gui.screens.ChatScreen
+import com.mojang.blaze3d.platform.NativeImage
+import net.minecraft.client.renderer.texture.DynamicTexture
+import net.minecraft.network.chat.ClickEvent
+import net.minecraft.network.chat.HoverEvent
+import net.minecraft.network.chat.Style
+import net.minecraft.network.chat.Component
+import net.minecraft.ChatFormatting
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ModifyChatEvent
@@ -54,7 +54,7 @@ object ChatLinks {
val nextTexId = AtomicInteger(0)
data class Image(
- val texture: Identifier,
+ val texture: ResourceLocation,
val width: Int,
val height: Int,
)
@@ -76,9 +76,9 @@ object ChatLinks {
.await()
val image = NativeImage.read(inputStream)
val texId = Firmament.identifier("dynamic_image_preview${nextTexId.getAndIncrement()}")
- MC.textureManager.registerTexture(
+ MC.textureManager.register(
texId,
- NativeImageBackedTexture({ texId.path }, image)
+ DynamicTexture({ texId.path }, image)
)
Image(texId, image.width, image.height)
} catch (exc: Exception) {
@@ -99,7 +99,7 @@ object ChatLinks {
if (!TConfig.imageEnabled) return
if (it.screen !is ChatScreen) return
val hoveredComponent =
- MC.inGameHud.chatHud.getTextStyleAt(it.mouseX.toDouble(), it.mouseY.toDouble()) ?: return
+ MC.inGameHud.chat.getClickedComponentStyleAt(it.mouseX.toDouble(), it.mouseY.toDouble()) ?: return
val hoverEvent = hoveredComponent.hoverEvent as? HoverEvent.ShowText ?: return
val value = hoverEvent.value
val url = urlRegex.matchEntire(value.unformattedString)?.groupValues?.get(0) ?: return
@@ -107,11 +107,11 @@ object ChatLinks {
val imageFuture = imageCache[url] ?: return
if (!imageFuture.isCompleted) return
val image = imageFuture.getCompleted() ?: return
- it.drawContext.matrices.pushMatrix()
+ it.drawContext.pose().pushMatrix()
val pos = TConfig.position
- pos.applyTransformations(JarvisIntegration.jarvis, it.drawContext.matrices)
+ pos.applyTransformations(JarvisIntegration.jarvis, it.drawContext.pose())
val scale = min(1F, min((9 * 20F) / image.height, (16 * 20F) / image.width))
- it.drawContext.matrices.scale(scale, scale)
+ it.drawContext.pose().scale(scale, scale)
it.drawContext.drawTexture(
image.texture,
0,
@@ -123,7 +123,7 @@ object ChatLinks {
image.width,
image.height,
)
- it.drawContext.matrices.popMatrix()
+ it.drawContext.pose().popMatrix()
}
@Subscribe
@@ -132,23 +132,23 @@ object ChatLinks {
it.replaceWith = it.replaceWith.transformEachRecursively { child ->
val text = child.string
if ("://" !in text) return@transformEachRecursively child
- val s = Text.empty().setStyle(child.style)
+ val s = Component.empty().setStyle(child.style)
var index = 0
while (index < text.length) {
val nextMatch = urlRegex.find(text, index)
val url = nextMatch?.groupValues[0]
val uri = runCatching { url?.let(::URI) }.getOrNull()
if (nextMatch == null || url == null || uri == null) {
- s.append(Text.literal(text.substring(index, text.length)))
+ s.append(Component.literal(text.substring(index, text.length)))
break
}
val range = nextMatch.groups[0]!!.range
- s.append(Text.literal(text.substring(index, range.first)))
+ s.append(Component.literal(text.substring(index, range.first)))
s.append(
- Text.literal(url).setStyle(
- Style.EMPTY.withUnderline(true).withColor(
- Formatting.AQUA
- ).withHoverEvent(HoverEvent.ShowText(Text.literal(url)))
+ Component.literal(url).setStyle(
+ Style.EMPTY.withUnderlined(true).withColor(
+ ChatFormatting.AQUA
+ ).withHoverEvent(HoverEvent.ShowText(Component.literal(url)))
.withClickEvent(ClickEvent.OpenUrl(uri))
)
)
diff --git a/src/main/kotlin/features/chat/CopyChat.kt b/src/main/kotlin/features/chat/CopyChat.kt
index 5c46465..6bef99f 100644
--- a/src/main/kotlin/features/chat/CopyChat.kt
+++ b/src/main/kotlin/features/chat/CopyChat.kt
@@ -1,6 +1,6 @@
package moe.nea.firmament.features.chat
-import net.minecraft.text.OrderedText
+import net.minecraft.util.FormattedCharSequence
import moe.nea.firmament.util.data.Config
import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.reconstitute
@@ -15,7 +15,7 @@ object CopyChat {
val copyChat by toggle("copy-chat") { false }
}
- fun orderedTextToString(orderedText: OrderedText): String {
+ fun orderedTextToString(orderedText: FormattedCharSequence): String {
return orderedText.reconstitute().string
}
}
diff --git a/src/main/kotlin/features/chat/PartyCommands.kt b/src/main/kotlin/features/chat/PartyCommands.kt
index 1b34946..85daf51 100644
--- a/src/main/kotlin/features/chat/PartyCommands.kt
+++ b/src/main/kotlin/features/chat/PartyCommands.kt
@@ -5,7 +5,7 @@ import com.mojang.brigadier.StringReader
import com.mojang.brigadier.exceptions.CommandSyntaxException
import com.mojang.brigadier.tree.LiteralCommandNode
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.util.math.BlockPos
+import net.minecraft.core.BlockPos
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.CaseInsensitiveLiteralCommandNode
import moe.nea.firmament.commands.thenExecute
@@ -80,7 +80,7 @@ object PartyCommands {
register("coords") {
executes {
- val p = MC.player?.blockPos ?: BlockPos.ORIGIN
+ val p = MC.player?.blockPosition() ?: BlockPos.ZERO
MC.sendCommand("pc x: ${p.x}, y: ${p.y}, z: ${p.z}")
0
}
diff --git a/src/main/kotlin/features/chat/QuickCommands.kt b/src/main/kotlin/features/chat/QuickCommands.kt
index 5221205..b857f8a 100644
--- a/src/main/kotlin/features/chat/QuickCommands.kt
+++ b/src/main/kotlin/features/chat/QuickCommands.kt
@@ -5,9 +5,9 @@ import com.mojang.brigadier.context.CommandContext
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
import net.fabricmc.fabric.impl.command.client.ClientCommandInternals
-import net.minecraft.command.CommandRegistryAccess
-import net.minecraft.network.packet.s2c.play.CommandTreeS2CPacket
-import net.minecraft.text.Text
+import net.minecraft.commands.CommandBuildContext
+import net.minecraft.network.protocol.game.ClientboundCommandsPacket
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.DefaultSource
import moe.nea.firmament.commands.RestArgumentType
@@ -45,13 +45,13 @@ object QuickCommands {
ClientCommandInternals.setActiveDispatcher(dispatcher)
ClientCommandRegistrationCallback.EVENT.invoker()
.register(
- dispatcher, CommandRegistryAccess.of(
- network.combinedDynamicRegistries,
- network.enabledFeatures
+ dispatcher, CommandBuildContext.simple(
+ network.registryAccess,
+ network.enabledFeatures()
)
)
ClientCommandInternals.finalizeInit()
- network.onCommandTree(lastPacket)
+ network.handleCommands(lastPacket)
} catch (ex: Exception) {
ClientCommandInternals.setActiveDispatcher(fallback)
throw ex
@@ -69,7 +69,7 @@ object QuickCommands {
return lf
}
- var lastReceivedTreePacket: CommandTreeS2CPacket? = null
+ var lastReceivedTreePacket: ClientboundCommandsPacket? = null
val kuudraLevelNames = listOf("NORMAL", "HOT", "BURNING", "FIERY", "INFERNAL")
val dungeonLevelNames = listOf("ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN")
@@ -103,10 +103,10 @@ object QuickCommands {
}
val joinName = getNameForFloor(what.replace(" ", "").lowercase())
if (joinName == null) {
- source.sendFeedback(Text.stringifiedTranslatable("firmament.quick-commands.join.unknown", what))
+ source.sendFeedback(Component.translatableEscape("firmament.quick-commands.join.unknown", what))
} else {
source.sendFeedback(
- Text.stringifiedTranslatable(
+ Component.translatableEscape(
"firmament.quick-commands.join.success",
joinName
)
@@ -116,7 +116,7 @@ object QuickCommands {
}
}
thenExecute {
- source.sendFeedback(Text.translatable("firmament.quick-commands.join.explain"))
+ source.sendFeedback(Component.translatable("firmament.quick-commands.join.explain"))
}
}
}
@@ -132,7 +132,7 @@ object QuickCommands {
}
if (l !in kuudraLevelNames.indices) {
source.sendFeedback(
- Text.stringifiedTranslatable(
+ Component.translatableEscape(
"firmament.quick-commands.join.unknown-kuudra",
kuudraLevel
)
@@ -157,7 +157,7 @@ object QuickCommands {
}
if (l !in dungeonLevelNames.indices) {
source.sendFeedback(
- Text.stringifiedTranslatable(
+ Component.translatableEscape(
"firmament.quick-commands.join.unknown-catacombs",
kuudraLevel
)
diff --git a/src/main/kotlin/features/debug/AnimatedClothingScanner.kt b/src/main/kotlin/features/debug/AnimatedClothingScanner.kt
index 4edccfb..dc77115 100644
--- a/src/main/kotlin/features/debug/AnimatedClothingScanner.kt
+++ b/src/main/kotlin/features/debug/AnimatedClothingScanner.kt
@@ -1,13 +1,13 @@
package moe.nea.firmament.features.debug
-import net.minecraft.command.argument.RegistryKeyArgumentType
-import net.minecraft.component.ComponentType
-import net.minecraft.entity.Entity
-import net.minecraft.entity.decoration.ArmorStandEntity
-import net.minecraft.item.ItemStack
-import net.minecraft.nbt.NbtElement
+import net.minecraft.commands.arguments.ResourceKeyArgument
+import net.minecraft.core.component.DataComponentType
+import net.minecraft.world.entity.Entity
+import net.minecraft.world.entity.decoration.ArmorStand
+import net.minecraft.world.item.ItemStack
+import net.minecraft.nbt.Tag
import net.minecraft.nbt.NbtOps
-import net.minecraft.registry.RegistryKeys
+import net.minecraft.core.registries.Registries
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.get
import moe.nea.firmament.commands.thenArgument
@@ -27,11 +27,11 @@ object AnimatedClothingScanner {
data class LensOfFashionTheft<T>(
val prism: NbtPrism,
- val component: ComponentType<T>,
+ val component: DataComponentType<T>,
) {
- fun observe(itemStack: ItemStack): Collection<NbtElement> {
+ fun observe(itemStack: ItemStack): Collection<Tag> {
val x = itemStack.get(component) ?: return listOf()
- val nbt = component.codecOrThrow.encodeStart(NbtOps.INSTANCE, x).orThrow
+ val nbt = component.codecOrThrow().encodeStart(NbtOps.INSTANCE, x).orThrow
return prism.access(nbt)
}
}
@@ -115,16 +115,16 @@ object AnimatedClothingScanner {
)
)
val p = MC.player!!
- val nearestPet = p.world.getEntitiesByClass(
- ArmorStandEntity::class.java,
- p.boundingBox.expand(10.0),
+ val nearestPet = p.level.getEntitiesOfClass(
+ ArmorStand::class.java,
+ p.boundingBox.inflate(10.0),
{ it.isMarker })
- .minBy { it.squaredDistanceTo(p) }
+ .minBy { it.distanceToSqr(p) }
toggleObserve(nearestPet)
}
}
thenExecute {
- val ent = MC.instance.targetedEntity
+ val ent = MC.instance.crosshairPickEntity
if (ent == null) {
source.sendFeedback(
tr(
@@ -140,7 +140,7 @@ object AnimatedClothingScanner {
thenLiteral("path") {
thenArgument(
"component",
- RegistryKeyArgumentType.registryKey(RegistryKeys.DATA_COMPONENT_TYPE)
+ ResourceKeyArgument.key(Registries.DATA_COMPONENT_TYPE)
) { component ->
thenArgument("path", NbtPrism.Argument) { path ->
thenExecute {
@@ -151,7 +151,7 @@ object AnimatedClothingScanner {
source.sendFeedback(
tr(
"firmament.fitstealer.lensset",
- "Analyzing path ${get(path)} for component ${get(component).value}"
+ "Analyzing path ${get(path)} for component ${get(component).location()}"
)
)
}
diff --git a/src/main/kotlin/features/debug/DebugLogger.kt b/src/main/kotlin/features/debug/DebugLogger.kt
index 52f6143..2c8ced0 100644
--- a/src/main/kotlin/features/debug/DebugLogger.kt
+++ b/src/main/kotlin/features/debug/DebugLogger.kt
@@ -1,7 +1,7 @@
package moe.nea.firmament.features.debug
import kotlinx.serialization.serializer
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.TestUtil
import moe.nea.firmament.util.collections.InstanceList
@@ -24,6 +24,6 @@ class DebugLogger(val tag: String) {
fun log(text: String) = log { text }
fun log(text: () -> String) {
if (!isEnabled()) return
- MC.sendChat(Text.literal(text()))
+ MC.sendChat(Component.literal(text()))
}
}
diff --git a/src/main/kotlin/features/debug/DeveloperFeatures.kt b/src/main/kotlin/features/debug/DeveloperFeatures.kt
index e86c6ad..8638bb6 100644
--- a/src/main/kotlin/features/debug/DeveloperFeatures.kt
+++ b/src/main/kotlin/features/debug/DeveloperFeatures.kt
@@ -10,8 +10,8 @@ import org.spongepowered.asm.mixin.Mixin
import kotlinx.serialization.json.encodeToStream
import kotlin.io.path.absolute
import kotlin.io.path.exists
-import net.minecraft.client.MinecraftClient
-import net.minecraft.text.Text
+import net.minecraft.client.Minecraft
+import net.minecraft.network.chat.Component
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.DebugInstantiateEvent
@@ -92,17 +92,17 @@ object DeveloperFeatures {
}
@JvmStatic
- fun hookOnBeforeResourceReload(client: MinecraftClient): CompletableFuture<Void> {
+ fun hookOnBeforeResourceReload(client: Minecraft): CompletableFuture<Void> {
val reloadFuture = if (TConfig.autoRebuildResources && Firmament.DEBUG && gradleDir != null) {
val builder = ProcessBuilder("./gradlew", ":processResources")
builder.directory(gradleDir.toFile())
builder.inheritIO()
val process = builder.start()
- MC.sendChat(Text.translatable("firmament.dev.resourcerebuild.start"))
+ MC.sendChat(Component.translatable("firmament.dev.resourcerebuild.start"))
val startTime = TimeMark.now()
process.toHandle().onExit().thenApply {
MC.sendChat(
- Text.stringifiedTranslatable(
+ Component.translatableEscape(
"firmament.dev.resourcerebuild.done",
startTime.passedTime()
)
@@ -112,7 +112,7 @@ object DeveloperFeatures {
} else {
CompletableFuture.completedFuture(Unit)
}
- return reloadFuture.thenCompose { client.reloadResources() }
+ return reloadFuture.thenCompose { client.reloadResourcePacks() }
}
}
diff --git a/src/main/kotlin/features/debug/ExportedTestConstantMeta.kt b/src/main/kotlin/features/debug/ExportedTestConstantMeta.kt
index bdc1f9a..a2b42fd 100644
--- a/src/main/kotlin/features/debug/ExportedTestConstantMeta.kt
+++ b/src/main/kotlin/features/debug/ExportedTestConstantMeta.kt
@@ -12,7 +12,7 @@ data class ExportedTestConstantMeta(
) {
companion object {
val current = ExportedTestConstantMeta(
- SharedConstants.getGameVersion().dataVersion().id,
+ SharedConstants.getCurrentVersion().dataVersion().version,
Optional.of("Firmament ${Firmament.version.friendlyString}")
)
diff --git a/src/main/kotlin/features/debug/MinorTrolling.kt b/src/main/kotlin/features/debug/MinorTrolling.kt
index d802d40..7936521 100644
--- a/src/main/kotlin/features/debug/MinorTrolling.kt
+++ b/src/main/kotlin/features/debug/MinorTrolling.kt
@@ -2,7 +2,7 @@
package moe.nea.firmament.features.debug
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ModifyChatEvent
@@ -20,6 +20,6 @@ object MinorTrolling {
val (_, name, text) = m.groupValues
if (name !in trollers) return
if (!text.startsWith("c:")) return
- it.replaceWith = Text.literal(text.substring(2).replace("&", "§"))
+ it.replaceWith = Component.literal(text.substring(2).replace("&", "§"))
}
}
diff --git a/src/main/kotlin/features/debug/PowerUserTools.kt b/src/main/kotlin/features/debug/PowerUserTools.kt
index fc36806..1a14f73 100644
--- a/src/main/kotlin/features/debug/PowerUserTools.kt
+++ b/src/main/kotlin/features/debug/PowerUserTools.kt
@@ -2,24 +2,24 @@ package moe.nea.firmament.features.debug
import com.mojang.serialization.JsonOps
import kotlin.jvm.optionals.getOrNull
-import net.minecraft.block.SkullBlock
-import net.minecraft.block.entity.SkullBlockEntity
-import net.minecraft.component.DataComponentTypes
-import net.minecraft.component.type.ProfileComponent
-import net.minecraft.entity.Entity
-import net.minecraft.entity.LivingEntity
-import net.minecraft.item.ItemStack
-import net.minecraft.item.Items
-import net.minecraft.nbt.NbtList
+import net.minecraft.world.level.block.SkullBlock
+import net.minecraft.world.level.block.entity.SkullBlockEntity
+import net.minecraft.core.component.DataComponents
+import net.minecraft.world.item.component.ResolvableProfile
+import net.minecraft.world.entity.Entity
+import net.minecraft.world.entity.LivingEntity
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.item.Items
+import net.minecraft.nbt.ListTag
import net.minecraft.nbt.NbtOps
-import net.minecraft.predicate.NbtPredicate
-import net.minecraft.text.Text
-import net.minecraft.text.TextCodecs
-import net.minecraft.util.Identifier
-import net.minecraft.util.Nameable
-import net.minecraft.util.hit.BlockHitResult
-import net.minecraft.util.hit.EntityHitResult
-import net.minecraft.util.hit.HitResult
+import net.minecraft.advancements.critereon.NbtPredicate
+import net.minecraft.network.chat.Component
+import net.minecraft.network.chat.ComponentSerialization
+import net.minecraft.resources.ResourceLocation
+import net.minecraft.world.Nameable
+import net.minecraft.world.phys.BlockHitResult
+import net.minecraft.world.phys.EntityHitResult
+import net.minecraft.world.phys.HitResult
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.CustomItemModelEvent
import moe.nea.firmament.events.HandledScreenKeyPressedEvent
@@ -69,7 +69,7 @@ object PowerUserTools {
val autoCopyAnimatedSkins by toggle("copy-animated-skins") { false }
}
- var lastCopiedStack: Pair<ItemStack, Text>? = null
+ var lastCopiedStack: Pair<ItemStack, Component>? = null
set(value) {
field = value
if (value != null) lastCopiedStackViewTime = 2
@@ -86,20 +86,20 @@ object PowerUserTools {
lastCopiedStack = null
}
- fun debugFormat(itemStack: ItemStack): Text {
- return Text.literal(itemStack.skyBlockId?.toString() ?: itemStack.toString())
+ fun debugFormat(itemStack: ItemStack): Component {
+ return Component.literal(itemStack.skyBlockId?.toString() ?: itemStack.toString())
}
@Subscribe
fun onRender(event: SlotRenderEvents.After) {
if (TConfig.showSlotNumbers.isPressed()) {
- event.context.drawText(
+ event.context.drawString(
MC.font,
- event.slot.id.toString(), event.slot.x, event.slot.y, 0xFF00FF00.toInt(), true
+ event.slot.index.toString(), event.slot.x, event.slot.y, 0xFF00FF00.toInt(), true
)
- event.context.drawText(
+ event.context.drawString(
MC.font,
- event.slot.index.toString(), event.slot.x, event.slot.y + MC.font.fontHeight, 0xFFFF0000.toInt(), true
+ event.slot.containerSlot.toString(), event.slot.x, event.slot.y + MC.font.lineHeight, 0xFFFF0000.toInt(), true
)
}
}
@@ -107,37 +107,37 @@ object PowerUserTools {
@Subscribe
fun onEntityInfo(event: WorldKeyboardEvent) {
if (!event.matches(TConfig.copyEntityData)) return
- val target = (MC.instance.crosshairTarget as? EntityHitResult)?.entity
+ val target = (MC.instance.hitResult as? EntityHitResult)?.entity
if (target == null) {
- MC.sendChat(Text.translatable("firmament.poweruser.entity.fail"))
+ MC.sendChat(Component.translatable("firmament.poweruser.entity.fail"))
return
}
showEntity(target)
}
fun showEntity(target: Entity) {
- val nbt = NbtPredicate.entityToNbt(target)
+ val nbt = NbtPredicate.getEntityTagToCompare(target)
nbt.remove("Inventory")
- nbt.put("StyledName", TextCodecs.CODEC.encodeStart(NbtOps.INSTANCE, target.styledDisplayName).orThrow)
+ nbt.put("StyledName", ComponentSerialization.CODEC.encodeStart(NbtOps.INSTANCE, target.feedbackDisplayName).orThrow)
println(SNbtFormatter.prettify(nbt))
ClipboardUtils.setTextContent(SNbtFormatter.prettify(nbt))
- MC.sendChat(Text.translatable("firmament.poweruser.entity.type", target.type))
- MC.sendChat(Text.translatable("firmament.poweruser.entity.name", target.name))
- MC.sendChat(Text.stringifiedTranslatable("firmament.poweruser.entity.position", target.pos))
+ MC.sendChat(Component.translatable("firmament.poweruser.entity.type", target.type))
+ MC.sendChat(Component.translatable("firmament.poweruser.entity.name", target.name))
+ MC.sendChat(Component.translatableEscape("firmament.poweruser.entity.position", target.position))
if (target is LivingEntity) {
- MC.sendChat(Text.translatable("firmament.poweruser.entity.armor"))
+ MC.sendChat(Component.translatable("firmament.poweruser.entity.armor"))
for ((slot, armorItem) in target.iterableArmorItems) {
- MC.sendChat(Text.translatable("firmament.poweruser.entity.armor.item", debugFormat(armorItem)))
+ MC.sendChat(Component.translatable("firmament.poweruser.entity.armor.item", debugFormat(armorItem)))
}
}
- MC.sendChat(Text.stringifiedTranslatable("firmament.poweruser.entity.passengers", target.passengerList.size))
- target.passengerList.forEach {
+ MC.sendChat(Component.translatableEscape("firmament.poweruser.entity.passengers", target.passengers.size))
+ target.passengers.forEach {
showEntity(it)
}
}
// TODO: leak this through some other way, maybe.
- lateinit var getSkullId: (profile: ProfileComponent) -> Identifier?
+ lateinit var getSkullId: (profile: ResolvableProfile) -> ResourceLocation?
@Subscribe
fun copyInventoryInfo(it: HandledScreenKeyPressedEvent) {
@@ -146,71 +146,71 @@ object PowerUserTools {
if (it.matches(TConfig.copyItemId)) {
val sbId = item.skyBlockId
if (sbId == null) {
- lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.skyblockid.fail"))
+ lastCopiedStack = Pair(item, Component.translatable("firmament.tooltip.copied.skyblockid.fail"))
return
}
ClipboardUtils.setTextContent(sbId.neuItem)
lastCopiedStack =
- Pair(item, Text.stringifiedTranslatable("firmament.tooltip.copied.skyblockid", sbId.neuItem))
+ Pair(item, Component.translatableEscape("firmament.tooltip.copied.skyblockid", sbId.neuItem))
} else if (it.matches(TConfig.copyTexturePackId)) {
val model = CustomItemModelEvent.getModelIdentifier0(item, object : IntrospectableItemModelManager {
- override fun hasModel_firmament(identifier: Identifier): Boolean {
+ override fun hasModel_firmament(identifier: ResourceLocation): Boolean {
return true
}
}).getOrNull() // TODO: remove global texture overrides, maybe
if (model == null) {
- lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.modelid.fail"))
+ lastCopiedStack = Pair(item, Component.translatable("firmament.tooltip.copied.modelid.fail"))
return
}
ClipboardUtils.setTextContent(model.toString())
lastCopiedStack =
- Pair(item, Text.stringifiedTranslatable("firmament.tooltip.copied.modelid", model.toString()))
+ Pair(item, Component.translatableEscape("firmament.tooltip.copied.modelid", model.toString()))
} else if (it.matches(TConfig.copyNbtData)) {
// TODO: copy full nbt
- val nbt = item.get(DataComponentTypes.CUSTOM_DATA)?.unsafeNbt?.toPrettyString() ?: "<empty>"
+ val nbt = item.get(DataComponents.CUSTOM_DATA)?.unsafeNbt?.toPrettyString() ?: "<empty>"
ClipboardUtils.setTextContent(nbt)
- lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.nbt"))
+ lastCopiedStack = Pair(item, Component.translatable("firmament.tooltip.copied.nbt"))
} else if (it.matches(TConfig.copyLoreData)) {
val list = mutableListOf(item.displayNameAccordingToNbt)
list.addAll(item.loreAccordingToNbt)
ClipboardUtils.setTextContent(list.joinToString("\n") {
- TextCodecs.CODEC.encodeStart(JsonOps.INSTANCE, it).result().getOrNull().toString()
+ ComponentSerialization.CODEC.encodeStart(JsonOps.INSTANCE, it).result().getOrNull().toString()
})
- lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.lore"))
+ lastCopiedStack = Pair(item, Component.translatable("firmament.tooltip.copied.lore"))
} else if (it.matches(TConfig.copySkullTexture)) {
if (item.item != Items.PLAYER_HEAD) {
- lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.skull-id.fail.no-skull"))
+ lastCopiedStack = Pair(item, Component.translatable("firmament.tooltip.copied.skull-id.fail.no-skull"))
return
}
- val profile = item.get(DataComponentTypes.PROFILE)
+ val profile = item.get(DataComponents.PROFILE)
if (profile == null) {
- lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.skull-id.fail.no-profile"))
+ lastCopiedStack = Pair(item, Component.translatable("firmament.tooltip.copied.skull-id.fail.no-profile"))
return
}
val skullTexture = getSkullId(profile)
if (skullTexture == null) {
- lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.skull-id.fail.no-texture"))
+ lastCopiedStack = Pair(item, Component.translatable("firmament.tooltip.copied.skull-id.fail.no-texture"))
return
}
ClipboardUtils.setTextContent(skullTexture.toString())
lastCopiedStack =
- Pair(item, Text.stringifiedTranslatable("firmament.tooltip.copied.skull-id", skullTexture.toString()))
+ Pair(item, Component.translatableEscape("firmament.tooltip.copied.skull-id", skullTexture.toString()))
println("Copied skull id: $skullTexture")
} else if (it.matches(TConfig.copyItemStack)) {
val nbt = ItemStack.CODEC
- .encodeStart(MC.currentOrDefaultRegistries.getOps(NbtOps.INSTANCE), item)
+ .encodeStart(MC.currentOrDefaultRegistries.createSerializationContext(NbtOps.INSTANCE), item)
.orThrow
ClipboardUtils.setTextContent(nbt.toPrettyString())
- lastCopiedStack = Pair(item, Text.stringifiedTranslatable("firmament.tooltip.copied.stack"))
+ lastCopiedStack = Pair(item, Component.translatableEscape("firmament.tooltip.copied.stack"))
} else if (it.matches(TConfig.copyTitle)) {
- val allTitles = NbtList()
+ val allTitles = ListTag()
val inventoryNames =
- it.screen.screenHandler.slots
- .mapNotNullTo(mutableSetOf()) { it.inventory }
+ it.screen.menu.slots
+ .mapNotNullTo(mutableSetOf()) { it.container }
.filterIsInstance<Nameable>()
.map { it.name }
for (it in listOf(it.screen.title) + inventoryNames) {
- allTitles.add(TextCodecs.CODEC.encodeStart(NbtOps.INSTANCE, it).result().getOrNull()!!)
+ allTitles.add(ComponentSerialization.CODEC.encodeStart(NbtOps.INSTANCE, it).result().getOrNull()!!)
}
ClipboardUtils.setTextContent(allTitles.toPrettyString())
MC.sendChat(tr("firmament.power-user.title.copied", "Copied screen and inventory titles"))
@@ -221,23 +221,23 @@ object PowerUserTools {
fun onCopyWorldInfo(it: WorldKeyboardEvent) {
if (it.matches(TConfig.copySkullTexture)) {
val p = MC.camera ?: return
- val blockHit = p.raycast(20.0, 0.0f, false) ?: return
+ val blockHit = p.pick(20.0, 0.0f, false) ?: return
if (blockHit.type != HitResult.Type.BLOCK || blockHit !is BlockHitResult) {
- MC.sendChat(Text.translatable("firmament.tooltip.copied.skull.fail"))
+ MC.sendChat(Component.translatable("firmament.tooltip.copied.skull.fail"))
return
}
- val blockAt = p.world.getBlockState(blockHit.blockPos)?.block
- val entity = p.world.getBlockEntity(blockHit.blockPos)
- if (blockAt !is SkullBlock || entity !is SkullBlockEntity || entity.owner == null) {
- MC.sendChat(Text.translatable("firmament.tooltip.copied.skull.fail"))
+ val blockAt = p.level.getBlockState(blockHit.blockPos)?.block
+ val entity = p.level.getBlockEntity(blockHit.blockPos)
+ if (blockAt !is SkullBlock || entity !is SkullBlockEntity || entity.ownerProfile == null) {
+ MC.sendChat(Component.translatable("firmament.tooltip.copied.skull.fail"))
return
}
- val id = getSkullId(entity.owner!!)
+ val id = getSkullId(entity.ownerProfile!!)
if (id == null) {
- MC.sendChat(Text.translatable("firmament.tooltip.copied.skull.fail"))
+ MC.sendChat(Component.translatable("firmament.tooltip.copied.skull.fail"))
} else {
ClipboardUtils.setTextContent(id.toString())
- MC.sendChat(Text.stringifiedTranslatable("firmament.tooltip.copied.skull", id.toString()))
+ MC.sendChat(Component.translatableEscape("firmament.tooltip.copied.skull", id.toString()))
}
}
}
@@ -246,10 +246,10 @@ object PowerUserTools {
fun addItemId(it: ItemTooltipEvent) {
if (TConfig.showItemIds) {
val id = it.stack.skyBlockId ?: return
- it.lines.add(Text.stringifiedTranslatable("firmament.tooltip.skyblockid", id.neuItem).grey())
+ it.lines.add(Component.translatableEscape("firmament.tooltip.skyblockid", id.neuItem).grey())
}
val (item, text) = lastCopiedStack ?: return
- if (!ItemStack.areEqual(item, it.stack)) {
+ if (!ItemStack.matches(item, it.stack)) {
lastCopiedStack = null
return
}
diff --git a/src/main/kotlin/features/debug/SkinPreviews.kt b/src/main/kotlin/features/debug/SkinPreviews.kt
index a853cd1..56c63db 100644
--- a/src/main/kotlin/features/debug/SkinPreviews.kt
+++ b/src/main/kotlin/features/debug/SkinPreviews.kt
@@ -5,11 +5,11 @@ import kotlinx.serialization.json.JsonPrimitive
import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.put
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.component.DataComponentTypes
-import net.minecraft.component.type.ProfileComponent
-import net.minecraft.entity.EquipmentSlot
-import net.minecraft.entity.LivingEntity
-import net.minecraft.util.math.Vec3d
+import net.minecraft.core.component.DataComponents
+import net.minecraft.world.item.component.ResolvableProfile
+import net.minecraft.world.entity.EquipmentSlot
+import net.minecraft.world.entity.LivingEntity
+import net.minecraft.world.phys.Vec3
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.EntityUpdateEvent
import moe.nea.firmament.events.IsSlotProtectedEvent
@@ -32,11 +32,11 @@ object SkinPreviews {
@Subscribe
fun onEntityUpdate(event: EntityUpdateEvent) {
if (!isRecording) return
- if (event.entity.pos != pos)
+ if (event.entity.position != pos)
return
val entity = event.entity as? LivingEntity ?: return
- val stack = entity.getEquippedStack(EquipmentSlot.HEAD) ?: return
- val profile = stack.get(DataComponentTypes.PROFILE)?.gameProfile ?: return
+ val stack = entity.getItemBySlot(EquipmentSlot.HEAD) ?: return
+ val profile = stack.get(DataComponents.PROFILE)?.partialProfile() ?: return
if (profile == animation.lastOrNull()) return
animation.add(profile)
val shortened = animation.shortenCycle()
@@ -65,7 +65,7 @@ object SkinPreviews {
}
var animation = mutableListOf<GameProfile>()
- var pos = Vec3d(-1.0, 72.0, -101.25)
+ var pos = Vec3(-1.0, 72.0, -101.25)
var isRecording = false
var skinColor: String? = null
var skinId: String? = null
diff --git a/src/main/kotlin/features/debug/SoundVisualizer.kt b/src/main/kotlin/features/debug/SoundVisualizer.kt
index f805e6b..37b248a 100644
--- a/src/main/kotlin/features/debug/SoundVisualizer.kt
+++ b/src/main/kotlin/features/debug/SoundVisualizer.kt
@@ -1,6 +1,6 @@
package moe.nea.firmament.features.debug
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.thenExecute
import moe.nea.firmament.commands.thenLiteral
@@ -43,7 +43,7 @@ object SoundVisualizer {
sounds.forEach { event ->
withFacingThePlayer(event.position) {
text(
- Text.literal(event.sound.value().id.toString()).also {
+ Component.literal(event.sound.value().location.toString()).also {
if (event.cancelled)
it.red()
},
diff --git a/src/main/kotlin/features/debug/itemeditor/ExportRecipe.kt b/src/main/kotlin/features/debug/itemeditor/ExportRecipe.kt
index b3dc69a..d12d667 100644
--- a/src/main/kotlin/features/debug/itemeditor/ExportRecipe.kt
+++ b/src/main/kotlin/features/debug/itemeditor/ExportRecipe.kt
@@ -4,9 +4,9 @@ import kotlinx.coroutines.launch
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.JsonPrimitive
-import net.minecraft.client.network.AbstractClientPlayerEntity
-import net.minecraft.entity.decoration.ArmorStandEntity
-import net.minecraft.util.AssetInfo
+import net.minecraft.client.player.AbstractClientPlayer
+import net.minecraft.world.entity.decoration.ArmorStand
+import net.minecraft.core.ClientAsset
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HandledScreenKeyPressedEvent
@@ -52,23 +52,23 @@ object ExportRecipe {
if (!event.matches(PowerUserTools.TConfig.exportNpcLocation)) {
return
}
- val entity = MC.instance.targetedEntity
+ val entity = MC.instance.crosshairPickEntity
if (entity == null) {
MC.sendChat(tr("firmament.repo.export.npc.noentity", "Could not find entity to export"))
return
}
Firmament.coroutineScope.launch {
- val guessName = entity.world.getEntitiesByClass(
- ArmorStandEntity::class.java,
- entity.boundingBox.expand(0.1),
+ val guessName = entity.level.getEntitiesOfClass(
+ ArmorStand::class.java,
+ entity.boundingBox.inflate(0.1),
{ !it.name.string.contains("CLICK") })
.firstOrNull()?.customName?.string
?: ""
val reply = waitForTextInput("$guessName (NPC)", "Export stub")
val id = generateName(reply)
ItemExporter.exportStub(id, "§9$reply") {
- val playerEntity = entity as? AbstractClientPlayerEntity
- val textureUrl = (playerEntity?.skin?.body as? AssetInfo.SkinAssetInfo)?.url
+ val playerEntity = entity as? AbstractClientPlayer
+ val textureUrl = (playerEntity?.skin?.body as? ClientAsset.DownloadedTexture)?.url
if (textureUrl != null)
it.setSkullOwner(playerEntity.uuid, textureUrl)
}
@@ -89,19 +89,19 @@ object ExportRecipe {
return
}
val title = event.screen.title.string
- val sellSlot = event.screen.getSlotByIndex(49, false)?.stack
+ val sellSlot = event.screen.getSlotByIndex(49, false)?.item
val craftingTableSlot = event.screen.getSlotByIndex(craftingTableSlut, false)
- if (craftingTableSlot?.stack?.displayNameAccordingToNbt?.unformattedString == "Crafting Table") {
+ if (craftingTableSlot?.item?.displayNameAccordingToNbt?.unformattedString == "Crafting Table") {
slotIndices.forEach { (_, index) ->
- event.screen.getSlotByIndex(index, false)?.stack?.let(ItemExporter::ensureExported)
+ event.screen.getSlotByIndex(index, false)?.item?.let(ItemExporter::ensureExported)
}
val inputs = slotIndices.associate { (name, index) ->
- val id = event.screen.getSlotByIndex(index, false)?.stack?.takeIf { !it.isEmpty() }?.let {
+ val id = event.screen.getSlotByIndex(index, false)?.item?.takeIf { !it.isEmpty() }?.let {
"${it.skyBlockId?.neuItem}:${it.count}"
} ?: ""
name to JsonPrimitive(id)
}
- val output = event.screen.getSlotByIndex(resultSlot, false)?.stack!!
+ val output = event.screen.getSlotByIndex(resultSlot, false)?.item!!
val overrideOutputId = output.skyBlockId!!.neuItem
val count = output.count
val recipe = JsonObject(
@@ -123,7 +123,7 @@ object ExportRecipe {
ItemExporter.exportStub(shopId, "§9$title (NPC)")
}
for (index in (9..9 * 5)) {
- val item = event.screen.getSlotByIndex(index, false)?.stack ?: continue
+ val item = event.screen.getSlotByIndex(index, false)?.item ?: continue
val skyblockId = item.skyBlockId ?: continue
val costLines = item.loreAccordingToNbt
.map { it.string.trim() }
diff --git a/src/main/kotlin/features/debug/itemeditor/ItemExporter.kt b/src/main/kotlin/features/debug/itemeditor/ItemExporter.kt
index ccbd7e0..f664da3 100644
--- a/src/main/kotlin/features/debug/itemeditor/ItemExporter.kt
+++ b/src/main/kotlin/features/debug/itemeditor/ItemExporter.kt
@@ -12,10 +12,10 @@ import kotlin.io.path.notExists
import kotlin.io.path.readText
import kotlin.io.path.relativeTo
import kotlin.io.path.writeText
-import net.minecraft.item.ItemStack
-import net.minecraft.item.Items
-import net.minecraft.nbt.NbtString
-import net.minecraft.text.Text
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.item.Items
+import net.minecraft.nbt.StringTag
+import net.minecraft.network.chat.Component
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.RestArgumentType
@@ -47,7 +47,7 @@ import moe.nea.firmament.util.tr
object ItemExporter {
- fun exportItem(itemStack: ItemStack): Text {
+ fun exportItem(itemStack: ItemStack): Component {
nonOverlayCache.clear()
val exporter = LegacyItemExporter.createExporter(itemStack)
var json = exporter.exportJson()
@@ -197,7 +197,7 @@ object ItemExporter {
display.putString("Name", mutJson["displayname"]!!.jsonPrimitive.content)
display.put(
"Lore",
- (mutJson["lore"] as JsonArray).map { NbtString.of(it.jsonPrimitive.content) }
+ (mutJson["lore"] as JsonArray).map { StringTag.valueOf(it.jsonPrimitive.content) }
.toNbtList()
)
mutJson["nbttag"] = JsonPrimitive(legacyTag.toLegacyString())
@@ -220,8 +220,8 @@ object ItemExporter {
if (!PowerUserTools.TConfig.highlightNonOverlayItems) {
return
}
- val stack = event.slot.stack ?: return
- val id = event.slot.stack.skyBlockId?.neuItem
+ val stack = event.slot.item ?: return
+ val id = event.slot.item.skyBlockId?.neuItem
if (PowerUserTools.TConfig.dontHighlightSemicolonItems && id != null && id.contains(";")) return
val sbId = stack.skyBlockId ?: return
val isExported = nonOverlayCache.getOrPut(sbId) {
@@ -240,8 +240,8 @@ object ItemExporter {
fun exportStub(skyblockId: SkyblockId, title: String, extra: (ItemStack) -> Unit = {}) {
exportItem(ItemStack(Items.PLAYER_HEAD).also {
- it.displayNameAccordingToNbt = Text.literal(title)
- it.loreAccordingToNbt = listOf(Text.literal(""))
+ it.displayNameAccordingToNbt = Component.literal(title)
+ it.loreAccordingToNbt = listOf(Component.literal(""))
it.setSkyBlockId(skyblockId)
extra(it) // LOL
})
diff --git a/src/main/kotlin/features/debug/itemeditor/LegacyItemData.kt b/src/main/kotlin/features/debug/itemeditor/LegacyItemData.kt
index 4b647c7..2bc51bc 100644
--- a/src/main/kotlin/features/debug/itemeditor/LegacyItemData.kt
+++ b/src/main/kotlin/features/debug/itemeditor/LegacyItemData.kt
@@ -1,8 +1,8 @@
package moe.nea.firmament.features.debug.itemeditor
import kotlinx.serialization.Serializable
-import net.minecraft.nbt.NbtCompound
-import net.minecraft.util.Identifier
+import net.minecraft.nbt.CompoundTag
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.Firmament
import moe.nea.firmament.repo.ExpensiveItemCacheApi
import moe.nea.firmament.repo.ItemCache
@@ -54,14 +54,14 @@ object LegacyItemData {
).getOrThrow()
val enchantmentData = getLegacyData<List<EnchantmentData>>("enchantments")
- val enchantmentLut = enchantmentData.associateBy { Identifier.ofVanilla(it.name) }
+ val enchantmentLut = enchantmentData.associateBy { ResourceLocation.withDefaultNamespace(it.name) }
val itemDat = getLegacyData<List<ItemData>>("items")
@OptIn(ExpensiveItemCacheApi::class) // This is fine, we get loaded in a thread.
val itemLut = itemDat.flatMap { item ->
item.allVariants().map { legacyItemType ->
- val nbt = ItemCache.convert189ToModern(NbtCompound().apply {
+ val nbt = ItemCache.convert189ToModern(CompoundTag().apply {
putString("id", legacyItemType.name)
putByte("Count", 1)
putShort("Damage", legacyItemType.metadata)
diff --git a/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt b/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt
index 65f9fa1..7b855d1 100644
--- a/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt
+++ b/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt
@@ -6,18 +6,18 @@ import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.put
import kotlin.concurrent.thread
import kotlin.jvm.optionals.getOrNull
-import net.minecraft.component.DataComponentTypes
-import net.minecraft.item.ItemStack
-import net.minecraft.item.Items
-import net.minecraft.nbt.NbtByte
-import net.minecraft.nbt.NbtCompound
-import net.minecraft.nbt.NbtElement
-import net.minecraft.nbt.NbtInt
-import net.minecraft.nbt.NbtList
+import net.minecraft.core.component.DataComponents
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.item.Items
+import net.minecraft.nbt.ByteTag
+import net.minecraft.nbt.CompoundTag
+import net.minecraft.nbt.Tag
+import net.minecraft.nbt.IntTag
+import net.minecraft.nbt.ListTag
import net.minecraft.nbt.NbtOps
-import net.minecraft.nbt.NbtString
-import net.minecraft.registry.tag.ItemTags
-import net.minecraft.text.Text
+import net.minecraft.nbt.StringTag
+import net.minecraft.tags.ItemTags
+import net.minecraft.network.chat.Component
import net.minecraft.util.Unit
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
@@ -51,7 +51,7 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) {
val originalId = itemStack.extraAttributes.getString("id")
var name = itemStack.displayNameAccordingToNbt
val extraAttribs = itemStack.extraAttributes.copy()
- val legacyNbt = NbtCompound()
+ val legacyNbt = CompoundTag()
val warnings = mutableListOf<String>()
// TODO: check if lore contains non 1.8.9 able hex codes and emit lore in overlay files if so
@@ -70,8 +70,8 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) {
extraAttribs.putString("id", it.neuItem)
}
trimLore()
- itemStack.loreAccordingToNbt = itemStack.item.defaultStack.loreAccordingToNbt
- itemStack.remove(DataComponentTypes.CUSTOM_NAME)
+ itemStack.loreAccordingToNbt = itemStack.item.defaultInstance.loreAccordingToNbt
+ itemStack.remove(DataComponents.CUSTOM_NAME)
}
fun trimLore() {
@@ -94,11 +94,11 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) {
name = name.transformEachRecursively {
var string = it.directLiteralStringContent ?: return@transformEachRecursively it
string = string.replace("Lvl \\d+".toRegex(), "Lvl {LVL}")
- Text.literal(string).setStyle(it.style)
+ Component.literal(string).setStyle(it.style)
}
if (lore.isEmpty())
- lore = listOf(Text.empty())
+ lore = listOf(Component.empty())
}
private fun trimStats() {
@@ -112,7 +112,7 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) {
v.siblings.removeIf { it.directLiteralStringContent!!.contains("(") }
val last = v.siblings.last()
v.siblings[v.siblings.lastIndex] =
- Text.literal(last.directLiteralStringContent!!.trimEnd())
+ Component.literal(last.directLiteralStringContent!!.trimEnd())
.setStyle(last.style)
lore[index] = v
}
@@ -120,7 +120,7 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) {
}
fun collapseWhitespaces() {
- lore = (listOf(null as Text?) + lore).zipWithNext()
+ lore = (listOf(null as Component?) + lore).zipWithNext()
.filter { !it.first?.unformattedString.isNullOrBlank() || !it.second?.unformattedString.isNullOrBlank() }
.map { it.second!! }
}
@@ -140,7 +140,7 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) {
fun processNbt() {
// TODO: calculate hideflags
- legacyNbt.put("HideFlags", NbtInt.of(254))
+ legacyNbt.put("HideFlags", IntTag.valueOf(254))
copyUnbreakable()
copyItemModel()
copyPotion()
@@ -154,51 +154,51 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) {
}
private fun copyPotion() {
- val effects = itemStack.get(DataComponentTypes.POTION_CONTENTS) ?: return
- legacyNbt.put("CustomPotionEffects", NbtList().also {
- effects.effects.forEach { effect ->
- val effectId = effect.effectType.key.get().value.path
+ val effects = itemStack.get(DataComponents.POTION_CONTENTS) ?: return
+ legacyNbt.put("CustomPotionEffects", ListTag().also {
+ effects.allEffects.forEach { effect ->
+ val effectId = effect.effect.unwrapKey().get().location().path
val duration = effect.duration
val legacyId = LegacyItemData.effectList[effectId]!!
- it.add(NbtCompound().apply {
- put("Ambient", NbtByte.of(false))
- put("Duration", NbtInt.of(duration))
- put("Id", NbtByte.of(legacyId.id.toByte()))
- put("Amplifier", NbtByte.of(effect.amplifier.toByte()))
+ it.add(CompoundTag().apply {
+ put("Ambient", ByteTag.valueOf(false))
+ put("Duration", IntTag.valueOf(duration))
+ put("Id", ByteTag.valueOf(legacyId.id.toByte()))
+ put("Amplifier", ByteTag.valueOf(effect.amplifier.toByte()))
})
}
})
}
- fun NbtCompound.getOrPutCompound(name: String): NbtCompound {
+ fun CompoundTag.getOrPutCompound(name: String): CompoundTag {
val compound = getCompoundOrEmpty(name)
put(name, compound)
return compound
}
private fun copyColour() {
- if (!itemStack.isIn(ItemTags.DYEABLE)) {
- itemStack.remove(DataComponentTypes.DYED_COLOR)
+ if (!itemStack.`is`(ItemTags.DYEABLE)) {
+ itemStack.remove(DataComponents.DYED_COLOR)
return
}
- val leatherTint = itemStack.componentChanges.get(DataComponentTypes.DYED_COLOR)?.getOrNull() ?: return
- legacyNbt.getOrPutCompound("display").put("color", NbtInt.of(leatherTint.rgb))
+ val leatherTint = itemStack.componentsPatch.get(DataComponents.DYED_COLOR)?.getOrNull() ?: return
+ legacyNbt.getOrPutCompound("display").put("color", IntTag.valueOf(leatherTint.rgb))
}
private fun copyItemModel() {
- val itemModel = itemStack.get(DataComponentTypes.ITEM_MODEL) ?: return
- legacyNbt.put("ItemModel", NbtString.of(itemModel.toString()))
+ val itemModel = itemStack.get(DataComponents.ITEM_MODEL) ?: return
+ legacyNbt.put("ItemModel", StringTag.valueOf(itemModel.toString()))
}
private fun copyDisplay() {
legacyNbt.getOrPutCompound("display").apply {
- put("Lore", lore.map { NbtString.of(it.getLegacyFormatString(trimmed = true)) }.toNbtList())
+ put("Lore", lore.map { StringTag.valueOf(it.getLegacyFormatString(trimmed = true)) }.toNbtList())
putString("Name", name.getLegacyFormatString(trimmed = true))
}
}
- fun exportModernSnbt(): NbtElement {
+ fun exportModernSnbt(): Tag {
val overlay = ItemStack.CODEC.encodeStart(MC.currentOrDefaultRegistryNbtOps, itemStack.copy().also {
it.modifyExtraAttributes { attribs ->
originalId.ifPresent { attribs.putString("id", it) }
@@ -251,30 +251,30 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) {
}
fun copyEnchantGlint() {
- if (itemStack.get(DataComponentTypes.ENCHANTMENT_GLINT_OVERRIDE) == true) {
+ if (itemStack.get(DataComponents.ENCHANTMENT_GLINT_OVERRIDE) == true) {
val ench = legacyNbt.getListOrEmpty("ench")
legacyNbt.put("ench", ench)
}
}
private fun copyUnbreakable() {
- if (itemStack.get(DataComponentTypes.UNBREAKABLE) == Unit.INSTANCE) {
+ if (itemStack.get(DataComponents.UNBREAKABLE) == Unit.INSTANCE) {
legacyNbt.putBoolean("Unbreakable", true)
}
}
fun copyEnchantments() {
- val enchantments = itemStack.get(DataComponentTypes.ENCHANTMENTS)?.takeIf { !it.isEmpty } ?: return
+ val enchantments = itemStack.get(DataComponents.ENCHANTMENTS)?.takeIf { !it.isEmpty } ?: return
val enchTag = legacyNbt.getListOrEmpty("ench")
legacyNbt.put("ench", enchTag)
- enchantments.enchantmentEntries.forEach { entry ->
- val id = entry.key.key.get().value
+ enchantments.entrySet().forEach { entry ->
+ val id = entry.key.unwrapKey().get().location()
val legacyId = LegacyItemData.enchantmentLut[id]
if (legacyId == null) {
warnings.add("Could not find legacy enchantment id for ${id}")
return@forEach
}
- enchTag.add(NbtCompound().apply {
+ enchTag.add(CompoundTag().apply {
putShort("lvl", entry.intValue.toShort())
putShort(
"id",
@@ -289,15 +289,15 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) {
}
fun copyLegacySkullNbt() {
- val profile = itemStack.get(DataComponentTypes.PROFILE) ?: return
- legacyNbt.put("SkullOwner", NbtCompound().apply {
- putString("Id", profile.gameProfile.id.toString())
+ val profile = itemStack.get(DataComponents.PROFILE) ?: return
+ legacyNbt.put("SkullOwner", CompoundTag().apply {
+ putString("Id", profile.partialProfile().id.toString())
putBoolean("hypixelPopulated", true)
- put("Properties", NbtCompound().apply {
- profile.gameProfile.properties().forEach { prop, value ->
+ put("Properties", CompoundTag().apply {
+ profile.partialProfile().properties().forEach { prop, value ->
val list = getListOrEmpty(prop)
put(prop, list)
- list.add(NbtCompound().apply {
+ list.add(CompoundTag().apply {
value.signature?.let {
putString("Signature", it)
}
diff --git a/src/main/kotlin/features/diana/AncestralSpadeSolver.kt b/src/main/kotlin/features/diana/AncestralSpadeSolver.kt
index a2869f0..72806c9 100644
--- a/src/main/kotlin/features/diana/AncestralSpadeSolver.kt
+++ b/src/main/kotlin/features/diana/AncestralSpadeSolver.kt
@@ -1,9 +1,9 @@
package moe.nea.firmament.features.diana
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.particle.ParticleTypes
-import net.minecraft.sound.SoundEvents
-import net.minecraft.util.math.Vec3d
+import net.minecraft.core.particles.ParticleTypes
+import net.minecraft.sounds.SoundEvents
+import net.minecraft.world.phys.Vec3
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ParticleSpawnEvent
import moe.nea.firmament.events.SoundReceiveEvent
@@ -23,8 +23,8 @@ object AncestralSpadeSolver {
var lastDing = TimeMark.farPast()
private set
private val pitches = mutableListOf<Float>()
- val particlePositions = mutableListOf<Vec3d>()
- var nextGuess: Vec3d? = null
+ val particlePositions = mutableListOf<Vec3>()
+ var nextGuess: Vec3? = null
private set
private var lastTeleportAttempt = TimeMark.farPast()
@@ -32,7 +32,7 @@ object AncestralSpadeSolver {
fun isEnabled() =
DianaWaypoints.TConfig.ancestralSpadeSolver
&& SBData.skyblockLocation == SkyBlockIsland.HUB
- && MC.player?.inventory?.containsAny { it.skyBlockId == SkyBlockItems.ANCESTRAL_SPADE } == true // TODO: add a reactive property here
+ && MC.player?.inventory?.hasAnyMatching { it.skyBlockId == SkyBlockItems.ANCESTRAL_SPADE } == true // TODO: add a reactive property here
@Subscribe
fun onKeyBind(event: WorldKeyboardEvent) {
@@ -59,7 +59,7 @@ object AncestralSpadeSolver {
@Subscribe
fun onPlaySound(event: SoundReceiveEvent) {
if (!isEnabled()) return
- if (!SoundEvents.BLOCK_NOTE_BLOCK_HARP.matchesId(event.sound.value().id)) return
+ if (!SoundEvents.NOTE_BLOCK_HARP.`is`(event.sound.value().location)) return
if (lastDing.passedTime() > 1.seconds) {
particlePositions.clear()
@@ -93,7 +93,7 @@ object AncestralSpadeSolver {
.let { (a, _, b) -> b.subtract(a) }
.normalize()
- nextGuess = event.position.add(lastParticleDirection.multiply(soundDistanceEstimate))
+ nextGuess = event.position.add(lastParticleDirection.scale(soundDistanceEstimate))
}
@Subscribe
diff --git a/src/main/kotlin/features/diana/NearbyBurrowsSolver.kt b/src/main/kotlin/features/diana/NearbyBurrowsSolver.kt
index e1fb856..35af660 100644
--- a/src/main/kotlin/features/diana/NearbyBurrowsSolver.kt
+++ b/src/main/kotlin/features/diana/NearbyBurrowsSolver.kt
@@ -2,10 +2,10 @@ package moe.nea.firmament.features.diana
import me.shedaniel.math.Color
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.particle.ParticleTypes
-import net.minecraft.util.math.BlockPos
-import net.minecraft.util.math.MathHelper
-import net.minecraft.util.math.Position
+import net.minecraft.core.particles.ParticleTypes
+import net.minecraft.core.BlockPos
+import net.minecraft.util.Mth
+import net.minecraft.core.Position
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ParticleSpawnEvent
import moe.nea.firmament.events.ProcessChatEvent
@@ -63,7 +63,7 @@ object NearbyBurrowsSolver {
fun onParticles(event: ParticleSpawnEvent) {
if (!DianaWaypoints.TConfig.nearbyWaypoints) return
- val position: BlockPos = event.position.toBlockPos().down()
+ val position: BlockPos = event.position.toBlockPos().below()
if (wasRecentlyDug(position)) return
@@ -135,5 +135,5 @@ object NearbyBurrowsSolver {
}
fun Position.toBlockPos(): BlockPos {
- return BlockPos(MathHelper.floor(x), MathHelper.floor(y), MathHelper.floor(z))
+ return BlockPos(Mth.floor(x()), Mth.floor(y()), Mth.floor(z()))
}
diff --git a/src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt b/src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt
index ded5e13..955d23b 100644
--- a/src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt
+++ b/src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt
@@ -4,9 +4,9 @@ import io.github.notenoughupdates.moulconfig.observer.ObservableList
import io.github.notenoughupdates.moulconfig.xml.Bind
import org.joml.Vector2i
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.entity.passive.PigEntity
-import net.minecraft.text.Text
-import net.minecraft.util.math.BlockPos
+import net.minecraft.world.entity.animal.Pig
+import net.minecraft.network.chat.Component
+import net.minecraft.core.BlockPos
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.EntityInteractionEvent
import moe.nea.firmament.events.ProcessChatEvent
@@ -36,16 +36,16 @@ object AnniversaryFeatures {
}
data class ClickedPig(
- val clickedAt: TimeMark,
- val startLocation: BlockPos,
- val pigEntity: PigEntity
+ val clickedAt: TimeMark,
+ val startLocation: BlockPos,
+ val pigEntity: Pig
) {
@Bind("timeLeft")
fun getTimeLeft(): Double = 1 - clickedAt.passedTime() / pigDuration
}
val clickedPigs = ObservableList<ClickedPig>(mutableListOf())
- var lastClickedPig: PigEntity? = null
+ var lastClickedPig: Pig? = null
val pigDuration = 90.seconds
@@ -62,14 +62,14 @@ object AnniversaryFeatures {
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
+ val startLocation = pig.blockPosition() ?: 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.minByOrNull { it.startLocation.distToCenterSqr(player.position) } ?: return
clickedPigs.remove(lowest)
}
pattern.useMatch(event.unformattedString) {
@@ -166,7 +166,7 @@ object AnniversaryFeatures {
@Subscribe
fun onEntityClick(event: EntityInteractionEvent) {
- if (event.entity is PigEntity) {
+ if (event.entity is Pig) {
lastClickedPig = event.entity
}
}
@@ -203,12 +203,12 @@ object AnniversaryFeatures {
@OptIn(ExpensiveItemCacheApi::class)
@Bind
- fun name(): Text {
+ fun name(): Component {
return when (backedBy) {
- is Reward.Coins -> Text.literal("Coins")
- is Reward.EXP -> Text.literal(backedBy.skill)
- is Reward.Items -> itemStack.asImmutableItemStack().name
- is Reward.Unknown -> Text.literal(backedBy.text)
+ is Reward.Coins -> Component.literal("Coins")
+ is Reward.EXP -> Component.literal(backedBy.skill)
+ is Reward.Items -> itemStack.asImmutableItemStack().hoverName
+ is Reward.Unknown -> Component.literal(backedBy.text)
}
}
diff --git a/src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt b/src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt
index 13ecd7b..9b87cc6 100644
--- a/src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt
+++ b/src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt
@@ -3,9 +3,9 @@ package moe.nea.firmament.features.events.anniversity
import java.util.Optional
import me.shedaniel.math.Color
import kotlin.jvm.optionals.getOrNull
-import net.minecraft.entity.player.PlayerEntity
-import net.minecraft.text.Style
-import net.minecraft.util.Formatting
+import net.minecraft.world.entity.player.Player
+import net.minecraft.network.chat.Style
+import net.minecraft.ChatFormatting
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.EntityRenderTintEvent
import moe.nea.firmament.util.MC
@@ -26,18 +26,18 @@ object CenturyRaffleFeatures {
val cakeIcon = "⛃"
val cakeColors = listOf(
- CakeTeam(SkyBlockItems.SLICE_OF_BLUEBERRY_CAKE, Formatting.BLUE),
- CakeTeam(SkyBlockItems.SLICE_OF_CHEESECAKE, Formatting.YELLOW),
- CakeTeam(SkyBlockItems.SLICE_OF_GREEN_VELVET_CAKE, Formatting.GREEN),
- CakeTeam(SkyBlockItems.SLICE_OF_RED_VELVET_CAKE, Formatting.RED),
- CakeTeam(SkyBlockItems.SLICE_OF_STRAWBERRY_SHORTCAKE, Formatting.LIGHT_PURPLE),
+ CakeTeam(SkyBlockItems.SLICE_OF_BLUEBERRY_CAKE, ChatFormatting.BLUE),
+ CakeTeam(SkyBlockItems.SLICE_OF_CHEESECAKE, ChatFormatting.YELLOW),
+ CakeTeam(SkyBlockItems.SLICE_OF_GREEN_VELVET_CAKE, ChatFormatting.GREEN),
+ CakeTeam(SkyBlockItems.SLICE_OF_RED_VELVET_CAKE, ChatFormatting.RED),
+ CakeTeam(SkyBlockItems.SLICE_OF_STRAWBERRY_SHORTCAKE, ChatFormatting.LIGHT_PURPLE),
)
data class CakeTeam(
- val id: SkyblockId,
- val formatting: Formatting,
+ val id: SkyblockId,
+ val formatting: ChatFormatting,
) {
- val searchedTextRgb = formatting.colorValue!!
+ val searchedTextRgb = formatting.color!!
val brightenedRgb = Color.ofOpaque(searchedTextRgb)//.brighter(2.0)
val tintOverlay by lazy {
TintedOverlayTexture().setColor(brightenedRgb)
@@ -51,13 +51,13 @@ object CenturyRaffleFeatures {
if (!TConfig.highlightPlayersForSlice) return
val requestedCakeTeam = sliceToColor[MC.stackInHand?.skyBlockId] ?: return
// TODO: cache the requested color
- val player = event.entity as? PlayerEntity ?: return
- val cakeColor: Style = player.styledDisplayName.visit(
+ val player = event.entity as? Player ?: return
+ val cakeColor: Style = player.feedbackDisplayName.visit(
{ style, text ->
if (text == cakeIcon) Optional.of(style)
else Optional.empty()
}, Style.EMPTY).getOrNull() ?: return
- if (cakeColor.color?.rgb == requestedCakeTeam.searchedTextRgb) {
+ if (cakeColor.color?.value == requestedCakeTeam.searchedTextRgb) {
event.renderState.overlayTexture_firmament = requestedCakeTeam.tintOverlay
}
}
diff --git a/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt b/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt
index e675cc9..64b3814 100644
--- a/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt
+++ b/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt
@@ -5,14 +5,14 @@ import io.github.notenoughupdates.moulconfig.observer.ObservableList
import io.github.notenoughupdates.moulconfig.platform.MoulConfigPlatform
import io.github.notenoughupdates.moulconfig.xml.Bind
import java.util.UUID
-import net.minecraft.block.Blocks
-import net.minecraft.item.Item
-import net.minecraft.item.ItemStack
-import net.minecraft.item.Items
-import net.minecraft.text.ClickEvent
-import net.minecraft.text.Text
-import net.minecraft.util.math.BlockPos
-import net.minecraft.world.WorldAccess
+import net.minecraft.world.level.block.Blocks
+import net.minecraft.world.item.Item
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.item.Items
+import net.minecraft.network.chat.ClickEvent
+import net.minecraft.network.chat.Component
+import net.minecraft.core.BlockPos
+import net.minecraft.world.level.LevelAccessor
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.thenExecute
import moe.nea.firmament.events.AttackBlockEvent
@@ -118,19 +118,19 @@ object MinesweeperHelper {
val itemStack = createSkullItem(UUID.randomUUID(), textureUrl)
.setSkyBlockFirmamentUiId("MINESWEEPER_$name")
@get:Bind("fruitName")
- val textFruitName = Text.literal(fruitName)
+ val textFruitName = Component.literal(fruitName)
@Bind
fun getIcon() = MoulConfigPlatform.wrap(itemStack)
@get:Bind("pieceLabel")
- val pieceLabel = Text.literal(fruitColor.formattingCode + fruitName)
+ val pieceLabel = Component.literal(fruitColor.formattingCode + fruitName)
@get:Bind("boardLabel")
- val boardLabel = Text.literal("§a$totalPerBoard§7/§rboard")
+ val boardLabel = Component.literal("§a$totalPerBoard§7/§rboard")
@get:Bind("description")
- val getDescription = Text.literal(buildString {
+ val getDescription = Component.literal(buildString {
append(specialAbility)
if (points >= 0) {
append(" Default points: $points.")
@@ -176,10 +176,10 @@ object MinesweeperHelper {
) {
fun toBlockPos() = BlockPos(sandBoxLow.x + x, sandBoxLow.y, sandBoxLow.z + y)
- fun getBlock(world: WorldAccess) = world.getBlockState(toBlockPos()).block
- fun isUnopened(world: WorldAccess) = getBlock(world) == Blocks.SAND
- fun isOpened(world: WorldAccess) = getBlock(world) == Blocks.SANDSTONE
- fun isScorched(world: WorldAccess) = getBlock(world) == Blocks.SANDSTONE_STAIRS
+ fun getBlock(world: LevelAccessor) = world.getBlockState(toBlockPos()).block
+ fun isUnopened(world: LevelAccessor) = getBlock(world) == Blocks.SAND
+ fun isOpened(world: LevelAccessor) = getBlock(world) == Blocks.SANDSTONE
+ fun isScorched(world: LevelAccessor) = getBlock(world) == Blocks.SANDSTONE_STAIRS
companion object {
fun fromBlockPos(blockPos: BlockPos): BoardPosition? {
@@ -222,7 +222,7 @@ object MinesweeperHelper {
@Subscribe
fun onChat(event: ProcessChatEvent) {
if (CarnivalFeatures.TConfig.displayTutorials && event.unformattedString == startGameQuestion) {
- MC.sendChat(Text.translatable("firmament.carnival.tutorial.minesweeper").styled {
+ MC.sendChat(Component.translatable("firmament.carnival.tutorial.minesweeper").withStyle {
it.withClickEvent(ClickEvent.RunCommand("/firm minesweepertutorial"))
})
}
@@ -260,7 +260,7 @@ object MinesweeperHelper {
val boardPosition = BoardPosition.fromBlockPos(event.blockPos)
log.log { "Breaking block at ${event.blockPos} ($boardPosition)" }
gs.lastClickedPosition = boardPosition
- gs.lastDowsingMode = DowsingMode.fromItem(event.player.mainHandStack)
+ gs.lastDowsingMode = DowsingMode.fromItem(event.player.mainHandItem)
}
@Subscribe
@@ -268,7 +268,7 @@ object MinesweeperHelper {
val gs = gameState ?: return
RenderInWorldContext.renderInWorld(event) {
for ((pos, bombCount) in gs.nearbyBombs) {
- this.text(pos.toBlockPos().up().toCenterPos(), Text.literal("§a$bombCount \uD83D\uDCA3"))
+ this.text(pos.toBlockPos().above().center, Component.literal("§a$bombCount \uD83D\uDCA3"))
}
}
}
diff --git a/src/main/kotlin/features/fixes/Fixes.kt b/src/main/kotlin/features/fixes/Fixes.kt
index e7027ac..161c7e5 100644
--- a/src/main/kotlin/features/fixes/Fixes.kt
+++ b/src/main/kotlin/features/fixes/Fixes.kt
@@ -2,9 +2,9 @@ package moe.nea.firmament.features.fixes
import org.joml.Vector2i
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable
-import net.minecraft.client.MinecraftClient
-import net.minecraft.client.option.KeyBinding
-import net.minecraft.text.Text
+import net.minecraft.client.Minecraft
+import net.minecraft.client.KeyMapping
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HudRenderEvent
import moe.nea.firmament.events.WorldKeyboardEvent
@@ -34,37 +34,37 @@ object Fixes {
}
fun handleIsPressed(
- keyBinding: KeyBinding,
- cir: CallbackInfoReturnable<Boolean>
+ keyBinding: KeyMapping,
+ cir: CallbackInfoReturnable<Boolean>
) {
- if (keyBinding !== MinecraftClient.getInstance().options.sprintKey) return
+ if (keyBinding !== Minecraft.getInstance().options.keySprint) return
if (!TConfig.autoSprint) return
val player = MC.player ?: return
if (player.isSprinting) return
- if (!TConfig.autoSprintUnderWater && player.isTouchingWater) return
+ if (!TConfig.autoSprintUnderWater && player.isInWater) return
cir.returnValue = true
}
@Subscribe
fun onRenderHud(it: HudRenderEvent) {
if (!TConfig.autoSprintKeyBinding.isBound) return
- it.context.matrices.pushMatrix()
- TConfig.autoSprintHud.applyTransformations(it.context.matrices)
- it.context.drawText(
+ it.context.pose().pushMatrix()
+ TConfig.autoSprintHud.applyTransformations(it.context.pose())
+ it.context.drawString(
MC.font, (
if (MC.player?.isSprinting == true) {
- Text.translatable("firmament.fixes.auto-sprint.sprinting")
+ Component.translatable("firmament.fixes.auto-sprint.sprinting")
} else if (TConfig.autoSprint) {
- if (!TConfig.autoSprintUnderWater && MC.player?.isTouchingWater == true)
+ if (!TConfig.autoSprintUnderWater && MC.player?.isInWater == true)
tr("firmament.fixes.auto-sprint.under-water", "In Water")
else
- Text.translatable("firmament.fixes.auto-sprint.on")
+ Component.translatable("firmament.fixes.auto-sprint.on")
} else {
- Text.translatable("firmament.fixes.auto-sprint.not-sprinting")
+ Component.translatable("firmament.fixes.auto-sprint.not-sprinting")
}
), 0, 0, -1, true
)
- it.context.matrices.popMatrix()
+ it.context.pose().popMatrix()
}
@Subscribe
diff --git a/src/main/kotlin/features/garden/HideComposterNoises.kt b/src/main/kotlin/features/garden/HideComposterNoises.kt
index 843e4f9..edd511f 100644
--- a/src/main/kotlin/features/garden/HideComposterNoises.kt
+++ b/src/main/kotlin/features/garden/HideComposterNoises.kt
@@ -1,8 +1,8 @@
package moe.nea.firmament.features.garden
-import net.minecraft.entity.passive.WolfSoundVariants
-import net.minecraft.sound.SoundEvent
-import net.minecraft.sound.SoundEvents
+import net.minecraft.world.entity.animal.wolf.WolfSoundVariants
+import net.minecraft.sounds.SoundEvent
+import net.minecraft.sounds.SoundEvents
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.SoundReceiveEvent
import moe.nea.firmament.util.SBData
@@ -17,10 +17,10 @@ object HideComposterNoises {
}
val composterSoundEvents: List<SoundEvent> = listOf(
- SoundEvents.BLOCK_PISTON_EXTEND,
- SoundEvents.BLOCK_WATER_AMBIENT,
- SoundEvents.ENTITY_CHICKEN_EGG,
- SoundEvents.WOLF_SOUNDS[WolfSoundVariants.Type.CLASSIC]!!.growlSound().value(),
+ SoundEvents.PISTON_EXTEND,
+ SoundEvents.WATER_AMBIENT,
+ SoundEvents.CHICKEN_EGG,
+ SoundEvents.WOLF_SOUNDS[WolfSoundVariants.SoundSet.CLASSIC]!!.growlSound().value(),
)
@Subscribe
diff --git a/src/main/kotlin/features/inventory/CraftingOverlay.kt b/src/main/kotlin/features/inventory/CraftingOverlay.kt
index 30d2c6b..5241f54 100644
--- a/src/main/kotlin/features/inventory/CraftingOverlay.kt
+++ b/src/main/kotlin/features/inventory/CraftingOverlay.kt
@@ -1,9 +1,9 @@
package moe.nea.firmament.features.inventory
import io.github.moulberry.repo.data.NEUCraftingRecipe
-import net.minecraft.client.gui.screen.ingame.GenericContainerScreen
-import net.minecraft.item.ItemStack
-import net.minecraft.util.Formatting
+import net.minecraft.client.gui.screens.inventory.ContainerScreen
+import net.minecraft.world.item.ItemStack
+import net.minecraft.ChatFormatting
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ScreenChangeEvent
import moe.nea.firmament.events.SlotRenderEvents
@@ -14,7 +14,7 @@ import moe.nea.firmament.util.skyblockId
object CraftingOverlay {
- private var screen: GenericContainerScreen? = null
+ private var screen: ContainerScreen? = null
private var recipe: NEUCraftingRecipe? = null
private var useNextScreen = false
private val craftingOverlayIndices = listOf(
@@ -24,7 +24,7 @@ object CraftingOverlay {
)
val CRAFTING_SCREEN_NAME = "Craft Item"
- fun setOverlay(screen: GenericContainerScreen?, recipe: NEUCraftingRecipe) {
+ fun setOverlay(screen: ContainerScreen?, recipe: NEUCraftingRecipe) {
this.screen = screen
if (screen == null) {
useNextScreen = true
@@ -34,7 +34,7 @@ object CraftingOverlay {
@Subscribe
fun onScreenChange(event: ScreenChangeEvent) {
- if (useNextScreen && event.new is GenericContainerScreen
+ if (useNextScreen && event.new is ContainerScreen
&& event.new.title?.string == "Craft Item"
) {
useNextScreen = false
@@ -50,11 +50,11 @@ object CraftingOverlay {
fun onSlotRender(event: SlotRenderEvents.After) {
val slot = event.slot
val recipe = this.recipe ?: return
- if (slot.inventory != screen?.screenHandler?.inventory) return
- val recipeIndex = craftingOverlayIndices.indexOf(slot.index)
+ if (slot.container != screen?.menu?.container) return
+ val recipeIndex = craftingOverlayIndices.indexOf(slot.containerSlot)
if (recipeIndex < 0) return
val expectedItem = recipe.inputs[recipeIndex]
- val actualStack = slot.stack ?: ItemStack.EMPTY!!
+ val actualStack = slot.item ?: ItemStack.EMPTY!!
val actualEntry = SBItemStack(actualStack)
if ((actualEntry.skyblockId != expectedItem.skyblockId || actualEntry.getStackSize() < expectedItem.amount)
&& expectedItem.amount.toInt() != 0
@@ -67,15 +67,15 @@ object CraftingOverlay {
0x80FF0000.toInt()
)
}
- if (!slot.hasStack()) {
+ if (!slot.hasItem()) {
val itemStack = SBItemStack(expectedItem)?.asImmutableItemStack() ?: return
- event.context.drawItem(itemStack, event.slot.x, event.slot.y)
- event.context.drawStackOverlay(
+ event.context.renderItem(itemStack, event.slot.x, event.slot.y)
+ event.context.renderItemDecorations(
MC.font,
itemStack,
event.slot.x,
event.slot.y,
- "${Formatting.RED}${expectedItem.amount.toInt()}"
+ "${ChatFormatting.RED}${expectedItem.amount.toInt()}"
)
}
}
diff --git a/src/main/kotlin/features/inventory/ItemRarityCosmetics.kt b/src/main/kotlin/features/inventory/ItemRarityCosmetics.kt
index 7a474f9..9712067 100644
--- a/src/main/kotlin/features/inventory/ItemRarityCosmetics.kt
+++ b/src/main/kotlin/features/inventory/ItemRarityCosmetics.kt
@@ -1,10 +1,10 @@
package moe.nea.firmament.features.inventory
import java.awt.Color
-import net.minecraft.client.gl.RenderPipelines
-import net.minecraft.client.gui.DrawContext
-import net.minecraft.item.ItemStack
-import net.minecraft.util.Identifier
+import net.minecraft.client.renderer.RenderPipelines
+import net.minecraft.client.gui.GuiGraphics
+import net.minecraft.world.item.ItemStack
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HotbarItemRenderEvent
import moe.nea.firmament.events.SlotRenderEvents
@@ -23,16 +23,16 @@ object ItemRarityCosmetics {
}
private val rarityToColor = Rarity.colourMap.mapValues {
- val c = Color(it.value.colorValue!!)
+ val c = Color(it.value.color!!)
c.rgb
}
- fun drawItemStackRarity(drawContext: DrawContext, x: Int, y: Int, item: ItemStack) {
+ fun drawItemStackRarity(drawContext: GuiGraphics, x: Int, y: Int, item: ItemStack) {
val rarity = Rarity.fromItem(item) ?: return
val rgb = rarityToColor[rarity] ?: 0xFF00FF80.toInt()
- drawContext.drawGuiTexture(
+ drawContext.blitSprite(
RenderPipelines.GUI_TEXTURED,
- Identifier.of("firmament:item_rarity_background"),
+ ResourceLocation.parse("firmament:item_rarity_background"),
x, y,
16, 16,
rgb
@@ -43,7 +43,7 @@ object ItemRarityCosmetics {
@Subscribe
fun onRenderSlot(it: SlotRenderEvents.Before) {
if (!TConfig.showItemRarityBackground) return
- val stack = it.slot.stack ?: return
+ val stack = it.slot.item ?: return
drawItemStackRarity(it.context, it.slot.x, it.slot.y, stack)
}
diff --git a/src/main/kotlin/features/inventory/JunkHighlighter.kt b/src/main/kotlin/features/inventory/JunkHighlighter.kt
index 45d265e..15bdcfa 100644
--- a/src/main/kotlin/features/inventory/JunkHighlighter.kt
+++ b/src/main/kotlin/features/inventory/JunkHighlighter.kt
@@ -23,7 +23,7 @@ object JunkHighlighter {
if (!TConfig.highlightBind.isPressed() || TConfig.junkRegex.isEmpty()) return
val junkRegex = TConfig.junkRegex.toPattern()
val slot = event.slot
- junkRegex.useMatch(slot.stack.getSearchName()) {
+ junkRegex.useMatch(slot.item.getSearchName()) {
event.context.fill(slot.x, slot.y, slot.x + 16, slot.y + 16, 0xffff0000.toInt())
}
}
diff --git a/src/main/kotlin/features/inventory/PetFeatures.kt b/src/main/kotlin/features/inventory/PetFeatures.kt
index 646989c..e0bb4b1 100644
--- a/src/main/kotlin/features/inventory/PetFeatures.kt
+++ b/src/main/kotlin/features/inventory/PetFeatures.kt
@@ -2,11 +2,11 @@ package moe.nea.firmament.features.inventory
import java.util.regex.Matcher
import org.joml.Vector2i
-import net.minecraft.entity.player.PlayerInventory
-import net.minecraft.item.ItemStack
-import net.minecraft.text.Text
-import net.minecraft.util.Formatting
-import net.minecraft.util.StringIdentifiable
+import net.minecraft.world.entity.player.Inventory
+import net.minecraft.world.item.ItemStack
+import net.minecraft.network.chat.Component
+import net.minecraft.ChatFormatting
+import net.minecraft.util.StringRepresentable
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HudRenderEvent
@@ -52,14 +52,14 @@ object PetFeatures {
val petOverlayHudStyle by choice("pet-overlay-hud-style") { PetOverlayHudStyles.PLAIN_NO_BACKGROUND }
}
- enum class PetOverlayHudStyles : StringIdentifiable {
+ enum class PetOverlayHudStyles : StringRepresentable {
PLAIN_NO_BACKGROUND,
COLOUR_NO_BACKGROUND,
PLAIN_BACKGROUND,
COLOUR_BACKGROUND,
ICON_ONLY;
- override fun asString() : String {
+ override fun getSerializedName() : String {
return name
}
}
@@ -86,7 +86,7 @@ object PetFeatures {
fun onSlotRender(event: SlotRenderEvents.Before) {
// Cache pets
petMenuTitle.useMatch(MC.screenName ?: return) {
- val stack = event.slot.stack
+ val stack = event.slot.item
if (!stack.isEmpty) cachePet(stack)
if (stack.petData?.active == true) {
if (currentPetUUID == "") currentPetUUID = stack.skyblockUUID.toString()
@@ -114,7 +114,7 @@ object PetFeatures {
fun onSlotClick(event: SlotClickEvent) {
// Check for switching/removing pet manually
petMenuTitle.useMatch(MC.screenName ?: return) {
- if (event.slot.inventory is PlayerInventory) return
+ if (event.slot.container is Inventory) return
if (event.button != 0 && event.button != 1) return
val petData = event.stack.petData ?: return
if (petData.active == true) {
@@ -175,23 +175,23 @@ object PetFeatures {
}
}
- private fun renderLinesAndBackground(it: HudRenderEvent, lines: List<Text>) {
+ private fun renderLinesAndBackground(it: HudRenderEvent, lines: List<Component>) {
// Render background for the hud
if (TConfig.petOverlayHudStyle == PetOverlayHudStyles.PLAIN_BACKGROUND ||
TConfig.petOverlayHudStyle == PetOverlayHudStyles.COLOUR_BACKGROUND) {
var maxWidth = 0
- lines.forEach { if (MC.font.getWidth(it) > maxWidth) maxWidth = MC.font.getWidth(it.unformattedString) }
- val height = if (MC.font.fontHeight * lines.size > 32) MC.font.fontHeight * lines.size else 32
+ lines.forEach { if (MC.font.width(it) > maxWidth) maxWidth = MC.font.width(it.unformattedString) }
+ val height = if (MC.font.lineHeight * lines.size > 32) MC.font.lineHeight * lines.size else 32
it.context.fill(0, -3, 40 + maxWidth, height + 2, 0x80000000.toInt())
}
// Render text for the hud
lines.forEachIndexed { index, line ->
- it.context.drawText(
+ it.context.drawString(
MC.font,
- line.copy().withColor(Formatting.GRAY),
+ line.copy().withColor(ChatFormatting.GRAY),
36,
- MC.font.fontHeight * index,
+ MC.font.lineHeight * index,
-1,
true
)
@@ -217,13 +217,13 @@ object PetFeatures {
val tabPet = PetParser.parseTabWidget(TabListAPI.getWidgetLines(TabListAPI.WidgetName.PET))
if (pet == null && tabPet == null && tempTabPet == null && tempChatPet == null) {
// No data on current pet
- it.context.matrices.pushMatrix()
- TConfig.petOverlayHud.applyTransformations(JarvisIntegration.jarvis, it.context.matrices)
- val lines = mutableListOf<Text>()
- lines.add(Text.literal("" + Formatting.WHITE + "Unknown Pet"))
- lines.add(Text.literal("Open Pets Menu To Fix"))
+ it.context.pose().pushMatrix()
+ TConfig.petOverlayHud.applyTransformations(JarvisIntegration.jarvis, it.context.pose())
+ val lines = mutableListOf<Component>()
+ lines.add(Component.literal("" + ChatFormatting.WHITE + "Unknown Pet"))
+ lines.add(Component.literal("Open Pets Menu To Fix"))
renderLinesAndBackground(it, lines)
- it.context.matrices.popMatrix()
+ it.context.pose().popMatrix()
return
}
if (pet == null) {
@@ -255,71 +255,71 @@ object PetFeatures {
// Set the text for the HUD
- val lines = mutableListOf<Text>()
+ val lines = mutableListOf<Component>()
if (TConfig.petOverlayHudStyle == PetOverlayHudStyles.COLOUR_NO_BACKGROUND ||
TConfig.petOverlayHudStyle == PetOverlayHudStyles.COLOUR_BACKGROUND) {
// Colour Style
- lines.add(Text.literal("[Lvl ${pet.level}] ").append(Text.literal(pet.name)
- .withColor((Rarity.colourMap[pet.rarity]) ?: Formatting.WHITE)))
+ lines.add(Component.literal("[Lvl ${pet.level}] ").append(Component.literal(pet.name)
+ .withColor((Rarity.colourMap[pet.rarity]) ?: ChatFormatting.WHITE)))
- lines.add(Text.literal(pet.petItem))
+ lines.add(Component.literal(pet.petItem))
if (pet.level != pet.maxLevel) {
// Exp data
lines.add(
- Text.literal(
- "" + Formatting.YELLOW + "Required L${pet.level + 1}: ${shortFormat(pet.currentExp)}" +
- Formatting.GOLD + "/" + Formatting.YELLOW +
- "${shortFormat(pet.expForNextLevel)} " + Formatting.GOLD +
+ Component.literal(
+ "" + ChatFormatting.YELLOW + "Required L${pet.level + 1}: ${shortFormat(pet.currentExp)}" +
+ ChatFormatting.GOLD + "/" + ChatFormatting.YELLOW +
+ "${shortFormat(pet.expForNextLevel)} " + ChatFormatting.GOLD +
"(${formatPercent(pet.currentExp / pet.expForNextLevel)})"
)
)
lines.add(
- Text.literal(
- "" + Formatting.YELLOW + "Required L100: ${shortFormat(pet.totalExp)}" +
- Formatting.GOLD + "/" + Formatting.YELLOW +
- "${shortFormat(pet.expForMax)} " + Formatting.GOLD +
+ Component.literal(
+ "" + ChatFormatting.YELLOW + "Required L100: ${shortFormat(pet.totalExp)}" +
+ ChatFormatting.GOLD + "/" + ChatFormatting.YELLOW +
+ "${shortFormat(pet.expForMax)} " + ChatFormatting.GOLD +
"(${formatPercent(pet.totalExp / pet.expForMax)})"
)
)
} else {
// Overflow Exp data
- lines.add(Text.literal(
- "" + Formatting.AQUA + Formatting.BOLD + "MAX LEVEL"
+ lines.add(Component.literal(
+ "" + ChatFormatting.AQUA + ChatFormatting.BOLD + "MAX LEVEL"
))
- lines.add(Text.literal(
- "" + Formatting.GOLD + "+" + Formatting.YELLOW + "${shortFormat(pet.overflowExp)} XP"
+ lines.add(Component.literal(
+ "" + ChatFormatting.GOLD + "+" + ChatFormatting.YELLOW + "${shortFormat(pet.overflowExp)} XP"
))
}
} else if (TConfig.petOverlayHudStyle == PetOverlayHudStyles.PLAIN_NO_BACKGROUND ||
TConfig.petOverlayHudStyle == PetOverlayHudStyles.PLAIN_BACKGROUND) {
// Plain Style
- lines.add(Text.literal("[Lvl ${pet.level}] ").append(Text.literal(pet.name)
- .withColor((Rarity.colourMap[pet.rarity]) ?: Formatting.WHITE)))
+ lines.add(Component.literal("[Lvl ${pet.level}] ").append(Component.literal(pet.name)
+ .withColor((Rarity.colourMap[pet.rarity]) ?: ChatFormatting.WHITE)))
- lines.add(Text.literal(if (pet.petItem != "None" && pet.petItem != "Unknown")
+ lines.add(Component.literal(if (pet.petItem != "None" && pet.petItem != "Unknown")
pet.petItem.substring(2) else pet.petItem))
if (pet.level != pet.maxLevel) {
// Exp data
lines.add(
- Text.literal(
+ Component.literal(
"Required L${pet.level + 1}: ${shortFormat(pet.currentExp)}/" +
"${shortFormat(pet.expForNextLevel)} " +
"(${formatPercent(pet.currentExp / pet.expForNextLevel)})"
)
)
lines.add(
- Text.literal(
+ Component.literal(
"Required L100: ${shortFormat(pet.totalExp)}/${shortFormat(pet.expForMax)} " +
"(${formatPercent(pet.totalExp / pet.expForMax)})"
)
)
} else {
// Overflow Exp data
- lines.add(Text.literal(
+ lines.add(Component.literal(
"MAX LEVEL"
))
- lines.add(Text.literal(
+ lines.add(Component.literal(
"+${shortFormat(pet.overflowExp)} XP"
))
}
@@ -327,19 +327,19 @@ object PetFeatures {
// Render HUD
- it.context.matrices.pushMatrix()
- TConfig.petOverlayHud.applyTransformations(JarvisIntegration.jarvis, it.context.matrices)
+ it.context.pose().pushMatrix()
+ TConfig.petOverlayHud.applyTransformations(JarvisIntegration.jarvis, it.context.pose())
renderLinesAndBackground(it, lines)
// Draw the ItemStack
- it.context.matrices.pushMatrix()
- it.context.matrices.translate(-0.5F, -0.5F)
- it.context.matrices.scale(2f, 2f)
- it.context.drawItem(pet.petItemStack.value, 0, 0)
- it.context.matrices.popMatrix()
+ it.context.pose().pushMatrix()
+ it.context.pose().translate(-0.5F, -0.5F)
+ it.context.pose().scale(2f, 2f)
+ it.context.renderItem(pet.petItemStack.value, 0, 0)
+ it.context.pose().popMatrix()
- it.context.matrices.popMatrix()
+ it.context.pose().popMatrix()
}
}
@@ -404,7 +404,7 @@ object PetParser {
}
@OptIn(ExpensiveItemCacheApi::class)
- fun parseTabWidget(lines: List<Text>): ParsedPet? {
+ fun parseTabWidget(lines: List<Component>): ParsedPet? {
found.clear()
for (line in lines.reversed()) {
if (!found.containsKey("kat")) {
@@ -524,20 +524,20 @@ object PetParser {
}
data class ParsedPet(
- val name: String,
- val rarity: Rarity,
- var level: Int,
- val maxLevel: Int,
- val expLadder: ExpLadders.ExpLadder?,
- var currentExp: Double,
- var expForNextLevel: Double,
- var totalExp: Double,
- var totalExpBeforeLevel: Double,
- val expForMax: Double,
- var overflowExp: Double,
- var petItem: String,
- var petItemStack: Lazy<ItemStack>,
- var isComplete: Boolean
+ val name: String,
+ val rarity: Rarity,
+ var level: Int,
+ val maxLevel: Int,
+ val expLadder: ExpLadders.ExpLadder?,
+ var currentExp: Double,
+ var expForNextLevel: Double,
+ var totalExp: Double,
+ var totalExpBeforeLevel: Double,
+ val expForMax: Double,
+ var overflowExp: Double,
+ var petItem: String,
+ var petItemStack: Lazy<ItemStack>,
+ var isComplete: Boolean
) {
fun update(other: ParsedPet) {
// Update the pet data to reflect another instance (of itself)
diff --git a/src/main/kotlin/features/inventory/PriceData.kt b/src/main/kotlin/features/inventory/PriceData.kt
index 5f9268e..54802db 100644
--- a/src/main/kotlin/features/inventory/PriceData.kt
+++ b/src/main/kotlin/features/inventory/PriceData.kt
@@ -1,8 +1,8 @@
package moe.nea.firmament.features.inventory
import org.lwjgl.glfw.GLFW
-import net.minecraft.text.Text
-import net.minecraft.util.StringIdentifiable
+import net.minecraft.network.chat.Component
+import net.minecraft.util.StringRepresentable
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ItemTooltipEvent
import moe.nea.firmament.repo.HypixelStaticData
@@ -34,25 +34,25 @@ object PriceData {
}
}
- enum class AvgLowestBin : StringIdentifiable {
+ enum class AvgLowestBin : StringRepresentable {
OFF,
ONEDAYAVGLOWESTBIN,
THREEDAYAVGLOWESTBIN,
SEVENDAYAVGLOWESTBIN;
- override fun asString(): String {
+ override fun getSerializedName(): String {
return name
}
}
- fun formatPrice(label: Text, price: Double): Text {
- return Text.literal("")
+ fun formatPrice(label: Component, price: Double): Component {
+ return Component.literal("")
.yellow()
.bold()
.append(label)
.append(": ")
.append(
- Text.literal(formatCommas(price, fractionalDigits = 1))
+ Component.literal(formatCommas(price, fractionalDigits = 1))
.append(if (price != 1.0) " coins" else " coin")
.gold()
.bold()
@@ -84,7 +84,7 @@ object PriceData {
AvgLowestBin.OFF -> null
}
if (bazaarData != null) {
- it.lines.add(Text.literal(""))
+ it.lines.add(Component.literal(""))
it.lines.add(multiplierText)
it.lines.add(
formatPrice(
@@ -99,7 +99,7 @@ object PriceData {
)
)
} else if (lowestBin != null) {
- it.lines.add(Text.literal(""))
+ it.lines.add(Component.literal(""))
it.lines.add(multiplierText)
it.lines.add(
formatPrice(
diff --git a/src/main/kotlin/features/inventory/REIDependencyWarner.kt b/src/main/kotlin/features/inventory/REIDependencyWarner.kt
index 9e8a4db..e508016 100644
--- a/src/main/kotlin/features/inventory/REIDependencyWarner.kt
+++ b/src/main/kotlin/features/inventory/REIDependencyWarner.kt
@@ -6,8 +6,8 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlin.time.Duration.Companion.seconds
import net.minecraft.SharedConstants
-import net.minecraft.text.ClickEvent
-import net.minecraft.text.Text
+import net.minecraft.network.chat.ClickEvent
+import net.minecraft.network.chat.Component
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.thenExecute
@@ -31,22 +31,22 @@ object REIDependencyWarner {
var sentWarning = false
fun modrinthLink(slug: String) =
- "https://modrinth.com/mod/$slug/versions?g=${SharedConstants.getGameVersion().name()}&l=fabric"
+ "https://modrinth.com/mod/$slug/versions?g=${SharedConstants.getCurrentVersion().name()}&l=fabric"
- fun downloadButton(modName: String, modId: String, slug: String): Text {
+ fun downloadButton(modName: String, modId: String, slug: String): Component {
val alreadyDownloaded = FabricLoader.getInstance().isModLoaded(modId)
- return Text.literal(" - ")
+ return Component.literal(" - ")
.white()
- .append(Text.literal("[").aqua())
- .append(Text.translatable("firmament.download", modName)
- .styled { it.withClickEvent(ClickEvent.OpenUrl(URI (modrinthLink(slug)))) }
+ .append(Component.literal("[").aqua())
+ .append(Component.translatable("firmament.download", modName)
+ .withStyle { it.withClickEvent(ClickEvent.OpenUrl(URI (modrinthLink(slug)))) }
.yellow()
.also {
if (alreadyDownloaded)
- it.append(Text.translatable("firmament.download.already", modName)
+ it.append(Component.translatable("firmament.download.already", modName)
.lime())
})
- .append(Text.literal("]").aqua())
+ .append(Component.literal("]").aqua())
}
@Subscribe
@@ -60,11 +60,11 @@ object REIDependencyWarner {
delay(2.seconds)
// TODO: should we offer an automatic install that actually downloads the JARs and places them into the mod folder?
MC.sendChat(
- Text.translatable("firmament.reiwarning").red().bold().append("\n")
+ Component.translatable("firmament.reiwarning").red().bold().append("\n")
.append(downloadButton("RoughlyEnoughItems", reiModId, "rei")).append("\n")
.append(downloadButton("Architectury API", "architectury", "architectury-api")).append("\n")
.append(downloadButton("Cloth Config API", "cloth-config", "cloth-config")).append("\n")
- .append(Text.translatable("firmament.reiwarning.disable")
+ .append(Component.translatable("firmament.reiwarning.disable")
.clickCommand("/firm disablereiwarning")
.grey())
)
@@ -78,7 +78,7 @@ object REIDependencyWarner {
thenExecute {
RepoManager.TConfig.warnForMissingItemListMod = false
RepoManager.TConfig.markDirty()
- MC.sendChat(Text.translatable("firmament.reiwarning.disabled").yellow())
+ MC.sendChat(Component.translatable("firmament.reiwarning.disabled").yellow())
}
}
}
diff --git a/src/main/kotlin/features/inventory/SaveCursorPosition.kt b/src/main/kotlin/features/inventory/SaveCursorPosition.kt
index c523661..c492a75 100644
--- a/src/main/kotlin/features/inventory/SaveCursorPosition.kt
+++ b/src/main/kotlin/features/inventory/SaveCursorPosition.kt
@@ -3,7 +3,7 @@ package moe.nea.firmament.features.inventory
import org.lwjgl.glfw.GLFW
import kotlin.math.absoluteValue
import kotlin.time.Duration.Companion.milliseconds
-import net.minecraft.client.util.InputUtil
+import com.mojang.blaze3d.platform.InputConstants
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.TimeMark
import moe.nea.firmament.util.assertNotNullOr
@@ -43,9 +43,9 @@ object SaveCursorPosition {
(lastPosition.middle.first - middleX).absoluteValue < 1 &&
(lastPosition.middle.second - middleY).absoluteValue < 1
) {
- InputUtil.setCursorParameters(
+ InputConstants.grabOrReleaseMouse(
MC.window,
- InputUtil.GLFW_CURSOR_NORMAL,
+ InputConstants.CURSOR_NORMAL,
lastPosition.cursor.first,
lastPosition.cursor.second
)
diff --git a/src/main/kotlin/features/inventory/SlotLocking.kt b/src/main/kotlin/features/inventory/SlotLocking.kt
index 10c58cb..09afe80 100644
--- a/src/main/kotlin/features/inventory/SlotLocking.kt
+++ b/src/main/kotlin/features/inventory/SlotLocking.kt
@@ -16,17 +16,17 @@ import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.JsonPrimitive
import kotlinx.serialization.json.int
import kotlinx.serialization.serializer
-import net.minecraft.client.gl.RenderPipelines
-import net.minecraft.client.gui.screen.ingame.HandledScreen
-import net.minecraft.client.gui.screen.ingame.InventoryScreen
-import net.minecraft.entity.player.PlayerInventory
-import net.minecraft.item.ItemStack
-import net.minecraft.screen.GenericContainerScreenHandler
-import net.minecraft.screen.PlayerScreenHandler
-import net.minecraft.screen.slot.Slot
-import net.minecraft.screen.slot.SlotActionType
-import net.minecraft.util.Identifier
-import net.minecraft.util.StringIdentifiable
+import net.minecraft.client.renderer.RenderPipelines
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
+import net.minecraft.client.gui.screens.inventory.InventoryScreen
+import net.minecraft.world.entity.player.Inventory
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.inventory.ChestMenu
+import net.minecraft.world.inventory.InventoryMenu
+import net.minecraft.world.inventory.Slot
+import net.minecraft.world.inventory.ClickType
+import net.minecraft.resources.ResourceLocation
+import net.minecraft.util.StringRepresentable
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ClientInitEvent
import moe.nea.firmament.events.HandledScreenForegroundEvent
@@ -157,12 +157,12 @@ object SlotLocking {
val allowDroppingInDungeons by toggle("drop-in-dungeons") { true }
}
- enum class SlotRenderLinesMode : StringIdentifiable {
+ enum class SlotRenderLinesMode : StringRepresentable {
EVERYTHING,
ONLY_BOXES,
NOTHING;
- override fun asString(): String {
+ override fun getSerializedName(): String {
return name
}
}
@@ -175,25 +175,25 @@ object SlotLocking {
val lockedSlots
get() = currentWorldData?.lockedSlots
- fun isSalvageScreen(screen: HandledScreen<*>?): Boolean {
+ fun isSalvageScreen(screen: AbstractContainerScreen<*>?): Boolean {
if (screen == null) return false
return screen.title.unformattedString.contains("Salvage Item")
}
- fun isTradeScreen(screen: HandledScreen<*>?): Boolean {
+ fun isTradeScreen(screen: AbstractContainerScreen<*>?): Boolean {
if (screen == null) return false
- val handler = screen.screenHandler as? GenericContainerScreenHandler ?: return false
- if (handler.inventory.size() < 9) return false
- val middlePane = handler.inventory.getStack(handler.inventory.size() - 5)
+ val handler = screen.menu as? ChestMenu ?: return false
+ if (handler.container.containerSize < 9) return false
+ val middlePane = handler.container.getItem(handler.container.containerSize - 5)
if (middlePane == null) return false
return middlePane.displayNameAccordingToNbt?.unformattedString == "⇦ Your stuff"
}
- fun isNpcShop(screen: HandledScreen<*>?): Boolean {
+ fun isNpcShop(screen: AbstractContainerScreen<*>?): Boolean {
if (screen == null) return false
- val handler = screen.screenHandler as? GenericContainerScreenHandler ?: return false
- if (handler.inventory.size() < 9) return false
- val sellItem = handler.inventory.getStack(handler.inventory.size() - 5)
+ val handler = screen.menu as? ChestMenu ?: return false
+ if (handler.container.containerSize < 9) return false
+ val sellItem = handler.container.getItem(handler.container.containerSize - 5)
if (sellItem == null) return false
if (sellItem.displayNameAccordingToNbt.unformattedString == "Sell Item") return true
val lore = sellItem.loreAccordingToNbt
@@ -203,15 +203,15 @@ object SlotLocking {
@Subscribe
fun onSalvageProtect(event: IsSlotProtectedEvent) {
if (event.slot == null) return
- if (!event.slot.hasStack()) return
- if (event.slot.stack.displayNameAccordingToNbt.unformattedString != "Salvage Items") return
- val inv = event.slot.inventory
+ if (!event.slot.hasItem()) return
+ if (event.slot.item.displayNameAccordingToNbt.unformattedString != "Salvage Items") return
+ val inv = event.slot.container
var anyBlocked = false
- for (i in 0 until event.slot.index) {
- val stack = inv.getStack(i)
+ for (i in 0 until event.slot.containerSlot) {
+ val stack = inv.getItem(i)
if (IsSlotProtectedEvent.shouldBlockInteraction(
null,
- SlotActionType.THROW,
+ ClickType.THROW,
IsSlotProtectedEvent.MoveOrigin.SALVAGE,
stack
)
@@ -225,15 +225,15 @@ object SlotLocking {
@Subscribe
fun onProtectUuidItems(event: IsSlotProtectedEvent) {
- val doesNotDeleteItem = event.actionType == SlotActionType.SWAP
- || event.actionType == SlotActionType.PICKUP
- || event.actionType == SlotActionType.QUICK_MOVE
- || event.actionType == SlotActionType.QUICK_CRAFT
- || event.actionType == SlotActionType.CLONE
- || event.actionType == SlotActionType.PICKUP_ALL
+ val doesNotDeleteItem = event.actionType == ClickType.SWAP
+ || event.actionType == ClickType.PICKUP
+ || event.actionType == ClickType.QUICK_MOVE
+ || event.actionType == ClickType.QUICK_CRAFT
+ || event.actionType == ClickType.CLONE
+ || event.actionType == ClickType.PICKUP_ALL
val isSellOrTradeScreen =
isNpcShop(MC.handledScreen) || isTradeScreen(MC.handledScreen) || isSalvageScreen(MC.handledScreen)
- if ((!isSellOrTradeScreen || event.slot?.inventory !is PlayerInventory)
+ if ((!isSellOrTradeScreen || event.slot?.container !is Inventory)
&& doesNotDeleteItem
) return
val stack = event.itemStack ?: return
@@ -253,7 +253,7 @@ object SlotLocking {
@Subscribe
fun onProtectSlot(it: IsSlotProtectedEvent) {
- if (it.slot != null && it.slot.inventory is PlayerInventory && it.slot.index in (lockedSlots ?: setOf())) {
+ if (it.slot != null && it.slot.container is Inventory && it.slot.containerSlot in (lockedSlots ?: setOf())) {
it.protect()
}
}
@@ -275,14 +275,14 @@ object SlotLocking {
fun onQuickMoveBoundSlot(it: IsSlotProtectedEvent) {
val boundSlots = currentWorldData?.boundSlots ?: BoundSlots()
val isValidAction =
- it.actionType == SlotActionType.QUICK_MOVE || (it.actionType == SlotActionType.PICKUP && !TConfig.slotBindRequireShift)
+ it.actionType == ClickType.QUICK_MOVE || (it.actionType == ClickType.PICKUP && !TConfig.slotBindRequireShift)
if (!isValidAction) return
- val handler = MC.handledScreen?.screenHandler ?: return
- if (TConfig.slotBindOnlyInInv && handler !is PlayerScreenHandler)
+ val handler = MC.handledScreen?.menu ?: return
+ if (TConfig.slotBindOnlyInInv && handler !is InventoryMenu)
return
val slot = it.slot
- if (slot != null && it.slot.inventory is PlayerInventory) {
- val matchingSlots = boundSlots.findMatchingSlots(slot.index)
+ if (slot != null && it.slot.container is Inventory) {
+ val matchingSlots = boundSlots.findMatchingSlots(slot.containerSlot)
if (matchingSlots.isEmpty()) return
it.protectSilent()
val boundSlot = matchingSlots.singleOrNull() ?: return
@@ -298,7 +298,7 @@ object SlotLocking {
inventory as AccessorHandledScreen
val slot = inventory.focusedSlot_Firmament ?: return
- val stack = slot.stack ?: return
+ val stack = slot.item ?: return
if (stack.isHuntingBox()) {
MC.sendChat(
tr(
@@ -339,10 +339,10 @@ object SlotLocking {
val hotBarSlot = if (slot.isHotbar()) slot else storedSlot
val invSlot = if (slot.isHotbar()) storedSlot else slot
val boundSlots = currentWorldData?.boundSlots ?: return
- lockedSlots?.remove(hotBarSlot.index)
- lockedSlots?.remove(invSlot.index)
- boundSlots.removeDuplicateForInventory(invSlot.index)
- boundSlots.insert(hotBarSlot.index, invSlot.index)
+ lockedSlots?.remove(hotBarSlot.containerSlot)
+ lockedSlots?.remove(invSlot.containerSlot)
+ boundSlots.removeDuplicateForInventory(invSlot.containerSlot)
+ boundSlots.insert(hotBarSlot.containerSlot, invSlot.containerSlot)
DConfig.markDirty()
CommonSoundEffects.playSuccess()
return
@@ -356,7 +356,7 @@ object SlotLocking {
storedLockingSlot = null
val boundSlots = currentWorldData?.boundSlots ?: return
if (slot != null)
- boundSlots.removeAllInvolving(slot.index)
+ boundSlots.removeAllInvolving(slot.containerSlot)
}
}
@@ -393,12 +393,12 @@ object SlotLocking {
hotX + sx, hotY + sy,
color(anyHovered)
)
- event.context.drawStrokedRectangle(
+ event.context.submitOutline(
hotbarSlot.x + sx,
hotbarSlot.y + sy,
16, 16, color(hotbarSlot in highlitSlots).color
)
- event.context.drawStrokedRectangle( // TODO: 1.21.10
+ event.context.submitOutline( // TODO: 1.21.10
inventorySlot.x + sx,
inventorySlot.y + sy,
16, 16, color(inventorySlot in highlitSlots).color
@@ -411,12 +411,12 @@ object SlotLocking {
val draggingSlot = storedLockingSlot ?: return
val accScreen = event.screen as AccessorHandledScreen
val hoveredSlot = accScreen.focusedSlot_Firmament
- ?.takeIf { it.inventory is PlayerInventory }
+ ?.takeIf { it.container is Inventory }
?.takeIf { it == draggingSlot || it.isHotbar() != draggingSlot.isHotbar() }
val sx = accScreen.x_Firmament
val sy = accScreen.y_Firmament
val (borderX, borderY) = draggingSlot.lineCenter()
- event.context.drawStrokedRectangle(draggingSlot.x + sx, draggingSlot.y + sy, 16, 16, 0xFF00FF00u.toInt()) // TODO: 1.21.10
+ event.context.submitOutline(draggingSlot.x + sx, draggingSlot.y + sy, 16, 16, 0xFF00FF00u.toInt()) // TODO: 1.21.10
if (hoveredSlot == null) {
event.context.drawLine(
borderX + sx, borderY + sy,
@@ -430,7 +430,7 @@ object SlotLocking {
hovX + sx, hovY + sy,
me.shedaniel.math.Color.ofOpaque(0x00FF00)
)
- event.context.drawStrokedRectangle(
+ event.context.submitOutline(
hoveredSlot.x + sx,
hoveredSlot.y + sy,
16, 16, 0xFF00FF00u.toInt()
@@ -448,7 +448,7 @@ object SlotLocking {
fun Slot.isHotbar(): Boolean {
- return index < 9
+ return containerSlot < 9
}
@Subscribe
@@ -461,13 +461,13 @@ object SlotLocking {
fun toggleSlotLock(slot: Slot) {
val lockedSlots = lockedSlots ?: return
val boundSlots = currentWorldData?.boundSlots ?: BoundSlots()
- if (slot.inventory is PlayerInventory) {
- if (boundSlots.removeAllInvolving(slot.index)) {
+ if (slot.container is Inventory) {
+ if (boundSlots.removeAllInvolving(slot.containerSlot)) {
// intentionally do nothing
- } else if (slot.index in lockedSlots) {
- lockedSlots.remove(slot.index)
+ } else if (slot.containerSlot in lockedSlots) {
+ lockedSlots.remove(slot.containerSlot)
} else {
- lockedSlots.add(slot.index)
+ lockedSlots.add(slot.containerSlot)
}
DConfig.markDirty()
CommonSoundEffects.playSuccess()
@@ -480,7 +480,7 @@ object SlotLocking {
inventory as AccessorHandledScreen
val slot = inventory.focusedSlot_Firmament ?: return
- if (slot.inventory !is PlayerInventory) return
+ if (slot.container !is Inventory) return
if (it.matches(TConfig.slotBind)) {
storedLockingSlot = storedLockingSlot ?: slot
return
@@ -493,17 +493,17 @@ object SlotLocking {
@Subscribe
fun onRenderSlotOverlay(it: SlotRenderEvents.After) {
- val isSlotLocked = it.slot.inventory is PlayerInventory && it.slot.index in (lockedSlots ?: setOf())
- val isUUIDLocked = (it.slot.stack?.skyblockUUID) in (lockedUUIDs ?: setOf())
+ val isSlotLocked = it.slot.container is Inventory && it.slot.containerSlot in (lockedSlots ?: setOf())
+ val isUUIDLocked = (it.slot.item?.skyblockUUID) in (lockedUUIDs ?: setOf())
if (isSlotLocked || isUUIDLocked) {
- it.context.drawGuiTexture(
+ it.context.blitSprite(
RenderPipelines.GUI_TEXTURED,
when {
isSlotLocked ->
- (Identifier.of("firmament:slot_locked"))
+ (ResourceLocation.parse("firmament:slot_locked"))
isUUIDLocked ->
- (Identifier.of("firmament:uuid_locked"))
+ (ResourceLocation.parse("firmament:uuid_locked"))
else ->
error("unreachable")
diff --git a/src/main/kotlin/features/inventory/TimerInLore.kt b/src/main/kotlin/features/inventory/TimerInLore.kt
index d8eebda..9bb78c9 100644
--- a/src/main/kotlin/features/inventory/TimerInLore.kt
+++ b/src/main/kotlin/features/inventory/TimerInLore.kt
@@ -7,8 +7,8 @@ import java.time.format.DateTimeFormatterBuilder
import java.time.format.FormatStyle
import java.time.format.TextStyle
import java.time.temporal.ChronoField
-import net.minecraft.text.Text
-import net.minecraft.util.StringIdentifiable
+import net.minecraft.network.chat.Component
+import net.minecraft.util.StringRepresentable
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ItemTooltipEvent
import moe.nea.firmament.util.SBData
@@ -29,7 +29,7 @@ object TimerInLore {
val timerFormat by choice("format") { TimerFormat.SOCIALIST }
}
- enum class TimerFormat(val formatter: DateTimeFormatter) : StringIdentifiable {
+ enum class TimerFormat(val formatter: DateTimeFormatter) : StringRepresentable {
RFC(DateTimeFormatter.RFC_1123_DATE_TIME),
LOCAL(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM)),
SOCIALIST(
@@ -57,7 +57,7 @@ object TimerInLore {
constructor(format: String) : this(DateTimeFormatter.ofPattern(format))
- override fun asString(): String {
+ override fun getSerializedName(): String {
return name
}
}
@@ -142,9 +142,9 @@ object TimerInLore {
// TODO: install approximate time stabilization algorithm
event.lines.add(
i + 1,
- Text.literal("${countdownType.label}: ")
+ Component.literal("${countdownType.label}: ")
.grey()
- .append(Text.literal(TConfig.timerFormat.formatter.format(localTimer)).aqua())
+ .append(Component.literal(TConfig.timerFormat.formatter.format(localTimer)).aqua())
)
}
}
diff --git a/src/main/kotlin/features/inventory/WardrobeKeybinds.kt b/src/main/kotlin/features/inventory/WardrobeKeybinds.kt
index cdd646e..b3d4bfd 100644
--- a/src/main/kotlin/features/inventory/WardrobeKeybinds.kt
+++ b/src/main/kotlin/features/inventory/WardrobeKeybinds.kt
@@ -1,7 +1,7 @@
package moe.nea.firmament.features.inventory
import org.lwjgl.glfw.GLFW
-import net.minecraft.item.Items
+import net.minecraft.world.item.Items
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HandledScreenKeyPressedEvent
import moe.nea.firmament.util.MC
@@ -41,16 +41,16 @@ object WardrobeKeybinds {
) {
event.cancel()
- val handler = event.screen.screenHandler
+ val handler = event.screen.menu
val previousSlot = handler.getSlot(45)
val nextSlot = handler.getSlot(53)
val backPressed = event.matches(TConfig.changePageKeybind) || event.matches(TConfig.previousPage)
val nextPressed = event.matches(TConfig.changePageKeybind) || event.matches(TConfig.nextPage)
- if (backPressed && previousSlot.stack.item == Items.ARROW) {
+ if (backPressed && previousSlot.item.item == Items.ARROW) {
previousSlot.clickLeftMouseButton(handler)
- } else if (nextPressed && nextSlot.stack.item == Items.ARROW) {
+ } else if (nextPressed && nextSlot.item.item == Items.ARROW) {
nextSlot.clickLeftMouseButton(handler)
}
}
@@ -63,10 +63,10 @@ object WardrobeKeybinds {
event.cancel()
- val handler = event.screen.screenHandler
+ val handler = event.screen.menu
val invSlot = handler.getSlot(slot)
- val itemStack = invSlot.stack
+ val itemStack = invSlot.item
val isSelected = itemStack.item == Items.LIME_DYE
val isSelectable = itemStack.item == Items.PINK_DYE
if (!isSelectable && !isSelected) return
diff --git a/src/main/kotlin/features/inventory/buttons/InventoryButton.kt b/src/main/kotlin/features/inventory/buttons/InventoryButton.kt
index e31f4a0..0cb51ca 100644
--- a/src/main/kotlin/features/inventory/buttons/InventoryButton.kt
+++ b/src/main/kotlin/features/inventory/buttons/InventoryButton.kt
@@ -5,14 +5,14 @@ import me.shedaniel.math.Dimension
import me.shedaniel.math.Point
import me.shedaniel.math.Rectangle
import kotlinx.serialization.Serializable
-import net.minecraft.client.gl.RenderPipelines
-import net.minecraft.client.gui.DrawContext
-import net.minecraft.command.CommandRegistryAccess
-import net.minecraft.command.argument.ItemStackArgumentType
-import net.minecraft.item.ItemStack
-import net.minecraft.item.Items
-import net.minecraft.resource.featuretoggle.FeatureFlags
-import net.minecraft.util.Identifier
+import net.minecraft.client.renderer.RenderPipelines
+import net.minecraft.client.gui.GuiGraphics
+import net.minecraft.commands.CommandBuildContext
+import net.minecraft.commands.arguments.item.ItemArgument
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.item.Items
+import net.minecraft.world.flag.FeatureFlags
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.repo.ExpensiveItemCacheApi
import moe.nea.firmament.repo.ItemCache.asItemStack
import moe.nea.firmament.repo.ItemCache.isBroken
@@ -40,10 +40,10 @@ data class InventoryButton(
companion object {
val itemStackParser by lazy {
- ItemStackArgumentType.itemStack(
- CommandRegistryAccess.of(
+ ItemArgument.item(
+ CommandBuildContext.simple(
MC.defaultRegistries,
- FeatureFlags.VANILLA_FEATURES
+ FeatureFlags.VANILLA_SET
)
)
}
@@ -71,7 +71,7 @@ data class InventoryButton(
else icon
val componentItem =
runCatching {
- itemStackParser.parse(StringReader(giveSyntaxItem)).createStack(1, false)
+ itemStackParser.parse(StringReader(giveSyntaxItem)).createItemStack(1, false)
}.getOrNull()
if (componentItem != null)
itemStack = componentItem
@@ -84,23 +84,23 @@ data class InventoryButton(
}
}
- fun render(context: DrawContext) {
- context.drawGuiTexture(
+ fun render(context: GuiGraphics) {
+ context.blitSprite(
RenderPipelines.GUI_TEXTURED,
- Identifier.of("firmament:inventory_button_background"),
+ ResourceLocation.parse("firmament:inventory_button_background"),
0,
0,
myDimension.width,
myDimension.height,
)
if (isGigantic) {
- context.matrices.pushMatrix()
- context.matrices.translate(myDimension.width / 2F, myDimension.height / 2F)
- context.matrices.scale(2F)
- context.drawItem(getItem(), -8, -8)
- context.matrices.popMatrix()
+ context.pose().pushMatrix()
+ context.pose().translate(myDimension.width / 2F, myDimension.height / 2F)
+ context.pose().scale(2F)
+ context.renderItem(getItem(), -8, -8)
+ context.pose().popMatrix()
} else {
- context.drawItem(getItem(), 1, 1)
+ context.renderItem(getItem(), 1, 1)
}
}
diff --git a/src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt b/src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt
index d5d291c..6b6a2d6 100644
--- a/src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt
+++ b/src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt
@@ -8,17 +8,17 @@ import io.github.notenoughupdates.moulconfig.xml.Bind
import me.shedaniel.math.Point
import me.shedaniel.math.Rectangle
import org.lwjgl.glfw.GLFW
-import net.minecraft.client.MinecraftClient
-import net.minecraft.client.gui.Click
-import net.minecraft.client.gui.DrawContext
-import net.minecraft.client.gui.widget.ButtonWidget
-import net.minecraft.client.gui.widget.MultilineTextWidget
-import net.minecraft.client.gui.widget.TextWidget
-import net.minecraft.client.input.KeyInput
-import net.minecraft.client.util.InputUtil
-import net.minecraft.text.Text
-import net.minecraft.util.math.MathHelper
-import net.minecraft.util.math.Vec2f
+import net.minecraft.client.Minecraft
+import net.minecraft.client.input.MouseButtonEvent
+import net.minecraft.client.gui.GuiGraphics
+import net.minecraft.client.gui.components.Button
+import net.minecraft.client.gui.components.MultiLineTextWidget
+import net.minecraft.client.gui.components.StringWidget
+import net.minecraft.client.input.KeyEvent
+import com.mojang.blaze3d.platform.InputConstants
+import net.minecraft.network.chat.Component
+import net.minecraft.util.Mth
+import net.minecraft.world.phys.Vec2
import moe.nea.firmament.util.ClipboardUtils
import moe.nea.firmament.util.FragmentGuiScreen
import moe.nea.firmament.util.MC
@@ -60,69 +60,69 @@ class InventoryButtonEditor(
var buttons: MutableList<InventoryButton> =
InventoryButtons.DConfig.data.buttons.map { it.copy() }.toMutableList()
- override fun close() {
+ override fun onClose() {
InventoryButtons.DConfig.data.buttons = buttons
InventoryButtons.DConfig.markDirty()
- super.close()
+ super.onClose()
}
- override fun resize(client: MinecraftClient, width: Int, height: Int) {
+ override fun resize(client: Minecraft, width: Int, height: Int) {
lastGuiRect.move(
- MC.window.scaledWidth / 2 - lastGuiRect.width / 2,
- MC.window.scaledHeight / 2 - lastGuiRect.height / 2
+ MC.window.guiScaledWidth / 2 - lastGuiRect.width / 2,
+ MC.window.guiScaledHeight / 2 - lastGuiRect.height / 2
)
super.resize(client, width, height)
}
override fun init() {
super.init()
- addDrawableChild(
- MultilineTextWidget(
+ addRenderableWidget(
+ MultiLineTextWidget(
lastGuiRect.minX,
25,
- Text.translatable("firmament.inventory-buttons.delete"),
+ Component.translatable("firmament.inventory-buttons.delete"),
MC.font
).setCentered(true).setMaxWidth(lastGuiRect.width)
)
- addDrawableChild(
- MultilineTextWidget(
+ addRenderableWidget(
+ MultiLineTextWidget(
lastGuiRect.minX,
40,
- Text.translatable("firmament.inventory-buttons.info"),
+ Component.translatable("firmament.inventory-buttons.info"),
MC.font
).setCentered(true).setMaxWidth(lastGuiRect.width)
)
- addDrawableChild(
- ButtonWidget.builder(Text.translatable("firmament.inventory-buttons.reset")) {
+ addRenderableWidget(
+ Button.builder(Component.translatable("firmament.inventory-buttons.reset")) {
val newButtons = InventoryButtonTemplates.loadTemplate("TkVVQlVUVE9OUy9bXQ==")
if (newButtons != null)
buttons = moveButtons(newButtons.map { it.copy(command = it.command?.removePrefix("/")) })
}
- .position(lastGuiRect.minX + 10, lastGuiRect.minY + 10)
+ .pos(lastGuiRect.minX + 10, lastGuiRect.minY + 10)
.width(lastGuiRect.width - 20)
.build()
)
- addDrawableChild(
- ButtonWidget.builder(Text.translatable("firmament.inventory-buttons.load-preset")) {
+ addRenderableWidget(
+ Button.builder(Component.translatable("firmament.inventory-buttons.load-preset")) {
val t = ClipboardUtils.getTextContents()
val newButtons = InventoryButtonTemplates.loadTemplate(t)
if (newButtons != null)
buttons = moveButtons(newButtons.map { it.copy(command = it.command?.removePrefix("/")) })
}
- .position(lastGuiRect.minX + 10, lastGuiRect.minY + 35)
+ .pos(lastGuiRect.minX + 10, lastGuiRect.minY + 35)
.width(lastGuiRect.width - 20)
.build()
)
- addDrawableChild(
- ButtonWidget.builder(Text.translatable("firmament.inventory-buttons.save-preset")) {
+ addRenderableWidget(
+ Button.builder(Component.translatable("firmament.inventory-buttons.save-preset")) {
ClipboardUtils.setTextContent(InventoryButtonTemplates.saveTemplate(buttons))
}
- .position(lastGuiRect.minX + 10, lastGuiRect.minY + 60)
+ .pos(lastGuiRect.minX + 10, lastGuiRect.minY + 60)
.width(lastGuiRect.width - 20)
.build()
)
- addDrawableChild(
- ButtonWidget.builder(Text.translatable("firmament.inventory-buttons.simple-preset")) {
+ addRenderableWidget(
+ Button.builder(Component.translatable("firmament.inventory-buttons.simple-preset")) {
// Preset from NEU
// Credit: https://github.com/NotEnoughUpdates/NotEnoughUpdates/blob/9b1fcfebc646e9fb69f99006327faa3e734e5f51/src/main/resources/assets/notenoughupdates/invbuttons/presets.json#L900-L1348
val newButtons = InventoryButtonTemplates.loadTemplate(
@@ -131,12 +131,12 @@ class InventoryButtonEditor(
if (newButtons != null)
buttons = moveButtons(newButtons.map { it.copy(command = it.command?.removePrefix("/")) })
}
- .position(lastGuiRect.minX + 10, lastGuiRect.minY + 85)
+ .pos(lastGuiRect.minX + 10, lastGuiRect.minY + 85)
.width(lastGuiRect.width - 20)
.build()
)
- addDrawableChild(
- ButtonWidget.builder(Text.translatable("firmament.inventory-buttons.all-warps-preset")) {
+ addRenderableWidget(
+ Button.builder(Component.translatable("firmament.inventory-buttons.all-warps-preset")) {
// Preset from NEU
// Credit: https://github.com/NotEnoughUpdates/NotEnoughUpdates/blob/9b1fcfebc646e9fb69f99006327faa3e734e5f51/src/main/resources/assets/notenoughupdates/invbuttons/presets.json#L1817-L2276
val newButtons = InventoryButtonTemplates.loadTemplate(
@@ -145,7 +145,7 @@ class InventoryButtonEditor(
if (newButtons != null)
buttons = moveButtons(newButtons.map { it.copy(command = it.command?.removePrefix("/")) })
}
- .position(lastGuiRect.minX + 10, lastGuiRect.minY + 110)
+ .pos(lastGuiRect.minX + 10, lastGuiRect.minY + 110)
.width(lastGuiRect.width - 20)
.build()
)
@@ -195,42 +195,42 @@ class InventoryButtonEditor(
return newButtons
}
- override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) {
- context.matrices.pushMatrix()
+ override fun render(context: GuiGraphics, mouseX: Int, mouseY: Int, delta: Float) {
+ context.pose().pushMatrix()
PanelComponent.DefaultBackgroundRenderer.VANILLA
.render(
MoulConfigRenderContext(context),
lastGuiRect.minX, lastGuiRect.minY,
lastGuiRect.width, lastGuiRect.height,
)
- context.matrices.popMatrix()
+ context.pose().popMatrix()
super.render(context, mouseX, mouseY, delta)
for (button in buttons) {
val buttonPosition = button.getBounds(lastGuiRect)
- context.matrices.pushMatrix()
- context.matrices.translate(buttonPosition.minX.toFloat(), buttonPosition.minY.toFloat())
+ context.pose().pushMatrix()
+ context.pose().translate(buttonPosition.minX.toFloat(), buttonPosition.minY.toFloat())
button.render(context)
- context.matrices.popMatrix()
+ context.pose().popMatrix()
}
renderPopup(context, mouseX, mouseY, delta)
}
- override fun keyPressed(input: KeyInput): Boolean {
+ override fun keyPressed(input: KeyEvent): Boolean {
if (super.keyPressed(input)) return true
- if (input.keycode == GLFW.GLFW_KEY_ESCAPE) {
- close()
+ if (input.input() == GLFW.GLFW_KEY_ESCAPE) {
+ onClose()
return true
}
return false
}
- override fun mouseReleased(click: Click): Boolean {
+ override fun mouseReleased(click: MouseButtonEvent): Boolean {
if (super.mouseReleased(click)) return true
val clickedButton = buttons.firstOrNull { it.getBounds(lastGuiRect).contains(Point(click.x, click.y)) }
if (clickedButton != null && !justPerformedAClickAction) {
- if (InputUtil.isKeyPressed(
+ if (InputConstants.isKeyDown(
MC.window,
- InputUtil.GLFW_KEY_LEFT_CONTROL
+ InputConstants.KEY_LCONTROL
)
) Editor(clickedButton).delete()
else createPopup(
@@ -244,11 +244,11 @@ class InventoryButtonEditor(
return false
}
- override fun mouseDragged(click: Click, offsetX: Double, offsetY: Double): Boolean {
+ override fun mouseDragged(click: MouseButtonEvent, offsetX: Double, offsetY: Double): Boolean {
if (super.mouseDragged(click, offsetX, offsetY)) return true
- if (initialDragMousePosition.distanceSquared(Vec2f(click.x.toFloat(), click.y.toFloat())) >= 4 * 4) {
- initialDragMousePosition = Vec2f(-10F, -10F)
+ if (initialDragMousePosition.distanceToSqr(Vec2(click.x.toFloat(), click.y.toFloat())) >= 4 * 4) {
+ initialDragMousePosition = Vec2(-10F, -10F)
lastDraggedButton?.let { dragging ->
justPerformedAClickAction = true
val (anchorRight, anchorBottom, offsetX, offsetY) = getCoordsForMouse(click.x.toInt(), click.y.toInt())
@@ -272,7 +272,7 @@ class InventoryButtonEditor(
var lastDraggedButton: InventoryButton? = null
var justPerformedAClickAction = false
- var initialDragMousePosition = Vec2f(-10F, -10F)
+ var initialDragMousePosition = Vec2(-10F, -10F)
data class AnchoredCoords(
val anchorRight: Boolean,
@@ -286,9 +286,9 @@ class InventoryButtonEditor(
val anchorBottom = my > lastGuiRect.maxY
var offsetX = mx - if (anchorRight) lastGuiRect.maxX else lastGuiRect.minX
var offsetY = my - if (anchorBottom) lastGuiRect.maxY else lastGuiRect.minY
- if (InputUtil.isKeyPressed(MC.window, InputUtil.GLFW_KEY_LEFT_SHIFT)) {
- offsetX = MathHelper.floor(offsetX / 20F) * 20
- offsetY = MathHelper.floor(offsetY / 20F) * 20
+ if (InputConstants.isKeyDown(MC.window, InputConstants.KEY_LSHIFT)) {
+ offsetX = Mth.floor(offsetX / 20F) * 20
+ offsetY = Mth.floor(offsetY / 20F) * 20
}
val rect = InventoryButton(offsetX, offsetY, anchorRight, anchorBottom).getBounds(lastGuiRect)
if (rect.intersects(lastGuiRect)) return null
@@ -296,12 +296,12 @@ class InventoryButtonEditor(
return anchoredCoords
}
- override fun mouseClicked(click: Click, doubled: Boolean): Boolean {
+ override fun mouseClicked(click: MouseButtonEvent, doubled: Boolean): Boolean {
if (super.mouseClicked(click, doubled)) return true
val clickedButton = buttons.firstOrNull { it.getBounds(lastGuiRect).contains(click.x, click.y) }
if (clickedButton != null) {
lastDraggedButton = clickedButton
- initialDragMousePosition = Vec2f(click.y.toFloat(), click.y.toFloat())
+ initialDragMousePosition = Vec2(click.y.toFloat(), click.y.toFloat())
return true
}
val mx = click.x.toInt()
diff --git a/src/main/kotlin/features/inventory/buttons/InventoryButtonTemplates.kt b/src/main/kotlin/features/inventory/buttons/InventoryButtonTemplates.kt
index 082673e..c6ad14d 100644
--- a/src/main/kotlin/features/inventory/buttons/InventoryButtonTemplates.kt
+++ b/src/main/kotlin/features/inventory/buttons/InventoryButtonTemplates.kt
@@ -1,6 +1,6 @@
package moe.nea.firmament.features.inventory.buttons
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.Firmament
import moe.nea.firmament.util.ErrorUtil
import moe.nea.firmament.util.MC
@@ -17,7 +17,7 @@ object InventoryButtonTemplates {
ErrorUtil.catch<InventoryButton?>("Could not import button") {
Firmament.json.decodeFromString<InventoryButton>(it).also {
if (it.icon?.startsWith("extra:") == true) {
- MC.sendChat(Text.translatable("firmament.inventory-buttons.import-failed"))
+ MC.sendChat(Component.translatable("firmament.inventory-buttons.import-failed"))
}
}
}.or {
diff --git a/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt b/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt
index 47fdbe9..fa376bc 100644
--- a/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt
+++ b/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt
@@ -4,9 +4,9 @@ import me.shedaniel.math.Rectangle
import kotlinx.serialization.Serializable
import kotlinx.serialization.serializer
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.client.gui.screen.ingame.HandledScreen
-import net.minecraft.client.gui.screen.ingame.InventoryScreen
-import net.minecraft.text.Text
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
+import net.minecraft.client.gui.screens.inventory.InventoryScreen
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HandledScreenClickEvent
import moe.nea.firmament.events.HandledScreenForegroundEvent
@@ -14,7 +14,7 @@ import moe.nea.firmament.events.HandledScreenPushREIEvent
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.ScreenUtil
import moe.nea.firmament.util.TimeMark
-import moe.nea.firmament.util.accessors.getRectangle
+import moe.nea.firmament.util.accessors.getProperRectangle
import moe.nea.firmament.util.data.Config
import moe.nea.firmament.util.data.DataHolder
import moe.nea.firmament.util.data.ManagedConfig
@@ -39,7 +39,7 @@ object InventoryButtons {
var buttons: MutableList<InventoryButton> = mutableListOf()
)
- fun getValidButtons(screen: HandledScreen<*>): Sequence<InventoryButton> {
+ fun getValidButtons(screen: AbstractContainerScreen<*>): Sequence<InventoryButton> {
return DConfig.data.buttons.asSequence().filter { button ->
button.isValid() && (!TConfig.onlyInv || screen is InventoryScreen)
}
@@ -48,7 +48,7 @@ object InventoryButtons {
@Subscribe
fun onRectangles(it: HandledScreenPushREIEvent) {
- val bounds = it.screen.getRectangle()
+ val bounds = it.screen.getProperRectangle()
for (button in getValidButtons(it.screen)) {
val buttonBounds = button.getBounds(bounds)
it.block(buttonBounds)
@@ -57,7 +57,7 @@ object InventoryButtons {
@Subscribe
fun onClickScreen(it: HandledScreenClickEvent) {
- val bounds = it.screen.getRectangle()
+ val bounds = it.screen.getProperRectangle()
for (button in getValidButtons(it.screen)) {
val buttonBounds = button.getBounds(bounds)
if (buttonBounds.contains(it.mouseX, it.mouseY)) {
@@ -72,22 +72,22 @@ object InventoryButtons {
@Subscribe
fun onRenderForeground(it: HandledScreenForegroundEvent) {
- val bounds = it.screen.getRectangle()
+ val bounds = it.screen.getProperRectangle()
var hoveredComponent: InventoryButton? = null
for (button in getValidButtons(it.screen)) {
val buttonBounds = button.getBounds(bounds)
- it.context.matrices.pushMatrix()
- it.context.matrices.translate(buttonBounds.minX.toFloat(), buttonBounds.minY.toFloat())
+ it.context.pose().pushMatrix()
+ it.context.pose().translate(buttonBounds.minX.toFloat(), buttonBounds.minY.toFloat())
button.render(it.context)
- it.context.matrices.popMatrix()
+ it.context.pose().popMatrix()
if (buttonBounds.contains(it.mouseX, it.mouseY) && TConfig.hoverText && hoveredComponent == null) {
hoveredComponent = button
if (lastMouseMove.passedTime() > 0.6.seconds && lastHoveredComponent === button) {
- it.context.drawTooltip(
+ it.context.setComponentTooltipForNextFrame(
MC.font,
- listOf(Text.literal(button.command).gold()),
+ listOf(Component.literal(button.command).gold()),
buttonBounds.minX - 15,
buttonBounds.maxY + 20,
)
@@ -105,8 +105,8 @@ object InventoryButtons {
ScreenUtil.setScreenLater(
InventoryButtonEditor(
lastRectangle ?: Rectangle(
- MC.window.scaledWidth / 2 - 88,
- MC.window.scaledHeight / 2 - 83,
+ MC.window.guiScaledWidth / 2 - 88,
+ MC.window.guiScaledHeight / 2 - 83,
176, 166,
)
)
diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageBackingHandle.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageBackingHandle.kt
index d7346c2..964f415 100644
--- a/src/main/kotlin/features/inventory/storageoverlay/StorageBackingHandle.kt
+++ b/src/main/kotlin/features/inventory/storageoverlay/StorageBackingHandle.kt
@@ -4,9 +4,9 @@ package moe.nea.firmament.features.inventory.storageoverlay
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract
-import net.minecraft.client.gui.screen.Screen
-import net.minecraft.client.gui.screen.ingame.GenericContainerScreen
-import net.minecraft.screen.GenericContainerScreenHandler
+import net.minecraft.client.gui.screens.Screen
+import net.minecraft.client.gui.screens.inventory.ContainerScreen
+import net.minecraft.world.inventory.ChestMenu
import moe.nea.firmament.util.ifMatches
import moe.nea.firmament.util.unformattedString
@@ -16,19 +16,19 @@ import moe.nea.firmament.util.unformattedString
sealed interface StorageBackingHandle {
sealed interface HasBackingScreen {
- val handler: GenericContainerScreenHandler
+ val handler: ChestMenu
}
/**
* The main storage overview is open. Clicking on a slot will open that page. This page is accessible via `/storage`
*/
- data class Overview(override val handler: GenericContainerScreenHandler) : StorageBackingHandle, HasBackingScreen
+ data class Overview(override val handler: ChestMenu) : StorageBackingHandle, HasBackingScreen
/**
* An individual storage page is open. This may be a backpack or an enderchest page. This page is accessible via
* the [Overview] or via `/ec <index + 1>` for enderchest pages.
*/
- data class Page(override val handler: GenericContainerScreenHandler, val storagePageSlot: StoragePageSlot) :
+ data class Page(override val handler: ChestMenu, val storagePageSlot: StoragePageSlot) :
StorageBackingHandle, HasBackingScreen
companion object {
@@ -46,13 +46,13 @@ sealed interface StorageBackingHandle {
returnsNotNull() implies (screen != null)
}
if (screen == null) return null
- if (screen !is GenericContainerScreen) return null
+ if (screen !is ContainerScreen) return null
val title = screen.title.unformattedString
- if (title == "Storage") return Overview(screen.screenHandler)
+ if (title == "Storage") return Overview(screen.menu)
return title.ifMatches(enderChestName) {
- Page(screen.screenHandler, StoragePageSlot.ofEnderChestPage(it.groupValues[1].toInt()))
+ Page(screen.menu, StoragePageSlot.ofEnderChestPage(it.groupValues[1].toInt()))
} ?: title.ifMatches(backPackName) {
- Page(screen.screenHandler, StoragePageSlot.ofBackPackPage(it.groupValues[1].toInt()))
+ Page(screen.menu, StoragePageSlot.ofBackPackPage(it.groupValues[1].toInt()))
}
}
}
diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlay.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlay.kt
index 7dbb02a..7f96637 100644
--- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlay.kt
+++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlay.kt
@@ -3,12 +3,12 @@ package moe.nea.firmament.features.inventory.storageoverlay
import io.github.notenoughupdates.moulconfig.ChromaColour
import java.util.SortedMap
import kotlinx.serialization.serializer
-import net.minecraft.client.gui.screen.ingame.GenericContainerScreen
-import net.minecraft.client.gui.screen.ingame.HandledScreen
-import net.minecraft.entity.player.PlayerInventory
-import net.minecraft.item.Items
-import net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket
-import net.minecraft.text.Text
+import net.minecraft.client.gui.screens.inventory.ContainerScreen
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
+import net.minecraft.world.entity.player.Inventory
+import net.minecraft.world.item.Items
+import net.minecraft.network.protocol.game.ServerboundContainerClosePacket
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ChestInventoryUpdateEvent
import moe.nea.firmament.events.ScreenChangeEvent
@@ -71,7 +71,7 @@ object StorageOverlay {
(MC.screen as? StorageOverlayScreen)
?: (MC.handledScreen?.customGui as? StorageOverlayCustom)?.overview
?: return
- val stack = event.slot.stack ?: return
+ val stack = event.slot.item ?: return
val search = storageOverlayScreen.searchText.get().takeIf { it.isNotBlank() } ?: return
if (storageOverlayScreen.matchesSearch(stack, search)) {
event.context.fill(
@@ -100,7 +100,7 @@ object StorageOverlay {
@Subscribe
fun onClick(event: SlotClickEvent) {
- if (lastStorageOverlay != null && event.slot.inventory !is PlayerInventory && event.slot.index < 9
+ if (lastStorageOverlay != null && event.slot.container !is Inventory && event.slot.containerSlot < 9
&& event.stack.item != Items.BLACK_STAINED_GLASS_PANE
) {
skipNextStorageOverlayBackflip = true
@@ -111,18 +111,18 @@ object StorageOverlay {
fun onScreenChange(it: ScreenChangeEvent) {
if (it.old == null && it.new == null) return
val storageOverlayScreen = it.old as? StorageOverlayScreen
- ?: ((it.old as? HandledScreen<*>)?.customGui as? StorageOverlayCustom)?.overview
+ ?: ((it.old as? AbstractContainerScreen<*>)?.customGui as? StorageOverlayCustom)?.overview
var storageOverviewScreen = it.old as? StorageOverviewScreen
- val screen = it.new as? GenericContainerScreen
+ val screen = it.new as? ContainerScreen
rememberContent(currentHandler)
val oldHandler = currentHandler
currentHandler = StorageBackingHandle.fromScreen(screen)
if (storageOverviewScreen != null && oldHandler is StorageBackingHandle.HasBackingScreen) {
val player = MC.player
assert(player != null)
- player?.networkHandler?.sendPacket(CloseHandledScreenC2SPacket(oldHandler.handler.syncId))
- if (player?.currentScreenHandler === oldHandler.handler) {
- player.currentScreenHandler = player.playerScreenHandler
+ player?.connection?.send(ServerboundContainerClosePacket(oldHandler.handler.containerId))
+ if (player?.containerMenu === oldHandler.handler) {
+ player.containerMenu = player.inventoryMenu
}
}
storageOverviewScreen = storageOverviewScreen ?: lastStorageOverlay
@@ -164,7 +164,7 @@ object StorageOverlay {
handler: StorageBackingHandle.Overview,
data: SortedMap<StoragePageSlot, StorageData.StorageInventory>
) {
- for ((index, stack) in handler.handler.stacks.withIndex()) {
+ for ((index, stack) in handler.handler.items.withIndex()) { // TODO: replace with slot iteration
// Ignore unloaded item stacks
if (stack.isEmpty) continue
val slot = StoragePageSlot.fromOverviewSlotIndex(index) ?: continue
@@ -186,7 +186,7 @@ object StorageOverlay {
data: SortedMap<StoragePageSlot, StorageData.StorageInventory>
) {
val newStacks =
- VirtualInventory(handler.handler.stacks.take(handler.handler.rows * 9).drop(9).map { it.copy() })
+ VirtualInventory(handler.handler.items.take(handler.handler.rowCount * 9).drop(9).map { it.copy() })
data.compute(handler.storagePageSlot) { slot, existingInventory ->
(existingInventory ?: StorageData.StorageInventory(
slot.defaultName(),
diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt
index a4199c9..f291dba 100644
--- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt
+++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt
@@ -2,22 +2,22 @@ package moe.nea.firmament.features.inventory.storageoverlay
import me.shedaniel.math.Point
import me.shedaniel.math.Rectangle
-import net.minecraft.client.MinecraftClient
-import net.minecraft.client.gui.Click
-import net.minecraft.client.gui.DrawContext
-import net.minecraft.client.gui.screen.ingame.GenericContainerScreen
-import net.minecraft.client.input.CharInput
-import net.minecraft.client.input.KeyInput
-import net.minecraft.entity.player.PlayerInventory
-import net.minecraft.screen.slot.Slot
+import net.minecraft.client.Minecraft
+import net.minecraft.client.input.MouseButtonEvent
+import net.minecraft.client.gui.GuiGraphics
+import net.minecraft.client.gui.screens.inventory.ContainerScreen
+import net.minecraft.client.input.CharacterEvent
+import net.minecraft.client.input.KeyEvent
+import net.minecraft.world.entity.player.Inventory
+import net.minecraft.world.inventory.Slot
import moe.nea.firmament.mixins.accessor.AccessorHandledScreen
import moe.nea.firmament.util.customgui.CustomGui
import moe.nea.firmament.util.focusedItemStack
class StorageOverlayCustom(
- val handler: StorageBackingHandle,
- val screen: GenericContainerScreen,
- val overview: StorageOverlayScreen,
+ val handler: StorageBackingHandle,
+ val screen: ContainerScreen,
+ val overview: StorageOverlayScreen,
) : CustomGui() {
override fun onVoluntaryExit(): Boolean {
overview.isExiting = true
@@ -29,18 +29,18 @@ class StorageOverlayCustom(
return overview.getBounds()
}
- override fun afterSlotRender(context: DrawContext, slot: Slot) {
- if (slot.inventory !is PlayerInventory)
+ override fun afterSlotRender(context: GuiGraphics, slot: Slot) {
+ if (slot.container !is Inventory)
context.disableScissor()
}
- override fun beforeSlotRender(context: DrawContext, slot: Slot) {
- if (slot.inventory !is PlayerInventory)
+ override fun beforeSlotRender(context: GuiGraphics, slot: Slot) {
+ if (slot.container !is Inventory)
overview.createScissors(context)
}
override fun onInit() {
- overview.init(MinecraftClient.getInstance(), screen.width, screen.height)
+ overview.init(Minecraft.getInstance(), screen.width, screen.height)
overview.init()
screen as AccessorHandledScreen
screen.x_Firmament = overview.measurements.x
@@ -52,7 +52,7 @@ class StorageOverlayCustom(
override fun isPointOverSlot(slot: Slot, xOffset: Int, yOffset: Int, pointX: Double, pointY: Double): Boolean {
if (!super.isPointOverSlot(slot, xOffset, yOffset, pointX, pointY))
return false
- if (slot.inventory !is PlayerInventory) {
+ if (slot.container !is Inventory) {
if (!overview.getScrollPanelInner().contains(pointX, pointY))
return false
}
@@ -63,31 +63,31 @@ class StorageOverlayCustom(
return false
}
- override fun mouseReleased(click: Click): Boolean {
+ override fun mouseReleased(click: MouseButtonEvent): Boolean {
return overview.mouseReleased(click)
}
- override fun mouseDragged(click: Click, offsetX: Double, offsetY: Double): Boolean {
+ override fun mouseDragged(click: MouseButtonEvent, offsetX: Double, offsetY: Double): Boolean {
return overview.mouseDragged(click, offsetX, offsetY)
}
- override fun keyReleased(input: KeyInput): Boolean {
+ override fun keyReleased(input: KeyEvent): Boolean {
return overview.keyReleased(input)
}
- override fun keyPressed(input: KeyInput): Boolean {
+ override fun keyPressed(input: KeyEvent): Boolean {
return overview.keyPressed(input)
}
- override fun charTyped(input: CharInput): Boolean {
+ override fun charTyped(input: CharacterEvent): Boolean {
return overview.charTyped(input)
}
- override fun mouseClick(click: Click, doubled: Boolean): Boolean {
+ override fun mouseClick(click: MouseButtonEvent, doubled: Boolean): Boolean {
return overview.mouseClicked(click, doubled, (handler as? StorageBackingHandle.Page)?.storagePageSlot)
}
- override fun render(drawContext: DrawContext, delta: Float, mouseX: Int, mouseY: Int) {
+ override fun render(drawContext: GuiGraphics, delta: Float, mouseX: Int, mouseY: Int) {
overview.drawBackgrounds(drawContext)
overview.drawPages(
drawContext,
@@ -95,7 +95,7 @@ class StorageOverlayCustom(
mouseY,
delta,
(handler as? StorageBackingHandle.Page)?.storagePageSlot,
- screen.screenHandler.slots.take(screen.screenHandler.rows * 9).drop(9),
+ screen.menu.slots.take(screen.menu.rowCount * 9).drop(9),
Point((screen as AccessorHandledScreen).x_Firmament, screen.y_Firmament)
)
overview.drawScrollBar(drawContext)
@@ -103,7 +103,7 @@ class StorageOverlayCustom(
}
override fun moveSlot(slot: Slot) {
- val index = slot.index
+ val index = slot.containerSlot
if (index in 0..<36) {
val (x, y) = overview.getPlayerInventorySlotPosition(index)
slot.x = x - (screen as AccessorHandledScreen).x_Firmament
diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt
index d2fff9c..3e0bb4b 100644
--- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt
+++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt
@@ -13,17 +13,17 @@ import io.github.notenoughupdates.moulconfig.observer.Property
import java.util.TreeSet
import me.shedaniel.math.Point
import me.shedaniel.math.Rectangle
-import net.minecraft.client.gui.Click
-import net.minecraft.client.gui.DrawContext
-import net.minecraft.client.gui.screen.Screen
-import net.minecraft.client.gui.screen.ingame.HandledScreen
-import net.minecraft.client.input.CharInput
-import net.minecraft.client.input.KeyInput
-import net.minecraft.item.ItemStack
-import net.minecraft.screen.slot.Slot
-import net.minecraft.text.Text
-import net.minecraft.util.Formatting
-import net.minecraft.util.Identifier
+import net.minecraft.client.input.MouseButtonEvent
+import net.minecraft.client.gui.GuiGraphics
+import net.minecraft.client.gui.screens.Screen
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
+import net.minecraft.client.input.CharacterEvent
+import net.minecraft.client.input.KeyEvent
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.inventory.Slot
+import net.minecraft.network.chat.Component
+import net.minecraft.ChatFormatting
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.events.SlotRenderEvents
import moe.nea.firmament.gui.EmptyComponent
import moe.nea.firmament.gui.FirmButtonComponent
@@ -43,7 +43,7 @@ import moe.nea.firmament.util.render.enableScissorWithoutTranslation
import moe.nea.firmament.util.tr
import moe.nea.firmament.util.unformattedString
-class StorageOverlayScreen : Screen(Text.literal("")) {
+class StorageOverlayScreen : Screen(Component.literal("")) {
companion object {
val PLAYER_WIDTH = 184
@@ -122,20 +122,20 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
fun getMaxScroll() = lastRenderedInnerHeight.toFloat() - getScrollPanelInner().height
- val playerInventorySprite = Identifier.of("firmament:storageoverlay/player_inventory")
- val upperBackgroundSprite = Identifier.of("firmament:storageoverlay/upper_background")
- val slotRowSprite = Identifier.of("firmament:storageoverlay/storage_row")
- val scrollbarBackground = Identifier.of("firmament:storageoverlay/scroll_bar_background")
- val scrollbarKnob = Identifier.of("firmament:storageoverlay/scroll_bar_knob")
- val controllerBackground = Identifier.of("firmament:storageoverlay/storage_controls")
+ val playerInventorySprite = ResourceLocation.parse("firmament:storageoverlay/player_inventory")
+ val upperBackgroundSprite = ResourceLocation.parse("firmament:storageoverlay/upper_background")
+ val slotRowSprite = ResourceLocation.parse("firmament:storageoverlay/storage_row")
+ val scrollbarBackground = ResourceLocation.parse("firmament:storageoverlay/scroll_bar_background")
+ val scrollbarKnob = ResourceLocation.parse("firmament:storageoverlay/scroll_bar_knob")
+ val controllerBackground = ResourceLocation.parse("firmament:storageoverlay/storage_controls")
- override fun close() {
+ override fun onClose() {
isExiting = true
resetScroll()
- super.close()
+ super.onClose()
}
- override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) {
+ override fun render(context: GuiGraphics, mouseX: Int, mouseY: Int, delta: Float) {
super.render(context, mouseX, mouseY, delta)
drawBackgrounds(context)
drawPages(context, mouseX, mouseY, delta, null, null, Point())
@@ -148,7 +148,7 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
return scroll / getMaxScroll()
}
- fun drawScrollBar(context: DrawContext) {
+ fun drawScrollBar(context: GuiGraphics) {
val sbRect = getScrollBarRect()
context.drawGuiTexture(
scrollbarBackground,
@@ -164,8 +164,8 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
fun editPages() {
isExiting = true
- MC.instance.send {
- val hs = MC.screen as? HandledScreen<*>
+ MC.instance.schedule {
+ val hs = MC.screen as? AbstractContainerScreen<*>
if (StorageBackingHandle.fromScreen(hs) is StorageBackingHandle.Overview) {
hs.customGui = null
hs.init(MC.instance, width, height)
@@ -204,7 +204,7 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
guiContext.adopt(controlComponent)
}
- fun drawControls(context: DrawContext, mouseX: Int, mouseY: Int) {
+ fun drawControls(context: GuiGraphics, mouseX: Int, mouseY: Int) {
context.drawGuiTexture(
controllerBackground,
measurements.controlX,
@@ -219,7 +219,7 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
)
}
- fun drawBackgrounds(context: DrawContext) {
+ fun drawBackgrounds(context: GuiGraphics) {
context.drawGuiTexture(
upperBackgroundSprite,
measurements.x,
@@ -246,12 +246,12 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
)
}
- fun drawPlayerInventory(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) {
- val items = MC.player?.inventory?.mainStacks ?: return
+ fun drawPlayerInventory(context: GuiGraphics, mouseX: Int, mouseY: Int, delta: Float) {
+ val items = MC.player?.inventory?.nonEquipmentItems ?: return
items.withIndex().forEach { (index, item) ->
val (x, y) = getPlayerInventorySlotPosition(index)
- context.drawItem(item, x, y, 0)
- context.drawStackOverlay(textRenderer, item, x, y)
+ context.renderItem(item, x, y, 0)
+ context.renderItemDecorations(font, item, x, y)
}
}
@@ -273,7 +273,7 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
)
}
- fun createScissors(context: DrawContext) {
+ fun createScissors(context: GuiGraphics) {
val rect = getScrollPanelInner()
context.enableScissorWithoutTranslation(
rect.minX.toFloat(), rect.minY.toFloat(),
@@ -282,10 +282,10 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
}
fun drawPages(
- context: DrawContext, mouseX: Int, mouseY: Int, delta: Float,
- excluding: StoragePageSlot?,
- slots: List<Slot>?,
- slotOffset: Point
+ context: GuiGraphics, mouseX: Int, mouseY: Int, delta: Float,
+ excluding: StoragePageSlot?,
+ slots: List<Slot>?,
+ slotOffset: Point
) {
createScissors(context)
val data = StorageOverlay.Data.data ?: StorageData()
@@ -310,11 +310,11 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
get() = guiContext.focusedElement == knobStub
set(value) = knobStub.setFocus(value)
- override fun mouseClicked(click: Click, doubled: Boolean): Boolean {
+ override fun mouseClicked(click: MouseButtonEvent, doubled: Boolean): Boolean {
return mouseClicked(click, doubled, null)
}
- override fun mouseReleased(click: Click): Boolean {
+ override fun mouseReleased(click: MouseButtonEvent): Boolean {
if (knobGrabbed) {
knobGrabbed = false
return true
@@ -330,7 +330,7 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
return super.mouseReleased(click)
}
- override fun mouseDragged(click: Click, offsetX: Double, offsetY: Double): Boolean {
+ override fun mouseDragged(click: MouseButtonEvent, offsetX: Double, offsetY: Double): Boolean {
if (knobGrabbed) {
val sbRect = getScrollBarRect()
val percentage = (click.x - sbRect.getY()) / sbRect.getHeight()
@@ -341,7 +341,7 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
return super.mouseDragged(click, offsetX, offsetY)
}
- fun mouseClicked(click: Click, doubled: Boolean, activePage: StoragePageSlot?): Boolean {
+ fun mouseClicked(click: MouseButtonEvent, doubled: Boolean, activePage: StoragePageSlot?): Boolean {
guiContext.setFocusedElement(null) // Blur all elements. They will be refocused by clickMCComponentInPlace if in doubt, and we don't have any double click components.
val mouseX = click.x
val mouseY = click.y
@@ -374,12 +374,12 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
return false
}
- override fun charTyped(input: CharInput): Boolean {
+ override fun charTyped(input: CharacterEvent): Boolean {
if (typeMCComponentInPlace(
controlComponent,
measurements.controlX, measurements.controlY,
CONTROL_WIDTH, CONTROL_HEIGHT,
- KeyboardEvent.CharTyped(input.asString().first()) // TODO: i dont like this .first()
+ KeyboardEvent.CharTyped(input.codepointAsString().first()) // TODO: i dont like this .first()
)
) {
return true
@@ -387,12 +387,12 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
return super.charTyped(input)
}
- override fun keyReleased(input: KeyInput): Boolean {
+ override fun keyReleased(input: KeyEvent): Boolean {
if (typeMCComponentInPlace(
controlComponent,
measurements.controlX, measurements.controlY,
CONTROL_WIDTH, CONTROL_HEIGHT,
- KeyboardEvent.KeyPressed(input.keycode, input.scancode, false)
+ KeyboardEvent.KeyPressed(input.input(), input.scancode, false)
)
) {
return true
@@ -404,12 +404,12 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
return this === MC.screen // Fixes this UI closing the handled screen on Escape press.
}
- override fun keyPressed(input: KeyInput): Boolean {
+ override fun keyPressed(input: KeyEvent): Boolean {
if (typeMCComponentInPlace(
controlComponent,
measurements.controlX, measurements.controlY,
CONTROL_WIDTH, CONTROL_HEIGHT,
- KeyboardEvent.KeyPressed(input.keycode, input.scancode, true)
+ KeyboardEvent.KeyPressed(input.input(), input.scancode, true)
)
) {
return true
@@ -463,7 +463,7 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
val filter = getFilteredPages()
for ((page, inventory) in data.storageInventories.entries) {
if (page !in filter) continue
- val currentHeight = inventory.inventory?.let { it.rows * SLOT_SIZE + 6 + textRenderer.fontHeight }
+ val currentHeight = inventory.inventory?.let { it.rows * SLOT_SIZE + 6 + font.lineHeight }
?: 18
maxHeight = maxOf(maxHeight, currentHeight)
val rect = Rectangle(
@@ -484,22 +484,22 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
}
fun drawPage(
- context: DrawContext,
- x: Int,
- y: Int,
- page: StoragePageSlot,
- inventory: StorageData.StorageInventory,
- slots: List<Slot>?,
- slotOffset: Point,
- mouseX: Int,
- mouseY: Int,
+ context: GuiGraphics,
+ x: Int,
+ y: Int,
+ page: StoragePageSlot,
+ inventory: StorageData.StorageInventory,
+ slots: List<Slot>?,
+ slotOffset: Point,
+ mouseX: Int,
+ mouseY: Int,
): Int {
val inv = inventory.inventory
if (inv == null) {
context.drawGuiTexture(upperBackgroundSprite, x, y, PAGE_WIDTH, 18)
- context.drawText(
- textRenderer,
- Text.literal("TODO: open this page"),
+ context.drawString(
+ font,
+ Component.literal("TODO: open this page"),
x + 4,
y + 4,
-1,
@@ -509,34 +509,34 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
}
assertTrueOr(slots == null || slots.size == inv.stacks.size) { return 0 }
val name = inventory.title
- val pageHeight = inv.rows * SLOT_SIZE + 8 + textRenderer.fontHeight
+ val pageHeight = inv.rows * SLOT_SIZE + 8 + font.lineHeight
if (slots != null && StorageOverlay.TConfig.outlineActiveStoragePage)
- context.drawStrokedRectangle(
+ context.submitOutline(
x,
- y + 3 + textRenderer.fontHeight,
+ y + 3 + font.lineHeight,
PAGE_WIDTH,
inv.rows * SLOT_SIZE + 4,
StorageOverlay.TConfig.outlineActiveStoragePageColour.getEffectiveColourRGB()
)
- context.drawText(
- textRenderer, Text.literal(name), x + 6, y + 3,
+ context.drawString(
+ font, Component.literal(name), x + 6, y + 3,
if (slots == null) 0xFFFFFFFF.toInt() else 0xFFFFFF00.toInt(), true
)
context.drawGuiTexture(
slotRowSprite,
x + 2,
- y + 5 + textRenderer.fontHeight,
+ y + 5 + font.lineHeight,
PAGE_SLOTS_WIDTH,
inv.rows * SLOT_SIZE
)
inv.stacks.forEachIndexed { index, stack ->
val slotX = (index % 9) * SLOT_SIZE + x + 3
- val slotY = (index / 9) * SLOT_SIZE + y + 5 + textRenderer.fontHeight + 1
+ val slotY = (index / 9) * SLOT_SIZE + y + 5 + font.lineHeight + 1
if (slots == null) {
val fakeSlot = FakeSlot(stack, slotX, slotY)
SlotRenderEvents.Before.publish(SlotRenderEvents.Before(context, fakeSlot))
- context.drawItem(stack, slotX, slotY)
- context.drawStackOverlay(textRenderer, stack, slotX, slotY)
+ context.renderItem(stack, slotX, slotY)
+ context.renderItemDecorations(font, stack, slotX, slotY)
SlotRenderEvents.After.publish(SlotRenderEvents.After(context, fakeSlot))
val rect = getScrollPanelInner()
if (StorageOverlay.TConfig.showInactivePageTooltips && !stack.isEmpty &&
@@ -544,11 +544,11 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
mouseX <= slotX + 16 && mouseY <= slotY + 16 &&
mouseY >= rect.minY && mouseY <= rect.maxY) {
try {
- context.drawItemTooltip(textRenderer, stack, mouseX, mouseY)
+ context.setTooltipForNextFrame(font, stack, mouseX, mouseY)
} catch (e: IllegalStateException) {
- context.drawTooltip(textRenderer, listOf(Text.of(Formatting.RED.toString() +
- "Error Getting Tooltip!"), Text.of(Formatting.YELLOW.toString() +
- "Open page to fix" + Formatting.RESET)), mouseX, mouseY)
+ context.setComponentTooltipForNextFrame(font, listOf(Component.nullToEmpty(ChatFormatting.RED.toString() +
+ "Error Getting Tooltip!"), Component.nullToEmpty(ChatFormatting.YELLOW.toString() +
+ "Open page to fix" + ChatFormatting.RESET)), mouseX, mouseY)
}
}
} else {
diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt
index a55b5ac..3c40fc6 100644
--- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt
+++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt
@@ -4,19 +4,19 @@ package moe.nea.firmament.features.inventory.storageoverlay
import org.lwjgl.glfw.GLFW
import kotlin.math.max
-import net.minecraft.block.Blocks
-import net.minecraft.client.gui.Click
-import net.minecraft.client.gui.DrawContext
-import net.minecraft.client.gui.screen.Screen
-import net.minecraft.client.input.KeyInput
-import net.minecraft.item.Item
-import net.minecraft.item.Items
-import net.minecraft.text.Text
-import net.minecraft.util.DyeColor
+import net.minecraft.world.level.block.Blocks
+import net.minecraft.client.input.MouseButtonEvent
+import net.minecraft.client.gui.GuiGraphics
+import net.minecraft.client.gui.screens.Screen
+import net.minecraft.client.input.KeyEvent
+import net.minecraft.world.item.Item
+import net.minecraft.world.item.Items
+import net.minecraft.network.chat.Component
+import net.minecraft.world.item.DyeColor
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.toShedaniel
-class StorageOverviewScreen() : Screen(Text.empty()) {
+class StorageOverviewScreen() : Screen(Component.empty()) {
companion object {
val emptyStorageSlotItems = listOf<Item>(
Blocks.RED_STAINED_GLASS_PANE.asItem(),
@@ -37,19 +37,19 @@ class StorageOverviewScreen() : Screen(Text.empty()) {
scroll = scroll.coerceAtMost(getMaxScroll()).coerceAtLeast(0)
}
- override fun close() {
+ override fun onClose() {
if (!StorageOverlay.TConfig.retainScroll) scroll = 0
- super.close()
+ super.onClose()
}
- override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) {
+ override fun render(context: GuiGraphics, mouseX: Int, mouseY: Int, delta: Float) {
super.render(context, mouseX, mouseY, delta)
context.fill(0, 0, width, height, 0x90000000.toInt())
layoutedForEach { (key, value), offsetX, offsetY ->
- context.matrices.pushMatrix()
- context.matrices.translate(offsetX.toFloat(), offsetY.toFloat())
+ context.pose().pushMatrix()
+ context.pose().translate(offsetX.toFloat(), offsetY.toFloat())
renderStoragePage(context, value, mouseX - offsetX, mouseY - offsetY)
- context.matrices.popMatrix()
+ context.pose().popMatrix()
}
}
@@ -74,12 +74,12 @@ class StorageOverviewScreen() : Screen(Text.empty()) {
lastRenderedHeight = totalHeight + currentMaxHeight
}
- override fun mouseClicked(click: Click, doubled: Boolean): Boolean {
+ override fun mouseClicked(click: MouseButtonEvent, doubled: Boolean): Boolean {
layoutedForEach { (k, p), x, y ->
val rx = click.x - x
val ry = click.y - y
if (rx in (0.0..pageWidth.toDouble()) && ry in (0.0..getStorePageHeight(p).toDouble())) {
- close()
+ onClose()
StorageOverlay.lastStorageOverlay = this
k.navigateTo()
return true
@@ -89,7 +89,7 @@ class StorageOverviewScreen() : Screen(Text.empty()) {
}
fun getStorePageHeight(page: StorageData.StorageInventory): Int {
- return page.inventory?.rows?.let { it * 19 + MC.font.fontHeight + 2 } ?: 60
+ return page.inventory?.rows?.let { it * 19 + MC.font.lineHeight + 2 } ?: 60
}
override fun mouseScrolled(
@@ -106,31 +106,31 @@ class StorageOverviewScreen() : Screen(Text.empty()) {
private fun getMaxScroll() = lastRenderedHeight - height + 2 * StorageOverlay.TConfig.margin
- private fun renderStoragePage(context: DrawContext, page: StorageData.StorageInventory, mouseX: Int, mouseY: Int) {
- context.drawText(MC.font, page.title, 2, 2, -1, true)
+ private fun renderStoragePage(context: GuiGraphics, page: StorageData.StorageInventory, mouseX: Int, mouseY: Int) {
+ context.drawString(MC.font, page.title, 2, 2, -1, true)
val inventory = page.inventory
if (inventory == null) {
// TODO: Missing texture
context.fill(0, 0, pageWidth, 60, DyeColor.RED.toShedaniel().darker(4.0).color)
- context.drawCenteredTextWithShadow(MC.font, Text.literal("Not loaded yet"), pageWidth / 2, 30, -1)
+ context.drawCenteredString(MC.font, Component.literal("Not loaded yet"), pageWidth / 2, 30, -1)
return
}
for ((index, stack) in inventory.stacks.withIndex()) {
val x = (index % 9) * 19
- val y = (index / 9) * 19 + MC.font.fontHeight + 2
+ val y = (index / 9) * 19 + MC.font.lineHeight + 2
if (((mouseX - x) in 0 until 18) && ((mouseY - y) in 0 until 18)) {
context.fill(x, y, x + 18, y + 18, 0x80808080.toInt())
} else {
context.fill(x, y, x + 18, y + 18, 0x40808080.toInt())
}
- context.drawItem(stack, x + 1, y + 1)
- context.drawStackOverlay(MC.font, stack, x + 1, y + 1)
+ context.renderItem(stack, x + 1, y + 1)
+ context.renderItemDecorations(MC.font, stack, x + 1, y + 1)
}
}
- override fun keyPressed(input: KeyInput): Boolean {
- if (input.keycode == GLFW.GLFW_KEY_ESCAPE)
+ override fun keyPressed(input: KeyEvent): Boolean {
+ if (input.input() == GLFW.GLFW_KEY_ESCAPE)
isClosing = true
return super.keyPressed(input)
}
diff --git a/src/main/kotlin/features/inventory/storageoverlay/VirtualInventory.kt b/src/main/kotlin/features/inventory/storageoverlay/VirtualInventory.kt
index fddc189..69d686f 100644
--- a/src/main/kotlin/features/inventory/storageoverlay/VirtualInventory.kt
+++ b/src/main/kotlin/features/inventory/storageoverlay/VirtualInventory.kt
@@ -13,12 +13,12 @@ import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import kotlin.jvm.optionals.getOrNull
-import net.minecraft.item.ItemStack
-import net.minecraft.nbt.NbtCompound
+import net.minecraft.world.item.ItemStack
+import net.minecraft.nbt.CompoundTag
import net.minecraft.nbt.NbtIo
-import net.minecraft.nbt.NbtList
+import net.minecraft.nbt.ListTag
import net.minecraft.nbt.NbtOps
-import net.minecraft.nbt.NbtSizeTracker
+import net.minecraft.nbt.NbtAccounter
import moe.nea.firmament.Firmament
import moe.nea.firmament.features.inventory.storageoverlay.VirtualInventory.Serializer.writeToByteArray
import moe.nea.firmament.util.Base64Util
@@ -44,21 +44,21 @@ data class VirtualInventory(
object Serializer : KSerializer<VirtualInventory> {
fun writeToByteArray(value: VirtualInventory): ByteArray {
- val list = NbtList()
+ val list = ListTag()
val ops = getOps()
value.stacks.forEach {
- if (it.isEmpty) list.add(NbtCompound())
+ if (it.isEmpty) list.add(CompoundTag())
else list.add(ErrorUtil.catch("Could not serialize item") {
ItemStack.CODEC.encode(
it,
ops,
- NbtCompound()
+ CompoundTag()
).orThrow
}
- .or { NbtCompound() })
+ .or { CompoundTag() })
}
val baos = ByteArrayOutputStream()
- NbtIo.writeCompressed(NbtCompound().also { it.put(INVENTORY, list) }, baos)
+ NbtIo.writeCompressed(CompoundTag().also { it.put(INVENTORY, list) }, baos)
return baos.toByteArray()
}
@@ -68,11 +68,11 @@ data class VirtualInventory(
override fun deserialize(decoder: Decoder): VirtualInventory {
val s = decoder.decodeString()
- val n = NbtIo.readCompressed(ByteArrayInputStream(Base64Util.decodeBytes(s)), NbtSizeTracker.of(100_000_000))
+ val n = NbtIo.readCompressed(ByteArrayInputStream(Base64Util.decodeBytes(s)), NbtAccounter.create(100_000_000))
val items = n.getList(INVENTORY).getOrNull()
val ops = getOps()
return VirtualInventory(items?.map {
- it as NbtCompound
+ it as CompoundTag
if (it.isEmpty) ItemStack.EMPTY
else ErrorUtil.catch("Could not deserialize item") {
ItemStack.CODEC.parse(ops, it).orThrow
diff --git a/src/main/kotlin/features/items/BlockZapperOverlay.kt b/src/main/kotlin/features/items/BlockZapperOverlay.kt
index a853012..cc58f8a 100644
--- a/src/main/kotlin/features/items/BlockZapperOverlay.kt
+++ b/src/main/kotlin/features/items/BlockZapperOverlay.kt
@@ -2,12 +2,12 @@ package moe.nea.firmament.features.items
import io.github.notenoughupdates.moulconfig.ChromaColour
import java.util.LinkedList
-import net.minecraft.block.Block
-import net.minecraft.block.BlockState
-import net.minecraft.block.Blocks
-import net.minecraft.util.hit.BlockHitResult
-import net.minecraft.util.hit.HitResult
-import net.minecraft.util.math.BlockPos
+import net.minecraft.world.level.block.Block
+import net.minecraft.world.level.block.state.BlockState
+import net.minecraft.world.level.block.Blocks
+import net.minecraft.world.phys.BlockHitResult
+import net.minecraft.world.phys.HitResult
+import net.minecraft.core.BlockPos
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.WorldKeyboardEvent
import moe.nea.firmament.events.WorldRenderLastEvent
@@ -64,10 +64,10 @@ object BlockZapperOverlay {
fun renderBlockZapperOverlay(event: WorldRenderLastEvent) {
if (!TConfig.blockZapperOverlay) return
val player = MC.player ?: return
- val world = player.world ?: return
+ val world = player.level ?: return
val heldItem = MC.stackInHand
if (heldItem.skyBlockId != SkyBlockItems.BLOCK_ZAPPER) return
- val hitResult = MC.instance.crosshairTarget ?: return
+ val hitResult = MC.instance.hitResult ?: return
val zapperBlocks: HashSet<BlockPos> = HashSet()
val returnablePositions = LinkedList<BlockPos>()
@@ -77,7 +77,7 @@ object BlockZapperOverlay {
val firstBlockState: BlockState = world.getBlockState(pos)
val block = firstBlockState.block
- val initialAboveBlock = world.getBlockState(pos.up()).block
+ val initialAboveBlock = world.getBlockState(pos.above()).block
if (!bannedZapper.contains(initialAboveBlock) && !bannedZapper.contains(block)) {
var i = 0
while (i < 164) {
@@ -87,13 +87,13 @@ object BlockZapperOverlay {
val availableNeighbors: MutableList<BlockPos> = ArrayList()
for (offset in zapperOffsets) {
- val newPos = pos.add(offset)
+ val newPos = pos.offset(offset)
if (zapperBlocks.contains(newPos)) continue
val state: BlockState? = world.getBlockState(newPos)
if (state != null && state.block === block) {
- val above = newPos.up()
+ val above = newPos.above()
val aboveBlock = world.getBlockState(above).block
if (!bannedZapper.contains(aboveBlock)) {
availableNeighbors.add(newPos)
@@ -118,7 +118,7 @@ object BlockZapperOverlay {
}
RenderInWorldContext.renderInWorld(event) {
- if (MC.player?.isSneaking ?: false) {
+ if (MC.player?.isShiftKeyDown ?: false) {
zapperBlocks.forEach {
block(it, TConfig.color.getEffectiveColourRGB())
}
diff --git a/src/main/kotlin/features/items/BonemerangOverlay.kt b/src/main/kotlin/features/items/BonemerangOverlay.kt
index 1310154..3f16922 100644
--- a/src/main/kotlin/features/items/BonemerangOverlay.kt
+++ b/src/main/kotlin/features/items/BonemerangOverlay.kt
@@ -2,11 +2,11 @@ package moe.nea.firmament.features.items
import me.shedaniel.math.Color
import org.joml.Vector2i
-import net.minecraft.entity.LivingEntity
-import net.minecraft.entity.decoration.ArmorStandEntity
-import net.minecraft.entity.player.PlayerEntity
-import net.minecraft.util.Formatting
-import net.minecraft.util.math.Box
+import net.minecraft.world.entity.LivingEntity
+import net.minecraft.world.entity.decoration.ArmorStand
+import net.minecraft.world.entity.player.Player
+import net.minecraft.ChatFormatting
+import net.minecraft.world.phys.AABB
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.EntityRenderTintEvent
import moe.nea.firmament.events.HudRenderEvent
@@ -31,18 +31,18 @@ object BonemerangOverlay {
fun getEntities(): MutableSet<LivingEntity> {
val entities = mutableSetOf<LivingEntity>()
- val camera = MC.camera as? PlayerEntity ?: return entities
+ val camera = MC.camera as? Player ?: return entities
val player = MC.player ?: return entities
- val world = player.world ?: return entities
+ val world = player.level ?: return entities
- val cameraPos = camera.eyePos
- val rayDirection = camera.rotationVector.normalize()
- val endPos = cameraPos.add(rayDirection.multiply(15.0))
- val foundEntities = world.getOtherEntities(camera, Box(cameraPos, endPos).expand(1.0))
+ val cameraPos = camera.eyePosition
+ val rayDirection = camera.lookAngle.normalize()
+ val endPos = cameraPos.add(rayDirection.scale(15.0))
+ val foundEntities = world.getEntities(camera, AABB(cameraPos, endPos).inflate(1.0))
for (entity in foundEntities) {
- if (entity !is LivingEntity || entity is ArmorStandEntity || entity.isInvisible) continue
- val hitResult = entity.boundingBox.expand(0.35).raycast(cameraPos, endPos).orElse(null)
+ if (entity !is LivingEntity || entity is ArmorStand || entity.isInvisible) continue
+ val hitResult = entity.boundingBox.inflate(0.35).clip(cameraPos, endPos).orElse(null)
if (hitResult != null) entities.add(entity)
}
@@ -66,7 +66,7 @@ object BonemerangOverlay {
if (event.entity !in entities) return
val tintOverlay by lazy {
- TintedOverlayTexture().setColor(Color.ofOpaque(Formatting.BLUE.colorValue!!))
+ TintedOverlayTexture().setColor(Color.ofOpaque(ChatFormatting.BLUE.color!!))
}
event.renderState.overlayTexture_firmament = tintOverlay
@@ -80,15 +80,15 @@ object BonemerangOverlay {
val entities = getEntities()
- it.context.matrices.pushMatrix()
- TConfig.bonemerangOverlayHud.applyTransformations(it.context.matrices)
- it.context.drawText(
+ it.context.pose().pushMatrix()
+ TConfig.bonemerangOverlayHud.applyTransformations(it.context.pose())
+ it.context.drawString(
MC.font, String.format(
tr(
"firmament.bonemerang-overlay.bonemerang-overlay.display", "Bonemerang Targets: %s"
).string, entities.size
), 0, 0, -1, true
)
- it.context.matrices.popMatrix()
+ it.context.pose().popMatrix()
}
}
diff --git a/src/main/kotlin/features/items/EtherwarpOverlay.kt b/src/main/kotlin/features/items/EtherwarpOverlay.kt
index 5f32a96..a59fcbd 100644
--- a/src/main/kotlin/features/items/EtherwarpOverlay.kt
+++ b/src/main/kotlin/features/items/EtherwarpOverlay.kt
@@ -1,17 +1,17 @@
package moe.nea.firmament.features.items
import io.github.notenoughupdates.moulconfig.ChromaColour
-import net.minecraft.block.Blocks
-import net.minecraft.registry.entry.RegistryEntry
-import net.minecraft.registry.tag.BlockTags
-import net.minecraft.registry.tag.TagKey
-import net.minecraft.text.Text
-import net.minecraft.util.hit.BlockHitResult
-import net.minecraft.util.hit.HitResult
-import net.minecraft.util.math.BlockPos
-import net.minecraft.util.math.Vec3d
-import net.minecraft.util.shape.VoxelShapes
-import net.minecraft.world.BlockView
+import net.minecraft.world.level.block.Blocks
+import net.minecraft.core.Holder
+import net.minecraft.tags.BlockTags
+import net.minecraft.tags.TagKey
+import net.minecraft.network.chat.Component
+import net.minecraft.world.phys.BlockHitResult
+import net.minecraft.world.phys.HitResult
+import net.minecraft.core.BlockPos
+import net.minecraft.world.phys.Vec3
+import net.minecraft.world.phys.shapes.Shapes
+import net.minecraft.world.level.BlockGetter
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.WorldRenderLastEvent
import moe.nea.firmament.util.MC
@@ -41,7 +41,7 @@ object EtherwarpOverlay {
var failureText by toggle("failure-text") { false }
}
- enum class EtherwarpResult(val label: Text?, val color: () -> ChromaColour) {
+ enum class EtherwarpResult(val label: Component?, val color: () -> ChromaColour) {
SUCCESS(null, TConfig::cubeColour),
INTERACTION_BLOCKED(
tr("firmament.etherwarp.fail.tooclosetointeractable", "Too close to interactable"),
@@ -76,10 +76,10 @@ object EtherwarpOverlay {
)
data class Checker<T>(
- val direct: Set<T>,
- val byTag: Set<TagKey<T>>,
+ val direct: Set<T>,
+ val byTag: Set<TagKey<T>>,
) {
- fun matches(entry: RegistryEntry<T>): Boolean {
+ fun matches(entry: Holder<T>): Boolean {
return entry.value() in direct || checkTags(entry, byTag)
}
}
@@ -123,34 +123,34 @@ object EtherwarpOverlay {
)
- fun <T> checkTags(holder: RegistryEntry<out T>, set: Set<TagKey<out T>>) =
- holder.streamTags()
+ fun <T> checkTags(holder: Holder<out T>, set: Set<TagKey<out T>>) =
+ holder.tags()
.anyMatch(set::contains)
- fun isEtherwarpTransparent(world: BlockView, blockPos: BlockPos): Boolean {
+ fun isEtherwarpTransparent(world: BlockGetter, blockPos: BlockPos): Boolean {
val blockState = world.getBlockState(blockPos)
val block = blockState.block
- if (etherwarpConsidersFat.matches(blockState.registryEntry))
+ if (etherwarpConsidersFat.matches(blockState.blockHolder))
return false
- if (block.defaultState.getCollisionShape(world, blockPos).isEmpty)
+ if (block.defaultBlockState().getCollisionShape(world, blockPos).isEmpty)
return true
- if (etherwarpHallpasses.matches(blockState.registryEntry))
+ if (etherwarpHallpasses.matches(blockState.blockHolder))
return true
return false
}
sealed interface EtherwarpBlockHit {
- data class BlockHit(val blockPos: BlockPos, val accuratePos: Vec3d?) : EtherwarpBlockHit
+ data class BlockHit(val blockPos: BlockPos, val accuratePos: Vec3?) : EtherwarpBlockHit
data object Miss : EtherwarpBlockHit
}
- fun raycastWithEtherwarpTransparency(world: BlockView, start: Vec3d, end: Vec3d): EtherwarpBlockHit {
- return BlockView.raycast<EtherwarpBlockHit, Unit>(
+ fun raycastWithEtherwarpTransparency(world: BlockGetter, start: Vec3, end: Vec3): EtherwarpBlockHit {
+ return BlockGetter.traverseBlocks<EtherwarpBlockHit, Unit>(
start, end, Unit,
{ _, blockPos ->
if (isEtherwarpTransparent(world, blockPos)) {
- return@raycast null
+ return@traverseBlocks null
}
// val defaultedState = world.getBlockState(blockPos).block.defaultState
// val hitShape = defaultedState.getCollisionShape(
@@ -161,8 +161,8 @@ object EtherwarpOverlay {
// if (world.raycastBlock(start, end, blockPos, hitShape, defaultedState) == null) {
// return@raycast null
// }
- val partialResult = world.raycastBlock(start, end, blockPos, VoxelShapes.fullCube(), world.getBlockState(blockPos).block.defaultState)
- return@raycast EtherwarpBlockHit.BlockHit(blockPos, partialResult?.pos)
+ val partialResult = world.clipWithInteractionOverride(start, end, blockPos, Shapes.block(), world.getBlockState(blockPos).block.defaultBlockState())
+ return@traverseBlocks EtherwarpBlockHit.BlockHit(blockPos, partialResult?.location)
},
{ EtherwarpBlockHit.Miss })
}
@@ -176,8 +176,8 @@ object EtherwarpOverlay {
fun renderEtherwarpOverlay(event: WorldRenderLastEvent) {
if (!TConfig.etherwarpOverlay) return
val player = MC.player ?: return
- if (TConfig.onlyShowWhileSneaking && !player.isSneaking) return
- val world = player.world
+ if (TConfig.onlyShowWhileSneaking && !player.isShiftKeyDown) return
+ val world = player.level
val heldItem = MC.stackInHand
val etherwarpTyp = run {
if (heldItem.extraAttributes.contains("ethermerge"))
@@ -188,12 +188,12 @@ object EtherwarpOverlay {
return
}
val playerEyeHeight = // Sneaking: 1.27 (1.21) 1.54 (1.8.9) / Upright: 1.62 (1.8.9,1.21)
- if (player.isSneaking || etherwarpTyp == EtherwarpItemKind.MERGED)
+ if (player.isShiftKeyDown || etherwarpTyp == EtherwarpItemKind.MERGED)
(if (SBData.skyblockLocation?.isModernServer ?: false) 1.27 else 1.54)
else 1.62
- val playerEyePos = player.pos.add(0.0, playerEyeHeight, 0.0)
+ val playerEyePos = player.position.add(0.0, playerEyeHeight, 0.0)
val start = playerEyePos
- val end = player.getRotationVec(0F).multiply(160.0).add(playerEyePos)
+ val end = player.getViewVector(0F).scale(160.0).add(playerEyePos)
val hitResult = raycastWithEtherwarpTransparency(
world,
start,
@@ -202,15 +202,15 @@ object EtherwarpOverlay {
if (hitResult !is EtherwarpBlockHit.BlockHit) return
val blockPos = hitResult.blockPos
val success = run {
- if (!isEtherwarpTransparent(world, blockPos.up()))
+ if (!isEtherwarpTransparent(world, blockPos.above()))
EtherwarpResult.OCCUPIED
- else if (!isEtherwarpTransparent(world, blockPos.up(2)))
+ else if (!isEtherwarpTransparent(world, blockPos.above(2)))
EtherwarpResult.OCCUPIED
- else if (playerEyePos.squaredDistanceTo(hitResult.accuratePos ?: blockPos.toCenterPos()) > 61 * 61)
+ else if (playerEyePos.distanceToSqr(hitResult.accuratePos ?: blockPos.center) > 61 * 61)
EtherwarpResult.TOO_DISTANT
- else if ((MC.instance.crosshairTarget as? BlockHitResult)
+ else if ((MC.instance.hitResult as? BlockHitResult)
?.takeIf { it.type == HitResult.Type.BLOCK }
- ?.let { interactionBlocked.matches(world.getBlockState(it.blockPos).registryEntry) }
+ ?.let { interactionBlocked.matches(world.getBlockState(it.blockPos).blockHolder) }
?: false
)
EtherwarpResult.INTERACTION_BLOCKED
@@ -225,7 +225,7 @@ object EtherwarpOverlay {
)
if (TConfig.wireframe) wireframeCube(blockPos, 10f)
if (TConfig.failureText && success.label != null) {
- withFacingThePlayer(blockPos.toCenterPos()) {
+ withFacingThePlayer(blockPos.center) {
text(success.label)
}
}
diff --git a/src/main/kotlin/features/macros/ComboProcessor.kt b/src/main/kotlin/features/macros/ComboProcessor.kt
index a01f8b7..9dadb80 100644
--- a/src/main/kotlin/features/macros/ComboProcessor.kt
+++ b/src/main/kotlin/features/macros/ComboProcessor.kt
@@ -1,7 +1,7 @@
package moe.nea.firmament.features.macros
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HudRenderEvent
import moe.nea.firmament.events.TickEvent
@@ -46,14 +46,14 @@ object ComboProcessor {
fun onRender(event: HudRenderEvent) {
if (!isInputting) return
if (!event.isRenderingHud) return
- event.context.matrices.pushMatrix()
+ event.context.pose().pushMatrix()
val width = 120
- event.context.matrices.translate(
- (MC.window.scaledWidth - width) / 2F,
- (MC.window.scaledHeight) / 2F + 8
+ event.context.pose().translate(
+ (MC.window.guiScaledWidth - width) / 2F,
+ (MC.window.guiScaledHeight) / 2F + 8
)
val breadCrumbText = breadCrumbs.joinToString(" > ")
- event.context.drawText(
+ event.context.drawString(
MC.font,
tr("firmament.combo.active", "Current Combo: ").append(breadCrumbText),
0,
@@ -61,19 +61,19 @@ object ComboProcessor {
-1,
true
)
- event.context.matrices.translate(0F, MC.font.fontHeight + 2F)
+ event.context.pose().translate(0F, MC.font.lineHeight + 2F)
for ((key, value) in activeTrie.nodes) {
- event.context.drawText(
+ event.context.drawString(
MC.font,
- Text.literal("$breadCrumbText > $key: ").append(value.label),
+ Component.literal("$breadCrumbText > $key: ").append(value.label),
0,
0,
-1,
true
)
- event.context.matrices.translate(0F, MC.font.fontHeight + 1F)
+ event.context.pose().translate(0F, MC.font.lineHeight + 1F)
}
- event.context.matrices.popMatrix()
+ event.context.pose().popMatrix()
}
@Subscribe
diff --git a/src/main/kotlin/features/macros/HotkeyAction.kt b/src/main/kotlin/features/macros/HotkeyAction.kt
index 011f797..18c95bc 100644
--- a/src/main/kotlin/features/macros/HotkeyAction.kt
+++ b/src/main/kotlin/features/macros/HotkeyAction.kt
@@ -2,21 +2,21 @@ package moe.nea.firmament.features.macros
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.util.MC
@Serializable
sealed interface HotkeyAction {
// TODO: execute
- val label: Text
+ val label: Component
fun execute()
}
@Serializable
@SerialName("command")
data class CommandAction(val command: String) : HotkeyAction {
- override val label: Text
- get() = Text.literal("/$command")
+ override val label: Component
+ get() = Component.literal("/$command")
override fun execute() {
MC.sendCommand(command)
diff --git a/src/main/kotlin/features/macros/KeyComboTrie.kt b/src/main/kotlin/features/macros/KeyComboTrie.kt
index 1983b2e..2701ac1 100644
--- a/src/main/kotlin/features/macros/KeyComboTrie.kt
+++ b/src/main/kotlin/features/macros/KeyComboTrie.kt
@@ -1,12 +1,12 @@
package moe.nea.firmament.features.macros
import kotlinx.serialization.Serializable
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.keybindings.SavedKeyBinding
import moe.nea.firmament.util.ErrorUtil
sealed interface KeyComboTrie {
- val label: Text
+ val label: Component
companion object {
fun fromComboList(
@@ -57,7 +57,7 @@ data class ComboKeyAction(
)
data class Leaf(val action: HotkeyAction) : KeyComboTrie {
- override val label: Text
+ override val label: Component
get() = action.label
fun execute() {
@@ -68,6 +68,6 @@ data class Leaf(val action: HotkeyAction) : KeyComboTrie {
data class Branch(
val nodes: Map<SavedKeyBinding, KeyComboTrie>
) : KeyComboTrie {
- override val label: Text
- get() = Text.literal("...") // TODO: better labels
+ override val label: Component
+ get() = Component.literal("...") // TODO: better labels
}
diff --git a/src/main/kotlin/features/macros/MacroUI.kt b/src/main/kotlin/features/macros/MacroUI.kt
index 869466d..e73f076 100644
--- a/src/main/kotlin/features/macros/MacroUI.kt
+++ b/src/main/kotlin/features/macros/MacroUI.kt
@@ -55,7 +55,7 @@ class MacroUI {
fun discard() {
dontSave = true
- MC.screen?.close()
+ MC.screen?.onClose()
}
class Command(
@@ -102,7 +102,7 @@ class MacroUI {
@Bind
fun back() {
- MC.screen?.close()
+ MC.screen?.onClose()
}
@Bind
@@ -169,7 +169,7 @@ class MacroUI {
fun saveAndClose() {
save()
- MC.screen?.close()
+ MC.screen?.onClose()
}
inner class Combos {
@@ -268,7 +268,7 @@ class MacroUI {
@Bind
fun back() {
- MC.screen?.close()
+ MC.screen?.onClose()
}
@Bind
diff --git a/src/main/kotlin/features/macros/RadialMenu.kt b/src/main/kotlin/features/macros/RadialMenu.kt
index 43e65a7..2519123 100644
--- a/src/main/kotlin/features/macros/RadialMenu.kt
+++ b/src/main/kotlin/features/macros/RadialMenu.kt
@@ -7,7 +7,7 @@ import kotlin.math.atan2
import kotlin.math.cos
import kotlin.math.sin
import kotlin.math.sqrt
-import net.minecraft.client.gui.DrawContext
+import net.minecraft.client.gui.GuiGraphics
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HudRenderEvent
import moe.nea.firmament.events.TickEvent
@@ -32,7 +32,7 @@ object RadialMenuViewer {
interface RadialMenuOption {
val isEnabled: Boolean
fun resolve()
- fun renderSlice(drawContext: DrawContext)
+ fun renderSlice(drawContext: GuiGraphics)
}
var activeMenu: RadialMenu? = null
@@ -63,11 +63,11 @@ object RadialMenuViewer {
@Subscribe
fun onRender(event: HudRenderEvent) {
val menu = activeMenu ?: return
- val mat = event.context.matrices
+ val mat = event.context.pose()
mat.pushMatrix()
mat.translate(
- (MC.window.scaledWidth) / 2F,
- (MC.window.scaledHeight) / 2F,
+ (MC.window.guiScaledWidth) / 2F,
+ (MC.window.guiScaledHeight) / 2F,
)
val sliceWidth = (τ / menu.options.size).toFloat()
var selectedAngle = wrapAngle(atan2(delta.y, delta.x))
@@ -137,8 +137,8 @@ object RadialMacros {
action.execute()
}
- override fun renderSlice(drawContext: DrawContext) {
- drawContext.drawCenteredTextWithShadow(MC.font, action.label, 0, 0, -1)
+ override fun renderSlice(drawContext: GuiGraphics) {
+ drawContext.drawCenteredString(MC.font, action.label, 0, 0, -1)
}
}
RadialMenuViewer.activeMenu = object : RadialMenu {
diff --git a/src/main/kotlin/features/mining/CommissionFeatures.kt b/src/main/kotlin/features/mining/CommissionFeatures.kt
index 1041ae5..bfc635a 100644
--- a/src/main/kotlin/features/mining/CommissionFeatures.kt
+++ b/src/main/kotlin/features/mining/CommissionFeatures.kt
@@ -20,7 +20,7 @@ object CommissionFeatures {
fun onSlotRender(event: SlotRenderEvents.Before) {
if (!TConfig.highlightCompletedCommissions) return
if (MC.screenName != "Commissions") return
- val stack = event.slot.stack
+ val stack = event.slot.item
if (stack.loreAccordingToNbt.any { it.unformattedString == "COMPLETED" }) {
event.highlight(Firmament.identifier("completed_commission_background"))
}
diff --git a/src/main/kotlin/features/mining/HotmPresets.kt b/src/main/kotlin/features/mining/HotmPresets.kt
index 97c9a7c..5316211 100644
--- a/src/main/kotlin/features/mining/HotmPresets.kt
+++ b/src/main/kotlin/features/mining/HotmPresets.kt
@@ -3,15 +3,15 @@ package moe.nea.firmament.features.mining
import me.shedaniel.math.Rectangle
import kotlinx.serialization.Serializable
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.block.Blocks
-import net.minecraft.client.gui.Click
-import net.minecraft.client.gui.DrawContext
-import net.minecraft.client.gui.screen.ingame.HandledScreen
-import net.minecraft.entity.player.PlayerInventory
-import net.minecraft.item.Items
-import net.minecraft.screen.GenericContainerScreenHandler
-import net.minecraft.screen.slot.Slot
-import net.minecraft.text.Text
+import net.minecraft.world.level.block.Blocks
+import net.minecraft.client.input.MouseButtonEvent
+import net.minecraft.client.gui.GuiGraphics
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
+import net.minecraft.world.entity.player.Inventory
+import net.minecraft.world.item.Items
+import net.minecraft.world.inventory.ChestMenu
+import net.minecraft.world.inventory.Slot
+import net.minecraft.network.chat.Component
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.thenExecute
@@ -51,8 +51,8 @@ object HotmPresets {
fun onScreenOpen(event: ScreenChangeEvent) {
val title = event.new?.title?.unformattedString
if (title != hotmInventoryName) return
- val screen = event.new as? HandledScreen<*> ?: return
- val oldHandler = (event.old as? HandledScreen<*>)?.customGui
+ val screen = event.new as? AbstractContainerScreen<*> ?: return
+ val oldHandler = (event.old as? AbstractContainerScreen<*>)?.customGui
if (oldHandler is HotmScrollPrompt) {
event.new.customGui = oldHandler
oldHandler.setNewScreen(screen)
@@ -63,32 +63,32 @@ object HotmPresets {
screen.customGui = HotmScrollPrompt(screen)
}
- class HotmScrollPrompt(var screen: HandledScreen<*>) : CustomGui() {
+ class HotmScrollPrompt(var screen: AbstractContainerScreen<*>) : CustomGui() {
var bounds = Rectangle(
0, 0, 0, 0
)
- fun setNewScreen(screen: HandledScreen<*>) {
+ fun setNewScreen(screen: AbstractContainerScreen<*>) {
this.screen = screen
onInit()
hasScrolled = false
}
- override fun render(drawContext: DrawContext, delta: Float, mouseX: Int, mouseY: Int) {
+ override fun render(drawContext: GuiGraphics, delta: Float, mouseX: Int, mouseY: Int) {
drawContext.drawGuiTexture(
CommonTextures.genericWidget(),
bounds.x, bounds.y,
bounds.width,
bounds.height,
)
- drawContext.drawCenteredTextWithShadow(
+ drawContext.drawCenteredString(
MC.font,
if (hasAll) {
- Text.translatable("firmament.hotmpreset.copied")
+ Component.translatable("firmament.hotmpreset.copied")
} else if (!hasScrolled) {
- Text.translatable("firmament.hotmpreset.scrollprompt")
+ Component.translatable("firmament.hotmpreset.scrollprompt")
} else {
- Text.translatable("firmament.hotmpreset.scrolled")
+ Component.translatable("firmament.hotmpreset.scrolled")
},
bounds.centerX,
bounds.centerY - 5,
@@ -100,11 +100,11 @@ object HotmPresets {
var hasScrolled = false
var hasAll = false
- override fun mouseClick(click: Click, doubled: Boolean): Boolean {
+ override fun mouseClick(click: MouseButtonEvent, doubled: Boolean): Boolean {
if (!hasScrolled) {
- val slot = screen.screenHandler.getSlot(8)
- println("Clicking ${slot.stack}")
- slot.clickRightMouseButton(screen.screenHandler)
+ val slot = screen.menu.getSlot(8)
+ println("Clicking ${slot.item}")
+ slot.clickRightMouseButton(screen.menu)
}
hasScrolled = true
return super.mouseClick(click, doubled)
@@ -140,10 +140,10 @@ object HotmPresets {
val allRows = (1..10).toSet()
fun onNewItems(event: ChestInventoryUpdateEvent) {
- val handler = screen.screenHandler as? GenericContainerScreenHandler ?: return
+ val handler = screen.menu as? ChestMenu ?: return
for (it in handler.slots) {
- if (it.inventory is PlayerInventory) continue
- val stack = it.stack
+ if (it.container is Inventory) continue
+ val stack = it.item
val name = stack.displayNameAccordingToNbt.unformattedString
tierRegex.useMatch(name) {
coveredRows.add(group("tier").toInt())
@@ -169,7 +169,7 @@ object HotmPresets {
@Subscribe
fun onSlotUpdates(event: ChestInventoryUpdateEvent) {
- val customGui = (event.inventory as? HandledScreen<*>)?.customGui
+ val customGui = (event.inventory as? AbstractContainerScreen<*>)?.customGui
if (customGui is HotmScrollPrompt) {
customGui.onNewItems(event)
}
@@ -185,7 +185,7 @@ object HotmPresets {
@Subscribe
fun onSlotRender(event: SlotRenderEvents.Before) {
if (hotmInventoryName == MC.screenName
- && event.slot.stack.displayNameAccordingToNbt.unformattedString in highlightedPerks
+ && event.slot.item.displayNameAccordingToNbt.unformattedString in highlightedPerks
) {
event.highlight((Firmament.identifier("hotm_perk_preset")))
}
@@ -197,7 +197,7 @@ object HotmPresets {
thenExecute {
hotmCommandSent = TimeMark.now()
MC.sendCommand("hotm")
- source.sendFeedback(Text.translatable("firmament.hotmpreset.openinghotm"))
+ source.sendFeedback(Component.translatable("firmament.hotmpreset.openinghotm"))
}
}
event.subcommand("importhotm") {
@@ -205,10 +205,10 @@ object HotmPresets {
val template =
TemplateUtil.maybeDecodeTemplate<HotmPreset>(SHARE_PREFIX, ClipboardUtils.getTextContents())
if (template == null) {
- source.sendFeedback(Text.translatable("firmament.hotmpreset.failedimport"))
+ source.sendFeedback(Component.translatable("firmament.hotmpreset.failedimport"))
} else {
highlightedPerks = template.perks.mapTo(mutableSetOf()) { it.perkName }
- source.sendFeedback(Text.translatable("firmament.hotmpreset.okayimport"))
+ source.sendFeedback(Component.translatable("firmament.hotmpreset.okayimport"))
MC.sendCommand("hotm")
}
}
diff --git a/src/main/kotlin/features/mining/MiningBlockInfoUi.kt b/src/main/kotlin/features/mining/MiningBlockInfoUi.kt
index f4def44..6c50665 100644
--- a/src/main/kotlin/features/mining/MiningBlockInfoUi.kt
+++ b/src/main/kotlin/features/mining/MiningBlockInfoUi.kt
@@ -3,8 +3,8 @@ package moe.nea.firmament.features.mining
import io.github.notenoughupdates.moulconfig.observer.ObservableList
import io.github.notenoughupdates.moulconfig.platform.MoulConfigPlatform
import io.github.notenoughupdates.moulconfig.xml.Bind
-import net.minecraft.client.gui.screen.Screen
-import net.minecraft.item.ItemStack
+import net.minecraft.client.gui.screens.Screen
+import net.minecraft.world.item.ItemStack
import moe.nea.firmament.repo.MiningRepoData
import moe.nea.firmament.repo.RepoManager
import moe.nea.firmament.util.MoulConfigUtils
diff --git a/src/main/kotlin/features/mining/PickaxeAbility.kt b/src/main/kotlin/features/mining/PickaxeAbility.kt
index 862d979..23b55e5 100644
--- a/src/main/kotlin/features/mining/PickaxeAbility.kt
+++ b/src/main/kotlin/features/mining/PickaxeAbility.kt
@@ -5,13 +5,13 @@ import java.util.regex.Pattern
import kotlin.jvm.optionals.getOrNull
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.client.MinecraftClient
-import net.minecraft.client.toast.SystemToast
-import net.minecraft.item.ItemStack
-import net.minecraft.util.DyeColor
-import net.minecraft.util.Hand
-import net.minecraft.util.Identifier
-import net.minecraft.util.StringIdentifiable
+import net.minecraft.client.Minecraft
+import net.minecraft.client.gui.components.toasts.SystemToast
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.item.DyeColor
+import net.minecraft.world.InteractionHand
+import net.minecraft.resources.ResourceLocation
+import net.minecraft.util.StringRepresentable
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HudRenderEvent
import moe.nea.firmament.events.ProcessChatEvent
@@ -48,13 +48,13 @@ object PickaxeAbility {
val identifier: String
get() = "pickaxe-info"
- enum class ShowOnTools(val label: String, val items: Set<ItemType>) : StringIdentifiable {
+ enum class ShowOnTools(val label: String, val items: Set<ItemType>) : StringRepresentable {
ALL("all", ItemType.DRILL, ItemType.PICKAXE, ItemType.SHOVEL, ItemType.AXE),
PICKAXES_AND_DRILLS("pick-and-drill", ItemType.PICKAXE, ItemType.DRILL),
DRILLS("drills", ItemType.DRILL),
;
- override fun asString(): String? {
+ override fun getSerializedName(): String? {
return label
}
@@ -79,12 +79,12 @@ object PickaxeAbility {
}
}
- enum class BlockPickaxeAbility : StringIdentifiable {
+ enum class BlockPickaxeAbility : StringRepresentable {
NEVER,
ALWAYS,
ONLY_DESTRUCTIVE;
- override fun asString(): String {
+ override fun getSerializedName(): String {
return name
}
}
@@ -195,11 +195,11 @@ object PickaxeAbility {
val ability = group("name")
lastUsage[ability] = TimeMark.farPast()
if (!TConfig.cooldownReadyToast) return
- val mc: MinecraftClient = MinecraftClient.getInstance()
- mc.toastManager.add(
- SystemToast.create(
+ val mc: Minecraft = Minecraft.getInstance()
+ mc.toastManager.addToast(
+ SystemToast.multiline(
mc,
- SystemToast.Type.NARRATOR_TOGGLE,
+ SystemToast.SystemToastId.NARRATOR_TOGGLE,
tr("firmament.pickaxe.ability-ready", "Pickaxe Cooldown"),
tr("firmament.pickaxe.ability-ready.desc", "Pickaxe ability is ready!")
)
@@ -248,7 +248,7 @@ object PickaxeAbility {
if (!TConfig.cooldownEnabled) return
if (TConfig.disableInDungeons && DungeonUtil.isInDungeonIsland) return
if (!event.isRenderingCursor) return
- val stack = MC.player?.getStackInHand(Hand.MAIN_HAND) ?: return
+ val stack = MC.player?.getItemInHand(InteractionHand.MAIN_HAND) ?: return
if (!TConfig.showOnTools.matches(ItemType.fromItemStack(stack) ?: ItemType.NIL))
return
var ability = getCooldownFromLore(stack)?.also { ability ->
@@ -258,15 +258,15 @@ object PickaxeAbility {
if (ability == null || (ao != ability.name && ao != null)) {
ability = PickaxeAbilityData(ao ?: return, defaultAbilityDurations[ao] ?: 120.seconds)
}
- event.context.matrices.pushMatrix()
- event.context.matrices.translate(MC.window.scaledWidth / 2F, MC.window.scaledHeight / 2F)
- event.context.matrices.scale(TConfig.cooldownScale.toFloat(), TConfig.cooldownScale.toFloat())
+ event.context.pose().pushMatrix()
+ event.context.pose().translate(MC.window.guiScaledWidth / 2F, MC.window.guiScaledHeight / 2F)
+ event.context.pose().scale(TConfig.cooldownScale.toFloat(), TConfig.cooldownScale.toFloat())
RenderCircleProgress.renderCircle(
- event.context, Identifier.of("firmament", "textures/gui/circle.png"),
+ event.context, ResourceLocation.fromNamespaceAndPath("firmament", "textures/gui/circle.png"),
getCooldownPercentage(ability.name, ability.cooldown).toFloat(),
0f, 1f, 0f, 1f,
color = TConfig.cooldownColour.getEffectiveColourRGB()
)
- event.context.matrices.popMatrix()
+ event.context.pose().popMatrix()
}
}
diff --git a/src/main/kotlin/features/mining/PristineProfitTracker.kt b/src/main/kotlin/features/mining/PristineProfitTracker.kt
index ad864c1..0470702 100644
--- a/src/main/kotlin/features/mining/PristineProfitTracker.kt
+++ b/src/main/kotlin/features/mining/PristineProfitTracker.kt
@@ -5,7 +5,7 @@ import org.joml.Vector2i
import kotlinx.serialization.Serializable
import kotlinx.serialization.serializer
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ProcessChatEvent
import moe.nea.firmament.gui.hud.MoulConfigHud
@@ -105,11 +105,11 @@ object PristineProfitTracker {
val moneyPerSecond = moneyHistogram.averagePer({ it }, 1.seconds)
if (collectionPerSecond == null || moneyPerSecond == null) return
ProfitHud.collectionCurrent = collectionPerSecond
- ProfitHud.collectionText = Text.stringifiedTranslatable("firmament.pristine-profit.collection",
+ ProfitHud.collectionText = Component.translatableEscape("firmament.pristine-profit.collection",
formatCommas(collectionPerSecond * SECONDS_PER_HOUR,
1)).formattedString()
ProfitHud.moneyCurrent = moneyPerSecond
- ProfitHud.moneyText = Text.stringifiedTranslatable("firmament.pristine-profit.money",
+ ProfitHud.moneyText = Component.translatableEscape("firmament.pristine-profit.money",
formatCommas(moneyPerSecond * SECONDS_PER_HOUR, 1))
.formattedString()
val data = DConfig.data
diff --git a/src/main/kotlin/features/misc/CustomCapes.kt b/src/main/kotlin/features/misc/CustomCapes.kt
index d66e6a3..8aa19d3 100644
--- a/src/main/kotlin/features/misc/CustomCapes.kt
+++ b/src/main/kotlin/features/misc/CustomCapes.kt
@@ -3,15 +3,15 @@ package moe.nea.firmament.features.misc
import util.render.CustomRenderPipelines
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.client.network.AbstractClientPlayerEntity
-import net.minecraft.client.render.RenderLayer
-import net.minecraft.client.render.VertexConsumer
-import net.minecraft.client.render.VertexConsumerProvider
-import net.minecraft.client.render.entity.state.PlayerEntityRenderState
-import net.minecraft.client.util.math.MatrixStack
-import net.minecraft.entity.player.SkinTextures
-import net.minecraft.util.AssetInfo
-import net.minecraft.util.Identifier
+import net.minecraft.client.player.AbstractClientPlayer
+import net.minecraft.client.renderer.RenderType
+import com.mojang.blaze3d.vertex.VertexConsumer
+import net.minecraft.client.renderer.MultiBufferSource
+import net.minecraft.client.renderer.entity.state.AvatarRenderState
+import com.mojang.blaze3d.vertex.PoseStack
+import net.minecraft.world.entity.player.PlayerSkin
+import net.minecraft.core.ClientAsset
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.Firmament
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.TimeMark
@@ -30,44 +30,44 @@ object CustomCapes {
interface CustomCapeRenderer {
fun replaceRender(
- renderLayer: RenderLayer,
- vertexConsumerProvider: VertexConsumerProvider,
- matrixStack: MatrixStack,
- model: (VertexConsumer) -> Unit
+ renderLayer: RenderType,
+ vertexConsumerProvider: MultiBufferSource,
+ matrixStack: PoseStack,
+ model: (VertexConsumer) -> Unit
)
}
data class TexturedCapeRenderer(
- val location: Identifier
+ val location: ResourceLocation
) : CustomCapeRenderer {
override fun replaceRender(
- renderLayer: RenderLayer,
- vertexConsumerProvider: VertexConsumerProvider,
- matrixStack: MatrixStack,
- model: (VertexConsumer) -> Unit
+ renderLayer: RenderType,
+ vertexConsumerProvider: MultiBufferSource,
+ matrixStack: PoseStack,
+ model: (VertexConsumer) -> Unit
) {
- model(vertexConsumerProvider.getBuffer(RenderLayer.getEntitySolid(location)))
+ model(vertexConsumerProvider.getBuffer(RenderType.entitySolid(location)))
}
}
data class ParallaxedHighlightCapeRenderer(
- val template: Identifier,
- val background: Identifier,
- val overlay: Identifier,
- val animationSpeed: Duration,
+ val template: ResourceLocation,
+ val background: ResourceLocation,
+ val overlay: ResourceLocation,
+ val animationSpeed: Duration,
) : CustomCapeRenderer {
override fun replaceRender(
- renderLayer: RenderLayer,
- vertexConsumerProvider: VertexConsumerProvider,
- matrixStack: MatrixStack,
- model: (VertexConsumer) -> Unit
+ renderLayer: RenderType,
+ vertexConsumerProvider: MultiBufferSource,
+ matrixStack: PoseStack,
+ model: (VertexConsumer) -> Unit
) {
val animationValue = (startTime.passedTime() / animationSpeed).mod(1F)
CustomRenderPassHelper(
{ "Firmament Cape Renderer" },
- renderLayer.drawMode,
- renderLayer.vertexFormat,
- MC.instance.framebuffer,
+ renderLayer.mode(),
+ renderLayer.format(),
+ MC.instance.mainRenderTarget,
true,
).use { renderPass ->
renderPass.setPipeline(CustomRenderPipelines.PARALLAX_CAPE_SHADER)
@@ -87,7 +87,7 @@ object CustomCapes {
interface CapeStorage {
companion object {
@JvmStatic
- fun cast(playerEntityRenderState: PlayerEntityRenderState) =
+ fun cast(playerEntityRenderState: AvatarRenderState) =
playerEntityRenderState as CapeStorage
}
@@ -146,8 +146,8 @@ object CustomCapes {
@JvmStatic
fun addCapeData(
- player: AbstractClientPlayerEntity,
- playerEntityRenderState: PlayerEntityRenderState
+ player: AbstractClientPlayer,
+ playerEntityRenderState: AvatarRenderState
) {
if (true) return // TODO: see capefeaturerenderer mixin
val cape = if (TConfig.showCapes) byUuid[player.uuid] else null
@@ -156,14 +156,14 @@ object CustomCapes {
capeStorage.cape_firmament = null
} else {
capeStorage.cape_firmament = cape
- playerEntityRenderState.skinTextures = SkinTextures(
- playerEntityRenderState.skinTextures.body,
- AssetInfo.TextureAssetInfo(Firmament.identifier("placeholder/fake_cape"), Firmament.identifier("placeholder/fake_cape")),
- playerEntityRenderState.skinTextures.elytra,
- playerEntityRenderState.skinTextures.model,
- playerEntityRenderState.skinTextures.secure,
+ playerEntityRenderState.skin = PlayerSkin(
+ playerEntityRenderState.skin.body,
+ ClientAsset.ResourceTexture(Firmament.identifier("placeholder/fake_cape"), Firmament.identifier("placeholder/fake_cape")),
+ playerEntityRenderState.skin.elytra,
+ playerEntityRenderState.skin.model,
+ playerEntityRenderState.skin.secure,
)
- playerEntityRenderState.capeVisible = true
+ playerEntityRenderState.showCape = true
}
}
diff --git a/src/main/kotlin/features/misc/Hud.kt b/src/main/kotlin/features/misc/Hud.kt
index fb7c6cd..bbe8044 100644
--- a/src/main/kotlin/features/misc/Hud.kt
+++ b/src/main/kotlin/features/misc/Hud.kt
@@ -1,8 +1,8 @@
package moe.nea.firmament.features.misc
import org.joml.Vector2i
-import net.minecraft.client.network.PlayerListEntry
-import net.minecraft.text.Text
+import net.minecraft.client.multiplayer.PlayerInfo
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HudRenderEvent
import moe.nea.firmament.util.MC
@@ -27,49 +27,49 @@ object Hud {
@Subscribe
fun onRenderHud(it: HudRenderEvent) {
if (TConfig.dayCount) {
- it.context.matrices.pushMatrix()
- TConfig.dayCountHud.applyTransformations(it.context.matrices)
- val day = (MC.world?.timeOfDay ?: 0L) / 24000
- it.context.drawText(
+ it.context.pose().pushMatrix()
+ TConfig.dayCountHud.applyTransformations(it.context.pose())
+ val day = (MC.world?.dayTime ?: 0L) / 24000
+ it.context.drawString(
MC.font,
- Text.literal(String.format(tr("firmament.config.hud.day-count-hud.display", "Day: %s").string, day)),
+ Component.literal(String.format(tr("firmament.config.hud.day-count-hud.display", "Day: %s").string, day)),
36,
- MC.font.fontHeight,
+ MC.font.lineHeight,
-1,
true
)
- it.context.matrices.popMatrix()
+ it.context.pose().popMatrix()
}
if (TConfig.fpsCount) {
- it.context.matrices.pushMatrix()
- TConfig.fpsCountHud.applyTransformations(it.context.matrices)
- it.context.drawText(
- MC.font, Text.literal(
+ it.context.pose().pushMatrix()
+ TConfig.fpsCountHud.applyTransformations(it.context.pose())
+ it.context.drawString(
+ MC.font, Component.literal(
String.format(
- tr("firmament.config.hud.fps-count-hud.display", "FPS: %s").string, MC.instance.currentFps
+ tr("firmament.config.hud.fps-count-hud.display", "FPS: %s").string, MC.instance.fps
)
- ), 36, MC.font.fontHeight, -1, true
+ ), 36, MC.font.lineHeight, -1, true
)
- it.context.matrices.popMatrix()
+ it.context.pose().popMatrix()
}
if (TConfig.pingCount) {
- it.context.matrices.pushMatrix()
- TConfig.pingCountHud.applyTransformations(it.context.matrices)
+ it.context.pose().pushMatrix()
+ TConfig.pingCountHud.applyTransformations(it.context.pose())
val ping = MC.player?.let {
- val entry: PlayerListEntry? = MC.networkHandler?.getPlayerListEntry(it.uuid)
+ val entry: PlayerInfo? = MC.networkHandler?.getPlayerInfo(it.uuid)
entry?.latency ?: -1
} ?: -1
- it.context.drawText(
- MC.font, Text.literal(
+ it.context.drawString(
+ MC.font, Component.literal(
String.format(
tr("firmament.config.hud.ping-count-hud.display", "Ping: %s ms").string, ping
)
- ), 36, MC.font.fontHeight, -1, true
+ ), 36, MC.font.lineHeight, -1, true
)
- it.context.matrices.popMatrix()
+ it.context.pose().popMatrix()
}
}
}
diff --git a/src/main/kotlin/features/misc/LicenseViewer.kt b/src/main/kotlin/features/misc/LicenseViewer.kt
index 7a43554..26bec80 100644
--- a/src/main/kotlin/features/misc/LicenseViewer.kt
+++ b/src/main/kotlin/features/misc/LicenseViewer.kt
@@ -6,7 +6,7 @@ import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient
import kotlinx.serialization.json.decodeFromStream
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.thenExecute
@@ -31,7 +31,7 @@ object LicenseViewer {
fun hasWebPresence() = webPresence != null
@Bind
- fun webPresence() = Text.literal(webPresence ?: "<no web presence>")
+ fun webPresence() = Component.literal(webPresence ?: "<no web presence>")
@Bind
fun open() {
@@ -39,10 +39,10 @@ object LicenseViewer {
}
@Bind
- fun projectName() = Text.literal(projectName)
+ fun projectName() = Component.literal(projectName)
@Bind
- fun projectDescription() = Text.literal(projectDescription ?: "<no project description>")
+ fun projectDescription() = Component.literal(projectDescription ?: "<no project description>")
@get:Bind("developers")
@Transient
@@ -60,7 +60,7 @@ object LicenseViewer {
) {
@Bind("name")
- fun nameT() = Text.literal(name)
+ fun nameT() = Component.literal(name)
@Bind
fun open() {
@@ -71,7 +71,7 @@ object LicenseViewer {
fun hasWebPresence() = webPresence != null
@Bind
- fun webPresence() = Text.literal(webPresence ?: "<no web presence>")
+ fun webPresence() = Component.literal(webPresence ?: "<no web presence>")
}
@Serializable
@@ -80,7 +80,7 @@ object LicenseViewer {
val licenseUrl: String? = null
) {
@Bind("name")
- fun nameG() = Text.literal(licenseName)
+ fun nameG() = Component.literal(licenseName)
@Bind
fun open() {
@@ -91,7 +91,7 @@ object LicenseViewer {
fun hasUrl() = licenseUrl != null
@Bind
- fun url() = Text.literal(licenseUrl ?: "<no link to license text>")
+ fun url() = Component.literal(licenseUrl ?: "<no link to license text>")
}
data class LicenseList(
diff --git a/src/main/kotlin/features/misc/ModAnnouncer.kt b/src/main/kotlin/features/misc/ModAnnouncer.kt
index 1047353..c2aa013 100644
--- a/src/main/kotlin/features/misc/ModAnnouncer.kt
+++ b/src/main/kotlin/features/misc/ModAnnouncer.kt
@@ -4,10 +4,10 @@ import io.netty.buffer.ByteBuf
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry
import net.fabricmc.loader.api.FabricLoader
-import net.minecraft.network.codec.PacketCodec
-import net.minecraft.network.codec.PacketCodecs
-import net.minecraft.network.packet.CustomPayload
-import net.minecraft.network.packet.c2s.common.CustomPayloadC2SPacket
+import net.minecraft.network.codec.StreamCodec
+import net.minecraft.network.codec.ByteBufCodecs
+import net.minecraft.network.protocol.common.custom.CustomPacketPayload
+import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.JoinServerEvent
@@ -37,9 +37,9 @@ object ModAnnouncer {
val modVersion: String,
) {
companion object {
- val CODEC: PacketCodec<ByteBuf, ModEntry> = PacketCodec.tuple(
- PacketCodecs.STRING, ModEntry::modid,
- PacketCodecs.STRING, ModEntry::modVersion,
+ val CODEC: StreamCodec<ByteBuf, ModEntry> = StreamCodec.composite(
+ ByteBufCodecs.STRING_UTF8, ModEntry::modid,
+ ByteBufCodecs.STRING_UTF8, ModEntry::modVersion,
::ModEntry
)
}
@@ -47,15 +47,15 @@ object ModAnnouncer {
data class ModPacket(
val mods: List<ModEntry>,
- ) : CustomPayload {
- override fun getId(): CustomPayload.Id<out ModPacket> {
+ ) : CustomPacketPayload {
+ override fun type(): CustomPacketPayload.Type<out ModPacket> {
return ID
}
companion object {
- val ID = CustomPayload.Id<ModPacket>(Firmament.identifier("mod_list"))
- val CODEC: PacketCodec<ByteBuf, ModPacket> = ModEntry.CODEC.collect(PacketCodecs.toList())
- .xmap(::ModPacket, ModPacket::mods)
+ val ID = CustomPacketPayload.Type<ModPacket>(Firmament.identifier("mod_list"))
+ val CODEC: StreamCodec<ByteBuf, ModPacket> = ModEntry.CODEC.apply(ByteBufCodecs.list())
+ .map(::ModPacket, ModPacket::mods)
}
}
@@ -68,10 +68,10 @@ object ModAnnouncer {
.map { ModEntry(it.metadata.id, it.metadata.version.friendlyString) })
val pbb = PacketByteBufs.create()
ModPacket.CODEC.encode(pbb, packet)
- if (pbb.writerIndex() > CustomPayloadC2SPacket.MAX_PAYLOAD_SIZE)
+ if (pbb.writerIndex() > ServerboundCustomPayloadPacket.MAX_PAYLOAD_SIZE)
return
- event.networkHandler.sendPacket(event.packetSender.createPacket(packet))
+ event.networkHandler.send(event.packetSender.createPacket(packet))
}
init {
diff --git a/src/main/kotlin/features/world/ColeWeightCompat.kt b/src/main/kotlin/features/world/ColeWeightCompat.kt
index f7f1317..3597d6d 100644
--- a/src/main/kotlin/features/world/ColeWeightCompat.kt
+++ b/src/main/kotlin/features/world/ColeWeightCompat.kt
@@ -1,8 +1,8 @@
package moe.nea.firmament.features.world
import kotlinx.serialization.Serializable
-import net.minecraft.text.Text
-import net.minecraft.util.math.BlockPos
+import net.minecraft.network.chat.Component
+import net.minecraft.core.BlockPos
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.DefaultSource
@@ -44,9 +44,9 @@ object ColeWeightCompat {
}
fun copyAndInform(
- source: DefaultSource,
- origin: BlockPos,
- positiveFeedback: (Int) -> Text,
+ source: DefaultSource,
+ origin: BlockPos,
+ positiveFeedback: (Int) -> Component,
) {
val waypoints = Waypoints.useNonEmptyWaypoints()
?.let { fromFirm(it, origin) }
@@ -61,12 +61,12 @@ object ColeWeightCompat {
}
fun importAndInform(
- source: DefaultSource,
- pos: BlockPos?,
- positiveFeedback: (Int) -> Text
+ source: DefaultSource,
+ pos: BlockPos?,
+ positiveFeedback: (Int) -> Component
) {
val text = ClipboardUtils.getTextContents()
- val wr = tryParse(text).map { intoFirm(it, pos ?: BlockPos.ORIGIN) }
+ val wr = tryParse(text).map { intoFirm(it, pos ?: BlockPos.ZERO) }
val waypoints = wr.getOrElse {
source.sendError(
tr("firmament.command.waypoint.import.cw.error",
@@ -84,7 +84,7 @@ object ColeWeightCompat {
event.subcommand(Waypoints.WAYPOINTS_SUBCOMMAND) {
thenLiteral("exportcw") {
thenExecute {
- copyAndInform(source, BlockPos.ORIGIN) {
+ copyAndInform(source, BlockPos.ZERO) {
tr("firmament.command.waypoint.export.cw",
"Copied $it waypoints to clipboard in ColeWeight format.")
}
@@ -92,7 +92,7 @@ object ColeWeightCompat {
}
thenLiteral("exportrelativecw") {
thenExecute {
- copyAndInform(source, MC.player?.blockPos ?: BlockPos.ORIGIN) {
+ copyAndInform(source, MC.player?.blockPosition() ?: BlockPos.ZERO) {
tr("firmament.command.waypoint.export.cw.relative",
"Copied $it relative waypoints to clipboard in ColeWeight format. Make sure to stand in the same position when importing.")
}
@@ -108,7 +108,7 @@ object ColeWeightCompat {
}
thenLiteral("importrelativecw") {
thenExecute {
- importAndInform(source, MC.player!!.blockPos) {
+ importAndInform(source, MC.player!!.blockPosition()) {
tr("firmament.command.waypoint.import.cw.relative",
"Imported $it relative waypoints from clipboard. Make sure you stand in the same position as when you exported these waypoints for them to line up correctly.")
}
diff --git a/src/main/kotlin/features/world/FairySouls.kt b/src/main/kotlin/features/world/FairySouls.kt
index 9191a80..b073726 100644
--- a/src/main/kotlin/features/world/FairySouls.kt
+++ b/src/main/kotlin/features/world/FairySouls.kt
@@ -67,12 +67,12 @@ object FairySouls {
fun findNearestClickableSoul(): Coordinate? {
val player = MC.player ?: return null
- val pos = player.pos
+ val pos = player.position
val location = SBData.skyblockLocation ?: return null
val soulLocations: List<Coordinate> =
RepoManager.neuRepo.constants.fairySouls.soulLocations[location.locrawMode] ?: return null
return soulLocations
- .map { it to it.blockPos.getSquaredDistance(pos) }
+ .map { it to it.blockPos.distToCenterSqr(pos) }
.filter { it.second < playerReachSquared }
.minByOrNull { it.second }
?.first
diff --git a/src/main/kotlin/features/world/FirmWaypointManager.kt b/src/main/kotlin/features/world/FirmWaypointManager.kt
index 41c3007..c6e2610 100644
--- a/src/main/kotlin/features/world/FirmWaypointManager.kt
+++ b/src/main/kotlin/features/world/FirmWaypointManager.kt
@@ -2,7 +2,7 @@ package moe.nea.firmament.features.world
import com.mojang.brigadier.arguments.StringArgumentType
import kotlinx.serialization.serializer
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.DefaultSource
import moe.nea.firmament.commands.RestArgumentType
@@ -46,10 +46,10 @@ object FirmWaypointManager {
return copy
}
- fun loadWaypoints(waypoints: FirmWaypoints, sendFeedback: (Text) -> Unit) {
+ fun loadWaypoints(waypoints: FirmWaypoints, sendFeedback: (Component) -> Unit) {
val copy = waypoints.deepCopy()
if (copy.isRelativeTo != null) {
- val origin = MC.player!!.blockPos
+ val origin = MC.player!!.blockPosition()
copy.waypoints.replaceAll {
it.copy(
x = it.x + origin.x,
@@ -57,7 +57,7 @@ object FirmWaypointManager {
z = it.z + origin.z,
)
}
- copy.lastRelativeImport = origin.toImmutable()
+ copy.lastRelativeImport = origin.immutable()
sendFeedback(tr("firmament.command.waypoint.import.ordered.success",
"Imported ${copy.size} relative waypoints. Make sure you stand in the correct spot while loading the waypoints: ${copy.isRelativeTo}."))
} else {
@@ -70,7 +70,7 @@ object FirmWaypointManager {
fun setOrigin(source: DefaultSource, text: String?) {
val waypoints = Waypoints.useEditableWaypoints()
waypoints.isRelativeTo = text ?: waypoints.isRelativeTo ?: ""
- val pos = MC.player!!.blockPos
+ val pos = MC.player!!.blockPosition()
waypoints.lastRelativeImport = pos
source.sendFeedback(tr("firmament.command.waypoint.originset",
"Set the origin of waypoints to ${FirmFormatters.formatPosition(pos)}. Run /firm waypoints export to save the waypoints relative to this position."))
diff --git a/src/main/kotlin/features/world/FirmWaypoints.kt b/src/main/kotlin/features/world/FirmWaypoints.kt
index d0cd55a..0b018cb 100644
--- a/src/main/kotlin/features/world/FirmWaypoints.kt
+++ b/src/main/kotlin/features/world/FirmWaypoints.kt
@@ -2,7 +2,7 @@ package moe.nea.firmament.features.world
import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient
-import net.minecraft.util.math.BlockPos
+import net.minecraft.core.BlockPos
@Serializable
data class FirmWaypoints(
diff --git a/src/main/kotlin/features/world/NavigableWaypoint.kt b/src/main/kotlin/features/world/NavigableWaypoint.kt
index 28a517f..653fd87 100644
--- a/src/main/kotlin/features/world/NavigableWaypoint.kt
+++ b/src/main/kotlin/features/world/NavigableWaypoint.kt
@@ -1,7 +1,7 @@
package moe.nea.firmament.features.world
import io.github.moulberry.repo.data.NEUItem
-import net.minecraft.util.math.BlockPos
+import net.minecraft.core.BlockPos
import moe.nea.firmament.util.SkyBlockIsland
abstract class NavigableWaypoint {
diff --git a/src/main/kotlin/features/world/NavigationHelper.kt b/src/main/kotlin/features/world/NavigationHelper.kt
index acdfb86..ea886bf 100644
--- a/src/main/kotlin/features/world/NavigationHelper.kt
+++ b/src/main/kotlin/features/world/NavigationHelper.kt
@@ -1,10 +1,10 @@
package moe.nea.firmament.features.world
import io.github.moulberry.repo.constants.Islands
-import net.minecraft.text.Text
-import net.minecraft.util.math.BlockPos
-import net.minecraft.util.math.Position
-import net.minecraft.util.math.Vec3i
+import net.minecraft.network.chat.Component
+import net.minecraft.core.BlockPos
+import net.minecraft.core.Position
+import net.minecraft.core.Vec3i
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.SkyblockServerUpdateEvent
import moe.nea.firmament.events.TickEvent
@@ -72,7 +72,7 @@ object NavigationHelper {
fun onMovement(event: TickEvent) { // TODO: add a movement tick event maybe?
val tp = targetWaypoint ?: return
val p = MC.player ?: return
- if (p.squaredDistanceTo(tp.position.toCenterPos()) < 5 * 5) {
+ if (p.distanceToSqr(tp.position.center) < 5 * 5) {
targetWaypoint = null
}
}
@@ -84,11 +84,11 @@ object NavigationHelper {
RenderInWorldContext.renderInWorld(event) {
if (nt != null) {
waypoint(nt.blockPos,
- Text.literal("Teleporter to " + nt.toIsland.userFriendlyName),
- Text.literal("(towards " + tp.name + "§f)"))
+ Component.literal("Teleporter to " + nt.toIsland.userFriendlyName),
+ Component.literal("(towards " + tp.name + "§f)"))
} else if (tp.island == SBData.skyblockLocation) {
waypoint(tp.position,
- Text.literal(tp.name))
+ Component.literal(tp.name))
}
}
}
@@ -96,7 +96,7 @@ object NavigationHelper {
fun tryWarpNear() {
val tp = targetWaypoint
if (tp == null) {
- MC.sendChat(Text.literal("Could not find a waypoint to warp you to. Select one first."))
+ MC.sendChat(Component.literal("Could not find a waypoint to warp you to. Select one first."))
return
}
WarpUtil.teleportToNearestWarp(tp.island, tp.position.asPositionView())
@@ -106,15 +106,15 @@ object NavigationHelper {
fun Vec3i.asPositionView(): Position {
return object : Position {
- override fun getX(): Double {
+ override fun x(): Double {
return this@asPositionView.x.toDouble()
}
- override fun getY(): Double {
+ override fun y(): Double {
return this@asPositionView.y.toDouble()
}
- override fun getZ(): Double {
+ override fun z(): Double {
return this@asPositionView.z.toDouble()
}
}
diff --git a/src/main/kotlin/features/world/NpcWaypointGui.kt b/src/main/kotlin/features/world/NpcWaypointGui.kt
index b6db7eb..3bae3e8 100644
--- a/src/main/kotlin/features/world/NpcWaypointGui.kt
+++ b/src/main/kotlin/features/world/NpcWaypointGui.kt
@@ -2,7 +2,7 @@ package moe.nea.firmament.features.world
import io.github.notenoughupdates.moulconfig.observer.ObservableList
import io.github.notenoughupdates.moulconfig.xml.Bind
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.features.events.anniversity.AnniversaryFeatures.atOnce
import moe.nea.firmament.keybindings.SavedKeyBinding
@@ -12,7 +12,7 @@ class NpcWaypointGui(
data class NavigableWaypointW(val waypoint: NavigableWaypoint) {
@Bind
- fun name() = Text.literal(waypoint.name)
+ fun name() = Component.literal(waypoint.name)
@Bind
fun isSelected() = NavigationHelper.targetWaypoint == waypoint
diff --git a/src/main/kotlin/features/world/TemporaryWaypoints.kt b/src/main/kotlin/features/world/TemporaryWaypoints.kt
index 14a9f74..ac1600e 100644
--- a/src/main/kotlin/features/world/TemporaryWaypoints.kt
+++ b/src/main/kotlin/features/world/TemporaryWaypoints.kt
@@ -2,8 +2,8 @@ package moe.nea.firmament.features.world
import me.shedaniel.math.Color
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.text.Text
-import net.minecraft.util.math.BlockPos
+import net.minecraft.network.chat.Component
+import net.minecraft.core.BlockPos
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ProcessChatEvent
import moe.nea.firmament.events.WorldReadyEvent
@@ -15,8 +15,8 @@ import moe.nea.firmament.util.render.RenderInWorldContext
object TemporaryWaypoints {
data class TemporaryWaypoint(
- val pos: BlockPos,
- val postedAt: TimeMark,
+ val pos: BlockPos,
+ val postedAt: TimeMark,
)
val temporaryPlayerWaypointList = mutableMapOf<String, TemporaryWaypoint>()
val temporaryPlayerWaypointMatcher = "(?i)x: (-?[0-9]+),? y: (-?[0-9]+),? z: (-?[0-9]+)".toPattern()
@@ -41,9 +41,9 @@ object TemporaryWaypoints {
}
temporaryPlayerWaypointList.forEach { (player, waypoint) ->
val skin =
- MC.networkHandler?.listedPlayerListEntries?.find { it.profile.name == player }?.skinTextures?.body
- withFacingThePlayer(waypoint.pos.toCenterPos()) {
- waypoint(waypoint.pos, Text.stringifiedTranslatable("firmament.waypoint.temporary", player))
+ MC.networkHandler?.listedOnlinePlayers?.find { it.profile.name == player }?.skin?.body
+ withFacingThePlayer(waypoint.pos.center) {
+ waypoint(waypoint.pos, Component.translatableEscape("firmament.waypoint.temporary", player))
if (skin != null) {
matrixStack.translate(0F, -20F, 0F)
// Head front
diff --git a/src/main/kotlin/features/world/Waypoints.kt b/src/main/kotlin/features/world/Waypoints.kt
index 318b6c2..9097d3a 100644
--- a/src/main/kotlin/features/world/Waypoints.kt
+++ b/src/main/kotlin/features/world/Waypoints.kt
@@ -4,9 +4,9 @@ import com.mojang.brigadier.arguments.IntegerArgumentType
import me.shedaniel.math.Color
import kotlin.time.Duration.Companion.hours
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.command.argument.BlockPosArgumentType
-import net.minecraft.text.Text
-import net.minecraft.util.math.Vec3d
+import net.minecraft.commands.arguments.coordinates.BlockPosArgument
+import net.minecraft.network.chat.Component
+import net.minecraft.world.phys.Vec3
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.get
import moe.nea.firmament.commands.thenArgument
@@ -46,14 +46,14 @@ object Waypoints {
if (!w.isOrdered) {
w.waypoints.withIndex().forEach {
block(it.value.blockPos, Color.ofRGBA(0, 80, 160, 128).color)
- if (TConfig.showIndex) withFacingThePlayer(it.value.blockPos.toCenterPos()) {
- text(Text.literal(it.index.toString()))
+ if (TConfig.showIndex) withFacingThePlayer(it.value.blockPos.center) {
+ text(Component.literal(it.index.toString()))
}
}
} else {
orderedIndex %= w.waypoints.size
val firstColor = Color.ofRGBA(0, 200, 40, 180)
- tracer(w.waypoints[orderedIndex].blockPos.toCenterPos(), color = firstColor.color, lineWidth = 3f)
+ tracer(w.waypoints[orderedIndex].blockPos.center, color = firstColor.color, lineWidth = 3f)
w.waypoints.withIndex().toList().wrappingWindow(orderedIndex, 3).zip(
listOf(
firstColor,
@@ -63,8 +63,8 @@ object Waypoints {
).reversed().forEach { (waypoint, col) ->
val (index, pos) = waypoint
block(pos.blockPos, col.color)
- if (TConfig.showIndex) withFacingThePlayer(pos.blockPos.toCenterPos()) {
- text(Text.literal(index.toString()))
+ if (TConfig.showIndex) withFacingThePlayer(pos.blockPos.center) {
+ text(Component.literal(index.toString()))
}
}
}
@@ -76,13 +76,13 @@ object Waypoints {
val w = useNonEmptyWaypoints() ?: return
if (!w.isOrdered) return
orderedIndex %= w.waypoints.size
- val p = MC.player?.pos ?: return
+ val p = MC.player?.position ?: return
if (TConfig.skipToNearest) {
orderedIndex =
- (w.waypoints.withIndex().minBy { it.value.blockPos.getSquaredDistance(p) }.index + 1) % w.waypoints.size
+ (w.waypoints.withIndex().minBy { it.value.blockPos.distToCenterSqr(p) }.index + 1) % w.waypoints.size
} else {
- if (w.waypoints[orderedIndex].blockPos.isWithinDistance(p, 3.0)) {
+ if (w.waypoints[orderedIndex].blockPos.closerToCenterThan(p, 3.0)) {
orderedIndex = (orderedIndex + 1) % w.waypoints.size
}
}
@@ -117,14 +117,14 @@ object Waypoints {
@Subscribe
fun onCommand(event: CommandEvent.SubCommand) {
event.subcommand("waypoint") {
- thenArgument("pos", BlockPosArgumentType.blockPos()) { pos ->
+ thenArgument("pos", BlockPosArgument.blockPos()) { pos ->
thenExecute {
source
- val position = pos.get(this).toAbsoluteBlockPos(source.asFakeServer())
+ val position = pos.get(this).getBlockPos(source.asFakeServer())
val w = useEditableWaypoints()
w.waypoints.add(FirmWaypoints.Waypoint.from(position))
source.sendFeedback(
- Text.stringifiedTranslatable(
+ Component.translatableEscape(
"firmament.command.waypoint.added",
position.x,
position.y,
@@ -180,7 +180,7 @@ object Waypoints {
thenLiteral("clear") {
thenExecute {
waypoints = null
- source.sendFeedback(Text.translatable("firmament.command.waypoint.clear"))
+ source.sendFeedback(Component.translatable("firmament.command.waypoint.clear"))
}
}
thenLiteral("toggleordered") {
@@ -188,11 +188,11 @@ object Waypoints {
val w = useEditableWaypoints()
w.isOrdered = !w.isOrdered
if (w.isOrdered) {
- val p = MC.player?.pos ?: Vec3d.ZERO
+ val p = MC.player?.position ?: Vec3.ZERO
orderedIndex = // TODO: this should be extracted to a utility method
- w.waypoints.withIndex().minByOrNull { it.value.blockPos.getSquaredDistance(p) }?.index ?: 0
+ w.waypoints.withIndex().minByOrNull { it.value.blockPos.distToCenterSqr(p) }?.index ?: 0
}
- source.sendFeedback(Text.translatable("firmament.command.waypoint.ordered.toggle.${w.isOrdered}"))
+ source.sendFeedback(Component.translatable("firmament.command.waypoint.ordered.toggle.${w.isOrdered}"))
}
}
thenLiteral("skip") {
@@ -200,9 +200,9 @@ object Waypoints {
val w = useNonEmptyWaypoints()
if (w != null && w.isOrdered) {
orderedIndex = (orderedIndex + 1) % w.size
- source.sendFeedback(Text.translatable("firmament.command.waypoint.skip"))
+ source.sendFeedback(Component.translatable("firmament.command.waypoint.skip"))
} else {
- source.sendError(Text.translatable("firmament.command.waypoint.skip.error"))
+ source.sendError(Component.translatable("firmament.command.waypoint.skip.error"))
}
}
}
@@ -214,13 +214,13 @@ object Waypoints {
if (w != null && index in w.waypoints.indices) {
w.waypoints.removeAt(index)
source.sendFeedback(
- Text.stringifiedTranslatable(
+ Component.translatableEscape(
"firmament.command.waypoint.remove",
index
)
)
} else {
- source.sendError(Text.stringifiedTranslatable("firmament.command.waypoint.remove.error"))
+ source.sendError(Component.translatableEscape("firmament.command.waypoint.remove.error"))
}
}
}
@@ -234,7 +234,7 @@ object Waypoints {
"Invalid index $index provided."
)
- fun textNothingToExport(): Text =
+ fun textNothingToExport(): Component =
tr(
"firmament.command.waypoint.export.nowaypoints",
"No waypoints to export found. Add some with /firm waypoint ~ ~ ~."
diff --git a/src/main/kotlin/gui/BarComponent.kt b/src/main/kotlin/gui/BarComponent.kt
index b144e0d..4c0a52d 100644
--- a/src/main/kotlin/gui/BarComponent.kt
+++ b/src/main/kotlin/gui/BarComponent.kt
@@ -6,9 +6,9 @@ import io.github.notenoughupdates.moulconfig.gui.GuiImmediateContext
import io.github.notenoughupdates.moulconfig.observer.GetSetter
import io.github.notenoughupdates.moulconfig.platform.MoulConfigRenderContext
import me.shedaniel.math.Color
-import net.minecraft.client.gl.RenderPipelines
-import net.minecraft.client.gui.DrawContext
-import net.minecraft.util.Identifier
+import net.minecraft.client.renderer.RenderPipelines
+import net.minecraft.client.gui.GuiGraphics
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.Firmament
class BarComponent(
@@ -25,12 +25,12 @@ class BarComponent(
}
data class Texture(
- val identifier: Identifier,
- val u1: Float, val v1: Float,
- val u2: Float, val v2: Float,
+ val identifier: ResourceLocation,
+ val u1: Float, val v1: Float,
+ val u2: Float, val v2: Float,
) {
- fun draw(context: DrawContext, x: Int, y: Int, width: Int, height: Int, color: Color) {
- context.drawTexturedQuad(
+ fun draw(context: GuiGraphics, x: Int, y: Int, width: Int, height: Int, color: Color) {
+ context.innerBlit(
RenderPipelines.GUI_TEXTURED,
identifier,
x, y, x + width, x + height,
@@ -49,13 +49,13 @@ class BarComponent(
}
private fun drawSection(
- context: DrawContext,
- texture: Texture,
- x: Int,
- y: Int,
- width: Int,
- sectionStart: Double,
- sectionEnd: Double
+ context: GuiGraphics,
+ texture: Texture,
+ x: Int,
+ y: Int,
+ width: Int,
+ sectionStart: Double,
+ sectionEnd: Double
) {
if (sectionEnd < progress.get() && width == 4) {
texture.draw(context, x, y, 4, 8, fillColor)
@@ -107,6 +107,6 @@ class BarComponent(
}
-fun Identifier.toMoulConfig(): MyResourceLocation {
+fun ResourceLocation.toMoulConfig(): MyResourceLocation {
return MyResourceLocation(this.namespace, this.path)
}
diff --git a/src/main/kotlin/gui/CheckboxComponent.kt b/src/main/kotlin/gui/CheckboxComponent.kt
index 4d29a96..da3e5c8 100644
--- a/src/main/kotlin/gui/CheckboxComponent.kt
+++ b/src/main/kotlin/gui/CheckboxComponent.kt
@@ -5,7 +5,7 @@ import io.github.notenoughupdates.moulconfig.gui.GuiImmediateContext
import io.github.notenoughupdates.moulconfig.gui.MouseEvent
import io.github.notenoughupdates.moulconfig.observer.GetSetter
import io.github.notenoughupdates.moulconfig.platform.MoulConfigRenderContext
-import net.minecraft.client.gl.RenderPipelines
+import net.minecraft.client.renderer.RenderPipelines
import moe.nea.firmament.Firmament
class CheckboxComponent<T>(
@@ -26,7 +26,7 @@ class CheckboxComponent<T>(
override fun render(context: GuiImmediateContext) {
val ctx = (context.renderContext as MoulConfigRenderContext).drawContext
- ctx.drawGuiTexture(
+ ctx.blitSprite(
RenderPipelines.GUI_TEXTURED,
if (isEnabled()) Firmament.identifier("widget/checkbox_checked")
else Firmament.identifier("widget/checkbox_unchecked"),
diff --git a/src/main/kotlin/gui/config/AllConfigsGui.kt b/src/main/kotlin/gui/config/AllConfigsGui.kt
index 869bda6..60711ca 100644
--- a/src/main/kotlin/gui/config/AllConfigsGui.kt
+++ b/src/main/kotlin/gui/config/AllConfigsGui.kt
@@ -2,8 +2,8 @@ package moe.nea.firmament.gui.config
import io.github.notenoughupdates.moulconfig.observer.ObservableList
import io.github.notenoughupdates.moulconfig.xml.Bind
-import net.minecraft.client.gui.screen.Screen
-import net.minecraft.text.Text
+import net.minecraft.client.gui.screens.Screen
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.RestArgumentType
import moe.nea.firmament.commands.get
@@ -41,12 +41,12 @@ object AllConfigsGui {
@Bind
fun close() {
- MC.screen?.close()
+ MC.screen?.onClose()
}
class EntryMapping(val config: ManagedConfig) {
@Bind
- fun name() = Text.translatable("firmament.config.${config.name}")
+ fun name() = Component.translatable("firmament.config.${config.name}")
@Bind
fun openEditor() {
diff --git a/src/main/kotlin/gui/config/BuiltInConfigScreenProvider.kt b/src/main/kotlin/gui/config/BuiltInConfigScreenProvider.kt
index 8ecdfa2..6495e68 100644
--- a/src/main/kotlin/gui/config/BuiltInConfigScreenProvider.kt
+++ b/src/main/kotlin/gui/config/BuiltInConfigScreenProvider.kt
@@ -1,7 +1,7 @@
package moe.nea.firmament.gui.config
import com.google.auto.service.AutoService
-import net.minecraft.client.gui.screen.Screen
+import net.minecraft.client.gui.screens.Screen
@AutoService(FirmamentConfigScreenProvider::class)
class BuiltInConfigScreenProvider : FirmamentConfigScreenProvider {
diff --git a/src/main/kotlin/gui/config/ChoiceHandler.kt b/src/main/kotlin/gui/config/ChoiceHandler.kt
index 321b40d..494d08a 100644
--- a/src/main/kotlin/gui/config/ChoiceHandler.kt
+++ b/src/main/kotlin/gui/config/ChoiceHandler.kt
@@ -7,7 +7,7 @@ import io.github.notenoughupdates.moulconfig.gui.component.RowComponent
import io.github.notenoughupdates.moulconfig.gui.component.TextComponent
import kotlinx.serialization.json.JsonElement
import kotlin.jvm.optionals.getOrNull
-import net.minecraft.util.StringIdentifiable
+import net.minecraft.util.StringRepresentable
import moe.nea.firmament.gui.CheckboxComponent
import moe.nea.firmament.util.ErrorUtil
import moe.nea.firmament.util.data.ManagedConfig
@@ -16,8 +16,8 @@ import moe.nea.firmament.util.json.KJsonOps
class ChoiceHandler<E>(
val enumClass: Class<E>,
val universe: List<E>,
-) : ManagedConfig.OptionHandler<E> where E : Enum<E>, E : StringIdentifiable {
- val codec = StringIdentifiable.createCodec {
+) : ManagedConfig.OptionHandler<E> where E : Enum<E>, E : StringRepresentable {
+ val codec = StringRepresentable.fromEnum {
@Suppress("UNCHECKED_CAST", "PLATFORM_CLASS_MAPPED_TO_KOTLIN")
(universe as java.util.List<*>).toArray(arrayOfNulls<Enum<E>>(0)) as Array<E>
}
diff --git a/src/main/kotlin/gui/config/EnumRenderer.kt b/src/main/kotlin/gui/config/EnumRenderer.kt
index 3b80b7e..a2dee69 100644
--- a/src/main/kotlin/gui/config/EnumRenderer.kt
+++ b/src/main/kotlin/gui/config/EnumRenderer.kt
@@ -1,14 +1,14 @@
package moe.nea.firmament.gui.config
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
interface EnumRenderer<E : Any> {
- fun getName(option: ManagedOption<E>, value: E): Text
+ fun getName(option: ManagedOption<E>, value: E): Component
companion object {
fun <E : Enum<E>> default() = object : EnumRenderer<E> {
- override fun getName(option: ManagedOption<E>, value: E): Text {
- return Text.translatable(option.rawLabelText + ".choice." + value.name.lowercase())
+ override fun getName(option: ManagedOption<E>, value: E): Component {
+ return Component.translatable(option.rawLabelText + ".choice." + value.name.lowercase())
}
}
}
diff --git a/src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt b/src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt
index 8700ffa..d2a8ab6 100644
--- a/src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt
+++ b/src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt
@@ -1,6 +1,6 @@
package moe.nea.firmament.gui.config
-import net.minecraft.client.gui.screen.Screen
+import net.minecraft.client.gui.screens.Screen
import moe.nea.firmament.util.compatloader.CompatLoader
interface FirmamentConfigScreenProvider {
diff --git a/src/main/kotlin/gui/config/GuiAppender.kt b/src/main/kotlin/gui/config/GuiAppender.kt
index 329319d..ba28400 100644
--- a/src/main/kotlin/gui/config/GuiAppender.kt
+++ b/src/main/kotlin/gui/config/GuiAppender.kt
@@ -6,8 +6,8 @@ import io.github.notenoughupdates.moulconfig.gui.GuiComponent
import io.github.notenoughupdates.moulconfig.gui.component.RowComponent
import io.github.notenoughupdates.moulconfig.gui.component.TextComponent
import io.github.notenoughupdates.moulconfig.observer.GetSetter
-import net.minecraft.client.gui.screen.Screen
-import net.minecraft.text.Text
+import net.minecraft.client.gui.screens.Screen
+import net.minecraft.network.chat.Component
import moe.nea.firmament.gui.FixedComponent
class GuiAppender(val width: Int, val screenAccessor: () -> Screen) {
@@ -18,7 +18,7 @@ class GuiAppender(val width: Int, val screenAccessor: () -> Screen) {
reloadables.add(reloadable)
}
- fun appendLabeledRow(label: Text, right: GuiComponent) {
+ fun appendLabeledRow(label: Component, right: GuiComponent) {
appendSplitRow(
TextComponent(label.string),
right
diff --git a/src/main/kotlin/gui/config/HudMetaHandler.kt b/src/main/kotlin/gui/config/HudMetaHandler.kt
index fae827d..915dcf3 100644
--- a/src/main/kotlin/gui/config/HudMetaHandler.kt
+++ b/src/main/kotlin/gui/config/HudMetaHandler.kt
@@ -5,9 +5,9 @@ import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.decodeFromJsonElement
import kotlinx.serialization.json.encodeToJsonElement
-import net.minecraft.client.gui.screen.Screen
-import net.minecraft.text.MutableText
-import net.minecraft.text.Text
+import net.minecraft.client.gui.screens.Screen
+import net.minecraft.network.chat.MutableComponent
+import net.minecraft.network.chat.Component
import moe.nea.firmament.Firmament
import moe.nea.firmament.gui.FirmButtonComponent
import moe.nea.firmament.jarvis.JarvisIntegration
@@ -15,11 +15,11 @@ import moe.nea.firmament.util.MC
import moe.nea.firmament.util.data.ManagedConfig
class HudMetaHandler(
- val config: ManagedConfig,
- val propertyName: String,
- val label: MutableText,
- val width: Int,
- val height: Int
+ val config: ManagedConfig,
+ val propertyName: String,
+ val label: MutableComponent,
+ val width: Int,
+ val height: Int
) :
ManagedConfig.OptionHandler<HudMeta> {
override fun toJson(element: HudMeta): JsonElement? {
@@ -42,7 +42,7 @@ class HudMetaHandler(
opt.labelText,
FirmButtonComponent(
TextComponent(
- Text.stringifiedTranslatable("firmament.hud.edit", label).string
+ Component.translatableEscape("firmament.hud.edit", label).string
),
) {
openEditor(opt, guiAppender.screenAccessor())
diff --git a/src/main/kotlin/gui/config/JAnyHud.kt b/src/main/kotlin/gui/config/JAnyHud.kt
index 1cde4f9..63975c6 100644
--- a/src/main/kotlin/gui/config/JAnyHud.kt
+++ b/src/main/kotlin/gui/config/JAnyHud.kt
@@ -5,8 +5,8 @@ import org.joml.Matrix3x2f
import org.joml.Vector2i
import org.joml.Vector2ic
import kotlinx.serialization.Serializable
-import net.minecraft.text.Text
-import net.minecraft.util.Identifier
+import net.minecraft.network.chat.Component
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.jarvis.JarvisIntegration
@Serializable
@@ -18,13 +18,13 @@ data class HudPosition(
data class HudMeta(
- val position: HudPosition,
- private val id: Identifier,
- private val label: Text,
- private val width: Int,
- private val height: Int,
+ val position: HudPosition,
+ private val id: ResourceLocation,
+ private val label: Component,
+ private val width: Int,
+ private val height: Int,
) : JarvisHud, JarvisHud.Scalable {
- override fun getLabel(): Text = label
+ override fun getLabel(): Component = label
override fun getUnscaledWidth(): Int {
return width
}
@@ -33,7 +33,7 @@ data class HudMeta(
return height
}
- override fun getHudId(): Identifier {
+ override fun getHudId(): ResourceLocation {
return id
}
diff --git a/src/main/kotlin/gui/config/KeyBindingStateManager.kt b/src/main/kotlin/gui/config/KeyBindingStateManager.kt
index d8ec359..9cf2771 100644
--- a/src/main/kotlin/gui/config/KeyBindingStateManager.kt
+++ b/src/main/kotlin/gui/config/KeyBindingStateManager.kt
@@ -8,8 +8,8 @@ import io.github.notenoughupdates.moulconfig.gui.KeyboardEvent
import io.github.notenoughupdates.moulconfig.gui.component.TextComponent
import io.github.notenoughupdates.moulconfig.platform.MoulConfigPlatform
import org.lwjgl.glfw.GLFW
-import net.minecraft.text.Text
-import net.minecraft.util.Formatting
+import net.minecraft.network.chat.Component
+import net.minecraft.ChatFormatting
import moe.nea.firmament.gui.FirmButtonComponent
import moe.nea.firmament.keybindings.GenericInputButton
import moe.nea.firmament.keybindings.InputModifiers
@@ -23,7 +23,7 @@ class KeyBindingStateManager(
) {
var editing = false
var lastPressed: GenericInputButton? = null
- var label: Text = Text.literal("")
+ var label: Component = Component.literal("")
fun onClick(mouseButton: Int) {
if (editing) {
@@ -89,14 +89,14 @@ class KeyBindingStateManager(
fun updateLabel() {
var stroke = value().format()
if (editing) {
- stroke = Text.empty()
+ stroke = Component.empty()
val modifiers = InputModifiers.current()
if (!modifiers.isEmpty()) {
stroke.append(modifiers.format())
stroke.append(" + ")
}
stroke.append("???")
- stroke.styled { it.withColor(Formatting.YELLOW) }
+ stroke.withStyle { it.withColor(ChatFormatting.YELLOW) }
}
label = stroke
}
diff --git a/src/main/kotlin/gui/config/ManagedOption.kt b/src/main/kotlin/gui/config/ManagedOption.kt
index 1f742a7..4c228de 100644
--- a/src/main/kotlin/gui/config/ManagedOption.kt
+++ b/src/main/kotlin/gui/config/ManagedOption.kt
@@ -5,7 +5,7 @@ import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonObject
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.util.ErrorUtil
import moe.nea.firmament.util.data.ManagedConfig
@@ -24,9 +24,9 @@ class ManagedOption<T : Any>(
}
val rawLabelText = "firmament.config.${element.name}.${propertyName}"
- val labelText: Text = Text.translatable(rawLabelText)
+ val labelText: Component = Component.translatable(rawLabelText)
val descriptionTranslationKey = "firmament.config.${element.name}.${propertyName}.description"
- val labelDescription: Text = Text.translatable(descriptionTranslationKey)
+ val labelDescription: Component = Component.translatable(descriptionTranslationKey)
var _actualValue: T? = null
var value: T
diff --git a/src/main/kotlin/gui/config/StringHandler.kt b/src/main/kotlin/gui/config/StringHandler.kt
index f1eacab..17bb981 100644
--- a/src/main/kotlin/gui/config/StringHandler.kt
+++ b/src/main/kotlin/gui/config/StringHandler.kt
@@ -7,7 +7,7 @@ import io.github.notenoughupdates.moulconfig.observer.GetSetter
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonPrimitive
import kotlinx.serialization.json.jsonPrimitive
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.util.data.ManagedConfig
class StringHandler(val config: ManagedConfig) : ManagedConfig.OptionHandler<String> {
@@ -30,7 +30,7 @@ class StringHandler(val config: ManagedConfig) : ManagedConfig.OptionHandler<Str
}
},
130,
- suggestion = Text.translatableWithFallback(opt.rawLabelText + ".hint", "").string
+ suggestion = Component.translatableWithFallback(opt.rawLabelText + ".hint", "").string
),
)
}
diff --git a/src/main/kotlin/gui/entity/EntityModifier.kt b/src/main/kotlin/gui/entity/EntityModifier.kt
index 9623070..4915ebb 100644
--- a/src/main/kotlin/gui/entity/EntityModifier.kt
+++ b/src/main/kotlin/gui/entity/EntityModifier.kt
@@ -2,7 +2,7 @@
package moe.nea.firmament.gui.entity
import com.google.gson.JsonObject
-import net.minecraft.entity.LivingEntity
+import net.minecraft.world.entity.LivingEntity
fun interface EntityModifier {
fun apply(entity: LivingEntity, info: JsonObject): LivingEntity
diff --git a/src/main/kotlin/gui/entity/EntityRenderer.kt b/src/main/kotlin/gui/entity/EntityRenderer.kt
index 3e21710..2381b69 100644
--- a/src/main/kotlin/gui/entity/EntityRenderer.kt
+++ b/src/main/kotlin/gui/entity/EntityRenderer.kt
@@ -6,14 +6,14 @@ import com.google.gson.JsonObject
import org.joml.Quaternionf
import org.joml.Vector3f
import kotlin.math.atan
-import net.minecraft.client.gui.DrawContext
-import net.minecraft.client.gui.screen.ingame.InventoryScreen
-import net.minecraft.entity.Entity
-import net.minecraft.entity.EntityType
-import net.minecraft.entity.LivingEntity
-import net.minecraft.entity.SpawnReason
-import net.minecraft.util.Identifier
-import net.minecraft.world.World
+import net.minecraft.client.gui.GuiGraphics
+import net.minecraft.client.gui.screens.inventory.InventoryScreen
+import net.minecraft.world.entity.Entity
+import net.minecraft.world.entity.EntityType
+import net.minecraft.world.entity.LivingEntity
+import net.minecraft.world.entity.EntitySpawnReason
+import net.minecraft.resources.ResourceLocation
+import net.minecraft.world.level.Level
import moe.nea.firmament.util.ErrorUtil
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.iterate
@@ -21,9 +21,9 @@ import moe.nea.firmament.util.openFirmamentResource
import moe.nea.firmament.util.render.enableScissorWithTranslation
object EntityRenderer {
- val fakeWorld: World get() = MC.lastWorld!!
+ val fakeWorld: Level get() = MC.lastWorld!!
private fun <T : Entity> t(entityType: EntityType<T>): () -> T {
- return { entityType.create(fakeWorld, SpawnReason.LOAD)!! }
+ return { entityType.create(fakeWorld, EntitySpawnReason.LOAD)!! }
}
val entityIds: Map<String, () -> LivingEntity> = mapOf(
@@ -139,7 +139,7 @@ object EntityRenderer {
}
private val gson = Gson()
- fun constructEntity(location: Identifier): LivingEntity? {
+ fun constructEntity(location: ResourceLocation): LivingEntity? {
return constructEntity(
gson.fromJson(
location.openFirmamentResource().bufferedReader(), JsonObject::class.java
@@ -149,7 +149,7 @@ object EntityRenderer {
fun renderEntity(
entity: LivingEntity,
- renderContext: DrawContext,
+ renderContext: GuiGraphics,
posX: Int,
posY: Int,
// TODO: Add width, height properties here
@@ -162,10 +162,10 @@ object EntityRenderer {
var bottomOffset = 0.0
var currentEntity = entity
val maxSize = entity.iterate { it.firstPassenger as? LivingEntity }
- .map { it.height }
+ .map { it.bbHeight }
.sum()
while (true) {
- currentEntity.age = MC.player?.age ?: 0
+ currentEntity.tickCount = MC.player?.tickCount ?: 0
drawEntity(
renderContext,
posX,
@@ -179,14 +179,14 @@ object EntityRenderer {
currentEntity
)
val next = currentEntity.firstPassenger as? LivingEntity ?: break
- bottomOffset += currentEntity.getPassengerRidingPos(next).y.toFloat() * 0.75F
+ bottomOffset += currentEntity.getPassengerRidingPosition(next).y.toFloat() * 0.75F
currentEntity = next
}
}
fun drawEntity(
- context: DrawContext,
+ context: GuiGraphics,
x1: Int,
y1: Int,
x2: Int,
@@ -203,22 +203,22 @@ object EntityRenderer {
val hw = (x2 - x1) / 2
val hh = (y2 - y1) / 2
val targetYaw = atan(((centerX - mouseX) / hw)).toFloat()
- val targetPitch = atan(((centerY - mouseY) / hh - entity.standingEyeHeight * hh / 40)).toFloat()
+ val targetPitch = atan(((centerY - mouseY) / hh - entity.eyeHeight * hh / 40)).toFloat()
val rotateToFaceTheFront = Quaternionf().rotateZ(Math.PI.toFloat())
val rotateToFaceTheCamera = Quaternionf().rotateX(targetPitch * 20.0f * (Math.PI.toFloat() / 180))
rotateToFaceTheFront.mul(rotateToFaceTheCamera)
- val oldBodyYaw = entity.bodyYaw
- val oldYaw = entity.yaw
- val oldPitch = entity.pitch
- val oldPrevHeadYaw = entity.lastHeadYaw
- val oldHeadYaw = entity.headYaw
- entity.bodyYaw = 180.0f + targetYaw * 20.0f
- entity.yaw = 180.0f + targetYaw * 40.0f
- entity.pitch = -targetPitch * 20.0f
- entity.headYaw = entity.yaw
- entity.lastHeadYaw = entity.yaw
- val vector3f = Vector3f(0.0f, (entity.height / 2.0f + bottomOffset).toFloat(), 0.0f)
- InventoryScreen.drawEntity( // TODO: fix multiple entities rendering the same entity
+ val oldBodyYaw = entity.yBodyRot
+ val oldYaw = entity.yRot
+ val oldPitch = entity.xRot
+ val oldPrevHeadYaw = entity.yHeadRotO
+ val oldHeadYaw = entity.yHeadRot
+ entity.yBodyRot = 180.0f + targetYaw * 20.0f
+ entity.yRot = 180.0f + targetYaw * 40.0f
+ entity.xRot = -targetPitch * 20.0f
+ entity.yHeadRot = entity.yRot
+ entity.yHeadRotO = entity.yRot
+ val vector3f = Vector3f(0.0f, (entity.bbHeight / 2.0f + bottomOffset).toFloat(), 0.0f)
+ InventoryScreen.renderEntityInInventory( // TODO: fix multiple entities rendering the same entity
context,
x1, y1,
x2, y2,
@@ -228,11 +228,11 @@ object EntityRenderer {
rotateToFaceTheCamera,
entity
)
- entity.bodyYaw = oldBodyYaw
- entity.yaw = oldYaw
- entity.pitch = oldPitch
- entity.lastHeadYaw = oldPrevHeadYaw
- entity.headYaw = oldHeadYaw
+ entity.yBodyRot = oldBodyYaw
+ entity.yRot = oldYaw
+ entity.xRot = oldPitch
+ entity.yHeadRotO = oldPrevHeadYaw
+ entity.yHeadRot = oldHeadYaw
context.disableScissor()
}
diff --git a/src/main/kotlin/gui/entity/GuiPlayer.kt b/src/main/kotlin/gui/entity/GuiPlayer.kt
index 2598de6..b53f68c 100644
--- a/src/main/kotlin/gui/entity/GuiPlayer.kt
+++ b/src/main/kotlin/gui/entity/GuiPlayer.kt
@@ -1,28 +1,28 @@
package moe.nea.firmament.gui.entity
-import net.minecraft.client.network.ClientMannequinEntity
-import net.minecraft.client.util.DefaultSkinHelper
-import net.minecraft.client.world.ClientWorld
-import net.minecraft.entity.player.SkinTextures
-import net.minecraft.world.World
+import net.minecraft.client.entity.ClientMannequin
+import net.minecraft.client.resources.DefaultPlayerSkin
+import net.minecraft.client.multiplayer.ClientLevel
+import net.minecraft.world.entity.player.PlayerSkin
+import net.minecraft.world.level.Level
import moe.nea.firmament.util.MC
-fun makeGuiPlayer(world: World): GuiPlayer {
- val player = GuiPlayer(MC.instance.world!!)
+fun makeGuiPlayer(world: Level): GuiPlayer {
+ val player = GuiPlayer(MC.instance.level!!)
return player
}
-class GuiPlayer(world: ClientWorld?) : ClientMannequinEntity(world, MC.instance.playerSkinCache) {
+class GuiPlayer(world: ClientLevel?) : ClientMannequin(world, MC.instance.playerSkinRenderCache()) {
override fun isSpectator(): Boolean {
return false
}
- override fun shouldRenderName(): Boolean {
+ override fun shouldShowName(): Boolean {
return false
}
- var skinTextures: SkinTextures = DefaultSkinHelper.getSkinTextures(this.getUuid()) // TODO: 1.21.10
- override fun getSkin(): SkinTextures {
+ var skinTextures: PlayerSkin = DefaultPlayerSkin.get(this.uuid) // TODO: 1.21.10
+ override fun getSkin(): PlayerSkin {
return skinTextures
}
}
diff --git a/src/main/kotlin/gui/entity/ModifyAge.kt b/src/main/kotlin/gui/entity/ModifyAge.kt
index a65c368..99154ef 100644
--- a/src/main/kotlin/gui/entity/ModifyAge.kt
+++ b/src/main/kotlin/gui/entity/ModifyAge.kt
@@ -2,19 +2,19 @@
package moe.nea.firmament.gui.entity
import com.google.gson.JsonObject
-import net.minecraft.entity.LivingEntity
-import net.minecraft.entity.decoration.ArmorStandEntity
-import net.minecraft.entity.mob.ZombieEntity
-import net.minecraft.entity.passive.PassiveEntity
+import net.minecraft.world.entity.LivingEntity
+import net.minecraft.world.entity.decoration.ArmorStand
+import net.minecraft.world.entity.monster.Zombie
+import net.minecraft.world.entity.AgeableMob
object ModifyAge : EntityModifier {
override fun apply(entity: LivingEntity, info: JsonObject): LivingEntity {
val isBaby = info["baby"]?.asBoolean ?: false
- if (entity is PassiveEntity) {
- entity.breedingAge = if (isBaby) -1 else 1
- } else if (entity is ZombieEntity) {
+ if (entity is AgeableMob) {
+ entity.age = if (isBaby) -1 else 1
+ } else if (entity is Zombie) {
entity.isBaby = isBaby
- } else if (entity is ArmorStandEntity) {
+ } else if (entity is ArmorStand) {
entity.isSmall = isBaby
} else {
error("Cannot set age for $entity")
diff --git a/src/main/kotlin/gui/entity/ModifyCharged.kt b/src/main/kotlin/gui/entity/ModifyCharged.kt
index d22f6e3..23fd495 100644
--- a/src/main/kotlin/gui/entity/ModifyCharged.kt
+++ b/src/main/kotlin/gui/entity/ModifyCharged.kt
@@ -2,13 +2,13 @@
package moe.nea.firmament.gui.entity
import com.google.gson.JsonObject
-import net.minecraft.entity.LivingEntity
-import net.minecraft.entity.mob.CreeperEntity
+import net.minecraft.world.entity.LivingEntity
+import net.minecraft.world.entity.monster.Creeper
object ModifyCharged : EntityModifier {
override fun apply(entity: LivingEntity, info: JsonObject): LivingEntity {
- require(entity is CreeperEntity)
- entity.dataTracker.set(CreeperEntity.CHARGED, true)
+ require(entity is Creeper)
+ entity.entityData.set(Creeper.DATA_IS_POWERED, true)
return entity
}
}
diff --git a/src/main/kotlin/gui/entity/ModifyEquipment.kt b/src/main/kotlin/gui/entity/ModifyEquipment.kt
index b2c6e5b..9c43e73 100644
--- a/src/main/kotlin/gui/entity/ModifyEquipment.kt
+++ b/src/main/kotlin/gui/entity/ModifyEquipment.kt
@@ -1,13 +1,13 @@
package moe.nea.firmament.gui.entity
import com.google.gson.JsonObject
-import net.minecraft.component.DataComponentTypes
-import net.minecraft.component.type.DyedColorComponent
-import net.minecraft.entity.EquipmentSlot
-import net.minecraft.entity.LivingEntity
-import net.minecraft.item.Item
-import net.minecraft.item.ItemStack
-import net.minecraft.item.Items
+import net.minecraft.core.component.DataComponents
+import net.minecraft.world.item.component.DyedItemColor
+import net.minecraft.world.entity.EquipmentSlot
+import net.minecraft.world.entity.LivingEntity
+import net.minecraft.world.item.Item
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.item.Items
import moe.nea.firmament.repo.ExpensiveItemCacheApi
import moe.nea.firmament.repo.SBItemStack
import moe.nea.firmament.util.SkyblockId
@@ -26,7 +26,7 @@ object ModifyEquipment : EntityModifier {
override fun apply(entity: LivingEntity, info: JsonObject): LivingEntity {
names.forEach { (key, slot) ->
info[key]?.let {
- entity.equipStack(slot, createItem(it.asString))
+ entity.setItemSlot(slot, createItem(it.asString))
}
}
return entity
@@ -49,7 +49,7 @@ object ModifyEquipment : EntityModifier {
private fun coloredLeatherArmor(leatherArmor: Item, data: String): ItemStack {
val stack = ItemStack(leatherArmor)
- stack.set(DataComponentTypes.DYED_COLOR, DyedColorComponent(data.toInt(16)))
+ stack.set(DataComponents.DYED_COLOR, DyedItemColor(data.toInt(16)))
return stack
}
}
diff --git a/src/main/kotlin/gui/entity/ModifyHorse.kt b/src/main/kotlin/gui/entity/ModifyHorse.kt
index c797f14..a870bf1 100644
--- a/src/main/kotlin/gui/entity/ModifyHorse.kt
+++ b/src/main/kotlin/gui/entity/ModifyHorse.kt
@@ -2,26 +2,26 @@ package moe.nea.firmament.gui.entity
import com.google.gson.JsonNull
import com.google.gson.JsonObject
-import net.minecraft.entity.EntityType
-import net.minecraft.entity.EquipmentSlot
-import net.minecraft.entity.LivingEntity
-import net.minecraft.entity.SpawnReason
-import net.minecraft.entity.passive.AbstractHorseEntity
-import net.minecraft.item.ItemStack
-import net.minecraft.item.Items
+import net.minecraft.world.entity.EntityType
+import net.minecraft.world.entity.EquipmentSlot
+import net.minecraft.world.entity.LivingEntity
+import net.minecraft.world.entity.EntitySpawnReason
+import net.minecraft.world.entity.animal.horse.AbstractHorse
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.item.Items
import moe.nea.firmament.gui.entity.EntityRenderer.fakeWorld
object ModifyHorse : EntityModifier {
override fun apply(entity: LivingEntity, info: JsonObject): LivingEntity {
- require(entity is AbstractHorseEntity)
- var entity: AbstractHorseEntity = entity
+ require(entity is AbstractHorse)
+ var entity: AbstractHorse = entity
info["kind"]?.let {
entity = when (it.asString) {
- "skeleton" -> EntityType.SKELETON_HORSE.create(fakeWorld, SpawnReason.LOAD)!!
- "zombie" -> EntityType.ZOMBIE_HORSE.create(fakeWorld, SpawnReason.LOAD)!!
- "mule" -> EntityType.MULE.create(fakeWorld, SpawnReason.LOAD)!!
- "donkey" -> EntityType.DONKEY.create(fakeWorld, SpawnReason.LOAD)!!
- "horse" -> EntityType.HORSE.create(fakeWorld, SpawnReason.LOAD)!!
+ "skeleton" -> EntityType.SKELETON_HORSE.create(fakeWorld, EntitySpawnReason.LOAD)!!
+ "zombie" -> EntityType.ZOMBIE_HORSE.create(fakeWorld, EntitySpawnReason.LOAD)!!
+ "mule" -> EntityType.MULE.create(fakeWorld, EntitySpawnReason.LOAD)!!
+ "donkey" -> EntityType.DONKEY.create(fakeWorld, EntitySpawnReason.LOAD)!!
+ "horse" -> EntityType.HORSE.create(fakeWorld, EntitySpawnReason.LOAD)!!
else -> error("Unknown horse kind $it")
}
}
@@ -45,12 +45,14 @@ object ModifyHorse : EntityModifier {
}
-fun AbstractHorseEntity.setIsSaddled(shouldBeSaddled: Boolean) {
- this.equipStack(EquipmentSlot.SADDLE,
- if (shouldBeSaddled) ItemStack(Items.SADDLE)
- else ItemStack.EMPTY)
+fun AbstractHorse.setIsSaddled(shouldBeSaddled: Boolean) {
+ this.setItemSlot(
+ EquipmentSlot.SADDLE,
+ if (shouldBeSaddled) ItemStack(Items.SADDLE)
+ else ItemStack.EMPTY
+ )
}
-fun AbstractHorseEntity.setHorseArmor(itemStack: ItemStack) {
- this.equipBodyArmor(itemStack)
+fun AbstractHorse.setHorseArmor(itemStack: ItemStack) {
+ bodyArmorItem = itemStack
}
diff --git a/src/main/kotlin/gui/entity/ModifyInvisible.kt b/src/main/kotlin/gui/entity/ModifyInvisible.kt
index 8d36991..7a54ab1 100644
--- a/src/main/kotlin/gui/entity/ModifyInvisible.kt
+++ b/src/main/kotlin/gui/entity/ModifyInvisible.kt
@@ -2,7 +2,7 @@
package moe.nea.firmament.gui.entity
import com.google.gson.JsonObject
-import net.minecraft.entity.LivingEntity
+import net.minecraft.world.entity.LivingEntity
object ModifyInvisible : EntityModifier {
override fun apply(entity: LivingEntity, info: JsonObject): LivingEntity {
diff --git a/src/main/kotlin/gui/entity/ModifyName.kt b/src/main/kotlin/gui/entity/ModifyName.kt
index a03da96..6def0b4 100644
--- a/src/main/kotlin/gui/entity/ModifyName.kt
+++ b/src/main/kotlin/gui/entity/ModifyName.kt
@@ -2,12 +2,12 @@
package moe.nea.firmament.gui.entity
import com.google.gson.JsonObject
-import net.minecraft.entity.LivingEntity
-import net.minecraft.text.Text
+import net.minecraft.world.entity.LivingEntity
+import net.minecraft.network.chat.Component
object ModifyName : EntityModifier {
override fun apply(entity: LivingEntity, info: JsonObject): LivingEntity {
- entity.customName = Text.literal(info.get("name").asString)
+ entity.customName = Component.literal(info.get("name").asString)
return entity
}
diff --git a/src/main/kotlin/gui/entity/ModifyPlayerSkin.kt b/src/main/kotlin/gui/entity/ModifyPlayerSkin.kt
index 48cd855..0b393bb 100644
--- a/src/main/kotlin/gui/entity/ModifyPlayerSkin.kt
+++ b/src/main/kotlin/gui/entity/ModifyPlayerSkin.kt
@@ -4,35 +4,35 @@ import com.google.gson.JsonObject
import com.google.gson.JsonPrimitive
import kotlin.experimental.and
import kotlin.experimental.or
-import net.minecraft.client.network.ClientPlayerLikeEntity
-import net.minecraft.entity.LivingEntity
-import net.minecraft.entity.PlayerLikeEntity
-import net.minecraft.entity.player.PlayerEntity
-import net.minecraft.entity.player.PlayerModelPart
-import net.minecraft.entity.player.PlayerSkinType
-import net.minecraft.entity.player.SkinTextures
-import net.minecraft.util.AssetInfo
-import net.minecraft.util.Identifier
+import net.minecraft.client.entity.ClientAvatarEntity
+import net.minecraft.world.entity.LivingEntity
+import net.minecraft.world.entity.Avatar
+import net.minecraft.world.entity.player.Player
+import net.minecraft.world.entity.player.PlayerModelPart
+import net.minecraft.world.entity.player.PlayerModelType
+import net.minecraft.world.entity.player.PlayerSkin
+import net.minecraft.core.ClientAsset
+import net.minecraft.resources.ResourceLocation
object ModifyPlayerSkin : EntityModifier {
- val playerModelPartIndex = PlayerModelPart.entries.associateBy { it.getName() }
+ val playerModelPartIndex = PlayerModelPart.entries.associateBy { it.id }
override fun apply(entity: LivingEntity, info: JsonObject): LivingEntity {
require(entity is GuiPlayer)
var capeTexture = entity.skinTextures.cape
var model = entity.skinTextures.model
var bodyTexture = entity.skinTextures.body
- fun mkTexAsset(id: Identifier) = AssetInfo.TextureAssetInfo(id, id)
+ fun mkTexAsset(id: ResourceLocation) = ClientAsset.ResourceTexture(id, id)
info["cape"]?.let {
- capeTexture = mkTexAsset(Identifier.of(it.asString))
+ capeTexture = mkTexAsset(ResourceLocation.parse(it.asString))
}
info["skin"]?.let {
- bodyTexture = mkTexAsset(Identifier.of(it.asString))
+ bodyTexture = mkTexAsset(ResourceLocation.parse(it.asString))
}
info["slim"]?.let {
- model = if (it.asBoolean) PlayerSkinType.SLIM else PlayerSkinType.WIDE
+ model = if (it.asBoolean) PlayerModelType.SLIM else PlayerModelType.WIDE
}
info["parts"]?.let {
- var trackedData = entity.dataTracker.get(PlayerLikeEntity.PLAYER_MODE_CUSTOMIZATION_ID)
+ var trackedData = entity.entityData.get(Avatar.DATA_PLAYER_MODE_CUSTOMISATION)
if (it is JsonPrimitive && it.isBoolean) {
trackedData = (if (it.asBoolean) -1 else 0).toByte()
} else {
@@ -40,15 +40,15 @@ object ModifyPlayerSkin : EntityModifier {
for ((k, v) in obj.entrySet()) {
val part = playerModelPartIndex[k]!!
trackedData = if (v.asBoolean) {
- trackedData and (part.bitFlag.inv().toByte())
+ trackedData and (part.mask.inv().toByte())
} else {
- trackedData or (part.bitFlag.toByte())
+ trackedData or (part.mask.toByte())
}
}
}
- entity.dataTracker.set(PlayerEntity.PLAYER_MODE_CUSTOMIZATION_ID, trackedData)
+ entity.entityData.set(Player.DATA_PLAYER_MODE_CUSTOMISATION, trackedData)
}
- entity.skinTextures = SkinTextures(
+ entity.skinTextures = PlayerSkin(
bodyTexture, capeTexture, null, model, true
)
return entity
diff --git a/src/main/kotlin/gui/entity/ModifyRiding.kt b/src/main/kotlin/gui/entity/ModifyRiding.kt
index d482b37..51fcfae 100644
--- a/src/main/kotlin/gui/entity/ModifyRiding.kt
+++ b/src/main/kotlin/gui/entity/ModifyRiding.kt
@@ -2,7 +2,7 @@
package moe.nea.firmament.gui.entity
import com.google.gson.JsonObject
-import net.minecraft.entity.LivingEntity
+import net.minecraft.world.entity.LivingEntity
object ModifyRiding : EntityModifier {
override fun apply(entity: LivingEntity, info: JsonObject): LivingEntity {
diff --git a/src/main/kotlin/gui/entity/ModifyWither.kt b/src/main/kotlin/gui/entity/ModifyWither.kt
index 6083d88..67252b8 100644
--- a/src/main/kotlin/gui/entity/ModifyWither.kt
+++ b/src/main/kotlin/gui/entity/ModifyWither.kt
@@ -2,14 +2,14 @@
package moe.nea.firmament.gui.entity
import com.google.gson.JsonObject
-import net.minecraft.entity.LivingEntity
-import net.minecraft.entity.boss.WitherEntity
+import net.minecraft.world.entity.LivingEntity
+import net.minecraft.world.entity.boss.wither.WitherBoss
object ModifyWither : EntityModifier {
override fun apply(entity: LivingEntity, info: JsonObject): LivingEntity {
- require(entity is WitherEntity)
+ require(entity is WitherBoss)
info["tiny"]?.let {
- entity.setInvulTimer(if (it.asBoolean) 800 else 0)
+ entity.invulnerableTicks = if (it.asBoolean) 800 else 0
}
info["armored"]?.let {
entity.health = if (it.asBoolean) 1F else entity.maxHealth
diff --git a/src/main/kotlin/gui/hud/MoulConfigHud.kt b/src/main/kotlin/gui/hud/MoulConfigHud.kt
index 8259ebe..b5d7cf7 100644
--- a/src/main/kotlin/gui/hud/MoulConfigHud.kt
+++ b/src/main/kotlin/gui/hud/MoulConfigHud.kt
@@ -3,9 +3,9 @@ package moe.nea.firmament.gui.hud
import io.github.notenoughupdates.moulconfig.gui.GuiContext
import io.github.notenoughupdates.moulconfig.gui.component.TextComponent
import io.github.notenoughupdates.moulconfig.platform.MoulConfigScreenComponent
-import net.minecraft.resource.ResourceManager
-import net.minecraft.resource.SynchronousResourceReloader
-import net.minecraft.text.Text
+import net.minecraft.server.packs.resources.ResourceManager
+import net.minecraft.server.packs.resources.ResourceManagerReloadListener
+import net.minecraft.network.chat.Component
import moe.nea.firmament.events.FinalizeResourceManagerEvent
import moe.nea.firmament.events.HudRenderEvent
import moe.nea.firmament.gui.config.HudMeta
@@ -19,9 +19,9 @@ abstract class MoulConfigHud(
) {
companion object {
private val componentWrapper by lazy {
- object : MoulConfigScreenComponent(Text.empty(), GuiContext(TextComponent("§cERROR")), null) {
+ object : MoulConfigScreenComponent(Component.empty(), GuiContext(TextComponent("§cERROR")), null) {
init {
- this.client = MC.instance
+ this.minecraft = MC.instance
}
}
}
@@ -43,18 +43,18 @@ abstract class MoulConfigHud(
val renderContext = componentWrapper.createContext(it.context)
if (fragment == null)
loadFragment()
- it.context.matrices.pushMatrix()
- hudMeta.applyTransformations(it.context.matrices)
+ it.context.pose().pushMatrix()
+ hudMeta.applyTransformations(it.context.pose())
val pos = hudMeta.getEffectivePosition(JarvisIntegration.jarvis)
val renderContextTranslated =
renderContext.translated(pos.x(), pos.y(), hudMeta.effectiveWidth, hudMeta.effectiveHeight)
.scaled(hudMeta.scale)
fragment!!.root.render(renderContextTranslated)
- it.context.matrices.popMatrix()
+ it.context.pose().popMatrix()
}
FinalizeResourceManagerEvent.subscribe("MoulConfigHud:finalizeResourceManager") {
- MC.resourceManager.registerReloader(object : SynchronousResourceReloader {
- override fun reload(manager: ResourceManager?) {
+ MC.resourceManager.registerReloadListener(object : ResourceManagerReloadListener {
+ override fun onResourceManagerReload(manager: ResourceManager?) {
fragment = null
}
})
diff --git a/src/main/kotlin/jarvis/JarvisIntegration.kt b/src/main/kotlin/jarvis/JarvisIntegration.kt
index 18c46c9..58c606b 100644
--- a/src/main/kotlin/jarvis/JarvisIntegration.kt
+++ b/src/main/kotlin/jarvis/JarvisIntegration.kt
@@ -6,8 +6,8 @@ import moe.nea.jarvis.api.Jarvis
import moe.nea.jarvis.api.JarvisConfigOption
import moe.nea.jarvis.api.JarvisHud
import moe.nea.jarvis.api.JarvisPlugin
-import net.minecraft.client.gui.screen.Screen
-import net.minecraft.text.Text
+import net.minecraft.client.gui.screens.Screen
+import net.minecraft.network.chat.Component
import moe.nea.firmament.Firmament
import moe.nea.firmament.gui.config.HudMeta
import moe.nea.firmament.gui.config.HudMetaHandler
@@ -44,11 +44,11 @@ class JarvisIntegration : JarvisPlugin {
return configs.flatMap { config ->
config.sortedOptions.map {
object : JarvisConfigOption {
- override fun title(): Text {
+ override fun title(): Component {
return it.labelText
}
- override fun description(): List<Text> {
+ override fun description(): List<Component> {
return emptyList()
}
diff --git a/src/main/kotlin/keybindings/FirmamentKeyBindings.kt b/src/main/kotlin/keybindings/FirmamentKeyBindings.kt
index fe87eff..c0fe995 100644
--- a/src/main/kotlin/keybindings/FirmamentKeyBindings.kt
+++ b/src/main/kotlin/keybindings/FirmamentKeyBindings.kt
@@ -1,18 +1,18 @@
package moe.nea.firmament.keybindings
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper
-import net.minecraft.client.option.KeyBinding
-import net.minecraft.client.util.InputUtil
+import net.minecraft.client.KeyMapping
+import com.mojang.blaze3d.platform.InputConstants
import moe.nea.firmament.Firmament
import moe.nea.firmament.gui.config.ManagedOption
import moe.nea.firmament.util.TestUtil
object FirmamentKeyBindings {
- val cat = KeyBinding.Category(Firmament.identifier("category"))
+ val cat = KeyMapping.Category(Firmament.identifier("category"))
fun registerKeyBinding(name: String, config: ManagedOption<SavedKeyBinding>) {
- val vanillaKeyBinding = KeyBinding(
+ val vanillaKeyBinding = KeyMapping(
name,
- InputUtil.Type.KEYSYM,
+ InputConstants.Type.KEYSYM,
-1,
cat
)
@@ -22,6 +22,6 @@ object FirmamentKeyBindings {
keyBindings[vanillaKeyBinding] = config
}
- val keyBindings = mutableMapOf<KeyBinding, ManagedOption<SavedKeyBinding>>()
+ val keyBindings = mutableMapOf<KeyMapping, ManagedOption<SavedKeyBinding>>()
}
diff --git a/src/main/kotlin/keybindings/FirmamentKeyboardState.kt b/src/main/kotlin/keybindings/FirmamentKeyboardState.kt
index dc20630..da94a44 100644
--- a/src/main/kotlin/keybindings/FirmamentKeyboardState.kt
+++ b/src/main/kotlin/keybindings/FirmamentKeyboardState.kt
@@ -2,7 +2,7 @@ package moe.nea.firmament.keybindings
import java.util.BitSet
import org.lwjgl.glfw.GLFW
-import net.minecraft.client.input.KeyInput
+import net.minecraft.client.input.KeyEvent
object FirmamentKeyboardState {
@@ -15,7 +15,7 @@ object FirmamentKeyboardState {
}
@Synchronized
- fun maintainState(keyInput: KeyInput, action: Int) {
+ fun maintainState(keyInput: KeyEvent, action: Int) {
when (action) {
GLFW.GLFW_PRESS -> pressedScancodes.set(keyInput.scancode)
GLFW.GLFW_RELEASE -> pressedScancodes.clear(keyInput.scancode)
diff --git a/src/main/kotlin/keybindings/GenericInputButton.kt b/src/main/kotlin/keybindings/GenericInputButton.kt
index 3876573..4a4aaba 100644
--- a/src/main/kotlin/keybindings/GenericInputButton.kt
+++ b/src/main/kotlin/keybindings/GenericInputButton.kt
@@ -13,14 +13,14 @@ import kotlinx.serialization.json.JsonPrimitive
import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.int
import kotlinx.serialization.json.put
-import net.minecraft.client.MinecraftClient
-import net.minecraft.client.gui.Click
-import net.minecraft.client.input.AbstractInput
-import net.minecraft.client.input.KeyInput
-import net.minecraft.client.input.MouseInput
-import net.minecraft.client.util.InputUtil
-import net.minecraft.client.util.MacWindowUtil
-import net.minecraft.text.Text
+import net.minecraft.client.Minecraft
+import net.minecraft.client.input.MouseButtonEvent
+import net.minecraft.client.input.InputWithModifiers
+import net.minecraft.client.input.KeyEvent
+import net.minecraft.client.input.MouseButtonInfo
+import com.mojang.blaze3d.platform.InputConstants
+import com.mojang.blaze3d.platform.MacosUtil
+import net.minecraft.network.chat.Component
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.mc.InitLevel
@@ -65,7 +65,7 @@ sealed interface GenericInputButton {
companion object {
- fun of(event: KeyInput) = ofKeyAndScan(event.keycode, event.scancode)
+ fun of(event: KeyEvent) = ofKeyAndScan(event.input(), event.scancode)
fun escape() = ofKeyCode(GLFW.GLFW_KEY_ESCAPE)
fun ofKeyCode(keyCode: Int): GenericInputButton = KeyCodeButton(keyCode)
fun ofScanCode(scanCode: Int): GenericInputButton = ScanCodeButton(scanCode)
@@ -80,8 +80,8 @@ sealed interface GenericInputButton {
}
data object Unbound : GenericInputButton {
- override fun toInputKey(): InputUtil.Key {
- return InputUtil.UNKNOWN_KEY
+ override fun toInputKey(): InputConstants.Key {
+ return InputConstants.UNKNOWN
}
override fun isBound(): Boolean {
@@ -96,24 +96,24 @@ sealed interface GenericInputButton {
data class MouseButton(
val mouseButton: Int
) : GenericInputButton {
- override fun toInputKey(): InputUtil.Key {
- return InputUtil.Type.MOUSE.createFromCode(mouseButton)
+ override fun toInputKey(): InputConstants.Key {
+ return InputConstants.Type.MOUSE.getOrCreate(mouseButton)
}
override fun isPressed(): Boolean {
- return GLFW.glfwGetMouseButton(MC.window.handle, mouseButton) == GLFW.GLFW_PRESS
+ return GLFW.glfwGetMouseButton(MC.window.handle(), mouseButton) == GLFW.GLFW_PRESS
}
}
data class KeyCodeButton(
val keyCode: Int
) : GenericInputButton {
- override fun toInputKey(): InputUtil.Key {
- return InputUtil.Type.KEYSYM.createFromCode(keyCode)
+ override fun toInputKey(): InputConstants.Key {
+ return InputConstants.Type.KEYSYM.getOrCreate(keyCode)
}
override fun isPressed(): Boolean {
- return InputUtil.isKeyPressed(MC.window, keyCode)
+ return InputConstants.isKeyDown(MC.window, keyCode)
}
override fun isCtrl(): Boolean {
@@ -136,8 +136,8 @@ sealed interface GenericInputButton {
data class ScanCodeButton(
val scanCode: Int
) : GenericInputButton {
- override fun toInputKey(): InputUtil.Key {
- return InputUtil.Type.SCANCODE.createFromCode(scanCode)
+ override fun toInputKey(): InputConstants.Key {
+ return InputConstants.Type.SCANCODE.getOrCreate(scanCode)
}
override fun isPressed(): Boolean {
@@ -153,12 +153,12 @@ sealed interface GenericInputButton {
fun isSuper() = false
fun isShift() = false
- fun toInputKey(): InputUtil.Key
- fun format(): Text =
+ fun toInputKey(): InputConstants.Key
+ fun format(): Component =
if (InitLevel.isAtLeast(InitLevel.RENDER_INIT)) {
- toInputKey().localizedText
+ toInputKey().displayName
} else {
- Text.of(toString())
+ Component.nullToEmpty(toString())
}
fun matches(inputAction: GenericInputAction) = inputAction.matches(this)
@@ -194,12 +194,12 @@ sealed interface GenericInputAction {
fun mouse(mouseButton: Int): GenericInputAction = MouseInput(mouseButton)
@JvmStatic
- fun mouse(click: Click): GenericInputAction = mouse(click.button())
+ fun mouse(click: MouseButtonEvent): GenericInputAction = mouse(click.button())
@JvmStatic
- fun of(input: net.minecraft.client.input.MouseInput): GenericInputAction = mouse(input.button)
+ fun of(input: net.minecraft.client.input.MouseButtonInfo): GenericInputAction = mouse(input.button)
@JvmStatic
- fun of(input: KeyInput): GenericInputAction = key(input.keycode, input.scancode)
+ fun of(input: KeyEvent): GenericInputAction = key(input.input(), input.scancode)
@JvmStatic
fun key(keyCode: Int, scanCode: Int): GenericInputAction = KeyboardInput(keyCode, scanCode)
@@ -214,19 +214,19 @@ data class InputModifiers(
@JvmStatic
fun current(): InputModifiers {
val h = MC.window
- val ctrl = if (MacWindowUtil.IS_MAC) {
- InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_LEFT_SUPER)
- || InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_RIGHT_SUPER)
- } else InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_LEFT_CONTROL)
- || InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_RIGHT_CONTROL)
- val shift = InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_LEFT_SHIFT) || InputUtil.isKeyPressed(
+ val ctrl = if (MacosUtil.IS_MACOS) {
+ InputConstants.isKeyDown(h, GLFW.GLFW_KEY_LEFT_SUPER)
+ || InputConstants.isKeyDown(h, GLFW.GLFW_KEY_RIGHT_SUPER)
+ } else InputConstants.isKeyDown(h, GLFW.GLFW_KEY_LEFT_CONTROL)
+ || InputConstants.isKeyDown(h, GLFW.GLFW_KEY_RIGHT_CONTROL)
+ val shift = InputConstants.isKeyDown(h, GLFW.GLFW_KEY_LEFT_SHIFT) || InputConstants.isKeyDown(
h,
GLFW.GLFW_KEY_RIGHT_SHIFT
)
- val alt = InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_LEFT_ALT)
- || InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_RIGHT_ALT)
- val `super` = InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_LEFT_SUPER)
- || InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_RIGHT_SUPER)
+ val alt = InputConstants.isKeyDown(h, GLFW.GLFW_KEY_LEFT_ALT)
+ || InputConstants.isKeyDown(h, GLFW.GLFW_KEY_RIGHT_ALT)
+ val `super` = InputConstants.isKeyDown(h, GLFW.GLFW_KEY_LEFT_SUPER)
+ || InputConstants.isKeyDown(h, GLFW.GLFW_KEY_RIGHT_SUPER)
return of(
ctrl = ctrl,
shift = shift,
@@ -237,7 +237,7 @@ data class InputModifiers(
val superKeys = listOf(GLFW.GLFW_KEY_LEFT_SUPER, GLFW.GLFW_KEY_RIGHT_SUPER)
- val controlKeys = if (MacWindowUtil.IS_MAC) {
+ val controlKeys = if (MacosUtil.IS_MACOS) {
listOf(GLFW.GLFW_KEY_LEFT_SUPER, GLFW.GLFW_KEY_RIGHT_SUPER)
} else {
listOf(GLFW.GLFW_KEY_LEFT_CONTROL, GLFW.GLFW_KEY_RIGHT_CONTROL)
@@ -280,7 +280,7 @@ data class InputModifiers(
fun of(modifiers: Int) = InputModifiers(modifiers)
@JvmStatic
- fun of(input: AbstractInput) = InputModifiers(input.modifiers())
+ fun of(input: InputWithModifiers) = InputModifiers(input.modifiers())
fun none(): InputModifiers {
return InputModifiers(0)
@@ -325,8 +325,8 @@ data class InputModifiers(
return this == other
}
- fun format(): Text { // TODO: translation for mods
- return Text.of(toString())
+ fun format(): Component { // TODO: translation for mods
+ return Component.nullToEmpty(toString())
}
}
diff --git a/src/main/kotlin/keybindings/SavedKeyBinding.kt b/src/main/kotlin/keybindings/SavedKeyBinding.kt
index 8f08e5f..91d88ca 100644
--- a/src/main/kotlin/keybindings/SavedKeyBinding.kt
+++ b/src/main/kotlin/keybindings/SavedKeyBinding.kt
@@ -1,7 +1,7 @@
package moe.nea.firmament.keybindings
import kotlinx.serialization.Serializable
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
@Serializable
data class SavedKeyBinding(
@@ -30,8 +30,8 @@ data class SavedKeyBinding(
return format().string
}
- fun format(): Text {
- val stroke = Text.empty()
+ fun format(): Component {
+ val stroke = Component.empty()
if (!modifiers.isEmpty()) {
stroke.append(modifiers.format())
stroke.append(" + ")
diff --git a/src/main/kotlin/repo/ItemCache.kt b/src/main/kotlin/repo/ItemCache.kt
index 0aa4a44..be07042 100644
--- a/src/main/kotlin/repo/ItemCache.kt
+++ b/src/main/kotlin/repo/ItemCache.kt
@@ -19,21 +19,21 @@ import kotlinx.coroutines.withContext
import kotlin.io.path.readText
import kotlin.jvm.optionals.getOrNull
import net.minecraft.SharedConstants
-import net.minecraft.component.DataComponentTypes
-import net.minecraft.component.type.NbtComponent
-import net.minecraft.datafixer.Schemas
-import net.minecraft.datafixer.TypeReferences
-import net.minecraft.item.ItemStack
-import net.minecraft.item.Items
-import net.minecraft.nbt.NbtCompound
-import net.minecraft.nbt.NbtElement
+import net.minecraft.core.component.DataComponents
+import net.minecraft.nbt.CompoundTag
import net.minecraft.nbt.NbtOps
-import net.minecraft.nbt.NbtString
-import net.minecraft.nbt.StringNbtReader
-import net.minecraft.text.MutableText
-import net.minecraft.text.Style
-import net.minecraft.text.Text
-import net.minecraft.util.Identifier
+import net.minecraft.nbt.StringTag
+import net.minecraft.nbt.Tag
+import net.minecraft.nbt.TagParser
+import net.minecraft.network.chat.Component
+import net.minecraft.network.chat.MutableComponent
+import net.minecraft.network.chat.Style
+import net.minecraft.resources.ResourceLocation
+import net.minecraft.util.datafix.DataFixers
+import net.minecraft.util.datafix.fixes.References
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.item.Items
+import net.minecraft.world.item.component.CustomData
import moe.nea.firmament.Firmament
import moe.nea.firmament.features.debug.ExportedTestConstantMeta
import moe.nea.firmament.repo.RepoManager.initialize
@@ -56,12 +56,12 @@ import moe.nea.firmament.util.transformEachRecursively
object ItemCache : IReloadable {
private val cache: MutableMap<String, ItemStack> = ConcurrentHashMap()
- private val df = Schemas.getFixer()
+ private val df = DataFixers.getDataFixer()
val logger = LogManager.getLogger("${Firmament.logger.name}.ItemCache")
var isFlawless = true
private set
- private fun NEUItem.get10809CompoundTag(): NbtCompound = NbtCompound().apply {
+ private fun NEUItem.get10809CompoundTag(): CompoundTag = CompoundTag().apply {
put("tag", LegacyTagParser.parse(nbttag))
putString("id", minecraftItemId)
putByte("Count", 1)
@@ -69,18 +69,18 @@ object ItemCache : IReloadable {
}
@ExpensiveItemCacheApi
- private fun NbtCompound.transformFrom10809ToModern() = convert189ToModern(this@transformFrom10809ToModern)
- val currentSaveVersion = SharedConstants.getGameVersion().dataVersion().id
+ private fun CompoundTag.transformFrom10809ToModern() = convert189ToModern(this@transformFrom10809ToModern)
+ val currentSaveVersion = SharedConstants.getCurrentVersion().dataVersion().version
@ExpensiveItemCacheApi
- fun convert189ToModern(nbtComponent: NbtCompound): NbtCompound? =
+ fun convert189ToModern(nbtComponent: CompoundTag): CompoundTag? =
try {
df.update(
- TypeReferences.ITEM_STACK,
+ References.ITEM_STACK,
Dynamic(NbtOps.INSTANCE, nbtComponent),
-1,
currentSaveVersion
- ).value as NbtCompound
+ ).value as CompoundTag
} catch (e: Exception) {
isFlawless = false
logger.error("Could not data fix up $this", e)
@@ -97,24 +97,24 @@ object ItemCache : IReloadable {
fun brokenItemStack(neuItem: NEUItem?, idHint: SkyblockId? = null): ItemStack {
return ItemStack(Items.PAINTING).apply {
- setCustomName(Text.literal(neuItem?.displayName ?: idHint?.neuItem ?: "null"))
+ setCustomName(Component.literal(neuItem?.displayName ?: idHint?.neuItem ?: "null"))
appendLore(
listOf(
- Text.stringifiedTranslatable(
+ Component.translatableEscape(
"firmament.repo.brokenitem",
(neuItem?.skyblockItemId ?: idHint)
)
)
)
- set(DataComponentTypes.CUSTOM_DATA, NbtComponent.of(NbtCompound().apply {
- put("ID", NbtString.of(neuItem?.skyblockItemId ?: idHint?.neuItem ?: "null"))
+ set(DataComponents.CUSTOM_DATA, CustomData.of(CompoundTag().apply {
+ put("ID", StringTag.valueOf(neuItem?.skyblockItemId ?: idHint?.neuItem ?: "null"))
}))
set(FirmamentDataComponentTypes.IS_BROKEN, true)
}
}
- fun un189Lore(lore: String): MutableText {
- val base = Text.literal("")
+ fun un189Lore(lore: String): MutableComponent {
+ val base = Component.literal("")
base.setStyle(Style.EMPTY.withItalic(false))
var lastColorCode = Style.EMPTY
var readOffset = 0
@@ -125,7 +125,7 @@ object ItemCache : IReloadable {
}
val text = lore.substring(readOffset, nextCode)
if (text.isNotEmpty()) {
- base.append(Text.literal(text).setStyle(lastColorCode))
+ base.append(Component.literal(text).setStyle(lastColorCode))
}
readOffset = nextCode + 2
if (nextCode + 1 < lore.length) {
@@ -135,27 +135,27 @@ object ItemCache : IReloadable {
if (modernFormatting.isColor) {
lastColorCode = Style.EMPTY.withColor(modernFormatting)
} else {
- lastColorCode = lastColorCode.withFormatting(modernFormatting)
+ lastColorCode = lastColorCode.applyFormat(modernFormatting)
}
}
}
return base
}
- fun tryFindFromModernFormat(skyblockId: SkyblockId): NbtCompound? {
+ fun tryFindFromModernFormat(skyblockId: SkyblockId): CompoundTag? {
val overlayFile =
RepoManager.overlayData.getMostModernReadableOverlay(skyblockId, currentSaveVersion) ?: return null
- val overlay = StringNbtReader.readCompound(overlayFile.path.readText())
+ val overlay = TagParser.parseCompoundFully(overlayFile.path.readText())
val result = ExportedTestConstantMeta.SOURCE_CODEC.decode(
NbtOps.INSTANCE, overlay
).result().getOrNull() ?: return null
val meta = result.first
return df.update(
- TypeReferences.ITEM_STACK,
+ References.ITEM_STACK,
Dynamic(NbtOps.INSTANCE, result.second),
meta.dataVersion,
currentSaveVersion
- ).value as NbtCompound
+ ).value as CompoundTag
}
@ExpensiveItemCacheApi
@@ -177,10 +177,10 @@ object ItemCache : IReloadable {
val extraAttributes = tag.flatMap { it.getCompound("ExtraAttributes") }
.getOrNull()
if (extraAttributes != null)
- itemInstance.set(DataComponentTypes.CUSTOM_DATA, NbtComponent.of(extraAttributes))
+ itemInstance.set(DataComponents.CUSTOM_DATA, CustomData.of(extraAttributes))
val itemModel = tag.flatMap { it.getString("ItemModel") }.getOrNull()
if (itemModel != null)
- itemInstance.set(DataComponentTypes.ITEM_MODEL, Identifier.of(itemModel))
+ itemInstance.set(DataComponents.ITEM_MODEL, ResourceLocation.parse(itemModel))
}
itemInstance.loreAccordingToNbt = lore.map { un189Lore(it) }
itemInstance.displayNameAccordingToNbt = un189Lore(displayName)
@@ -206,7 +206,7 @@ object ItemCache : IReloadable {
if (!loreReplacements.isNullOrEmpty()) {
s = s.copy()!!
s.applyLoreReplacements(loreReplacements)
- s.setCustomName(s.name.applyLoreReplacements(loreReplacements))
+ s.setCustomName(s.hoverName.applyLoreReplacements(loreReplacements))
}
return s
}
@@ -219,13 +219,13 @@ object ItemCache : IReloadable {
}
}
- fun Text.applyLoreReplacements(loreReplacements: Map<String, String>): Text {
+ fun Component.applyLoreReplacements(loreReplacements: Map<String, String>): Component {
return this.transformEachRecursively {
var string = it.directLiteralStringContent ?: return@transformEachRecursively it
loreReplacements.forEach { (find, replace) ->
string = string.replace("{$find}", replace)
}
- Text.literal(string).setStyle(it.style)
+ Component.literal(string).setStyle(it.style)
}
}
@@ -289,7 +289,7 @@ object ItemCache : IReloadable {
"http://textures.minecraft.net/texture/7b951fed6a7b2cbc2036916dec7a46c4a56481564d14f945b6ebc03382766d3b"
}
val itemStack = ItemStack(Items.PLAYER_HEAD)
- itemStack.setCustomName(Text.literal("§r§6" + NumberFormat.getInstance().format(coinAmount) + " Coins"))
+ itemStack.setCustomName(Component.literal("§r§6" + NumberFormat.getInstance().format(coinAmount) + " Coins"))
itemStack.setSkullOwner(uuid, texture)
return itemStack
}
@@ -303,10 +303,10 @@ object ItemCache : IReloadable {
}
-operator fun NbtCompound.set(key: String, value: String) {
+operator fun CompoundTag.set(key: String, value: String) {
putString(key, value)
}
-operator fun NbtCompound.set(key: String, value: NbtElement) {
+operator fun CompoundTag.set(key: String, value: Tag) {
put(key, value)
}
diff --git a/src/main/kotlin/repo/MiningRepoData.kt b/src/main/kotlin/repo/MiningRepoData.kt
index a987ab1..5b5b016 100644
--- a/src/main/kotlin/repo/MiningRepoData.kt
+++ b/src/main/kotlin/repo/MiningRepoData.kt
@@ -9,11 +9,11 @@ import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient
import kotlinx.serialization.serializer
import kotlin.streams.asSequence
-import net.minecraft.block.Block
-import net.minecraft.item.BlockItem
-import net.minecraft.item.ItemStack
-import net.minecraft.nbt.NbtCompound
-import net.minecraft.text.Text
+import net.minecraft.world.level.block.Block
+import net.minecraft.world.item.BlockItem
+import net.minecraft.world.item.ItemStack
+import net.minecraft.nbt.CompoundTag
+import net.minecraft.network.chat.Component
import moe.nea.firmament.repo.ReforgeStore.kJson
import moe.nea.firmament.util.SBData
import moe.nea.firmament.util.SkyBlockIsland
@@ -87,7 +87,7 @@ class MiningRepoData : IReloadable {
private fun markItemStack(itemStack: ItemStack) {
itemStack.set(FirmamentDataComponentTypes.CUSTOM_MINING_BLOCK_DATA, this)
if (name != null)
- itemStack.displayNameAccordingToNbt = Text.literal(name)
+ itemStack.displayNameAccordingToNbt = Component.literal(name)
}
fun getDisplayItem(block: Block): ItemStack {
@@ -112,7 +112,7 @@ class MiningRepoData : IReloadable {
@OptIn(ExpensiveItemCacheApi::class)
private fun convertToModernBlock(): Block? {
// TODO: this should be in a shared util, really
- val newCompound = ItemCache.convert189ToModern(NbtCompound().apply {
+ val newCompound = ItemCache.convert189ToModern(CompoundTag().apply {
putString("id", itemId)
putShort("Damage", damage)
}) ?: return null
diff --git a/src/main/kotlin/repo/Reforge.kt b/src/main/kotlin/repo/Reforge.kt
index dc0d93d..5f6506f 100644
--- a/src/main/kotlin/repo/Reforge.kt
+++ b/src/main/kotlin/repo/Reforge.kt
@@ -13,10 +13,10 @@ import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.JsonPrimitive
import kotlinx.serialization.serializer
-import net.minecraft.item.Item
-import net.minecraft.registry.RegistryKey
-import net.minecraft.registry.RegistryKeys
-import net.minecraft.util.Identifier
+import net.minecraft.world.item.Item
+import net.minecraft.resources.ResourceKey
+import net.minecraft.core.registries.Registries
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.util.ReforgeId
import moe.nea.firmament.util.SkyblockId
import moe.nea.firmament.util.skyblock.ItemType
@@ -64,9 +64,9 @@ data class Reforge(
}
jsonElement["itemId"]?.let {
decoder.json.decodeFromJsonElement(serializer<List<String>>(), it).forEach {
- val ident = Identifier.tryParse(it)
+ val ident = ResourceLocation.tryParse(it)
if (ident != null)
- filters.add(AllowsVanillaItemType(RegistryKey.of(RegistryKeys.ITEM, ident)))
+ filters.add(AllowsVanillaItemType(ResourceKey.create(Registries.ITEM, ident)))
}
}
return filters
@@ -90,8 +90,8 @@ data class Reforge(
return AllowsItemType(ItemType.ofName((it as JsonPrimitive).content))
}
jsonObject["minecraftId"]?.let {
- return AllowsVanillaItemType(RegistryKey.of(RegistryKeys.ITEM,
- Identifier.of((it as JsonPrimitive).content)))
+ return AllowsVanillaItemType(ResourceKey.create(Registries.ITEM,
+ ResourceLocation.parse((it as JsonPrimitive).content)))
}
error("Unknown item type")
}
@@ -104,7 +104,7 @@ data class Reforge(
data class AllowsItemType(val itemType: ItemType) : ReforgeEligibilityFilter
data class AllowsInternalName(val internalName: SkyblockId) : ReforgeEligibilityFilter
- data class AllowsVanillaItemType(val minecraftId: RegistryKey<Item>) : ReforgeEligibilityFilter
+ data class AllowsVanillaItemType(val minecraftId: ResourceKey<Item>) : ReforgeEligibilityFilter
}
diff --git a/src/main/kotlin/repo/ReforgeStore.kt b/src/main/kotlin/repo/ReforgeStore.kt
index 4c01974..cf8b434 100644
--- a/src/main/kotlin/repo/ReforgeStore.kt
+++ b/src/main/kotlin/repo/ReforgeStore.kt
@@ -9,8 +9,8 @@ import io.github.moulberry.repo.NEURepositoryException
import io.github.moulberry.repo.data.NEURecipe
import kotlinx.serialization.KSerializer
import kotlinx.serialization.serializer
-import net.minecraft.item.Item
-import net.minecraft.registry.RegistryKey
+import net.minecraft.world.item.Item
+import net.minecraft.resources.ResourceKey
import moe.nea.firmament.Firmament
import moe.nea.firmament.util.ReforgeId
import moe.nea.firmament.util.SkyblockId
@@ -23,7 +23,7 @@ object ReforgeStore : ExtraRecipeProvider, IReloadable {
}
var byType: Map<ItemType, List<Reforge>> = mapOf()
- var byVanilla: Map<RegistryKey<Item>, List<Reforge>> = mapOf()
+ var byVanilla: Map<ResourceKey<Item>, List<Reforge>> = mapOf()
var byInternalName: Map<SkyblockId, List<Reforge>> = mapOf()
var modifierLut = mapOf<ReforgeId, Reforge>()
var byReforgeStone = mapOf<SkyblockId, Reforge>()
@@ -52,7 +52,7 @@ object ReforgeStore : ExtraRecipeProvider, IReloadable {
byReforgeStone = allReforges.filter { it.reforgeStone != null }
.associateBy { it.reforgeStone!! }
val byType = mutableMapOf<ItemType, MutableList<Reforge>>()
- val byVanilla = mutableMapOf<RegistryKey<Item>, MutableList<Reforge>>()
+ val byVanilla = mutableMapOf<ResourceKey<Item>, MutableList<Reforge>>()
val byInternalName = mutableMapOf<SkyblockId, MutableList<Reforge>>()
this.byType = byType
this.byVanilla = byVanilla
diff --git a/src/main/kotlin/repo/RepoManager.kt b/src/main/kotlin/repo/RepoManager.kt
index 3a245b6..c8da6a7 100644
--- a/src/main/kotlin/repo/RepoManager.kt
+++ b/src/main/kotlin/repo/RepoManager.kt
@@ -10,10 +10,10 @@ import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
-import net.minecraft.client.MinecraftClient
-import net.minecraft.network.packet.s2c.play.SynchronizeRecipesS2CPacket
-import net.minecraft.recipe.display.CuttingRecipeDisplay
-import net.minecraft.util.StringIdentifiable
+import net.minecraft.client.Minecraft
+import net.minecraft.network.protocol.game.ClientboundUpdateRecipesPacket
+import net.minecraft.world.item.crafting.SelectableRecipe
+import net.minecraft.util.StringRepresentable
import moe.nea.firmament.Firmament
import moe.nea.firmament.Firmament.logger
import moe.nea.firmament.events.ReloadRegistrationEvent
@@ -56,7 +56,7 @@ object RepoManager {
val perfectRenders by choice("perfect-renders") { PerfectRender.RENDER }
}
- enum class PerfectRender(val label: String) : StringIdentifiable {
+ enum class PerfectRender(val label: String) : StringRepresentable {
NOTHING("nothing"),
RENDER("render"),
RENDER_AND_TEXT("text"),
@@ -65,7 +65,7 @@ object RepoManager {
fun rendersPerfectText() = this == RENDER_AND_TEXT
fun rendersPerfectVisuals() = this == RENDER || this == RENDER_AND_TEXT
- override fun asString(): String? = label
+ override fun getSerializedName(): String? = label
}
val currentDownloadedSha by RepoDownloadManager::latestSavedVersionHash
@@ -112,8 +112,8 @@ object RepoManager {
fun getUsagesFor(skyblockId: SkyblockId): Set<NEURecipe> = recipeCache.usages[skyblockId] ?: setOf()
private fun trySendClientboundUpdateRecipesPacket(): Boolean {
- return MinecraftClient.getInstance().world != null && MinecraftClient.getInstance().networkHandler?.onSynchronizeRecipes(
- SynchronizeRecipesS2CPacket(mutableMapOf(), CuttingRecipeDisplay.Grouping.empty())
+ return Minecraft.getInstance().level != null && Minecraft.getInstance().connection?.handleUpdateRecipes(
+ ClientboundUpdateRecipesPacket(mutableMapOf(), SelectableRecipe.SingleInputSet.empty())
) != null
}
diff --git a/src/main/kotlin/repo/RepoModResourcePack.kt b/src/main/kotlin/repo/RepoModResourcePack.kt
index 8b201af..cd0bc63 100644
--- a/src/main/kotlin/repo/RepoModResourcePack.kt
+++ b/src/main/kotlin/repo/RepoModResourcePack.kt
@@ -12,19 +12,19 @@ import kotlin.io.path.exists
import kotlin.io.path.isRegularFile
import kotlin.io.path.relativeTo
import kotlin.streams.asSequence
-import net.minecraft.resource.AbstractFileResourcePack
-import net.minecraft.resource.InputSupplier
-import net.minecraft.resource.NamespaceResourceManager
-import net.minecraft.resource.Resource
-import net.minecraft.resource.ResourcePack
-import net.minecraft.resource.ResourcePackInfo
-import net.minecraft.resource.ResourcePackSource
-import net.minecraft.resource.ResourceType
-import net.minecraft.resource.metadata.ResourceMetadata
-import net.minecraft.resource.metadata.ResourceMetadataSerializer
-import net.minecraft.text.Text
-import net.minecraft.util.Identifier
-import net.minecraft.util.path.PathUtil
+import net.minecraft.server.packs.AbstractPackResources
+import net.minecraft.server.packs.resources.IoSupplier
+import net.minecraft.server.packs.resources.FallbackResourceManager
+import net.minecraft.server.packs.resources.Resource
+import net.minecraft.server.packs.PackResources
+import net.minecraft.server.packs.PackLocationInfo
+import net.minecraft.server.packs.repository.PackSource
+import net.minecraft.server.packs.PackType
+import net.minecraft.server.packs.resources.ResourceMetadata
+import net.minecraft.server.packs.metadata.MetadataSectionType
+import net.minecraft.network.chat.Component
+import net.minecraft.resources.ResourceLocation
+import net.minecraft.FileUtil
import moe.nea.firmament.Firmament
class RepoModResourcePack(val basePath: Path) : ModResourcePack {
@@ -34,19 +34,19 @@ class RepoModResourcePack(val basePath: Path) : ModResourcePack {
packs.addPack(RepoModResourcePack(RepoDownloadManager.repoSavedLocation))
}
- fun createResourceDirectly(identifier: Identifier): Optional<Resource> {
+ fun createResourceDirectly(identifier: ResourceLocation): Optional<Resource> {
val pack = RepoModResourcePack(RepoDownloadManager.repoSavedLocation)
return Optional.of(
Resource(
pack,
- pack.open(ResourceType.CLIENT_RESOURCES, identifier) ?: return Optional.empty()
+ pack.getResource(PackType.CLIENT_RESOURCES, identifier) ?: return Optional.empty()
) {
val base =
- pack.open(ResourceType.CLIENT_RESOURCES, identifier.withPath(identifier.path + ".mcmeta"))
+ pack.getResource(PackType.CLIENT_RESOURCES, identifier.withPath(identifier.path + ".mcmeta"))
if (base == null)
- ResourceMetadata.NONE
+ ResourceMetadata.EMPTY
else
- NamespaceResourceManager.loadMetadata(base)
+ FallbackResourceManager.parseMetadata(base)
}
)
}
@@ -55,32 +55,32 @@ class RepoModResourcePack(val basePath: Path) : ModResourcePack {
override fun close() {
}
- override fun openRoot(vararg segments: String): InputSupplier<InputStream>? {
- return getFile(segments)?.let { InputSupplier.create(it) }
+ override fun getRootResource(vararg segments: String): IoSupplier<InputStream>? {
+ return getFile(segments)?.let { IoSupplier.create(it) }
}
fun getFile(segments: Array<out String>): Path? {
- PathUtil.validatePath(*segments)
+ FileUtil.validatePath(*segments)
val path = segments.fold(basePath, Path::resolve)
if (!path.isRegularFile()) return null
return path
}
- override fun open(type: ResourceType?, id: Identifier): InputSupplier<InputStream>? {
- if (type != ResourceType.CLIENT_RESOURCES) return null
+ override fun getResource(type: PackType?, id: ResourceLocation): IoSupplier<InputStream>? {
+ if (type != PackType.CLIENT_RESOURCES) return null
if (id.namespace != "neurepo") return null
val file = getFile(id.path.split("/").toTypedArray())
- return file?.let { InputSupplier.create(it) }
+ return file?.let { IoSupplier.create(it) }
}
- override fun findResources(
- type: ResourceType?,
+ override fun listResources(
+ type: PackType?,
namespace: String,
prefix: String,
- consumer: ResourcePack.ResultConsumer
+ consumer: PackResources.ResourceOutput
) {
if (namespace != "neurepo") return
- if (type != ResourceType.CLIENT_RESOURCES) return
+ if (type != PackType.CLIENT_RESOURCES) return
val prefixPath = basePath.resolve(prefix)
if (!prefixPath.exists())
@@ -90,19 +90,19 @@ class RepoModResourcePack(val basePath: Path) : ModResourcePack {
.map { it.relativeTo(basePath) }
.forEach {
consumer.accept(
- Identifier.tryParse("neurepo", it.toString()) ?: return@forEach,
- InputSupplier.create(it)
+ ResourceLocation.tryBuild("neurepo", it.toString()) ?: return@forEach,
+ IoSupplier.create(it)
)
}
}
- override fun getNamespaces(type: ResourceType?): Set<String> {
- if (type != ResourceType.CLIENT_RESOURCES) return emptySet()
+ override fun getNamespaces(type: PackType?): Set<String> {
+ if (type != PackType.CLIENT_RESOURCES) return emptySet()
return setOf("neurepo")
}
- override fun <T : Any?> parseMetadata(metadataSerializer: ResourceMetadataSerializer<T>?): T? {
- return AbstractFileResourcePack.parseMetadata(
+ override fun <T : Any?> getMetadataSection(metadataSerializer: MetadataSectionType<T>?): T? {
+ return AbstractPackResources.getMetadataFromStream(
metadataSerializer, """
{
"pack": {
@@ -110,13 +110,13 @@ class RepoModResourcePack(val basePath: Path) : ModResourcePack {
"description": "NEU Repo Resources"
}
}
-""".trimIndent().byteInputStream(), info
+""".trimIndent().byteInputStream(), location()
)
}
- override fun getInfo(): ResourcePackInfo {
- return ResourcePackInfo("neurepo", Text.literal("NEU Repo"), ResourcePackSource.BUILTIN, Optional.empty())
+ override fun location(): PackLocationInfo {
+ return PackLocationInfo("neurepo", Component.literal("NEU Repo"), PackSource.BUILT_IN, Optional.empty())
}
override fun getFabricModMetadata(): ModMetadata {
diff --git a/src/main/kotlin/repo/SBItemStack.kt b/src/main/kotlin/repo/SBItemStack.kt
index 01d1c4d..80cd5d7 100644
--- a/src/main/kotlin/repo/SBItemStack.kt
+++ b/src/main/kotlin/repo/SBItemStack.kt
@@ -5,14 +5,14 @@ import com.mojang.serialization.codecs.RecordCodecBuilder
import io.github.moulberry.repo.constants.PetNumbers
import io.github.moulberry.repo.data.NEUIngredient
import io.github.moulberry.repo.data.NEUItem
-import net.minecraft.item.ItemStack
-import net.minecraft.network.RegistryByteBuf
-import net.minecraft.network.codec.PacketCodec
-import net.minecraft.network.codec.PacketCodecs
-import net.minecraft.text.Style
-import net.minecraft.text.Text
-import net.minecraft.text.TextColor
-import net.minecraft.util.Formatting
+import net.minecraft.world.item.ItemStack
+import net.minecraft.network.RegistryFriendlyByteBuf
+import net.minecraft.network.codec.StreamCodec
+import net.minecraft.network.codec.ByteBufCodecs
+import net.minecraft.network.chat.Style
+import net.minecraft.network.chat.Component
+import net.minecraft.network.chat.TextColor
+import net.minecraft.ChatFormatting
import moe.nea.firmament.repo.ItemCache.asItemStack
import moe.nea.firmament.repo.ItemCache.withFallback
import moe.nea.firmament.util.FirmFormatters
@@ -48,7 +48,7 @@ data class SBItemStack constructor(
val neuItem: NEUItem?,
private var stackSize: Int,
private var petData: PetData?,
- val extraLore: List<Text> = emptyList(),
+ val extraLore: List<Component> = emptyList(),
val stars: Int = 0,
val fallback: ItemStack? = null,
val reforge: ReforgeId? = null,
@@ -67,9 +67,9 @@ data class SBItemStack constructor(
}
companion object {
- val PACKET_CODEC: PacketCodec<in RegistryByteBuf, SBItemStack> = PacketCodec.tuple(
+ val PACKET_CODEC: StreamCodec<in RegistryFriendlyByteBuf, SBItemStack> = StreamCodec.composite(
SkyblockId.PACKET_CODEC, { it.skyblockId },
- PacketCodecs.VAR_INT, { it.stackSize },
+ ByteBufCodecs.VAR_INT, { it.stackSize },
{ id, count -> SBItemStack(id, count) }
)
val CODEC: Codec<SBItemStack> = RecordCodecBuilder.create {
@@ -136,7 +136,7 @@ data class SBItemStack constructor(
loreMut[i] = statLine.addStat(statBuff, buffKind).reconstitute()
}
if (namedReforgeStats.isNotEmpty() && statBlockLastIndex == -1) {
- loreMut.add(0, Text.literal(""))
+ loreMut.add(0, Component.literal(""))
}
// If there is no stat block the statBlockLastIndex falls through to -1
// TODO: this is good enough for some items. some other items might have their stats at a different place.
@@ -149,47 +149,47 @@ data class SBItemStack constructor(
data class StatFormatting(
val postFix: String,
- val color: Formatting,
+ val color: ChatFormatting,
val isStarAffected: Boolean = true,
)
val formattingOverrides = mapOf(
- "Sea Creature Chance" to StatFormatting("%", Formatting.RED),
- "Strength" to StatFormatting("", Formatting.RED),
- "Damage" to StatFormatting("", Formatting.RED),
- "Bonus Attack Speed" to StatFormatting("%", Formatting.RED),
- "Shot Cooldown" to StatFormatting("s", Formatting.GREEN, false),
- "Ability Damage" to StatFormatting("%", Formatting.RED),
- "Crit Damage" to StatFormatting("%", Formatting.RED),
- "Crit Chance" to StatFormatting("%", Formatting.RED),
- "Ability Damage" to StatFormatting("%", Formatting.RED),
- "Trophy Fish Chance" to StatFormatting("%", Formatting.GREEN),
- "Health" to StatFormatting("", Formatting.GREEN),
- "Defense" to StatFormatting("", Formatting.GREEN),
- "Fishing Speed" to StatFormatting("", Formatting.GREEN),
- "Double Hook Chance" to StatFormatting("%", Formatting.GREEN),
- "Mining Speed" to StatFormatting("", Formatting.GREEN),
- "Mining Fortune" to StatFormatting("", Formatting.GREEN),
- "Heat Resistance" to StatFormatting("", Formatting.GREEN),
- "Swing Range" to StatFormatting("", Formatting.GREEN),
- "Rift Time" to StatFormatting("", Formatting.GREEN),
- "Speed" to StatFormatting("", Formatting.GREEN),
- "Farming Fortune" to StatFormatting("", Formatting.GREEN),
- "True Defense" to StatFormatting("", Formatting.GREEN),
- "Mending" to StatFormatting("", Formatting.GREEN),
- "Foraging Wisdom" to StatFormatting("", Formatting.GREEN),
- "Farming Wisdom" to StatFormatting("", Formatting.GREEN),
- "Foraging Fortune" to StatFormatting("", Formatting.GREEN),
- "Magic Find" to StatFormatting("", Formatting.GREEN),
- "Ferocity" to StatFormatting("", Formatting.GREEN),
- "Bonus Pest Chance" to StatFormatting("%", Formatting.GREEN),
- "Cold Resistance" to StatFormatting("", Formatting.GREEN),
- "Pet Luck" to StatFormatting("", Formatting.GREEN),
- "Fear" to StatFormatting("", Formatting.GREEN),
- "Mana Regen" to StatFormatting("%", Formatting.GREEN),
- "Rift Damage" to StatFormatting("", Formatting.GREEN),
- "Hearts" to StatFormatting("", Formatting.GREEN),
- "Vitality" to StatFormatting("", Formatting.GREEN),
+ "Sea Creature Chance" to StatFormatting("%", ChatFormatting.RED),
+ "Strength" to StatFormatting("", ChatFormatting.RED),
+ "Damage" to StatFormatting("", ChatFormatting.RED),
+ "Bonus Attack Speed" to StatFormatting("%", ChatFormatting.RED),
+ "Shot Cooldown" to StatFormatting("s", ChatFormatting.GREEN, false),
+ "Ability Damage" to StatFormatting("%", ChatFormatting.RED),
+ "Crit Damage" to StatFormatting("%", ChatFormatting.RED),
+ "Crit Chance" to StatFormatting("%", ChatFormatting.RED),
+ "Ability Damage" to StatFormatting("%", ChatFormatting.RED),
+ "Trophy Fish Chance" to StatFormatting("%", ChatFormatting.GREEN),
+ "Health" to StatFormatting("", ChatFormatting.GREEN),
+ "Defense" to StatFormatting("", ChatFormatting.GREEN),
+ "Fishing Speed" to StatFormatting("", ChatFormatting.GREEN),
+ "Double Hook Chance" to StatFormatting("%", ChatFormatting.GREEN),
+ "Mining Speed" to StatFormatting("", ChatFormatting.GREEN),
+ "Mining Fortune" to StatFormatting("", ChatFormatting.GREEN),
+ "Heat Resistance" to StatFormatting("", ChatFormatting.GREEN),
+ "Swing Range" to StatFormatting("", ChatFormatting.GREEN),
+ "Rift Time" to StatFormatting("", ChatFormatting.GREEN),
+ "Speed" to StatFormatting("", ChatFormatting.GREEN),
+ "Farming Fortune" to StatFormatting("", ChatFormatting.GREEN),
+ "True Defense" to StatFormatting("", ChatFormatting.GREEN),
+ "Mending" to StatFormatting("", ChatFormatting.GREEN),
+ "Foraging Wisdom" to StatFormatting("", ChatFormatting.GREEN),
+ "Farming Wisdom" to StatFormatting("", ChatFormatting.GREEN),
+ "Foraging Fortune" to StatFormatting("", ChatFormatting.GREEN),
+ "Magic Find" to StatFormatting("", ChatFormatting.GREEN),
+ "Ferocity" to StatFormatting("", ChatFormatting.GREEN),
+ "Bonus Pest Chance" to StatFormatting("%", ChatFormatting.GREEN),
+ "Cold Resistance" to StatFormatting("", ChatFormatting.GREEN),
+ "Pet Luck" to StatFormatting("", ChatFormatting.GREEN),
+ "Fear" to StatFormatting("", ChatFormatting.GREEN),
+ "Mana Regen" to StatFormatting("%", ChatFormatting.GREEN),
+ "Rift Damage" to StatFormatting("", ChatFormatting.GREEN),
+ "Hearts" to StatFormatting("", ChatFormatting.GREEN),
+ "Vitality" to StatFormatting("", ChatFormatting.GREEN),
// TODO: make this a repo json
)
@@ -197,21 +197,21 @@ data class SBItemStack constructor(
private val statLabelRegex = "(?<statName>.*): ".toPattern()
enum class BuffKind(
- val color: Formatting,
+ val color: ChatFormatting,
val prefix: String,
val postFix: String,
val isHidden: Boolean,
) {
- REFORGE(Formatting.BLUE, "(", ")", false),
- STAR_BUFF(Formatting.RESET, "", "", true),
- CATA_STAR_BUFF(Formatting.DARK_GRAY, "(", ")", false),
+ REFORGE(ChatFormatting.BLUE, "(", ")", false),
+ STAR_BUFF(ChatFormatting.RESET, "", "", true),
+ CATA_STAR_BUFF(ChatFormatting.DARK_GRAY, "(", ")", false),
;
}
data class StatLine(
val statName: String,
- val value: Text?,
- val rest: List<Text> = listOf(),
+ val value: Component?,
+ val rest: List<Component> = listOf(),
val valueNum: Double? = value?.directLiteralStringContent?.trim(' ', 's', '%', '+')?.toDoubleOrNull()
) {
fun addStat(amount: Double, buffKind: BuffKind): StatLine {
@@ -222,7 +222,7 @@ data class SBItemStack constructor(
rest = rest +
if (buffKind.isHidden) emptyList()
else listOf(
- Text.literal(
+ Component.literal(
buffKind.prefix + formattedAmount +
statFormatting.postFix +
buffKind.postFix + " "
@@ -233,7 +233,7 @@ data class SBItemStack constructor(
}
fun formatValue() =
- Text.literal(
+ Component.literal(
FirmFormatters.formatCommas(
valueNum ?: 0.0,
1,
@@ -242,7 +242,7 @@ data class SBItemStack constructor(
)
.setStyle(Style.EMPTY.withColor(statFormatting.color))
- val statFormatting = formattingOverrides[statName] ?: StatFormatting("", Formatting.GREEN)
+ val statFormatting = formattingOverrides[statName] ?: StatFormatting("", ChatFormatting.GREEN)
private fun abbreviate(abbreviateTo: Int): String {
if (abbreviateTo >= statName.length) return statName
val segments = statName.split(" ")
@@ -251,9 +251,9 @@ data class SBItemStack constructor(
}
}
- fun reconstitute(abbreviateTo: Int = Int.MAX_VALUE): Text =
- Text.literal("").setStyle(Style.EMPTY.withItalic(false))
- .append(Text.literal("${abbreviate(abbreviateTo)}: ").grey())
+ fun reconstitute(abbreviateTo: Int = Int.MAX_VALUE): Component =
+ Component.literal("").setStyle(Style.EMPTY.withItalic(false))
+ .append(Component.literal("${abbreviate(abbreviateTo)}: ").grey())
.append(value ?: formatValue())
.also { rest.forEach(it::append) }
}
@@ -263,10 +263,10 @@ data class SBItemStack constructor(
return segments.joinToString(" ") { it.replaceFirstChar { it.uppercaseChar() } }
}
- fun parseStatLine(line: Text): StatLine? {
+ fun parseStatLine(line: Component): StatLine? {
val sibs = line.siblings
val stat = sibs.firstOrNull() ?: return null
- if (stat.style.color != TextColor.fromFormatting(Formatting.GRAY)) return null
+ if (stat.style.color != TextColor.fromLegacyFormat(ChatFormatting.GRAY)) return null
val statLabel = stat.directLiteralStringContent ?: return null
val statName = statLabelRegex.useMatch(statLabel) { group("statName") } ?: return null
return StatLine(statName, sibs[1], sibs.subList(2, sibs.size))
@@ -329,7 +329,7 @@ data class SBItemStack constructor(
val reforge = ReforgeStore.modifierLut[reforgeId] ?: return
val reforgeStats = reforge.reforgeStats?.get(rarity) ?: mapOf()
itemStack.displayNameAccordingToNbt = itemStack.displayNameAccordingToNbt.copy()
- .prepend(Text.literal(reforge.reforgeName + " ").formatted(Rarity.colourMap[rarity] ?: Formatting.WHITE))
+ .prepend(Component.literal(reforge.reforgeName + " ").withStyle(Rarity.colourMap[rarity] ?: ChatFormatting.WHITE))
val data = itemStack.extraAttributes.copy()
data.putString("modifier", reforgeId.id)
itemStack.extraAttributes = data
@@ -339,11 +339,11 @@ data class SBItemStack constructor(
.grey()
itemStack.modifyLore {
val lastBlank = it.indexOfLast { it.unformattedString.isBlank() }
- val newList = mutableListOf<Text>()
+ val newList = mutableListOf<Component>()
newList.addAll(it.subList(0, lastBlank))
- newList.add(Text.literal(""))
- newList.add(Text.literal("${reforge.reforgeName} Bonus").blue())
- MC.font.textHandler.wrapLines(formattedReforgeAbility, 180, Style.EMPTY).mapTo(newList) {
+ newList.add(Component.literal(""))
+ newList.add(Component.literal("${reforge.reforgeName} Bonus").blue())
+ MC.font.splitter.splitLines(formattedReforgeAbility, 180, Style.EMPTY).mapTo(newList) {
it.reconstitute()
}
newList.addAll(it.subList(lastBlank, it.size))
@@ -391,8 +391,8 @@ data class SBItemStack constructor(
}
- private fun starString(stars: Int): Text {
- if (stars <= 0) return Text.empty()
+ private fun starString(stars: Int): Component {
+ if (stars <= 0) return Component.empty()
// TODO: idk master stars
val tiers = listOf(
LegacyFormattingCode.GOLD,
@@ -400,15 +400,15 @@ data class SBItemStack constructor(
LegacyFormattingCode.AQUA,
)
val maxStars = 5
- if (stars > tiers.size * maxStars) return Text.literal(" ${stars}✪").withColor(Formatting.RED)
+ if (stars > tiers.size * maxStars) return Component.literal(" ${stars}✪").withColor(ChatFormatting.RED)
val starBaseTier = (stars - 1) / maxStars
val starBaseColor = tiers[starBaseTier]
val starsInCurrentTier = stars - starBaseTier * maxStars
- val starString = Text.literal(" " + "✪".repeat(starsInCurrentTier)).withColor(starBaseColor.modern)
+ val starString = Component.literal(" " + "✪".repeat(starsInCurrentTier)).withColor(starBaseColor.modern)
if (starBaseTier > 0) {
val starLastTier = tiers[starBaseTier - 1]
val starsInLastTier = 5 - starsInCurrentTier
- starString.append(Text.literal("✪".repeat(starsInLastTier)).withColor(starLastTier.modern))
+ starString.append(Component.literal("✪".repeat(starsInLastTier)).withColor(starLastTier.modern))
}
return starString
}
diff --git a/src/main/kotlin/repo/recipes/GenericRecipeRenderer.kt b/src/main/kotlin/repo/recipes/GenericRecipeRenderer.kt
index 3774f26..6bc79d5 100644
--- a/src/main/kotlin/repo/recipes/GenericRecipeRenderer.kt
+++ b/src/main/kotlin/repo/recipes/GenericRecipeRenderer.kt
@@ -3,9 +3,9 @@ package moe.nea.firmament.repo.recipes
import io.github.moulberry.repo.NEURepository
import io.github.moulberry.repo.data.NEURecipe
import me.shedaniel.math.Rectangle
-import net.minecraft.item.ItemStack
-import net.minecraft.text.Text
-import net.minecraft.util.Identifier
+import net.minecraft.world.item.ItemStack
+import net.minecraft.network.chat.Component
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.repo.SBItemStack
interface GenericRecipeRenderer<T : NEURecipe> {
@@ -13,8 +13,8 @@ interface GenericRecipeRenderer<T : NEURecipe> {
fun getInputs(recipe: T): Collection<SBItemStack>
fun getOutputs(recipe: T): Collection<SBItemStack>
val icon: ItemStack
- val title: Text
- val identifier: Identifier
+ val title: Component
+ val identifier: ResourceLocation
fun findAllRecipes(neuRepository: NEURepository): Iterable<T>
val displayHeight: Int get() = 66
val typ: Class<T>
diff --git a/src/main/kotlin/repo/recipes/RecipeLayouter.kt b/src/main/kotlin/repo/recipes/RecipeLayouter.kt
index ed0dca2..2c013b7 100644
--- a/src/main/kotlin/repo/recipes/RecipeLayouter.kt
+++ b/src/main/kotlin/repo/recipes/RecipeLayouter.kt
@@ -3,7 +3,7 @@ package moe.nea.firmament.repo.recipes
import io.github.notenoughupdates.moulconfig.gui.GuiComponent
import me.shedaniel.math.Point
import me.shedaniel.math.Rectangle
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.repo.SBItemStack
interface RecipeLayouter {
@@ -23,11 +23,11 @@ interface RecipeLayouter {
slotKind: SlotKind,
)
- fun createTooltip(rectangle: Rectangle, label: Text)
+ fun createTooltip(rectangle: Rectangle, label: Component)
fun createLabel(
x: Int, y: Int,
- text: Text
+ text: Component
)
fun createArrow(x: Int, y: Int): Rectangle
diff --git a/src/main/kotlin/repo/recipes/SBCraftingRecipeRenderer.kt b/src/main/kotlin/repo/recipes/SBCraftingRecipeRenderer.kt
index 37994ca..0a0d5e2 100644
--- a/src/main/kotlin/repo/recipes/SBCraftingRecipeRenderer.kt
+++ b/src/main/kotlin/repo/recipes/SBCraftingRecipeRenderer.kt
@@ -4,10 +4,10 @@ import io.github.moulberry.repo.NEURepository
import io.github.moulberry.repo.data.NEUCraftingRecipe
import me.shedaniel.math.Point
import me.shedaniel.math.Rectangle
-import net.minecraft.block.Blocks
-import net.minecraft.item.ItemStack
-import net.minecraft.text.Text
-import net.minecraft.util.Identifier
+import net.minecraft.world.level.block.Blocks
+import net.minecraft.world.item.ItemStack
+import net.minecraft.network.chat.Component
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.Firmament
import moe.nea.firmament.repo.SBItemStack
import moe.nea.firmament.util.tr
@@ -25,7 +25,7 @@ object SBCraftingRecipeRenderer : GenericRecipeRenderer<NEUCraftingRecipe> {
if (recipe.extraText != null && recipe.extraText!!.isNotBlank()) {
layouter.createTooltip(
arrow,
- Text.of(recipe.extraText!!),
+ Component.nullToEmpty(recipe.extraText!!),
)
}
@@ -63,6 +63,6 @@ object SBCraftingRecipeRenderer : GenericRecipeRenderer<NEUCraftingRecipe> {
}
override val icon: ItemStack = ItemStack(Blocks.CRAFTING_TABLE)
- override val title: Text = tr("firmament.category.crafting", "SkyBlock Crafting")
- override val identifier: Identifier = Firmament.identifier("crafting_recipe")
+ override val title: Component = tr("firmament.category.crafting", "SkyBlock Crafting")
+ override val identifier: ResourceLocation = Firmament.identifier("crafting_recipe")
}
diff --git a/src/main/kotlin/repo/recipes/SBEssenceUpgradeRecipeRenderer.kt b/src/main/kotlin/repo/recipes/SBEssenceUpgradeRecipeRenderer.kt
index 90a6de4..15785bd 100644
--- a/src/main/kotlin/repo/recipes/SBEssenceUpgradeRecipeRenderer.kt
+++ b/src/main/kotlin/repo/recipes/SBEssenceUpgradeRecipeRenderer.kt
@@ -2,9 +2,9 @@ package moe.nea.firmament.repo.recipes
import io.github.moulberry.repo.NEURepository
import me.shedaniel.math.Rectangle
-import net.minecraft.item.ItemStack
-import net.minecraft.text.Text
-import net.minecraft.util.Identifier
+import net.minecraft.world.item.ItemStack
+import net.minecraft.network.chat.Component
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.Firmament
import moe.nea.firmament.repo.EssenceRecipeProvider
import moe.nea.firmament.repo.ExpensiveItemCacheApi
@@ -63,8 +63,8 @@ object SBEssenceUpgradeRecipeRenderer : GenericRecipeRenderer<EssenceRecipeProvi
@OptIn(ExpensiveItemCacheApi::class)
override val icon: ItemStack get() = SBItemStack(SkyblockId("ESSENCE_WITHER")).asImmutableItemStack()
- override val title: Text = tr("firmament.category.essence", "Essence Upgrades")
- override val identifier: Identifier = Firmament.identifier("essence_upgrade")
+ override val title: Component = tr("firmament.category.essence", "Essence Upgrades")
+ override val identifier: ResourceLocation = Firmament.identifier("essence_upgrade")
override fun findAllRecipes(neuRepository: NEURepository): Iterable<EssenceRecipeProvider.EssenceUpgradeRecipe> {
return RepoManager.essenceRecipeProvider.recipes
}
diff --git a/src/main/kotlin/repo/recipes/SBForgeRecipeRenderer.kt b/src/main/kotlin/repo/recipes/SBForgeRecipeRenderer.kt
index 343493a..b595f07 100644
--- a/src/main/kotlin/repo/recipes/SBForgeRecipeRenderer.kt
+++ b/src/main/kotlin/repo/recipes/SBForgeRecipeRenderer.kt
@@ -7,10 +7,10 @@ import me.shedaniel.math.Rectangle
import kotlin.math.cos
import kotlin.math.sin
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.block.Blocks
-import net.minecraft.item.ItemStack
-import net.minecraft.text.Text
-import net.minecraft.util.Identifier
+import net.minecraft.world.level.block.Blocks
+import net.minecraft.world.item.ItemStack
+import net.minecraft.network.chat.Component
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.Firmament
import moe.nea.firmament.repo.SBItemStack
import moe.nea.firmament.util.tr
@@ -23,16 +23,16 @@ object SBForgeRecipeRenderer : GenericRecipeRenderer<NEUForgeRecipe> {
mainItem: SBItemStack?,
) {
val arrow = layouter.createArrow(bounds.minX + 90, bounds.minY + 54 - 18 / 2)
- val tooltip = Text.empty()
- .append(Text.stringifiedTranslatable(
+ val tooltip = Component.empty()
+ .append(Component.translatableEscape(
"firmament.recipe.forge.time",
recipe.duration.seconds,
))
if (recipe.extraText != null && recipe.extraText!!.isNotBlank()) {
tooltip
- .append(Text.of("\n"))
- .append(Text.of(recipe.extraText))
+ .append(Component.nullToEmpty("\n"))
+ .append(Component.nullToEmpty(recipe.extraText))
}
layouter.createTooltip(arrow, tooltip)
@@ -75,8 +75,8 @@ object SBForgeRecipeRenderer : GenericRecipeRenderer<NEUForgeRecipe> {
}
override val icon: ItemStack = ItemStack(Blocks.ANVIL)
- override val title: Text = tr("firmament.category.forge", "Forge Recipes")
- override val identifier: Identifier = Firmament.identifier("forge_recipe")
+ override val title: Component = tr("firmament.category.forge", "Forge Recipes")
+ override val identifier: ResourceLocation = Firmament.identifier("forge_recipe")
override fun findAllRecipes(neuRepository: NEURepository): Iterable<NEUForgeRecipe> {
// TODO: theres gotta be an index for these tbh.
diff --git a/src/main/kotlin/util/CommonSoundEffects.kt b/src/main/kotlin/util/CommonSoundEffects.kt
index a97a2cb..a4d7129 100644
--- a/src/main/kotlin/util/CommonSoundEffects.kt
+++ b/src/main/kotlin/util/CommonSoundEffects.kt
@@ -2,18 +2,18 @@
package moe.nea.firmament.util
-import net.minecraft.client.sound.PositionedSoundInstance
-import net.minecraft.sound.SoundEvent
-import net.minecraft.util.Identifier
+import net.minecraft.client.resources.sounds.SimpleSoundInstance
+import net.minecraft.sounds.SoundEvent
+import net.minecraft.resources.ResourceLocation
// TODO: Replace these with custom sound events that just re use the vanilla ogg s
object CommonSoundEffects {
- fun playSound(identifier: Identifier) {
- MC.soundManager.play(PositionedSoundInstance.master(SoundEvent.of(identifier), 1F))
+ fun playSound(identifier: ResourceLocation) {
+ MC.soundManager.play(SimpleSoundInstance.forUI(SoundEvent.createVariableRangeEvent(identifier), 1F))
}
fun playFailure() {
- playSound(Identifier.of("minecraft", "block.anvil.place"))
+ playSound(ResourceLocation.fromNamespaceAndPath("minecraft", "block.anvil.place"))
}
fun playSuccess() {
@@ -21,6 +21,6 @@ object CommonSoundEffects {
}
fun playDing() {
- playSound(Identifier.of("minecraft", "entity.arrow.hit_player"))
+ playSound(ResourceLocation.fromNamespaceAndPath("minecraft", "entity.arrow.hit_player"))
}
}
diff --git a/src/main/kotlin/util/DurabilityBarEvent.kt b/src/main/kotlin/util/DurabilityBarEvent.kt
index 993462c..c2f863f 100644
--- a/src/main/kotlin/util/DurabilityBarEvent.kt
+++ b/src/main/kotlin/util/DurabilityBarEvent.kt
@@ -2,7 +2,7 @@
package moe.nea.firmament.util
import me.shedaniel.math.Color
-import net.minecraft.item.ItemStack
+import net.minecraft.world.item.ItemStack
import moe.nea.firmament.events.FirmamentEvent
import moe.nea.firmament.events.FirmamentEventBus
diff --git a/src/main/kotlin/util/FirmFormatters.kt b/src/main/kotlin/util/FirmFormatters.kt
index 03dafc5..c4cffc3 100644
--- a/src/main/kotlin/util/FirmFormatters.kt
+++ b/src/main/kotlin/util/FirmFormatters.kt
@@ -12,8 +12,8 @@ import kotlin.math.absoluteValue
import kotlin.math.roundToInt
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.text.Text
-import net.minecraft.util.math.BlockPos
+import net.minecraft.network.chat.Component
+import net.minecraft.core.BlockPos
object FirmFormatters {
@@ -103,7 +103,7 @@ object FirmFormatters {
return sb.toString()
}
- fun debugPath(path: Path): Text {
+ fun debugPath(path: Path): Component {
if (!path.exists()) {
return tr("firmament.path.missing", "$path (missing)").red()
}
@@ -127,13 +127,13 @@ object FirmFormatters {
fun formatBool(
boolean: Boolean,
trueIsGood: Boolean = true,
- ): Text {
- val text = Text.literal(boolean.toString())
+ ): Component {
+ val text = Component.literal(boolean.toString())
return if (boolean == trueIsGood) text.lime() else text.red()
}
- fun formatPosition(position: BlockPos): Text {
- return Text.literal("x: ${position.x}, y: ${position.y}, z: ${position.z}")
+ fun formatPosition(position: BlockPos): Component {
+ return Component.literal("x: ${position.x}, y: ${position.y}, z: ${position.z}")
}
fun formatPercent(value: Double, decimals: Int = 1): String {
diff --git a/src/main/kotlin/util/FragmentGuiScreen.kt b/src/main/kotlin/util/FragmentGuiScreen.kt
index 74558a0..8797a31 100644
--- a/src/main/kotlin/util/FragmentGuiScreen.kt
+++ b/src/main/kotlin/util/FragmentGuiScreen.kt
@@ -6,23 +6,23 @@ import io.github.notenoughupdates.moulconfig.gui.GuiContext
import me.shedaniel.math.Dimension
import me.shedaniel.math.Point
import me.shedaniel.math.Rectangle
-import net.minecraft.client.gui.Click
-import net.minecraft.client.gui.DrawContext
-import net.minecraft.client.gui.screen.Screen
-import net.minecraft.client.input.CharInput
-import net.minecraft.client.input.KeyInput
-import net.minecraft.text.Text
+import net.minecraft.client.input.MouseButtonEvent
+import net.minecraft.client.gui.GuiGraphics
+import net.minecraft.client.gui.screens.Screen
+import net.minecraft.client.input.CharacterEvent
+import net.minecraft.client.input.KeyEvent
+import net.minecraft.network.chat.Component
abstract class FragmentGuiScreen(
val dismissOnOutOfBounds: Boolean = true
-) : Screen(Text.literal("")) {
+) : Screen(Component.literal("")) {
var popup: MoulConfigFragment? = null
fun createPopup(context: GuiContext, position: Point) {
popup = MoulConfigFragment(context, position) { popup = null }
}
- fun renderPopup(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) {
+ fun renderPopup(context: GuiGraphics, mouseX: Int, mouseY: Int, delta: Float) {
popup?.render(context, mouseX, mouseY, delta)
}
@@ -32,13 +32,13 @@ abstract class FragmentGuiScreen(
return true
}
- override fun keyPressed(input: KeyInput): Boolean {
+ override fun keyPressed(input: KeyEvent): Boolean {
return ifPopup {
it.keyPressed(input)
}
}
- override fun keyReleased(input: KeyInput): Boolean {
+ override fun keyReleased(input: KeyEvent): Boolean {
return ifPopup {
it.keyReleased(input)
}
@@ -48,19 +48,19 @@ abstract class FragmentGuiScreen(
ifPopup { it.mouseMoved(mouseX, mouseY) }
}
- override fun mouseReleased(click: Click): Boolean {
+ override fun mouseReleased(click: MouseButtonEvent): Boolean {
return ifPopup {
it.mouseReleased(click)
}
}
- override fun mouseDragged(click: Click, offsetX: Double, offsetY: Double): Boolean {
+ override fun mouseDragged(click: MouseButtonEvent, offsetX: Double, offsetY: Double): Boolean {
return ifPopup {
it.mouseDragged(click, offsetX, offsetY)
}
}
- override fun mouseClicked(click: Click, doubled: Boolean): Boolean {
+ override fun mouseClicked(click: MouseButtonEvent, doubled: Boolean): Boolean {
return ifPopup {
if (!Rectangle(
it.position,
@@ -75,7 +75,7 @@ abstract class FragmentGuiScreen(
}|| super.mouseClicked(click, doubled)
}
- override fun charTyped(input: CharInput): Boolean {
+ override fun charTyped(input: CharacterEvent): Boolean {
return ifPopup { it.charTyped(input) }
}
diff --git a/src/main/kotlin/util/HoveredItemStack.kt b/src/main/kotlin/util/HoveredItemStack.kt
index 1b54562..c8d33fd 100644
--- a/src/main/kotlin/util/HoveredItemStack.kt
+++ b/src/main/kotlin/util/HoveredItemStack.kt
@@ -1,13 +1,13 @@
package moe.nea.firmament.util
import com.google.auto.service.AutoService
-import net.minecraft.client.gui.screen.ingame.HandledScreen
-import net.minecraft.item.ItemStack
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
+import net.minecraft.world.item.ItemStack
import moe.nea.firmament.mixins.accessor.AccessorHandledScreen
import moe.nea.firmament.util.compatloader.CompatLoader
interface HoveredItemStackProvider : Comparable<HoveredItemStackProvider> {
- fun provideHoveredItemStack(screen: HandledScreen<*>): ItemStack?
+ fun provideHoveredItemStack(screen: AbstractContainerScreen<*>): ItemStack?
override fun compareTo(other: HoveredItemStackProvider): Int {
return compareValues(this.prio, other.prio)
}
@@ -22,9 +22,9 @@ interface HoveredItemStackProvider : Comparable<HoveredItemStackProvider> {
@AutoService(HoveredItemStackProvider::class)
class VanillaScreenProvider : HoveredItemStackProvider {
- override fun provideHoveredItemStack(screen: HandledScreen<*>): ItemStack? {
+ override fun provideHoveredItemStack(screen: AbstractContainerScreen<*>): ItemStack? {
screen as AccessorHandledScreen
- val vanillaSlot = screen.focusedSlot_Firmament?.stack
+ val vanillaSlot = screen.focusedSlot_Firmament?.item
return vanillaSlot
}
@@ -32,7 +32,7 @@ class VanillaScreenProvider : HoveredItemStackProvider {
get() = -1
}
-val HandledScreen<*>.focusedItemStack: ItemStack?
+val AbstractContainerScreen<*>.focusedItemStack: ItemStack?
get() =
HoveredItemStackProvider.sorted
.firstNotNullOfOrNull { it.provideHoveredItemStack(this)?.takeIf { !it.isEmpty } }
diff --git a/src/main/kotlin/util/IdentifierSerializer.kt b/src/main/kotlin/util/IdentifierSerializer.kt
index 65c5b1c..2255255 100644
--- a/src/main/kotlin/util/IdentifierSerializer.kt
+++ b/src/main/kotlin/util/IdentifierSerializer.kt
@@ -8,18 +8,18 @@ import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
-import net.minecraft.util.Identifier
+import net.minecraft.resources.ResourceLocation
-object IdentifierSerializer : KSerializer<Identifier> {
+object IdentifierSerializer : KSerializer<ResourceLocation> {
val delegateSerializer = String.serializer()
override val descriptor: SerialDescriptor
get() = PrimitiveSerialDescriptor("Identifier", PrimitiveKind.STRING)
- override fun deserialize(decoder: Decoder): Identifier {
- return Identifier.of(decoder.decodeSerializableValue(delegateSerializer))
+ override fun deserialize(decoder: Decoder): ResourceLocation {
+ return ResourceLocation.parse(decoder.decodeSerializableValue(delegateSerializer))
}
- override fun serialize(encoder: Encoder, value: Identifier) {
+ override fun serialize(encoder: Encoder, value: ResourceLocation) {
encoder.encodeSerializableValue(delegateSerializer, value.toString())
}
}
diff --git a/src/main/kotlin/util/LegacyFormattingCode.kt b/src/main/kotlin/util/LegacyFormattingCode.kt
index 1a5d1dd..20574d8 100644
--- a/src/main/kotlin/util/LegacyFormattingCode.kt
+++ b/src/main/kotlin/util/LegacyFormattingCode.kt
@@ -1,6 +1,6 @@
package moe.nea.firmament.util
-import net.minecraft.util.Formatting
+import net.minecraft.ChatFormatting
enum class LegacyFormattingCode(val label: String, val char: Char, val index: Int) {
BLACK("BLACK", '0', 0),
@@ -30,7 +30,7 @@ enum class LegacyFormattingCode(val label: String, val char: Char, val index: In
val byCode = entries.associateBy { it.char }
}
- val modern = Formatting.byCode(char)!!
+ val modern = ChatFormatting.getByCode(char)!!
val formattingCode = "§$char"
diff --git a/src/main/kotlin/util/LegacyTagParser.kt b/src/main/kotlin/util/LegacyTagParser.kt
index 5a26335..0de4caa 100644
--- a/src/main/kotlin/util/LegacyTagParser.kt
+++ b/src/main/kotlin/util/LegacyTagParser.kt
@@ -3,17 +3,17 @@
package moe.nea.firmament.util
import java.util.Stack
-import net.minecraft.nbt.AbstractNbtNumber
-import net.minecraft.nbt.NbtByte
-import net.minecraft.nbt.NbtCompound
-import net.minecraft.nbt.NbtDouble
-import net.minecraft.nbt.NbtElement
-import net.minecraft.nbt.NbtFloat
-import net.minecraft.nbt.NbtInt
-import net.minecraft.nbt.NbtList
-import net.minecraft.nbt.NbtLong
-import net.minecraft.nbt.NbtShort
-import net.minecraft.nbt.NbtString
+import net.minecraft.nbt.NumericTag
+import net.minecraft.nbt.ByteTag
+import net.minecraft.nbt.CompoundTag
+import net.minecraft.nbt.DoubleTag
+import net.minecraft.nbt.Tag
+import net.minecraft.nbt.FloatTag
+import net.minecraft.nbt.IntTag
+import net.minecraft.nbt.ListTag
+import net.minecraft.nbt.LongTag
+import net.minecraft.nbt.ShortTag
+import net.minecraft.nbt.StringTag
class LegacyTagParser private constructor(string: String) {
data class TagParsingException(val baseString: String, val offset: Int, val mes0: String) :
@@ -93,7 +93,7 @@ class LegacyTagParser private constructor(string: String) {
companion object {
val digitRange = "0123456789-"
- fun parse(string: String): NbtCompound {
+ fun parse(string: String): CompoundTag {
return LegacyTagParser(string).baseTag
}
}
@@ -102,11 +102,11 @@ class LegacyTagParser private constructor(string: String) {
racer.consumeWhile { Character.isWhitespace(it.last()) } // Only check last since other chars are always checked before.
}
- fun parseTag(): NbtCompound {
+ fun parseTag(): CompoundTag {
skipWhitespace()
racer.expect("{", "Expected '{’ at start of tag")
skipWhitespace()
- val tag = NbtCompound()
+ val tag = CompoundTag()
while (!racer.tryConsume("}")) {
skipWhitespace()
val lhs = parseIdentifier()
@@ -121,7 +121,7 @@ class LegacyTagParser private constructor(string: String) {
return tag
}
- private fun parseAny(): NbtElement {
+ private fun parseAny(): Tag {
skipWhitespace()
val nextChar = racer.peekReq(1) ?: racer.error("Expected new object, found EOF")
return when {
@@ -133,11 +133,11 @@ class LegacyTagParser private constructor(string: String) {
}
}
- fun parseList(): NbtList {
+ fun parseList(): ListTag {
skipWhitespace()
racer.expect("[", "Expected '[' at start of tag")
skipWhitespace()
- val list = NbtList()
+ val list = ListTag()
while (!racer.tryConsume("]")) {
skipWhitespace()
racer.pushState()
@@ -183,8 +183,8 @@ class LegacyTagParser private constructor(string: String) {
return sb.toString()
}
- fun parseStringTag(): NbtString {
- return NbtString.of(parseQuotedString())
+ fun parseStringTag(): StringTag {
+ return StringTag.valueOf(parseQuotedString())
}
object Patterns {
@@ -198,7 +198,7 @@ class LegacyTagParser private constructor(string: String) {
val ROUGH_PATTERN = "[-+]?[0-9]*\\.?[0-9]*[dDbBfFlLsS]?".toRegex()
}
- fun parseNumericTag(): AbstractNbtNumber {
+ fun parseNumericTag(): NumericTag {
skipWhitespace()
val textForm = racer.consumeWhile { Patterns.ROUGH_PATTERN.matchEntire(it) != null }
if (textForm.isEmpty()) {
@@ -206,27 +206,27 @@ class LegacyTagParser private constructor(string: String) {
}
val floatMatch = Patterns.FLOAT.matchEntire(textForm)
if (floatMatch != null) {
- return NbtFloat.of(floatMatch.groups[1]!!.value.toFloat())
+ return FloatTag.valueOf(floatMatch.groups[1]!!.value.toFloat())
}
val byteMatch = Patterns.BYTE.matchEntire(textForm)
if (byteMatch != null) {
- return NbtByte.of(byteMatch.groups[1]!!.value.toByte())
+ return ByteTag.valueOf(byteMatch.groups[1]!!.value.toByte())
}
val longMatch = Patterns.LONG.matchEntire(textForm)
if (longMatch != null) {
- return NbtLong.of(longMatch.groups[1]!!.value.toLong())
+ return LongTag.valueOf(longMatch.groups[1]!!.value.toLong())
}
val shortMatch = Patterns.SHORT.matchEntire(textForm)
if (shortMatch != null) {
- return NbtShort.of(shortMatch.groups[1]!!.value.toShort())
+ return ShortTag.valueOf(shortMatch.groups[1]!!.value.toShort())
}
val integerMatch = Patterns.INTEGER.matchEntire(textForm)
if (integerMatch != null) {
- return NbtInt.of(integerMatch.groups[1]!!.value.toInt())
+ return IntTag.valueOf(integerMatch.groups[1]!!.value.toInt())
}
val doubleMatch = Patterns.DOUBLE.matchEntire(textForm) ?: Patterns.DOUBLE_UNTYPED.matchEntire(textForm)
if (doubleMatch != null) {
- return NbtDouble.of(doubleMatch.groups[1]!!.value.toDouble())
+ return DoubleTag.valueOf(doubleMatch.groups[1]!!.value.toDouble())
}
throw IllegalStateException("Could not properly parse numeric tag '$textForm', despite passing rough verification. This is a bug in the LegacyTagParser")
}
diff --git a/src/main/kotlin/util/LegacyTagWriter.kt b/src/main/kotlin/util/LegacyTagWriter.kt
index 9889b2c..eb755c4 100644
--- a/src/main/kotlin/util/LegacyTagWriter.kt
+++ b/src/main/kotlin/util/LegacyTagWriter.kt
@@ -1,27 +1,27 @@
package moe.nea.firmament.util
import kotlinx.serialization.json.JsonPrimitive
-import net.minecraft.nbt.AbstractNbtList
-import net.minecraft.nbt.NbtByte
-import net.minecraft.nbt.NbtCompound
-import net.minecraft.nbt.NbtDouble
-import net.minecraft.nbt.NbtElement
-import net.minecraft.nbt.NbtEnd
-import net.minecraft.nbt.NbtFloat
-import net.minecraft.nbt.NbtInt
-import net.minecraft.nbt.NbtLong
-import net.minecraft.nbt.NbtShort
-import net.minecraft.nbt.NbtString
+import net.minecraft.nbt.CollectionTag
+import net.minecraft.nbt.ByteTag
+import net.minecraft.nbt.CompoundTag
+import net.minecraft.nbt.DoubleTag
+import net.minecraft.nbt.Tag
+import net.minecraft.nbt.EndTag
+import net.minecraft.nbt.FloatTag
+import net.minecraft.nbt.IntTag
+import net.minecraft.nbt.LongTag
+import net.minecraft.nbt.ShortTag
+import net.minecraft.nbt.StringTag
import moe.nea.firmament.util.mc.SNbtFormatter.Companion.SIMPLE_NAME
class LegacyTagWriter(val compact: Boolean) {
companion object {
- fun stringify(nbt: NbtElement, compact: Boolean): String {
+ fun stringify(nbt: Tag, compact: Boolean): String {
return LegacyTagWriter(compact).also { it.writeElement(nbt) }
.stringWriter.toString()
}
- fun NbtElement.toLegacyString(pretty: Boolean = false): String {
+ fun Tag.toLegacyString(pretty: Boolean = false): String {
return stringify(this, !pretty)
}
}
@@ -36,22 +36,22 @@ class LegacyTagWriter(val compact: Boolean) {
}
}
- fun writeElement(nbt: NbtElement) {
+ fun writeElement(nbt: Tag) {
when (nbt) {
- is NbtInt -> stringWriter.append(nbt.value.toString())
- is NbtString -> stringWriter.append(escapeString(nbt.value))
- is NbtFloat -> stringWriter.append(nbt.value).append('F')
- is NbtDouble -> stringWriter.append(nbt.value).append('D')
- is NbtByte -> stringWriter.append(nbt.value).append('B')
- is NbtLong -> stringWriter.append(nbt.value).append('L')
- is NbtShort -> stringWriter.append(nbt.value).append('S')
- is NbtCompound -> writeCompound(nbt)
- is NbtEnd -> {}
- is AbstractNbtList -> writeArray(nbt)
+ is IntTag -> stringWriter.append(nbt.value.toString())
+ is StringTag -> stringWriter.append(escapeString(nbt.value))
+ is FloatTag -> stringWriter.append(nbt.value).append('F')
+ is DoubleTag -> stringWriter.append(nbt.value).append('D')
+ is ByteTag -> stringWriter.append(nbt.value).append('B')
+ is LongTag -> stringWriter.append(nbt.value).append('L')
+ is ShortTag -> stringWriter.append(nbt.value).append('S')
+ is CompoundTag -> writeCompound(nbt)
+ is EndTag -> {}
+ is CollectionTag -> writeArray(nbt)
}
}
- fun writeArray(nbt: AbstractNbtList) {
+ fun writeArray(nbt: CollectionTag) {
stringWriter.append('[')
indent++
newLine()
@@ -69,7 +69,7 @@ class LegacyTagWriter(val compact: Boolean) {
stringWriter.append(']')
}
- fun writeCompound(nbt: NbtCompound) {
+ fun writeCompound(nbt: CompoundTag) {
stringWriter.append('{')
indent++
newLine()
@@ -83,7 +83,7 @@ class LegacyTagWriter(val compact: Boolean) {
}
}
indent--
- if (nbt.size != 0)
+ if (nbt.size() != 0)
newLine()
stringWriter.append('}')
}
diff --git a/src/main/kotlin/util/LoadResource.kt b/src/main/kotlin/util/LoadResource.kt
index 4bc8704..d3a7ac2 100644
--- a/src/main/kotlin/util/LoadResource.kt
+++ b/src/main/kotlin/util/LoadResource.kt
@@ -4,17 +4,17 @@ package moe.nea.firmament.util
import java.io.InputStream
import kotlin.io.path.inputStream
import kotlin.jvm.optionals.getOrNull
-import net.minecraft.util.Identifier
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.repo.RepoDownloadManager
-fun Identifier.openFirmamentResource(): InputStream {
+fun ResourceLocation.openFirmamentResource(): InputStream {
val resource = MC.resourceManager.getResource(this).getOrNull()
if (resource == null) {
if (namespace == "neurepo")
return RepoDownloadManager.repoSavedLocation.resolve(path).inputStream()
error("Could not read resource $this")
}
- return resource.inputStream
+ return resource.open()
}
diff --git a/src/main/kotlin/util/MC.kt b/src/main/kotlin/util/MC.kt
index 9f3fe99..e70c382 100644
--- a/src/main/kotlin/util/MC.kt
+++ b/src/main/kotlin/util/MC.kt
@@ -4,32 +4,32 @@ import io.github.moulberry.repo.data.Coordinate
import io.github.notenoughupdates.moulconfig.platform.MoulConfigScreenComponent
import java.util.concurrent.ConcurrentLinkedQueue
import kotlin.jvm.optionals.getOrNull
-import net.minecraft.client.MinecraftClient
-import net.minecraft.client.gui.hud.InGameHud
-import net.minecraft.client.gui.screen.Screen
-import net.minecraft.client.gui.screen.ingame.HandledScreen
-import net.minecraft.client.network.ClientPlayerEntity
-import net.minecraft.client.render.GameRenderer
-import net.minecraft.client.render.WorldRenderer
-import net.minecraft.client.render.item.ItemRenderer
-import net.minecraft.client.world.ClientWorld
-import net.minecraft.entity.Entity
-import net.minecraft.item.Item
-import net.minecraft.item.ItemStack
+import net.minecraft.client.Minecraft
+import net.minecraft.client.gui.Gui
+import net.minecraft.client.gui.screens.Screen
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
+import net.minecraft.client.player.LocalPlayer
+import net.minecraft.client.renderer.GameRenderer
+import net.minecraft.client.renderer.LevelRenderer
+import net.minecraft.client.renderer.entity.ItemRenderer
+import net.minecraft.client.multiplayer.ClientLevel
+import net.minecraft.world.entity.Entity
+import net.minecraft.world.item.Item
+import net.minecraft.world.item.ItemStack
import net.minecraft.nbt.NbtOps
-import net.minecraft.network.packet.c2s.play.CommandExecutionC2SPacket
-import net.minecraft.registry.BuiltinRegistries
-import net.minecraft.registry.Registry
-import net.minecraft.registry.RegistryKey
-import net.minecraft.registry.RegistryKeys
-import net.minecraft.registry.RegistryOps
-import net.minecraft.registry.RegistryWrapper
-import net.minecraft.resource.ReloadableResourceManagerImpl
-import net.minecraft.text.Text
-import net.minecraft.util.Identifier
-import net.minecraft.util.Util
-import net.minecraft.util.math.BlockPos
-import net.minecraft.world.World
+import net.minecraft.network.protocol.game.ServerboundChatCommandPacket
+import net.minecraft.data.registries.VanillaRegistries
+import net.minecraft.core.Registry
+import net.minecraft.resources.ResourceKey
+import net.minecraft.core.registries.Registries
+import net.minecraft.resources.RegistryOps
+import net.minecraft.core.HolderLookup
+import net.minecraft.server.packs.resources.ReloadableResourceManager
+import net.minecraft.network.chat.Component
+import net.minecraft.resources.ResourceLocation
+import net.minecraft.Util
+import net.minecraft.core.BlockPos
+import net.minecraft.world.level.Level
import moe.nea.firmament.Firmament
import moe.nea.firmament.events.TickEvent
import moe.nea.firmament.events.WorldReadyEvent
@@ -37,13 +37,13 @@ import moe.nea.firmament.util.mc.TolerantRegistriesOps
object MC {
- private val messageQueue = ConcurrentLinkedQueue<Text>()
+ private val messageQueue = ConcurrentLinkedQueue<Component>()
init {
TickEvent.subscribe("MC:push") {
- if (inGameHud.chatHud != null && world != null)
+ if (inGameHud.chat != null && world != null)
while (true) {
- inGameHud.chatHud.addMessage(messageQueue.poll() ?: break)
+ inGameHud.chat.addMessage(messageQueue.poll() ?: break)
}
while (true) {
(nextTickTodos.poll() ?: break).invoke()
@@ -54,42 +54,42 @@ object MC {
}
}
- fun sendChat(text: Text) {
+ fun sendChat(text: Component) {
if (TestUtil.isInTest) {
Firmament.logger.info("CHAT: ${text.string}")
return
}
- if (instance.isOnThread && inGameHud.chatHud != null && world != null)
- inGameHud.chatHud.addMessage(text)
+ if (instance.isSameThread && inGameHud.chat != null && world != null)
+ inGameHud.chat.addMessage(text)
else
messageQueue.add(text)
}
@Deprecated("Use checked method instead", replaceWith = ReplaceWith("sendCommand(command)"))
fun sendServerCommand(command: String) {
- val nh = player?.networkHandler ?: return
- nh.sendPacket(
- CommandExecutionC2SPacket(
+ val nh = player?.connection ?: return
+ nh.send(
+ ServerboundChatCommandPacket(
command,
)
)
}
fun sendServerChat(text: String) {
- player?.networkHandler?.sendChatMessage(text)
+ player?.connection?.sendChat(text)
}
fun sendCommand(command: String) {
// TODO: add a queue to this and sendServerChat
ErrorUtil.softCheck("Server commands have an implied /", !command.startsWith("/"))
- player?.networkHandler?.sendChatCommand(command)
+ player?.connection?.sendCommand(command)
}
fun onMainThread(block: () -> Unit) {
- if (instance.isOnThread)
+ if (instance.isSameThread)
block()
else
- instance.send(block)
+ instance.schedule(block)
}
private val nextTickTodos = ConcurrentLinkedQueue<() -> Unit>()
@@ -98,38 +98,38 @@ object MC {
}
- inline val resourceManager get() = (instance.resourceManager as ReloadableResourceManagerImpl)
+ inline val resourceManager get() = (instance.resourceManager as ReloadableResourceManager)
inline val itemRenderer: ItemRenderer get() = instance.itemRenderer
- inline val worldRenderer: WorldRenderer get() = instance.worldRenderer
+ inline val worldRenderer: LevelRenderer get() = instance.levelRenderer
inline val gameRenderer: GameRenderer get() = instance.gameRenderer
- inline val networkHandler get() = player?.networkHandler
- inline val instance get() = MinecraftClient.getInstance()
- inline val keyboard get() = instance.keyboard
- inline val interactionManager get() = instance.interactionManager
+ inline val networkHandler get() = player?.connection
+ inline val instance get() = Minecraft.getInstance()
+ inline val keyboard get() = instance.keyboardHandler
+ inline val interactionManager get() = instance.gameMode
inline val textureManager get() = instance.textureManager
inline val options get() = instance.options
- inline val inGameHud: InGameHud get() = instance.inGameHud
- inline val font get() = instance.textRenderer
+ inline val inGameHud: Gui get() = instance.gui
+ inline val font get() = instance.font
inline val soundManager get() = instance.soundManager
- inline val player: ClientPlayerEntity? get() = TestUtil.unlessTesting { instance.player }
+ inline val player: LocalPlayer? get() = TestUtil.unlessTesting { instance.player }
inline val camera: Entity? get() = instance.cameraEntity
- inline val stackInHand: ItemStack get() = player?.mainHandStack ?: ItemStack.EMPTY
- inline val world: ClientWorld? get() = TestUtil.unlessTesting { instance.world }
- inline val playerName: String get() = player?.name?.unformattedString ?: MC.instance.session.username
+ inline val stackInHand: ItemStack get() = player?.mainHandItem ?: ItemStack.EMPTY
+ inline val world: ClientLevel? get() = TestUtil.unlessTesting { instance.level }
+ inline val playerName: String get() = player?.name?.unformattedString ?: MC.instance.user.name
inline var screen: Screen?
- get() = TestUtil.unlessTesting { instance.currentScreen }
+ get() = TestUtil.unlessTesting { instance.screen }
set(value) = instance.setScreen(value)
val screenName get() = screen?.title?.unformattedString?.trim()
- inline val handledScreen: HandledScreen<*>? get() = instance.currentScreen as? HandledScreen<*>
+ inline val handledScreen: AbstractContainerScreen<*>? get() = instance.screen as? AbstractContainerScreen<*>
inline val window get() = instance.window
- inline val currentRegistries: RegistryWrapper.WrapperLookup? get() = world?.registryManager
- val defaultRegistries: RegistryWrapper.WrapperLookup by lazy { BuiltinRegistries.createWrapperLookup() }
- val defaultRegistryNbtOps by lazy { RegistryOps.of(NbtOps.INSTANCE, defaultRegistries) }
+ inline val currentRegistries: HolderLookup.Provider? get() = world?.registryAccess()
+ val defaultRegistries: HolderLookup.Provider by lazy { VanillaRegistries.createLookup() }
+ val defaultRegistryNbtOps by lazy { RegistryOps.create(NbtOps.INSTANCE, defaultRegistries) }
inline val currentOrDefaultRegistries get() = currentRegistries ?: defaultRegistries
val currentOrDefaultRegistryNbtOps get() = TolerantRegistriesOps(NbtOps.INSTANCE, currentOrDefaultRegistries)
- val defaultItems: RegistryWrapper.Impl<Item> by lazy { defaultRegistries.getOrThrow(RegistryKeys.ITEM) }
+ val defaultItems: HolderLookup.RegistryLookup<Item> by lazy { defaultRegistries.lookupOrThrow(Registries.ITEM) }
var currentTick = 0
- var lastWorld: World? = null
+ var lastWorld: Level? = null
get() {
field = world ?: field
return field
@@ -140,17 +140,17 @@ object MC {
get() = (screen as? MoulConfigScreenComponent)?.guiContext
fun openUrl(uri: String) {
- Util.getOperatingSystem().open(uri)
+ Util.getPlatform().openUri(uri)
}
- fun <T> unsafeGetRegistryEntry(registry: RegistryKey<out Registry<T>>, identifier: Identifier) =
- unsafeGetRegistryEntry(RegistryKey.of(registry, identifier))
+ fun <T> unsafeGetRegistryEntry(registry: ResourceKey<out Registry<T>>, identifier: ResourceLocation) =
+ unsafeGetRegistryEntry(ResourceKey.create(registry, identifier))
- fun <T> unsafeGetRegistryEntry(registryKey: RegistryKey<T>): T? {
+ fun <T> unsafeGetRegistryEntry(registryKey: ResourceKey<T>): T? {
return currentOrDefaultRegistries
- .getOrThrow(registryKey.registryRef)
- .getOptional(registryKey)
+ .lookupOrThrow(registryKey.registryKey())
+ .get(registryKey)
.getOrNull()
?.value()
}
diff --git a/src/main/kotlin/util/MinecraftDispatcher.kt b/src/main/kotlin/util/MinecraftDispatcher.kt
index d1f22a9..3e23f54 100644
--- a/src/main/kotlin/util/MinecraftDispatcher.kt
+++ b/src/main/kotlin/util/MinecraftDispatcher.kt
@@ -3,6 +3,6 @@
package moe.nea.firmament.util
import kotlinx.coroutines.asCoroutineDispatcher
-import net.minecraft.client.MinecraftClient
+import net.minecraft.client.Minecraft
-val MinecraftDispatcher by lazy { MinecraftClient.getInstance().asCoroutineDispatcher() }
+val MinecraftDispatcher by lazy { Minecraft.getInstance().asCoroutineDispatcher() }
diff --git a/src/main/kotlin/util/MoulConfigFragment.kt b/src/main/kotlin/util/MoulConfigFragment.kt
index 7e7f5db..200b780 100644
--- a/src/main/kotlin/util/MoulConfigFragment.kt
+++ b/src/main/kotlin/util/MoulConfigFragment.kt
@@ -4,19 +4,19 @@ import io.github.notenoughupdates.moulconfig.gui.GuiContext
import io.github.notenoughupdates.moulconfig.gui.GuiImmediateContext
import io.github.notenoughupdates.moulconfig.platform.MoulConfigScreenComponent
import me.shedaniel.math.Point
-import net.minecraft.client.gui.DrawContext
-import net.minecraft.text.Text
+import net.minecraft.client.gui.GuiGraphics
+import net.minecraft.network.chat.Component
class MoulConfigFragment(
context: GuiContext,
val position: Point,
val dismiss: () -> Unit
-) : MoulConfigScreenComponent(Text.empty(), context, null) {
+) : MoulConfigScreenComponent(Component.empty(), context, null) {
init {
this.init(MC.instance, MC.screen!!.width, MC.screen!!.height)
}
- override fun createContext(drawContext: DrawContext?): GuiImmediateContext {
+ override fun createContext(drawContext: GuiGraphics?): GuiImmediateContext {
val oldContext = super.createContext(drawContext)
return oldContext.translated(
position.x,
@@ -27,9 +27,9 @@ class MoulConfigFragment(
}
- override fun render(drawContext: DrawContext, i: Int, j: Int, f: Float) {
+ override fun render(drawContext: GuiGraphics, i: Int, j: Int, f: Float) {
val ctx = createContext(drawContext)
- val m = drawContext.matrices
+ val m = drawContext.pose()
m.pushMatrix()
m.translate(position.x.toFloat(), position.y.toFloat())
guiContext.root.render(ctx)
@@ -37,7 +37,7 @@ class MoulConfigFragment(
ctx.renderContext.renderExtraLayers()
}
- override fun close() {
+ override fun onClose() {
dismiss()
}
}
diff --git a/src/main/kotlin/util/MoulConfigUtils.kt b/src/main/kotlin/util/MoulConfigUtils.kt
index fb955ae..c0c7ef5 100644
--- a/src/main/kotlin/util/MoulConfigUtils.kt
+++ b/src/main/kotlin/util/MoulConfigUtils.kt
@@ -23,10 +23,10 @@ import me.shedaniel.math.Color
import org.w3c.dom.Element
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.client.gui.DrawContext
-import net.minecraft.client.gui.screen.Screen
-import net.minecraft.client.util.InputUtil
-import net.minecraft.text.Text
+import net.minecraft.client.gui.GuiGraphics
+import net.minecraft.client.gui.screens.Screen
+import com.mojang.blaze3d.platform.InputConstants
+import net.minecraft.network.chat.Component
import moe.nea.firmament.gui.BarComponent
import moe.nea.firmament.gui.FirmButtonComponent
import moe.nea.firmament.gui.FirmHoverComponent
@@ -227,10 +227,10 @@ object MoulConfigUtils {
}
fun wrapScreen(guiContext: GuiContext, parent: Screen?, onClose: () -> Unit = {}): Screen {
- return object : MoulConfigScreenComponent(Text.empty(), guiContext, null) {
- override fun close() {
+ return object : MoulConfigScreenComponent(Component.empty(), guiContext, null) {
+ override fun onClose() {
if (guiContext.onBeforeClose() == CloseEventListener.CloseAction.NO_OBJECTIONS_TO_CLOSE) {
- client!!.setScreen(parent)
+ minecraft!!.setScreen(parent)
onClose()
}
}
@@ -270,7 +270,7 @@ object MoulConfigUtils {
return true
if (component.context.getFocusedElement() != null) {
if (keyboardEvent is KeyboardEvent.KeyPressed
- && keyboardEvent.pressed && keyboardEvent.keycode == InputUtil.GLFW_KEY_ESCAPE
+ && keyboardEvent.pressed && keyboardEvent.keycode == InputConstants.KEY_ESCAPE
) {
component.context.setFocusedElement(null)
}
@@ -292,7 +292,7 @@ object MoulConfigUtils {
return component.mouseEvent(mouseEvent, immContext.translated(x, y, w, h))
}
- fun createInPlaceFullContext(drawContext: DrawContext?, mouseX: Int, mouseY: Int): GuiImmediateContext {
+ fun createInPlaceFullContext(drawContext: GuiGraphics?, mouseX: Int, mouseY: Int): GuiImmediateContext {
ErrorUtil.softCheck(
"created moulconfig context with pre-existing translations.",
drawContext?.isUntranslatedGuiDrawContext() != false
@@ -310,7 +310,7 @@ object MoulConfigUtils {
return immContext
}
- fun DrawContext.drawMCComponentInPlace(
+ fun GuiGraphics.drawMCComponentInPlace(
component: GuiComponent,
x: Int,
y: Int,
@@ -320,10 +320,10 @@ object MoulConfigUtils {
mouseY: Int
) {
val immContext = createInPlaceFullContext(this, mouseX, mouseY)
- matrices.pushMatrix()
- matrices.translate(x.toFloat(), y.toFloat())
+ pose().pushMatrix()
+ pose().translate(x.toFloat(), y.toFloat())
component.render(immContext.translated(x, y, w, h))
- matrices.popMatrix()
+ pose().popMatrix()
}
diff --git a/src/main/kotlin/util/ScoreboardUtil.kt b/src/main/kotlin/util/ScoreboardUtil.kt
index f5f28b9..d94eb54 100644
--- a/src/main/kotlin/util/ScoreboardUtil.kt
+++ b/src/main/kotlin/util/ScoreboardUtil.kt
@@ -1,18 +1,18 @@
package moe.nea.firmament.util
import java.util.Optional
-import net.minecraft.client.gui.hud.InGameHud
-import net.minecraft.scoreboard.ScoreboardDisplaySlot
-import net.minecraft.scoreboard.Team
-import net.minecraft.text.StringVisitable
-import net.minecraft.text.Style
-import net.minecraft.text.Text
-import net.minecraft.util.Formatting
+import net.minecraft.client.gui.Gui
+import net.minecraft.world.scores.DisplaySlot
+import net.minecraft.world.scores.PlayerTeam
+import net.minecraft.network.chat.FormattedText
+import net.minecraft.network.chat.Style
+import net.minecraft.network.chat.Component
+import net.minecraft.ChatFormatting
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.TickEvent
object ScoreboardUtil {
- var scoreboardLines: List<Text> = listOf()
+ var scoreboardLines: List<Component> = listOf()
var simplifiedScoreboardLines: List<String> = listOf()
@Subscribe
@@ -21,26 +21,26 @@ object ScoreboardUtil {
simplifiedScoreboardLines = scoreboardLines.map { it.unformattedString }
}
- private fun getScoreboardLinesUncached(): List<Text> {
- val scoreboard = MC.instance.world?.scoreboard ?: return listOf()
- val activeObjective = scoreboard.getObjectiveForSlot(ScoreboardDisplaySlot.SIDEBAR) ?: return listOf()
- return scoreboard.getScoreboardEntries(activeObjective)
- .filter { !it.hidden() }
- .sortedWith(InGameHud.SCOREBOARD_ENTRY_COMPARATOR)
+ private fun getScoreboardLinesUncached(): List<Component> {
+ val scoreboard = MC.instance.level?.scoreboard ?: return listOf()
+ val activeObjective = scoreboard.getDisplayObjective(DisplaySlot.SIDEBAR) ?: return listOf()
+ return scoreboard.listPlayerScores(activeObjective)
+ .filter { !it.isHidden() }
+ .sortedWith(Gui.SCORE_DISPLAY_ORDER)
.take(15).map {
- val team = scoreboard.getScoreHolderTeam(it.owner)
- val text = it.name()
- Team.decorateName(team, text)
+ val team = scoreboard.getPlayersTeam(it.owner)
+ val text = it.ownerName()
+ PlayerTeam.formatNameForTeam(team, text)
}
}
}
-fun Text.formattedString(): String {
+fun Component.formattedString(): String {
val sb = StringBuilder()
- visit(StringVisitable.StyledVisitor<Unit> { style, string ->
- val c = Formatting.byName(style.color?.name)
+ visit(FormattedText.StyledContentConsumer<Unit> { style, string ->
+ val c = ChatFormatting.getByName(style.color?.serialize())
if (c != null) {
- sb.append("§${c.code}")
+ sb.append("§${c.char}")
}
if (style.isUnderlined) {
sb.append("§n")
diff --git a/src/main/kotlin/util/ScreenUtil.kt b/src/main/kotlin/util/ScreenUtil.kt
index 99d77fb..98875e0 100644
--- a/src/main/kotlin/util/ScreenUtil.kt
+++ b/src/main/kotlin/util/ScreenUtil.kt
@@ -3,8 +3,8 @@
package moe.nea.firmament.util
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
-import net.minecraft.client.MinecraftClient
-import net.minecraft.client.gui.screen.Screen
+import net.minecraft.client.Minecraft
+import net.minecraft.client.gui.screens.Screen
import moe.nea.firmament.Firmament
object ScreenUtil {
@@ -12,11 +12,11 @@ object ScreenUtil {
ClientTickEvents.START_CLIENT_TICK.register(::onTick)
}
- private fun onTick(minecraft: MinecraftClient) {
+ private fun onTick(minecraft: Minecraft) {
if (nextOpenedGui != null) {
val p = minecraft.player
- if (p?.currentScreenHandler != null) {
- p.closeHandledScreen()
+ if (p?.containerMenu != null) {
+ p.closeContainer()
}
minecraft.setScreen(nextOpenedGui)
nextOpenedGui = null
diff --git a/src/main/kotlin/util/SkyblockId.kt b/src/main/kotlin/util/SkyblockId.kt
index 8fd32c7..0d21559 100644
--- a/src/main/kotlin/util/SkyblockId.kt
+++ b/src/main/kotlin/util/SkyblockId.kt
@@ -17,15 +17,15 @@ import kotlinx.serialization.Serializable
import kotlinx.serialization.UseSerializers
import kotlinx.serialization.json.Json
import kotlin.jvm.optionals.getOrNull
-import net.minecraft.component.DataComponentTypes
-import net.minecraft.component.type.NbtComponent
-import net.minecraft.item.ItemStack
-import net.minecraft.item.Items
-import net.minecraft.nbt.NbtCompound
-import net.minecraft.network.RegistryByteBuf
-import net.minecraft.network.codec.PacketCodec
-import net.minecraft.network.codec.PacketCodecs
-import net.minecraft.util.Identifier
+import net.minecraft.core.component.DataComponents
+import net.minecraft.world.item.component.CustomData
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.item.Items
+import net.minecraft.nbt.CompoundTag
+import net.minecraft.network.RegistryFriendlyByteBuf
+import net.minecraft.network.codec.StreamCodec
+import net.minecraft.network.codec.ByteBufCodecs
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.repo.ExpLadders
import moe.nea.firmament.repo.ExpensiveItemCacheApi
import moe.nea.firmament.repo.ItemCache.asItemStack
@@ -50,7 +50,7 @@ import moe.nea.firmament.util.skyblock.ScreenType
@Serializable
value class SkyblockId(val neuItem: String) : Comparable<SkyblockId> {
val identifier
- get() = Identifier.of(
+ get() = ResourceLocation.fromNamespaceAndPath(
"skyblockitem",
neuItem.lowercase().replace(";", "__")
.replace(":", "___")
@@ -91,8 +91,8 @@ value class SkyblockId(val neuItem: String) : Comparable<SkyblockId> {
val PET_NULL: SkyblockId = SkyblockId("null_pet")
private val illlegalPathRegex = "[^a-z0-9_.-/]".toRegex()
val CODEC = Codec.STRING.xmap({ SkyblockId(it) }, { it.neuItem })
- val PACKET_CODEC: PacketCodec<in RegistryByteBuf, SkyblockId> =
- PacketCodecs.STRING.xmap({ SkyblockId(it) }, { it.neuItem })
+ val PACKET_CODEC: StreamCodec<in RegistryFriendlyByteBuf, SkyblockId> =
+ ByteBufCodecs.STRING_UTF8.map({ SkyblockId(it) }, { it.neuItem })
}
}
@@ -128,23 +128,23 @@ data class HypixelPetInfo(
private val jsonparser = Json { ignoreUnknownKeys = true }
-var ItemStack.extraAttributes: NbtCompound
+var ItemStack.extraAttributes: CompoundTag
set(value) {
- set(DataComponentTypes.CUSTOM_DATA, NbtComponent.of(value))
+ set(DataComponents.CUSTOM_DATA, CustomData.of(value))
}
get() {
- val customData = get(DataComponentTypes.CUSTOM_DATA) ?: run {
- val component = NbtComponent.of(NbtCompound())
- set(DataComponentTypes.CUSTOM_DATA, component)
+ val customData = get(DataComponents.CUSTOM_DATA) ?: run {
+ val component = CustomData.of(CompoundTag())
+ set(DataComponents.CUSTOM_DATA, component)
component
}
return customData.unsafeNbt
}
-fun ItemStack.modifyExtraAttributes(block: (NbtCompound) -> Unit) {
- val baseNbt = get(DataComponentTypes.CUSTOM_DATA)?.copyNbt() ?: NbtCompound()
+fun ItemStack.modifyExtraAttributes(block: (CompoundTag) -> Unit) {
+ val baseNbt = get(DataComponents.CUSTOM_DATA)?.copyTag() ?: CompoundTag()
block(baseNbt)
- set(DataComponentTypes.CUSTOM_DATA, NbtComponent.of(baseNbt))
+ set(DataComponents.CUSTOM_DATA, CustomData.of(baseNbt))
}
val ItemStack.skyBlockUUIDString: String?
@@ -266,7 +266,7 @@ val ItemStack.skyBlockId: SkyblockId?
"RUNE", "UNIQUE_RUNE" -> {
val runeData = extraAttributes.getCompound("runes")
.getOrNull()
- val runeKind = runeData?.keys?.singleOrNull()
+ val runeKind = runeData?.keySet()?.singleOrNull()
if (runeKind == null) SkyblockId("RUNE")
else SkyblockId("${runeKind.uppercase()}_RUNE;${runeData.getInt(runeKind).getOrNull()}")
}
@@ -278,14 +278,14 @@ val ItemStack.skyBlockId: SkyblockId?
"ENCHANTED_BOOK" -> {
val enchantmentData = extraAttributes.getCompound("enchantments")
.getOrNull()
- val enchantName = enchantmentData?.keys?.singleOrNull()
+ val enchantName = enchantmentData?.keySet()?.singleOrNull()
if (enchantName == null) SkyblockId("ENCHANTED_BOOK")
else SkyblockId("${enchantName.uppercase()};${enchantmentData.getInt(enchantName).getOrNull()}")
}
"ATTRIBUTE_SHARD" -> {
val attributeData = extraAttributes.getCompound("attributes").getOrNull()
- val attributeName = attributeData?.keys?.singleOrNull()
+ val attributeName = attributeData?.keySet()?.singleOrNull()
if (attributeName == null) SkyblockId("ATTRIBUTE_SHARD")
else SkyblockId(
"ATTRIBUTE_SHARD_${attributeName.uppercase()};${
diff --git a/src/main/kotlin/util/WarpUtil.kt b/src/main/kotlin/util/WarpUtil.kt
index 6783fa1..3008592 100644
--- a/src/main/kotlin/util/WarpUtil.kt
+++ b/src/main/kotlin/util/WarpUtil.kt
@@ -6,8 +6,8 @@ import kotlinx.serialization.Serializable
import kotlinx.serialization.serializer
import kotlin.math.sqrt
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.text.Text
-import net.minecraft.util.math.Position
+import net.minecraft.network.chat.Component
+import net.minecraft.core.Position
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.thenExecute
import moe.nea.firmament.events.CommandEvent
@@ -45,25 +45,25 @@ object WarpUtil {
}
private fun squaredDist(pos: Position, warp: Warp): Double {
- val dx = pos.x - warp.x
- val dy = pos.y - warp.y
- val dz = pos.z - warp.z
+ val dx = pos.x() - warp.x
+ val dy = pos.y() - warp.y
+ val dz = pos.z() - warp.z
return dx * dx + dy * dy + dz * dz
}
fun teleportToNearestWarp(island: SkyBlockIsland, pos: Position) {
val nearestWarp = findNearestWarp(island, pos)
if (nearestWarp == null) {
- MC.sendChat(Text.translatable("firmament.warp-util.no-warp-found", island.userFriendlyName))
+ MC.sendChat(Component.translatable("firmament.warp-util.no-warp-found", island.userFriendlyName))
return
}
if (island == SBData.skyblockLocation
- && sqrt(squaredDist(pos, nearestWarp)) > 1.1 * sqrt(squaredDist((MC.player ?: return).pos, nearestWarp))
+ && sqrt(squaredDist(pos, nearestWarp)) > 1.1 * sqrt(squaredDist((MC.player ?: return).position, nearestWarp))
) {
- MC.sendChat(Text.translatable("firmament.warp-util.already-close", nearestWarp.warp))
+ MC.sendChat(Component.translatable("firmament.warp-util.already-close", nearestWarp.warp))
return
}
- MC.sendChat(Text.translatable("firmament.warp-util.attempting-to-warp", nearestWarp.warp))
+ MC.sendChat(Component.translatable("firmament.warp-util.attempting-to-warp", nearestWarp.warp))
lastWarpAttempt = TimeMark.now()
lastAttemptedWarp = nearestWarp.warp
MC.sendCommand("warp ${nearestWarp.warp}")
@@ -75,7 +75,7 @@ object WarpUtil {
thenExecute {
DConfig.data?.excludedWarps?.clear()
DConfig.markDirty()
- source.sendFeedback(Text.translatable("firmament.warp-util.clear-excluded"))
+ source.sendFeedback(Component.translatable("firmament.warp-util.clear-excluded"))
}
}
}
@@ -87,7 +87,7 @@ object WarpUtil {
) {
DConfig.data?.excludedWarps?.add(lastAttemptedWarp)
DConfig.markDirty()
- MC.sendChat(Text.stringifiedTranslatable("firmament.warp-util.mark-excluded", lastAttemptedWarp))
+ MC.sendChat(Component.translatableEscape("firmament.warp-util.mark-excluded", lastAttemptedWarp))
lastWarpAttempt = TimeMark.farPast()
}
if (it.unformattedString.startsWith("You may now fast travel to")) {
diff --git a/src/main/kotlin/util/accessors/GetRectangle.kt b/src/main/kotlin/util/accessors/GetRectangle.kt
index 56f420c..05ecfa9 100644
--- a/src/main/kotlin/util/accessors/GetRectangle.kt
+++ b/src/main/kotlin/util/accessors/GetRectangle.kt
@@ -3,10 +3,10 @@
package moe.nea.firmament.util.accessors
import me.shedaniel.math.Rectangle
-import net.minecraft.client.gui.screen.ingame.HandledScreen
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
import moe.nea.firmament.mixins.accessor.AccessorHandledScreen
-fun HandledScreen<*>.getRectangle(): Rectangle {
+fun AbstractContainerScreen<*>.getProperRectangle(): Rectangle {
this as AccessorHandledScreen
return Rectangle(
getX_Firmament(),
diff --git a/src/main/kotlin/util/accessors/chathud.kt b/src/main/kotlin/util/accessors/chathud.kt
index effac7d..7935ad4 100644
--- a/src/main/kotlin/util/accessors/chathud.kt
+++ b/src/main/kotlin/util/accessors/chathud.kt
@@ -1,8 +1,8 @@
package moe.nea.firmament.util.accessors
-import net.minecraft.client.gui.hud.ChatHud
-import net.minecraft.client.gui.hud.ChatHudLine
+import net.minecraft.client.gui.components.ChatComponent
+import net.minecraft.client.GuiMessage
import moe.nea.firmament.mixins.accessor.AccessorChatHud
-val ChatHud.messages: MutableList<ChatHudLine>
+val ChatComponent.messages: MutableList<GuiMessage>
get() = (this as AccessorChatHud).messages_firmament
diff --git a/src/main/kotlin/util/async/input.kt b/src/main/kotlin/util/async/input.kt
index 35265f5..65479e9 100644
--- a/src/main/kotlin/util/async/input.kt
+++ b/src/main/kotlin/util/async/input.kt
@@ -9,7 +9,7 @@ import io.github.notenoughupdates.moulconfig.gui.component.TextFieldComponent
import io.github.notenoughupdates.moulconfig.observer.GetSetter
import kotlinx.coroutines.suspendCancellableCoroutine
import kotlin.coroutines.resume
-import net.minecraft.client.gui.screen.Screen
+import net.minecraft.client.gui.screens.Screen
import moe.nea.firmament.events.HandledScreenKeyPressedEvent
import moe.nea.firmament.gui.FirmButtonComponent
import moe.nea.firmament.keybindings.SavedKeyBinding
diff --git a/src/main/kotlin/util/colorconversion.kt b/src/main/kotlin/util/colorconversion.kt
index d7a5dad..758e354 100644
--- a/src/main/kotlin/util/colorconversion.kt
+++ b/src/main/kotlin/util/colorconversion.kt
@@ -2,12 +2,12 @@
package moe.nea.firmament.util
-import net.minecraft.text.TextColor
-import net.minecraft.util.DyeColor
+import net.minecraft.network.chat.TextColor
+import net.minecraft.world.item.DyeColor
fun DyeColor.toShedaniel(): me.shedaniel.math.Color =
- me.shedaniel.math.Color.ofOpaque(this.signColor)
+ me.shedaniel.math.Color.ofOpaque(this.textColor)
fun DyeColor.toTextColor(): TextColor =
- TextColor.fromRgb(this.signColor)
+ TextColor.fromRgb(this.textColor)
diff --git a/src/main/kotlin/util/customgui/CoordRememberingSlot.kt b/src/main/kotlin/util/customgui/CoordRememberingSlot.kt
index c61c711..e565850 100644
--- a/src/main/kotlin/util/customgui/CoordRememberingSlot.kt
+++ b/src/main/kotlin/util/customgui/CoordRememberingSlot.kt
@@ -1,7 +1,7 @@
package moe.nea.firmament.util.customgui
-import net.minecraft.screen.slot.Slot
+import net.minecraft.world.inventory.Slot
interface CoordRememberingSlot {
fun rememberCoords_firmament()
diff --git a/src/main/kotlin/util/customgui/CustomGui.kt b/src/main/kotlin/util/customgui/CustomGui.kt
index 457632b..f64bf4d 100644
--- a/src/main/kotlin/util/customgui/CustomGui.kt
+++ b/src/main/kotlin/util/customgui/CustomGui.kt
@@ -1,11 +1,11 @@
package moe.nea.firmament.util.customgui
import me.shedaniel.math.Rectangle
-import net.minecraft.client.gui.Click
-import net.minecraft.client.gui.DrawContext
-import net.minecraft.client.input.CharInput
-import net.minecraft.client.input.KeyInput
-import net.minecraft.screen.slot.Slot
+import net.minecraft.client.input.MouseButtonEvent
+import net.minecraft.client.gui.GuiGraphics
+import net.minecraft.client.input.CharacterEvent
+import net.minecraft.client.input.KeyEvent
+import net.minecraft.world.inventory.Slot
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HandledScreenPushREIEvent
@@ -26,19 +26,19 @@ abstract class CustomGui {
}
open fun render(
- drawContext: DrawContext,
- delta: Float,
- mouseX: Int,
- mouseY: Int
+ drawContext: GuiGraphics,
+ delta: Float,
+ mouseX: Int,
+ mouseY: Int
) {
}
- open fun mouseClick(click: Click, doubled: Boolean): Boolean {
+ open fun mouseClick(click: MouseButtonEvent, doubled: Boolean): Boolean {
return false
}
- open fun afterSlotRender(context: DrawContext, slot: Slot) {}
- open fun beforeSlotRender(context: DrawContext, slot: Slot) {}
+ open fun afterSlotRender(context: GuiGraphics, slot: Slot) {}
+ open fun beforeSlotRender(context: GuiGraphics, slot: Slot) {}
open fun mouseScrolled(mouseX: Double, mouseY: Double, horizontalAmount: Double, verticalAmount: Double): Boolean {
return false
}
@@ -72,23 +72,23 @@ abstract class CustomGui {
return true
}
- open fun mouseReleased(click: Click): Boolean {
+ open fun mouseReleased(click: MouseButtonEvent): Boolean {
return false
}
- open fun mouseDragged(click: Click, offsetX: Double, offsetY: Double): Boolean {
+ open fun mouseDragged(click: MouseButtonEvent, offsetX: Double, offsetY: Double): Boolean {
return false
}
- open fun keyPressed(input: KeyInput): Boolean {
+ open fun keyPressed(input: KeyEvent): Boolean {
return false
}
- open fun charTyped(input: CharInput): Boolean {
+ open fun charTyped(input: CharacterEvent): Boolean {
return false
}
- open fun keyReleased(input: KeyInput): Boolean {
+ open fun keyReleased(input: KeyEvent): Boolean {
return false
}
}
diff --git a/src/main/kotlin/util/customgui/HasCustomGui.kt b/src/main/kotlin/util/customgui/HasCustomGui.kt
index edead2e..7182979 100644
--- a/src/main/kotlin/util/customgui/HasCustomGui.kt
+++ b/src/main/kotlin/util/customgui/HasCustomGui.kt
@@ -1,7 +1,7 @@
package moe.nea.firmament.util.customgui
-import net.minecraft.client.gui.screen.ingame.HandledScreen
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
@Suppress("FunctionName")
interface HasCustomGui {
@@ -9,7 +9,7 @@ interface HasCustomGui {
fun setCustomGui_Firmament(gui: CustomGui?)
}
-var <T : HandledScreen<*>> T.customGui: CustomGui?
+var <T : AbstractContainerScreen<*>> T.customGui: CustomGui?
get() = (this as HasCustomGui).getCustomGui_Firmament()
set(value) {
(this as HasCustomGui).setCustomGui_Firmament(value)
diff --git a/src/main/kotlin/util/json/BlockPosSerializer.kt b/src/main/kotlin/util/json/BlockPosSerializer.kt
index 144b0a0..5906544 100644
--- a/src/main/kotlin/util/json/BlockPosSerializer.kt
+++ b/src/main/kotlin/util/json/BlockPosSerializer.kt
@@ -5,7 +5,7 @@ import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.serializer
-import net.minecraft.util.math.BlockPos
+import net.minecraft.core.BlockPos
object BlockPosSerializer : KSerializer<BlockPos> {
val delegate = serializer<List<Int>>()
diff --git a/src/main/kotlin/util/json/FirmCodecs.kt b/src/main/kotlin/util/json/FirmCodecs.kt
index c0863bc..d7b8f57 100644
--- a/src/main/kotlin/util/json/FirmCodecs.kt
+++ b/src/main/kotlin/util/json/FirmCodecs.kt
@@ -4,11 +4,11 @@ import com.mojang.serialization.Codec
import com.mojang.serialization.DataResult
import com.mojang.serialization.Lifecycle
import com.mojang.util.UndashedUuid
-import net.minecraft.util.Uuids
+import net.minecraft.core.UUIDUtil
object FirmCodecs {
@JvmField
- val UUID_LENIENT_PREFER_INT_STREAM = Codec.withAlternative(Uuids.INT_STREAM_CODEC, Codec.STRING.comapFlatMap(
+ val UUID_LENIENT_PREFER_INT_STREAM = Codec.withAlternative(UUIDUtil.CODEC, Codec.STRING.comapFlatMap(
{
try {
DataResult.success(UndashedUuid.fromStringLenient(it), Lifecycle.stable())
diff --git a/src/main/kotlin/util/math/Projections.kt b/src/main/kotlin/util/math/Projections.kt
index 359b21b..9e9f844 100644
--- a/src/main/kotlin/util/math/Projections.kt
+++ b/src/main/kotlin/util/math/Projections.kt
@@ -3,7 +3,7 @@ package moe.nea.firmament.util.math
import kotlin.math.absoluteValue
import kotlin.math.cos
import kotlin.math.sin
-import net.minecraft.util.math.Vec2f
+import net.minecraft.world.phys.Vec2
import moe.nea.firmament.util.render.wrapAngle
object Projections {
@@ -14,14 +14,14 @@ object Projections {
fun isNullish(float: Float) = float.absoluteValue < ε
- fun xInterceptOfLine(origin: Vec2f, direction: Vec2f): Vec2f? {
+ fun xInterceptOfLine(origin: Vec2, direction: Vec2): Vec2? {
if (isNullish(direction.x))
- return Vec2f(origin.x, 0F)
+ return Vec2(origin.x, 0F)
if (isNullish(direction.y))
return null
val slope = direction.y / direction.x
- return Vec2f(origin.x - origin.y / slope, 0F)
+ return Vec2(origin.x - origin.y / slope, 0F)
}
fun interceptAlongCardinal(distanceFromAxis: Float, slope: Float): Float? {
@@ -30,7 +30,7 @@ object Projections {
return -distanceFromAxis / slope
}
- fun projectAngleOntoUnitBox(angleRadians: Double): Vec2f {
+ fun projectAngleOntoUnitBox(angleRadians: Double): Vec2 {
val angleRadians = wrapAngle(angleRadians)
val cx = cos(angleRadians)
val cy = sin(angleRadians)
@@ -40,7 +40,7 @@ object Projections {
val e = minOf(ex, ey)
- return Vec2f((cx * e).toFloat(), (cy * e).toFloat())
+ return Vec2((cx * e).toFloat(), (cy * e).toFloat())
}
}
}
diff --git a/src/main/kotlin/util/mc/ArmorUtil.kt b/src/main/kotlin/util/mc/ArmorUtil.kt
index fd1867c..3bb1768 100644
--- a/src/main/kotlin/util/mc/ArmorUtil.kt
+++ b/src/main/kotlin/util/mc/ArmorUtil.kt
@@ -1,8 +1,8 @@
package moe.nea.firmament.util.mc
-import net.minecraft.entity.EquipmentSlot
-import net.minecraft.entity.LivingEntity
+import net.minecraft.world.entity.EquipmentSlot
+import net.minecraft.world.entity.LivingEntity
val LivingEntity.iterableArmorItems
get() = EquipmentSlot.entries.asSequence()
- .map { it to getEquippedStack(it) }
+ .map { it to getItemBySlot(it) }
diff --git a/src/main/kotlin/util/mc/CustomRenderPassHelper.kt b/src/main/kotlin/util/mc/CustomRenderPassHelper.kt
index 67fb2f8..93cd7c1 100644
--- a/src/main/kotlin/util/mc/CustomRenderPassHelper.kt
+++ b/src/main/kotlin/util/mc/CustomRenderPassHelper.kt
@@ -13,22 +13,22 @@ import java.util.OptionalDouble
import java.util.OptionalInt
import org.joml.Vector3f
import org.joml.Vector4f
-import net.minecraft.client.gl.Framebuffer
-import net.minecraft.client.render.BufferBuilder
-import net.minecraft.client.render.BuiltBuffer
-import net.minecraft.client.texture.AbstractTexture
-import net.minecraft.client.util.BufferAllocator
-import net.minecraft.util.Identifier
-import net.minecraft.util.math.MathHelper
+import com.mojang.blaze3d.pipeline.RenderTarget
+import com.mojang.blaze3d.vertex.BufferBuilder
+import com.mojang.blaze3d.vertex.MeshData
+import net.minecraft.client.renderer.texture.AbstractTexture
+import com.mojang.blaze3d.vertex.ByteBufferBuilder
+import net.minecraft.resources.ResourceLocation
+import net.minecraft.util.Mth
import moe.nea.firmament.util.ErrorUtil
import moe.nea.firmament.util.MC
class CustomRenderPassHelper(
val labelSupplier: () -> String,
- val drawMode: VertexFormat.DrawMode,
+ val drawMode: VertexFormat.Mode,
val vertexFormat: VertexFormat,
- val frameBuffer: Framebuffer,
+ val frameBuffer: RenderTarget,
val hasDepth: Boolean,
) : AutoCloseable {
private val scope = mutableListOf<AutoCloseable>()
@@ -45,12 +45,12 @@ class CustomRenderPassHelper(
}
}
- fun bindSampler(name: String, texture: Identifier) {
+ fun bindSampler(name: String, texture: ResourceLocation) {
bindSampler(name, MC.textureManager.getTexture(texture))
}
fun bindSampler(name: String, texture: AbstractTexture) {
- queueAction { it.bindSampler(name, texture.glTextureView) }
+ queueAction { it.bindSampler(name, texture.textureView) }
}
@@ -65,7 +65,7 @@ class CustomRenderPassHelper(
}
setUniform(
"DynamicTransforms", RenderSystem.getDynamicUniforms()
- .write(
+ .writeTransform(
RenderSystem.getModelViewMatrix(),
Vector4f(1.0F, 1.0F, 1.0F, 1.0F),
Vector3f(), // TODO: 1.21.10
@@ -83,25 +83,25 @@ class CustomRenderPassHelper(
setUniform(name, buffer)
}
- var vertices: BuiltBuffer? = null
+ var vertices: MeshData? = null
fun uploadVertices(size: Int, init: (BufferBuilder) -> Unit) {
uploadVertices(
- BufferBuilder(queueClose(BufferAllocator(size)), drawMode, vertexFormat)
+ BufferBuilder(queueClose(ByteBufferBuilder(size)), drawMode, vertexFormat)
.also(init)
- .end()
+ .buildOrThrow()
)
}
- fun uploadVertices(buffer: BuiltBuffer) {
+ fun uploadVertices(buffer: MeshData) {
queueClose(buffer)
ErrorUtil.softCheck("Vertices have already been uploaded", vertices == null)
vertices = buffer
- val vertexBuffer = vertexFormat.uploadImmediateVertexBuffer(buffer.buffer)
+ val vertexBuffer = vertexFormat.uploadImmediateVertexBuffer(buffer.vertexBuffer())
val indexBufferConstructor = RenderSystem.getSequentialBuffer(drawMode)
- val indexBuffer = indexBufferConstructor.getIndexBuffer(buffer.drawParameters.indexCount)
+ val indexBuffer = indexBufferConstructor.getBuffer(buffer.drawState().indexCount)
queueAction {
- it.setIndexBuffer(indexBuffer, indexBufferConstructor.indexType)
+ it.setIndexBuffer(indexBuffer, indexBufferConstructor.type())
it.setVertexBuffer(0, vertexBuffer)
}
}
@@ -119,7 +119,7 @@ class CustomRenderPassHelper(
fun allocateByteBuf(size: Int, init: (Std140Builder) -> Unit): ByteBuffer {
return Std140Builder.intoBuffer( // TODO: i really dont know about this 16 align? but it seems to be generally correct.
ByteBuffer
- .allocateDirect(MathHelper.roundUpToMultiple(size, 16))
+ .allocateDirect(Mth.roundToward(size, 16))
.order(ByteOrder.nativeOrder())
).also(init).get()
}
@@ -142,10 +142,10 @@ class CustomRenderPassHelper(
val renderPass = queueClose(
commandEncoder.createRenderPass(
labelSupplier::invoke,
- RenderSystem.outputColorTextureOverride ?: frameBuffer.getColorAttachmentView(),
+ RenderSystem.outputColorTextureOverride ?: frameBuffer.colorTextureView!!,
OptionalInt.empty(),
(RenderSystem.outputDepthTextureOverride
- ?: frameBuffer.getDepthAttachmentView()).takeIf { frameBuffer.useDepthAttachment && hasDepth },
+ ?: frameBuffer.depthTextureView).takeIf { frameBuffer.useDepth && hasDepth },
OptionalDouble.empty()
)
)
@@ -153,7 +153,7 @@ class CustomRenderPassHelper(
renderPass.drawIndexed(
0,
0,
- vertexData.drawParameters.indexCount,
+ vertexData.drawState().indexCount,
1
)
return DrawToken
diff --git a/src/main/kotlin/util/mc/FakeInventory.kt b/src/main/kotlin/util/mc/FakeInventory.kt
index 26c04bc..198ec68 100644
--- a/src/main/kotlin/util/mc/FakeInventory.kt
+++ b/src/main/kotlin/util/mc/FakeInventory.kt
@@ -1,14 +1,14 @@
package util.mc
-import net.minecraft.entity.player.PlayerEntity
-import net.minecraft.inventory.Inventory
-import net.minecraft.item.ItemStack
+import net.minecraft.world.entity.player.Player
+import net.minecraft.world.Container
+import net.minecraft.world.item.ItemStack
-class FakeInventory(val stack: ItemStack) : Inventory {
- override fun clear() {
+class FakeInventory(val stack: ItemStack) : Container {
+ override fun clearContent() {
}
- override fun size(): Int {
+ override fun getContainerSize(): Int {
return 1
}
@@ -16,26 +16,26 @@ class FakeInventory(val stack: ItemStack) : Inventory {
return stack.isEmpty
}
- override fun getStack(slot: Int): ItemStack {
+ override fun getItem(slot: Int): ItemStack {
require(slot == 0)
return stack
}
- override fun removeStack(slot: Int, amount: Int): ItemStack {
+ override fun removeItem(slot: Int, amount: Int): ItemStack {
return ItemStack.EMPTY
}
- override fun removeStack(slot: Int): ItemStack {
+ override fun removeItemNoUpdate(slot: Int): ItemStack {
return ItemStack.EMPTY
}
- override fun setStack(slot: Int, stack: ItemStack?) {
+ override fun setItem(slot: Int, stack: ItemStack?) {
}
- override fun markDirty() {
+ override fun setChanged() {
}
- override fun canPlayerUse(player: PlayerEntity?): Boolean {
+ override fun stillValid(player: Player?): Boolean {
return true
}
}
diff --git a/src/main/kotlin/util/mc/FakeSlot.kt b/src/main/kotlin/util/mc/FakeSlot.kt
index a9be484..9793fdf 100644
--- a/src/main/kotlin/util/mc/FakeSlot.kt
+++ b/src/main/kotlin/util/mc/FakeSlot.kt
@@ -1,15 +1,15 @@
package moe.nea.firmament.util.mc
import util.mc.FakeInventory
-import net.minecraft.item.ItemStack
-import net.minecraft.screen.slot.Slot
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.inventory.Slot
class FakeSlot(
- stack: ItemStack,
- x: Int,
- y: Int
+ stack: ItemStack,
+ x: Int,
+ y: Int
) : Slot(FakeInventory(stack), 0, x, y) {
init {
- id = 0
+ index = 0
}
}
diff --git a/src/main/kotlin/util/mc/FirmamentDataComponentTypes.kt b/src/main/kotlin/util/mc/FirmamentDataComponentTypes.kt
index 0866665..79536e5 100644
--- a/src/main/kotlin/util/mc/FirmamentDataComponentTypes.kt
+++ b/src/main/kotlin/util/mc/FirmamentDataComponentTypes.kt
@@ -2,10 +2,10 @@ package moe.nea.firmament.util.mc
import com.mojang.serialization.Codec
import io.netty.buffer.ByteBuf
-import net.minecraft.component.ComponentType
-import net.minecraft.network.codec.PacketCodec
-import net.minecraft.registry.Registries
-import net.minecraft.registry.Registry
+import net.minecraft.core.component.DataComponentType
+import net.minecraft.network.codec.StreamCodec
+import net.minecraft.core.registries.BuiltInRegistries
+import net.minecraft.core.Registry
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ClientInitEvent
@@ -19,18 +19,18 @@ object FirmamentDataComponentTypes {
private fun <T> register(
id: String,
- builderOperator: (ComponentType.Builder<T>) -> Unit
- ): ComponentType<T> {
+ builderOperator: (DataComponentType.Builder<T>) -> Unit
+ ): DataComponentType<T> {
return Registry.register(
- Registries.DATA_COMPONENT_TYPE,
+ BuiltInRegistries.DATA_COMPONENT_TYPE,
Firmament.identifier(id),
- ComponentType.builder<T>().also(builderOperator)
+ DataComponentType.builder<T>().also(builderOperator)
.build()
)
}
- fun <T> errorCodec(message: String): PacketCodec<in ByteBuf, T> =
- object : PacketCodec<ByteBuf, T> {
+ fun <T> errorCodec(message: String): StreamCodec<in ByteBuf, T> =
+ object : StreamCodec<ByteBuf, T> {
override fun decode(buf: ByteBuf?): T? {
error(message)
}
@@ -40,16 +40,16 @@ object FirmamentDataComponentTypes {
}
}
- fun <T, B : ComponentType.Builder<T>> B.neverEncode(message: String = "This element should never be encoded or decoded"): B {
- packetCodec(errorCodec(message))
- codec(null)
+ fun <T, B : DataComponentType.Builder<T>> B.neverEncode(message: String = "This element should never be encoded or decoded"): B {
+ networkSynchronized(errorCodec(message))
+ persistent(null)
return this
}
val IS_BROKEN = register<Boolean>(
"is_broken"
) {
- it.codec(Codec.BOOL.fieldOf("is_broken").codec())
+ it.persistent(Codec.BOOL.fieldOf("is_broken").codec())
}
val CUSTOM_MINING_BLOCK_DATA = register<MiningRepoData.CustomMiningBlock>("custom_mining_block") {
diff --git a/src/main/kotlin/util/mc/IntrospectableItemModelManager.kt b/src/main/kotlin/util/mc/IntrospectableItemModelManager.kt
index e546fd3..537ca5b 100644
--- a/src/main/kotlin/util/mc/IntrospectableItemModelManager.kt
+++ b/src/main/kotlin/util/mc/IntrospectableItemModelManager.kt
@@ -1,7 +1,7 @@
package moe.nea.firmament.util.mc
-import net.minecraft.util.Identifier
+import net.minecraft.resources.ResourceLocation
interface IntrospectableItemModelManager {
- fun hasModel_firmament(identifier: Identifier): Boolean
+ fun hasModel_firmament(identifier: ResourceLocation): Boolean
}
diff --git a/src/main/kotlin/util/mc/InventoryUtil.kt b/src/main/kotlin/util/mc/InventoryUtil.kt
index 74f7b9f..0509138 100644
--- a/src/main/kotlin/util/mc/InventoryUtil.kt
+++ b/src/main/kotlin/util/mc/InventoryUtil.kt
@@ -2,26 +2,26 @@ package moe.nea.firmament.util.mc
import java.util.Spliterator
import java.util.Spliterators
-import net.minecraft.inventory.Inventory
-import net.minecraft.item.ItemStack
+import net.minecraft.world.Container
+import net.minecraft.world.item.ItemStack
-val Inventory.indices get() = 0 until size()
-val Inventory.iterableView
+val Container.indices get() = 0 until containerSize
+val Container.iterableView
get() = object : Iterable<ItemStack> {
override fun spliterator(): Spliterator<ItemStack> {
- return Spliterators.spliterator(iterator(), size().toLong(), 0)
+ return Spliterators.spliterator(iterator(), containerSize.toLong(), 0)
}
override fun iterator(): Iterator<ItemStack> {
return object : Iterator<ItemStack> {
var i = 0
override fun hasNext(): Boolean {
- return i < size()
+ return i < containerSize
}
override fun next(): ItemStack {
if (!hasNext()) throw NoSuchElementException()
- return getStack(i++)
+ return getItem(i++)
}
}
}
diff --git a/src/main/kotlin/util/mc/ItemUtil.kt b/src/main/kotlin/util/mc/ItemUtil.kt
index 3cabb8e..91b6409 100644
--- a/src/main/kotlin/util/mc/ItemUtil.kt
+++ b/src/main/kotlin/util/mc/ItemUtil.kt
@@ -1,15 +1,15 @@
package moe.nea.firmament.util.mc
import kotlin.jvm.optionals.getOrNull
-import net.minecraft.item.ItemStack
-import net.minecraft.nbt.NbtCompound
+import net.minecraft.world.item.ItemStack
+import net.minecraft.nbt.CompoundTag
import net.minecraft.nbt.NbtOps
-import net.minecraft.registry.RegistryOps
-import net.minecraft.registry.RegistryWrapper
-import net.minecraft.text.Text
+import net.minecraft.resources.RegistryOps
+import net.minecraft.core.HolderLookup
+import net.minecraft.network.chat.Component
import moe.nea.firmament.util.MC
-fun ItemStack.appendLore(args: List<Text>) {
+fun ItemStack.appendLore(args: List<Component>) {
if (args.isEmpty()) return
modifyLore {
val loreList = loreAccordingToNbt.toMutableList()
@@ -20,11 +20,11 @@ fun ItemStack.appendLore(args: List<Text>) {
}
}
-fun ItemStack.modifyLore(update: (List<Text>) -> List<Text>) {
+fun ItemStack.modifyLore(update: (List<Component>) -> List<Component>) {
val loreList = loreAccordingToNbt
loreAccordingToNbt = update(loreList)
}
-fun loadItemFromNbt(nbt: NbtCompound, registries: RegistryWrapper.WrapperLookup = MC.defaultRegistries): ItemStack? {
- return ItemStack.CODEC.decode(RegistryOps.of(NbtOps.INSTANCE, registries), nbt).result().getOrNull()?.first
+fun loadItemFromNbt(nbt: CompoundTag, registries: HolderLookup.Provider = MC.defaultRegistries): ItemStack? {
+ return ItemStack.CODEC.decode(RegistryOps.create(NbtOps.INSTANCE, registries), nbt).result().getOrNull()?.first
}
diff --git a/src/main/kotlin/util/mc/MCTabListAPI.kt b/src/main/kotlin/util/mc/MCTabListAPI.kt
index 66bdd55..56933d9 100644
--- a/src/main/kotlin/util/mc/MCTabListAPI.kt
+++ b/src/main/kotlin/util/mc/MCTabListAPI.kt
@@ -4,11 +4,11 @@ import com.mojang.serialization.Codec
import com.mojang.serialization.codecs.RecordCodecBuilder
import java.util.Optional
import org.jetbrains.annotations.TestOnly
-import net.minecraft.client.gui.hud.PlayerListHud
+import net.minecraft.client.gui.components.PlayerTabOverlay
import net.minecraft.nbt.NbtOps
-import net.minecraft.scoreboard.Team
-import net.minecraft.text.Text
-import net.minecraft.text.TextCodecs
+import net.minecraft.world.scores.PlayerTeam
+import net.minecraft.network.chat.Component
+import net.minecraft.network.chat.ComponentSerialization
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.thenExecute
import moe.nea.firmament.commands.thenLiteral
@@ -24,7 +24,7 @@ import moe.nea.firmament.util.mc.SNbtFormatter.Companion.toPrettyString
object MCTabListAPI {
- fun PlayerListHud.cast() = this as AccessorPlayerListHud
+ fun PlayerTabOverlay.cast() = this as AccessorPlayerListHud
@Subscribe
fun onTick(event: TickEvent) {
@@ -37,7 +37,7 @@ object MCTabListAPI {
thenLiteral("copytablist") {
thenExecute {
currentTabList.body.forEach {
- MC.sendChat(Text.literal(TextCodecs.CODEC.encodeStart(NbtOps.INSTANCE, it).orThrow.toString()))
+ MC.sendChat(Component.literal(ComponentSerialization.CODEC.encodeStart(NbtOps.INSTANCE, it).orThrow.toString()))
}
var compound = CurrentTabList.CODEC.encodeStart(NbtOps.INSTANCE, currentTabList).orThrow
compound = ExportedTestConstantMeta.SOURCE_CODEC.encode(
@@ -60,16 +60,16 @@ object MCTabListAPI {
val currentTabList get() = _currentTabList ?: getTabListNow().also { _currentTabList = it }
data class CurrentTabList(
- val header: Optional<Text>,
- val footer: Optional<Text>,
- val body: List<Text>,
+ val header: Optional<Component>,
+ val footer: Optional<Component>,
+ val body: List<Component>,
) {
companion object {
val CODEC: Codec<CurrentTabList> = RecordCodecBuilder.create {
it.group(
- TextCodecs.CODEC.optionalFieldOf("header").forGetter(CurrentTabList::header),
- TextCodecs.CODEC.optionalFieldOf("footer").forGetter(CurrentTabList::footer),
- TextCodecs.CODEC.listOf().fieldOf("body").forGetter(CurrentTabList::body),
+ ComponentSerialization.CODEC.optionalFieldOf("header").forGetter(CurrentTabList::header),
+ ComponentSerialization.CODEC.optionalFieldOf("footer").forGetter(CurrentTabList::footer),
+ ComponentSerialization.CODEC.listOf().fieldOf("body").forGetter(CurrentTabList::body),
).apply(it, ::CurrentTabList)
}
}
@@ -78,13 +78,13 @@ object MCTabListAPI {
private fun getTabListNow(): CurrentTabList {
// This is a precondition for PlayerListHud.collectEntries to be valid
MC.networkHandler ?: return CurrentTabList(Optional.empty(), Optional.empty(), emptyList())
- val hud = MC.inGameHud.playerListHud.cast()
+ val hud = MC.inGameHud.tabList.cast()
val entries = hud.collectPlayerEntries_firmament()
.map {
- it.displayName ?: run {
- val team = it.scoreboardTeam
+ it.tabListDisplayName ?: run {
+ val team = it.team
val name = it.profile.name
- Team.decorateName(team, Text.literal(name))
+ PlayerTeam.formatNameForTeam(team, Component.literal(name))
}
}
return CurrentTabList(
diff --git a/src/main/kotlin/util/mc/NbtItemData.kt b/src/main/kotlin/util/mc/NbtItemData.kt
index 0c49862..55bfac3 100644
--- a/src/main/kotlin/util/mc/NbtItemData.kt
+++ b/src/main/kotlin/util/mc/NbtItemData.kt
@@ -1,22 +1,22 @@
package moe.nea.firmament.util.mc
-import net.minecraft.component.DataComponentTypes
-import net.minecraft.component.type.LoreComponent
-import net.minecraft.item.ItemStack
-import net.minecraft.text.Text
+import net.minecraft.core.component.DataComponents
+import net.minecraft.world.item.component.ItemLore
+import net.minecraft.world.item.ItemStack
+import net.minecraft.network.chat.Component
-var ItemStack.loreAccordingToNbt: List<Text>
- get() = get(DataComponentTypes.LORE)?.lines ?: listOf()
+var ItemStack.loreAccordingToNbt: List<Component>
+ get() = get(DataComponents.LORE)?.lines ?: listOf()
set(value) {
- set(DataComponentTypes.LORE, LoreComponent(value))
+ set(DataComponents.LORE, ItemLore(value))
}
-var ItemStack.displayNameAccordingToNbt: Text
- get() = get(DataComponentTypes.CUSTOM_NAME) ?: get(DataComponentTypes.ITEM_NAME) ?: item.name
+var ItemStack.displayNameAccordingToNbt: Component
+ get() = get(DataComponents.CUSTOM_NAME) ?: get(DataComponents.ITEM_NAME) ?: item.name
set(value) {
- set(DataComponentTypes.CUSTOM_NAME, value)
+ set(DataComponents.CUSTOM_NAME, value)
}
-fun ItemStack.setCustomName(text: Text) {
- set(DataComponentTypes.CUSTOM_NAME, text)
+fun ItemStack.setCustomName(text: Component) {
+ set(DataComponents.CUSTOM_NAME, text)
}
diff --git a/src/main/kotlin/util/mc/NbtPrism.kt b/src/main/kotlin/util/mc/NbtPrism.kt
index f13fad5..6ac7cb2 100644
--- a/src/main/kotlin/util/mc/NbtPrism.kt
+++ b/src/main/kotlin/util/mc/NbtPrism.kt
@@ -9,11 +9,11 @@ import com.mojang.brigadier.arguments.ArgumentType
import com.mojang.brigadier.arguments.StringArgumentType
import com.mojang.serialization.JsonOps
import kotlin.jvm.optionals.getOrNull
-import net.minecraft.nbt.NbtCompound
-import net.minecraft.nbt.NbtElement
-import net.minecraft.nbt.NbtList
+import net.minecraft.nbt.CompoundTag
+import net.minecraft.nbt.Tag
+import net.minecraft.nbt.ListTag
import net.minecraft.nbt.NbtOps
-import net.minecraft.nbt.NbtString
+import net.minecraft.nbt.StringTag
import moe.nea.firmament.util.Base64Util
class NbtPrism(val path: List<String>) {
@@ -42,9 +42,9 @@ class NbtPrism(val path: List<String>) {
return "Prism($path)"
}
- fun access(root: NbtElement): Collection<NbtElement> {
+ fun access(root: Tag): Collection<Tag> {
var rootSet = mutableListOf(root)
- var switch = mutableListOf<NbtElement>()
+ var switch = mutableListOf<Tag>()
for (pathSegment in path) {
if (pathSegment == ".") continue
if (pathSegment != "*" && pathSegment.startsWith("*")) {
@@ -57,21 +57,21 @@ class NbtPrism(val path: List<String>) {
} else if (pathSegment == "*base64") {
for (element in rootSet) {
val string = element.asString().getOrNull() ?: continue
- switch.add(NbtString.of(Base64Util.decodeString(string)))
+ switch.add(StringTag.valueOf(Base64Util.decodeString(string)))
}
}
}
for (element in rootSet) {
- if (element is NbtList) {
+ if (element is ListTag) {
if (pathSegment == "*")
switch.addAll(element)
val index = pathSegment.toIntOrNull() ?: continue
if (index !in element.indices) continue
switch.add(element[index])
}
- if (element is NbtCompound) {
+ if (element is CompoundTag) {
if (pathSegment == "*")
- element.keys.mapTo(switch) { element.get(it)!! }
+ element.keySet().mapTo(switch) { element.get(it)!! }
switch.add(element.get(pathSegment) ?: continue)
}
}
diff --git a/src/main/kotlin/util/mc/NbtUtil.kt b/src/main/kotlin/util/mc/NbtUtil.kt
index 5c47c28..cfd4184 100644
--- a/src/main/kotlin/util/mc/NbtUtil.kt
+++ b/src/main/kotlin/util/mc/NbtUtil.kt
@@ -1,15 +1,15 @@
package moe.nea.firmament.util.mc
-import net.minecraft.component.type.NbtComponent
-import net.minecraft.nbt.NbtElement
-import net.minecraft.nbt.NbtList
+import net.minecraft.world.item.component.CustomData
+import net.minecraft.nbt.Tag
+import net.minecraft.nbt.ListTag
import moe.nea.firmament.mixins.accessor.AccessorNbtComponent
-fun Iterable<NbtElement>.toNbtList() = NbtList().also {
+fun Iterable<Tag>.toNbtList() = ListTag().also {
for (element in this) {
it.add(element)
}
}
@Suppress("CAST_NEVER_SUCCEEDS")
-val NbtComponent.unsafeNbt get() = (this as AccessorNbtComponent).unsafeNbt_firmament
+val CustomData.unsafeNbt get() = (this as AccessorNbtComponent).unsafeNbt_firmament
diff --git a/src/main/kotlin/util/mc/PlayerUtil.kt b/src/main/kotlin/util/mc/PlayerUtil.kt
index 53ef1f4..7c21987 100644
--- a/src/main/kotlin/util/mc/PlayerUtil.kt
+++ b/src/main/kotlin/util/mc/PlayerUtil.kt
@@ -1,7 +1,7 @@
package moe.nea.firmament.util.mc
-import net.minecraft.entity.EquipmentSlot
-import net.minecraft.entity.player.PlayerEntity
+import net.minecraft.world.entity.EquipmentSlot
+import net.minecraft.world.entity.player.Player
-val PlayerEntity.mainHandStack get() = this.getEquippedStack(EquipmentSlot.MAINHAND)
+val Player.mainHandStack get() = this.getItemBySlot(EquipmentSlot.MAINHAND)
diff --git a/src/main/kotlin/util/mc/SNbtFormatter.kt b/src/main/kotlin/util/mc/SNbtFormatter.kt
index 7617d17..0e630eb 100644
--- a/src/main/kotlin/util/mc/SNbtFormatter.kt
+++ b/src/main/kotlin/util/mc/SNbtFormatter.kt
@@ -1,23 +1,23 @@
package moe.nea.firmament.util.mc
-import net.minecraft.nbt.AbstractNbtList
-import net.minecraft.nbt.NbtByte
-import net.minecraft.nbt.NbtByteArray
-import net.minecraft.nbt.NbtCompound
-import net.minecraft.nbt.NbtDouble
-import net.minecraft.nbt.NbtElement
-import net.minecraft.nbt.NbtEnd
-import net.minecraft.nbt.NbtFloat
-import net.minecraft.nbt.NbtInt
-import net.minecraft.nbt.NbtIntArray
-import net.minecraft.nbt.NbtList
-import net.minecraft.nbt.NbtLong
-import net.minecraft.nbt.NbtLongArray
-import net.minecraft.nbt.NbtShort
-import net.minecraft.nbt.NbtString
-import net.minecraft.nbt.visitor.NbtElementVisitor
-
-class SNbtFormatter private constructor() : NbtElementVisitor {
+import net.minecraft.nbt.CollectionTag
+import net.minecraft.nbt.ByteTag
+import net.minecraft.nbt.ByteArrayTag
+import net.minecraft.nbt.CompoundTag
+import net.minecraft.nbt.DoubleTag
+import net.minecraft.nbt.Tag
+import net.minecraft.nbt.EndTag
+import net.minecraft.nbt.FloatTag
+import net.minecraft.nbt.IntTag
+import net.minecraft.nbt.IntArrayTag
+import net.minecraft.nbt.ListTag
+import net.minecraft.nbt.LongTag
+import net.minecraft.nbt.LongArrayTag
+import net.minecraft.nbt.ShortTag
+import net.minecraft.nbt.StringTag
+import net.minecraft.nbt.TagVisitor
+
+class SNbtFormatter private constructor() : TagVisitor {
private val result = StringBuilder()
private var indent = 0
private fun writeIndent() {
@@ -32,41 +32,41 @@ class SNbtFormatter private constructor() : NbtElementVisitor {
indent--
}
- fun apply(element: NbtElement): StringBuilder {
+ fun apply(element: Tag): StringBuilder {
element.accept(this)
return result
}
- override fun visitString(element: NbtString) {
- result.append(NbtString.escape(element.value))
+ override fun visitString(element: StringTag) {
+ result.append(StringTag.quoteAndEscape(element.value))
}
- override fun visitByte(element: NbtByte) {
- result.append(element.numberValue()).append("b")
+ override fun visitByte(element: ByteTag) {
+ result.append(element.box()).append("b")
}
- override fun visitShort(element: NbtShort) {
+ override fun visitShort(element: ShortTag) {
result.append(element.shortValue()).append("s")
}
- override fun visitInt(element: NbtInt) {
+ override fun visitInt(element: IntTag) {
result.append(element.intValue())
}
- override fun visitLong(element: NbtLong) {
+ override fun visitLong(element: LongTag) {
result.append(element.longValue()).append("L")
}
- override fun visitFloat(element: NbtFloat) {
+ override fun visitFloat(element: FloatTag) {
result.append(element.floatValue()).append("f")
}
- override fun visitDouble(element: NbtDouble) {
+ override fun visitDouble(element: DoubleTag) {
result.append(element.doubleValue()).append("d")
}
- private fun visitArrayContents(array: AbstractNbtList) {
+ private fun visitArrayContents(array: CollectionTag) {
array.forEachIndexed { index, element ->
writeIndent()
element.accept(this)
@@ -77,7 +77,7 @@ class SNbtFormatter private constructor() : NbtElementVisitor {
}
}
- private fun writeArray(arrayTypeTag: String, array: AbstractNbtList) {
+ private fun writeArray(arrayTypeTag: String, array: CollectionTag) {
result.append("[").append(arrayTypeTag).append("\n")
pushIndent()
visitArrayContents(array)
@@ -87,26 +87,26 @@ class SNbtFormatter private constructor() : NbtElementVisitor {
}
- override fun visitByteArray(element: NbtByteArray) {
+ override fun visitByteArray(element: ByteArrayTag) {
writeArray("B;", element)
}
- override fun visitIntArray(element: NbtIntArray) {
+ override fun visitIntArray(element: IntArrayTag) {
writeArray("I;", element)
}
- override fun visitLongArray(element: NbtLongArray) {
+ override fun visitLongArray(element: LongArrayTag) {
writeArray("L;", element)
}
- override fun visitList(element: NbtList) {
+ override fun visitList(element: ListTag) {
writeArray("", element)
}
- override fun visitCompound(compound: NbtCompound) {
+ override fun visitCompound(compound: CompoundTag) {
result.append("{\n")
pushIndent()
- val keys = compound.keys.sorted()
+ val keys = compound.keySet().sorted()
keys.forEachIndexed { index, key ->
writeIndent()
val element = compound[key] ?: error("Key '$key' found but not present in compound: $compound")
@@ -123,19 +123,19 @@ class SNbtFormatter private constructor() : NbtElementVisitor {
result.append("}")
}
- override fun visitEnd(element: NbtEnd) {
+ override fun visitEnd(element: EndTag) {
result.append("END")
}
companion object {
- fun prettify(nbt: NbtElement): String {
+ fun prettify(nbt: Tag): String {
return SNbtFormatter().apply(nbt).toString()
}
- fun NbtElement.toPrettyString() = prettify(this)
+ fun Tag.toPrettyString() = prettify(this)
fun escapeName(key: String): String =
- if (key.matches(SIMPLE_NAME)) key else NbtString.escape(key)
+ if (key.matches(SIMPLE_NAME)) key else StringTag.quoteAndEscape(key)
val SIMPLE_NAME = "[A-Za-z0-9._+-]+".toRegex()
}
diff --git a/src/main/kotlin/util/mc/ScreenUtil.kt b/src/main/kotlin/util/mc/ScreenUtil.kt
index 36feb6b..4e3dbf1 100644
--- a/src/main/kotlin/util/mc/ScreenUtil.kt
+++ b/src/main/kotlin/util/mc/ScreenUtil.kt
@@ -1,9 +1,9 @@
package moe.nea.firmament.util.mc
-import net.minecraft.client.gui.screen.Screen
-import net.minecraft.client.gui.screen.ingame.HandledScreen
-import net.minecraft.entity.player.PlayerInventory
-import net.minecraft.screen.slot.Slot
+import net.minecraft.client.gui.screens.Screen
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
+import net.minecraft.world.entity.player.Inventory
+import net.minecraft.world.inventory.Slot
object ScreenUtil {
private var lastScreen: Screen? = null
@@ -12,15 +12,15 @@ object ScreenUtil {
data class SlotIndex(val index: Int, val isPlayerInventory: Boolean)
fun Screen.getSlotsByIndex(): Map<SlotIndex, Slot> {
- if (this !is HandledScreen<*>) return mapOf()
+ if (this !is AbstractContainerScreen<*>) return mapOf()
if (lastScreen === this) return slotsByIndex
lastScreen = this
- slotsByIndex = this.screenHandler.slots.associate {
- SlotIndex(it.index, it.inventory is PlayerInventory) to it
+ slotsByIndex = this.menu.slots.associate {
+ SlotIndex(it.containerSlot, it.container is Inventory) to it
}
return slotsByIndex
}
- fun Screen.getSlotByIndex( index: Int, isPlayerInventory: Boolean): Slot? =
+ fun Screen.getSlotByIndex(index: Int, isPlayerInventory: Boolean): Slot? =
getSlotsByIndex()[SlotIndex(index, isPlayerInventory)]
}
diff --git a/src/main/kotlin/util/mc/SkullItemData.kt b/src/main/kotlin/util/mc/SkullItemData.kt
index 6f8f24b..cfe5d21 100644
--- a/src/main/kotlin/util/mc/SkullItemData.kt
+++ b/src/main/kotlin/util/mc/SkullItemData.kt
@@ -9,10 +9,10 @@ import java.time.Instant
import java.util.UUID
import kotlinx.serialization.Serializable
import kotlinx.serialization.UseSerializers
-import net.minecraft.component.DataComponentTypes
-import net.minecraft.component.type.ProfileComponent
-import net.minecraft.item.ItemStack
-import net.minecraft.item.Items
+import net.minecraft.core.component.DataComponents
+import net.minecraft.world.item.component.ResolvableProfile
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.item.Items
import moe.nea.firmament.Firmament
import moe.nea.firmament.util.Base64Util.padToValidBase64
import moe.nea.firmament.util.assertTrueOr
@@ -46,7 +46,7 @@ fun ItemStack.setEncodedSkullOwner(uuid: UUID, encodedData: String) {
assert(this.item == Items.PLAYER_HEAD)
val gameProfile = GameProfile(uuid, "LameGuy123")
gameProfile.properties.put(propertyTextures, Property(propertyTextures, encodedData.padToValidBase64()))
- this.set(DataComponentTypes.PROFILE, ProfileComponent.ofStatic(gameProfile))
+ this.set(DataComponents.PROFILE, ResolvableProfile.createResolved(gameProfile))
}
val arbitraryUUID = UUID.fromString("d3cb85e2-3075-48a1-b213-a9bfb62360c1")
@@ -63,7 +63,7 @@ fun ItemStack.setSkullOwner(uuid: UUID, url: String) {
profileName = "nea89",
)
)
- this.set(DataComponentTypes.PROFILE, ProfileComponent.ofStatic(gameProfile))
+ this.set(DataComponents.PROFILE, ResolvableProfile.createResolved(gameProfile))
}
diff --git a/src/main/kotlin/util/mc/SlotUtils.kt b/src/main/kotlin/util/mc/SlotUtils.kt
index 9eb4918..2f5fd49 100644
--- a/src/main/kotlin/util/mc/SlotUtils.kt
+++ b/src/main/kotlin/util/mc/SlotUtils.kt
@@ -1,46 +1,46 @@
package moe.nea.firmament.util.mc
import org.lwjgl.glfw.GLFW
-import net.minecraft.screen.ScreenHandler
-import net.minecraft.screen.slot.Slot
-import net.minecraft.screen.slot.SlotActionType
+import net.minecraft.world.inventory.AbstractContainerMenu
+import net.minecraft.world.inventory.Slot
+import net.minecraft.world.inventory.ClickType
import moe.nea.firmament.util.MC
object SlotUtils {
- fun Slot.clickMiddleMouseButton(handler: ScreenHandler) {
- MC.interactionManager?.clickSlot(
- handler.syncId,
- this.id,
+ fun Slot.clickMiddleMouseButton(handler: AbstractContainerMenu) {
+ MC.interactionManager?.handleInventoryMouseClick(
+ handler.containerId,
+ this.index,
GLFW.GLFW_MOUSE_BUTTON_MIDDLE,
- SlotActionType.CLONE,
+ ClickType.CLONE,
MC.player
)
}
- fun Slot.swapWithHotBar(handler: ScreenHandler, hotbarIndex: Int) {
- MC.interactionManager?.clickSlot(
- handler.syncId, this.id,
- hotbarIndex, SlotActionType.SWAP,
+ fun Slot.swapWithHotBar(handler: AbstractContainerMenu, hotbarIndex: Int) {
+ MC.interactionManager?.handleInventoryMouseClick(
+ handler.containerId, this.index,
+ hotbarIndex, ClickType.SWAP,
MC.player
)
}
- fun Slot.clickRightMouseButton(handler: ScreenHandler) {
- MC.interactionManager?.clickSlot(
- handler.syncId,
- this.id,
+ fun Slot.clickRightMouseButton(handler: AbstractContainerMenu) {
+ MC.interactionManager?.handleInventoryMouseClick(
+ handler.containerId,
+ this.index,
GLFW.GLFW_MOUSE_BUTTON_RIGHT,
- SlotActionType.PICKUP,
+ ClickType.PICKUP,
MC.player
)
}
- fun Slot.clickLeftMouseButton(handler: ScreenHandler) {
- MC.interactionManager?.clickSlot(
- handler.syncId,
- this.id,
+ fun Slot.clickLeftMouseButton(handler: AbstractContainerMenu) {
+ MC.interactionManager?.handleInventoryMouseClick(
+ handler.containerId,
+ this.index,
GLFW.GLFW_MOUSE_BUTTON_LEFT,
- SlotActionType.PICKUP,
+ ClickType.PICKUP,
MC.player
)
}
diff --git a/src/main/kotlin/util/mc/TolerantRegistriesOps.kt b/src/main/kotlin/util/mc/TolerantRegistriesOps.kt
index ce596a0..833aca9 100644
--- a/src/main/kotlin/util/mc/TolerantRegistriesOps.kt
+++ b/src/main/kotlin/util/mc/TolerantRegistriesOps.kt
@@ -2,27 +2,27 @@ package moe.nea.firmament.util.mc
import com.mojang.serialization.DynamicOps
import java.util.Optional
-import net.minecraft.registry.Registry
-import net.minecraft.registry.RegistryKey
-import net.minecraft.registry.RegistryOps
-import net.minecraft.registry.RegistryWrapper
-import net.minecraft.registry.entry.RegistryEntryOwner
+import net.minecraft.core.Registry
+import net.minecraft.resources.ResourceKey
+import net.minecraft.resources.RegistryOps
+import net.minecraft.core.HolderLookup
+import net.minecraft.core.HolderOwner
class TolerantRegistriesOps<T>(
delegate: DynamicOps<T>,
- registryInfoGetter: RegistryInfoGetter
+ registryInfoGetter: RegistryInfoLookup
) : RegistryOps<T>(delegate, registryInfoGetter) {
- constructor(delegate: DynamicOps<T>, registry: RegistryWrapper.WrapperLookup) :
- this(delegate, CachedRegistryInfoGetter(registry))
+ constructor(delegate: DynamicOps<T>, registry: HolderLookup.Provider) :
+ this(delegate, HolderLookupAdapter(registry))
- class TolerantOwner<E> : RegistryEntryOwner<E> {
- override fun ownerEquals(other: RegistryEntryOwner<E>?): Boolean {
+ class TolerantOwner<E> : HolderOwner<E> {
+ override fun canSerializeIn(other: HolderOwner<E>?): Boolean {
return true
}
}
- override fun <E : Any?> getOwner(registryRef: RegistryKey<out Registry<out E>>?): Optional<RegistryEntryOwner<E>> {
- return super.getOwner(registryRef).map {
+ override fun <E : Any?> owner(registryRef: ResourceKey<out Registry<out E>>?): Optional<HolderOwner<E>> {
+ return super.owner(registryRef).map {
TolerantOwner()
}
}
diff --git a/src/main/kotlin/util/mc/asFakeServer.kt b/src/main/kotlin/util/mc/asFakeServer.kt
index d3811bd..1075d62 100644
--- a/src/main/kotlin/util/mc/asFakeServer.kt
+++ b/src/main/kotlin/util/mc/asFakeServer.kt
@@ -1,27 +1,27 @@
package moe.nea.firmament.util.mc
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
-import net.minecraft.server.command.CommandOutput
-import net.minecraft.server.command.ServerCommandSource
-import net.minecraft.text.Text
+import net.minecraft.commands.CommandSource
+import net.minecraft.commands.CommandSourceStack
+import net.minecraft.network.chat.Component
-fun FabricClientCommandSource.asFakeServer(): ServerCommandSource {
+fun FabricClientCommandSource.asFakeServer(): CommandSourceStack {
val source = this
- return ServerCommandSource(
- object : CommandOutput {
- override fun sendMessage(message: Text?) {
- source.player.sendMessage(message, false)
+ return CommandSourceStack(
+ object : CommandSource {
+ override fun sendSystemMessage(message: Component?) {
+ source.player.displayClientMessage(message, false)
}
- override fun shouldReceiveFeedback(): Boolean {
+ override fun acceptsSuccess(): Boolean {
return true
}
- override fun shouldTrackOutput(): Boolean {
+ override fun acceptsFailure(): Boolean {
return true
}
- override fun shouldBroadcastConsoleToOps(): Boolean {
+ override fun shouldInformAdmins(): Boolean {
return true
}
},
@@ -30,7 +30,7 @@ fun FabricClientCommandSource.asFakeServer(): ServerCommandSource {
null,
0,
"FakeServerCommandSource",
- Text.literal("FakeServerCommandSource"),
+ Component.literal("FakeServerCommandSource"),
null,
source.player
)
diff --git a/src/main/kotlin/util/render/CustomRenderLayers.kt b/src/main/kotlin/util/render/CustomRenderLayers.kt
index d88a1e4..4a85c17 100644
--- a/src/main/kotlin/util/render/CustomRenderLayers.kt
+++ b/src/main/kotlin/util/render/CustomRenderLayers.kt
@@ -3,38 +3,38 @@ package util.render
import com.mojang.blaze3d.pipeline.BlendFunction
import com.mojang.blaze3d.pipeline.RenderPipeline
import com.mojang.blaze3d.platform.DepthTestFunction
-import com.mojang.blaze3d.vertex.VertexFormat.DrawMode
+import com.mojang.blaze3d.vertex.VertexFormat.Mode
import java.util.function.Function
-import net.minecraft.client.gl.RenderPipelines
-import net.minecraft.client.gl.UniformType
-import net.minecraft.client.render.RenderLayer
-import net.minecraft.client.render.RenderPhase
-import net.minecraft.client.render.VertexFormats
-import net.minecraft.util.Identifier
-import net.minecraft.util.Util
+import net.minecraft.client.renderer.RenderPipelines
+import com.mojang.blaze3d.shaders.UniformType
+import net.minecraft.client.renderer.RenderType
+import net.minecraft.client.renderer.RenderStateShard
+import com.mojang.blaze3d.vertex.DefaultVertexFormat
+import net.minecraft.resources.ResourceLocation
+import net.minecraft.Util
import moe.nea.firmament.Firmament
object CustomRenderPipelines {
val GUI_TEXTURED_NO_DEPTH_TRIS =
- RenderPipeline.builder(RenderPipelines.POSITION_TEX_COLOR_SNIPPET)
- .withVertexFormat(VertexFormats.POSITION_TEXTURE_COLOR, DrawMode.TRIANGLES)
+ RenderPipeline.builder(RenderPipelines.GUI_TEXTURED_SNIPPET)
+ .withVertexFormat(DefaultVertexFormat.POSITION_TEX_COLOR, Mode.TRIANGLES)
.withLocation(Firmament.identifier("gui_textured_overlay_tris"))
.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST)
.withCull(false)
.withDepthWrite(false)
.build()
val OMNIPRESENT_LINES = RenderPipeline
- .builder(RenderPipelines.RENDERTYPE_LINES_SNIPPET)
+ .builder(RenderPipelines.LINES_SNIPPET)
.withLocation(Firmament.identifier("lines"))
.withDepthWrite(false)
.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST)
.build()
val COLORED_OMNIPRESENT_QUADS =
- RenderPipeline.builder(RenderPipelines.TRANSFORMS_AND_PROJECTION_SNIPPET)// TODO: split this up to support better transparent ordering.
+ RenderPipeline.builder(RenderPipelines.MATRICES_PROJECTION_SNIPPET)// TODO: split this up to support better transparent ordering.
.withLocation(Firmament.identifier("colored_omnipresent_quads"))
.withVertexShader("core/position_color")
.withFragmentShader("core/position_color")
- .withVertexFormat(VertexFormats.POSITION_COLOR, DrawMode.QUADS)
+ .withVertexFormat(DefaultVertexFormat.POSITION_COLOR, Mode.QUADS)
.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST)
.withCull(false)
.withDepthWrite(false)
@@ -42,8 +42,8 @@ object CustomRenderPipelines {
.build()
val CIRCLE_FILTER_TRANSLUCENT_GUI_TRIS =
- RenderPipeline.builder(RenderPipelines.POSITION_TEX_COLOR_SNIPPET)
- .withVertexFormat(VertexFormats.POSITION_TEXTURE_COLOR, DrawMode.TRIANGLES)
+ RenderPipeline.builder(RenderPipelines.GUI_TEXTURED_SNIPPET)
+ .withVertexFormat(DefaultVertexFormat.POSITION_TEX_COLOR, Mode.TRIANGLES)
.withLocation(Firmament.identifier("gui_textured_overlay_tris_circle"))
.withUniform("CutoutRadius", UniformType.UNIFORM_BUFFER)
.withFragmentShader(Firmament.identifier("circle_discard_color"))
@@ -61,45 +61,45 @@ object CustomRenderPipelines {
}
object CustomRenderLayers {
- inline fun memoizeTextured(crossinline func: (Identifier) -> RenderLayer.MultiPhase) = memoize(func)
+ inline fun memoizeTextured(crossinline func: (ResourceLocation) -> RenderType.CompositeRenderType) = memoize(func)
inline fun <T, R> memoize(crossinline func: (T) -> R): Function<T, R> {
return Util.memoize { it: T -> func(it) }
}
val GUI_TEXTURED_NO_DEPTH_TRIS = memoizeTextured { texture ->
- RenderLayer.of(
+ RenderType.create(
"firmament_gui_textured_overlay_tris",
- RenderLayer.DEFAULT_BUFFER_SIZE,
+ RenderType.TRANSIENT_BUFFER_SIZE,
CustomRenderPipelines.GUI_TEXTURED_NO_DEPTH_TRIS,
- RenderLayer.MultiPhaseParameters.builder().texture(
- RenderPhase.Texture(texture, false)
+ RenderType.CompositeState.builder().setTextureState(
+ RenderStateShard.TextureStateShard(texture, false)
)
- .build(false)
+ .createCompositeState(false)
)
}
- val LINES = RenderLayer.of(
+ val LINES = RenderType.create(
"firmament_lines",
- RenderLayer.DEFAULT_BUFFER_SIZE,
+ RenderType.TRANSIENT_BUFFER_SIZE,
CustomRenderPipelines.OMNIPRESENT_LINES,
- RenderLayer.MultiPhaseParameters.builder() // TODO: accept linewidth here
- .build(false)
+ RenderType.CompositeState.builder() // TODO: accept linewidth here
+ .createCompositeState(false)
)
- val COLORED_QUADS = RenderLayer.of(
+ val COLORED_QUADS = RenderType.create(
"firmament_quads",
- RenderLayer.DEFAULT_BUFFER_SIZE,
+ RenderType.TRANSIENT_BUFFER_SIZE,
false, true,
CustomRenderPipelines.COLORED_OMNIPRESENT_QUADS,
- RenderLayer.MultiPhaseParameters.builder()
- .lightmap(RenderPhase.DISABLE_LIGHTMAP)
- .build(false)
+ RenderType.CompositeState.builder()
+ .setLightmapState(RenderStateShard.NO_LIGHTMAP)
+ .createCompositeState(false)
)
val TRANSLUCENT_CIRCLE_GUI =
- RenderLayer.of(
+ RenderType.create(
"firmament_circle_gui",
- RenderLayer.DEFAULT_BUFFER_SIZE,
+ RenderType.TRANSIENT_BUFFER_SIZE,
CustomRenderPipelines.CIRCLE_FILTER_TRANSLUCENT_GUI_TRIS,
- RenderLayer.MultiPhaseParameters.builder()
- .build(false)
+ RenderType.CompositeState.builder()
+ .createCompositeState(false)
)
}
diff --git a/src/main/kotlin/util/render/DrawContextExt.kt b/src/main/kotlin/util/render/DrawContextExt.kt
index e96fab9..9ef66f3 100644
--- a/src/main/kotlin/util/render/DrawContextExt.kt
+++ b/src/main/kotlin/util/render/DrawContextExt.kt
@@ -5,30 +5,30 @@ import me.shedaniel.math.Color
import org.joml.Vector3f
import util.render.CustomRenderLayers
import kotlin.math.abs
-import net.minecraft.client.gl.RenderPipelines
-import net.minecraft.client.gui.DrawContext
-import net.minecraft.client.gui.ScreenRect
-import net.minecraft.client.render.VertexConsumerProvider
-import net.minecraft.client.util.math.MatrixStack
-import net.minecraft.util.Identifier
+import net.minecraft.client.renderer.RenderPipelines
+import net.minecraft.client.gui.GuiGraphics
+import net.minecraft.client.gui.navigation.ScreenRectangle
+import net.minecraft.client.renderer.MultiBufferSource
+import com.mojang.blaze3d.vertex.PoseStack
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.util.MC
-fun DrawContext.isUntranslatedGuiDrawContext(): Boolean {
- return matrices.m00 == 1F && matrices.m11 == 1f && matrices.m01 == 0F && matrices.m10 == 0F && matrices.m20 == 0F && matrices.m21 == 0F
+fun GuiGraphics.isUntranslatedGuiDrawContext(): Boolean {
+ return pose().m00 == 1F && pose().m11 == 1f && pose().m01 == 0F && pose().m10 == 0F && pose().m20 == 0F && pose().m21 == 0F
}
@Deprecated("Use the other drawGuiTexture")
-fun DrawContext.drawGuiTexture(
- x: Int, y: Int, z: Int, width: Int, height: Int, sprite: Identifier
-) = this.drawGuiTexture(RenderPipelines.GUI_TEXTURED, sprite, x, y, width, height)
+fun GuiGraphics.drawGuiTexture(
+ x: Int, y: Int, z: Int, width: Int, height: Int, sprite: ResourceLocation
+) = this.blitSprite(RenderPipelines.GUI_TEXTURED, sprite, x, y, width, height)
-fun DrawContext.drawGuiTexture(
- sprite: Identifier,
+fun GuiGraphics.drawGuiTexture(
+ sprite: ResourceLocation,
x: Int, y: Int, width: Int, height: Int
-) = this.drawGuiTexture(RenderPipelines.GUI_TEXTURED, sprite, x, y, width, height)
+) = this.blitSprite(RenderPipelines.GUI_TEXTURED, sprite, x, y, width, height)
-fun DrawContext.drawTexture(
- sprite: Identifier,
+fun GuiGraphics.drawTexture(
+ sprite: ResourceLocation,
x: Int,
y: Int,
u: Float,
@@ -38,7 +38,7 @@ fun DrawContext.drawTexture(
textureWidth: Int,
textureHeight: Int
) {
- this.drawTexture(
+ this.blit(
RenderPipelines.GUI_TEXTURED,
sprite,
x,
@@ -60,7 +60,7 @@ data class LineRenderState(
override val y1: Int,
override val y2: Int,
override val scale: Float,
- override val bounds: ScreenRect,
+ override val bounds: ScreenRectangle,
val lineWidth: Float,
val w: Int,
val h: Int,
@@ -72,42 +72,42 @@ data class LineRenderState(
BOTTOM_LEFT_TO_TOP_RIGHT,
}
- override fun createRenderer(vertexConsumers: VertexConsumerProvider.Immediate): MultiSpecialGuiRenderer<out MultiSpecialGuiRenderState> {
+ override fun createRenderer(vertexConsumers: MultiBufferSource.BufferSource): MultiSpecialGuiRenderer<out MultiSpecialGuiRenderState> {
return LineRenderer(vertexConsumers)
}
override val scissorArea = null
}
-class LineRenderer(vertexConsumers: VertexConsumerProvider.Immediate) :
+class LineRenderer(vertexConsumers: MultiBufferSource.BufferSource) :
MultiSpecialGuiRenderer<LineRenderState>(vertexConsumers) {
- override fun getElementClass(): Class<LineRenderState> {
+ override fun getRenderStateClass(): Class<LineRenderState> {
return LineRenderState::class.java
}
- override fun getYOffset(height: Int, windowScaleFactor: Int): Float {
+ override fun getTranslateY(height: Int, windowScaleFactor: Int): Float {
return height / 2F
}
- override fun render(
+ override fun renderToTexture(
state: LineRenderState,
- matrices: MatrixStack
+ matrices: PoseStack
) {
val gr = MC.instance.gameRenderer
val client = MC.instance
- gr.globalSettings
- .set(
+ gr.globalSettingsUniform
+ .update(
state.bounds.width,
state.bounds.height,
- client.options.glintStrength.getValue(),
- client.world?.time ?: 0L,
- client.renderTickCounter,
- client.options.menuBackgroundBlurrinessValue
+ client.options.glintStrength().get(),
+ client.level?.gameTime ?: 0L,
+ client.deltaTracker,
+ client.options.menuBackgroundBlurriness
)
RenderSystem.lineWidth(state.lineWidth)
- val buf = vertexConsumers.getBuffer(CustomRenderLayers.LINES)
- val matrix = matrices.peek()
+ val buf = bufferSource.getBuffer(CustomRenderLayers.LINES)
+ val matrix = matrices.last()
val wh = state.w / 2F
val hh = state.h / 2F
val lowX = -wh
@@ -115,50 +115,50 @@ class LineRenderer(vertexConsumers: VertexConsumerProvider.Immediate) :
val highX = wh
val highY = -lowY
val norm = Vector3f(highX - lowX, highY - lowY, 0F).normalize()
- buf.vertex(matrix, lowX, lowY, 0F).color(state.color)
- .normal(matrix, norm)
- buf.vertex(matrix, highX, highY, 0F).color(state.color)
- .normal(matrix, norm)
- vertexConsumers.draw()
- gr.globalSettings
- .set(
- client.window.framebufferWidth,
- client.window.framebufferHeight,
- client.options.glintStrength.getValue(),
- client.world?.getTime() ?: 0L,
- client.renderTickCounter,
- client.options.menuBackgroundBlurrinessValue
+ buf.addVertex(matrix, lowX, lowY, 0F).setColor(state.color)
+ .setNormal(matrix, norm)
+ buf.addVertex(matrix, highX, highY, 0F).setColor(state.color)
+ .setNormal(matrix, norm)
+ bufferSource.endBatch()
+ gr.globalSettingsUniform
+ .update(
+ client.window.width,
+ client.window.height,
+ client.options.glintStrength().get(),
+ client.level?.gameTime ?: 0L,
+ client.deltaTracker,
+ client.options.menuBackgroundBlurriness
)
}
- override fun getName(): String? {
+ override fun getTextureLabel(): String? {
return "Firmament Line Renderer"
}
}
-fun DrawContext.drawLine(fromX: Int, fromY: Int, toX: Int, toY: Int, color: Color, lineWidth: Float = 1F) {
+fun GuiGraphics.drawLine(fromX: Int, fromY: Int, toX: Int, toY: Int, color: Color, lineWidth: Float = 1F) {
if (toY < fromY) {
drawLine(toX, toY, fromX, fromY, color)
return
}
- val originalRect = ScreenRect(
+ val originalRect = ScreenRectangle(
minOf(fromX, toX), minOf(toY, fromY),
abs(toX - fromX), abs(toY - fromY)
- ).transform(matrices)
+ ).transformAxisAligned(pose())
val expansionFactor = 3
- val rect = ScreenRect(
- originalRect.left - expansionFactor,
- originalRect.top - expansionFactor,
+ val rect = ScreenRectangle(
+ originalRect.left() - expansionFactor,
+ originalRect.top() - expansionFactor,
originalRect.width + expansionFactor * 2,
originalRect.height + expansionFactor * 2
)
// TODO: expand the bounds so that the thickness of the line can be used
// TODO: fix this up to work with scissorarea
- state.addSpecialElement(
+ guiRenderState.submitPicturesInPictureState(
LineRenderState(
- rect.left, rect.right, rect.top, rect.bottom, 1F, rect, lineWidth,
+ rect.left(), rect.right(), rect.top(), rect.bottom(), 1F, rect, lineWidth,
originalRect.width, originalRect.height, color.color,
if (fromX < toX) LineRenderState.LineDirection.TOP_LEFT_TO_BOTTOM_RIGHT else LineRenderState.LineDirection.BOTTOM_LEFT_TO_TOP_RIGHT
)
diff --git a/src/main/kotlin/util/render/DumpTexture.kt b/src/main/kotlin/util/render/DumpTexture.kt
index a7b4e78..2ac6a1c 100644
--- a/src/main/kotlin/util/render/DumpTexture.kt
+++ b/src/main/kotlin/util/render/DumpTexture.kt
@@ -4,7 +4,7 @@ import com.mojang.blaze3d.buffers.GpuBuffer
import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.textures.GpuTexture
import java.io.File
-import net.minecraft.client.texture.NativeImage
+import com.mojang.blaze3d.platform.NativeImage
fun dumpTexture(gpuTexture: GpuTexture, name: String) {
val w = gpuTexture.getWidth(0)
@@ -23,12 +23,12 @@ fun dumpTexture(gpuTexture: GpuTexture, name: String) {
for (i in 0..<w) {
for (j in 0..<h) {
val color = mappedView.data().getInt((j + i * w) * gpuTexture.format.pixelSize())
- nativeImage.setColor(j, h - i - 1, color)
+ nativeImage.setPixelABGR(j, h - i - 1, color)
}
}
}
buffer.close()
- nativeImage.writeTo(File("$name.png"))
+ nativeImage.writeToFile(File("$name.png"))
}, 0
)
}
diff --git a/src/main/kotlin/util/render/FacingThePlayerContext.kt b/src/main/kotlin/util/render/FacingThePlayerContext.kt
index e5cb78a..dc45939 100644
--- a/src/main/kotlin/util/render/FacingThePlayerContext.kt
+++ b/src/main/kotlin/util/render/FacingThePlayerContext.kt
@@ -3,13 +3,13 @@ package moe.nea.firmament.util.render
import org.joml.Matrix4f
import util.render.CustomRenderLayers
-import net.minecraft.client.font.TextRenderer
-import net.minecraft.client.render.LightmapTextureManager
-import net.minecraft.client.render.RenderLayer
-import net.minecraft.client.render.VertexConsumer
-import net.minecraft.text.Text
-import net.minecraft.util.Identifier
-import net.minecraft.util.math.BlockPos
+import net.minecraft.client.gui.Font
+import net.minecraft.client.renderer.LightTexture
+import net.minecraft.client.renderer.RenderType
+import com.mojang.blaze3d.vertex.VertexConsumer
+import net.minecraft.network.chat.Component
+import net.minecraft.resources.ResourceLocation
+import net.minecraft.core.BlockPos
import moe.nea.firmament.util.FirmFormatters
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.assertTrueOr
@@ -17,76 +17,76 @@ import moe.nea.firmament.util.assertTrueOr
@RenderContextDSL
class FacingThePlayerContext(val worldContext: RenderInWorldContext) {
val matrixStack by worldContext::matrixStack
- fun waypoint(position: BlockPos, label: Text) {
+ fun waypoint(position: BlockPos, label: Component) {
text(
label,
- Text.literal("§e${FirmFormatters.formatDistance(MC.player?.pos?.distanceTo(position.toCenterPos()) ?: 42069.0)}")
+ Component.literal("§e${FirmFormatters.formatDistance(MC.player?.position?.distanceTo(position.center) ?: 42069.0)}")
)
}
fun text(
- vararg texts: Text,
- verticalAlign: RenderInWorldContext.VerticalAlign = RenderInWorldContext.VerticalAlign.CENTER,
- background: Int = 0x70808080,
+ vararg texts: Component,
+ verticalAlign: RenderInWorldContext.VerticalAlign = RenderInWorldContext.VerticalAlign.CENTER,
+ background: Int = 0x70808080,
) {
assertTrueOr(texts.isNotEmpty()) { return@text }
for ((index, text) in texts.withIndex()) {
- worldContext.matrixStack.push()
- val width = MC.font.getWidth(text)
+ worldContext.matrixStack.pushPose()
+ val width = MC.font.width(text)
worldContext.matrixStack.translate(-width / 2F, verticalAlign.align(index, texts.size), 0F)
val vertexConsumer: VertexConsumer =
- worldContext.vertexConsumers.getBuffer(RenderLayer.getTextBackgroundSeeThrough())
- val matrix4f = worldContext.matrixStack.peek().positionMatrix
- vertexConsumer.vertex(matrix4f, -1.0f, -1.0f, 0.0f).color(background)
- .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE)
- vertexConsumer.vertex(matrix4f, -1.0f, MC.font.fontHeight.toFloat(), 0.0f).color(background)
- .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE)
- vertexConsumer.vertex(matrix4f, width.toFloat(), MC.font.fontHeight.toFloat(), 0.0f)
- .color(background)
- .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE)
- vertexConsumer.vertex(matrix4f, width.toFloat(), -1.0f, 0.0f).color(background)
- .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE)
+ worldContext.vertexConsumers.getBuffer(RenderType.textBackgroundSeeThrough())
+ val matrix4f = worldContext.matrixStack.last().pose()
+ vertexConsumer.addVertex(matrix4f, -1.0f, -1.0f, 0.0f).setColor(background)
+ .setLight(LightTexture.FULL_BLOCK)
+ vertexConsumer.addVertex(matrix4f, -1.0f, MC.font.lineHeight.toFloat(), 0.0f).setColor(background)
+ .setLight(LightTexture.FULL_BLOCK)
+ vertexConsumer.addVertex(matrix4f, width.toFloat(), MC.font.lineHeight.toFloat(), 0.0f)
+ .setColor(background)
+ .setLight(LightTexture.FULL_BLOCK)
+ vertexConsumer.addVertex(matrix4f, width.toFloat(), -1.0f, 0.0f).setColor(background)
+ .setLight(LightTexture.FULL_BLOCK)
worldContext.matrixStack.translate(0F, 0F, 0.01F)
- MC.font.draw(
+ MC.font.drawInBatch(
text,
0F,
0F,
-1,
false,
- worldContext.matrixStack.peek().positionMatrix,
+ worldContext.matrixStack.last().pose(),
worldContext.vertexConsumers,
- TextRenderer.TextLayerType.SEE_THROUGH,
+ Font.DisplayMode.SEE_THROUGH,
0,
- LightmapTextureManager.MAX_LIGHT_COORDINATE
+ LightTexture.FULL_BRIGHT
)
- worldContext.matrixStack.pop()
+ worldContext.matrixStack.popPose()
}
}
fun texture(
- texture: Identifier, width: Int, height: Int,
- u1: Float, v1: Float,
- u2: Float, v2: Float,
+ texture: ResourceLocation, width: Int, height: Int,
+ u1: Float, v1: Float,
+ u2: Float, v2: Float,
) {
val buf = worldContext.vertexConsumers.getBuffer(CustomRenderLayers.GUI_TEXTURED_NO_DEPTH_TRIS.apply(texture)) // TODO: this is strictly an incorrect render layer
val hw = width / 2F
val hh = height / 2F
- val matrix4f: Matrix4f = worldContext.matrixStack.peek().positionMatrix
- buf.vertex(matrix4f, -hw, -hh, 0F)
- .color(-1)
- .texture(u1, v1)
- buf.vertex(matrix4f, -hw, +hh, 0F)
- .color(-1)
- .texture(u1, v2)
- buf.vertex(matrix4f, +hw, +hh, 0F)
- .color(-1)
- .texture(u2, v2)
- buf.vertex(matrix4f, +hw, -hh, 0F)
- .color(-1)
- .texture(u2, v1)
- worldContext.vertexConsumers.draw()
+ val matrix4f: Matrix4f = worldContext.matrixStack.last().pose()
+ buf.addVertex(matrix4f, -hw, -hh, 0F)
+ .setColor(-1)
+ .setUv(u1, v1)
+ buf.addVertex(matrix4f, -hw, +hh, 0F)
+ .setColor(-1)
+ .setUv(u1, v2)
+ buf.addVertex(matrix4f, +hw, +hh, 0F)
+ .setColor(-1)
+ .setUv(u2, v2)
+ buf.addVertex(matrix4f, +hw, -hh, 0F)
+ .setColor(-1)
+ .setUv(u2, v1)
+ worldContext.vertexConsumers.endBatch()
}
}
diff --git a/src/main/kotlin/util/render/MultiSpecialGuiRenderState.kt b/src/main/kotlin/util/render/MultiSpecialGuiRenderState.kt
index d05e71e..a58ffdc 100644
--- a/src/main/kotlin/util/render/MultiSpecialGuiRenderState.kt
+++ b/src/main/kotlin/util/render/MultiSpecialGuiRenderState.kt
@@ -1,47 +1,47 @@
package moe.nea.firmament.util.render
-import net.minecraft.client.gui.ScreenRect
-import net.minecraft.client.gui.render.SpecialGuiElementRenderer
+import net.minecraft.client.gui.navigation.ScreenRectangle
+import net.minecraft.client.gui.render.pip.PictureInPictureRenderer
import net.minecraft.client.gui.render.state.GuiRenderState
-import net.minecraft.client.gui.render.state.special.SpecialGuiElementRenderState
-import net.minecraft.client.render.VertexConsumerProvider
+import net.minecraft.client.gui.render.state.pip.PictureInPictureRenderState
+import net.minecraft.client.renderer.MultiBufferSource
-abstract class MultiSpecialGuiRenderState : SpecialGuiElementRenderState {
+abstract class MultiSpecialGuiRenderState : PictureInPictureRenderState {
// I wish i had manifolds @Self type here... Maybe i should switch to java after all :(
- abstract fun createRenderer(vertexConsumers: VertexConsumerProvider.Immediate): MultiSpecialGuiRenderer<out MultiSpecialGuiRenderState>
+ abstract fun createRenderer(vertexConsumers: MultiBufferSource.BufferSource): MultiSpecialGuiRenderer<out MultiSpecialGuiRenderState>
abstract val x1: Int
abstract val x2: Int
abstract val y1: Int
abstract val y2: Int
abstract val scale: Float
- abstract val bounds: ScreenRect?
- abstract val scissorArea: ScreenRect?
- override fun x1(): Int = x1
+ abstract val bounds: ScreenRectangle?
+ abstract val scissorArea: ScreenRectangle?
+ override fun x0(): Int = x1
- override fun x2(): Int = x2
+ override fun x1(): Int = x2
- override fun y1(): Int = y1
+ override fun y0(): Int = y1
- override fun y2(): Int = y2
+ override fun y1(): Int = y2
override fun scale(): Float = scale
- override fun scissorArea(): ScreenRect? = scissorArea
+ override fun scissorArea(): ScreenRectangle? = scissorArea
- override fun bounds(): ScreenRect? = bounds
+ override fun bounds(): ScreenRectangle? = bounds
}
abstract class MultiSpecialGuiRenderer<T : MultiSpecialGuiRenderState>(
- vertexConsumers: VertexConsumerProvider.Immediate
-) : SpecialGuiElementRenderer<T>(vertexConsumers) {
+ vertexConsumers: MultiBufferSource.BufferSource
+) : PictureInPictureRenderer<T>(vertexConsumers) {
var wasUsedThisFrame = false
fun consumeRender(): Boolean {
return wasUsedThisFrame.also { wasUsedThisFrame = false }
}
- override fun renderElement(element: T, state: GuiRenderState) {
+ override fun blitTexture(element: T, state: GuiRenderState) {
wasUsedThisFrame = true
- super.renderElement(element, state)
+ super.blitTexture(element, state)
}
}
diff --git a/src/main/kotlin/util/render/RenderCircleProgress.kt b/src/main/kotlin/util/render/RenderCircleProgress.kt
index c9b8e16..acd0210 100644
--- a/src/main/kotlin/util/render/RenderCircleProgress.kt
+++ b/src/main/kotlin/util/render/RenderCircleProgress.kt
@@ -2,14 +2,14 @@ package moe.nea.firmament.util.render
import com.mojang.blaze3d.vertex.VertexFormat
import util.render.CustomRenderLayers
-import net.minecraft.client.gui.DrawContext
-import net.minecraft.client.gui.ScreenRect
-import net.minecraft.client.render.BufferBuilder
-import net.minecraft.client.render.RenderLayer
-import net.minecraft.client.render.VertexConsumerProvider
-import net.minecraft.client.util.BufferAllocator
-import net.minecraft.client.util.math.MatrixStack
-import net.minecraft.util.Identifier
+import net.minecraft.client.gui.GuiGraphics
+import net.minecraft.client.gui.navigation.ScreenRectangle
+import com.mojang.blaze3d.vertex.BufferBuilder
+import net.minecraft.client.renderer.RenderType
+import net.minecraft.client.renderer.MultiBufferSource
+import com.mojang.blaze3d.vertex.ByteBufferBuilder
+import com.mojang.blaze3d.vertex.PoseStack
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.collections.nonNegligibleSubSectionsAlignedWith
import moe.nea.firmament.util.math.Projections
@@ -23,7 +23,7 @@ object RenderCircleProgress {
override val x2: Int,
override val y1: Int,
override val y2: Int,
- val layer: RenderLayer.MultiPhase,
+ val layer: RenderType.CompositeRenderType,
val u1: Float,
val u2: Float,
val v1: Float,
@@ -32,21 +32,21 @@ object RenderCircleProgress {
val color: Int,
val innerCutoutRadius: Float,
override val scale: Float,
- override val bounds: ScreenRect?,
- override val scissorArea: ScreenRect?,
+ override val bounds: ScreenRectangle?,
+ override val scissorArea: ScreenRectangle?,
) : MultiSpecialGuiRenderState() {
- override fun createRenderer(vertexConsumers: VertexConsumerProvider.Immediate): MultiSpecialGuiRenderer<out MultiSpecialGuiRenderState> {
+ override fun createRenderer(vertexConsumers: MultiBufferSource.BufferSource): MultiSpecialGuiRenderer<out MultiSpecialGuiRenderState> {
return Renderer(vertexConsumers)
}
}
- class Renderer(vertexConsumers: VertexConsumerProvider.Immediate) :
+ class Renderer(vertexConsumers: MultiBufferSource.BufferSource) :
MultiSpecialGuiRenderer<State>(vertexConsumers) {
- override fun render(
+ override fun renderToTexture(
state: State,
- matrices: MatrixStack
+ matrices: PoseStack
) {
- matrices.push()
+ matrices.pushPose()
matrices.translate(0F, -1F, 0F)
val sections = state.angleRadians.nonNegligibleSubSectionsAlignedWith((τ / 8f).toFloat())
.zipWithNext().toList()
@@ -55,10 +55,10 @@ object RenderCircleProgress {
val v1 = state.v1
val v2 = state.v2
val color = state.color
- val matrix = matrices.peek().positionMatrix
- BufferAllocator(state.layer.vertexFormat.vertexSize * sections.size * 3).use { allocator ->
+ val matrix = matrices.last().pose()
+ ByteBufferBuilder(state.layer.format().vertexSize * sections.size * 3).use { allocator ->
- val bufferBuilder = BufferBuilder(allocator, VertexFormat.DrawMode.TRIANGLES, state.layer.vertexFormat)
+ val bufferBuilder = BufferBuilder(allocator, VertexFormat.Mode.TRIANGLES, state.layer.format())
for ((sectionStart, sectionEnd) in sections) {
val firstPoint = Projections.Two.projectAngleOntoUnitBox(sectionStart.toDouble())
@@ -67,37 +67,37 @@ object RenderCircleProgress {
ilerp(-1f, 1f, f)
bufferBuilder
- .vertex(matrix, secondPoint.x, secondPoint.y, 0F)
- .texture(lerp(u1, u2, ilerp(secondPoint.x)), lerp(v1, v2, ilerp(secondPoint.y)))
- .color(color)
+ .addVertex(matrix, secondPoint.x, secondPoint.y, 0F)
+ .setUv(lerp(u1, u2, ilerp(secondPoint.x)), lerp(v1, v2, ilerp(secondPoint.y)))
+ .setColor(color)
bufferBuilder
- .vertex(matrix, firstPoint.x, firstPoint.y, 0F)
- .texture(lerp(u1, u2, ilerp(firstPoint.x)), lerp(v1, v2, ilerp(firstPoint.y)))
- .color(color)
+ .addVertex(matrix, firstPoint.x, firstPoint.y, 0F)
+ .setUv(lerp(u1, u2, ilerp(firstPoint.x)), lerp(v1, v2, ilerp(firstPoint.y)))
+ .setColor(color)
bufferBuilder
- .vertex(matrix, 0F, 0F, 0F)
- .texture(lerp(u1, u2, ilerp(0F)), lerp(v1, v2, ilerp(0F)))
- .color(color)
+ .addVertex(matrix, 0F, 0F, 0F)
+ .setUv(lerp(u1, u2, ilerp(0F)), lerp(v1, v2, ilerp(0F)))
+ .setColor(color)
}
- bufferBuilder.end().use { buffer ->
+ bufferBuilder.buildOrThrow().use { buffer ->
if (state.innerCutoutRadius <= 0) {
state.layer.draw(buffer)
return
}
CustomRenderPassHelper(
{ "RenderCircleProgress" },
- VertexFormat.DrawMode.TRIANGLES,
- state.layer.vertexFormat,
- MC.instance.framebuffer,
+ VertexFormat.Mode.TRIANGLES,
+ state.layer.format(),
+ MC.instance.mainRenderTarget,
false,
).use { renderPass ->
renderPass.uploadVertices(buffer)
renderPass.setAllDefaultUniforms()
- renderPass.setPipeline(state.layer.pipeline)
+ renderPass.setPipeline(state.layer.renderPipeline)
renderPass.setUniform("CutoutRadius", 4) {
it.putFloat(state.innerCutoutRadius)
}
@@ -105,21 +105,21 @@ object RenderCircleProgress {
}
}
}
- matrices.pop()
+ matrices.popPose()
}
- override fun getElementClass(): Class<State> {
+ override fun getRenderStateClass(): Class<State> {
return State::class.java
}
- override fun getName(): String {
+ override fun getTextureLabel(): String {
return "Firmament Circle"
}
}
fun renderCircularSlice(
- drawContext: DrawContext,
- layer: RenderLayer.MultiPhase,
+ drawContext: GuiGraphics,
+ layer: RenderType.CompositeRenderType,
u1: Float,
u2: Float,
v1: Float,
@@ -128,11 +128,11 @@ object RenderCircleProgress {
color: Int = -1,
innerCutoutRadius: Float = 0F
) {
- val screenRect = ScreenRect(-1, -1, 2, 2).transform(drawContext.matrices)
- drawContext.state.addSpecialElement(
+ val screenRect = ScreenRectangle(-1, -1, 2, 2).transformAxisAligned(drawContext.pose())
+ drawContext.guiRenderState.submitPicturesInPictureState(
State(
- screenRect.left, screenRect.right,
- screenRect.top, screenRect.bottom,
+ screenRect.left(), screenRect.right(),
+ screenRect.top(), screenRect.bottom(),
layer,
u1, u2, v1, v2,
angleRadians,
@@ -146,8 +146,8 @@ object RenderCircleProgress {
}
fun renderCircle(
- drawContext: DrawContext,
- texture: Identifier,
+ drawContext: GuiGraphics,
+ texture: ResourceLocation,
progress: Float,
u1: Float,
u2: Float,
diff --git a/src/main/kotlin/util/render/RenderInWorldContext.kt b/src/main/kotlin/util/render/RenderInWorldContext.kt
index 116ae5d..f6877c8 100644
--- a/src/main/kotlin/util/render/RenderInWorldContext.kt
+++ b/src/main/kotlin/util/render/RenderInWorldContext.kt
@@ -5,53 +5,53 @@ import org.joml.Matrix4f
import org.joml.Vector3f
import util.render.CustomRenderLayers
import kotlin.math.pow
-import net.minecraft.client.render.Camera
-import net.minecraft.client.render.RenderLayer
-import net.minecraft.client.render.RenderLayers
-import net.minecraft.client.render.RenderTickCounter
-import net.minecraft.client.render.TexturedRenderLayers
-import net.minecraft.client.render.VertexConsumer
-import net.minecraft.client.render.VertexConsumerProvider
-import net.minecraft.client.render.state.CameraRenderState
-import net.minecraft.client.texture.Sprite
-import net.minecraft.client.util.math.MatrixStack
-import net.minecraft.text.Text
-import net.minecraft.util.Identifier
-import net.minecraft.util.math.BlockPos
-import net.minecraft.util.math.Box
-import net.minecraft.util.math.Vec3d
+import net.minecraft.client.Camera
+import net.minecraft.client.renderer.RenderType
+import net.minecraft.client.renderer.ItemBlockRenderTypes
+import net.minecraft.client.DeltaTracker
+import net.minecraft.client.renderer.Sheets
+import com.mojang.blaze3d.vertex.VertexConsumer
+import net.minecraft.client.renderer.MultiBufferSource
+import net.minecraft.client.renderer.state.CameraRenderState
+import net.minecraft.client.renderer.texture.TextureAtlasSprite
+import com.mojang.blaze3d.vertex.PoseStack
+import net.minecraft.network.chat.Component
+import net.minecraft.resources.ResourceLocation
+import net.minecraft.core.BlockPos
+import net.minecraft.world.phys.AABB
+import net.minecraft.world.phys.Vec3
import moe.nea.firmament.events.WorldRenderLastEvent
import moe.nea.firmament.util.FirmFormatters
import moe.nea.firmament.util.MC
@RenderContextDSL
class RenderInWorldContext private constructor(
- val matrixStack: MatrixStack,
+ val matrixStack: PoseStack,
private val camera: CameraRenderState,
- val vertexConsumers: VertexConsumerProvider.Immediate,
+ val vertexConsumers: MultiBufferSource.BufferSource,
) {
fun block(blockPos: BlockPos, color: Int) {
- matrixStack.push()
+ matrixStack.pushPose()
matrixStack.translate(blockPos.x.toFloat(), blockPos.y.toFloat(), blockPos.z.toFloat())
- buildCube(matrixStack.peek().positionMatrix, vertexConsumers.getBuffer(CustomRenderLayers.COLORED_QUADS), color)
- matrixStack.pop()
+ buildCube(matrixStack.last().pose(), vertexConsumers.getBuffer(CustomRenderLayers.COLORED_QUADS), color)
+ matrixStack.popPose()
}
- fun box(aabb: Box, color: Int) {
- matrixStack.push()
+ fun box(aabb: AABB, color: Int) {
+ matrixStack.pushPose()
matrixStack.translate(aabb.minX, aabb.minY, aabb.minZ)
- matrixStack.scale(aabb.lengthX.toFloat(), aabb.lengthY.toFloat(), aabb.lengthZ.toFloat())
- buildCube(matrixStack.peek().positionMatrix, vertexConsumers.getBuffer(CustomRenderLayers.COLORED_QUADS), color)
- matrixStack.pop()
+ matrixStack.scale(aabb.xsize.toFloat(), aabb.ysize.toFloat(), aabb.zsize.toFloat())
+ buildCube(matrixStack.last().pose(), vertexConsumers.getBuffer(CustomRenderLayers.COLORED_QUADS), color)
+ matrixStack.popPose()
}
fun sharedVoxelSurface(blocks: Set<BlockPos>, color: Int) {
- val m = BlockPos.Mutable()
+ val m = BlockPos.MutableBlockPos()
val l = vertexConsumers.getBuffer(CustomRenderLayers.COLORED_QUADS)
blocks.forEach {
- matrixStack.push()
+ matrixStack.pushPose()
matrixStack.translate(it.x.toFloat(), it.y.toFloat(), it.z.toFloat())
- val p = matrixStack.peek().positionMatrix
+ val p = matrixStack.last().pose()
m.set(it)
if (m.setX(it.x + 1) !in blocks) {
buildFaceXP(p, l, color)
@@ -73,7 +73,7 @@ class RenderInWorldContext private constructor(
if (m.setZ(it.z - 1) !in blocks) {
buildFaceZN(p, l, color)
}
- matrixStack.pop()
+ matrixStack.popPose()
}
}
@@ -82,46 +82,46 @@ class RenderInWorldContext private constructor(
fun align(index: Int, count: Int): Float {
return when (this) {
- CENTER -> (index - count / 2F) * (1 + MC.font.fontHeight.toFloat())
- BOTTOM -> (index - count) * (1 + MC.font.fontHeight.toFloat())
- TOP -> (index) * (1 + MC.font.fontHeight.toFloat())
+ CENTER -> (index - count / 2F) * (1 + MC.font.lineHeight.toFloat())
+ BOTTOM -> (index - count) * (1 + MC.font.lineHeight.toFloat())
+ TOP -> (index) * (1 + MC.font.lineHeight.toFloat())
}
}
}
- fun waypoint(position: BlockPos, vararg label: Text) {
+ fun waypoint(position: BlockPos, vararg label: Component) {
text(
- position.toCenterPos(),
+ position.center,
*label,
- Text.literal("§e${FirmFormatters.formatDistance(MC.player?.pos?.distanceTo(position.toCenterPos()) ?: 42069.0)}"),
+ Component.literal("§e${FirmFormatters.formatDistance(MC.player?.position?.distanceTo(position.center) ?: 42069.0)}"),
background = 0xAA202020.toInt()
)
}
- fun withFacingThePlayer(position: Vec3d, block: FacingThePlayerContext.() -> Unit) {
- matrixStack.push()
+ fun withFacingThePlayer(position: Vec3, block: FacingThePlayerContext.() -> Unit) {
+ matrixStack.pushPose()
matrixStack.translate(position.x, position.y, position.z)
val actualCameraDistance = position.distanceTo(camera.pos)
val distanceToMoveTowardsCamera = if (actualCameraDistance < 10) 0.0 else -(actualCameraDistance - 10.0)
- val vec = position.subtract(camera.pos).multiply(distanceToMoveTowardsCamera / actualCameraDistance)
+ val vec = position.subtract(camera.pos).scale(distanceToMoveTowardsCamera / actualCameraDistance)
matrixStack.translate(vec.x, vec.y, vec.z)
- matrixStack.multiply(camera.orientation)
+ matrixStack.mulPose(camera.orientation)
matrixStack.scale(0.025F, -0.025F, 1F)
FacingThePlayerContext(this).run(block)
- matrixStack.pop()
- vertexConsumers.drawCurrentLayer()
+ matrixStack.popPose()
+ vertexConsumers.endLastBatch()
}
- fun sprite(position: Vec3d, sprite: Sprite, width: Int, height: Int) {
+ fun sprite(position: Vec3, sprite: TextureAtlasSprite, width: Int, height: Int) {
texture(
- position, sprite.atlasId, width, height, sprite.minU, sprite.minV, sprite.maxU, sprite.maxV
+ position, sprite.atlasLocation(), width, height, sprite.u0, sprite.v0, sprite.u1, sprite.v1
)
}
fun texture(
- position: Vec3d, texture: Identifier, width: Int, height: Int,
+ position: Vec3, texture: ResourceLocation, width: Int, height: Int,
u1: Float, v1: Float,
u2: Float, v2: Float,
) {
@@ -131,8 +131,8 @@ class RenderInWorldContext private constructor(
}
fun text(
- position: Vec3d,
- vararg texts: Text,
+ position: Vec3,
+ vararg texts: Component,
verticalAlign: VerticalAlign = VerticalAlign.CENTER,
background: Int = 0x70808080
) {
@@ -141,22 +141,22 @@ class RenderInWorldContext private constructor(
}
}
- fun tinyBlock(vec3d: Vec3d, size: Float, color: Int) {
- matrixStack.push()
+ fun tinyBlock(vec3d: Vec3, size: Float, color: Int) {
+ matrixStack.pushPose()
matrixStack.translate(vec3d.x, vec3d.y, vec3d.z)
matrixStack.scale(size, size, size)
matrixStack.translate(-.5, -.5, -.5)
- buildCube(matrixStack.peek().positionMatrix, vertexConsumers.getBuffer(CustomRenderLayers.COLORED_QUADS), color)
- matrixStack.pop()
- vertexConsumers.draw()
+ buildCube(matrixStack.last().pose(), vertexConsumers.getBuffer(CustomRenderLayers.COLORED_QUADS), color)
+ matrixStack.popPose()
+ vertexConsumers.endBatch()
}
fun wireframeCube(blockPos: BlockPos, lineWidth: Float = 10F) {
- val buf = vertexConsumers.getBuffer(RenderLayer.LINES)
- matrixStack.push()
+ val buf = vertexConsumers.getBuffer(RenderType.LINES)
+ matrixStack.pushPose()
// TODO: add color arg to this
// TODO: this does not render through blocks (or water layers) anymore
- RenderSystem.lineWidth(lineWidth / camera.pos.squaredDistanceTo(blockPos.toCenterPos()).pow(0.25).toFloat())
+ RenderSystem.lineWidth(lineWidth / camera.pos.distanceToSqr(blockPos.center).pow(0.25).toFloat())
val offset = 1 / 512F
matrixStack.translate(
blockPos.x.toFloat() - offset,
@@ -166,25 +166,25 @@ class RenderInWorldContext private constructor(
val scale = 1 + 2 * offset
matrixStack.scale(scale, scale, scale)
- buildWireFrameCube(matrixStack.peek(), buf)
- matrixStack.pop()
- vertexConsumers.draw()
+ buildWireFrameCube(matrixStack.last(), buf)
+ matrixStack.popPose()
+ vertexConsumers.endBatch()
}
- fun line(vararg points: Vec3d, color: Int, lineWidth: Float = 10F) {
+ fun line(vararg points: Vec3, color: Int, lineWidth: Float = 10F) {
line(points.toList(), color, lineWidth)
}
- fun tracer(toWhere: Vec3d, color: Int, lineWidth: Float = 3f) {
+ fun tracer(toWhere: Vec3, color: Int, lineWidth: Float = 3f) {
val cameraForward = Vector3f(0f, 0f, -1f).rotate(camera.orientation)
- line(camera.pos.add(Vec3d(cameraForward)), toWhere, color = color, lineWidth = lineWidth)
+ line(camera.pos.add(Vec3(cameraForward)), toWhere, color = color, lineWidth = lineWidth)
}
- fun line(points: List<Vec3d>, color: Int, lineWidth: Float = 10F) {
+ fun line(points: List<Vec3>, color: Int, lineWidth: Float = 10F) {
RenderSystem.lineWidth(lineWidth)
val buffer = vertexConsumers.getBuffer(CustomRenderLayers.LINES)
- val matrix = matrixStack.peek()
+ val matrix = matrixStack.last()
var lastNormal: Vector3f? = null
points.zipWithNext().forEach { (a, b) ->
val normal = Vector3f(b.x.toFloat(), b.y.toFloat(), b.z.toFloat())
@@ -192,13 +192,13 @@ class RenderInWorldContext private constructor(
.normalize()
val lastNormal0 = lastNormal ?: normal
lastNormal = normal
- buffer.vertex(matrix.positionMatrix, a.x.toFloat(), a.y.toFloat(), a.z.toFloat())
- .color(color)
- .normal(matrix, lastNormal0.x, lastNormal0.y, lastNormal0.z)
+ buffer.addVertex(matrix.pose(), a.x.toFloat(), a.y.toFloat(), a.z.toFloat())
+ .setColor(color)
+ .setNormal(matrix, lastNormal0.x, lastNormal0.y, lastNormal0.z)
- buffer.vertex(matrix.positionMatrix, b.x.toFloat(), b.y.toFloat(), b.z.toFloat())
- .color(color)
- .normal(matrix, normal.x, normal.y, normal.z)
+ buffer.addVertex(matrix.pose(), b.x.toFloat(), b.y.toFloat(), b.z.toFloat())
+ .setColor(color)
+ .setNormal(matrix, normal.x, normal.y, normal.z)
}
@@ -207,7 +207,7 @@ class RenderInWorldContext private constructor(
companion object {
private fun doLine(
- matrix: MatrixStack.Entry,
+ matrix: PoseStack.Pose,
buf: VertexConsumer,
i: Float,
j: Float,
@@ -219,18 +219,18 @@ class RenderInWorldContext private constructor(
val normal = Vector3f(x, y, z)
.sub(i, j, k)
.normalize()
- buf.vertex(matrix.positionMatrix, i, j, k)
- .normal(matrix, normal.x, normal.y, normal.z)
- .color(-1)
+ buf.addVertex(matrix.pose(), i, j, k)
+ .setNormal(matrix, normal.x, normal.y, normal.z)
+ .setColor(-1)
- buf.vertex(matrix.positionMatrix, x, y, z)
- .normal(matrix, normal.x, normal.y, normal.z)
- .color(-1)
+ buf.addVertex(matrix.pose(), x, y, z)
+ .setNormal(matrix, normal.x, normal.y, normal.z)
+ .setColor(-1)
}
- private fun buildWireFrameCube(matrix: MatrixStack.Entry, buf: VertexConsumer) {
+ private fun buildWireFrameCube(matrix: PoseStack.Pose, buf: VertexConsumer) {
for (i in 0..1) {
for (j in 0..1) {
val i = i.toFloat()
@@ -243,45 +243,45 @@ class RenderInWorldContext private constructor(
}
private fun buildFaceZP(matrix: Matrix4f, buf: VertexConsumer, rgba: Int) {
- buf.vertex(matrix, 0F, 0F, 1F).color(rgba)
- buf.vertex(matrix, 0F, 1F, 1F).color(rgba)
- buf.vertex(matrix, 1F, 1F, 1F).color(rgba)
- buf.vertex(matrix, 1F, 0F, 1F).color(rgba)
+ buf.addVertex(matrix, 0F, 0F, 1F).setColor(rgba)
+ buf.addVertex(matrix, 0F, 1F, 1F).setColor(rgba)
+ buf.addVertex(matrix, 1F, 1F, 1F).setColor(rgba)
+ buf.addVertex(matrix, 1F, 0F, 1F).setColor(rgba)
}
private fun buildFaceZN(matrix: Matrix4f, buf: VertexConsumer, rgba: Int) {
- buf.vertex(matrix, 0F, 0F, 0F).color(rgba)
- buf.vertex(matrix, 1F, 0F, 0F).color(rgba)
- buf.vertex(matrix, 1F, 1F, 0F).color(rgba)
- buf.vertex(matrix, 0F, 1F, 0F).color(rgba)
+ buf.addVertex(matrix, 0F, 0F, 0F).setColor(rgba)
+ buf.addVertex(matrix, 1F, 0F, 0F).setColor(rgba)
+ buf.addVertex(matrix, 1F, 1F, 0F).setColor(rgba)
+ buf.addVertex(matrix, 0F, 1F, 0F).setColor(rgba)
}
private fun buildFaceXP(matrix: Matrix4f, buf: VertexConsumer, rgba: Int) {
- buf.vertex(matrix, 1F, 0F, 0F).color(rgba)
- buf.vertex(matrix, 1F, 1F, 0F).color(rgba)
- buf.vertex(matrix, 1F, 1F, 1F).color(rgba)
- buf.vertex(matrix, 1F, 0F, 1F).color(rgba)
+ buf.addVertex(matrix, 1F, 0F, 0F).setColor(rgba)
+ buf.addVertex(matrix, 1F, 1F, 0F).setColor(rgba)
+ buf.addVertex(matrix, 1F, 1F, 1F).setColor(rgba)
+ buf.addVertex(matrix, 1F, 0F, 1F).setColor(rgba)
}
private fun buildFaceXN(matrix: Matrix4f, buf: VertexConsumer, rgba: Int) {
- buf.vertex(matrix, 0F, 0F, 0F).color(rgba)
- buf.vertex(matrix, 0F, 0F, 1F).color(rgba)
- buf.vertex(matrix, 0F, 1F, 1F).color(rgba)
- buf.vertex(matrix, 0F, 1F, 0F).color(rgba)
+ buf.addVertex(matrix, 0F, 0F, 0F).setColor(rgba)
+ buf.addVertex(matrix, 0F, 0F, 1F).setColor(rgba)
+ buf.addVertex(matrix, 0F, 1F, 1F).setColor(rgba)
+ buf.addVertex(matrix, 0F, 1F, 0F).setColor(rgba)
}
private fun buildFaceYN(matrix: Matrix4f, buf: VertexConsumer, rgba: Int) {
- buf.vertex(matrix, 0F, 0F, 0F).color(rgba)
- buf.vertex(matrix, 0F, 0F, 1F).color(rgba)
- buf.vertex(matrix, 1F, 0F, 1F).color(rgba)
- buf.vertex(matrix, 1F, 0F, 0F).color(rgba)
+ buf.addVertex(matrix, 0F, 0F, 0F).setColor(rgba)
+ buf.addVertex(matrix, 0F, 0F, 1F).setColor(rgba)
+ buf.addVertex(matrix, 1F, 0F, 1F).setColor(rgba)
+ buf.addVertex(matrix, 1F, 0F, 0F).setColor(rgba)
}
private fun buildFaceYP(matrix: Matrix4f, buf: VertexConsumer, rgba: Int) {
- buf.vertex(matrix, 0F, 1F, 0F).color(rgba)
- buf.vertex(matrix, 1F, 1F, 0F).color(rgba)
- buf.vertex(matrix, 1F, 1F, 1F).color(rgba)
- buf.vertex(matrix, 0F, 1F, 1F).color(rgba)
+ buf.addVertex(matrix, 0F, 1F, 0F).setColor(rgba)
+ buf.addVertex(matrix, 1F, 1F, 0F).setColor(rgba)
+ buf.addVertex(matrix, 1F, 1F, 1F).setColor(rgba)
+ buf.addVertex(matrix, 0F, 1F, 1F).setColor(rgba)
}
private fun buildCube(matrix4f: Matrix4f, buf: VertexConsumer, rgba: Int) {
@@ -295,7 +295,7 @@ class RenderInWorldContext private constructor(
fun renderInWorld(event: WorldRenderLastEvent, block: RenderInWorldContext. () -> Unit) {
- event.matrices.push()
+ event.matrices.pushPose()
event.matrices.translate(-event.camera.pos.x, -event.camera.pos.y, -event.camera.pos.z)
val ctx = RenderInWorldContext(
@@ -306,8 +306,8 @@ class RenderInWorldContext private constructor(
block(ctx)
- event.matrices.pop()
- event.vertexConsumers.draw()
+ event.matrices.popPose()
+ event.vertexConsumers.endBatch()
}
}
}
diff --git a/src/main/kotlin/util/render/TintedOverlayTexture.kt b/src/main/kotlin/util/render/TintedOverlayTexture.kt
index 0677846..6513574 100644
--- a/src/main/kotlin/util/render/TintedOverlayTexture.kt
+++ b/src/main/kotlin/util/render/TintedOverlayTexture.kt
@@ -1,8 +1,8 @@
package moe.nea.firmament.util.render
import me.shedaniel.math.Color
-import net.minecraft.client.render.OverlayTexture
-import net.minecraft.util.math.ColorHelper
+import net.minecraft.client.renderer.texture.OverlayTexture
+import net.minecraft.util.ARGB
import moe.nea.firmament.util.ErrorUtil
class TintedOverlayTexture : OverlayTexture() {
@@ -12,17 +12,17 @@ class TintedOverlayTexture : OverlayTexture() {
private var lastColor: Color? = null
fun setColor(color: Color): TintedOverlayTexture {
- val image = ErrorUtil.notNullOr(texture.image, "Disposed TintedOverlayTexture written to") { return this }
+ val image = ErrorUtil.notNullOr(texture.pixels, "Disposed TintedOverlayTexture written to") { return this }
if (color == lastColor) return this
lastColor = color
for (i in 0..<size) {
for (j in 0..<size) {
if (i < 8) {
- image.setColorArgb(j, i, 0xB2FF0000.toInt())
+ image.setPixel(j, i, 0xB2FF0000.toInt())
} else {
val k = ((1F - j / 15F * 0.75F) * 255F).toInt()
- image.setColorArgb(j, i, ColorHelper.withAlpha(k, color.color))
+ image.setPixel(j, i, ARGB.color(k, color.color))
}
}
}
diff --git a/src/main/kotlin/util/render/TranslatedScissors.kt b/src/main/kotlin/util/render/TranslatedScissors.kt
index ee90a2d..5c7e31d 100644
--- a/src/main/kotlin/util/render/TranslatedScissors.kt
+++ b/src/main/kotlin/util/render/TranslatedScissors.kt
@@ -2,14 +2,14 @@ package moe.nea.firmament.util.render
import org.joml.Matrix3x2f
import org.joml.Vector3f
-import net.minecraft.client.gui.DrawContext
+import net.minecraft.client.gui.GuiGraphics
-fun DrawContext.enableScissorWithTranslation(x1: Float, y1: Float, x2: Float, y2: Float) {
+fun GuiGraphics.enableScissorWithTranslation(x1: Float, y1: Float, x2: Float, y2: Float) {
enableScissor(x1.toInt(), y1.toInt(), x2.toInt(), y2.toInt())
}
-fun DrawContext.enableScissorWithoutTranslation(x1: Float, y1: Float, x2: Float, y2: Float) {
- val pMat = Matrix3x2f(matrices).invert()
+fun GuiGraphics.enableScissorWithoutTranslation(x1: Float, y1: Float, x2: Float, y2: Float) {
+ val pMat = Matrix3x2f(pose()).invert()
var target = Vector3f()
target.set(x1, y1, 1F)
diff --git a/src/main/kotlin/util/skyblock/AbilityUtils.kt b/src/main/kotlin/util/skyblock/AbilityUtils.kt
index 0d7d2b7..9ba182d 100644
--- a/src/main/kotlin/util/skyblock/AbilityUtils.kt
+++ b/src/main/kotlin/util/skyblock/AbilityUtils.kt
@@ -1,8 +1,8 @@
package moe.nea.firmament.util.skyblock
import kotlin.time.Duration
-import net.minecraft.item.ItemStack
-import net.minecraft.text.Text
+import net.minecraft.world.item.ItemStack
+import net.minecraft.network.chat.Component
import moe.nea.firmament.util.ErrorUtil
import moe.nea.firmament.util.directLiteralStringContent
import moe.nea.firmament.util.mc.loreAccordingToNbt
@@ -17,7 +17,7 @@ object AbilityUtils {
val hasPowerScroll: Boolean,
val activation: AbilityActivation,
val manaCost: Int?,
- val descriptionLines: List<Text>,
+ val descriptionLines: List<Component>,
val cooldown: Duration?,
)
@@ -40,7 +40,7 @@ object AbilityUtils {
}
private val abilityNameRegex = "Ability: (?<name>.*?) *".toPattern()
- private fun findAbility(iterator: ListIterator<Text>): ItemAbility? {
+ private fun findAbility(iterator: ListIterator<Component>): ItemAbility? {
if (!iterator.hasNext()) {
return null
}
@@ -72,7 +72,7 @@ object AbilityUtils {
return null
}
if (abilityName == null) return null
- val descriptionLines = mutableListOf<Text>()
+ val descriptionLines = mutableListOf<Component>()
var manaCost: Int? = null
var cooldown: Duration? = null
while (iterator.hasNext()) {
@@ -121,7 +121,7 @@ object AbilityUtils {
)
}
- fun getAbilities(lore: List<Text>): List<ItemAbility> {
+ fun getAbilities(lore: List<Component>): List<ItemAbility> {
val iterator = lore.listIterator()
val abilities = mutableListOf<ItemAbility>()
while (iterator.hasNext()) {
diff --git a/src/main/kotlin/util/skyblock/ItemType.kt b/src/main/kotlin/util/skyblock/ItemType.kt
index 9045646..887edef 100644
--- a/src/main/kotlin/util/skyblock/ItemType.kt
+++ b/src/main/kotlin/util/skyblock/ItemType.kt
@@ -1,6 +1,6 @@
package moe.nea.firmament.util.skyblock
-import net.minecraft.item.ItemStack
+import net.minecraft.world.item.ItemStack
import moe.nea.firmament.util.directLiteralStringContent
import moe.nea.firmament.util.mc.loreAccordingToNbt
import moe.nea.firmament.util.petData
diff --git a/src/main/kotlin/util/skyblock/PartyUtil.kt b/src/main/kotlin/util/skyblock/PartyUtil.kt
index 7d28868..46e1aa3 100644
--- a/src/main/kotlin/util/skyblock/PartyUtil.kt
+++ b/src/main/kotlin/util/skyblock/PartyUtil.kt
@@ -7,7 +7,7 @@ import net.hypixel.modapi.packet.impl.clientbound.ClientboundPartyInfoPacket.Par
import net.hypixel.modapi.packet.impl.serverbound.ServerboundPartyInfoPacket
import org.intellij.lang.annotations.Language
import kotlinx.coroutines.launch
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.apis.Routes
@@ -53,7 +53,7 @@ object PartyUtil {
}
thenExecute {
val p = party
- val text = Text.empty()
+ val text = Component.empty()
text.append(
tr("firmament.dev.partyinfo", "Party Info: ")
.boolColour(p != null)
@@ -64,7 +64,7 @@ object PartyUtil {
text.append(tr("firmament.dev.partyinfo.count", "${p.members.size} members").grey())
p.members.forEach {
text.append("\n")
- .append(Text.literal(" - ${it.name}"))
+ .append(Component.literal(" - ${it.name}"))
.append(" (")
.append(
when (it.role) {
diff --git a/src/main/kotlin/util/skyblock/Rarity.kt b/src/main/kotlin/util/skyblock/Rarity.kt
index 2507256..95e5d87 100644
--- a/src/main/kotlin/util/skyblock/Rarity.kt
+++ b/src/main/kotlin/util/skyblock/Rarity.kt
@@ -7,10 +7,10 @@ import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
-import net.minecraft.item.ItemStack
-import net.minecraft.text.Style
-import net.minecraft.text.Text
-import net.minecraft.util.Formatting
+import net.minecraft.world.item.ItemStack
+import net.minecraft.network.chat.Style
+import net.minecraft.network.chat.Component
+import net.minecraft.ChatFormatting
import moe.nea.firmament.util.StringUtil.words
import moe.nea.firmament.util.collections.lastNotNullOfOrNull
import moe.nea.firmament.util.mc.loreAccordingToNbt
@@ -49,23 +49,23 @@ enum class Rarity(vararg altNames: String) {
}
val names = setOf(name) + altNames
- val text: Text get() = Text.literal(name).setStyle(Style.EMPTY.withColor(colourMap[this]))
+ val text: Component get() = Component.literal(name).setStyle(Style.EMPTY.withColor(colourMap[this]))
val neuRepoRarity: RepoRarity? = RepoRarity.entries.find { it.name == name }
companion object {
// TODO: inline those formattings as fields
val colourMap = mapOf(
- Rarity.COMMON to Formatting.WHITE,
- Rarity.UNCOMMON to Formatting.GREEN,
- Rarity.RARE to Formatting.BLUE,
- Rarity.EPIC to Formatting.DARK_PURPLE,
- Rarity.LEGENDARY to Formatting.GOLD,
- Rarity.MYTHIC to Formatting.LIGHT_PURPLE,
- Rarity.DIVINE to Formatting.AQUA,
- Rarity.SPECIAL to Formatting.RED,
- Rarity.VERY_SPECIAL to Formatting.RED,
- Rarity.SUPREME to Formatting.DARK_RED,
- Rarity.ULTIMATE to Formatting.DARK_RED,
+ Rarity.COMMON to ChatFormatting.WHITE,
+ Rarity.UNCOMMON to ChatFormatting.GREEN,
+ Rarity.RARE to ChatFormatting.BLUE,
+ Rarity.EPIC to ChatFormatting.DARK_PURPLE,
+ Rarity.LEGENDARY to ChatFormatting.GOLD,
+ Rarity.MYTHIC to ChatFormatting.LIGHT_PURPLE,
+ Rarity.DIVINE to ChatFormatting.AQUA,
+ Rarity.SPECIAL to ChatFormatting.RED,
+ Rarity.VERY_SPECIAL to ChatFormatting.RED,
+ Rarity.SUPREME to ChatFormatting.DARK_RED,
+ Rarity.ULTIMATE to ChatFormatting.DARK_RED,
)
val byName = entries.flatMap { en -> en.names.map { it to en } }.toMap()
val fromNeuRepo = entries.associateBy { it.neuRepoRarity }
@@ -89,7 +89,7 @@ enum class Rarity(vararg altNames: String) {
fun fromPetItem(itemStack: ItemStack): Rarity? =
itemStack.petData?.tier?.let(::fromNeuRepo)
- fun fromLore(lore: List<Text>): Rarity? =
+ fun fromLore(lore: List<Component>): Rarity? =
lore.lastNotNullOfOrNull {
it.unformattedString.words()
.firstNotNullOfOrNull(::fromString)
diff --git a/src/main/kotlin/util/skyblock/SBItemUtil.kt b/src/main/kotlin/util/skyblock/SBItemUtil.kt
index 3901b60..619a10b 100644
--- a/src/main/kotlin/util/skyblock/SBItemUtil.kt
+++ b/src/main/kotlin/util/skyblock/SBItemUtil.kt
@@ -1,12 +1,12 @@
package moe.nea.firmament.util.skyblock
-import net.minecraft.item.ItemStack
+import net.minecraft.world.item.ItemStack
import moe.nea.firmament.util.mc.loreAccordingToNbt
import moe.nea.firmament.util.unformattedString
object SBItemUtil {
fun ItemStack.getSearchName(): String {
- val name = this.name.unformattedString
+ val name = this.hoverName.unformattedString
if (name.contains("Enchanted Book")) {
val enchant = loreAccordingToNbt.firstOrNull()?.unformattedString
if (enchant != null) return enchant
diff --git a/src/main/kotlin/util/skyblock/SackUtil.kt b/src/main/kotlin/util/skyblock/SackUtil.kt
index af03363..a69309b 100644
--- a/src/main/kotlin/util/skyblock/SackUtil.kt
+++ b/src/main/kotlin/util/skyblock/SackUtil.kt
@@ -2,9 +2,9 @@ package moe.nea.firmament.util.skyblock
import kotlinx.serialization.Serializable
import kotlinx.serialization.serializer
-import net.minecraft.client.gui.screen.ingame.GenericContainerScreen
-import net.minecraft.text.HoverEvent
-import net.minecraft.text.Text
+import net.minecraft.client.gui.screens.inventory.ContainerScreen
+import net.minecraft.network.chat.HoverEvent
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ChestInventoryUpdateEvent
import moe.nea.firmament.events.ProcessChatEvent
@@ -46,11 +46,11 @@ object SackUtil {
@Subscribe
fun storeDataFromInventory(event: ChestInventoryUpdateEvent) {
- val screen = event.inventory as? GenericContainerScreen ?: return
+ val screen = event.inventory as? ContainerScreen ?: return
if (!screen.title.unformattedString.endsWith(" Sack")) return
- val inv = screen.screenHandler?.inventory ?: return
- if (inv.size() < 18) return
- val backSlot = inv.getStack(inv.size() - 5)
+ val inv = screen.menu?.container ?: return
+ if (inv.containerSize < 18) return
+ val backSlot = inv.getItem(inv.containerSize - 5)
if (backSlot.displayNameAccordingToNbt.unformattedString != "Go Back") return
if (backSlot.loreAccordingToNbt.map { it.unformattedString } != listOf("To Sack of Sacks")) return
for (itemStack in inv.iterableView) {
@@ -74,7 +74,7 @@ object SackUtil {
getUpdatesFromMessage(event.text)
}
- fun getUpdatesFromMessage(text: Text): List<SackUpdate> {
+ fun getUpdatesFromMessage(text: Component): List<SackUpdate> {
val update = ChatUpdate()
text.siblings.forEach(update::updateFromHoverText)
return update.updates
@@ -102,7 +102,7 @@ object SackUtil {
}
}
- fun updateFromHoverText(text: Text) {
+ fun updateFromHoverText(text: Component) {
text.siblings.forEach(::updateFromHoverText)
val hoverText = (text.style.hoverEvent as? HoverEvent.ShowText)?.value ?: return
val cleanedText = hoverText.unformattedString
diff --git a/src/main/kotlin/util/skyblock/ScreenIdentification.kt b/src/main/kotlin/util/skyblock/ScreenIdentification.kt
index 0e7797c..ff725fa 100644
--- a/src/main/kotlin/util/skyblock/ScreenIdentification.kt
+++ b/src/main/kotlin/util/skyblock/ScreenIdentification.kt
@@ -1,7 +1,7 @@
package moe.nea.firmament.util.skyblock
-import net.minecraft.client.gui.screen.Screen
-import net.minecraft.client.gui.screen.ingame.GenericContainerScreen
+import net.minecraft.client.gui.screens.Screen
+import net.minecraft.client.gui.screens.inventory.ContainerScreen
import moe.nea.firmament.util.mc.displayNameAccordingToNbt
import moe.nea.firmament.util.mc.loreAccordingToNbt
import moe.nea.firmament.util.unformattedString
@@ -24,13 +24,13 @@ object ScreenIdentification {
enum class ScreenType(val detector: (Screen) -> Boolean) {
BAZAAR_ANY({
- it is GenericContainerScreen && (
- it.screenHandler.getSlot(it.screenHandler.rows * 9 - 4)
- .stack
+ it is ContainerScreen && (
+ it.menu.getSlot(it.menu.rowCount * 9 - 4)
+ .item
.displayNameAccordingToNbt
.unformattedString == "Manage Orders"
- || it.screenHandler.getSlot(it.screenHandler.rows * 9 - 5)
- .stack
+ || it.menu.getSlot(it.menu.rowCount * 9 - 5)
+ .item
.loreAccordingToNbt
.any {
it.unformattedString == "To Bazaar"
diff --git a/src/main/kotlin/util/skyblock/TabListAPI.kt b/src/main/kotlin/util/skyblock/TabListAPI.kt
index 6b937da..43722e0 100644
--- a/src/main/kotlin/util/skyblock/TabListAPI.kt
+++ b/src/main/kotlin/util/skyblock/TabListAPI.kt
@@ -1,7 +1,7 @@
package moe.nea.firmament.util.skyblock
import org.intellij.lang.annotations.Language
-import net.minecraft.text.Text
+import net.minecraft.network.chat.Component
import moe.nea.firmament.util.StringUtil.title
import moe.nea.firmament.util.StringUtil.unwords
import moe.nea.firmament.util.mc.MCTabListAPI
@@ -9,7 +9,7 @@ import moe.nea.firmament.util.unformattedString
object TabListAPI {
- fun getWidgetLines(widgetName: WidgetName, includeTitle: Boolean = false, from: MCTabListAPI.CurrentTabList = MCTabListAPI.currentTabList): List<Text> {
+ fun getWidgetLines(widgetName: WidgetName, includeTitle: Boolean = false, from: MCTabListAPI.CurrentTabList = MCTabListAPI.currentTabList): List<Component> {
return from.body
.dropWhile { !widgetName.matchesTitle(it) }
.takeWhile { it.string.isNotBlank() && !it.string.startsWith(" ") }
@@ -25,7 +25,7 @@ object TabListAPI {
PET
;
- fun matchesTitle(it: Text): Boolean {
+ fun matchesTitle(it: Component): Boolean {
return regex.matches(it.unformattedString)
}
diff --git a/src/main/kotlin/util/textutil.kt b/src/main/kotlin/util/textutil.kt
index f7c7d1c..d8b2592 100644
--- a/src/main/kotlin/util/textutil.kt
+++ b/src/main/kotlin/util/textutil.kt
@@ -1,17 +1,17 @@
package moe.nea.firmament.util
import java.util.Optional
-import net.minecraft.text.ClickEvent
-import net.minecraft.text.HoverEvent
-import net.minecraft.text.MutableText
-import net.minecraft.text.OrderedText
-import net.minecraft.text.PlainTextContent
-import net.minecraft.text.StringVisitable
-import net.minecraft.text.Style
-import net.minecraft.text.Text
-import net.minecraft.text.TextColor
-import net.minecraft.text.TranslatableTextContent
-import net.minecraft.util.Formatting
+import net.minecraft.network.chat.ClickEvent
+import net.minecraft.network.chat.HoverEvent
+import net.minecraft.network.chat.MutableComponent
+import net.minecraft.util.FormattedCharSequence
+import net.minecraft.network.chat.contents.PlainTextContents
+import net.minecraft.network.chat.FormattedText
+import net.minecraft.network.chat.Style
+import net.minecraft.network.chat.Component
+import net.minecraft.network.chat.TextColor
+import net.minecraft.network.chat.contents.TranslatableContents
+import net.minecraft.ChatFormatting
val formattingChars = "kmolnrKMOLNR".toSet()
@@ -36,15 +36,15 @@ fun CharSequence.removeColorCodes(keepNonColorCodes: Boolean = false): String {
return stringBuffer.toString()
}
-fun OrderedText.reconstitute(): MutableText {
- val base = Text.literal("")
+fun FormattedCharSequence.reconstitute(): MutableComponent {
+ val base = Component.literal("")
base.setStyle(Style.EMPTY.withItalic(false))
var lastColorCode = Style.EMPTY
val text = StringBuilder()
this.accept { index, style, codePoint ->
if (style != lastColorCode) {
if (text.isNotEmpty())
- base.append(Text.literal(text.toString()).setStyle(lastColorCode))
+ base.append(Component.literal(text.toString()).setStyle(lastColorCode))
lastColorCode = style
text.clear()
}
@@ -52,20 +52,20 @@ fun OrderedText.reconstitute(): MutableText {
true
}
if (text.isNotEmpty())
- base.append(Text.literal(text.toString()).setStyle(lastColorCode))
+ base.append(Component.literal(text.toString()).setStyle(lastColorCode))
return base
}
-fun StringVisitable.reconstitute(): MutableText {
- val base = Text.literal("")
+fun FormattedText.reconstitute(): MutableComponent {
+ val base = Component.literal("")
base.setStyle(Style.EMPTY.withItalic(false))
var lastColorCode = Style.EMPTY
val text = StringBuilder()
this.visit({ style, string ->
if (style != lastColorCode) {
if (text.isNotEmpty())
- base.append(Text.literal(text.toString()).setStyle(lastColorCode))
+ base.append(Component.literal(text.toString()).setStyle(lastColorCode))
lastColorCode = style
text.clear()
}
@@ -73,17 +73,17 @@ fun StringVisitable.reconstitute(): MutableText {
Optional.empty<Unit>()
}, Style.EMPTY)
if (text.isNotEmpty())
- base.append(Text.literal(text.toString()).setStyle(lastColorCode))
+ base.append(Component.literal(text.toString()).setStyle(lastColorCode))
return base
}
-val Text.unformattedString: String
+val Component.unformattedString: String
get() = string.removeColorCodes() // TODO: maybe shortcircuit this with .visit
-val Text.directLiteralStringContent: String? get() = (this.content as? PlainTextContent)?.string()
+val Component.directLiteralStringContent: String? get() = (this.contents as? PlainTextContents)?.text()
-fun Text.getLegacyFormatString(trimmed: Boolean = false): String =
+fun Component.getLegacyFormatString(trimmed: Boolean = false): String =
run {
var lastCode = "§r"
val sb = StringBuilder()
@@ -126,65 +126,65 @@ fun Text.getLegacyFormatString(trimmed: Boolean = false): String =
it
}
-private val textColorLUT = Formatting.entries
- .mapNotNull { formatting -> formatting.colorValue?.let { it to formatting } }
+private val textColorLUT = ChatFormatting.entries
+ .mapNotNull { formatting -> formatting.color?.let { it to formatting } }
.toMap()
-fun TextColor.toChatFormatting(): Formatting? {
- return textColorLUT[this.rgb]
+fun TextColor.toChatFormatting(): ChatFormatting? {
+ return textColorLUT[this.value]
}
-fun Text.iterator(): Sequence<Text> {
+fun Component.iterator(): Sequence<Component> {
return sequenceOf(this) + siblings.asSequence()
.flatMap { it.iterator() } // TODO: in theory we want to properly inherit styles here
}
-fun Text.allSiblings(): List<Text> = listOf(this) + siblings.flatMap { it.allSiblings() }
+fun Component.allSiblings(): List<Component> = listOf(this) + siblings.flatMap { it.allSiblings() }
-fun MutableText.withColor(formatting: Formatting): MutableText = this.styled {
+fun MutableComponent.withColor(formatting: ChatFormatting): MutableComponent = this.withStyle {
it.withColor(formatting)
.withItalic(false)
.withBold(false)
}
-fun MutableText.blue() = withColor(Formatting.BLUE)
-fun MutableText.aqua() = withColor(Formatting.AQUA)
-fun MutableText.lime() = withColor(Formatting.GREEN)
-fun MutableText.darkGreen() = withColor(Formatting.DARK_GREEN)
-fun MutableText.purple() = withColor(Formatting.DARK_PURPLE)
-fun MutableText.pink() = withColor(Formatting.LIGHT_PURPLE)
-fun MutableText.yellow() = withColor(Formatting.YELLOW)
-fun MutableText.gold() = withColor(Formatting.GOLD)
-fun MutableText.grey() = withColor(Formatting.GRAY)
-fun MutableText.darkGrey() = withColor(Formatting.DARK_GRAY)
-fun MutableText.red() = withColor(Formatting.RED)
-fun MutableText.white() = withColor(Formatting.WHITE)
-fun MutableText.bold(): MutableText = styled { it.withBold(true) }
-fun MutableText.hover(text: Text): MutableText = styled { it.withHoverEvent(HoverEvent.ShowText(text)) }
-fun MutableText.boolColour(
- bool: Boolean,
- ifTrue: Formatting = Formatting.GREEN,
- ifFalse: Formatting = Formatting.DARK_RED
+fun MutableComponent.blue() = withColor(ChatFormatting.BLUE)
+fun MutableComponent.aqua() = withColor(ChatFormatting.AQUA)
+fun MutableComponent.lime() = withColor(ChatFormatting.GREEN)
+fun MutableComponent.darkGreen() = withColor(ChatFormatting.DARK_GREEN)
+fun MutableComponent.purple() = withColor(ChatFormatting.DARK_PURPLE)
+fun MutableComponent.pink() = withColor(ChatFormatting.LIGHT_PURPLE)
+fun MutableComponent.yellow() = withColor(ChatFormatting.YELLOW)
+fun MutableComponent.gold() = withColor(ChatFormatting.GOLD)
+fun MutableComponent.grey() = withColor(ChatFormatting.GRAY)
+fun MutableComponent.darkGrey() = withColor(ChatFormatting.DARK_GRAY)
+fun MutableComponent.red() = withColor(ChatFormatting.RED)
+fun MutableComponent.white() = withColor(ChatFormatting.WHITE)
+fun MutableComponent.bold(): MutableComponent = withStyle { it.withBold(true) }
+fun MutableComponent.hover(text: Component): MutableComponent = withStyle { it.withHoverEvent(HoverEvent.ShowText(text)) }
+fun MutableComponent.boolColour(
+ bool: Boolean,
+ ifTrue: ChatFormatting = ChatFormatting.GREEN,
+ ifFalse: ChatFormatting = ChatFormatting.DARK_RED
) =
if (bool) withColor(ifTrue) else withColor(ifFalse)
-fun MutableText.clickCommand(command: String): MutableText {
+fun MutableComponent.clickCommand(command: String): MutableComponent {
require(command.startsWith("/"))
- return this.styled {
+ return this.withStyle {
it.withClickEvent(ClickEvent.RunCommand(command))
}
}
-fun MutableText.prepend(text: Text): MutableText {
+fun MutableComponent.prepend(text: Component): MutableComponent {
siblings.addFirst(text)
return this
}
-fun Text.transformEachRecursively(function: (Text) -> Text): Text {
- val c = this.content
- if (c is TranslatableTextContent) {
- return Text.translatableWithFallback(c.key, c.fallback, *c.args.map {
- (it as? Text ?: Text.literal(it.toString())).transformEachRecursively(function)
+fun Component.transformEachRecursively(function: (Component) -> Component): Component {
+ val c = this.contents
+ if (c is TranslatableContents) {
+ return Component.translatableWithFallback(c.key, c.fallback, *c.args.map {
+ (it as? Component ?: Component.literal(it.toString())).transformEachRecursively(function)
}.toTypedArray()).also { new ->
new.style = this.style
new.siblings.clear()
@@ -201,8 +201,8 @@ fun Text.transformEachRecursively(function: (Text) -> Text): Text {
}
}
-fun tr(key: String, default: String): MutableText = error("Compiler plugin did not run.")
-fun trResolved(key: String, vararg args: Any): MutableText = Text.stringifiedTranslatable(key, *args)
+fun tr(key: String, default: String): MutableComponent = error("Compiler plugin did not run.")
+fun trResolved(key: String, vararg args: Any): MutableComponent = Component.translatableEscape(key, *args)
fun titleCase(str: String): String {
return str
.lowercase()
diff --git a/src/main/resources/firmament.accesswidener b/src/main/resources/firmament.accesswidener
index 2bc3a9a..c6795db 100644
--- a/src/main/resources/firmament.accesswidener
+++ b/src/main/resources/firmament.accesswidener
@@ -1,45 +1,47 @@
accessWidener v2 named
-accessible class net/minecraft/client/render/RenderLayer$MultiPhase
-accessible class net/minecraft/client/render/RenderLayer$MultiPhaseParameters
-accessible class net/minecraft/client/font/TextRenderer$Drawer
+accessible class net/minecraft/client/renderer/RenderType$CompositeRenderType
+accessible class net/minecraft/client/renderer/RenderType$CompositeState
+accessible class net/minecraft/client/gui/Font$PreparedTextBuilder
-accessible field net/minecraft/client/gui/hud/InGameHud SCOREBOARD_ENTRY_COMPARATOR Ljava/util/Comparator;
+accessible field net/minecraft/client/gui/Gui SCORE_DISPLAY_ORDER Ljava/util/Comparator;
-accessible field net/minecraft/client/network/ClientPlayNetworkHandler combinedDynamicRegistries Lnet/minecraft/registry/DynamicRegistryManager$Immutable;
-accessible method net/minecraft/registry/RegistryOps <init> (Lcom/mojang/serialization/DynamicOps;Lnet/minecraft/registry/RegistryOps$RegistryInfoGetter;)V
-accessible class net/minecraft/registry/RegistryOps$CachedRegistryInfoGetter
-accessible class net/minecraft/client/render/model/ModelBaker$BakerImpl
-accessible method net/minecraft/client/render/model/ModelBaker$BakerImpl <init> (Lnet/minecraft/client/render/model/ModelBaker;Lnet/minecraft/client/render/model/ErrorCollectingSpriteGetter;)V
+accessible field net/minecraft/client/multiplayer/ClientPacketListener registryAccess Lnet/minecraft/core/RegistryAccess$Frozen;
+accessible method net/minecraft/resources/RegistryOps <init> (Lcom/mojang/serialization/DynamicOps;Lnet/minecraft/resources/RegistryOps$RegistryInfoLookup;)V
+accessible class net/minecraft/resources/RegistryOps$HolderLookupAdapter
+accessible class net/minecraft/client/resources/model/ModelBakery$ModelBakerImpl
+accessible method net/minecraft/client/resources/model/ModelBakery$ModelBakerImpl <init> (Lnet/minecraft/client/resources/model/ModelBakery;Lnet/minecraft/client/resources/model/SpriteGetter;)V
-accessible field net/minecraft/entity/mob/CreeperEntity CHARGED Lnet/minecraft/entity/data/TrackedData;
-accessible method net/minecraft/entity/decoration/ArmorStandEntity setSmall (Z)V
-accessible method net/minecraft/resource/NamespaceResourceManager loadMetadata (Lnet/minecraft/resource/InputSupplier;)Lnet/minecraft/resource/metadata/ResourceMetadata;
-accessible method net/minecraft/client/gui/DrawContext drawTexturedQuad (Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/util/Identifier;IIIIFFFFI)V
+accessible field net/minecraft/world/entity/monster/Creeper DATA_IS_POWERED Lnet/minecraft/network/syncher/EntityDataAccessor;
+accessible method net/minecraft/world/entity/decoration/ArmorStand setSmall (Z)V
+accessible method net/minecraft/server/packs/resources/FallbackResourceManager parseMetadata (Lnet/minecraft/server/packs/resources/IoSupplier;)Lnet/minecraft/server/packs/resources/ResourceMetadata;
+accessible method net/minecraft/client/gui/GuiGraphics innerBlit (Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/ResourceLocation;IIIIFFFFI)V
-accessible field net/minecraft/network/packet/c2s/common/CustomPayloadC2SPacket MAX_PAYLOAD_SIZE I
+accessible field net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket MAX_PAYLOAD_SIZE I
-accessible class net/minecraft/client/render/model/BlockStatesLoader$LoadedBlockStateDefinition
-accessible field net/minecraft/client/render/model/BlockStatesLoader FINDER Lnet/minecraft/resource/ResourceFinder;
-accessible method net/minecraft/client/render/model/BlockStatesLoader$LoadedBlockStateDefinition <init> (Ljava/lang/String;Lnet/minecraft/client/render/model/json/BlockModelDefinition;)V
-accessible method net/minecraft/client/render/model/BlockStatesLoader combine (Lnet/minecraft/util/Identifier;Lnet/minecraft/state/StateManager;Ljava/util/List;)Lnet/minecraft/client/render/model/BlockStatesLoader$LoadedModels;
+accessible class net/minecraft/client/resources/model/BlockStateModelLoader$LoadedBlockModelDefinition
+accessible field net/minecraft/client/resources/model/BlockStateModelLoader BLOCKSTATE_LISTER Lnet/minecraft/resources/FileToIdConverter;
+accessible method net/minecraft/client/resources/model/BlockStateModelLoader$LoadedBlockModelDefinition <init> (Ljava/lang/String;Lnet/minecraft/client/renderer/block/model/BlockModelDefinition;)V
+accessible method net/minecraft/client/resources/model/BlockStateModelLoader loadBlockStateDefinitionStack (Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/world/level/block/state/StateDefinition;Ljava/util/List;)Lnet/minecraft/client/resources/model/BlockStateModelLoader$LoadedModels;
-mutable field net/minecraft/screen/slot/Slot x I
-mutable field net/minecraft/screen/slot/Slot y I
+mutable field net/minecraft/world/inventory/Slot x I
+mutable field net/minecraft/world/inventory/Slot y I
#accessible field net/minecraft/entity/player/PlayerEntity PLAYER_MODEL_PARTS Lnet/minecraft/entity/data/TrackedData;
-accessible field net/minecraft/client/render/WorldRenderer chunks Lnet/minecraft/client/render/BuiltChunkStorage;
-accessible field net/minecraft/client/render/OverlayTexture texture Lnet/minecraft/client/texture/NativeImageBackedTexture;
-
-accessible method net/minecraft/client/render/RenderPhase$Texture getId ()Ljava/util/Optional;
-accessible field net/minecraft/client/render/RenderLayer$MultiPhase phases Lnet/minecraft/client/render/RenderLayer$MultiPhaseParameters;
-accessible field net/minecraft/client/render/RenderLayer$MultiPhaseParameters texture Lnet/minecraft/client/render/RenderPhase$TextureBase;
-accessible field net/minecraft/client/network/ClientPlayerInteractionManager currentBreakingPos Lnet/minecraft/util/math/BlockPos;
-accessible field net/minecraft/client/render/RenderLayer$MultiPhase pipeline Lcom/mojang/blaze3d/pipeline/RenderPipeline;
-
-mutable field net/minecraft/client/render/entity/state/LivingEntityRenderState headItemRenderState Lnet/minecraft/client/render/item/ItemRenderState;
-
-accessible field net/minecraft/entity/Entity world Lnet/minecraft/world/World;
-accessible field net/minecraft/client/MinecraftClient userApiService Lcom/mojang/authlib/minecraft/UserApiService;
-accessible field net/minecraft/entity/Entity pos Lnet/minecraft/util/math/Vec3d;
-accessible method net/minecraft/component/type/ProfileComponent get ()Lcom/mojang/datafixers/util/Either;
-accessible field net/minecraft/entity/PlayerLikeEntity PLAYER_MODE_CUSTOMIZATION_ID Lnet/minecraft/entity/data/TrackedData;
+accessible field net/minecraft/client/renderer/LevelRenderer viewArea Lnet/minecraft/client/renderer/ViewArea;
+accessible field net/minecraft/client/renderer/texture/OverlayTexture texture Lnet/minecraft/client/renderer/texture/DynamicTexture;
+
+accessible method net/minecraft/client/renderer/RenderStateShard$TextureStateShard cutoutTexture ()Ljava/util/Optional;
+# was accessible method net/minecraft/client/renderer/RenderStateShard$TextureStateShard getId ()Ljava/util/Optional;
+
+accessible field net/minecraft/client/renderer/RenderType$CompositeRenderType state Lnet/minecraft/client/renderer/RenderType$CompositeState;
+accessible field net/minecraft/client/renderer/RenderType$CompositeState textureState Lnet/minecraft/client/renderer/RenderStateShard$EmptyTextureStateShard;
+accessible field net/minecraft/client/multiplayer/MultiPlayerGameMode destroyBlockPos Lnet/minecraft/core/BlockPos;
+accessible field net/minecraft/client/renderer/RenderType$CompositeRenderType renderPipeline Lcom/mojang/blaze3d/pipeline/RenderPipeline;
+
+mutable field net/minecraft/client/renderer/entity/state/LivingEntityRenderState headItem Lnet/minecraft/client/renderer/item/ItemStackRenderState;
+
+accessible field net/minecraft/world/entity/Entity level Lnet/minecraft/world/level/Level;
+accessible field net/minecraft/client/Minecraft userApiService Lcom/mojang/authlib/minecraft/UserApiService;
+accessible field net/minecraft/world/entity/Entity position Lnet/minecraft/world/phys/Vec3;
+accessible method net/minecraft/world/item/component/ResolvableProfile unpack ()Lcom/mojang/datafixers/util/Either;
+accessible field net/minecraft/world/entity/Avatar DATA_PLAYER_MODE_CUSTOMISATION Lnet/minecraft/network/syncher/EntityDataAccessor;