summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Blocks/BlockDoor.h25
-rw-r--r--src/Blocks/BlockOre.h5
-rw-r--r--src/Items/ItemDoor.h2
-rw-r--r--src/Items/ItemSlab.h23
4 files changed, 49 insertions, 6 deletions
diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h
index 53f84b553..445383e7c 100644
--- a/src/Blocks/BlockDoor.h
+++ b/src/Blocks/BlockDoor.h
@@ -6,7 +6,7 @@
#include "Chunk.h"
#include "MetaRotator.h"
#include "ChunkInterface.h"
-
+#include "BlockSlab.h"
@@ -109,16 +109,31 @@ public:
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
- return ((a_RelY > 0) && CanBeOn(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)));
+ return ((a_RelY > 0) && CanBeOn(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ), a_Chunk.GetMeta(a_RelX, a_RelY - 1, a_RelZ)));
}
/** Returns true if door can be placed on the specified block type. */
- static bool CanBeOn(BLOCKTYPE a_BlockType)
+ static bool CanBeOn(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- // Vanilla refuses to place doors on transparent blocks
+ // Vanilla refuses to place doors on transparent blocks, except top-half slabs and other doors
// We need to keep the door compatible with itself, otherwise the top half drops while the bottom half stays
- return !cBlockInfo::IsTransparent(a_BlockType) || IsDoorBlockType(a_BlockType);
+
+ // Doors can be placed on upside-down slabs
+ if (cBlockSlabHandler::IsAnySlabType(a_BlockType) && ((a_BlockMeta & 0x08) != 0))
+ {
+ return true;
+ }
+ // Doors can also be placed on other doors
+ else if (IsDoorBlockType(a_BlockType))
+ {
+ return true;
+ }
+ // Doors can not be placed on transparent blocks, but on any other block
+ else
+ {
+ return !cBlockInfo::IsTransparent(a_BlockType);
+ }
}
diff --git a/src/Blocks/BlockOre.h b/src/Blocks/BlockOre.h
index 08d79f435..7c4ae01f9 100644
--- a/src/Blocks/BlockOre.h
+++ b/src/Blocks/BlockOre.h
@@ -50,6 +50,11 @@ public:
a_Pickups.push_back(cItem(E_ITEM_COAL));
break;
}
+ case E_BLOCK_NETHER_QUARTZ_ORE:
+ {
+ a_Pickups.push_back(cItem(E_ITEM_NETHER_QUARTZ));
+ break;
+ }
default:
{
a_Pickups.push_back(cItem(m_BlockType));
diff --git a/src/Items/ItemDoor.h b/src/Items/ItemDoor.h
index 524c49a5c..ddd3d4e20 100644
--- a/src/Items/ItemDoor.h
+++ b/src/Items/ItemDoor.h
@@ -40,7 +40,7 @@ public:
}
// The door needs a compatible block below it:
- if (!cBlockDoorHandler::CanBeOn(a_World.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ)))
+ if (!cBlockDoorHandler::CanBeOn(a_World.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ), a_World.GetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ)))
{
return false;
}
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);
/*