1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 14:26:04 +00:00

more chunk and readme stuff

This commit is contained in:
mat 2022-05-02 23:07:06 +00:00
parent 1e2ec61100
commit 8e42e1c5df
7 changed files with 16 additions and 12 deletions

1
Cargo.lock generated
View file

@ -99,6 +99,7 @@ dependencies = [
"azalea-core",
"azalea-crypto",
"azalea-protocol",
"azalea-world",
"tokio",
]

View file

@ -1,20 +1,24 @@
# Azalea
A Rust crate for creating Minecraft bots.
<p align="center">
<img src="https://cdn.matdoes.dev/images/flowering_azalea.webp" alt="Azalea" height="200">
</p>
A Rust crate for creating Minecraft bots.
I named this Azalea because it sounds like a cool word and this is a cool library. This project was heavily inspired by PrismarineJS.
## Why
I wanted a fun excuse to do something cool with Rust, and I also felt like I could do better than [Mineflayer](https://github.com/prismarinejs/mineflayer) in some areas.
## Goals
- Do everything a vanilla client can do
- Be easy to use
- Bypass most/all anticheats
- Support the latest Minecraft version
- Be fast
- Be fast and memory efficient
## Example code

View file

@ -10,4 +10,5 @@ azalea-auth = {path = "../azalea-auth"}
azalea-core = {path = "../azalea-core"}
azalea-crypto = {path = "../azalea-crypto"}
azalea-protocol = {path = "../azalea-protocol"}
azalea-world = {path = "../azalea-world"}
tokio = {version = "1.18.0", features = ["sync"]}

View file

@ -13,6 +13,7 @@ use azalea_protocol::{
},
resolver, ServerAddress,
};
use azalea_world::Chunk;
use std::sync::Arc;
use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender};
use tokio::sync::Mutex;
@ -233,7 +234,7 @@ impl Client {
}
GamePacket::ClientboundLevelChunkWithLightPacket(p) => {
println!("Got chunk with light packet {} {}", p.x, p.z);
// p.chunk_data
// let chunk = Chunk::read_with_world_height(&mut p.chunk_data);
}
GamePacket::ClientboundLightUpdatePacket(p) => {
println!("Got light update packet {:?}", p);

View file

@ -1,11 +1,5 @@
//! Utilities for reading and writing for the Minecraft protocol
// TODO: have a separate azalea-protocol-definitions crate to house everything in mc_buf
// We need to do this to prevent cyclic dependencies.
// For example with azalea-protocol depending on azalea-world,
// it could be changed to azalea-protocol depending on azalea-world
// and azalea-world depending on azalea-protocol-definitions.
mod read;
mod write;

View file

@ -27,4 +27,3 @@ pub struct BlockEntity {
data: azalea_nbt::Tag,
}
pub struct ChunkSection {}

View file

@ -12,12 +12,16 @@ mod tests {
const SECTION_HEIGHT: u32 = 16;
pub struct World {
}
pub struct Chunk {
pub sections: Vec<Section>,
}
impl Chunk {
fn read_with_world_height(buf: &mut impl Read, world_height: u32) -> Result<Self, String> {
pub fn read_with_world_height(buf: &mut impl Read, world_height: u32) -> Result<Self, String> {
let section_count = world_height / SECTION_HEIGHT;
let mut sections = Vec::with_capacity(section_count as usize);
for _ in 0..section_count {