summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockCactus.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-05-05 15:25:10 +0200
committerGitHub <noreply@github.com>2021-05-05 15:25:10 +0200
commita62b2b1be2103d7de2fd66c7304b7473e369be3c (patch)
treea44f2b43fd90f5c79af5e308b554349e6dc546af /src/Blocks/BlockCactus.h
parentRename files to match code (diff)
downloadcuberite-a62b2b1be2103d7de2fd66c7304b7473e369be3c.tar
cuberite-a62b2b1be2103d7de2fd66c7304b7473e369be3c.tar.gz
cuberite-a62b2b1be2103d7de2fd66c7304b7473e369be3c.tar.bz2
cuberite-a62b2b1be2103d7de2fd66c7304b7473e369be3c.tar.lz
cuberite-a62b2b1be2103d7de2fd66c7304b7473e369be3c.tar.xz
cuberite-a62b2b1be2103d7de2fd66c7304b7473e369be3c.tar.zst
cuberite-a62b2b1be2103d7de2fd66c7304b7473e369be3c.zip
Diffstat (limited to 'src/Blocks/BlockCactus.h')
-rw-r--r--src/Blocks/BlockCactus.h42
1 files changed, 4 insertions, 38 deletions
diff --git a/src/Blocks/BlockCactus.h b/src/Blocks/BlockCactus.h
index 2e7cc7db2..23c4d3421 100644
--- a/src/Blocks/BlockCactus.h
+++ b/src/Blocks/BlockCactus.h
@@ -18,47 +18,13 @@ public:
private:
- /** 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
- ) const override
+ virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const 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) const override
- {
- if (a_RelPos.y <= 0)
+ if (a_Position.y <= 0)
{
return false;
}
- BLOCKTYPE Surface = a_Chunk.GetBlock(a_RelPos.addedY(-1));
+ BLOCKTYPE Surface = a_Chunk.GetBlock(a_Position.addedY(-1));
if ((Surface != E_BLOCK_SAND) && (Surface != E_BLOCK_CACTUS))
{
// Cactus can only be placed on sand and itself
@@ -78,7 +44,7 @@ private:
BLOCKTYPE BlockType;
NIBBLETYPE BlockMeta;
if (
- a_Chunk.UnboundedRelGetBlock(a_RelPos + Coords[i], BlockType, BlockMeta) &&
+ a_Chunk.UnboundedRelGetBlock(a_Position + Coords[i], BlockType, BlockMeta) &&
(
cBlockInfo::IsSolid(BlockType) ||
(BlockType == E_BLOCK_LAVA) ||