Check if item is a block, Because Not every item can be placed
This commit is contained in:
parent
460e9d3cae
commit
1b510eaa21
@ -615,8 +615,9 @@ impl Player {
|
||||
|
||||
if let Some(face) = BlockFace::from_i32(use_item_on.face.0) {
|
||||
if let Some(item) = self.inventory.lock().await.held_item() {
|
||||
let block = get_block_by_item(item.item_id)
|
||||
.expect("No item found, TODO Better error handling");
|
||||
let block = get_block_by_item(item.item_id);
|
||||
// check if item is a block, Because Not every item can be placed :D
|
||||
if let Some(block) = block {
|
||||
let entity = &self.living_entity.entity;
|
||||
let world = &entity.world;
|
||||
|
||||
@ -630,6 +631,7 @@ impl Player {
|
||||
self.client
|
||||
.send_packet(&CAcknowledgeBlockChange::new(use_item_on.sequence))
|
||||
.await;
|
||||
}
|
||||
} else {
|
||||
self.kick(TextComponent::text("Invalid block face")).await;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user