Update Via* to support 1.20.5

This commit is contained in:
FlorianMichael 2024-04-26 16:50:42 +02:00
parent 31a7c84a05
commit 9a52ae4c4a
3 changed files with 2 additions and 91 deletions

View File

@ -38,6 +38,7 @@ public class ResourcePackHeaderDiff {
private final static Map<ProtocolVersion, GameVersion> 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");

View File

@ -1,89 +0,0 @@
/*
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> 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 <http://www.gnu.org/licenses/>.
*/
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<String, Pair<String, SubVersionRange>> viaFabricPlus$remaps;
@Inject(method = "<clinit>", 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 = "<clinit>", 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<String, SubVersionRange> 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 = "<clinit>", 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<String, SubVersionRange> remapEntry = viaFabricPlus$remaps.get(name);
if (remapEntry != null) {
if (remapEntry.key() != null) name = remapEntry.key();
}
return ProtocolVersion.register(version, snapshotVersion, name);
}
@Redirect(method = "<clinit>", 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<String, SubVersionRange> 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);
}
}

View File

@ -200,8 +200,7 @@
"viabedrock.MixinBedrockProtocol",
"viabedrock.MixinJoinPackets",
"vialegacy.MixinExtensionProtocolMetadataStorage",
"vialegacy.MixinViaLegacyConfig",
"viaversion.MixinProtocolVersion"
"vialegacy.MixinViaLegacyConfig"
],
"injectors": {
"defaultRequire": 1