diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v671/serializer/CorrectPlayerMovePredictionSerializer_v671.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v671/serializer/CorrectPlayerMovePredictionSerializer_v671.java index cb836e6d1..62c41e8dd 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v671/serializer/CorrectPlayerMovePredictionSerializer_v671.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v671/serializer/CorrectPlayerMovePredictionSerializer_v671.java @@ -18,7 +18,7 @@ public void serialize(ByteBuf buffer, BedrockCodecHelper helper, CorrectPlayerMo helper.writeVector3f(buffer, packet.getPosition()); helper.writeVector3f(buffer, packet.getDelta()); if (packet.getPredictionType() == PredictionType.VEHICLE) { - helper.writeVector2f(buffer, packet.getVehicleRotation()); + this.writeVehiclePrediction(buffer, helper, packet); } buffer.writeBoolean(packet.isOnGround()); VarInts.writeUnsignedLong(buffer, packet.getTick()); @@ -30,9 +30,17 @@ public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, CorrectPlayer packet.setPosition(helper.readVector3f(buffer)); packet.setDelta(helper.readVector3f(buffer)); if (packet.getPredictionType() == PredictionType.VEHICLE) { - packet.setVehicleRotation(helper.readVector2f(buffer)); + this.readVehiclePrediction(buffer, helper, packet); } packet.setOnGround(buffer.readBoolean()); packet.setTick(VarInts.readUnsignedInt(buffer)); } + + protected void writeVehiclePrediction(ByteBuf buffer, BedrockCodecHelper helper, CorrectPlayerMovePredictionPacket packet) { + helper.writeVector2f(buffer, packet.getVehicleRotation()); + } + + protected void readVehiclePrediction(ByteBuf buffer, BedrockCodecHelper helper, CorrectPlayerMovePredictionPacket packet) { + packet.setVehicleRotation(helper.readVector2f(buffer)); + } } diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v712/Bedrock_v712.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v712/Bedrock_v712.java index 8a025e673..030a5d33d 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v712/Bedrock_v712.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v712/Bedrock_v712.java @@ -44,6 +44,7 @@ public class Bedrock_v712 extends Bedrock_v686 { .updateSerializer(CameraInstructionPacket.class, CameraInstructionSerializer_v712.INSTANCE) .updateSerializer(CameraPresetsPacket.class, CameraPresetsSerializer_v712.INSTANCE) .updateSerializer(ChangeDimensionPacket.class, ChangeDimensionSerializer_v712.INSTANCE) + .updateSerializer(CorrectPlayerMovePredictionPacket.class, CorrectPlayerMovePredictionSerializer_v712.INSTANCE) .updateSerializer(DisconnectPacket.class, DisconnectSerializer_v712.INSTANCE) .updateSerializer(EditorNetworkPacket.class, EditorNetworkSerializer_v712.INSTANCE) .updateSerializer(InventoryContentPacket.class, InventoryContentSerializer_v712.INSTANCE) diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v712/serializer/CorrectPlayerMovePredictionSerializer_v712.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v712/serializer/CorrectPlayerMovePredictionSerializer_v712.java new file mode 100644 index 000000000..df61375e0 --- /dev/null +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v712/serializer/CorrectPlayerMovePredictionSerializer_v712.java @@ -0,0 +1,22 @@ +package org.cloudburstmc.protocol.bedrock.codec.v712.serializer; + +import io.netty.buffer.ByteBuf; +import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper; +import org.cloudburstmc.protocol.bedrock.codec.v671.serializer.CorrectPlayerMovePredictionSerializer_v671; +import org.cloudburstmc.protocol.bedrock.packet.CorrectPlayerMovePredictionPacket; + +public class CorrectPlayerMovePredictionSerializer_v712 extends CorrectPlayerMovePredictionSerializer_v671 { + public static final CorrectPlayerMovePredictionSerializer_v712 INSTANCE = new CorrectPlayerMovePredictionSerializer_v712(); + + @Override + protected void writeVehiclePrediction(ByteBuf buffer, BedrockCodecHelper helper, CorrectPlayerMovePredictionPacket packet) { + super.writeVehiclePrediction(buffer, helper, packet); + helper.writeOptionalNull(buffer, packet.getVehicleAngularVelocity(), ByteBuf::writeFloatLE); + } + + @Override + protected void readVehiclePrediction(ByteBuf buffer, BedrockCodecHelper helper, CorrectPlayerMovePredictionPacket packet) { + super.readVehiclePrediction(buffer, helper, packet); + packet.setVehicleAngularVelocity(helper.readOptional(buffer, null, ByteBuf::readFloatLE)); + } +} \ No newline at end of file diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/PredictionType.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/PredictionType.java index eb378b6d5..8fd6318ae 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/PredictionType.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/PredictionType.java @@ -1,6 +1,6 @@ package org.cloudburstmc.protocol.bedrock.data; public enum PredictionType { - VEHICLE, - PLAYER + PLAYER, + VEHICLE } diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/CorrectPlayerMovePredictionPacket.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/CorrectPlayerMovePredictionPacket.java index 3b27790aa..7c866d4eb 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/CorrectPlayerMovePredictionPacket.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/CorrectPlayerMovePredictionPacket.java @@ -62,6 +62,11 @@ public class CorrectPlayerMovePredictionPacket implements BedrockPacket { */ private Vector2f vehicleRotation; + /** + * @since v712 + */ + private Float vehicleAngularVelocity; + @Override public PacketSignal handle(BedrockPacketHandler handler) { return handler.handle(this);