mirror of
https://github.com/ViaVersion/ViaFabric.git
synced 2024-11-22 11:45:47 +01:00
Use SharedConstants, use server version when starting it
This commit is contained in:
parent
1c9345ada5
commit
9d2103b011
@ -35,6 +35,7 @@ import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import io.github.cottonmc.clientcommands.ArgumentBuilders;
|
||||
import io.github.cottonmc.clientcommands.ClientCommands;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.fabric.events.ServerEvent;
|
||||
import net.fabricmc.loader.FabricLoader;
|
||||
import us.myles.ViaVersion.ViaManager;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
@ -78,5 +79,13 @@ public class VRViaVersionInitializer {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
ServerEvent.START.register(server -> {
|
||||
try {
|
||||
ProtocolRegistry.SERVER_PROTOCOL = Via.getManager().getInjector().getServerProtocolVersion();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ import io.netty.channel.DefaultEventLoop;
|
||||
import io.netty.channel.EventLoop;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.loader.FabricLoader;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.SharedConstants;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@ -95,7 +95,7 @@ public class ViaFabric implements ModInitializer {
|
||||
while (matcher.find()) {
|
||||
versions.add(matcher.group(1));
|
||||
}
|
||||
String mcVersion = MinecraftClient.getInstance().getGame().getVersion().getName();
|
||||
String mcVersion = SharedConstants.getGameVersion().getName();
|
||||
String bestViaVersion = null;
|
||||
if (mcVersion.contains("w") || mcVersion.contains("-")) {
|
||||
bestViaVersion = versions.stream()
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
package com.github.creeper123123321.viafabric.platform;
|
||||
|
||||
import net.minecraft.client.options.ServerEntry;
|
||||
import net.minecraft.SharedConstants;
|
||||
import us.myles.ViaVersion.api.platform.ViaInjector;
|
||||
|
||||
public class VRInjector implements ViaInjector {
|
||||
@ -40,7 +40,7 @@ public class VRInjector implements ViaInjector {
|
||||
|
||||
@Override
|
||||
public int getServerProtocolVersion() {
|
||||
return new ServerEntry("", "", false).protocolVersion;
|
||||
return SharedConstants.getGameVersion().getProtocolVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user