We're now a pseudoproxy, fixes #142

This commit is contained in:
creeper123123321 2021-07-16 11:28:44 -03:00
parent 28958d9491
commit b1e5645a2c
14 changed files with 59 additions and 169 deletions

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -35,34 +35,4 @@ public class FabricViaConfig extends AbstractViaConfig {
public List<String> 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;
}
}

View File

@ -35,7 +35,8 @@ public abstract class AbstractFabricPlatform implements ViaPlatform<UUID> {
@Override
public boolean isProxy() {
return false;
// We kinda of have all server versions
return true;
}
@Override

View File

@ -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;

View File

@ -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();
}
}

View File

@ -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;

View File

@ -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();
}
}

View File

@ -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;

View File

@ -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();
}
}

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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);
}
}