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>
This commit is contained in:
@@ -15,14 +15,9 @@ class cBlockMobSpawnerHandler:
|
||||
|
||||
public:
|
||||
|
||||
cBlockMobSpawnerHandler(BLOCKTYPE a_BlockType):
|
||||
Super(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
using Super::Super;
|
||||
|
||||
private:
|
||||
|
||||
virtual bool OnUse(
|
||||
cChunkInterface & a_ChunkInterface,
|
||||
@@ -31,7 +26,7 @@ public:
|
||||
const Vector3i a_BlockPos,
|
||||
eBlockFace a_BlockFace,
|
||||
const Vector3i a_CursorPos
|
||||
) override
|
||||
) const override
|
||||
{
|
||||
return a_ChunkInterface.UseBlockEntity(&a_Player, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z);
|
||||
}
|
||||
@@ -40,7 +35,7 @@ public:
|
||||
|
||||
|
||||
|
||||
virtual bool IsUseable() override
|
||||
virtual bool IsUseable() const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -49,7 +44,7 @@ public:
|
||||
|
||||
|
||||
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override
|
||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||
{
|
||||
// No pickups
|
||||
return {};
|
||||
@@ -64,7 +59,7 @@ public:
|
||||
cPlayer & a_Player,
|
||||
Vector3i a_BlockPos,
|
||||
BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta
|
||||
) override
|
||||
) const override
|
||||
{
|
||||
auto handler = a_Player.GetEquippedItem().GetHandler();
|
||||
if (!a_Player.IsGameModeSurvival() || !handler->CanHarvestBlock(E_BLOCK_MOB_SPAWNER))
|
||||
|
||||
Reference in New Issue
Block a user