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:
parent
36a1122010
commit
108e576173
5 changed files with 43 additions and 1 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -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"
|
||||
|
|
|
@ -16,6 +16,7 @@ members = [
|
|||
"azalea-buf",
|
||||
"azalea-physics",
|
||||
"azalea-registry",
|
||||
"azalea-inventory",
|
||||
]
|
||||
|
||||
[profile.release]
|
||||
|
|
9
azalea-inventory/Cargo.toml
Normal file
9
azalea-inventory/Cargo.toml
Normal 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" }
|
25
azalea-inventory/src/lib.rs
Normal file
25
azalea-inventory/src/lib.rs
Normal 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>,
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue