From db57ced2bba5d43d2d7c6d4b9d3a0390b55e2456 Mon Sep 17 00:00:00 2001 From: creeper123123321 <7974274+creeper123123321@users.noreply.github.com> Date: Sat, 18 Dec 2021 07:52:59 -0300 Subject: [PATCH] return native version on server-side, allow untested mc versions closes #165 --- .../viaversion/fabric/common/platform/FabricInjector.java | 8 ++++++++ src/main/resources/fabric.mod.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/viaversion/fabric/common/platform/FabricInjector.java b/src/main/java/com/viaversion/fabric/common/platform/FabricInjector.java index f3ed00f..6997b33 100644 --- a/src/main/java/com/viaversion/fabric/common/platform/FabricInjector.java +++ b/src/main/java/com/viaversion/fabric/common/platform/FabricInjector.java @@ -1,11 +1,15 @@ package com.viaversion.fabric.common.platform; 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 net.fabricmc.api.EnvType; +import net.fabricmc.loader.api.FabricLoader; public class FabricInjector implements ViaInjector { @Override @@ -35,6 +39,10 @@ public class FabricInjector implements ViaInjector { @Override public IntSortedSet getServerProtocolVersions() { + if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER) { + int version = Via.getManager().getProviders().get(NativeVersionProvider.class).getNativeServerVersion(); + return IntSortedSets.singleton(version); + } // On client-side we can connect to any server version IntSortedSet versions = new IntLinkedOpenHashSet(); versions.add(ProtocolVersion.v1_7_1.getOriginalVersion()); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index a44cb1e..fc5c55f 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -13,7 +13,7 @@ }, "depends": { "fabricloader": ">=0.10.0", - "minecraft": ["1.8.9", "1.14.4", "1.15.2", "1.16.5", "1.17.1", "1.18.x"], + "minecraft": ["1.8.x", "1.14.x", "1.15.x", "1.16.x", "1.17.x", "1.18.x"], "viaversion": ">=4.0.0" }, "environment": "*",