summaryrefslogtreecommitdiffstats
path: root/src/Blocks/Mixins.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-09-20 15:50:52 +0200
committerGitHub <noreply@github.com>2020-09-20 15:50:52 +0200
commit68cced73afe546328cf94ed07c57deee47bfadec (patch)
tree88be88e3fd4a208b9849e526f1877caa44058ab5 /src/Blocks/Mixins.h
parentAdded armor and shulker box cleaning (#4875) (diff)
downloadcuberite-68cced73afe546328cf94ed07c57deee47bfadec.tar
cuberite-68cced73afe546328cf94ed07c57deee47bfadec.tar.gz
cuberite-68cced73afe546328cf94ed07c57deee47bfadec.tar.bz2
cuberite-68cced73afe546328cf94ed07c57deee47bfadec.tar.lz
cuberite-68cced73afe546328cf94ed07c57deee47bfadec.tar.xz
cuberite-68cced73afe546328cf94ed07c57deee47bfadec.tar.zst
cuberite-68cced73afe546328cf94ed07c57deee47bfadec.zip
Diffstat (limited to 'src/Blocks/Mixins.h')
-rw-r--r--src/Blocks/Mixins.h58
1 files changed, 22 insertions, 36 deletions
diff --git a/src/Blocks/Mixins.h b/src/Blocks/Mixins.h
index 7e581c876..040969ddb 100644
--- a/src/Blocks/Mixins.h
+++ b/src/Blocks/Mixins.h
@@ -31,16 +31,14 @@ class cBlockWithNoDrops:
{
public:
- cBlockWithNoDrops(BLOCKTYPE a_BlockType):
+ constexpr cBlockWithNoDrops(BLOCKTYPE a_BlockType):
Base(a_BlockType)
{
}
+private:
-
-
-
- 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
{
// Don't drop anything:
return {};
@@ -58,16 +56,14 @@ class cClearMetaOnDrop:
{
public:
- cClearMetaOnDrop(BLOCKTYPE a_BlockType):
+ constexpr cClearMetaOnDrop(BLOCKTYPE a_BlockType):
Base(a_BlockType)
{
}
+private:
-
-
-
- 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
{
// Reset the meta to zero:
return cItem(this->m_BlockType);
@@ -87,15 +83,14 @@ class cMetaRotator:
{
public:
- cMetaRotator(BLOCKTYPE a_BlockType):
+ constexpr cMetaRotator(BLOCKTYPE a_BlockType):
Base(a_BlockType)
- {}
-
-
-
+ {
+ }
+protected:
- virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
+ virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) const override
{
NIBBLETYPE OtherMeta = a_Meta & (~BitMask);
switch (a_Meta & BitMask)
@@ -116,7 +111,7 @@ public:
- virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
+ virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) const override
{
NIBBLETYPE OtherMeta = a_Meta & (~BitMask);
switch (a_Meta & BitMask)
@@ -137,7 +132,7 @@ public:
- virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
+ virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) const override
{
NIBBLETYPE OtherMeta = a_Meta & (~BitMask);
switch (a_Meta & BitMask)
@@ -153,7 +148,7 @@ public:
- virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
+ virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) const override
{
NIBBLETYPE OtherMeta = a_Meta & (~BitMask);
switch (a_Meta & BitMask)
@@ -185,16 +180,12 @@ class cYawRotator:
public cMetaRotator<Base, BitMask, North, East, South, West, AssertIfNotMatched>
{
using Super = cMetaRotator<Base, BitMask, North, East, South, West, AssertIfNotMatched>;
-public:
-
- cYawRotator(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
+public:
+ using Super::Super;
+public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer & a_Player,
@@ -202,7 +193,7 @@ public:
eBlockFace a_BlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
NIBBLETYPE BaseMeta;
if (!Super::GetPlacementBlockTypeMeta(a_ChunkInterface, a_Player, a_BlockPos, a_BlockFace, a_CursorPos, a_BlockType, BaseMeta))
@@ -264,14 +255,9 @@ class cPitchYawRotator:
public:
- cPitchYawRotator(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+protected:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface,
@@ -280,7 +266,7 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
NIBBLETYPE BaseMeta;
if (!Super::GetPlacementBlockTypeMeta(a_ChunkInterface, a_Player, a_PlacedBlockPos, a_ClickedBlockFace, a_CursorPos, a_BlockType, BaseMeta))
@@ -296,7 +282,7 @@ public:
- virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override
+ virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) const override
{
NIBBLETYPE OtherMeta = a_Meta & (~BitMask);
switch (a_Meta & BitMask)