diff --git a/Cargo.lock b/Cargo.lock index 320e3a9d2..613020cf5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1913,7 +1913,7 @@ checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a" [[package]] name = "lieutenant" version = "0.2.0" -source = "git+https://github.com/feather-rs/lieutenant?branch=master#c8f7a3fb02fe852dcd91de5d711e993610dda29a" +source = "git+https://github.com/feather-rs/lieutenant#c8f7a3fb02fe852dcd91de5d711e993610dda29a" dependencies = [ "derivative 2.1.1", "lieutenant-macros", @@ -1924,7 +1924,7 @@ dependencies = [ [[package]] name = "lieutenant-macros" version = "0.1.0" -source = "git+https://github.com/feather-rs/lieutenant?branch=master#c8f7a3fb02fe852dcd91de5d711e993610dda29a" +source = "git+https://github.com/feather-rs/lieutenant#c8f7a3fb02fe852dcd91de5d711e993610dda29a" dependencies = [ "darling", "proc-macro-error", diff --git a/core/blocks/Cargo.toml b/core/blocks/Cargo.toml index f9596e467..e2d429b4b 100644 --- a/core/blocks/Cargo.toml +++ b/core/blocks/Cargo.toml @@ -8,6 +8,7 @@ edition = "2018" feather-definitions = { path = "../../definitions" } feather-util = { path = "../util" } + bit-set = "0.5" once_cell = { version = "1.3", features = ["parking_lot"] } anyhow = "1.0" diff --git a/core/blocks/src/lib.rs b/core/blocks/src/lib.rs index fca0df083..baf4505d2 100644 --- a/core/blocks/src/lib.rs +++ b/core/blocks/src/lib.rs @@ -2,8 +2,10 @@ use num_traits::FromPrimitive; use std::convert::TryFrom; use thiserror::Error; + pub use feather_definitions::BlockKind; + mod categories; mod directions; #[allow(warnings)] @@ -11,6 +13,7 @@ mod directions; mod generated; mod wall_blocks; + static BLOCK_TABLE: Lazy = Lazy::new(|| { let bytes = include_bytes!("generated/table.dat"); bincode::deserialize(bytes).expect("failed to deserialize generated block table (bincode)") @@ -90,6 +93,7 @@ impl From for u32 { } } + #[derive(Debug, Error)] pub enum BlockIdFromU32Error { #[error("invalid block kind ID {0}")] diff --git a/server/block/src/chest.rs b/server/block/src/chest.rs index c55b17de9..e4ef52065 100644 --- a/server/block/src/chest.rs +++ b/server/block/src/chest.rs @@ -358,14 +358,21 @@ impl InteractionHandler for ChestInteraction { // For large chests, the top row is the left // chest (ChestKind::Right, oddly enough) and the // bottom row is the right chest (ChestKind::Left). + + - let chests: ArrayVec<[Option; 2]> = opened_chests(game, pos); - let slots = slots(world, &chests); + match game.block_at(pos + BlockPosition::new(0,1,0)){ + Some(block) if block.kind().full_block() => (), + _ => { + let chests: ArrayVec<[Option; 2]> = opened_chests(game, pos); + let slots = slots(world, &chests); - send_open_window(world, player, slots.len(), window_id); - send_window_items(world, player, slots, window_id); + send_open_window(world, player, slots.len(), window_id); + send_window_items(world, player, slots, window_id); - set_player_window(game, world, player, &chests); + set_player_window(game, world, player, &chests); + } + } } fn block_kind(&self) -> BlockKind { diff --git a/server/player/src/packet_handlers/placement.rs b/server/player/src/packet_handlers/placement.rs index 7170808c8..d4cf8303b 100644 --- a/server/player/src/packet_handlers/placement.rs +++ b/server/player/src/packet_handlers/placement.rs @@ -39,6 +39,7 @@ static INTERACTION_HANDLERS: Lazy(player); + + let item = { let inventory = world.get::(player); match inventory.item_in_main_hand(player, world) { @@ -121,20 +124,24 @@ pub fn handle_block_placement( packet.location + packet.face.placement_offset() }; - let current_block = game.block_at(pos).unwrap(); + match game.block_at(pos) { + Some(current_block) => { + if !current_block.is_replaceable() { + return; + } - if !current_block.is_replaceable() { - return; + // Deny replacing grass with grass for example + if current_block.is_replaceable() + && !current_block.is_air() + && !current_block.is_fluid() + && block.is_replaceable() + { + return; + } + }, + None => () } - // Deny replacing grass with grass for example - if current_block.is_replaceable() - && !current_block.is_air() - && !current_block.is_fluid() - && block.is_replaceable() - { - return; - } let block = update_block_state_for_placement( game, @@ -548,3 +555,8 @@ fn facing_directions(d: Vec3d) -> [FacingCubic; 6] { dirs[0].opposite(), ] } + + + + +