diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-01-12 05:46:01 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-01-12 05:46:01 +0100 |
commit | 43e684071933adef93040e8d4b830d5c6b71cf9a (patch) | |
tree | 014e5300feb1cdbbb8f24e4e42594eeb841f0be2 /source/Blocks/BlockSlab.h | |
parent | Fixed rclk in doublechests (diff) | |
download | cuberite-43e684071933adef93040e8d4b830d5c6b71cf9a.tar cuberite-43e684071933adef93040e8d4b830d5c6b71cf9a.tar.gz cuberite-43e684071933adef93040e8d4b830d5c6b71cf9a.tar.bz2 cuberite-43e684071933adef93040e8d4b830d5c6b71cf9a.tar.lz cuberite-43e684071933adef93040e8d4b830d5c6b71cf9a.tar.xz cuberite-43e684071933adef93040e8d4b830d5c6b71cf9a.tar.zst cuberite-43e684071933adef93040e8d4b830d5c6b71cf9a.zip |
Diffstat (limited to 'source/Blocks/BlockSlab.h')
-rw-r--r-- | source/Blocks/BlockSlab.h | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/source/Blocks/BlockSlab.h b/source/Blocks/BlockSlab.h index 45488480c..2abcc6364 100644 --- a/source/Blocks/BlockSlab.h +++ b/source/Blocks/BlockSlab.h @@ -24,24 +24,41 @@ public: }
- virtual void PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
+ virtual bool GetPlacementBlockTypeMeta(
+ cWorld * a_World, cPlayer * a_Player,
+ int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace,
+ int a_CursorX, int a_CursorY, int a_CursorZ,
+ BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
+ ) override
{
- a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, DirectionToMetaData( a_Dir, a_BlockMeta ));
- OnPlacedByPlayer(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_Dir);
+ a_BlockType = m_BlockType;
+ NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage & 0x07);
+ switch (a_BlockFace)
+ {
+ case BLOCK_FACE_TOP: a_BlockMeta = Meta & 0x7; break; // Always bottom half of the slab when placing on top of something
+ case BLOCK_FACE_BOTTOM: a_BlockMeta = Meta | 0x8; break; // Always top half of the slab when placing on bottom of something
+ case BLOCK_FACE_EAST:
+ case BLOCK_FACE_NORTH:
+ case BLOCK_FACE_SOUTH:
+ case BLOCK_FACE_WEST:
+ {
+ if (a_CursorY > 7)
+ {
+ // Cursor at the top half of the face, place a top half of slab
+ a_BlockMeta = Meta | 0x8;
+ }
+ else
+ {
+ // Cursor at the bottom half of the face, place a bottom half of slab:
+ a_BlockMeta = Meta & 0x7;
+ }
+ break;
+ }
+ } // switch (a_BlockFace)
+ return true;
}
- static char DirectionToMetaData( char a_Direction, NIBBLETYPE Meta )
- {
- char result = Meta;
- if( a_Direction == 0)
- {
- result |= 0x8;
- }
- return result;
- }
-
-
virtual const char * GetStepSound(void) override
{
return ((m_BlockType == E_BLOCK_WOODEN_SLAB) || (m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? "step.wood" : "step.stone";
|