diff options
author | wraith11 <wraith11@users.noreply.github.com> | 2015-04-08 00:16:10 +0200 |
---|---|---|
committer | wraith11 <TheWraith@web.de> | 2015-04-22 23:01:21 +0200 |
commit | 85c37dd3a0d811e5956a3ec861773e555aa5ae6d (patch) | |
tree | 97ec0df37512e893723e987cec4d3c9b4609e53f /src/Items | |
parent | Added extra divide operator to Vector3. (diff) | |
download | cuberite-85c37dd3a0d811e5956a3ec861773e555aa5ae6d.tar cuberite-85c37dd3a0d811e5956a3ec861773e555aa5ae6d.tar.gz cuberite-85c37dd3a0d811e5956a3ec861773e555aa5ae6d.tar.bz2 cuberite-85c37dd3a0d811e5956a3ec861773e555aa5ae6d.tar.lz cuberite-85c37dd3a0d811e5956a3ec861773e555aa5ae6d.tar.xz cuberite-85c37dd3a0d811e5956a3ec861773e555aa5ae6d.tar.zst cuberite-85c37dd3a0d811e5956a3ec861773e555aa5ae6d.zip |
Diffstat (limited to 'src/Items')
-rw-r--r-- | src/Items/ItemSlab.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/Items/ItemSlab.h b/src/Items/ItemSlab.h index b0b5ce005..3a78cc016 100644 --- a/src/Items/ItemSlab.h +++ b/src/Items/ItemSlab.h @@ -39,10 +39,15 @@ public: int a_CursorX, int a_CursorY, int a_CursorZ ) override { + // Prepare sound effect + AString PlaceSound = cBlockInfo::GetPlaceSound(m_ItemType); + float Volume = 1.0f, Pitch = 0.8f; + // Special slab handling - placing a slab onto another slab produces a dblslab instead: BLOCKTYPE ClickedBlockType; NIBBLETYPE ClickedBlockMeta; a_World.GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, ClickedBlockType, ClickedBlockMeta); + // If clicked on a half slab directly if ( (ClickedBlockType == m_ItemType) && // Placing the same slab material ((ClickedBlockMeta & 0x07) == a_EquippedItem.m_ItemDamage) // Placing the same slab sub-kind (and existing slab is single) @@ -54,6 +59,7 @@ public: ((ClickedBlockMeta & 0x08) == 0) ) { + a_World.BroadcastSoundEffect(PlaceSound, a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5, Volume, Pitch); return a_Player.PlaceBlock(a_BlockX, a_BlockY, a_BlockZ, m_DoubleSlabBlockType, ClickedBlockMeta & 0x07); } @@ -63,11 +69,28 @@ public: ((ClickedBlockMeta & 0x08) != 0) ) { + a_World.BroadcastSoundEffect(PlaceSound, a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5, Volume, Pitch); return a_Player.PlaceBlock(a_BlockX, a_BlockY, a_BlockZ, m_DoubleSlabBlockType, ClickedBlockMeta & 0x07); } } + // Checking the type of block that should be placed + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); + BLOCKTYPE PlaceBlockType; + NIBBLETYPE PlaceBlockMeta; + a_World.GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, PlaceBlockType, PlaceBlockMeta); + // If it's a slab combine into a doubleslab (means that clicked on side, top or bottom of a block adjacent to a half slab) + if ( + (PlaceBlockType == m_ItemType) && // Placing the same slab material + ((PlaceBlockMeta & 0x07) == a_EquippedItem.m_ItemDamage) // Placing the same slab sub-kind (and existing slab is single) + ) + { + a_World.BroadcastSoundEffect(PlaceSound, a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5, Volume, Pitch); + return a_Player.PlaceBlock(a_BlockX, a_BlockY, a_BlockZ, m_DoubleSlabBlockType, PlaceBlockMeta & 0x07); + } + // The slabs didn't combine, use the default handler to place the slab: + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, true); bool res = super::OnPlayerPlace(a_World, a_Player, a_EquippedItem, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ); /* |