From 43e684071933adef93040e8d4b830d5c6b71cf9a Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sat, 12 Jan 2013 04:46:01 +0000 Subject: Merged branch "branches/hooks" into "trunk". git-svn-id: http://mc-server.googlecode.com/svn/trunk@1139 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Blocks/BlockStairs.h | 50 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 8 deletions(-) (limited to 'source/Blocks/BlockStairs.h') diff --git a/source/Blocks/BlockStairs.h b/source/Blocks/BlockStairs.h index 71df6f00e..6fcbc2cba 100644 --- a/source/Blocks/BlockStairs.h +++ b/source/Blocks/BlockStairs.h @@ -1,22 +1,56 @@ + #pragma once + #include "BlockHandler.h" #include "../Stairs.h" -class cBlockStairsHandler : public cBlockHandler + + + + +class cBlockStairsHandler : + public cBlockHandler { public: - cBlockStairsHandler(BLOCKTYPE a_BlockType) - : cBlockHandler(a_BlockType) + cBlockStairsHandler(BLOCKTYPE a_BlockType) : + cBlockHandler(a_BlockType) { } - 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, cStairs::RotationToMetaData(a_Player->GetRotation(), a_Dir)); - OnPlacedByPlayer(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_Dir); + a_BlockType = m_BlockType; + a_BlockMeta = cStairs::RotationToMetaData(a_Player->GetRotation()); + switch (a_BlockFace) + { + case BLOCK_FACE_TOP: break; + case BLOCK_FACE_BOTTOM: a_BlockMeta = a_BlockMeta | 0x4; break; // When placing onto a bottom face, always place an upside-down stairs block + case BLOCK_FACE_EAST: + case BLOCK_FACE_NORTH: + case BLOCK_FACE_SOUTH: + case BLOCK_FACE_WEST: + { + // When placing onto a sideways face, check cursor, if in top half, make it an upside-down stairs block + if (a_CursorY < 8) + { + a_BlockMeta |= 0x4; + } + break; + } + } + return true; } - //TODO: step sound -}; + // TODO: step sound +} ; + + + + -- cgit v1.2.3