From 9a52ae4c4aa076ef6920cb6996172a6401b9c904 Mon Sep 17 00:00:00 2001 From: FlorianMichael <60033407+FlorianMichael@users.noreply.github.com> Date: Fri, 26 Apr 2024 16:50:42 +0200 Subject: [PATCH] Update Via* to support 1.20.5 --- .../fixes/data/ResourcePackHeaderDiff.java | 1 + .../viaversion/MixinProtocolVersion.java | 89 ------------------- src/main/resources/viafabricplus.mixins.json | 3 +- 3 files changed, 2 insertions(+), 91 deletions(-) delete mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/viaversion/MixinProtocolVersion.java diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/data/ResourcePackHeaderDiff.java b/src/main/java/de/florianmichael/viafabricplus/fixes/data/ResourcePackHeaderDiff.java index 7ec91dc1..19f82dfc 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/data/ResourcePackHeaderDiff.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/data/ResourcePackHeaderDiff.java @@ -38,6 +38,7 @@ public class ResourcePackHeaderDiff { private final static Map GAME_VERSION_DIFF = new HashMap<>(); static { + registerVersion(ProtocolVersion.v1_20_5, 32, "1.20.5"); registerVersion(ProtocolVersion.v1_20_3, 22, "1.20.4"); registerVersion(ProtocolVersion.v1_20_2, 18, "1.20.2"); registerVersion(ProtocolVersion.v1_20, 15, "1.20.1"); diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/viaversion/MixinProtocolVersion.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/viaversion/MixinProtocolVersion.java deleted file mode 100644 index ccbbe470..00000000 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/viaversion/MixinProtocolVersion.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus - * Copyright (C) 2021-2024 FlorianMichael/EnZaXD and RK_01/RaphiMC - * Copyright (C) 2023-2024 contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.florianmichael.viafabricplus.injection.mixin.viaversion; - -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viaversion.api.protocol.version.SubVersionRange; -import com.viaversion.viaversion.util.Pair; -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.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.HashMap; -import java.util.Map; - -@Mixin(value = ProtocolVersion.class, remap = false) -public abstract class MixinProtocolVersion { - - @Unique - private static Map> viaFabricPlus$remaps; - - @Inject(method = "", at = @At("HEAD")) - private static void initMaps(CallbackInfo ci) { - viaFabricPlus$remaps = new HashMap<>(); - viaFabricPlus$remaps.put("1.9.3/1.9.4", new Pair<>("1.9.3-1.9.4", null)); - viaFabricPlus$remaps.put("1.11.1/1.11.2", new Pair<>("1.11.1-1.11.2", null)); - viaFabricPlus$remaps.put("1.16.4/1.16.5", new Pair<>("1.16.4-1.16.5", null)); - viaFabricPlus$remaps.put("1.18/1.18.1", new Pair<>("1.18-1.18.1", null)); - viaFabricPlus$remaps.put("1.19.1/1.19.2", new Pair<>("1.19.1-1.19.2", null)); - viaFabricPlus$remaps.put("1.20/1.20.1", new Pair<>("1.20-1.20.1", null)); - viaFabricPlus$remaps.put("1.20.3/1.20.4", new Pair<>("1.20.3-1.20.4", null)); - viaFabricPlus$remaps.put("1.20.5", new Pair<>("24w09a", null)); - } - - @Redirect(method = "", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/protocol/version/ProtocolVersion;register(ILjava/lang/String;)Lcom/viaversion/viaversion/api/protocol/version/ProtocolVersion;")) - private static ProtocolVersion unregisterAndRenameVersions(int version, String name) { - final Pair remapEntry = viaFabricPlus$remaps.get(name); - if (remapEntry != null) { - if (remapEntry.key() != null) name = remapEntry.key(); - if (remapEntry.value() != null) { - return ProtocolVersion.register(version, name, remapEntry.value()); - } - } - - return ProtocolVersion.register(version, name); - } - - @SuppressWarnings({"UnresolvedMixinReference", "MixinAnnotationTarget", "InvalidInjectorMethodSignature"}) // Optional injection - @Redirect(method = "", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/protocol/version/ProtocolVersion;register(IILjava/lang/String;)Lcom/viaversion/viaversion/api/protocol/version/ProtocolVersion;"), require = 0) - private static ProtocolVersion unregisterAndRenameVersions(int version, int snapshotVersion, String name) { - final Pair remapEntry = viaFabricPlus$remaps.get(name); - if (remapEntry != null) { - if (remapEntry.key() != null) name = remapEntry.key(); - } - - return ProtocolVersion.register(version, snapshotVersion, name); - } - - @Redirect(method = "", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/protocol/version/ProtocolVersion;register(ILjava/lang/String;Lcom/viaversion/viaversion/api/protocol/version/SubVersionRange;)Lcom/viaversion/viaversion/api/protocol/version/ProtocolVersion;")) - private static ProtocolVersion unregisterAndRenameVersions(int version, String name, SubVersionRange versionRange) { - final Pair remapEntry = viaFabricPlus$remaps.get(name); - if (remapEntry != null) { - if (remapEntry.key() != null) name = remapEntry.key(); - if (remapEntry.value() != null) versionRange = remapEntry.value(); - } - - return ProtocolVersion.register(version, name, versionRange); - } - -} diff --git a/src/main/resources/viafabricplus.mixins.json b/src/main/resources/viafabricplus.mixins.json index 7faa9fd3..6d60fc51 100644 --- a/src/main/resources/viafabricplus.mixins.json +++ b/src/main/resources/viafabricplus.mixins.json @@ -200,8 +200,7 @@ "viabedrock.MixinBedrockProtocol", "viabedrock.MixinJoinPackets", "vialegacy.MixinExtensionProtocolMetadataStorage", - "vialegacy.MixinViaLegacyConfig", - "viaversion.MixinProtocolVersion" + "vialegacy.MixinViaLegacyConfig" ], "injectors": { "defaultRequire": 1