Skip to content

Commit

Permalink
base: Move world save implementation into base
Browse files Browse the repository at this point in the history
  • Loading branch information
caelunshun committed Sep 8, 2020
1 parent f1a8b24 commit fcdb9dd
Show file tree
Hide file tree
Showing 16 changed files with 230 additions and 146 deletions.
115 changes: 115 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"crates/base",
"crates/ecs",
"crates/datapacks",
"crates/worldgen",
"crates/common",
"crates/protocol",
"crates/server",
Expand Down
26 changes: 0 additions & 26 deletions core/anvil/Cargo.toml

This file was deleted.

33 changes: 1 addition & 32 deletions core/inventory/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,7 @@ use smallvec::{smallvec, SmallVec};
use thiserror::Error;

pub mod constants {
// Constants representing various standard inventory slot indices
// for the `Player` window
// Deprecated; mainly for interop with world saves.

pub const SLOT_CRAFTING_OUTPUT: usize = 0;
pub const SLOT_CRAFTING_INPUT_X0_Y0: usize = 1;
pub const SLOT_CRAFTING_INPUT_X1_Y0: usize = 2;
pub const SLOT_CRAFTING_INPUT_X0_Y1: usize = 3;
pub const SLOT_CRAFTING_INPUT_X1_Y1: usize = 4;

pub const SLOT_ARMOR_MIN: usize = 5;
pub const SLOT_ARMOR_MAX: usize = 8;

pub const SLOT_ARMOR_HEAD: usize = 5;
pub const SLOT_ARMOR_CHEST: usize = 6;
pub const SLOT_ARMOR_LEGS: usize = 7;
pub const SLOT_ARMOR_FEET: usize = 8;

pub const SLOT_OFFHAND: usize = 45;

pub const SLOT_INVENTORY_OFFSET: usize = 9;
pub const SLOT_HOTBAR_OFFSET: usize = 36;

pub const HOTBAR_SIZE: usize = 9;
pub const INVENTORY_SIZE: usize = 27;

pub const SLOT_ENTITY_EQUIPMENT_MAIN_HAND: usize = 0;
pub const SLOT_ENTITY_EQUIPMENT_OFF_HAND: usize = 1;
pub const SLOT_ENTITY_EQUIPMENT_BOOTS: usize = 2;
pub const SLOT_ENTITY_EQUIPMENT_LEGGINGS: usize = 3;
pub const SLOT_ENTITY_EQUIPMENT_CHESTPLATE: usize = 4;
pub const SLOT_ENTITY_EQUIPMENT_HELMET: usize = 5;

}

/// Converted from of a protocol index, used
Expand Down
6 changes: 6 additions & 0 deletions crates/base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ resources = { version = "1", default-features = false }
vek = "0.12"
ahash = "0.4"
smallvec = "1"
arrayvec = { version = "0.5", features = ["serde"] }
bitflags = "1"
parking_lot = "0.11"
uuid = { version = "0.8", features = ["serde"] }
num-traits = "0.2"
num-derive = "0.3"
bitvec = "0.18"

# Text markdown parsing
nom = "5"
Expand All @@ -27,5 +29,9 @@ serde = { version = "1", features = ["derive"] }
serde_with = "1"
serde_json = "1"
hematite-nbt = "0.5"
byteorder = "1"
anyhow = "1"
thiserror = "1"

[dev-dependencies]
serde_test = "1"
2 changes: 1 addition & 1 deletion core/anvil/src/lib.rs → crates/base/src/anvil.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Module containing functions for loading and saving to
//! Loading and saving to/from
//! world saves. Currently includes region file loading,
//! player data loading, and level data loading.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::player::InventorySlot;
use serde::ser::Error;
use serde::{Deserialize, Serialize, Serializer};

use super::player::InventorySlot;

/// A block entity loaded or saved to the Anvil format.
/// Should be serialized using NBT.
///
Expand Down
Loading

0 comments on commit fcdb9dd

Please sign in to comment.