summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockSnow.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2013-11-30 16:20:27 +0100
committerMattes D <github@xoft.cz>2013-11-30 16:20:27 +0100
commit2bbe5046e9d2119f2751af01cbce3185ee9514ed (patch)
tree059a36e4c22c22b1f6d591bc02ade598153015b4 /src/Blocks/BlockSnow.h
parentChanged cBlockHandler->OnUpdate() to use cChunk directly. (diff)
parentFixed pistons extending (diff)
downloadcuberite-2bbe5046e9d2119f2751af01cbce3185ee9514ed.tar
cuberite-2bbe5046e9d2119f2751af01cbce3185ee9514ed.tar.gz
cuberite-2bbe5046e9d2119f2751af01cbce3185ee9514ed.tar.bz2
cuberite-2bbe5046e9d2119f2751af01cbce3185ee9514ed.tar.lz
cuberite-2bbe5046e9d2119f2751af01cbce3185ee9514ed.tar.xz
cuberite-2bbe5046e9d2119f2751af01cbce3185ee9514ed.tar.zst
cuberite-2bbe5046e9d2119f2751af01cbce3185ee9514ed.zip
Diffstat (limited to 'src/Blocks/BlockSnow.h')
-rw-r--r--src/Blocks/BlockSnow.h42
1 files changed, 35 insertions, 7 deletions
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;
}