Skip to content

Adding play packet#1

Draft
AxenoDev wants to merge 18 commits into
masterfrom
feat/login
Draft

Adding play packet#1
AxenoDev wants to merge 18 commits into
masterfrom
feat/login

Conversation

@AxenoDev

@AxenoDev AxenoDev commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added support for namespaced identifiers throughout packet handling.
    • Expanded protocol coverage with new play/login data and packet types, including position and death location details.
    • Improved handling of newer client configuration and login fields.
  • Bug Fixes

    • Updated packet encoding/decoding to better match current protocol formats.
    • Improved support for optional and variable-length values in network messages.

AxenoDev and others added 2 commits June 28, 2026 23:51
@AxenoDev AxenoDev self-assigned this Jun 29, 2026
@AxenoDev AxenoDev marked this pull request as draft June 29, 2026 00:55
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Review Change Stack

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4ef2377a-db06-4d22-8f0d-82b679740b87

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Replaces the PacketReader/PacketWriter I/O layer in yoki_binutils with new BinaryReader/BinaryWriter traits (ReadBytes/WriteBytes), adds a yoki_identifier crate for namespaced resource identifiers, migrates PacketMeta to remove the ID constant (moving it to Connection::send), and adds play-phase LoginPacket, Position, and DeathLocation types.

Changes

Binary I/O Infrastructure (yoki_binutils)

Layer / File(s) Summary
BinaryError, BinaryReader, BinaryWriter core
crates/yoki_binutils/src/binary_error.rs, crates/yoki_binutils/src/binary_reader.rs, crates/yoki_binutils/src/binary_writer.rs, crates/yoki_binutils/src/lib.rs, crates/yoki_binutils/Cargo.toml
Introduces BinaryError enum with from_io, ReadBytes/BinaryReader cursor wrapper, WriteBytes/BinaryWriter buffer, and read_be/write_be const-generic helpers; updates crate root exports.
Primitive and composite ReadBytes/WriteBytes impls
crates/yoki_binutils/src/data_types/*
Adds ReadBytes/WriteBytes for bool, u8, u16, i8, i32, i64, f64, String, Vec<T>, Option<T>, Omitted<T>, Uuid, and VarInt with conversion impls.
ProtocolRead/ProtocolWrite migration and error bridge
crates/yoki_binutils/src/protocol.rs, crates/yoki_binutils/src/error.rs, crates/yoki_binutils/src/reader.rs, crates/yoki_binutils/src/writer.rs
Rewrites ProtocolRead/ProtocolWrite to use BinaryReader/BinaryWriter; delegates Vec/Option impls via impl_protocol_via_bytes!; adds InvalidIdentifier variant and From<BinaryError> to ProtocolError; deletes PacketReader/PacketWriter.

yoki_identifier crate

Layer / File(s) Summary
Identifier type, errors, and protocol impls
crates/yoki_identifier/..., Cargo.toml
Introduces yoki_identifier crate with IdentifierError, Identifier struct (validation, parse, serde), and ReadBytes/WriteBytes/ProtocolRead/ProtocolWrite impls bridging to BinaryError::InvalidIdentifier.

Packet API migration and new play packets

Layer / File(s) Summary
PacketMeta/IncomingPacket/OutgoingPacket trait and macro changes
crates/minecraft_packet/src/packet/mod.rs, crates/minecraft_packet/src/packet/raw.rs, crates/yoki_macros/src/...
PacketMeta drops ID; encode() replaced by encode_with_id(id); traits switch to BinaryReader/BinaryWriter; derive macros remove packet attribute and ID codegen; attrs.rs removes parse_packet_id/has_packet_flag.
Connection::send explicit id and framing
crates/minecraft_packet/src/connection.rs, crates/minecraft_packet/Cargo.toml
Connection::send now takes explicit id: i32 and calls encode_with_id; send_raw/send_framed rewrite framing using BinaryWriter and VarInt.
Packet struct migrations across all phases
crates/minecraft_packet/src/packets/configuration/..., crates/minecraft_packet/src/packets/login/..., crates/minecraft_packet/src/packets/status/..., crates/minecraft_packet/src/packets/handshaking/..., yoki/src/handlers/handshake.rs
All packet structs remove #[packet(id=...)] attributes, switch to PacketIn/PacketOut derives, update field types to VarInt/Identifier, and migrate manual decode/encode impls to BinaryReader/BinaryWriter.
New play/login packet, Position, DeathLocation
crates/minecraft_packet/src/packets/play/...
Adds Position and DeathLocation data types with full binary/protocol serialization, and introduces LoginPacket struct with all play-login fields including optional DeathLocation.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 Hop hop, the old PacketWriter is gone,
BinaryWriter bounces the bytes along!
Identifier blooms in its very own crate,
VarInt encodes at a spectacular rate.
The rabbit re-traced every framing byte,
Now packets flow clean through the night! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 2.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is related, but it's too generic to identify the main change in this large refactor. Use a more specific title that names the primary change, such as adding play packet support and the BinaryReader/BinaryWriter refactor.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/login

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@AxenoDev

Copy link
Copy Markdown
Owner Author

tu fous quoi ici @CodeRabbit

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

@AxenoDev Je suis là pour relire la PR et signaler d’éventuels soucis ou améliorations, rien de plus.

Si tu ne veux pas de mes retours ici, dis-le et je m’efface — ou tu peux me demander de mettre les reviews en pause.

(/_·)/🐇

@AxenoDev

Copy link
Copy Markdown
Owner Author

@coderabbitai retire toi de mes PRs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 20

🧹 Nitpick comments (2)
crates/yoki_identifier/src/identifier.rs (1)

56-58: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Rename as_str or change its contract.

as_str returns an owned String, so the name reads like a borrowed &str API. Rename it to something like as_string/to_string, or change it to return a borrowed view if that’s the intended contract.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/yoki_identifier/src/identifier.rs` around lines 56 - 58, The
Identifier::as_str method returns an owned String, which conflicts with the
naming expectation of a borrowed string view. Update the API in identifier.rs by
either renaming as_str to something like as_string or to_string, or change its
signature and implementation so it returns a borrowed &str if that is the
intended contract. Make sure any callers of Identifier::as_str are updated to
match the revised method name or return type.
crates/yoki_binutils/src/binary_writer.rs (1)

33-35: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Avoid cloning every byte-array payload before writing.

write_byte_array currently copies the whole slice into a new Vec and then serializes it byte-by-byte. crates/yoki_macros/src/attrs.rs:103-136 sends every Vec<u8> field through this helper, so larger payloads pay an unnecessary extra allocation on each encode. Prefer writing the length prefix directly and then appending the slice in one shot.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/yoki_binutils/src/binary_writer.rs` around lines 33 - 35, Avoid
cloning the byte slice in BinaryWriter::write_byte_array: it currently allocates
a new Vec<u8> and then writes it back out, which adds unnecessary copying for
every Vec<u8> field encoded through the attrs macros path. Update
write_byte_array to write the length prefix directly and then write the provided
slice in one shot, keeping the BinaryError flow unchanged and preserving the
existing callers that route through write_byte_array.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/minecraft_packet/src/connection.rs`:
- Around line 31-37: The `Connection::send` API currently accepts a free-form
`i32` packet id, which breaks the packet-type-to-id association and can let
callers encode mismatched frames. Update `send` to derive the packet id from the
packet type’s metadata instead of taking it as a parameter, and keep that
association enforced through the `OutgoingPacket`/`PacketMeta` types so only the
correct id can be used for each packet. Adjust any call sites to pass only the
packet value and use the existing packet metadata path for encoding.

In `@crates/minecraft_packet/src/packet/raw.rs`:
- Around line 12-14: RawPacket::decode is now decoding payloads without
verifying the packet ID, which lets callers misinterpret unrelated packet bytes
as type P. Restore the safety check inside RawPacket::decode by validating
self.id against P before calling P::decode_payload, or make the helper
internal/private and only use the unchecked path from
PacketReport::decode_serverbound. Keep the existing decode flow in RawPacket and
the IncomingPacket bound, but ensure public callers still get UnknownPacket
protection instead of silent mis-decodes.

In `@crates/minecraft_packet/src/packets/configuration/plugin_message.rs`:
- Line 7: The plugin-message payload field is being decoded with the wrong
framing because `PluginMessage`’s `data: Vec<u8>` is missing remaining-bytes
semantics. Update the `PluginMessage` packet definition to restore the
`#[protocol(remaining)]` behavior on `data` so the derive reads the rest of the
packet as the payload instead of treating it as a length-prefixed byte array.

In `@crates/minecraft_packet/src/packets/login/login_success.rs`:
- Around line 20-23: The LoginSuccess packet encoding in write is missing the
optional-signature presence flag before the signature payload, so the
Some(signature) branch currently writes the value directly and misframes signed
properties. Update the LoginSuccess::write logic to emit the expected
boolean/prefix flag for self.signature first, then write the signature only when
present, and keep the None case consistent with the protocol’s optional-field
encoding.

In `@crates/minecraft_packet/src/packets/play/data/death_location.rs`:
- Around line 1-4: The import block in death_location.rs is not
rustfmt-compliant, so update the existing use statement to match standard
rustfmt ordering and formatting. Keep the same symbols imported from
yoki_binutils, but let rustfmt-style grouping/order be applied to the `use` list
so CI passes consistently.
- Around line 10-29: Make DeathLocation atomic by removing the per-field Omitted
wrappers from the DeathLocation struct and having ReadBytes/WriteBytes serialize
both dimension and location as required fields. Update DeathLocation::read and
DeathLocation::write so truncated payloads fail with BinaryError::UnexpectedEof
instead of producing a partially filled value, and let
LoginPacket.death_location’s outer Option be the only presence guard.

In `@crates/minecraft_packet/src/packets/play/data/position.rs`:
- Around line 1-4: The import block in the position module is not
rustfmt-compliant. Reformat the existing yoki_binutils use statement so it
matches standard rustfmt ordering and wrapping, keeping the same imported
symbols in the same module.
- Around line 7-35: The Position type is currently serialized and deserialized
as three f64 values, which does not match the packed block-position wire format
used by DeathLocation.location. Update Position’s ReadBytes and WriteBytes
implementations to use the packed block-position encoding/decoding instead of
individual floating-point fields, and make sure the DeathLocation path that uses
Position continues to read/write the remaining optional fields in the correct
order.

In `@crates/minecraft_packet/src/packets/play/login.rs`:
- Around line 7-29: `LoginPacket` is currently impossible to construct outside
its module because all fields are private and `PacketOut` only adds encoding
metadata, not a constructor. Make `LoginPacket` buildable by either exposing a
public constructor on `LoginPacket` or making the fields public, and ensure any
new constructor covers all required fields such as `entity_id`,
`dimension_names`, and `death_location`.

In `@crates/yoki_binutils/src/data_types/f64.rs`:
- Around line 2-3: The import ordering in the f64 module is not formatted
consistently, causing CI to fail. Run cargo fmt on this module so the use
statements in f64.rs are reordered and normalized automatically; the affected
symbols are the top-level imports from binary_reader and binary_writer.

In `@crates/yoki_binutils/src/data_types/i32.rs`:
- Around line 1-3: The import block in i32.rs needs to be rustfmt-compliant
because CI is failing on reordered use lists. Run cargo fmt, or manually reorder
the imports in the i32 module so the BinaryError, BinaryReader/ReadBytes, and
BinaryWriter/WriteBytes uses match rustfmt’s expected order.

In `@crates/yoki_binutils/src/data_types/i64.rs`:
- Around line 1-3: The import block in i64.rs needs to be rustfmt-compliant
because the current use list ordering is causing CI failures. Run cargo fmt, or
reorder the imports in the module’s top-level use statements so the grouped
symbols from binary_reader and binary_writer match rustfmt’s expected ordering.

In `@crates/yoki_binutils/src/data_types/string.rs`:
- Around line 8-10: The string decode path in the read logic for String should
reject negative lengths before converting the VarInt value to usize. Update the
String reader to inspect the signed value returned by VarInt::inner() first,
return an invalid-length-style BinaryError for any negative value, and only cast
to usize after that check so malformed input is not misreported as
UnexpectedEof. Apply the same validation pattern anywhere this length-decoding
flow is reused for identifier parsing.

In `@crates/yoki_binutils/src/data_types/u16.rs`:
- Around line 1-3: The import block in u16.rs needs to be reformatted to match
rustfmt’s ordering so CI passes. Update the grouped use statements for
BinaryReader/BinaryWriter and their helpers by running cargo fmt or otherwise
reordering the imports in place, keeping the symbols BinaryError, read_be,
BinaryReader, ReadBytes, write_be, BinaryWriter, and WriteBytes intact.

In `@crates/yoki_binutils/src/data_types/uuid.rs`:
- Around line 3-5: The import block in uuid.rs needs to be rustfmt-compliant
because CI is failing on the `use` ordering. Re-run `cargo fmt` or reorder the
imports in the `uuid` module so the `BinaryReader`, `ReadBytes`, `BinaryWriter`,
and `WriteBytes` items are grouped and sorted the way rustfmt expects, keeping
the existing symbols intact.

In `@crates/yoki_binutils/src/data_types/var_int.rs`:
- Around line 80-89: The VarInt conversions from u32 and &u32 are lossy because
they cast into i32 and can truncate values above i32::MAX. Replace the existing
From<u32> and From<&u32> implementations on VarInt with fallible TryFrom
versions, and make the conversion return an error for out-of-range values
instead of silently narrowing. Update any related VarInt conversion helpers or
call sites in this module to use the new TryFrom-based API.

In `@crates/yoki_binutils/src/data_types/vec.rs`:
- Around line 8-10: The Vec<T> decoder currently casts VarInt::inner() directly
to usize and preallocates before validating the decoded length, which can turn
malformed input into an oversized allocation. Update the ProtocolRead
implementation for Vec<T> in vec.rs to validate the decoded VarInt length first,
reject negative or unreasonably large values, and only then create the vector
with capacity and enter the read loop. Keep the fix localized around
VarInt::read and the Vec::with_capacity path.

In `@crates/yoki_binutils/src/error.rs`:
- Around line 44-52: The BinaryError to ProtocolError conversion is collapsing
distinct varint and varlong failures into the same ProtocolError::VarIntTooBig
case. Update the From<BinaryError> for ProtocolError implementation in error.rs
so BinaryError::VarLongTooBig maps to its own corresponding ProtocolError
variant instead of sharing the varint one, while keeping the existing mappings
for the other BinaryError cases unchanged.

In `@crates/yoki_identifier/src/protocol.rs`:
- Around line 1-4: The `yoki_binutils` import block in `protocol.rs` needs to be
reformatted to match rustfmt output so CI stops failing. Update the grouped `use
yoki_binutils::{...}` statement to the canonical rustfmt ordering and wrapping,
keeping the same imported symbols (`BinaryError`, `BinaryReader`,
`BinaryWriter`, `ProtocolError`, `ProtocolRead`, `ProtocolWrite`, `ReadBytes`,
`WriteBytes`) but letting rustfmt control the layout.

In `@crates/yoki_macros/src/attrs.rs`:
- Around line 84-87: The generated code for #[present_if(...)] is using a bare
identifier that is not in scope in either derive path. Update
generate_field_decode and generate_field_encode in attrs.rs so
field_present_if(field) resolves against an available binding: use the packet
struct/instance field access in PacketOut and the decoded-value binding in
PacketIn, rather than emitting `#present_field` directly. Ensure the generated
quote! references a symbol that exists in each context so derives with
present_if compile cleanly.

---

Nitpick comments:
In `@crates/yoki_binutils/src/binary_writer.rs`:
- Around line 33-35: Avoid cloning the byte slice in
BinaryWriter::write_byte_array: it currently allocates a new Vec<u8> and then
writes it back out, which adds unnecessary copying for every Vec<u8> field
encoded through the attrs macros path. Update write_byte_array to write the
length prefix directly and then write the provided slice in one shot, keeping
the BinaryError flow unchanged and preserving the existing callers that route
through write_byte_array.

In `@crates/yoki_identifier/src/identifier.rs`:
- Around line 56-58: The Identifier::as_str method returns an owned String,
which conflicts with the naming expectation of a borrowed string view. Update
the API in identifier.rs by either renaming as_str to something like as_string
or to_string, or change its signature and implementation so it returns a
borrowed &str if that is the intended contract. Make sure any callers of
Identifier::as_str are updated to match the revised method name or return type.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f277019b-bb8a-4512-ac86-8b32b336dd2f

📥 Commits

Reviewing files that changed from the base of the PR and between 7a92cf3 and dd76b80.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (60)
  • Cargo.toml
  • crates/minecraft_packet/Cargo.toml
  • crates/minecraft_packet/src/connection.rs
  • crates/minecraft_packet/src/packet/mod.rs
  • crates/minecraft_packet/src/packet/raw.rs
  • crates/minecraft_packet/src/packets/configuration/acknowledge_finish_configuration.rs
  • crates/minecraft_packet/src/packets/configuration/client_information.rs
  • crates/minecraft_packet/src/packets/configuration/finish_configuration.rs
  • crates/minecraft_packet/src/packets/configuration/plugin_message.rs
  • crates/minecraft_packet/src/packets/handshaking/handshake.rs
  • crates/minecraft_packet/src/packets/login/cookie_response_login.rs
  • crates/minecraft_packet/src/packets/login/encryption_response.rs
  • crates/minecraft_packet/src/packets/login/login_acknowledged.rs
  • crates/minecraft_packet/src/packets/login/login_plugin_response.rs
  • crates/minecraft_packet/src/packets/login/login_start.rs
  • crates/minecraft_packet/src/packets/login/login_success.rs
  • crates/minecraft_packet/src/packets/play/data/death_location.rs
  • crates/minecraft_packet/src/packets/play/data/mod.rs
  • crates/minecraft_packet/src/packets/play/data/position.rs
  • crates/minecraft_packet/src/packets/play/login.rs
  • crates/minecraft_packet/src/packets/play/mod.rs
  • crates/minecraft_packet/src/packets/status/ping_request.rs
  • crates/minecraft_packet/src/packets/status/ping_response.rs
  • crates/minecraft_packet/src/packets/status/status_request.rs
  • crates/minecraft_packet/src/packets/status/status_response.rs
  • crates/yoki_binutils/Cargo.toml
  • crates/yoki_binutils/src/binary_error.rs
  • crates/yoki_binutils/src/binary_reader.rs
  • crates/yoki_binutils/src/binary_writer.rs
  • crates/yoki_binutils/src/data_types/bool.rs
  • crates/yoki_binutils/src/data_types/f64.rs
  • crates/yoki_binutils/src/data_types/i32.rs
  • crates/yoki_binutils/src/data_types/i64.rs
  • crates/yoki_binutils/src/data_types/i8.rs
  • crates/yoki_binutils/src/data_types/mod.rs
  • crates/yoki_binutils/src/data_types/option.rs
  • crates/yoki_binutils/src/data_types/optional.rs
  • crates/yoki_binutils/src/data_types/string.rs
  • crates/yoki_binutils/src/data_types/u16.rs
  • crates/yoki_binutils/src/data_types/u8.rs
  • crates/yoki_binutils/src/data_types/uuid.rs
  • crates/yoki_binutils/src/data_types/var_int.rs
  • crates/yoki_binutils/src/data_types/vec.rs
  • crates/yoki_binutils/src/error.rs
  • crates/yoki_binutils/src/lib.rs
  • crates/yoki_binutils/src/protocol.rs
  • crates/yoki_binutils/src/reader.rs
  • crates/yoki_binutils/src/writer.rs
  • crates/yoki_identifier/Cargo.toml
  • crates/yoki_identifier/src/error.rs
  • crates/yoki_identifier/src/identifier.rs
  • crates/yoki_identifier/src/lib.rs
  • crates/yoki_identifier/src/protocol.rs
  • crates/yoki_macros/Cargo.toml
  • crates/yoki_macros/src/attrs.rs
  • crates/yoki_macros/src/lib.rs
  • crates/yoki_macros/src/packet_in.rs
  • crates/yoki_macros/src/packet_out.rs
  • crates/yoki_macros/src/packet_report.rs
  • yoki/src/handlers/handshake.rs
💤 Files with no reviewable changes (12)
  • crates/minecraft_packet/src/packets/login/login_acknowledged.rs
  • crates/minecraft_packet/src/packets/status/status_request.rs
  • crates/minecraft_packet/src/packets/login/login_start.rs
  • crates/minecraft_packet/src/packets/status/status_response.rs
  • crates/minecraft_packet/src/packets/configuration/acknowledge_finish_configuration.rs
  • crates/minecraft_packet/src/packets/login/cookie_response_login.rs
  • crates/minecraft_packet/src/packets/status/ping_response.rs
  • crates/yoki_binutils/src/writer.rs
  • crates/minecraft_packet/src/packets/status/ping_request.rs
  • crates/minecraft_packet/src/packets/login/encryption_response.rs
  • crates/yoki_binutils/src/reader.rs
  • crates/minecraft_packet/src/packets/configuration/finish_configuration.rs

Comment on lines +31 to 37
pub async fn send<P: OutgoingPacket>(
&mut self,
id: i32,
packet: &P,
) -> Result<(), ProtocolError> {
let payload = packet.encode_with_id(id)?;
self.send_framed(&payload).await

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

send can now emit mismatched packet IDs and payloads.

With the per-type ID removed from PacketMeta, this signature accepts any id for any OutgoingPacket. A wrong call site still produces a valid frame, but the peer will decode it as a different packet type. Please keep the (packet type, packet id) association in the type system instead of taking a free i32 here.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/minecraft_packet/src/connection.rs` around lines 31 - 37, The
`Connection::send` API currently accepts a free-form `i32` packet id, which
breaks the packet-type-to-id association and can let callers encode mismatched
frames. Update `send` to derive the packet id from the packet type’s metadata
instead of taking it as a parameter, and keep that association enforced through
the `OutgoingPacket`/`PacketMeta` types so only the correct id can be used for
each packet. Adjust any call sites to pass only the packet value and use the
existing packet metadata path for encoding.

Comment thread crates/minecraft_packet/src/packet/raw.rs
Comment thread crates/minecraft_packet/src/packets/configuration/plugin_message.rs
Comment thread crates/minecraft_packet/src/packets/login/login_success.rs
Comment thread crates/minecraft_packet/src/packets/play/data/death_location.rs
Comment thread crates/yoki_binutils/src/data_types/var_int.rs
Comment thread crates/yoki_binutils/src/data_types/vec.rs
Comment thread crates/yoki_binutils/src/error.rs
Comment thread crates/yoki_identifier/src/protocol.rs
Comment thread crates/yoki_macros/src/attrs.rs
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

@AxenoDev Compris — je me mets en pause sur cette PR. Si tu veux, je peux aussi t’indiquer comment me désactiver au niveau du dépôt.

(╥﹏╥)

✅ Action performed

Reviews paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant