1
0
cuberite-2a/src/Items/ItemBigFlower.h
Tiger Wang 68cced73af
BlockHandler initialisation is a constant expression (#4891)
* BlockHandler initialisation is a constant expression

If we can't make it all namespaces, this is the next best I guess.

+ Tag handlers constexpr, const as needed
+ Inherit constructors
* Privatise handler functions

* More constexpr

Co-authored-by: Alexander Harkness <me@bearbin.net>
2020-09-20 13:50:52 +00:00

65 lines
1.3 KiB
C++

#pragma once
#include "ItemHandler.h"
#include "../BlockInfo.h"
class cItemBigFlowerHandler:
public cItemHandler
{
using Super = cItemHandler;
public:
cItemBigFlowerHandler():
Super(E_BLOCK_BIG_FLOWER)
{
}
virtual bool GetBlocksToPlace(
cWorld & a_World,
cPlayer & a_Player,
const cItem & a_EquippedItem,
const Vector3i a_PlacedBlockPos,
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
sSetBlockVector & a_BlocksToPlace
) override
{
// Can only be placed on dirt:
if ((a_PlacedBlockPos.y <= 0) || !IsBlockTypeOfDirt(a_World.GetBlock(a_PlacedBlockPos.addedY(-1))))
{
return false;
}
// Needs at least two free blocks to build in
if (a_PlacedBlockPos.y >= cChunkDef::Height - 1)
{
return false;
}
auto TopPos = a_PlacedBlockPos.addedY(1);
BLOCKTYPE TopType;
NIBBLETYPE TopMeta;
a_World.GetBlockTypeMeta(TopPos, TopType, TopMeta);
cChunkInterface ChunkInterface(a_World.GetChunkMap());
if (!cBlockHandler::For(TopType).DoesIgnoreBuildCollision(ChunkInterface, TopPos, a_Player, TopMeta))
{
return false;
}
a_BlocksToPlace.emplace_back(a_PlacedBlockPos, E_BLOCK_BIG_FLOWER, a_EquippedItem.m_ItemDamage & 0x07);
a_BlocksToPlace.emplace_back(TopPos, E_BLOCK_BIG_FLOWER, E_META_BIG_FLOWER_TOP);
return true;
}
};