1
0
cuberite-2a/src/Blocks/BlockRedstoneOre.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

93 lines
1.4 KiB
C++

#pragma once
#include "BlockHandler.h"
#include "BlockOre.h"
class cBlockRedstoneOreHandler :
public cBlockOreHandler
{
using Super = cBlockOreHandler;
public:
using Super::Super; // Inherit constructor from base
virtual bool OnUse(
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player,
const Vector3i a_BlockPos,
eBlockFace a_BlockFace,
const Vector3i a_CursorPos
) const override
{
a_ChunkInterface.SetBlock(a_BlockPos, E_BLOCK_REDSTONE_ORE_GLOWING, 0);
return false;
}
virtual void OnDigging(
cChunkInterface & a_ChunkInterface,
cWorldInterface & a_WorldInterface,
cPlayer & a_Player,
const Vector3i a_BlockPos
) const override
{
a_ChunkInterface.SetBlock(a_BlockPos, E_BLOCK_REDSTONE_ORE_GLOWING, 0);
}
virtual bool IsUseable() const override
{
return true;
}
};
class cBlockGlowingRedstoneOreHandler:
public cBlockOreHandler
{
using Super = cBlockOreHandler;
public:
using Super::Super; // Inherit constructor from base
virtual void OnUpdate(
cChunkInterface & a_ChunkInterface,
cWorldInterface & a_WorldInterface,
cBlockPluginInterface & a_BlockPluginInterface,
cChunk & a_Chunk,
const Vector3i a_RelPos
) const override
{
auto BlockPos = a_Chunk.RelativeToAbsolute(a_RelPos);
a_ChunkInterface.SetBlock(BlockPos, E_BLOCK_REDSTONE_ORE, 0);
}
};