Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile time (packet ids, registries) stuff #158

Merged
merged 8 commits into from
Jan 5, 2025

Conversation

Sweattypalms
Copy link
Member

@Sweattypalms Sweattypalms commented Jan 4, 2025

Made packets use resource ids (move_player_pos_rot) instead of packet ids (0x01) for both INCOMING (Serverbound) and OUTGOING (Clientbound) packets.

OLD System:
#[packet(packet_id = 0x1B, state = "play")]

NEW System:
#[packet(packet_id = "move_player_pos_rot", state = "play")]

What's a resource id and how do I get it? 🤓 ☝️
You can get it from here, little timmy:
Step 1: Go to the Protocol website
Step 2: Look for a packet you want, e.g.:
image
Step 3: Look for resource name, in this case it'd be cooldown.
Done.

Benefits: No hardcoding, version switching (ofcourse ignoring other problems like field orders, and state machine changes), is way easier. Just change the json file (generated via the datagenerator of 1.21.1 version server.jar), and recompile.
This is compile time macros so it's basically equivalent to manually typing it yourself, runtime performance-wise.

Also there is a new get_registry_entry! macro, also compile time. It returns a specific ID from the registries.json, also generated by the datagenerator.
Example usage:
image

DATA GENERATOR: https://minecraft.wiki/w/Minecraft_Wiki:Projects/wiki.vg_merge/Data_Generators

I had to manually replace all ids with the resource ids, 😔😔.

This is a lot of yap, where's my credits?

@Sweattypalms Sweattypalms changed the title Compile time shit packet ids shit Compile time (packet ids, registries) stuff Jan 4, 2025
Copy link
Contributor

@0xnim 0xnim left a comment

Choose a reason for hiding this comment

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

just one quick fix

src/lib/derive_macros/Cargo.toml Outdated Show resolved Hide resolved
Copy link
Contributor

@0xnim 0xnim left a comment

Choose a reason for hiding this comment

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

Honestly have no idea what half this does. APPROVED

@Sweattypalms Sweattypalms merged commit 289e743 into master Jan 5, 2025
9 checks passed
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.

3 participants