Fix: Place block on correct side
This commit is contained in:
parent
94748859c6
commit
fdb94d43fa
@ -1,5 +1,7 @@
|
|||||||
use num_derive::FromPrimitive;
|
use num_derive::FromPrimitive;
|
||||||
|
|
||||||
|
use crate::vector3::Vector3;
|
||||||
|
|
||||||
pub mod block_registry;
|
pub mod block_registry;
|
||||||
|
|
||||||
#[derive(FromPrimitive)]
|
#[derive(FromPrimitive)]
|
||||||
@ -11,3 +13,17 @@ pub enum BlockFace {
|
|||||||
West,
|
West,
|
||||||
East,
|
East,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl BlockFace {
|
||||||
|
pub fn to_offset(&self) -> Vector3<i32> {
|
||||||
|
match self {
|
||||||
|
BlockFace::Bottom => (0, -1, 0),
|
||||||
|
BlockFace::East => (1, 0, 0),
|
||||||
|
BlockFace::North => (0, 0, -1),
|
||||||
|
BlockFace::South => (0, 0, 1),
|
||||||
|
BlockFace::Top => (0, 1, 0),
|
||||||
|
BlockFace::West => (-1, 0, 0),
|
||||||
|
}
|
||||||
|
.into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -4,14 +4,14 @@ use pumpkin_protocol::{
|
|||||||
client::play::{
|
client::play::{
|
||||||
Animation, CBlockUpdate, CEntityAnimation, CEntityVelocity, CHeadRot, CHurtAnimation,
|
Animation, CBlockUpdate, CEntityAnimation, CEntityVelocity, CHeadRot, CHurtAnimation,
|
||||||
CSystemChatMessge, CUpdateEntityPos, CUpdateEntityPosRot, CUpdateEntityRot,
|
CSystemChatMessge, CUpdateEntityPos, CUpdateEntityPosRot, CUpdateEntityRot,
|
||||||
},
|
}, position::WorldPosition, server::play::{
|
||||||
server::play::{
|
|
||||||
Action, SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, SInteract,
|
Action, SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, SInteract,
|
||||||
SPlayerAction, SPlayerCommand, SPlayerPosition, SPlayerPositionRotation, SPlayerRotation,
|
SPlayerAction, SPlayerCommand, SPlayerPosition, SPlayerPositionRotation, SPlayerRotation,
|
||||||
SSetHeldItem, SSwingArm, SUseItemOn,
|
SSetHeldItem, SSwingArm, SUseItemOn,
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
use pumpkin_text::TextComponent;
|
use pumpkin_text::TextComponent;
|
||||||
|
use pumpkin_world::block::BlockFace;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
commands::{handle_command, CommandSender},
|
commands::{handle_command, CommandSender},
|
||||||
@ -317,7 +317,8 @@ impl Client {
|
|||||||
|
|
||||||
pub fn handle_use_item_on(&mut self, server: &mut Server, use_item_on: SUseItemOn) {
|
pub fn handle_use_item_on(&mut self, server: &mut Server, use_item_on: SUseItemOn) {
|
||||||
let mut location = use_item_on.location;
|
let mut location = use_item_on.location;
|
||||||
location.y += 2;
|
let face = BlockFace::from_i32(use_item_on.face.0).unwrap();
|
||||||
|
let location = WorldPosition(location.0 + face.to_offset());
|
||||||
server.broadcast_packet(self, &CBlockUpdate::new(location, 11.into()));
|
server.broadcast_packet(self, &CBlockUpdate::new(location, 11.into()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user