diff options
author | madmaxoft <github@xoft.cz> | 2014-04-04 13:29:48 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2014-04-04 13:29:48 +0200 |
commit | d77ca77086ddc158355d7d1c4b37ae19eedfe5f7 (patch) | |
tree | 5bf093d28fb0be55e4c1447161d3275cc55bb5ff /src/Blocks | |
parent | Merge branch 'master' into HTTPSizeT (diff) | |
parent | Explicit change record size. (diff) | |
download | cuberite-d77ca77086ddc158355d7d1c4b37ae19eedfe5f7.tar cuberite-d77ca77086ddc158355d7d1c4b37ae19eedfe5f7.tar.gz cuberite-d77ca77086ddc158355d7d1c4b37ae19eedfe5f7.tar.bz2 cuberite-d77ca77086ddc158355d7d1c4b37ae19eedfe5f7.tar.lz cuberite-d77ca77086ddc158355d7d1c4b37ae19eedfe5f7.tar.xz cuberite-d77ca77086ddc158355d7d1c4b37ae19eedfe5f7.tar.zst cuberite-d77ca77086ddc158355d7d1c4b37ae19eedfe5f7.zip |
Diffstat (limited to 'src/Blocks')
-rw-r--r-- | src/Blocks/BlockFluid.h | 2 | ||||
-rw-r--r-- | src/Blocks/BlockSign.h | 4 | ||||
-rw-r--r-- | src/Blocks/BlockSlab.h | 43 |
3 files changed, 14 insertions, 35 deletions
diff --git a/src/Blocks/BlockFluid.h b/src/Blocks/BlockFluid.h index 37885e4de..d486d642d 100644 --- a/src/Blocks/BlockFluid.h +++ b/src/Blocks/BlockFluid.h @@ -93,6 +93,7 @@ public: // Check if it's fuel: BLOCKTYPE BlockType; if ( + ((a_RelY + y < 0) || (a_RelY + y > cChunkDef::Height)) || !a_Chunk.UnboundedRelGetBlockType(a_RelX + x, a_RelY + y, a_RelZ + z, BlockType) || !cFireSimulator::IsFuel(BlockType) ) @@ -119,6 +120,7 @@ public: for (size_t i = 0; i < ARRAYCOUNT(CrossCoords); i++) { if ( + ((RelY + CrossCoords[i].y >= 0) && (RelY + CrossCoords[i].y <= cChunkDef::Height)) && a_Chunk.UnboundedRelGetBlockType(RelX + CrossCoords[i].x, RelY + CrossCoords[i].y, RelZ + CrossCoords[i].z, BlockType) && (BlockType == E_BLOCK_AIR) ) diff --git a/src/Blocks/BlockSign.h b/src/Blocks/BlockSign.h index 6c0becfd6..9d6fede21 100644 --- a/src/Blocks/BlockSign.h +++ b/src/Blocks/BlockSign.h @@ -31,7 +31,7 @@ public: } - static char RotationToMetaData(double a_Rotation) + static NIBBLETYPE RotationToMetaData(double a_Rotation) { a_Rotation += 180 + (180 / 16); // So it's not aligned with axis if (a_Rotation > 360) @@ -45,7 +45,7 @@ public: } - static char DirectionToMetaData(eBlockFace a_Direction) + static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction) { switch (a_Direction) { diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index 4f94d45f6..76f5ed0e7 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -11,6 +11,7 @@ #include "BlockHandler.h" #include "../Items/ItemHandler.h" +#include "Root.h" @@ -38,41 +39,9 @@ public: ) override { a_BlockType = m_BlockType; - BLOCKTYPE Type = (BLOCKTYPE) (a_Player->GetEquippedItem().m_ItemType); NIBBLETYPE Meta = (NIBBLETYPE) a_Player->GetEquippedItem().m_ItemDamage; - // HandlePlaceBlock wants a cItemHandler pointer thing, so let's give it one - cItemHandler * ItemHandler = cItemHandler::GetItemHandler(GetDoubleSlabType(Type)); - - // Check if the block at the coordinates is a slab. Eligibility for combining has already been processed in ClientHandle - if (IsAnySlabType(a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ))) - { - // Call the function in ClientHandle that places a block when the client sends the packet, - // so that plugins may interfere with the placement. - - if ((a_BlockFace == BLOCK_FACE_TOP) || (a_BlockFace == BLOCK_FACE_BOTTOM)) - { - // Top and bottom faces need no parameter modification - a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); - } - else - { - // The other faces need to distinguish between top and bottom cursor positions - if (a_CursorY > 7) - { - // Edit the call to use BLOCK_FACE_BOTTOM, otherwise it places incorrectly - a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_TOP, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); - } - else - { - // Edit the call to use BLOCK_FACE_TOP, otherwise it places incorrectly - a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_BOTTOM, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); - } - } - return false; // Cancel the event, because dblslabs were already placed, nothing else needed - } - - // Place the single-slab with correct metas: + // Set the correct metadata based on player equipped item (i.e. a_BlockMeta not initialised yet) switch (a_BlockFace) { case BLOCK_FACE_TOP: @@ -105,6 +74,14 @@ public: } case BLOCK_FACE_NONE: return false; } // switch (a_BlockFace) + + // Check if the block at the coordinates is a single slab. Eligibility for combining has already been processed in ClientHandle + // Changed to-be-placed to a double slab if we are clicking on a single slab, as opposed to placing one for the first time + if (IsAnySlabType(a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ))) + { + a_BlockType = GetDoubleSlabType(m_BlockType); + } + return true; } |