update entity_teleport packet on 1.21.3+ - #1154
Conversation
update entity_teleport packet on 1.21.3
|
Do you have link to relevant vanilla source code for this? |
|
Re: the vanilla source — here's the relevant code, decompiled from the server jar ( public record ClientboundTeleportEntityPacket(int id, PositionMoveRotation change, Set<Relative> relatives, boolean onGround) {
public static final StreamCodec<FriendlyByteBuf, ClientboundTeleportEntityPacket> STREAM_CODEC = StreamCodec.composite(
ByteBufCodecs.VAR_INT, ClientboundTeleportEntityPacket::id,
PositionMoveRotation.STREAM_CODEC, ClientboundTeleportEntityPacket::change,
Relative.SET_STREAM_CODEC, ClientboundTeleportEntityPacket::relatives,
ByteBufCodecs.BOOL, ClientboundTeleportEntityPacket::onGround,
ClientboundTeleportEntityPacket::new);
}
public record PositionMoveRotation(Vec3 position, Vec3 deltaMovement, float yRot, float xRot) { /* Vec3, Vec3, FLOAT, FLOAT */ }So the wire layout is Two things worth fixing: 1. public enum Relative { X(0), Y(1), Z(2), Y_ROT(3), X_ROT(4), DELTA_X(5), DELTA_Y(6), DELTA_Z(7), ROTATE_DELTA(8); }
public static final StreamCodec<ByteBuf, Set<Relative>> SET_STREAM_CODEC = ByteBufCodecs.INT.map(Relative::unpack, Relative::pack);— a 4-byte int with bits 0–8. The inline "PositionUpdateRelatives": ["bitflags", { "type": "u32", "flags": ["x","y","z","yaw","pitch","dx","dy","dz","yawDelta"] }]So 2. This affects every 1.21.2+ version, not only 1.21.3. |
|
Is this ready to be merged? My console is again full of this spam :D |
|
@copilot Please correct the changes made per atiweb comment with |
|
I verified this fix against the actual packet buffers from mineflayer#3759 (entity_teleport errors on 1.21.8) and it works. Decoding with your new format: However, 2 bytes remain unread in both buffers from that issue ( Also, this same bug affects all versions from 1.21.2+ (1.21.4, 1.21.5, 1.21.6, 1.21.8, 1.21.9, 1.21.11, 26.1) — the current PR only updates 1.21.3. Worth extending if you have the bandwidth, otherwise I can open a follow-up. |
|
@AnonymoDGH the leftover bytes are an off-by-one, there is no The buffer in DatArnoGuy's report above is 64 bytes and the first byte is the packet id ( Three of those values match what mineflayer printed in the same error, and the total lands exactly on the buffer length. The The jar agrees. 1.21.8 public record ClientboundTeleportEntityPacket(int id, PositionMoveRotation change, Set<Relative> relatives, boolean onGround) {
public static final StreamCodec<FriendlyByteBuf, ClientboundTeleportEntityPacket> STREAM_CODEC = StreamCodec.composite(
ByteBufCodecs.VAR_INT, ClientboundTeleportEntityPacket::id,
PositionMoveRotation.STREAM_CODEC, ClientboundTeleportEntityPacket::change,
Relative.SET_STREAM_CODEC, ClientboundTeleportEntityPacket::relatives,
ByteBufCodecs.BOOL, ClientboundTeleportEntityPacket::onGround,
ClientboundTeleportEntityPacket::new);
}No vehicle id, and nothing after The wiki page you linked is a different packet. public record ClientboundEntityPositionSyncPacket(int id, PositionMoveRotation values, boolean onGround) { ... }One caveat on that sample: Your second point is right and still open. This needs to go to every 1.21.2+ version, not only 1.21.3. Also still open: public enum Relative { X(0), Y(1), Z(2), Y_ROT(3), X_ROT(4), DELTA_X(5), DELTA_Y(6), DELTA_Z(7), ROTATE_DELTA(8); }
public static final StreamCodec<ByteBuf, Set<Relative>> SET_STREAM_CODEC = ByteBufCodecs.INT.map(Relative::unpack, Relative::pack);So @TheSharkyOfficial @extremeheat if Sharky does not have the bandwidth, I am happy to open the complete fix as a separate PR: |
Updated teleport_entity packet according to https://minecraft.wiki/w/Java_Edition_protocol/Packets#Synchronize_Vehicle_Position
Should fix partial packet errors for this packet.