mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2025-01-08 19:38:57 +01:00
Fixed incompatible version string being visible on <= 1.6.4 servers
Updated ViaVersion and ViaBackwards
This commit is contained in:
parent
4e6ed57fa5
commit
18a6c449d1
@ -14,7 +14,7 @@
|
||||
# Why another protocol translator?
|
||||
ViaFabricPlus is intended to replace [multiconnect](https://github.com/Earthcomputer/multiconnect), and it also promises more compactness and stability. ViaFabricPlus can do everything multiconnect could do, but supports more Minecraft versions (listed below) and has more protocol changes implemented.
|
||||
### Supported Server versions
|
||||
- Release (1.0.0 - 1.20.1)
|
||||
- Release (1.0.0 - 1.20.2 [23w32a])
|
||||
- Beta (b1.0 - b1.8.1)
|
||||
- Alpha (a1.0.15 - a1.2.6)
|
||||
- Classic (c0.0.15 - c0.30 including [CPE](https://wiki.vg/Classic_Protocol_Extension))
|
||||
|
@ -18,15 +18,15 @@ raknet_transport_version=1.0.0.CR1-SNAPSHOT
|
||||
classic4j_version=1.2.0
|
||||
|
||||
# viaversion (and required) libs
|
||||
viaversion_version=4.7.1-SNAPSHOT
|
||||
viabackwards_version=4.7.1-SNAPSHOT
|
||||
viaversion_version=4.8.0-23w32a-SNAPSHOT
|
||||
viabackwards_version=4.8.0-23w32a-SNAPSHOT
|
||||
|
||||
# raphimc libs
|
||||
vialegacy_version=2.2.18-SNAPSHOT
|
||||
viaaprilfools_version=2.0.8-SNAPSHOT
|
||||
vialegacy_version=2.2.19-SNAPSHOT
|
||||
viaaprilfools_version=2.0.9-SNAPSHOT
|
||||
viabedrock_version=0.0.2-SNAPSHOT
|
||||
minecraftauth_version=2.1.4-SNAPSHOT
|
||||
vialoader_version=2.2.8-SNAPSHOT
|
||||
vialoader_version=2.2.9-SNAPSHOT
|
||||
|
||||
# lenni0451 libs
|
||||
reflect_version=1.2.2
|
||||
|
@ -17,8 +17,6 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.definition;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.network.AllowedAddressResolver;
|
||||
import net.minecraft.client.network.ServerAddress;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialoader.util.VersionRange;
|
||||
@ -27,7 +25,6 @@ public class LegacyServerAddress {
|
||||
public final static VersionRange SRV_RANGE = VersionRange.andOlder(VersionEnum.r1_2_4tor1_2_5).add(VersionRange.single(VersionEnum.bedrockLatest));
|
||||
|
||||
public static ServerAddress parse(VersionEnum version, String address) {
|
||||
if (version == null) version = ProtocolHack.getTargetVersion();
|
||||
final ServerAddress modern = ServerAddress.parse(address);
|
||||
if (SRV_RANGE.contains(version) && !modern.equals(ServerAddress.INVALID)) {
|
||||
final var addressParts = address.split(":");
|
||||
|
@ -18,7 +18,7 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
|
||||
import de.florianmichael.viafabricplus.definition.LegacyServerAddress;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.screen.impl.base.ProtocolSelectionScreen;
|
||||
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
@ -66,6 +66,6 @@ public class MixinMultiplayerScreen extends Screen {
|
||||
|
||||
@Redirect(method = "connect(Lnet/minecraft/client/network/ServerInfo;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ServerAddress;parse(Ljava/lang/String;)Lnet/minecraft/client/network/ServerAddress;"))
|
||||
public ServerAddress doOwnParse(String address) {
|
||||
return LegacyServerAddress.parse(((IServerInfo) viafabricplus_lastConnect).viafabricplus_forcedVersion(), address);
|
||||
return LegacyServerAddress.parse(ProtocolHack.getTargetVersion(viafabricplus_lastConnect), address);
|
||||
}
|
||||
}
|
||||
|
@ -19,16 +19,20 @@ package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
|
||||
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
|
||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerServerListWidget;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.text.Text;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
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.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -52,4 +56,12 @@ public class MixinMultiplayerServerListWidget_ServerEntry {
|
||||
}
|
||||
instance.setMultiplayerScreenTooltip(tooltipOverwrite);
|
||||
}
|
||||
|
||||
@Inject(method = "protocolVersionMatches", at = @At("HEAD"), cancellable = true)
|
||||
public void supportViaLegacyVersionRanges(CallbackInfoReturnable<Boolean> cir) {
|
||||
final var version = ProtocolHack.getTargetVersion(server);
|
||||
if (version.isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
cir.setReturnValue(LegacyProtocolVersion.getRealProtocolVersion(version.getVersion()) == server.protocolVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
import com.google.common.net.HostAndPort;
|
||||
import de.florianmichael.viafabricplus.definition.LegacyServerAddress;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.lenni0451.reflect.stream.RStream;
|
||||
import net.minecraft.client.network.MultiplayerServerListPinger;
|
||||
import net.minecraft.client.network.ServerAddress;
|
||||
@ -35,7 +36,7 @@ public class MixinMultiplayerServerListPinger {
|
||||
|
||||
@Inject(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AllowedAddressResolver;resolve(Lnet/minecraft/client/network/ServerAddress;)Ljava/util/Optional;"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
public void mapParsing(ServerInfo entry, Runnable saver, CallbackInfo ci, ServerAddress serverAddress) {
|
||||
final ServerAddress remapped = LegacyServerAddress.parse(((IServerInfo) entry).viafabricplus_forcedVersion(), serverAddress.hostAndPort.toString());
|
||||
final ServerAddress remapped = LegacyServerAddress.parse(ProtocolHack.getTargetVersion(entry), serverAddress.hostAndPort.toString());
|
||||
RStream.of(serverAddress).fields().filter(HostAndPort.class).by(0).set(RStream.of(remapped).fields().filter(HostAndPort.class).by(0).get());
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
public class MixinNBTType {
|
||||
|
||||
@Unique
|
||||
private final TagLimiter viafabricplus_tag_limiter = new TagLimiter() {
|
||||
private static final TagLimiter viafabricplus_tag_limiter = new TagLimiter() {
|
||||
private final int maxBytes = 2097152;
|
||||
private int bytes;
|
||||
|
||||
@ -59,8 +59,8 @@ public class MixinNBTType {
|
||||
}
|
||||
};
|
||||
|
||||
@Redirect(method = "read(Lio/netty/buffer/ByteBuf;)Lcom/viaversion/viaversion/libs/opennbt/tag/builtin/CompoundTag;", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/libs/opennbt/tag/limiter/TagLimiter;create(II)Lcom/viaversion/viaversion/libs/opennbt/tag/limiter/TagLimiter;"))
|
||||
public TagLimiter replaceTagLimiter(int maxBytes, int maxLevels) {
|
||||
return this.viafabricplus_tag_limiter;
|
||||
@Redirect(method = "read(Lio/netty/buffer/ByteBuf;Z)Lcom/viaversion/viaversion/libs/opennbt/tag/builtin/CompoundTag;", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/libs/opennbt/tag/limiter/TagLimiter;create(II)Lcom/viaversion/viaversion/libs/opennbt/tag/limiter/TagLimiter;"))
|
||||
private static TagLimiter replaceTagLimiter(int maxBytes, int maxLevels) {
|
||||
return viafabricplus_tag_limiter;
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.protocol.version.VersionRange;
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
@ -47,6 +46,7 @@ public abstract class MixinProtocolVersion {
|
||||
viafabricplus_remaps.put("1.18/1.18.1", new Pair<>("1.18-1.18.1", null));
|
||||
viafabricplus_remaps.put("1.19.1/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.2", new Pair<>("23w32a", 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;"))
|
||||
|
@ -28,6 +28,7 @@ import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.storage.Inventor
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.base.event.ChangeProtocolVersionCallback;
|
||||
import de.florianmichael.viafabricplus.base.event.FinishViaVersionStartupCallback;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import de.florianmichael.viafabricplus.protocolhack.command.ViaFabricPlusVLCommandHandler;
|
||||
import de.florianmichael.viafabricplus.protocolhack.impl.ViaFabricPlusVLInjector;
|
||||
import de.florianmichael.viafabricplus.protocolhack.impl.ViaFabricPlusVLLoader;
|
||||
@ -39,6 +40,7 @@ import io.netty.util.AttributeKey;
|
||||
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.raphimc.vialoader.ViaLoader;
|
||||
import net.raphimc.vialoader.impl.platform.ViaAprilFoolsPlatformImpl;
|
||||
@ -117,6 +119,19 @@ public class ProtocolHack {
|
||||
return targetVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used when you need the target version while connecting to the server after Netty is started and after ViaVersion is finished loading.
|
||||
*
|
||||
* @param serverInfo the current server info
|
||||
* @return the target version
|
||||
*/
|
||||
public static VersionEnum getTargetVersion(final ServerInfo serverInfo) {
|
||||
final var forcedVersion = ((IServerInfo) serverInfo).viafabricplus_forcedVersion();
|
||||
if (forcedVersion == null) return getTargetVersion();
|
||||
|
||||
return forcedVersion;
|
||||
}
|
||||
|
||||
public static Map<InetSocketAddress, VersionEnum> getForcedVersions() {
|
||||
return forcedVersions;
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import de.florianmichael.classic4j.model.betacraft.BCServerInfo;
|
||||
import de.florianmichael.classic4j.model.betacraft.BCServerList;
|
||||
import de.florianmichael.classic4j.model.betacraft.BCVersion;
|
||||
import de.florianmichael.viafabricplus.definition.LegacyServerAddress;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.screen.MappedSlotEntry;
|
||||
import de.florianmichael.viafabricplus.screen.VFPScreen;
|
||||
import de.florianmichael.viafabricplus.screen.impl.settings.settingrenderer.meta.TitleRenderer;
|
||||
@ -106,7 +107,7 @@ public class BetaCraftScreen extends VFPScreen {
|
||||
|
||||
@Override
|
||||
public void mappedMouseClicked(double mouseX, double mouseY, int button) {
|
||||
final ServerAddress serverAddress = LegacyServerAddress.parse(null, server.host() + ":" + server.port());
|
||||
final ServerAddress serverAddress = LegacyServerAddress.parse(ProtocolHack.getTargetVersion(), server.host() + ":" + server.port());
|
||||
final ServerInfo entry = new ServerInfo(server.name(), serverAddress.getAddress(), false);
|
||||
|
||||
ConnectScreen.connect(MinecraftClient.getInstance().currentScreen, MinecraftClient.getInstance(), serverAddress, entry, false);
|
||||
|
Loading…
Reference in New Issue
Block a user