From 139089d9beb134465737c4afff3b1303bf481aa1 Mon Sep 17 00:00:00 2001 From: nea Date: Mon, 25 Sep 2023 19:24:16 +0200 Subject: Port to 1.20.2 --- gradle/libs.versions.toml | 28 +++++++++--------- .../mixins/MixinClientCommonNetworkHandler.java | 25 ++++++++++++++++ .../firmament/mixins/MixinClientPacketHandler.java | 7 ----- .../nea/firmament/mixins/MixinPlayerInventory.java | 17 ----------- .../nea/firmament/mixins/MixinPlayerListEntry.java | 24 ---------------- .../moe/nea/firmament/mixins/MixinProperty.java | 33 ++++++++++++++++++++++ .../mixins/MixinYggdrasilServicesKeyInfo.java | 25 ++++++++++++++++ .../mixins/devenv/DisableCommonPacketWarnings.java | 11 +++++--- .../kotlin/moe/nea/firmament/apis/UrsaManager.kt | 4 +-- .../storageoverlay/StorageOverlayScreen.kt | 9 ++++-- .../kotlin/moe/nea/firmament/repo/RepoManager.kt | 14 +++++---- .../moe/nea/firmament/util/ScoreboardUtil.kt | 3 +- src/main/resources/firmament.accesswidener | 1 + 13 files changed, 124 insertions(+), 77 deletions(-) create mode 100644 src/main/java/moe/nea/firmament/mixins/MixinClientCommonNetworkHandler.java delete mode 100644 src/main/java/moe/nea/firmament/mixins/MixinPlayerInventory.java delete mode 100644 src/main/java/moe/nea/firmament/mixins/MixinPlayerListEntry.java create mode 100644 src/main/java/moe/nea/firmament/mixins/MixinProperty.java create mode 100644 src/main/java/moe/nea/firmament/mixins/MixinYggdrasilServicesKeyInfo.java diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 37f5295..ce8c9da 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,26 +3,26 @@ # SPDX-License-Identifier: CC0-1.0 [versions] -minecraft = "1.20" -fabric_loader = "0.14.21" -fabric_api = "0.83.0+1.20" +minecraft = "1.20.2" +fabric_loader = "0.14.22" +fabric_api = "0.89.2+1.20.2" fabric_kotlin = "1.9.4+kotlin.1.8.21" -yarn = "1.20+build.1" -libgui = "8.0.1+1.20" -rei = "12.0.622" +yarn = "1.20.2+build.1" +libgui = "8.1.0+1.20.2" +rei = "13.0.655" devauth = "1.0.0" -modmenu = "7.0.0" +modmenu = "7.2.2" ktor = "2.3.0" dbus_java = "4.2.1" -architectury = "9.0.7" +architectury = "10.0.7" neurepoparser = "1.3.1" -qolify = "1.3.0-1.20" +qolify = "1.3.0-1.20.2" citresewn = "1.1.3+1.20" hotswap_agent = "1.4.2-SNAPSHOT" -sodium = "mc1.20-0.4.10" +sodium = "mc1.20.2-0.5.3" freecammod = "1.2.0-mc1.20" ncr = "Fabric-1.20-v2.2.0" -mixinextras = "0.2.0-beta.9" +mixinextras = "0.2.0-rc.5" jarvis = "1.1.1" nealisp = "1.0.0" @@ -38,7 +38,7 @@ repoparser = { module = "moe.nea:neurepoparser", version.ref = "neurepoparser" } dbus_java_core = { module = "com.github.hypfvieh:dbus-java-core", version.ref = "dbus_java" } dbus_java_unixsocket = { module = "com.github.hypfvieh:dbus-java-transport-native-unixsocket", version.ref = "dbus_java" } libgui = { module = "io.github.cottonmc:LibGui", version.ref = "libgui" } -mixinextras = { module = "com.github.llamalad7.mixinextras:mixinextras-fabric", version.ref = "mixinextras" } +mixinextras = { module = "io.github.llamalad7:mixinextras-fabric", version.ref = "mixinextras" } jarvis_api = { module = "moe.nea.jarvis:jarvis-api", version.ref = "jarvis" } jarvis_fabric = { module = "moe.nea.jarvis:jarvis-fabric", version.ref = "jarvis" } nealisp = { module = "moe.nea:nealisp", version.ref = "nealisp" } @@ -60,11 +60,11 @@ dbus = ["dbus_java_core", "dbus_java_unixsocket"] runtime_required = ["architectury_fabric", "rei_fabric"] runtime_optional = [ "devauth", - "freecammod", +# "freecammod", "sodium", "qolify", # "citresewn", - "ncr", +# "ncr", ] diff --git a/src/main/java/moe/nea/firmament/mixins/MixinClientCommonNetworkHandler.java b/src/main/java/moe/nea/firmament/mixins/MixinClientCommonNetworkHandler.java new file mode 100644 index 0000000..767d25c --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/MixinClientCommonNetworkHandler.java @@ -0,0 +1,25 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import moe.nea.firmament.events.OutgoingPacketEvent; +import net.minecraft.client.network.ClientCommonNetworkHandler; +import net.minecraft.network.packet.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) +public class MixinClientCommonNetworkHandler { + @Inject(method = "sendPacket(Lnet/minecraft/network/packet/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/MixinClientPacketHandler.java b/src/main/java/moe/nea/firmament/mixins/MixinClientPacketHandler.java index aa6ce38..dbf8c7f 100644 --- a/src/main/java/moe/nea/firmament/mixins/MixinClientPacketHandler.java +++ b/src/main/java/moe/nea/firmament/mixins/MixinClientPacketHandler.java @@ -29,11 +29,4 @@ public class MixinClientPacketHandler { packet.isLongDistance() )); } - - @Inject(method = "sendPacket(Lnet/minecraft/network/packet/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/MixinPlayerInventory.java b/src/main/java/moe/nea/firmament/mixins/MixinPlayerInventory.java deleted file mode 100644 index 2076923..0000000 --- a/src/main/java/moe/nea/firmament/mixins/MixinPlayerInventory.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Linnea Gräf - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -package moe.nea.firmament.mixins; - -import net.minecraft.entity.player.PlayerInventory; -import org.spongepowered.asm.mixin.Mixin; - -@Mixin(PlayerInventory.class) -public class MixinPlayerInventory { - - - -} diff --git a/src/main/java/moe/nea/firmament/mixins/MixinPlayerListEntry.java b/src/main/java/moe/nea/firmament/mixins/MixinPlayerListEntry.java deleted file mode 100644 index 870aaad..0000000 --- a/src/main/java/moe/nea/firmament/mixins/MixinPlayerListEntry.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Linnea Gräf - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -package moe.nea.firmament.mixins; - -import moe.nea.firmament.features.fixes.Fixes; -import net.minecraft.client.network.PlayerListEntry; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyArg; - -@Mixin(PlayerListEntry.class) -public class MixinPlayerListEntry { - @ModifyArg(method = "loadTextures", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/PlayerSkinProvider;loadSkin(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/texture/PlayerSkinProvider$SkinTextureAvailableCallback;Z)V")) - public boolean shouldBeSecure(boolean originalSecure) { - if (Fixes.TConfig.INSTANCE.getFixUnsignedPlayerSkins()) { - return false; - } - return originalSecure; - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/MixinProperty.java b/src/main/java/moe/nea/firmament/mixins/MixinProperty.java new file mode 100644 index 0000000..15ff6e4 --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/MixinProperty.java @@ -0,0 +1,33 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import com.mojang.authlib.properties.Property; +import moe.nea.firmament.features.fixes.Fixes; +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; + +import java.security.PublicKey; + +@Mixin(value = Property.class, remap = false) +public class MixinProperty { + @Inject(method = "isSignatureValid", cancellable = true, at = @At("HEAD"), remap = false) + public void onValidateSignature(PublicKey publicKey, CallbackInfoReturnable cir) { + if (Fixes.TConfig.INSTANCE.getFixUnsignedPlayerSkins()) { + cir.setReturnValue(true); + } + } + + @Inject(method = "hasSignature", cancellable = true, at = @At("HEAD"), remap = false) + public void onHasSignature(CallbackInfoReturnable cir) { + if (Fixes.TConfig.INSTANCE.getFixUnsignedPlayerSkins()) { + cir.setReturnValue(true); + } + } +} diff --git a/src/main/java/moe/nea/firmament/mixins/MixinYggdrasilServicesKeyInfo.java b/src/main/java/moe/nea/firmament/mixins/MixinYggdrasilServicesKeyInfo.java new file mode 100644 index 0000000..38c380b --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/MixinYggdrasilServicesKeyInfo.java @@ -0,0 +1,25 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import com.mojang.authlib.properties.Property; +import com.mojang.authlib.yggdrasil.YggdrasilServicesKeyInfo; +import moe.nea.firmament.features.fixes.Fixes; +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(value = YggdrasilServicesKeyInfo.class, remap = false) +public class MixinYggdrasilServicesKeyInfo { + @Inject(method = "validateProperty", at = @At("HEAD"), cancellable = true, remap = false) + public void validate(Property property, CallbackInfoReturnable cir) { + if (Fixes.TConfig.INSTANCE.getFixUnsignedPlayerSkins()) { + 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 9fc2ab0..3d557fc 100644 --- a/src/main/java/moe/nea/firmament/mixins/devenv/DisableCommonPacketWarnings.java +++ b/src/main/java/moe/nea/firmament/mixins/devenv/DisableCommonPacketWarnings.java @@ -7,21 +7,24 @@ package moe.nea.firmament.mixins.devenv; import net.minecraft.client.network.ClientPlayNetworkHandler; +import net.minecraft.network.packet.CustomPayload; import net.minecraft.util.Identifier; import org.slf4j.Logger; 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.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.Objects; @Mixin(ClientPlayNetworkHandler.class) public class DisableCommonPacketWarnings { - @Redirect(method = "onCustomPayload", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V", remap = false)) - public void onCustomPacket(Logger instance, String s, Object o) { - if (!Objects.equals(o, Identifier.of("badlion", "mods"))) { - instance.warn(s, o); + @Inject(method = "method_52801", at = @At("HEAD")) + public void onCustomPacketError(CustomPayload customPayload, CallbackInfo ci) { + if (Objects.equals(customPayload.id(), Identifier.of("badlion", "mods"))) { + ci.cancel(); } } diff --git a/src/main/kotlin/moe/nea/firmament/apis/UrsaManager.kt b/src/main/kotlin/moe/nea/firmament/apis/UrsaManager.kt index 8288283..a78b423 100644 --- a/src/main/kotlin/moe/nea/firmament/apis/UrsaManager.kt +++ b/src/main/kotlin/moe/nea/firmament/apis/UrsaManager.kt @@ -50,8 +50,8 @@ object UrsaManager { withContext(Dispatchers.IO) { val mc = MinecraftClient.getInstance() val serverId = UUID.randomUUID().toString() - mc.sessionService.joinServer(mc.session.profile, mc.session.accessToken, serverId) - header("x-ursa-username", mc.session.profile.name) + mc.sessionService.joinServer(mc.session.uuidOrNull, mc.session.accessToken, serverId) + header("x-ursa-username", mc.session.username) header("x-ursa-serverid", serverId) } } else { diff --git a/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlayScreen.kt b/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlayScreen.kt index 63ce134..8251c92 100644 --- a/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlayScreen.kt +++ b/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlayScreen.kt @@ -102,9 +102,14 @@ class StorageOverlayScreen() : Screen(Text.empty()) { return page.inventory?.rows?.let { it * 19 + MC.font.fontHeight + 2 } ?: 60 } - override fun mouseScrolled(mouseX: Double, mouseY: Double, amount: Double): Boolean { + override fun mouseScrolled( + mouseX: Double, + mouseY: Double, + horizontalAmount: Double, + verticalAmount: Double + ): Boolean { scroll = - (scroll + amount * StorageOverlay.config.scrollSpeed * + (scroll + horizontalAmount * StorageOverlay.config.scrollSpeed * (if (StorageOverlay.config.inverseScroll) 1 else -1)).toInt() .coerceAtMost(lastRenderedHeight - height + 2 * StorageOverlay.config.margin).coerceAtLeast(0) return true diff --git a/src/main/kotlin/moe/nea/firmament/repo/RepoManager.kt b/src/main/kotlin/moe/nea/firmament/repo/RepoManager.kt index eda6130..6c877ec 100644 --- a/src/main/kotlin/moe/nea/firmament/repo/RepoManager.kt +++ b/src/main/kotlin/moe/nea/firmament/repo/RepoManager.kt @@ -13,7 +13,11 @@ import io.github.moulberry.repo.NEURepositoryException import io.github.moulberry.repo.data.NEUItem import io.github.moulberry.repo.data.NEURecipe import io.github.moulberry.repo.data.Rarity +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents import kotlinx.coroutines.launch +import net.minecraft.client.MinecraftClient +import net.minecraft.network.packet.s2c.play.SynchronizeRecipesS2CPacket +import net.minecraft.text.Text import moe.nea.firmament.Firmament import moe.nea.firmament.Firmament.logger import moe.nea.firmament.gui.config.ManagedConfig @@ -21,10 +25,6 @@ import moe.nea.firmament.hud.ProgressBar import moe.nea.firmament.rei.PetData import moe.nea.firmament.util.MinecraftDispatcher import moe.nea.firmament.util.SkyblockId -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents -import net.minecraft.client.MinecraftClient -import net.minecraft.network.packet.s2c.play.SynchronizeRecipesS2CPacket -import net.minecraft.text.Text object RepoManager { object Config : ManagedConfig("repo") { @@ -54,8 +54,10 @@ object RepoManager { var recentlyFailedToUpdateItemList = false - val progressBar = ProgressBar("", null, 0).also { - it.setSize(180, 22) + val progressBar by lazy { + ProgressBar("", null, 0).also { + it.setSize(180, 22) + } } val neuRepo: NEURepository = NEURepository.of(RepoDownloadManager.repoSavedLocation).apply { diff --git a/src/main/kotlin/moe/nea/firmament/util/ScoreboardUtil.kt b/src/main/kotlin/moe/nea/firmament/util/ScoreboardUtil.kt index afbdd82..b437357 100644 --- a/src/main/kotlin/moe/nea/firmament/util/ScoreboardUtil.kt +++ b/src/main/kotlin/moe/nea/firmament/util/ScoreboardUtil.kt @@ -8,6 +8,7 @@ package moe.nea.firmament.util import java.util.Optional import net.minecraft.scoreboard.Scoreboard +import net.minecraft.scoreboard.ScoreboardDisplaySlot import net.minecraft.scoreboard.Team import net.minecraft.text.StringVisitable import net.minecraft.text.Style @@ -16,7 +17,7 @@ import net.minecraft.util.Formatting fun getScoreboardLines(): List { val scoreboard = MC.player?.scoreboard ?: return listOf() - val activeObjective = scoreboard.getObjectiveForSlot(Scoreboard.SIDEBAR_DISPLAY_SLOT_ID) ?: return listOf() + val activeObjective = scoreboard.getObjectiveForSlot(ScoreboardDisplaySlot.SIDEBAR) ?: return listOf() return scoreboard.getAllPlayerScores(activeObjective).reversed().take(15).map { val team = scoreboard.getPlayerTeam(it.playerName) Team.decorateName(team, Text.literal(it.playerName)) diff --git a/src/main/resources/firmament.accesswidener b/src/main/resources/firmament.accesswidener index 8b4f3d7..08d4bff 100644 --- a/src/main/resources/firmament.accesswidener +++ b/src/main/resources/firmament.accesswidener @@ -4,3 +4,4 @@ accessible class net/minecraft/client/render/RenderLayer$MultiPhaseParameters accessible class net/minecraft/client/font/TextRenderer$Drawer accessible class net/minecraft/client/render/model/ModelLoader$BakerImpl accessible method net/minecraft/client/render/model/ModelLoader$BakerImpl (Lnet/minecraft/client/render/model/ModelLoader;Ljava/util/function/BiFunction;Lnet/minecraft/util/Identifier;)V +accessible field net/minecraft/client/texture/PlayerSkinProvider TEXTURES Ljava/lang/String; -- cgit