Archived
0

debug: log send packet

This commit is contained in:
2021-05-02 20:59:58 +03:00
parent a1a629279c
commit 18a857193f
2 changed files with 4 additions and 5 deletions

View File

@@ -4,6 +4,7 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder; import io.netty.handler.codec.MessageToByteEncoder;
import lombok.extern.slf4j.Slf4j;
import mc.protocol.NetworkAttributes; import mc.protocol.NetworkAttributes;
import mc.protocol.State; import mc.protocol.State;
import mc.protocol.io.NetByteBuf; import mc.protocol.io.NetByteBuf;
@@ -11,6 +12,7 @@ import mc.protocol.packets.ServerSidePacket;
import java.util.Objects; import java.util.Objects;
@Slf4j
public class ProtocolEncoder extends MessageToByteEncoder<ServerSidePacket> { public class ProtocolEncoder extends MessageToByteEncoder<ServerSidePacket> {
@Override @Override
@@ -18,6 +20,8 @@ public class ProtocolEncoder extends MessageToByteEncoder<ServerSidePacket> {
State state = ctx.channel().attr(NetworkAttributes.STATE).get(); State state = ctx.channel().attr(NetworkAttributes.STATE).get();
int packetId = Objects.requireNonNull(state.getServerSidePacketId(packet.getClass())); int packetId = Objects.requireNonNull(state.getServerSidePacketId(packet.getClass()));
log.info("Send {}:{}", state, packet);
NetByteBuf buffer = new NetByteBuf(Unpooled.buffer()); NetByteBuf buffer = new NetByteBuf(Unpooled.buffer());
buffer.writeVarInt(packetId); buffer.writeVarInt(packetId);
packet.writeSelf(buffer); packet.writeSelf(buffer);

View File

@@ -64,7 +64,6 @@ public class PacketHandler {
loginSuccessPacket.setUuid(UUID.randomUUID()); loginSuccessPacket.setUuid(UUID.randomUUID());
loginSuccessPacket.setName(loginStartPacket.getName()); loginSuccessPacket.setName(loginStartPacket.getName());
log.info("{}", loginSuccessPacket);
channel.getCtx().writeAndFlush(loginSuccessPacket); channel.getCtx().writeAndFlush(loginSuccessPacket);
channel.setState(State.PLAY); channel.setState(State.PLAY);
@@ -75,7 +74,6 @@ public class PacketHandler {
joinGamePacket.setDifficulty(Difficulty.PEACEFUL); joinGamePacket.setDifficulty(Difficulty.PEACEFUL);
joinGamePacket.setLevelType(LevelType.FLAT); joinGamePacket.setLevelType(LevelType.FLAT);
log.info("{}", joinGamePacket);
channel.getCtx().write(joinGamePacket); channel.getCtx().write(joinGamePacket);
Location spawnLocation = new Location(0d, 63d, 0d); Location spawnLocation = new Location(0d, 63d, 0d);
@@ -83,7 +81,6 @@ public class PacketHandler {
var spawnPositionPacket = new SpawnPositionPacket(); var spawnPositionPacket = new SpawnPositionPacket();
spawnPositionPacket.setSpawn(spawnLocation); spawnPositionPacket.setSpawn(spawnLocation);
log.info("{}", spawnPositionPacket);
channel.getCtx().write(spawnPositionPacket); channel.getCtx().write(spawnPositionPacket);
var playerAbilitiesPacket = new PlayerAbilitiesPacket(); var playerAbilitiesPacket = new PlayerAbilitiesPacket();
@@ -94,7 +91,6 @@ public class PacketHandler {
playerAbilitiesPacket.setFieldOfView(0.0f); playerAbilitiesPacket.setFieldOfView(0.0f);
playerAbilitiesPacket.setFlyingSpeed(0.05f); playerAbilitiesPacket.setFlyingSpeed(0.05f);
log.info("{}", playerAbilitiesPacket);
channel.getCtx().write(playerAbilitiesPacket); channel.getCtx().write(playerAbilitiesPacket);
channel.getCtx().flush(); channel.getCtx().flush();
@@ -104,7 +100,6 @@ public class PacketHandler {
playerPositionAndLookPacket.setLook(new Look(0f, 0f)); playerPositionAndLookPacket.setLook(new Look(0f, 0f));
playerPositionAndLookPacket.setTeleportId(random.nextInt()); playerPositionAndLookPacket.setTeleportId(random.nextInt());
log.info("{}", playerPositionAndLookPacket);
channel.getCtx().writeAndFlush(playerPositionAndLookPacket); channel.getCtx().writeAndFlush(playerPositionAndLookPacket);
} }