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

start adding azalea-inventory

This commit is contained in:
mat 2022-11-27 23:15:00 -06:00
parent 36a1122010
commit 108e576173
5 changed files with 43 additions and 1 deletions

7
Cargo.lock generated
View file

@ -253,6 +253,13 @@ dependencies = [
"uuid",
]
[[package]]
name = "azalea-inventory"
version = "0.1.0"
dependencies = [
"azalea-core",
]
[[package]]
name = "azalea-language"
version = "0.4.0"

View file

@ -16,6 +16,7 @@ members = [
"azalea-buf",
"azalea-physics",
"azalea-registry",
"azalea-inventory",
]
[profile.release]

View file

@ -0,0 +1,9 @@
[package]
edition = "2021"
name = "azalea-inventory"
version = "0.1.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
azalea-core = { version = "0.4.0", path = "../azalea-core" }

View file

@ -0,0 +1,25 @@
use azalea_core::Slot;
/// This inventory has a normal "grid" inventory you can put items in.
pub trait HasMainInventory {
/// Get the width of the main inventory.
fn width(&self) -> usize;
/// Get the height of the main inventory.
fn height(&self) -> usize;
/// Get the slot at the given x and y position in the main inventory.
fn slot(&self, x: usize, y: usize) -> Option<&Slot>;
}
/// A basic representation of a Minecraft inventory.
struct Inventory<const SIZE: usize> {
/// Every slot in the inventory. This will always include the player's
/// inventory, so you probably don't want this.
slots: [Slot; SIZE],
}
pub struct Generic9x1 {
inventory: Inventory<9>,
}
pub struct Generic9x2 {
inventory: Inventory<18>,
}

View file

@ -45,7 +45,7 @@ async fn handle(bot: Client, event: Event, state: State) -> anyhow::Result<()> {
.open_container(&bot.world().find_one_block(|b| b.id == "minecraft:chest"))
.await
.unwrap();
bot.take_amount(&chest, 5, |i| i.id == "#minecraft:planks")
bot.take_amount_from_container(&chest, 5, |i| i.id == "#minecraft:planks")
.await;
chest.close().await;