summaryrefslogtreecommitdiffstats
path: root/src/Blocks
diff options
context:
space:
mode:
authorworktycho <work.tycho@gmail.com>2015-12-14 21:31:33 +0100
committerworktycho <work.tycho@gmail.com>2015-12-14 21:31:33 +0100
commit1e5ba8a1bb887808961e9c17dfd44af6bbbd2a84 (patch)
tree8adc41d291bdac3c83eb0c56933e7a29cd1c3942 /src/Blocks
parentMerge pull request #2744 from cuberite/HopperMetaStrip (diff)
parentblockheight mechanism (diff)
downloadcuberite-1e5ba8a1bb887808961e9c17dfd44af6bbbd2a84.tar
cuberite-1e5ba8a1bb887808961e9c17dfd44af6bbbd2a84.tar.gz
cuberite-1e5ba8a1bb887808961e9c17dfd44af6bbbd2a84.tar.bz2
cuberite-1e5ba8a1bb887808961e9c17dfd44af6bbbd2a84.tar.lz
cuberite-1e5ba8a1bb887808961e9c17dfd44af6bbbd2a84.tar.xz
cuberite-1e5ba8a1bb887808961e9c17dfd44af6bbbd2a84.tar.zst
cuberite-1e5ba8a1bb887808961e9c17dfd44af6bbbd2a84.zip
Diffstat (limited to '')
-rw-r--r--src/Blocks/BlockHandler.cpp10
-rw-r--r--src/Blocks/BlockHandler.h6
-rw-r--r--src/Blocks/BlockSlab.h9
-rw-r--r--src/Blocks/BlockSnow.h5
-rw-r--r--src/Blocks/BlockStairs.h32
5 files changed, 61 insertions, 1 deletions
diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp
index bb479db53..0ad0e2242 100644
--- a/src/Blocks/BlockHandler.cpp
+++ b/src/Blocks/BlockHandler.cpp
@@ -553,6 +553,16 @@ bool cBlockHandler::DoesDropOnUnsuitable(void)
+/* default functionality: only test for height, since we assume full voxels with varying height */
+bool cBlockHandler::IsInsideBlock(const Vector3d & a_Position, const BLOCKTYPE a_BlockType, const NIBBLETYPE a_BlockMeta)
+{
+ return a_Position.y < cBlockInfo::GetBlockHeight(a_BlockType);
+}
+
+
+
+
+
void cBlockHandler::Check(cChunkInterface & a_ChunkInterface, cBlockPluginInterface & a_PluginInterface, int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk)
{
if (!CanBeAt(a_ChunkInterface, a_RelX, a_RelY, a_RelZ, a_Chunk))
diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h
index 4a7b76019..41fbc5140 100644
--- a/src/Blocks/BlockHandler.h
+++ b/src/Blocks/BlockHandler.h
@@ -124,7 +124,11 @@ public:
/** Returns if this block drops if it gets destroyed by an unsuitable situation.
Default: true */
virtual bool DoesDropOnUnsuitable(void);
-
+
+ /** Tests if a_Position is inside the block where a_Position is relative to the origin of the block
+ Note that this is considered from a "top-down" perspective i.e. empty spaces on the bottom of a block don't matter */
+ virtual bool IsInsideBlock(const Vector3d & a_Position, const BLOCKTYPE a_BlockType, const NIBBLETYPE a_BlockMeta);
+
/** Called when one of the neighbors gets set; equivalent to MC block update.
By default drops if position no more suitable (CanBeAt(), DoesDropOnUnsuitable(), Drop()),
and wakes up all simulators on the block. */
diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h
index 19b25595d..79d440cf6 100644
--- a/src/Blocks/BlockSlab.h
+++ b/src/Blocks/BlockSlab.h
@@ -174,6 +174,15 @@ public:
}
}
}
+
+ virtual bool IsInsideBlock(const Vector3d & a_Position, const BLOCKTYPE a_BlockType, const NIBBLETYPE a_BlockMeta) override
+ {
+ if (a_BlockMeta & 0x8) // top half
+ {
+ return true;
+ }
+ return cBlockHandler::IsInsideBlock(a_Position, a_BlockType, a_BlockMeta);
+ }
} ;
diff --git a/src/Blocks/BlockSnow.h b/src/Blocks/BlockSnow.h
index 3fab0b8ef..c49aa7161 100644
--- a/src/Blocks/BlockSnow.h
+++ b/src/Blocks/BlockSnow.h
@@ -88,6 +88,11 @@ public:
UNUSED(a_Meta);
return 14;
}
+
+ virtual bool IsInsideBlock(const Vector3d & a_Position, const BLOCKTYPE a_BlockType, const NIBBLETYPE a_BlockMeta) override
+ {
+ return a_Position.y < (cBlockInfo::GetBlockHeight(a_BlockType) * (a_BlockMeta & 7));
+ }
} ;
diff --git a/src/Blocks/BlockStairs.h b/src/Blocks/BlockStairs.h
index 8a23fd064..3d7dd1442 100644
--- a/src/Blocks/BlockStairs.h
+++ b/src/Blocks/BlockStairs.h
@@ -115,6 +115,38 @@ public:
}
}
}
+
+ /** EXCEPTION a.k.a. why is this removed:
+ This collision-detection is actually more accurate than the client, but since the client itself
+ sends inaccurate / sparse data, it's easier to just err on the side of the client and keep the
+ two in sync by assuming that if a player hit ANY of the stair's bounding cube, it counts as the ground. */
+ #if 0
+ bool IsInsideBlock(const Vector3d & a_Position, const BLOCKTYPE a_BlockType, const NIBBLETYPE a_BlockMeta)
+ {
+ if (a_BlockMeta & 0x4) // upside down
+ {
+ return true;
+ }
+ else if ((a_BlockMeta & 0x3) == 0) // tall side is east (+X)
+ {
+ return a_Position.y < ((a_Position.x > 0.5) ? 1.0 : 0.5);
+ }
+ else if ((a_BlockMeta & 0x3) == 1) // tall side is west (-X)
+ {
+ return a_Position.y < ((a_Position.x < 0.5) ? 1.0 : 0.5);
+ }
+ else if ((a_BlockMeta & 0x3) == 2) // tall side is south (+Z)
+ {
+ return a_Position.y < ((a_Position.z > 0.5) ? 1.0 : 0.5);
+ }
+ else if ((a_BlockMeta & 0x3) == 3) // tall side is north (-Z)
+ {
+ return a_Position.y < ((a_Position.z < 0.5) ? 1.0 : 0.5);
+ }
+ return false;
+ }
+ #endif
+
} ;