diff --git a/src/main/java/com/viaversion/fabric/common/platform/AbstractFabricInjector.java b/src/main/java/com/viaversion/fabric/common/platform/AbstractFabricInjector.java deleted file mode 100644 index 8a9c2da..0000000 --- a/src/main/java/com/viaversion/fabric/common/platform/AbstractFabricInjector.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.viaversion.fabric.common.platform; - -import com.viaversion.fabric.common.handler.CommonTransformer; -import com.viaversion.viaversion.api.platform.ViaInjector; -import com.viaversion.viaversion.libs.gson.JsonObject; - -public abstract class AbstractFabricInjector implements ViaInjector { - @Override - public void inject() { - // *looks at Mixins* - } - - @Override - public void uninject() { - // not possible *plays sad violin* - } - - @Override - public String getEncoderName() { - return CommonTransformer.HANDLER_ENCODER_NAME; - } - - @Override - public String getDecoderName() { - return CommonTransformer.HANDLER_DECODER_NAME; - } - - @Override - public JsonObject getDump() { - return new JsonObject(); - } -} diff --git a/src/main/java/com/viaversion/fabric/common/platform/FabricInjector.java b/src/main/java/com/viaversion/fabric/common/platform/FabricInjector.java new file mode 100644 index 0000000..716cea8 --- /dev/null +++ b/src/main/java/com/viaversion/fabric/common/platform/FabricInjector.java @@ -0,0 +1,52 @@ +package com.viaversion.fabric.common.platform; + +import com.viaversion.fabric.common.handler.CommonTransformer; +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.gson.JsonObject; + +public class FabricInjector implements ViaInjector { + @Override + public void inject() { + // *looks at Mixins* + } + + @Override + public void uninject() { + // not possible *plays sad violin* + } + + @Override + public String getEncoderName() { + return CommonTransformer.HANDLER_ENCODER_NAME; + } + + @Override + public String getDecoderName() { + return CommonTransformer.HANDLER_DECODER_NAME; + } + + @Override + public JsonObject getDump() { + return new JsonObject(); + } + + @Override + public IntSortedSet getServerProtocolVersions() { + // On client-side we can connect to any server version + IntSortedSet versions = new IntLinkedOpenHashSet(); + versions.add(ProtocolVersion.v1_7_1.getOriginalVersion()); + versions.add(ProtocolVersion.getProtocols() + .stream() + .mapToInt(ProtocolVersion::getOriginalVersion) + .max().getAsInt()); + return versions; + } + + @Override + public int getServerProtocolVersion() throws Exception { + return getServerProtocolVersions().firstInt(); + } +} diff --git a/src/main/java/com/viaversion/fabric/common/platform/FabricViaConfig.java b/src/main/java/com/viaversion/fabric/common/platform/FabricViaConfig.java index a7224d7..82194d5 100644 --- a/src/main/java/com/viaversion/fabric/common/platform/FabricViaConfig.java +++ b/src/main/java/com/viaversion/fabric/common/platform/FabricViaConfig.java @@ -35,34 +35,4 @@ public class FabricViaConfig extends AbstractViaConfig { public List getUnsupportedOptions() { return UNSUPPORTED; } - - @Override - public boolean isAntiXRay() { - return false; - } - - @Override - public boolean isNMSPlayerTicking() { - return false; - } - - @Override - public boolean is1_12QuickMoveActionFix() { - return false; - } - - @Override - public String getBlockConnectionMethod() { - return "packet"; - } - - @Override - public boolean is1_9HitboxFix() { - return false; - } - - @Override - public boolean is1_14HitboxFix() { - return false; - } } diff --git a/src/main/java/com/viaversion/fabric/common/provider/AbstractFabricPlatform.java b/src/main/java/com/viaversion/fabric/common/provider/AbstractFabricPlatform.java index 65739c7..6339e61 100644 --- a/src/main/java/com/viaversion/fabric/common/provider/AbstractFabricPlatform.java +++ b/src/main/java/com/viaversion/fabric/common/provider/AbstractFabricPlatform.java @@ -35,7 +35,8 @@ public abstract class AbstractFabricPlatform implements ViaPlatform { @Override public boolean isProxy() { - return false; + // We kinda of have all server versions + return true; } @Override diff --git a/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/ViaFabric.java b/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/ViaFabric.java index 6daa57f..5a7f819 100644 --- a/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/ViaFabric.java +++ b/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/ViaFabric.java @@ -1,8 +1,8 @@ package com.viaversion.fabric.mc114; import com.viaversion.fabric.common.config.VFConfig; +import com.viaversion.fabric.common.platform.FabricInjector; import com.viaversion.fabric.mc114.commands.VRCommandHandler; -import com.viaversion.fabric.mc114.platform.FabricInjector; import com.viaversion.fabric.mc114.platform.VFLoader; import com.viaversion.fabric.mc114.platform.FabricPlatform; import com.viaversion.fabric.common.protocol.HostnameParserProtocol; diff --git a/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/platform/FabricInjector.java b/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/platform/FabricInjector.java deleted file mode 100644 index 5d176a6..0000000 --- a/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/platform/FabricInjector.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.viaversion.fabric.mc114.platform; - -import com.viaversion.fabric.common.platform.AbstractFabricInjector; -import net.minecraft.SharedConstants; - -public class FabricInjector extends AbstractFabricInjector { - @Override - public int getServerProtocolVersion() { - return SharedConstants.getGameVersion().getProtocolVersion(); - } -} diff --git a/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/ViaFabric.java b/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/ViaFabric.java index c46d6e3..fd7c3db 100644 --- a/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/ViaFabric.java +++ b/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/ViaFabric.java @@ -6,10 +6,10 @@ import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.RequiredArgumentBuilder; import com.viaversion.fabric.common.config.VFConfig; +import com.viaversion.fabric.common.platform.FabricInjector; import com.viaversion.fabric.common.protocol.HostnameParserProtocol; import com.viaversion.fabric.common.util.JLoggerToLog4j; import com.viaversion.fabric.mc115.commands.VRCommandHandler; -import com.viaversion.fabric.mc115.platform.FabricInjector; import com.viaversion.fabric.mc115.platform.VFLoader; import com.viaversion.fabric.mc115.platform.FabricPlatform; import com.viaversion.viaversion.ViaManagerImpl; diff --git a/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/platform/FabricInjector.java b/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/platform/FabricInjector.java deleted file mode 100644 index 919f4c3..0000000 --- a/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/platform/FabricInjector.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.viaversion.fabric.mc115.platform; - -import com.viaversion.fabric.common.platform.AbstractFabricInjector; -import net.minecraft.SharedConstants; - -public class FabricInjector extends AbstractFabricInjector { - @Override - public int getServerProtocolVersion() { - return SharedConstants.getGameVersion().getProtocolVersion(); - } -} diff --git a/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/ViaFabric.java b/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/ViaFabric.java index 8aaedfd..d5003b3 100644 --- a/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/ViaFabric.java +++ b/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/ViaFabric.java @@ -1,8 +1,8 @@ package com.viaversion.fabric.mc116; import com.viaversion.fabric.common.config.VFConfig; +import com.viaversion.fabric.common.platform.FabricInjector; import com.viaversion.fabric.mc116.commands.VRCommandHandler; -import com.viaversion.fabric.mc116.platform.FabricInjector; import com.viaversion.fabric.mc116.platform.VFLoader; import com.viaversion.fabric.mc116.platform.FabricPlatform; import com.viaversion.fabric.common.protocol.HostnameParserProtocol; diff --git a/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/platform/FabricInjector.java b/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/platform/FabricInjector.java deleted file mode 100644 index 486fea2..0000000 --- a/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/platform/FabricInjector.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.viaversion.fabric.mc116.platform; - -import com.viaversion.fabric.common.platform.AbstractFabricInjector; -import net.minecraft.SharedConstants; - -public class FabricInjector extends AbstractFabricInjector { - @Override - public int getServerProtocolVersion() { - return SharedConstants.getGameVersion().getProtocolVersion(); - } -} diff --git a/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/ViaFabric.java b/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/ViaFabric.java index bc3bd12..9a3b7f7 100644 --- a/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/ViaFabric.java +++ b/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/ViaFabric.java @@ -1,8 +1,8 @@ package com.viaversion.fabric.mc117; import com.viaversion.fabric.common.config.VFConfig; +import com.viaversion.fabric.common.platform.FabricInjector; import com.viaversion.fabric.mc117.commands.VRCommandHandler; -import com.viaversion.fabric.mc117.platform.FabricInjector; import com.viaversion.fabric.mc117.platform.VFLoader; import com.viaversion.fabric.mc117.platform.FabricPlatform; import com.viaversion.fabric.common.protocol.HostnameParserProtocol; diff --git a/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/platform/FabricInjector.java b/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/platform/FabricInjector.java deleted file mode 100644 index 2f07f6c..0000000 --- a/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/platform/FabricInjector.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.viaversion.fabric.mc117.platform; - -import com.viaversion.fabric.common.handler.CommonTransformer; -import com.viaversion.fabric.common.platform.AbstractFabricInjector; -import com.viaversion.viaversion.libs.gson.JsonObject; -import com.viaversion.viaversion.util.GsonUtil; -import net.fabricmc.api.EnvType; -import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.SharedConstants; - -import java.lang.reflect.Method; -import java.util.Arrays; - -public class FabricInjector extends AbstractFabricInjector { - @Override - public int getServerProtocolVersion() { - return SharedConstants.getGameVersion().getProtocolVersion(); - } - - public String getDecoderName() { - return CommonTransformer.HANDLER_DECODER_NAME; - } - - @Override - public JsonObject getDump() { - JsonObject obj = new JsonObject(); - try { - obj.add("serverNetworkIOChInit", GsonUtil.getGson().toJsonTree( - Arrays.stream(Class.forName("net.minecraft.class_3242$1").getDeclaredMethods()) - .map(Method::toString) - .toArray(String[]::new))); - } catch (ClassNotFoundException ignored) { - } - if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { - try { - obj.add("clientConnectionChInit", GsonUtil.getGson().toJsonTree( - Arrays.stream(Class.forName("net.minecraft.class_2535$1").getDeclaredMethods()) - .map(Method::toString) - .toArray(String[]::new))); - } catch (ClassNotFoundException ignored) { - } - } - return obj; - } -} diff --git a/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/ViaFabric.java b/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/ViaFabric.java index 8b17243..727b25a 100644 --- a/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/ViaFabric.java +++ b/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/ViaFabric.java @@ -1,9 +1,9 @@ package com.viaversion.fabric.mc18; +import com.viaversion.fabric.common.platform.FabricInjector; import com.viaversion.fabric.mc18.commands.NMSCommandImpl; import com.viaversion.fabric.mc18.commands.VRCommandHandler; import com.viaversion.fabric.common.config.VFConfig; -import com.viaversion.fabric.mc18.platform.FabricInjector; import com.viaversion.fabric.mc18.platform.VFLoader; import com.viaversion.fabric.mc18.platform.FabricPlatform; import com.viaversion.fabric.common.protocol.HostnameParserProtocol; diff --git a/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/platform/FabricInjector.java b/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/platform/FabricInjector.java deleted file mode 100644 index 26ae3b9..0000000 --- a/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/platform/FabricInjector.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.viaversion.fabric.mc18.platform; - -import com.viaversion.fabric.common.platform.AbstractFabricInjector; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.realms.RealmsSharedConstants; -import net.minecraft.server.MinecraftServer; - -public class FabricInjector extends AbstractFabricInjector { - @Override - public int getServerProtocolVersion() throws NoSuchFieldException, IllegalAccessException { - if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { - return getClientProtocol(); - } - return MinecraftServer.getServer().getServerMetadata().getVersion().getProtocolVersion(); - } - - @Environment(EnvType.CLIENT) - private int getClientProtocol() throws NoSuchFieldException, IllegalAccessException { - return RealmsSharedConstants.class.getField("NETWORK_PROTOCOL_VERSION").getInt(null); - } -}