Port to upstream changes (maybe)

This commit is contained in:
FlorianMichael 2024-02-14 20:35:36 +01:00
parent 2971cdedeb
commit fbd46800c0
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
27 changed files with 107 additions and 63 deletions

View File

@ -2,7 +2,7 @@
org.gradle.jvmargs=-Xms32M -Xmx4G -XX:+UseG1GC -XX:+UseStringDeduplication
loader_version=0.15.6
viaver_version=4.10.0-24w06a-SNAPSHOT
viaver_version=4.10.0-24w07a-SNAPSHOT
yaml_version=2.2
publish_mc_versions=1.20.4, 1.19.4, 1.18.2, 1.17.1, 1.16.5, 1.15.2, 1.14.4, 1.12.2, 1.8.9

View File

@ -18,14 +18,15 @@
package com.viaversion.fabric.common.config;
import com.viaversion.fabric.common.util.ProtocolUtils;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
public interface AbstractViaConfigScreen {
String TITLE_TRANSLATE_ID = "gui.viafabric_config.title";
String VERSION_TRANSLATE_ID = "gui.protocol_version_field.name";
default int getProtocolTextColor(int version, boolean parsedValid) {
default int getProtocolTextColor(ProtocolVersion version, boolean parsedValid) {
if (!parsedValid) return 0xff0000; // Red
if (version == -1 || version == -2) return 0x5555FF; // Blue
if (!ProtocolUtils.isValid(version)) return 0x5555FF; // Blue
if (!ProtocolUtils.isSupportedClientSide(version)) return 0xFFA500; // Orange
return 0xE0E0E0; // Default
}

View File

@ -21,13 +21,15 @@ import com.viaversion.fabric.common.handler.CommonTransformer;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.platform.ViaInjector;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.libs.fastutil.ints.IntLinkedOpenHashSet;
import com.viaversion.viaversion.libs.fastutil.ints.IntSortedSet;
import com.viaversion.viaversion.libs.fastutil.ints.IntSortedSets;
import com.viaversion.viaversion.libs.gson.JsonObject;
import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet;
import it.unimi.dsi.fastutil.objects.ObjectSortedSet;
import it.unimi.dsi.fastutil.objects.ObjectSortedSets;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import java.util.OptionalInt;
public class FabricInjector implements ViaInjector {
@Override
public void inject() {
@ -55,23 +57,21 @@ public class FabricInjector implements ViaInjector {
}
@Override
public IntSortedSet getServerProtocolVersions() {
public ObjectSortedSet<ProtocolVersion> getServerProtocolVersions() {
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER) {
int version = Via.getManager().getProviders().get(NativeVersionProvider.class).getNativeServerVersion();
return IntSortedSets.singleton(version);
final ProtocolVersion version = Via.getManager().getProviders().get(NativeVersionProvider.class).getNativeServerProtocolVersion();
return ObjectSortedSets.singleton(version);
}
// On client-side we can connect to any server version
IntSortedSet versions = new IntLinkedOpenHashSet();
versions.add(ProtocolVersion.v1_8.getOriginalVersion());
versions.add(ProtocolVersion.getProtocols()
.stream()
.mapToInt(ProtocolVersion::getOriginalVersion)
.max().getAsInt());
ObjectSortedSet<ProtocolVersion> versions = new ObjectLinkedOpenHashSet<>();
versions.add(ProtocolVersion.v1_8);
final OptionalInt highestSupportedVersion = ProtocolVersion.getProtocols().stream().mapToInt(ProtocolVersion::getOriginalVersion).max();
versions.add(ProtocolVersion.getProtocol(highestSupportedVersion.getAsInt()));
return versions;
}
@Override
public int getServerProtocolVersion() {
return getServerProtocolVersions().firstInt();
public ProtocolVersion getServerProtocolVersion() {
return getServerProtocolVersions().first();
}
}

View File

@ -18,8 +18,20 @@
package com.viaversion.fabric.common.platform;
import com.viaversion.viaversion.ViaAPIBase;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import io.netty.buffer.ByteBuf;
import java.util.UUID;
public class FabricViaAPI extends ViaAPIBase<UUID> {
public class FabricViaAPI extends ViaAPIBase<UserConnection> {
@Override
public ProtocolVersion getPlayerProtocolVersion(UserConnection player) {
return player.getProtocolInfo().protocolVersion();
}
@Override
public void sendRawPacket(UserConnection player, ByteBuf packet) {
player.scheduleSendRawPacket(packet);
}
}

View File

@ -18,7 +18,13 @@
package com.viaversion.fabric.common.platform;
import com.viaversion.viaversion.api.platform.providers.Provider;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
public interface NativeVersionProvider extends Provider {
int getNativeServerVersion();
default ProtocolVersion getNativeServerProtocolVersion() {
return ProtocolVersion.getProtocol(getNativeServerVersion());
}
}

View File

@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.ViaAPI;
import com.viaversion.viaversion.api.configuration.ConfigurationProvider;
import com.viaversion.viaversion.api.configuration.ViaVersionConfig;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.platform.UnsupportedSoftware;
import com.viaversion.viaversion.api.platform.ViaPlatform;
import com.viaversion.viaversion.libs.gson.JsonArray;
@ -54,11 +55,11 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
public abstract class AbstractFabricPlatform implements ViaPlatform<UUID> {
public abstract class AbstractFabricPlatform implements ViaPlatform<UserConnection> {
private final Logger logger = new JLoggerToLog4j(LogManager.getLogger("ViaVersion"));
private FabricViaConfig config;
private File dataFolder;
private final ViaAPI<UUID> api;
private final ViaAPI<UserConnection> api;
{
api = new FabricViaAPI();
@ -148,7 +149,7 @@ public abstract class AbstractFabricPlatform implements ViaPlatform<UUID> {
}
@Override
public ViaAPI<UUID> getApi() {
public ViaAPI<UserConnection> getApi() {
return api;
}
@ -214,7 +215,7 @@ public abstract class AbstractFabricPlatform implements ViaPlatform<UUID> {
platformSpecific.add("mods", mods);
NativeVersionProvider ver = Via.getManager().getProviders().get(NativeVersionProvider.class);
if (ver != null) {
platformSpecific.addProperty("native version", ver.getNativeServerVersion());
platformSpecific.addProperty("native version", ver.getNativeServerProtocolVersion().getVersion());
}
return platformSpecific;
}

View File

@ -82,11 +82,11 @@ public abstract class AbstractFabricVersionProvider extends BaseVersionProvider
}
@Override
public int getClosestServerProtocol(UserConnection connection) throws Exception {
public ProtocolVersion getClosestServerProtocol(UserConnection connection) throws Exception {
if (connection.isClientSide()) {
ProtocolInfo info = Objects.requireNonNull(connection.getProtocolInfo());
if (!getConfig().isClientSideEnabled()) return info.getProtocolVersion();
if (!getConfig().isClientSideEnabled()) return info.protocolVersion();
int serverVer = getConfig().getClientSideVersion();
SocketAddress addr = connection.getChannel().remoteAddress();
@ -112,18 +112,20 @@ public abstract class AbstractFabricVersionProvider extends BaseVersionProvider
}
}
boolean blocked = checkAddressBlocked(addr);
boolean supported = ProtocolUtils.isSupported(serverVer, info.getProtocolVersion());
ProtocolVersion serverVersion = ProtocolVersion.getProtocol(serverVer);
handleMulticonnectPing(connection, info, blocked, serverVer);
boolean blocked = checkAddressBlocked(addr);
boolean supported = ProtocolUtils.isSupported(serverVersion, info.protocolVersion());
handleMulticonnectPing(connection, info, blocked, serverVersion);
if (blocked || !supported) serverVer = info.getProtocolVersion();
return serverVer;
return ProtocolVersion.getProtocol(serverVer);
}
NativeVersionProvider natProvider = Via.getManager().getProviders().get(NativeVersionProvider.class);
if (natProvider != null) {
return ProtocolVersion.getProtocol(natProvider.getNativeServerVersion()).getVersion();
return natProvider.getNativeServerProtocolVersion();
}
return super.getClosestServerProtocol(connection);
}
@ -135,15 +137,15 @@ public abstract class AbstractFabricVersionProvider extends BaseVersionProvider
|| isDisabled(((InetSocketAddress) addr).getAddress().getHostName()))));
}
private void handleMulticonnectPing(UserConnection connection, ProtocolInfo info, boolean blocked, int serverVer) throws Exception {
private void handleMulticonnectPing(UserConnection connection, ProtocolInfo info, boolean blocked, ProtocolVersion serverVer) throws Exception {
if (info.getState() == State.STATUS
&& info.getProtocolVersion() == -1
&& isMulticonnectHandler(connection.getChannel().pipeline())
&& (blocked || ProtocolUtils.isSupported(serverVer, getVersionForMulticonnect(serverVer)))) { // Intercept the connection
int multiconnectSuggestion = blocked ? -1 : getVersionForMulticonnect(serverVer);
getLogger().info("Sending " + ProtocolVersion.getProtocol(multiconnectSuggestion) + " for multiconnect version detector");
ProtocolVersion multiconnectSuggestion = blocked ? ProtocolVersion.unknown : getVersionForMulticonnect(serverVer);
getLogger().info("Sending " + multiconnectSuggestion + " for multiconnect version detector");
PacketWrapper newAnswer = PacketWrapper.create(ClientboundStatusPackets.STATUS_RESPONSE, null, connection);
newAnswer.write(Type.STRING, "{\"version\":{\"name\":\"viafabric integration\",\"protocol\":" + multiconnectSuggestion + "}}");
newAnswer.write(Type.STRING, "{\"version\":{\"name\":\"viafabric integration\",\"protocol\":" + multiconnectSuggestion.getVersion() + "}}");
newAnswer.send(info.getPipeline().contains(BaseProtocol1_16.class) ? BaseProtocol1_16.class : BaseProtocol1_7.class);
throw CancelException.generate();
}
@ -153,23 +155,23 @@ public abstract class AbstractFabricVersionProvider extends BaseVersionProvider
return false;
}
private int getVersionForMulticonnect(int clientSideVersion) {
private ProtocolVersion getVersionForMulticonnect(ProtocolVersion clientSideVersion) {
// https://github.com/ViaVersion/ViaVersion/blob/master/velocity/src/main/java/us/myles/ViaVersion/velocity/providers/VelocityVersionProvider.java
int[] compatibleProtocols = multiconnectSupportedVersions;
if (Arrays.binarySearch(compatibleProtocols, clientSideVersion) >= 0) {
if (Arrays.binarySearch(compatibleProtocols, clientSideVersion.getVersion()) >= 0) {
return clientSideVersion;
}
if (clientSideVersion < compatibleProtocols[0]) {
return compatibleProtocols[0];
if (clientSideVersion.getVersion() < compatibleProtocols[0]) {
return ProtocolVersion.getProtocol(compatibleProtocols[0]);
}
// TODO: This needs a better fix, i.e checking ProtocolRegistry to see if it would work.
for (int i = compatibleProtocols.length - 1; i >= 0; i--) {
int protocol = compatibleProtocols[i];
if (clientSideVersion > protocol && ProtocolVersion.isRegistered(protocol)) {
return protocol;
if (clientSideVersion.getVersion() > protocol && ProtocolVersion.isRegistered(protocol)) {
return ProtocolVersion.getProtocol(protocol);
}
}

View File

@ -25,14 +25,14 @@ import java.util.Arrays;
import java.util.stream.Stream;
public class ProtocolUtils {
public static boolean isSupportedClientSide(int server) {
public static boolean isSupportedClientSide(ProtocolVersion server) {
return isSupported(server, Via.getManager().getProviders()
.get(NativeVersionProvider.class)
.getNativeServerVersion());
.getNativeServerProtocolVersion());
}
public static boolean isSupported(int server, int client) {
return server == client || Via.getManager().getProtocolManager().getProtocolPath(client, server) != null;
public static boolean isSupported(ProtocolVersion server, ProtocolVersion client) {
return server.equals(client) || Via.getManager().getProtocolManager().getProtocolPath(client, server) != null;
}
public static String getProtocolName(int id) {
@ -40,6 +40,10 @@ public class ProtocolUtils {
return ProtocolVersion.getProtocol(id).getName();
}
public static boolean isValid(final ProtocolVersion version) {
return version.isKnown() && version.getVersion() != -2;
}
public static boolean isStartOfProtocolText(String s) {
try {
Integer.parseInt(s);

View File

@ -72,7 +72,8 @@ public class ViaFabric implements ModInitializer {
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
manager.init();
Via.getManager().getProtocolManager().registerBaseProtocol(HostnameParserProtocol.INSTANCE, Range.lessThan(Integer.MIN_VALUE));
HostnameParserProtocol.INSTANCE.initialize();
HostnameParserProtocol.INSTANCE.register(Via.getManager().getProviders());
ProtocolVersion.register(-2, "AUTO");
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);

View File

@ -20,6 +20,7 @@ package com.viaversion.fabric.mc112.gui;
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
import com.viaversion.fabric.mc112.ViaFabric;
import com.viaversion.fabric.common.util.ProtocolUtils;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
@ -95,7 +96,7 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen {
validProtocol = false;
}
protocolVersion.setEditableColor(getProtocolTextColor(newVersion, validProtocol));
protocolVersion.setEditableColor(getProtocolTextColor(ProtocolVersion.getProtocol(newVersion), validProtocol));
int finalNewVersion = newVersion;
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);

View File

@ -35,7 +35,7 @@ public class FabricNativeVersionProvider implements NativeVersionProvider {
}
ServerMetadata.Version version = MinecraftClient.getInstance().getServer().getServerMetadata().getVersion();
if (version == null) return ProtocolVersion.v1_8.getVersion();
if (version == null) return ProtocolVersion.v1_12_2.getVersion();
return version.getProtocolVersion();
}
@ -46,6 +46,6 @@ public class FabricNativeVersionProvider implements NativeVersionProvider {
} catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
}
return ProtocolVersion.v1_8.getVersion(); // fallback
return ProtocolVersion.v1_12_2.getVersion(); // fallback
}
}

View File

@ -86,7 +86,8 @@ public class ViaFabric implements ModInitializer {
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
manager.init();
Via.getManager().getProtocolManager().registerBaseProtocol(HostnameParserProtocol.INSTANCE, Range.lessThan(Integer.MIN_VALUE));
HostnameParserProtocol.INSTANCE.initialize();
HostnameParserProtocol.INSTANCE.register(Via.getManager().getProviders());
ProtocolVersion.register(-2, "AUTO");
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);

View File

@ -20,6 +20,7 @@ package com.viaversion.fabric.mc114.gui;
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
import com.viaversion.fabric.mc114.ViaFabric;
import com.viaversion.fabric.common.util.ProtocolUtils;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
@ -93,7 +94,7 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen {
}
}
protocolVersion.setEditableColor(getProtocolTextColor(newVersion, validProtocol));
protocolVersion.setEditableColor(getProtocolTextColor(ProtocolVersion.getProtocol(newVersion), validProtocol));
int finalNewVersion = newVersion;
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);

View File

@ -86,7 +86,8 @@ public class ViaFabric implements ModInitializer {
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
manager.init();
Via.getManager().getProtocolManager().registerBaseProtocol(HostnameParserProtocol.INSTANCE, Range.lessThan(Integer.MIN_VALUE));
HostnameParserProtocol.INSTANCE.initialize();
HostnameParserProtocol.INSTANCE.register(Via.getManager().getProviders());
ProtocolVersion.register(-2, "AUTO");
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);

View File

@ -20,6 +20,7 @@ package com.viaversion.fabric.mc115.gui;
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
import com.viaversion.fabric.mc115.ViaFabric;
import com.viaversion.fabric.common.util.ProtocolUtils;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
@ -93,7 +94,7 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen {
}
}
protocolVersion.setEditableColor(getProtocolTextColor(newVersion, validProtocol));
protocolVersion.setEditableColor(getProtocolTextColor(ProtocolVersion.getProtocol(newVersion), validProtocol));
int finalNewVersion = newVersion;
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);

View File

@ -88,7 +88,8 @@ public class ViaFabric implements ModInitializer {
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
manager.init();
Via.getManager().getProtocolManager().registerBaseProtocol(HostnameParserProtocol.INSTANCE, Range.lessThan(Integer.MIN_VALUE));
HostnameParserProtocol.INSTANCE.initialize();
HostnameParserProtocol.INSTANCE.register(Via.getManager().getProviders());
ProtocolVersion.register(-2, "AUTO");
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);

View File

@ -20,6 +20,7 @@ package com.viaversion.fabric.mc116.gui;
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
import com.viaversion.fabric.mc116.ViaFabric;
import com.viaversion.fabric.common.util.ProtocolUtils;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
@ -95,7 +96,7 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen {
}
}
protocolVersion.setEditableColor(getProtocolTextColor(newVersion, validProtocol));
protocolVersion.setEditableColor(getProtocolTextColor(ProtocolVersion.getProtocol(newVersion), validProtocol));
int finalNewVersion = newVersion;
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);

View File

@ -88,7 +88,8 @@ public class ViaFabric implements ModInitializer {
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
manager.init();
Via.getManager().getProtocolManager().registerBaseProtocol(HostnameParserProtocol.INSTANCE, Range.lessThan(Integer.MIN_VALUE));
HostnameParserProtocol.INSTANCE.initialize();
HostnameParserProtocol.INSTANCE.register(Via.getManager().getProviders());
ProtocolVersion.register(-2, "AUTO");
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);

View File

@ -20,6 +20,7 @@ package com.viaversion.fabric.mc117.gui;
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
import com.viaversion.fabric.mc117.ViaFabric;
import com.viaversion.fabric.common.util.ProtocolUtils;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
@ -95,7 +96,7 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen {
}
}
protocolVersion.setEditableColor(getProtocolTextColor(newVersion, validProtocol));
protocolVersion.setEditableColor(getProtocolTextColor(ProtocolVersion.getProtocol(newVersion), validProtocol));
int finalNewVersion = newVersion;
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);

View File

@ -88,7 +88,8 @@ public class ViaFabric implements ModInitializer {
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
manager.init();
Via.getManager().getProtocolManager().registerBaseProtocol(HostnameParserProtocol.INSTANCE, Range.lessThan(Integer.MIN_VALUE));
HostnameParserProtocol.INSTANCE.initialize();
HostnameParserProtocol.INSTANCE.register(Via.getManager().getProviders());
ProtocolVersion.register(-2, "AUTO");
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);

View File

@ -20,6 +20,7 @@ package com.viaversion.fabric.mc118.gui;
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
import com.viaversion.fabric.mc118.ViaFabric;
import com.viaversion.fabric.common.util.ProtocolUtils;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
@ -95,7 +96,7 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen {
}
}
protocolVersion.setEditableColor(getProtocolTextColor(newVersion, validProtocol));
protocolVersion.setEditableColor(getProtocolTextColor(ProtocolVersion.getProtocol(newVersion), validProtocol));
int finalNewVersion = newVersion;
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);

View File

@ -88,7 +88,8 @@ public class ViaFabric implements ModInitializer {
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
manager.init();
Via.getManager().getProtocolManager().registerBaseProtocol(HostnameParserProtocol.INSTANCE, Range.lessThan(Integer.MIN_VALUE));
HostnameParserProtocol.INSTANCE.initialize();
HostnameParserProtocol.INSTANCE.register(Via.getManager().getProviders());
ProtocolVersion.register(-2, "AUTO");
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);

View File

@ -20,6 +20,7 @@ package com.viaversion.fabric.mc119.gui;
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
import com.viaversion.fabric.mc119.ViaFabric;
import com.viaversion.fabric.common.util.ProtocolUtils;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
@ -99,7 +100,7 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen {
}
}
protocolVersion.setEditableColor(getProtocolTextColor(newVersion, validProtocol));
protocolVersion.setEditableColor(getProtocolTextColor(ProtocolVersion.getProtocol(newVersion), validProtocol));
int finalNewVersion = newVersion;
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);

View File

@ -88,7 +88,8 @@ public class ViaFabric implements ModInitializer {
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
manager.init();
Via.getManager().getProtocolManager().registerBaseProtocol(HostnameParserProtocol.INSTANCE, Range.lessThan(Integer.MIN_VALUE));
HostnameParserProtocol.INSTANCE.initialize();
HostnameParserProtocol.INSTANCE.register(Via.getManager().getProviders());
ProtocolVersion.register(-2, "AUTO");
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);

View File

@ -20,6 +20,7 @@ package com.viaversion.fabric.mc120.gui;
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
import com.viaversion.fabric.mc120.ViaFabric;
import com.viaversion.fabric.common.util.ProtocolUtils;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
@ -99,7 +100,7 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen {
}
}
protocolVersion.setEditableColor(getProtocolTextColor(newVersion, validProtocol));
protocolVersion.setEditableColor(getProtocolTextColor(ProtocolVersion.getProtocol(newVersion), validProtocol));
int finalNewVersion = newVersion;
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);

View File

@ -72,7 +72,8 @@ public class ViaFabric implements ModInitializer {
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
manager.init();
Via.getManager().getProtocolManager().registerBaseProtocol(HostnameParserProtocol.INSTANCE, Range.lessThan(Integer.MIN_VALUE));
HostnameParserProtocol.INSTANCE.initialize();
HostnameParserProtocol.INSTANCE.register(Via.getManager().getProviders());
ProtocolVersion.register(-2, "AUTO");
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);

View File

@ -20,6 +20,7 @@ package com.viaversion.fabric.mc18.gui;
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
import com.viaversion.fabric.mc18.ViaFabric;
import com.viaversion.fabric.common.util.ProtocolUtils;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
@ -95,7 +96,7 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen {
validProtocol = false;
}
protocolVersion.setEditableColor(getProtocolTextColor(newVersion, validProtocol));
protocolVersion.setEditableColor(getProtocolTextColor(ProtocolVersion.getProtocol(newVersion), validProtocol));
int finalNewVersion = newVersion;
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);