summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTORS1
-rw-r--r--src/Blocks/BlockCactus.h34
2 files changed, 35 insertions, 0 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 85038b364..37e1ca5bf 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -43,6 +43,7 @@ mBornand
MeMuXin
mgueydan
MikeHunsinger
+morsmordere (Anzhelika Iugai)
mtilden
nesco
NiLSPACE (formerly STR_Warrior)
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)