public bool HandlePacket(MinecraftClient client, MinecraftPacketStream stream) { // NOTE: Maybe bad practice... Probably a better idea to store data after packet 100% received... // Although I don't see anything that might go wrong... Since the server and client is essentially "syncronized" if (stream.Length - stream.Position >= 8) { client.Player.Position.X = stream.ReadDouble(); if (stream.Length - stream.Position >= 8) { client.Player.Stance = stream.ReadDouble(); if (stream.Length - stream.Position >= 8) { client.Player.Position.Y = stream.ReadDouble(); if (stream.Length - stream.Position >= 8) { client.Player.Position.Z = stream.ReadDouble(); if (stream.Length - stream.Position >= 4) { client.Player.Rotation.Yaw = stream.ReadFloat(); if (stream.Length - stream.Position >= 4) { client.Player.Rotation.Pitch = stream.ReadFloat(); if (stream.Length - stream.Position >= 1) { client.Player.OnGround = stream.ReadBool(); return true; } } } } } } } return false; }
public bool HandlePacket(MinecraftClient client, MinecraftPacketStream stream) { if (stream.Length - stream.Position >= 8) { double x = stream.ReadDouble(); if (stream.Length - stream.Position >= 8) { double y = stream.ReadDouble(); if (stream.Length - stream.Position >= 8) { double stance = stream.ReadDouble(); if (stream.Length - stream.Position >= 8) { double z = stream.ReadDouble(); if (stream.Length - stream.Position >= 1) { bool onGround = stream.ReadBool(); client.Player.Position.X = x; client.Player.Position.Y = y; client.Player.Stance = stance; client.Player.Position.Z = z; client.Player.OnGround = onGround; return true; } } } } } return false; }