Skip to content

Commit

Permalink
Merge pull request #5 from koskja/revert-4-main
Browse files Browse the repository at this point in the history
Revert "Merge upstream"
  • Loading branch information
koskja authored Dec 29, 2021
2 parents e2f89b7 + ba40655 commit 19cd980
Show file tree
Hide file tree
Showing 70 changed files with 27,952 additions and 1,707 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,18 @@ jobs:
target: ${{ matrix.target }}
override: true

- name: aarch64-specific items
run: |
# Use the beta compiler
sudo xcode-select -s /Applications/Xcode_12.2.app/Contents/Developer/
# Set SDK environment variables
echo "SDKROOT=$(xcrun -sdk macosx11.0 --show-sdk-path)" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx11.0 --show-sdk-platform-version)" >> $GITHUB_ENV
if: matrix.target == 'aarch64-apple-darwin'

- name: Run cargo build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.use-cross }}
command: build
args: --target=${{ matrix.target }}
args: --target=${{ matrix.target }}
11 changes: 10 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,19 @@ jobs:
toolchain: stable
target: ${{ matrix.target }}
override: true

- name: aarch64-specific items
run: |
# Use the beta compiler
sudo xcode-select -s /Applications/Xcode_12.2.app/Contents/Developer/
# Set SDK environment variables
echo "SDKROOT=$(xcrun -sdk macosx11.0 --show-sdk-path)" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx11.0 --show-sdk-platform-version)" >> $GITHUB_ENV
if: matrix.target == 'aarch64-apple-darwin'

- name: Run cargo build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.use-cross }}
command: build
args: --release --target ${{ matrix.target }}
args: --release --target ${{ matrix.target }}
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,7 +8,6 @@ members = [
"libcraft/macros",
"libcraft/particles",
"libcraft/text",
"libcraft/inventory",

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

# Feather (common and server)
"feather/utils",
"feather/generated",
"feather/blocks",
"feather/blocks/generator",
"feather/base",
Expand Down
6 changes: 2 additions & 4 deletions feather/base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ 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-inventory = { path = "../../libcraft/inventory" }

libcraft-text = { path = "../../libcraft/text" }
nom = "5"
nom_locate = "2"
num-derive = "0.3"
Expand Down
28 changes: 9 additions & 19 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 libcraft_items::{Item, ItemStack, ItemStackBuilder};
use generated::{Item, ItemStack};
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,22 +235,12 @@ pub struct ItemNbt {
}

impl ItemNbt {
/// Create an `ItemStack` of the specified item and amount, setting any NBT present.
///
/// # Panics
/// Panics if `count` is zero.
/// Create an `ItemStack` of the specified item and amount, setting any nbt present.
pub fn item_stack(nbt: &Option<Self>, item: Item, count: u8) -> ItemStack {
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()
}
ItemStack {
count: count as u32,
item,
damage: nbt.as_ref().map(|n| n.damage).flatten().map(|x| x as u32),
}
}
}
Expand All @@ -262,7 +252,7 @@ where
fn from(s: S) -> Self {
let stack = s.borrow();
Self {
damage: stack.damage_taken().map(|d| d as i32),
damage: stack.damage.map(|d| d as i32),
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions feather/base/src/anvil/level.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Implements level.dat file loading.
use libcraft_core::Biome;
use libcraft_items::Item;
use generated::{Biome, Item};
use serde::{Deserialize, Serialize};
use std::io::{Cursor, Read, Write};
use std::{collections::HashMap, fs::File};
Expand Down
31 changes: 14 additions & 17 deletions feather/base/src/anvil/player.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use libcraft_items::{Item, ItemStack};
use std::{
collections::HashMap,
fs,
Expand All @@ -10,6 +9,7 @@ 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 @@ -70,8 +70,8 @@ pub struct InventorySlot {
}

impl InventorySlot {
/// Converts an [`ItemStack`] and network protocol index into an [`InventorySlot`].
pub fn from_network_index(network: usize, stack: &ItemStack) -> Option<Self> {
/// Converts an `ItemStack` and network protocol index into an `InventorySlot`.
pub fn from_network_index(network: usize, stack: ItemStack) -> Option<Self> {
let slot = if SLOT_HOTBAR_OFFSET <= network && network < SLOT_HOTBAR_OFFSET + HOTBAR_SIZE {
// Hotbar
(network - SLOT_HOTBAR_OFFSET) as i8
Expand All @@ -90,18 +90,18 @@ impl InventorySlot {
Some(Self::from_inventory_index(slot, stack))
}

/// Converts an [`ItemStack`] and inventory position index into an [`InventorySlot`].
pub fn from_inventory_index(slot: i8, stack: &ItemStack) -> Self {
/// Converts an `ItemStack` and inventory position index into an `InventorySlot`.
pub fn from_inventory_index(slot: i8, stack: ItemStack) -> Self {
let nbt = stack.clone().into();
let nbt = if nbt == Default::default() {
None
} else {
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_taken(), Some(42));
assert_eq!(item_stack.item, Item::DiamondAxe);
assert_eq!(item_stack.count, 1);
assert_eq!(item_stack.damage, 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,10 +285,7 @@ mod tests {
};
assert_eq!(slot.convert_index().unwrap(), expected);
assert_eq!(
InventorySlot::from_network_index(
expected,
&ItemStack::new(Item::Stone, 1).unwrap()
),
InventorySlot::from_network_index(expected, ItemStack::new(Item::Stone, 1)),
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 libcraft_core::Biome;
use generated::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 libcraft_core::Biome;
use generated::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 libcraft_core::Biome;
use generated::Biome;

use crate::{CHUNK_HEIGHT, CHUNK_WIDTH};

Expand Down
8 changes: 2 additions & 6 deletions feather/base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@ 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, Biome, BlockPosition, ChunkPosition, EntityKind, Gamemode, Position, Vec3d,
};
pub use libcraft_inventory::{Area, Inventory};
pub use libcraft_items::{Item, ItemStack, ItemStackBuilder, ItemStackError};
pub use libcraft_core::{position, vec3, BlockPosition, ChunkPosition, Gamemode, Position, Vec3d};
pub use libcraft_particles::{Particle, ParticleKind};
pub use libcraft_text::{deserialize_text, Text, Title};
#[doc(inline)]
Expand Down
Loading

0 comments on commit 19cd980

Please sign in to comment.