-
-
Notifications
You must be signed in to change notification settings - Fork 145
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
ReCentralize Packets #429
ReCentralize Packets #429
Conversation
|
Yes this is the thing they are not just for the packet definitions they are also helper type ;) But for the enduser he was not messing with any packets but just using the simple api, so for him he just import an helper type that as nothing to do with patkets (for him) from the Hope you see what I mean |
We can just reexport those types from |
In addition to what dyc3 said, Every packet should have its own file and should be organized according to its state. Like this. So we could have something like...
All the packets are defined, but they're just scattered all over the place.
I'm a bit hesitant to do that since the info on wiki.vg can become outdated and wrong very quickly. Incorrect documentation is arguably worse than no documentation at all.
The packet inspector needs to know how to decode and display a packet given some information like packet ID, side, and state. So I think something like this will work: pub struct PacketRegistry {
packets: Vec<ErasedPacket>,
}
pub struct ErasedPacket {
name: String,
side: PacketSide,
state: PacketState,
id: i32,
/// Decodes this packet and returns its `Debug` output.
decode_and_debug: Box<dyn Fn(&mut &[u8]) -> anyhow::Result<String>>
} But this work could be postponed until later. Recently I had some bigger ideas for improving the project's structure. Right now I'm not really happy with the way things are organized, so here's my rough new idea: graph TD
subgraph valence
schem --> server
player_list --> server
inventory --> server
anvil --> server
command --> server
network --> server
weather --> server
advancement --> server
world_border --> server
server --> layer
boss_bar --> server
layer --> biome
layer --> dimension
biome --> registry
dimension --> registry
layer --> entity
layer --> core
entity --> protocol
protocol --> text
protocol --> block
protocol --> item
protocol --> nbt
end
I can't tell if this is completely overengineered, but basically,
There are a lot of constraints to work with here. For instance,
|
We should probably add the sound crate at the same level as block, item... cause it is needed by the packet. Ok, so I think that I will just organize all the packets then I leave it that way. |
Ok so I'v just created the modules and didn't bother changing any import if this will not be merge, you will just have to copy the folder from this branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good, thanks for working on this. If you could finish it up that would be appreciated. I'll worry about organizing more after this is merged.
Also the packet modules should re-export the packet structs, e.g.
pub mod handshake_c2s;
pub use handshake_c2s::HandshakeC2s;
Then you can glob import the packets from the packet inspector build script.
crates/valence_packet/src/packets/play/rotate_and_move_relative.rs
Outdated
Show resolved
Hide resolved
We have so many thing that depend on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just need to update the branch.
I was based on `main` but `layers` was just merge with `main`
Objective
As discuss in #400
Solution
I centralize all packets and there associates structs from all crates in
valence_packet
.I did not move any of the packet trait and stuff from
valence_core
cause I do not see the need, I see this crate only as way to get all packets in one place, for me the macro and trait should stay invalence_core
. (can be discuss)I did rework the
valence_boss_bar
crate because it used his ecs component in the packet struct, which was not good for moving the packets.Upgrade
Before it get merge I'd like to :
Question
I personally think that we should put all 'really minecraft related' struct in the
valence_core
, I explaining myself with an example :This two struct are currently in
valence_packet::inventory::
but like I said, I personally think that this crate should only contain the packets definition, so I would like to move all this related to packets struct in there associate module invalence_core
. Just like your through on this.