summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockCactus.h
diff options
context:
space:
mode:
authormorsmordere <35617773+morsmordere@users.noreply.github.com>2020-06-26 02:23:47 +0200
committerGitHub <noreply@github.com>2020-06-26 02:23:47 +0200
commit60c10ef248a2f571f4653363155e1eefdeab23ff (patch)
tree8dc6659542b98b83b85c52aac2a483e34ebc439f /src/Blocks/BlockCactus.h
parentSend entities in cChunkSender (#4532) (diff)
downloadcuberite-60c10ef248a2f571f4653363155e1eefdeab23ff.tar
cuberite-60c10ef248a2f571f4653363155e1eefdeab23ff.tar.gz
cuberite-60c10ef248a2f571f4653363155e1eefdeab23ff.tar.bz2
cuberite-60c10ef248a2f571f4653363155e1eefdeab23ff.tar.lz
cuberite-60c10ef248a2f571f4653363155e1eefdeab23ff.tar.xz
cuberite-60c10ef248a2f571f4653363155e1eefdeab23ff.tar.zst
cuberite-60c10ef248a2f571f4653363155e1eefdeab23ff.zip
Diffstat (limited to 'src/Blocks/BlockCactus.h')
-rw-r--r--src/Blocks/BlockCactus.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/Blocks/BlockCactus.h b/src/Blocks/BlockCactus.h
index 0c3577898..15d585eac 100644
--- a/src/Blocks/BlockCactus.h
+++ b/src/Blocks/BlockCactus.h
@@ -23,6 +23,40 @@ public:
+ /** Called before a cactus block is placed by a player, overrides cItemHandler::GetPlacementBlockTypeMeta().
+ Calls CanBeAt function to determine if a cactus block can be placed on a given block. */
+ bool GetPlacementBlockTypeMeta(
+ cChunkInterface & a_ChunkInterface,
+ cPlayer & a_Player,
+ const Vector3i a_PlacedBlockPos,
+ eBlockFace a_ClickedBlockFace,
+ const Vector3i a_CursorPos,
+ BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
+ ) override
+ {
+ if (
+ a_Player.GetWorld()->DoWithChunkAt(a_PlacedBlockPos,
+ [this, a_PlacedBlockPos, &a_ChunkInterface](cChunk & a_Chunk)
+ {
+ auto RelPos = cChunkDef::AbsoluteToRelative(a_PlacedBlockPos);
+ return CanBeAt(a_ChunkInterface, RelPos, a_Chunk);
+ }
+ ))
+ {
+ a_BlockType = m_BlockType;
+ // Setting a_BlockMeta to meta copied from the lowest 4 bits of the player's equipped item's damage value.
+ NIBBLETYPE Meta = static_cast<NIBBLETYPE>(a_Player.GetEquippedItem().m_ItemDamage);
+ a_BlockMeta = Meta & 0x0f;
+ return true;
+ }
+
+ return false;
+ }
+
+
+
+
+
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
{
if (a_RelPos.y <= 0)