summaryrefslogtreecommitdiffstats
path: root/src/Blocks
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Blocks/BlockButton.cpp32
-rw-r--r--src/Blocks/BlockButton.h26
-rw-r--r--src/Blocks/BlockComparator.cpp53
-rw-r--r--src/Blocks/BlockComparator.h24
-rw-r--r--src/Blocks/BlockHandler.cpp2
-rw-r--r--src/Blocks/BlockHandler.h27
-rw-r--r--src/Blocks/BlockLever.cpp31
-rw-r--r--src/Blocks/BlockLever.h14
-rw-r--r--src/Blocks/BlockRedstone.cpp27
-rw-r--r--src/Blocks/BlockRedstone.h7
-rw-r--r--src/Blocks/BlockRedstoneRepeater.cpp50
-rw-r--r--src/Blocks/BlockRedstoneRepeater.h33
-rw-r--r--src/Blocks/BlockSnow.h42
-rw-r--r--src/Blocks/BlockStairs.h24
-rw-r--r--src/Blocks/BlockStems.h1
-rw-r--r--src/Blocks/BlockTrapdoor.h108
16 files changed, 261 insertions, 240 deletions
diff --git a/src/Blocks/BlockButton.cpp b/src/Blocks/BlockButton.cpp
deleted file mode 100644
index a48e82f4d..000000000
--- a/src/Blocks/BlockButton.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-
-#include "Globals.h"
-#include "BlockButton.h"
-
-
-
-
-
-cBlockButtonHandler::cBlockButtonHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
-{
-}
-
-
-
-
-
-void cBlockButtonHandler::OnUse(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)
-{
- // Flip the ON bit on/off using the XOR bitwise operation
- NIBBLETYPE Meta = (a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) | 0x08);
-
- a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta);
- a_World->BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
-
- // Queue a button reset (unpress)
- a_World->QueueSetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, (a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) & 0x07), m_BlockType == E_BLOCK_STONE_BUTTON ? 20 : 30);
-}
-
-
-
-
diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h
index e2c60002b..ec897835a 100644
--- a/src/Blocks/BlockButton.h
+++ b/src/Blocks/BlockButton.h
@@ -10,9 +10,23 @@ class cBlockButtonHandler :
public cBlockHandler
{
public:
- cBlockButtonHandler(BLOCKTYPE a_BlockType);
+ cBlockButtonHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
- virtual void OnUse(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) override;
+ virtual void OnUse(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) override
+ {
+ // Flip the ON bit on/off using the XOR bitwise operation
+ NIBBLETYPE Meta = (a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) | 0x08);
+
+ a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
+ a_World->BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
+
+ // Queue a button reset (unpress)
+ a_World->QueueSetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, (a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) & 0x07), m_BlockType == E_BLOCK_STONE_BUTTON ? 20 : 30);
+ }
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
@@ -51,10 +65,10 @@ public:
{
switch (a_BlockFace)
{
- case BLOCK_FACE_ZM: { return 0x4; }
- case BLOCK_FACE_ZP: { return 0x3; }
- case BLOCK_FACE_XM: { return 0x2; }
- case BLOCK_FACE_XP: { return 0x1; }
+ case BLOCK_FACE_ZM: return 0x4;
+ case BLOCK_FACE_ZP: return 0x3;
+ case BLOCK_FACE_XM: return 0x2;
+ case BLOCK_FACE_XP: return 0x1;
default:
{
ASSERT(!"Unhandled block face!");
diff --git a/src/Blocks/BlockComparator.cpp b/src/Blocks/BlockComparator.cpp
deleted file mode 100644
index 8bc0ac5ac..000000000
--- a/src/Blocks/BlockComparator.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-
-#include "Globals.h"
-#include "BlockComparator.h"
-#include "BlockRedstoneRepeater.h"
-#include "../Entities/Player.h"
-
-
-
-
-
-cBlockComparatorHandler::cBlockComparatorHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
-{
-}
-
-
-
-
-
-void cBlockComparatorHandler::OnDestroyed(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
- // Nothing needed yet
-}
-
-
-
-
-
-void cBlockComparatorHandler::OnUse(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)
-{
- NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- Meta ^= 0x04; // Toggle 3rd (addition/subtraction) bit with XOR
- a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
-}
-
-
-
-
-bool cBlockComparatorHandler::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
-)
-{
- a_BlockType = m_BlockType;
- a_BlockMeta = cBlockRedstoneRepeaterHandler::RepeaterRotationToMetaData(a_Player->GetRotation());
- return true;
-}
-
-
-
-
diff --git a/src/Blocks/BlockComparator.h b/src/Blocks/BlockComparator.h
index cb2941d3c..e7e18bac9 100644
--- a/src/Blocks/BlockComparator.h
+++ b/src/Blocks/BlockComparator.h
@@ -2,6 +2,7 @@
#pragma once
#include "BlockHandler.h"
+#include "BlockRedstoneRepeater.h"
@@ -11,10 +12,18 @@ class cBlockComparatorHandler :
public cBlockHandler
{
public:
- cBlockComparatorHandler(BLOCKTYPE a_BlockType);
- virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
+ cBlockComparatorHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
- virtual void OnUse(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) override;
+ virtual void OnUse(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) override
+ {
+ NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ Meta ^= 0x04; // Toggle 3rd (addition/subtraction) bit with XOR
+ a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
+ }
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
@@ -38,10 +47,15 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace,
+ 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;
+ ) override
+ {
+ a_BlockType = m_BlockType;
+ a_BlockMeta = cBlockRedstoneRepeaterHandler::RepeaterRotationToMetaData(a_Player->GetRotation());
+ return true;
+ }
virtual const char * GetStepSound(void) override
diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp
index 3448cf8a1..7bb35efeb 100644
--- a/src/Blocks/BlockHandler.cpp
+++ b/src/Blocks/BlockHandler.cpp
@@ -61,6 +61,7 @@
#include "BlockSugarcane.h"
#include "BlockTallGrass.h"
#include "BlockTorch.h"
+#include "BlockTrapdoor.h"
#include "BlockVine.h"
#include "BlockWood.h"
#include "BlockWorkbench.h"
@@ -193,6 +194,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_SUGARCANE: return new cBlockSugarcaneHandler (a_BlockType);
case E_BLOCK_TALL_GRASS: return new cBlockTallGrassHandler (a_BlockType);
case E_BLOCK_TORCH: return new cBlockTorchHandler (a_BlockType);
+ case E_BLOCK_TRAPDOOR: return new cBlockTrapdoorHandler (a_BlockType);
case E_BLOCK_VINES: return new cBlockVineHandler (a_BlockType);
case E_BLOCK_WALLSIGN: return new cBlockSignHandler (a_BlockType);
case E_BLOCK_WATER: return new cBlockFluidHandler (a_BlockType);
diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h
index 80dccd8c7..107d36476 100644
--- a/src/Blocks/BlockHandler.h
+++ b/src/Blocks/BlockHandler.h
@@ -98,7 +98,10 @@ public:
*/
virtual bool DoesIgnoreBuildCollision(void);
- /// Does this block drop if it gets destroyed by an unsuitable situation? Default: true
+ /// <summary>Similar to DoesIgnoreBuildCollision(void), but is used for cases where block meta/player item-in-hand is needed to determine collision (thin snow)</summary>
+ virtual bool DoesIgnoreBuildCollision(cPlayer * a_Player, NIBBLETYPE a_Meta) { return DoesIgnoreBuildCollision(); }
+
+ /// <summary>Returns if this block drops if it gets destroyed by an unsuitable situation. Default: true</summary>
virtual bool DoesDropOnUnsuitable(void);
/** Called when one of the neighbors gets set; equivalent to MC block update.
@@ -107,26 +110,30 @@ public:
*/
virtual void Check(int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk);
- /// Returns the meta for a block after rotating it counter-clockwise from the specified meta. Default: no change
+ /// <summary>Rotates a given block meta counter-clockwise. Default: no change</summary>
+ /// <returns>Block meta following rotation</returns>
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) { return a_Meta; }
- /// Returns the meta for a block after rotating it clockwise from the specified meta. Default: no change
+ /// <summary>Rotates a given block meta clockwise. Default: no change</summary>
+ /// <returns>Block meta following rotation</returns>
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) { return a_Meta; }
- /// Returns the meta for a block after mirroring it around the XY plane. Default: no change
+ /// <summary>Mirros a given block meta around the XY plane. Default: no change</summary>
+ /// <returns>Block meta following mirroring</returns>
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) { return a_Meta; }
- /// Returns the meta for a block after mirroring it around the XZ plane. Default: no change
+ /// <summary>Mirros a given block meta around the XZ plane. Default: no change</summary>
+ /// <returns>Block meta following mirroring</returns>
virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) { return a_Meta; }
- /// Returns the meta for a block after mirroring it around the YZ plane. Default: no change
+ /// <summary>Mirros a given block meta around the YZ plane. Default: no change</summary>
+ /// <returns>Block meta following mirroring</returns>
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) { return a_Meta; }
-
-
- /// Get the blockhandler for a specific block id
+
+ /// <summary>Get the blockhandler for a specific block id</summary>
static cBlockHandler * GetBlockHandler(BLOCKTYPE a_BlockType);
- /// Deletes all initialised block handlers
+ /// <summary>Deletes all initialised block handlers</summary>
static void Deinit();
protected:
diff --git a/src/Blocks/BlockLever.cpp b/src/Blocks/BlockLever.cpp
deleted file mode 100644
index c482b0246..000000000
--- a/src/Blocks/BlockLever.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-
-#include "Globals.h"
-#include "BlockLever.h"
-#include "../Entities/Player.h"
-#include "../Simulator/RedstoneSimulator.h"
-
-
-
-
-
-cBlockLeverHandler::cBlockLeverHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
-{
-}
-
-
-
-
-
-void cBlockLeverHandler::OnUse(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)
-{
- // Flip the ON bit on/off using the XOR bitwise operation
- NIBBLETYPE Meta = (a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x08);
-
- a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta);
- a_World->BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
-}
-
-
-
-
diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h
index 5e6a3bd1e..15fe2071c 100644
--- a/src/Blocks/BlockLever.h
+++ b/src/Blocks/BlockLever.h
@@ -10,9 +10,19 @@ class cBlockLeverHandler :
public cBlockHandler
{
public:
- cBlockLeverHandler(BLOCKTYPE a_BlockType);
+ cBlockLeverHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
- virtual void OnUse(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) override;
+ virtual void OnUse(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) override
+ {
+ // Flip the ON bit on/off using the XOR bitwise operation
+ NIBBLETYPE Meta = (a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x08);
+
+ a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
+ a_World->BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
+ }
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
diff --git a/src/Blocks/BlockRedstone.cpp b/src/Blocks/BlockRedstone.cpp
deleted file mode 100644
index 35cdc34cf..000000000
--- a/src/Blocks/BlockRedstone.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-
-#include "Globals.h"
-#include "BlockRedstone.h"
-#include "../Item.h"
-#include "../World.h"
-
-
-
-
-
-cBlockRedstoneHandler::cBlockRedstoneHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
-{
-}
-
-
-
-
-
-void cBlockRedstoneHandler::OnDestroyed(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
- // Nothing needed yet
-}
-
-
-
-
diff --git a/src/Blocks/BlockRedstone.h b/src/Blocks/BlockRedstone.h
index f28f3f2d6..57bd91b46 100644
--- a/src/Blocks/BlockRedstone.h
+++ b/src/Blocks/BlockRedstone.h
@@ -12,9 +12,10 @@ class cBlockRedstoneHandler :
public cBlockHandler
{
public:
- cBlockRedstoneHandler(BLOCKTYPE a_BlockType);
-
- virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
+ cBlockRedstoneHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
diff --git a/src/Blocks/BlockRedstoneRepeater.cpp b/src/Blocks/BlockRedstoneRepeater.cpp
deleted file mode 100644
index 3ab5bc559..000000000
--- a/src/Blocks/BlockRedstoneRepeater.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-
-#include "Globals.h"
-#include "BlockRedstoneRepeater.h"
-#include "../Entities/Player.h"
-
-
-
-
-
-cBlockRedstoneRepeaterHandler::cBlockRedstoneRepeaterHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
-{
-}
-
-
-
-
-
-void cBlockRedstoneRepeaterHandler::OnDestroyed(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
- // Nothing needed yet
-}
-
-
-
-
-
-void cBlockRedstoneRepeaterHandler::OnUse(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)
-{
- a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, ((a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) + 0x04) & 0x0f));
-}
-
-
-
-
-bool cBlockRedstoneRepeaterHandler::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
-)
-{
- a_BlockType = m_BlockType;
- a_BlockMeta = RepeaterRotationToMetaData(a_Player->GetRotation());
- return true;
-}
-
-
-
-
diff --git a/src/Blocks/BlockRedstoneRepeater.h b/src/Blocks/BlockRedstoneRepeater.h
index a61121d3a..1fcddd4f8 100644
--- a/src/Blocks/BlockRedstoneRepeater.h
+++ b/src/Blocks/BlockRedstoneRepeater.h
@@ -11,10 +11,29 @@ class cBlockRedstoneRepeaterHandler :
public cBlockHandler
{
public:
- cBlockRedstoneRepeaterHandler(BLOCKTYPE a_BlockType);
- virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
+ cBlockRedstoneRepeaterHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ 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_BlockType = m_BlockType;
+ a_BlockMeta = RepeaterRotationToMetaData(a_Player->GetRotation());
+ return true;
+ }
- virtual void OnUse(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) override;
+
+ virtual void OnUse(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) override
+ {
+ a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, ((a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) + 0x04) & 0x0f));
+ }
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
@@ -34,14 +53,6 @@ public:
{
return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR));
}
-
-
- 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;
virtual const char * GetStepSound(void) override
diff --git a/src/Blocks/BlockSnow.h b/src/Blocks/BlockSnow.h
index b8d48362c..d7fd1e19e 100644
--- a/src/Blocks/BlockSnow.h
+++ b/src/Blocks/BlockSnow.h
@@ -25,21 +25,37 @@ public:
) override
{
a_BlockType = m_BlockType;
- NIBBLETYPE Meta = a_World->GetBlockMeta(Vector3i(a_BlockX, a_BlockY, a_BlockZ));
- if ((Meta < 7) && (Meta != 0)) // Is height at maximum (7) or at mininum (0)? Don't do anything if so
+ BLOCKTYPE BlockBeforePlacement;
+ NIBBLETYPE MetaBeforePlacement;
+ a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, BlockBeforePlacement, MetaBeforePlacement);
+
+ if ((BlockBeforePlacement == E_BLOCK_SNOW) && (MetaBeforePlacement < 7))
{
- Meta++;
+ // Only increment if:
+ // A snow block was already there (not first time placement) AND
+ // Height is smaller than 7, the maximum possible height
+ MetaBeforePlacement++;
}
- a_BlockMeta = Meta;
+ a_BlockMeta = MetaBeforePlacement;
return true;
}
- virtual bool DoesIgnoreBuildCollision(void) override
+ virtual bool DoesIgnoreBuildCollision(cPlayer * a_Player, NIBBLETYPE a_Meta) override
{
- return true;
+ if ((a_Player->GetEquippedItem().m_ItemType == E_BLOCK_SNOW) && (a_Meta < 7))
+ {
+ return true; // If a player is holding a (thin) snow block and it's size can be increased, return collision ignored
+ }
+
+ if (a_Meta == 0)
+ {
+ return true; // If at normal snowfall height (lowest), we ignore collision
+ }
+
+ return false;
}
@@ -51,7 +67,19 @@ public:
virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
- return (a_RelY > 0) && g_BlockIsSnowable[a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)];
+ if (a_RelY > 0)
+ {
+ BLOCKTYPE BlockBelow = a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ);
+ NIBBLETYPE MetaBelow = a_Chunk.GetMeta(a_RelX, a_RelY - 1, a_RelZ);
+
+ if (g_BlockIsSnowable[BlockBelow] || ((BlockBelow == E_BLOCK_SNOW) && (MetaBelow == 7)))
+ {
+ // If block below is snowable, or it is a thin slow block and has a meta of 7 (full thin snow block), say yay
+ return true;
+ }
+ }
+
+ return false;
}
diff --git a/src/Blocks/BlockStairs.h b/src/Blocks/BlockStairs.h
index 8d259eee3..fa378e4b5 100644
--- a/src/Blocks/BlockStairs.h
+++ b/src/Blocks/BlockStairs.h
@@ -47,8 +47,28 @@ public:
return true;
}
- // TODO: step sound
-
+ virtual const char * GetStepSound(void) override
+ {
+ if (
+ (m_BlockType == E_BLOCK_WOODEN_STAIRS) ||
+ (m_BlockType == E_BLOCK_SPRUCE_WOOD_STAIRS) ||
+ (m_BlockType == E_BLOCK_JUNGLE_WOOD_STAIRS) ||
+ (m_BlockType == E_BLOCK_ACACIA_WOOD_STAIRS) ||
+ (m_BlockType == E_BLOCK_BIRCH_WOOD_STAIRS) ||
+ (m_BlockType == E_BLOCK_DARK_OAK_WOOD_STAIRS)
+ )
+ {
+ return "step.wood";
+ }
+
+ return "step.stone";
+ }
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ // Reset meta to 0
+ a_Pickups.push_back(cItem(m_BlockType, 1, 0));
+ }
static NIBBLETYPE RotationToMetaData(double a_Rotation)
{
diff --git a/src/Blocks/BlockStems.h b/src/Blocks/BlockStems.h
index e17f2ea3d..c2dff62cf 100644
--- a/src/Blocks/BlockStems.h
+++ b/src/Blocks/BlockStems.h
@@ -2,7 +2,6 @@
#pragma once
#include "BlockHandler.h"
-#include "../MersenneTwister.h"
#include "../World.h"
diff --git a/src/Blocks/BlockTrapdoor.h b/src/Blocks/BlockTrapdoor.h
new file mode 100644
index 000000000..58d770d23
--- /dev/null
+++ b/src/Blocks/BlockTrapdoor.h
@@ -0,0 +1,108 @@
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockTrapdoorHandler :
+ public cBlockHandler
+{
+public:
+ cBlockTrapdoorHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.wood";
+ }
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ // Reset meta to 0
+ a_Pickups.push_back(cItem(m_BlockType, 1, 0));
+ }
+
+ virtual bool IsUseable(void) override
+ {
+ return true;
+ }
+
+ void OnUse(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)
+ {
+ // Flip the ON bit on/off using the XOR bitwise operation
+ NIBBLETYPE Meta = (a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x04);
+
+ a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
+ }
+
+ 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_BlockType = m_BlockType;
+ a_BlockMeta = BlockFaceToMetaData(a_BlockFace);
+
+ /* TODO: fix CursorY issues and uncomment this
+ if (a_CursorY > 7)
+ {
+ a_BlockMeta |= 0x8;
+ }
+ */
+ return true;
+ }
+
+ inline static NIBBLETYPE BlockFaceToMetaData(char a_BlockFace)
+ {
+ switch (a_BlockFace)
+ {
+ case BLOCK_FACE_ZP: return 0x1;
+ case BLOCK_FACE_ZM: return 0x0;
+ case BLOCK_FACE_XP: return 0x3;
+ case BLOCK_FACE_XM: return 0x2;
+ default:
+ {
+ ASSERT(!"Unhandled block face!");
+ return 0x0;
+ }
+ }
+ }
+
+ inline static NIBBLETYPE BlockMetaDataToBlockFace(NIBBLETYPE a_Meta)
+ {
+ switch (a_Meta & 0x3)
+ {
+ case 0x0: return BLOCK_FACE_ZM;
+ case 0x1: return BLOCK_FACE_ZP;
+ case 0x2: return BLOCK_FACE_XM;
+ case 0x3: return BLOCK_FACE_XP;
+ default:
+ {
+ ASSERT(!"Unhandled block meta!");
+ return BLOCK_FACE_NONE;
+ }
+ }
+ }
+
+ virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ {
+ NIBBLETYPE Meta;
+ a_Chunk.UnboundedRelGetBlockMeta(a_RelX, a_RelY, a_RelZ, Meta);
+
+ AddFaceDirection(a_RelX, a_RelY, a_RelZ, BlockMetaDataToBlockFace(Meta), true);
+ BLOCKTYPE BlockIsOn; a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, BlockIsOn);
+
+ return (a_RelY > 0) && (g_BlockIsSolid[BlockIsOn]);
+ }
+};
+
+
+
+