mirror of
https://github.com/mat-1/azalea.git
synced 2024-09-20 07:02:31 +00:00
add set time packet and update readme
This commit is contained in:
parent
b9c31efc01
commit
f0a277788c
4 changed files with 27 additions and 0 deletions
|
@ -261,6 +261,9 @@ impl Client {
|
||||||
GamePacket::ClientboundInitializeBorderPacket(p) => {
|
GamePacket::ClientboundInitializeBorderPacket(p) => {
|
||||||
println!("Got initialize border packet {:?}", p);
|
println!("Got initialize border packet {:?}", p);
|
||||||
}
|
}
|
||||||
|
GamePacket::ClientboundSetTimePacket(p) => {
|
||||||
|
println!("Got set time packet {:?}", p);
|
||||||
|
}
|
||||||
_ => panic!("Unexpected packet {:?}", packet),
|
_ => panic!("Unexpected packet {:?}", packet),
|
||||||
}
|
}
|
||||||
println!();
|
println!();
|
||||||
|
|
|
@ -7,3 +7,18 @@ The goal is to **only** support the latest Minecraft version in order to ease de
|
||||||
This is not yet complete, search for `TODO` in the code for things that need to be done.
|
This is not yet complete, search for `TODO` in the code for things that need to be done.
|
||||||
|
|
||||||
Unfortunately, compiling the crate requires Rust nightly because specialization is not stable yet.
|
Unfortunately, compiling the crate requires Rust nightly because specialization is not stable yet.
|
||||||
|
|
||||||
|
## Adding a new packet
|
||||||
|
|
||||||
|
Adding new packets is usually pretty easy, but you'll want to have Minecraft's decompiled source code which you can obtain with tools such as [DecompilerMC](https://github.com/hube12/DecompilerMC).
|
||||||
|
|
||||||
|
1. Find the packet in Minecraft's source code. Minecraft's packets are in the `net/minecraft/network/protocol/<state>` directory. The state for your packet is usually `game`.
|
||||||
|
2. Add a new file in the [`packets/<state>`](./src/packets/game) directory with the snake_cased version of the name Minecraft uses.
|
||||||
|
3. Copy the code from a similar packet and change the struct name.
|
||||||
|
4. Add the fields from Minecraft's source code from either the read or write methods.
|
||||||
|
If it's a `varint`, use `#[var] pub <name>: i32` (or u32 if it makes more sense).
|
||||||
|
If it's a `varlong`, use `#[var] pub <name>: i64` (or u64).
|
||||||
|
If it's a byte, use i8 or u8.
|
||||||
|
Etc.. You can look at [wiki.vg](https://wiki.vg/Protocol) if you're not sure about how a packet is structured, but be aware that wiki.vg uses different names for most things.
|
||||||
|
5. Add the packet to the `mod.rs` file in the same directory. You will have to look at [wiki.vg](https://wiki.vg/Protocol) to determine the packet id here.
|
||||||
|
6. That's it! Format your code, submit a pull request, and wait for it to be reviewed.
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
use packet_macros::GamePacket;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, GamePacket)]
|
||||||
|
pub struct ClientboundSetTimePacket {
|
||||||
|
pub game_time: u64,
|
||||||
|
pub day_time: u64,
|
||||||
|
}
|
|
@ -19,6 +19,7 @@ pub mod clientbound_set_carried_item_packet;
|
||||||
pub mod clientbound_set_chunk_cache_center;
|
pub mod clientbound_set_chunk_cache_center;
|
||||||
pub mod clientbound_set_entity_data_packet;
|
pub mod clientbound_set_entity_data_packet;
|
||||||
pub mod clientbound_set_entity_link_packet;
|
pub mod clientbound_set_entity_link_packet;
|
||||||
|
pub mod clientbound_set_time_packet;
|
||||||
pub mod clientbound_update_attributes_packet;
|
pub mod clientbound_update_attributes_packet;
|
||||||
pub mod clientbound_update_recipes_packet;
|
pub mod clientbound_update_recipes_packet;
|
||||||
pub mod clientbound_update_tags_packet;
|
pub mod clientbound_update_tags_packet;
|
||||||
|
@ -55,6 +56,7 @@ declare_state_packets!(
|
||||||
0x4d: clientbound_set_entity_data_packet::ClientboundSetEntityDataPacket,
|
0x4d: clientbound_set_entity_data_packet::ClientboundSetEntityDataPacket,
|
||||||
0x45: clientbound_set_entity_link_packet::ClientboundSetEntityLinkPacket,
|
0x45: clientbound_set_entity_link_packet::ClientboundSetEntityLinkPacket,
|
||||||
0x4f: clientbound_entity_velocity_packet::ClientboundEntityVelocityPacket,
|
0x4f: clientbound_entity_velocity_packet::ClientboundEntityVelocityPacket,
|
||||||
|
0x59: clientbound_set_time_packet::ClientboundSetTimePacket,
|
||||||
0x64: clientbound_update_attributes_packet::ClientboundUpdateAttributesPacket,
|
0x64: clientbound_update_attributes_packet::ClientboundUpdateAttributesPacket,
|
||||||
0x66: clientbound_update_recipes_packet::ClientboundUpdateRecipesPacket,
|
0x66: clientbound_update_recipes_packet::ClientboundUpdateRecipesPacket,
|
||||||
0x67: clientbound_update_tags_packet::ClientboundUpdateTagsPacket
|
0x67: clientbound_update_tags_packet::ClientboundUpdateTagsPacket
|
||||||
|
|
Loading…
Reference in a new issue