Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
7b8010b
Refactoring ongoing
Miro-Andrin Sep 10, 2021
ae66bf0
Added libcraft-inventory
Tracreed Sep 10, 2021
ed09cd9
Merge pull request #1 from Tracreed/libcraft-inventory
Miro-Andrin Sep 10, 2021
f0f785b
cha-cha-cha-Changes
Miro-Andrin Sep 10, 2021
71856b4
Turn and face the stranger
Miro-Andrin Sep 11, 2021
569366f
Ch-ch-Changes
Miro-Andrin Sep 11, 2021
e11f723
Don't want to be a richer one
Miro-Andrin Sep 11, 2021
fb26154
Ch-ch-ch-ch-Changes
Miro-Andrin Sep 11, 2021
a6971fd
(Turn and face the stranger)
Miro-Andrin Sep 11, 2021
ac9edf0
hHAHAHA
Tracreed Sep 11, 2021
ceb0266
Changed stuff as a test
Tracreed Sep 11, 2021
1646e78
Changed stuff.
Tracreed Sep 12, 2021
62ba993
Something
Tracreed Sep 12, 2021
dc838b5
Fixed a problem
Tracreed Sep 12, 2021
e04d562
Fixed most things. Some problems left.
Tracreed Sep 14, 2021
0895297
Merge branch 'refactor' into refactor-new
Miro-Andrin Sep 14, 2021
163187e
Merge pull request #4 from Tracreed/refactor-new
Miro-Andrin Sep 14, 2021
560cd5c
Finnished up.
Miro-Andrin Sep 16, 2021
a85db46
removed Filled from use.
Miro-Andrin Sep 16, 2021
14956ca
Merge remote-tracking branch 'upstream/main' into refactor
Tracreed Sep 20, 2021
9123aa7
Ongoing refactor.
Miro-Andrin Sep 20, 2021
c938abc
Fixed so it compiles and runs fine.
Tracreed Sep 20, 2021
d803603
Fix missing offhand area in inventory.json.
Tracreed Sep 20, 2021
b82ae7d
Merge pull request #5 from Tracreed/refactor
Miro-Andrin Sep 20, 2021
59e00b2
Clippy issues.
Miro-Andrin Sep 23, 2021
59d3d7b
Appease the clippy gods.
Tracreed Sep 23, 2021
52f058a
Merge pull request #6 from Tracreed/refactor
Miro-Andrin Sep 23, 2021
42229e2
cargo fmt
Tracreed Sep 23, 2021
d87f78b
Merge pull request #7 from Tracreed/refactor
Miro-Andrin Sep 23, 2021
67f7544
Added clippy ignore to inventory generator.
Tracreed Sep 23, 2021
407b31f
Just fixed the generator instead. No need to ignore clippy.
Tracreed Sep 23, 2021
7d1b05b
Fix Some(slot + 0)
Tracreed Sep 23, 2021
1fdf4a7
Fixed `let slot = index - 0;`
Tracreed Sep 23, 2021
715bf9b
Merge pull request #8 from Tracreed/refactor
Miro-Andrin Sep 23, 2021
dddfc35
Removed unnecessary borrows.
Tracreed Sep 23, 2021
044e608
Added _ to unread struct field.
Tracreed Sep 23, 2021
e7e8a96
Derived default where it was possible.
Tracreed Sep 23, 2021
d823f2d
Spelling error.
Tracreed Sep 23, 2021
00c1d73
Merge pull request #9 from Tracreed/refactor
Miro-Andrin Sep 23, 2021
0910497
`cargo fmt` wants new lines at the end of files.
Tracreed Sep 23, 2021
8c5f47a
Merge pull request #10 from Tracreed/refactor
Miro-Andrin Sep 23, 2021
31ecb3a
Merge remote-tracking branch 'upstream/main' into refactor
Tracreed Sep 25, 2021
ab6e54d
Fix merge issues.
Tracreed Sep 25, 2021
e883f3a
Removed commented out code.
Tracreed Sep 26, 2021
4dfe403
Format doc comment better.
Tracreed Sep 26, 2021
ac3130e
Remove default derive on HotbarSlot.
Tracreed Sep 26, 2021
f3eaca3
Clarify why the `unreachable!()` is unreachable.
Tracreed Sep 26, 2021
b386b7b
Add trailing newline.
Tracreed Sep 26, 2021
52e7123
Update feather/base/src/anvil/entity.rs
Miro-Andrin Sep 26, 2021
39bab9e
Merge branch 'refactor' into refactor
Tracreed Sep 26, 2021
9e03bb6
Merge pull request #11 from Tracreed/refactor
Miro-Andrin Sep 26, 2021
768c19d
set_slot takes a reference instead.
Tracreed Sep 27, 2021
fe06cfe
remove clone from handle_click_window.
Tracreed Sep 27, 2021
249b59b
Made damage an i32 on ItemStackMeta
Miro-Andrin Sep 27, 2021
2994058
Changed code to use filter_map.
Miro-Andrin Sep 27, 2021
c44b012
Merge pull request #12 from Tracreed/refactor
Miro-Andrin Sep 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"libcraft/macros",
"libcraft/particles",
"libcraft/text",
"libcraft/inventory",

# Quill
"quill/sys-macros",
Expand All @@ -29,7 +30,6 @@ members = [

# Feather (common and server)
"feather/utils",
"feather/generated",
"feather/blocks",
"feather/blocks/generator",
"feather/base",
Expand Down
6 changes: 4 additions & 2 deletions feather/base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ bitflags = "1"
bitvec = "0.21"
blocks = { path = "../blocks", package = "feather-blocks" }
byteorder = "1"
generated = { path = "../generated", package = "feather-generated" }
hematite-nbt = { git = "https://github.com/PistonDevelopers/hematite_nbt" }

libcraft-blocks = { path = "../../libcraft/blocks" }
libcraft-core = { path = "../../libcraft/core" }
libcraft-items = { path = "../../libcraft/items" }
libcraft-particles = { path = "../../libcraft/particles" }
libcraft-text = { path = "../../libcraft/text" }
libcraft-text = { path = "../../libcraft/text" }
libcraft-inventory = { path = "../../libcraft/inventory" }

nom = "5"
nom_locate = "2"
num-derive = "0.3"
Expand Down
28 changes: 19 additions & 9 deletions feather/base/src/anvil/entity.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use arrayvec::ArrayVec;
use generated::{Item, ItemStack};
use libcraft_items::{Item, ItemStack, ItemStackBuilder};
use serde::ser::Error;
use serde::{Deserialize, Serialize, Serializer};
use thiserror::Error;
Expand Down Expand Up @@ -219,8 +219,8 @@ where
Some(nbt)
};
Self {
count: stack.count as i8,
item: stack.item.name().to_owned(),
count: stack.count() as i8,
item: stack.item().name().to_owned(),
nbt,
}
}
Expand All @@ -235,12 +235,22 @@ pub struct ItemNbt {
}

impl ItemNbt {
/// Create an `ItemStack` of the specified item and amount, setting any nbt present.
/// Create an `ItemStack` of the specified item and amount, setting any NBT present.
///
/// # Panics
/// Panics if `count` is zero.
pub fn item_stack(nbt: &Option<Self>, item: Item, count: u8) -> ItemStack {
ItemStack {
count: count as u32,
item,
damage: nbt.as_ref().map(|n| n.damage).flatten().map(|x| x as u32),
match nbt {
Some(ItemNbt {
damage: Some(damage),
}) => ItemStackBuilder::with_item(item)
.count(count as u32)
.damage(*damage)
.into(),

Some(ItemNbt { damage: None }) | None => {
ItemStackBuilder::with_item(item).count(count as u32).into()
Comment thread
Miro-Andrin marked this conversation as resolved.
}
}
}
}
Expand All @@ -252,7 +262,7 @@ where
fn from(s: S) -> Self {
let stack = s.borrow();
Self {
damage: stack.damage.map(|d| d as i32),
damage: stack.damage_taken().map(|d| d as i32),
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion feather/base/src/anvil/level.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Implements level.dat file loading.

use generated::{Biome, Item};
use libcraft_core::Biome;
use libcraft_items::Item;
use serde::{Deserialize, Serialize};
use std::io::{Cursor, Read, Write};
use std::{collections::HashMap, fs::File};
Expand Down
23 changes: 13 additions & 10 deletions feather/base/src/anvil/player.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use libcraft_items::{Item, ItemStack};
use std::{
collections::HashMap,
fs,
Expand All @@ -9,7 +10,6 @@ use nbt::Value;
use serde::{Deserialize, Serialize};
use uuid::Uuid;

use generated::{Item, ItemStack};
use quill_common::components::{
CanBuild, CanCreativeFly, CreativeFlying, CreativeFlyingSpeed, Instabreak, Invulnerable,
WalkSpeed,
Expand Down Expand Up @@ -99,9 +99,9 @@ impl InventorySlot {
Some(nbt)
};
Self {
count: stack.count as i8,
count: stack.count() as i8,
slot,
item: stack.item.name().to_owned(),
item: stack.item().name().to_owned(),
nbt,
}
}
Expand Down Expand Up @@ -222,8 +222,8 @@ mod tests {
};

let item_stack: ItemStack = slot.into();
assert_eq!(item_stack.item, Item::Feather);
assert_eq!(item_stack.count, 1);
assert_eq!(item_stack.item(), Item::Feather);
assert_eq!(item_stack.count(), 1);
}

#[test]
Expand All @@ -236,9 +236,9 @@ mod tests {
};

let item_stack: ItemStack = slot.into();
assert_eq!(item_stack.item, Item::DiamondAxe);
assert_eq!(item_stack.count, 1);
assert_eq!(item_stack.damage, Some(42));
assert_eq!(item_stack.item(), Item::DiamondAxe);
assert_eq!(item_stack.count(), 1);
assert_eq!(item_stack.damage_taken(), Some(42));
}

#[test]
Expand All @@ -251,7 +251,7 @@ mod tests {
};

let item_stack: ItemStack = slot.into();
assert_eq!(item_stack.item, Item::Air);
assert_eq!(item_stack.item(), Item::Air);
}

#[test]
Expand Down Expand Up @@ -285,7 +285,10 @@ mod tests {
};
assert_eq!(slot.convert_index().unwrap(), expected);
assert_eq!(
InventorySlot::from_network_index(expected, ItemStack::new(Item::Stone, 1)),
InventorySlot::from_network_index(
expected,
ItemStack::new(Item::Stone, 1).unwrap()
),
Some(slot),
);
}
Expand Down
2 changes: 1 addition & 1 deletion feather/base/src/anvil/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use super::{block_entity::BlockEntityData, entity::EntityData};
use bitvec::{bitvec, vec::BitVec};
use blocks::BlockId;
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use generated::Biome;
use libcraft_core::Biome;
use serde::{Deserialize, Serialize};
use std::borrow::Cow;
use std::collections::BTreeMap;
Expand Down
2 changes: 1 addition & 1 deletion feather/base/src/chunk.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::usize;

use ::blocks::BlockId;
use generated::Biome;
use libcraft_core::Biome;

use crate::ChunkPosition;

Expand Down
2 changes: 1 addition & 1 deletion feather/base/src/chunk/biome_store.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use generated::Biome;
use libcraft_core::Biome;

use crate::{CHUNK_HEIGHT, CHUNK_WIDTH};

Expand Down
8 changes: 6 additions & 2 deletions feather/base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ pub use block::{BlockPositionValidationError, ValidBlockPosition};
pub use blocks::*;
pub use chunk::{Chunk, ChunkSection, CHUNK_HEIGHT, CHUNK_WIDTH};
pub use chunk_lock::*;
pub use generated::{Area, Biome, EntityKind, Inventory, Item, ItemStack};

pub use libcraft_blocks::{BlockKind, BlockState};
pub use libcraft_core::{position, vec3, BlockPosition, ChunkPosition, Gamemode, Position, Vec3d};
pub use libcraft_core::{
position, vec3, Biome, BlockPosition, ChunkPosition, EntityKind, Gamemode, Position, Vec3d,
};
pub use libcraft_inventory::{Area, Inventory};
pub use libcraft_items::{Item, ItemStack, ItemStackBuilder, ItemStackError};
pub use libcraft_particles::{Particle, ParticleKind};
pub use libcraft_text::{deserialize_text, Text, Title};
#[doc(inline)]
Expand Down
6 changes: 3 additions & 3 deletions feather/base/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use crate::{Direction, ValidBlockPosition};
use bitflags::bitflags;
use generated::ItemStack;
use libcraft_items::InventorySlot;
use std::collections::BTreeMap;
use uuid::Uuid;

Expand Down Expand Up @@ -44,7 +44,7 @@ pub enum MetaEntry {
String(String),
Chat(String),
OptChat(OptChat),
Slot(Option<ItemStack>),
Slot(InventorySlot),
Boolean(bool),
Rotation(f32, f32, f32),
Position(ValidBlockPosition),
Expand Down Expand Up @@ -119,7 +119,7 @@ impl ToMetaEntry for OptChat {
}
}

impl ToMetaEntry for Option<ItemStack> {
impl ToMetaEntry for InventorySlot {
fn to_meta_entry(&self) -> MetaEntry {
MetaEntry::Slot(self.clone())
}
Expand Down
2 changes: 1 addition & 1 deletion feather/blocks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ edition = "2018"
[dependencies]
anyhow = "1"
bincode = "1"
feather-generated = { path = "../generated" }
num-traits = "0.2"
once_cell = { version = "1" }
serde = { version = "1", features = [ "derive" ] }
thiserror = "1"
vek = "0.14"
libcraft-blocks = { path = "../../libcraft/blocks" }
2 changes: 1 addition & 1 deletion feather/blocks/generator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct Property {
/// CamelCase name of this property if it were a struct or enum.
///
/// Often prefixed with the name of the block to which this property belongs.
name_camel_case: Ident,
_name_camel_case: Ident,
/// The kind of this property.
kind: PropertyKind,
/// Possible values of this property.
Expand Down
2 changes: 1 addition & 1 deletion feather/blocks/generator/src/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl PropertyStore {
Property {
name: ident(name),
real_name: real_name.to_owned(),
name_camel_case: ident(name.to_camel_case()),
_name_camel_case: ident(name.to_camel_case()),
kind: guess_property_kind(&possible_values, &name.to_camel_case()),
possible_values,
}
Expand Down
2 changes: 1 addition & 1 deletion feather/blocks/src/categories.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{BlockId, BlockKind};
use feather_generated::SimplifiedBlockKind;
use libcraft_blocks::SimplifiedBlockKind;

#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum PlacementType {
Expand Down
3 changes: 1 addition & 2 deletions feather/blocks/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
pub use libcraft_blocks::{BlockKind, SimplifiedBlockKind};
use num_traits::FromPrimitive;
use std::convert::TryFrom;
use thiserror::Error;

pub use feather_generated::{BlockKind, SimplifiedBlockKind};

pub mod categories;
mod directions;
#[allow(warnings)]
Expand Down
3 changes: 2 additions & 1 deletion feather/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ base = { path = "../base", package = "feather-base" }
blocks = { path = "../blocks", package = "feather-blocks" }
ecs = { path = "../ecs", package = "feather-ecs" }
flume = "0.10"
generated = { path = "../generated", package = "feather-generated" }
itertools = "0.10"
log = "0.4"
parking_lot = "0.11"
Expand All @@ -20,6 +19,8 @@ smartstring = "0.2"
utils = { path = "../utils", package = "feather-utils" }
uuid = { version = "0.8", features = [ "v4" ] }
libcraft-core = { path = "../../libcraft/core" }
libcraft-inventory = { path = "../../libcraft/inventory" }
libcraft-items = { path = "../../libcraft/items" }
rayon = "1.5"
worldgen = { path = "../worldgen", package = "feather-worldgen" }
rand = "0.8"
6 changes: 0 additions & 6 deletions feather/common/src/entities/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,3 @@ impl HotbarSlot {
Ok(())
}
}

impl Default for HotbarSlot {
fn default() -> Self {
HotbarSlot(0)
}
}
Loading