Skip to content

Commit

Permalink
Fixing PacketPlayInHandskaingSetProtocol wrapper for 1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
funkemunky committed Dec 2, 2021
1 parent f66b9a0 commit e7bc843
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ public int getProtocolVersion(Player player) {

Integer protocol = protocolLookup.get(channel);
if (protocol != null) {
System.out.println(player.getName() + ": " + protocol);
return protocol;
} else return -1;
}
Expand Down Expand Up @@ -540,6 +541,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
channelLookup.put(profile.getName(), channel);
} else if (PACKET_SET_PROTOCOL.getParent().isInstance(msg)) {
int protocol = ((Enum)protocolType.get(msg)).ordinal();
System.out.println("PacketPlayInSetProtocol: " + protocol);
if (protocol == 3) {
int id = protocolId.get(msg);
protocolLookup.put(channel, id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public WrappedHandshakingInSetProtocol(Object object) {
public String hostname;
public WrappedEnumProtocol enumProtocol;

private static WrappedField aField = packet.getFieldByType(int.class, 0),
private static WrappedField aField = packet.getFieldByType(int.class, ProtocolVersion.getGameVersion().isOrAbove(ProtocolVersion.v1_17) ? 1 :0),
hostField = packet.getFieldByType(String.class, 0),
portField = packet.getFieldByType(int.class, 1),
portField = packet.getFieldByType(int.class, ProtocolVersion.getGameVersion().isOrAbove(ProtocolVersion.v1_17) ? 2 : 1),
protocolField = packet.getFieldByType(WrappedEnumProtocol.enumProtocol.getParent(), 0);

@Override
Expand Down

0 comments on commit e7bc843

Please sign in to comment.