diff options
| author | mat <git@matdoes.dev> | 2023-09-17 21:44:17 -0500 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2023-09-17 21:44:17 -0500 |
| commit | 856a3252f693421df519cbc4d9bc03cfc0f0c212 (patch) | |
| tree | 310cffa9d9c09a4651ab1707899ae20416713fc0 /azalea | |
| parent | 61e63c08968f7b0f451c4c3b07ea8d4927b14a2f (diff) | |
| download | azalea-drasl-856a3252f693421df519cbc4d9bc03cfc0f0c212.tar.xz | |
heightmaps
Diffstat (limited to 'azalea')
| -rw-r--r-- | azalea/examples/testbot.rs | 35 | ||||
| -rw-r--r-- | azalea/src/lib.rs | 2 |
2 files changed, 29 insertions, 8 deletions
diff --git a/azalea/examples/testbot.rs b/azalea/examples/testbot.rs index c562041e..eaa36832 100644 --- a/azalea/examples/testbot.rs +++ b/azalea/examples/testbot.rs @@ -3,17 +3,18 @@ #![feature(type_alias_impl_trait)] use azalea::ecs::query::With; -use azalea::entity::metadata::Player; -use azalea::entity::{EyeHeight, Position}; +use azalea::entity::{metadata::Player, EyeHeight, Position}; use azalea::interact::HitResultComponent; use azalea::inventory::ItemSlot; use azalea::pathfinder::goals::BlockPosGoal; use azalea::protocol::packets::game::ClientboundGamePacket; -use azalea::{prelude::*, swarm::prelude::*, BlockPos, GameProfileComponent, WalkDirection}; -use azalea::{Account, Client, Event}; -use azalea_client::SprintDirection; -use azalea_core::Vec3; -use azalea_world::{InstanceName, MinecraftEntityId}; +use azalea::world::{heightmap::HeightmapKind, InstanceName, MinecraftEntityId}; +use azalea::SprintDirection; +use azalea::{prelude::*, swarm::prelude::*}; +use azalea::{ + Account, BlockPos, ChunkPos, Client, Event, GameProfileComponent, Vec3, WalkDirection, +}; +use azalea_core::ChunkBlockPos; use std::time::Duration; #[derive(Default, Clone, Component)] @@ -288,6 +289,26 @@ async fn handle(mut bot: Client, event: Event, _state: State) -> anyhow::Result< bot.chat("no entities found"); } } + "heightmap" => { + let position = bot.position(); + let chunk_pos = ChunkPos::from(position); + let chunk_block_pos = ChunkBlockPos::from(position); + let chunk = bot.world().read().chunks.get(&chunk_pos); + if let Some(chunk) = chunk { + let heightmaps = &chunk.read().heightmaps; + let Some(world_surface_heightmap) = + heightmaps.get(&HeightmapKind::WorldSurface) + else { + bot.chat("no world surface heightmap"); + return Ok(()); + }; + let highest_y = world_surface_heightmap + .get_highest_taken(chunk_block_pos.x, chunk_block_pos.z); + bot.chat(&format!("highest_y: {highest_y}",)); + } else { + bot.chat("no chunk found"); + } + } _ => {} } } diff --git a/azalea/src/lib.rs b/azalea/src/lib.rs index 9e2cfb13..397e6f90 100644 --- a/azalea/src/lib.rs +++ b/azalea/src/lib.rs @@ -20,7 +20,7 @@ pub use azalea_block as blocks; pub use azalea_brigadier as brigadier; pub use azalea_chat::FormattedText; pub use azalea_client::*; -pub use azalea_core::{BlockPos, Vec3}; +pub use azalea_core::{BlockPos, ChunkPos, Vec3}; pub use azalea_entity as entity; pub use azalea_protocol as protocol; pub use azalea_registry::{Block, EntityKind, Item}; |
