mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
chunk packets work
This commit is contained in:
parent
1ca9caee36
commit
b6fb96429c
6 changed files with 24 additions and 18 deletions
|
@ -100,7 +100,7 @@ pub async fn join_server(address: &ServerAddress) -> Result<(), String> {
|
||||||
println!("Got difficulty packet {:?}", p);
|
println!("Got difficulty packet {:?}", p);
|
||||||
}
|
}
|
||||||
GamePacket::ClientboundDeclareCommandsPacket(p) => {
|
GamePacket::ClientboundDeclareCommandsPacket(p) => {
|
||||||
println!("Got declare commands packet {:?}", p);
|
println!("Got declare commands packet");
|
||||||
}
|
}
|
||||||
GamePacket::ClientboundPlayerAbilitiesPacket(p) => {
|
GamePacket::ClientboundPlayerAbilitiesPacket(p) => {
|
||||||
println!("Got player abilities packet {:?}", p);
|
println!("Got player abilities packet {:?}", p);
|
||||||
|
@ -109,19 +109,19 @@ pub async fn join_server(address: &ServerAddress) -> Result<(), String> {
|
||||||
println!("Got set carried item packet {:?}", p);
|
println!("Got set carried item packet {:?}", p);
|
||||||
}
|
}
|
||||||
GamePacket::ClientboundUpdateTagsPacket(p) => {
|
GamePacket::ClientboundUpdateTagsPacket(p) => {
|
||||||
println!("Got update tags packet {:?}", p);
|
println!("Got update tags packet");
|
||||||
}
|
}
|
||||||
GamePacket::ClientboundDisconnectPacket(p) => {
|
GamePacket::ClientboundDisconnectPacket(p) => {
|
||||||
println!("Got login disconnect packet {:?}", p);
|
println!("Got login disconnect packet {:?}", p);
|
||||||
}
|
}
|
||||||
GamePacket::ClientboundUpdateRecipesPacket(p) => {
|
GamePacket::ClientboundUpdateRecipesPacket(p) => {
|
||||||
println!("Got update recipes packet {:?}", p);
|
println!("Got update recipes packet");
|
||||||
}
|
}
|
||||||
GamePacket::ClientboundEntityEventPacket(p) => {
|
GamePacket::ClientboundEntityEventPacket(p) => {
|
||||||
println!("Got entity event packet {:?}", p);
|
println!("Got entity event packet {:?}", p);
|
||||||
}
|
}
|
||||||
GamePacket::ClientboundRecipePacket(p) => {
|
GamePacket::ClientboundRecipePacket(p) => {
|
||||||
println!("Got recipe packet {:?}", p);
|
println!("Got recipe packet");
|
||||||
}
|
}
|
||||||
GamePacket::ClientboundPlayerPositionPacket(p) => {
|
GamePacket::ClientboundPlayerPositionPacket(p) => {
|
||||||
// TODO: reply with teleport confirm
|
// TODO: reply with teleport confirm
|
||||||
|
@ -133,6 +133,12 @@ pub async fn join_server(address: &ServerAddress) -> Result<(), String> {
|
||||||
GamePacket::ClientboundSetChunkCacheCenterPacket(p) => {
|
GamePacket::ClientboundSetChunkCacheCenterPacket(p) => {
|
||||||
println!("Got chunk cache center packet {:?}", p);
|
println!("Got chunk cache center packet {:?}", p);
|
||||||
}
|
}
|
||||||
|
GamePacket::ClientboundLevelChunkWithLightPacket(p) => {
|
||||||
|
println!("Got chunk with light packet");
|
||||||
|
}
|
||||||
|
GamePacket::ClientboundLightUpdatePacket(p) => {
|
||||||
|
println!("Got light update packet {:?}", p);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
panic!("Error: {:?}", e);
|
panic!("Error: {:?}", e);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
mod read;
|
mod read;
|
||||||
mod write;
|
mod write;
|
||||||
|
|
||||||
|
use packet_macros::{McBufReadable, McBufWritable};
|
||||||
pub use read::{McBufReadable, McBufVarintReadable, Readable};
|
pub use read::{McBufReadable, McBufVarintReadable, Readable};
|
||||||
use std::ops::{Deref, Index};
|
use std::ops::{Deref, Index};
|
||||||
pub use write::{McBufVarintWritable, McBufWritable, Writable};
|
pub use write::{McBufVarintWritable, McBufWritable, Writable};
|
||||||
|
@ -31,17 +32,16 @@ impl From<Vec<u8>> for UnsizedByteArray {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Represents Java's BitSet, a list of bits. */
|
/// Represents Java's BitSet, a list of bits.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Hash, McBufReadable, McBufWritable)]
|
||||||
pub struct BitSet {
|
pub struct BitSet {
|
||||||
data: Vec<u64>,
|
data: Vec<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Index<usize> for BitSet {
|
// the Index trait requires us to return a reference, but we can't do that
|
||||||
type Output = bool;
|
impl BitSet {
|
||||||
|
pub fn index(&self, index: usize) -> bool {
|
||||||
fn index(&self, index: usize) -> &Self::Output {
|
(self.data[index / 64] & (1u64 << (index % 64))) != 0
|
||||||
let result = (self.data[index / 64] & (1u64 << (index % 64))) != 0;
|
|
||||||
&result
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use serde::Deserialize;
|
||||||
use tokio::io::{AsyncRead, AsyncReadExt};
|
use tokio::io::{AsyncRead, AsyncReadExt};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use super::{UnsizedByteArray, MAX_STRING_LENGTH};
|
use super::{BitSet, UnsizedByteArray, MAX_STRING_LENGTH};
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait Readable {
|
pub trait Readable {
|
||||||
|
|
|
@ -14,7 +14,7 @@ pub struct ClientboundLevelChunkWithLightPacket {
|
||||||
pub struct ClientboundLevelChunkPacketData {
|
pub struct ClientboundLevelChunkPacketData {
|
||||||
heightmaps: azalea_nbt::Tag,
|
heightmaps: azalea_nbt::Tag,
|
||||||
data: Vec<u8>,
|
data: Vec<u8>,
|
||||||
block_entities: BlockEntity,
|
block_entities: Vec<BlockEntity>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBufReadable, McBufWritable)]
|
#[derive(Clone, Debug, McBufReadable, McBufWritable)]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::mc_buf::BitSet;
|
use crate::mc_buf::BitSet;
|
||||||
use azalea_core::{game_type::GameType, resource_location::ResourceLocation};
|
use azalea_core::{game_type::GameType, resource_location::ResourceLocation};
|
||||||
use packet_macros::GamePacket;
|
use packet_macros::{GamePacket, McBufReadable, McBufWritable};
|
||||||
|
|
||||||
#[derive(Clone, Debug, GamePacket)]
|
#[derive(Clone, Debug, GamePacket)]
|
||||||
pub struct ClientboundLightUpdatePacket {
|
pub struct ClientboundLightUpdatePacket {
|
||||||
|
@ -16,7 +16,6 @@ pub struct ClientboundLightUpdatePacketData {
|
||||||
block_y_mask: BitSet,
|
block_y_mask: BitSet,
|
||||||
empty_sky_y_mask: BitSet,
|
empty_sky_y_mask: BitSet,
|
||||||
empty_block_y_mask: BitSet,
|
empty_block_y_mask: BitSet,
|
||||||
sky_updates: Vec<>,
|
sky_updates: Vec<Vec<u8>>,
|
||||||
block_updates: BitSet,
|
block_updates: Vec<Vec<u8>>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,8 @@ async fn main() {
|
||||||
println!("Hello, world!");
|
println!("Hello, world!");
|
||||||
|
|
||||||
// let address = "95.111.249.143:10000";
|
// let address = "95.111.249.143:10000";
|
||||||
let address = "localhost:63097";
|
// let address = "localhost:52467";
|
||||||
|
let address = "localhost:25566";
|
||||||
// let response = azalea_client::ping::ping_server(&address.try_into().unwrap())
|
// let response = azalea_client::ping::ping_server(&address.try_into().unwrap())
|
||||||
// .await
|
// .await
|
||||||
// .unwrap();
|
// .unwrap();
|
||||||
|
|
Loading…
Add table
Reference in a new issue