Skip to content

Commit

Permalink
fix version sent in 1.8/1.12 detector
Browse files Browse the repository at this point in the history
  • Loading branch information
creeper123123321 committed May 13, 2024
1 parent bab3522 commit 9065c52
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 29 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ modrinth {
dependencies {
optional.project "P7dR8mSH" // fabric api
optional.project "9CJED7xi" // legacy fabric api
embedded.project "P1OZGk5p" // viaversion
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.viaversion.fabric.mc1122.mixin.pipeline.client;

import net.minecraft.network.packet.c2s.handshake.HandshakeC2SPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(HandshakeC2SPacket.class)
public interface MixinHandshakeC2SPacketAccessor {
@Accessor
void setProtocolVersion(int version);
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.viaversion.fabric.mc1122.mixin.pipeline.client.MixinHandshakeC2SPacketAccessor;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.*;
import io.netty.channel.socket.nio.NioSocketChannel;
Expand All @@ -34,6 +35,7 @@
import net.minecraft.network.packet.c2s.query.QueryRequestC2SPacket;
import net.minecraft.network.packet.s2c.query.QueryPongS2CPacket;
import net.minecraft.network.packet.s2c.query.QueryResponseS2CPacket;
import net.minecraft.realms.RealmsSharedConstants;
import net.minecraft.server.ServerMetadata;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
Expand Down Expand Up @@ -113,8 +115,8 @@ public void onDisconnected(Text reason) {

HandshakeC2SPacket handshakeC2SPacket = new HandshakeC2SPacket(address.getHostString(),
address.getPort(), NetworkState.STATUS);
((HandshakeInterceptor) handshakeC2SPacket).viaFabric$setProtocolVersion(
Via.getAPI().getServerVersion().lowestSupportedVersion());
((MixinHandshakeC2SPacketAccessor) handshakeC2SPacket).setProtocolVersion(
RealmsSharedConstants.NETWORK_PROTOCOL_VERSION);
clientConnection.send(handshakeC2SPacket);
clientConnection.send(new QueryRequestC2SPacket());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"client": [
"client.MixinClientConnection",
"client.MixinClientConnectionChInit",
"client.MixinHandshakeC2SPacket"
"client.MixinHandshakeC2SPacketAccessor"
],
"injectors": {
"defaultRequire": 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
import net.minecraft.network.packet.c2s.query.QueryRequestC2SPacket;
import net.minecraft.network.packet.s2c.query.QueryPongS2CPacket;
import net.minecraft.network.packet.s2c.query.QueryResponseS2CPacket;
import net.minecraft.realms.RealmsSharedConstants;
import net.minecraft.server.ServerMetadata;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.api.Via;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
Expand Down Expand Up @@ -110,7 +110,7 @@ public void onDisconnected(Text reason) {
}
});

clientConnection.send(new HandshakeC2SPacket(Via.getAPI().getServerVersion().lowestSupportedVersion(), address.getHostString(),
clientConnection.send(new HandshakeC2SPacket(RealmsSharedConstants.NETWORK_PROTOCOL_VERSION, address.getHostString(),
address.getPort(), NetworkState.STATUS));
clientConnection.send(new QueryRequestC2SPacket());
});
Expand Down

0 comments on commit 9065c52

Please sign in to comment.