summaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/BlockArea.cpp31
-rw-r--r--src/BlockArea.h2
-rw-r--r--src/BlockInfo.cpp10
-rw-r--r--src/BlockInfo.h19
-rw-r--r--src/Blocks/BlockAnvil.h19
-rw-r--r--src/Blocks/BlockBed.cpp8
-rw-r--r--src/Blocks/BlockBed.h73
-rw-r--r--src/Blocks/BlockBigFlower.h21
-rw-r--r--src/Blocks/BlockBookShelf.h52
-rw-r--r--src/Blocks/BlockBrewingStand.h13
-rw-r--r--src/Blocks/BlockButton.h83
-rw-r--r--src/Blocks/BlockCactus.h25
-rw-r--r--src/Blocks/BlockCake.h17
-rw-r--r--src/Blocks/BlockCarpet.h15
-rw-r--r--src/Blocks/BlockCauldron.h19
-rw-r--r--src/Blocks/BlockChest.h73
-rw-r--r--src/Blocks/BlockCloth.h14
-rw-r--r--src/Blocks/BlockCobWeb.h12
-rw-r--r--src/Blocks/BlockCocoaPod.h58
-rw-r--r--src/Blocks/BlockCommandBlock.h13
-rw-r--r--src/Blocks/BlockComparator.h189
-rw-r--r--src/Blocks/BlockConcretePowder.h15
-rw-r--r--src/Blocks/BlockCrops.h17
-rw-r--r--src/Blocks/BlockDeadBush.h16
-rw-r--r--src/Blocks/BlockDirt.h13
-rw-r--r--src/Blocks/BlockDoor.cpp25
-rw-r--r--src/Blocks/BlockDoor.h264
-rw-r--r--src/Blocks/BlockDropSpenser.h13
-rw-r--r--src/Blocks/BlockEnchantingTable.h8
-rw-r--r--src/Blocks/BlockEndPortalFrame.h175
-rw-r--r--src/Blocks/BlockEnderchest.h11
-rw-r--r--src/Blocks/BlockEntity.h21
-rw-r--r--src/Blocks/BlockFarmland.h19
-rw-r--r--src/Blocks/BlockFence.h27
-rw-r--r--src/Blocks/BlockFenceGate.h17
-rw-r--r--src/Blocks/BlockFire.h70
-rw-r--r--src/Blocks/BlockFlower.h15
-rw-r--r--src/Blocks/BlockFlowerPot.h13
-rw-r--r--src/Blocks/BlockFluid.h33
-rw-r--r--src/Blocks/BlockFurnace.h13
-rw-r--r--src/Blocks/BlockGlass.h12
-rw-r--r--src/Blocks/BlockGlowstone.h12
-rw-r--r--src/Blocks/BlockGrass.h23
-rw-r--r--src/Blocks/BlockGravel.h12
-rw-r--r--src/Blocks/BlockHandler.cpp545
-rw-r--r--src/Blocks/BlockHandler.h64
-rw-r--r--src/Blocks/BlockHopper.h13
-rw-r--r--src/Blocks/BlockIce.h13
-rw-r--r--src/Blocks/BlockJukebox.h17
-rw-r--r--src/Blocks/BlockLadder.h15
-rw-r--r--src/Blocks/BlockLeaves.h26
-rw-r--r--src/Blocks/BlockLever.h37
-rw-r--r--src/Blocks/BlockLilypad.h13
-rw-r--r--src/Blocks/BlockMelon.h13
-rw-r--r--src/Blocks/BlockMobHead.h12
-rw-r--r--src/Blocks/BlockMobSpawner.h17
-rw-r--r--src/Blocks/BlockMushroom.h17
-rw-r--r--src/Blocks/BlockMycelium.h14
-rw-r--r--src/Blocks/BlockNetherWart.h17
-rw-r--r--src/Blocks/BlockNetherrack.h16
-rw-r--r--src/Blocks/BlockObserver.h4
-rw-r--r--src/Blocks/BlockOre.h12
-rw-r--r--src/Blocks/BlockPiston.cpp287
-rw-r--r--src/Blocks/BlockPiston.h36
-rw-r--r--src/Blocks/BlockPlanks.h13
-rw-r--r--src/Blocks/BlockPlant.h22
-rw-r--r--src/Blocks/BlockPortal.h20
-rw-r--r--src/Blocks/BlockPressurePlate.h13
-rw-r--r--src/Blocks/BlockPumpkin.h10
-rw-r--r--src/Blocks/BlockQuartz.h13
-rw-r--r--src/Blocks/BlockRail.h37
-rw-r--r--src/Blocks/BlockRedstone.h15
-rw-r--r--src/Blocks/BlockRedstoneLamp.h12
-rw-r--r--src/Blocks/BlockRedstoneOre.h8
-rw-r--r--src/Blocks/BlockRedstoneRepeater.h102
-rw-r--r--src/Blocks/BlockRedstoneTorch.h13
-rw-r--r--src/Blocks/BlockSand.h14
-rw-r--r--src/Blocks/BlockSapling.h29
-rw-r--r--src/Blocks/BlockSeaLantern.h15
-rw-r--r--src/Blocks/BlockSideways.h13
-rw-r--r--src/Blocks/BlockSignPost.h48
-rw-r--r--src/Blocks/BlockSlab.h58
-rw-r--r--src/Blocks/BlockSlime.h17
-rw-r--r--src/Blocks/BlockSnow.h28
-rw-r--r--src/Blocks/BlockSponge.h15
-rw-r--r--src/Blocks/BlockStairs.h15
-rw-r--r--src/Blocks/BlockStems.h24
-rw-r--r--src/Blocks/BlockStone.h13
-rw-r--r--src/Blocks/BlockSugarcane.h25
-rw-r--r--src/Blocks/BlockTNT.h13
-rw-r--r--src/Blocks/BlockTallGrass.h19
-rw-r--r--src/Blocks/BlockTorch.h15
-rw-r--r--src/Blocks/BlockTrapdoor.h18
-rw-r--r--src/Blocks/BlockTripwire.h13
-rw-r--r--src/Blocks/BlockTripwireHook.h39
-rw-r--r--src/Blocks/BlockVine.h33
-rw-r--r--src/Blocks/BlockWallSign.h53
-rw-r--r--src/Blocks/BlockWorkbench.h15
-rw-r--r--src/Blocks/ChunkInterface.cpp3
-rw-r--r--src/Blocks/Mixins.h58
-rw-r--r--src/Chunk.cpp17
-rw-r--r--src/ClientHandle.cpp18
-rw-r--r--src/Entities/Pawn.cpp2
-rw-r--r--src/Entities/Player.cpp6
-rw-r--r--src/Items/ItemBigFlower.h2
-rw-r--r--src/Items/ItemChest.h6
-rw-r--r--src/Items/ItemHandler.cpp8
-rw-r--r--src/Items/ItemSign.h2
-rw-r--r--src/Map.cpp12
-rw-r--r--src/Physics/Explodinator.cpp4
-rw-r--r--src/Simulator/FloodyFluidSimulator.cpp3
-rw-r--r--src/World.cpp4
112 files changed, 1652 insertions, 2101 deletions
diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp
index 4aa5175f2..1e70fc9ba 100644
--- a/src/BlockArea.cpp
+++ b/src/BlockArea.cpp
@@ -1067,7 +1067,7 @@ void cBlockArea::RotateCCW(void)
auto NewIdx = MakeIndexForSize({ NewX, y, NewZ }, { m_Size.z, m_Size.y, m_Size.x });
auto OldIdx = MakeIndex(x, y, z);
NewTypes[NewIdx] = m_BlockTypes[OldIdx];
- NewMetas[NewIdx] = BlockHandler(m_BlockTypes[OldIdx])->MetaRotateCCW(m_BlockMetas[OldIdx]);
+ NewMetas[NewIdx] = cBlockHandler::For(m_BlockTypes[OldIdx]).MetaRotateCCW(m_BlockMetas[OldIdx]);
} // for y
} // for z
} // for x
@@ -1127,7 +1127,7 @@ void cBlockArea::RotateCW(void)
auto NewIdx = MakeIndexForSize({ NewX, y, NewZ }, { m_Size.z, m_Size.y, m_Size.x });
auto OldIdx = MakeIndex(x, y, z);
NewTypes[NewIdx] = m_BlockTypes[OldIdx];
- NewMetas[NewIdx] = BlockHandler(m_BlockTypes[OldIdx])->MetaRotateCW(m_BlockMetas[OldIdx]);
+ NewMetas[NewIdx] = cBlockHandler::For(m_BlockTypes[OldIdx]).MetaRotateCW(m_BlockMetas[OldIdx]);
} // for y
} // for z
} // for x
@@ -1185,8 +1185,8 @@ void cBlockArea::MirrorXY(void)
auto Idx1 = MakeIndex(x, y, z);
auto Idx2 = MakeIndex(x, y, MaxZ - z);
std::swap(m_BlockTypes[Idx1], m_BlockTypes[Idx2]);
- NIBBLETYPE Meta1 = BlockHandler(m_BlockTypes[Idx2])->MetaMirrorXY(m_BlockMetas[Idx1]);
- NIBBLETYPE Meta2 = BlockHandler(m_BlockTypes[Idx1])->MetaMirrorXY(m_BlockMetas[Idx2]);
+ NIBBLETYPE Meta1 = cBlockHandler::For(m_BlockTypes[Idx2]).MetaMirrorXY(m_BlockMetas[Idx1]);
+ NIBBLETYPE Meta2 = cBlockHandler::For(m_BlockTypes[Idx1]).MetaMirrorXY(m_BlockMetas[Idx2]);
m_BlockMetas[Idx1] = Meta2;
m_BlockMetas[Idx2] = Meta1;
} // for x
@@ -1242,8 +1242,8 @@ void cBlockArea::MirrorXZ(void)
auto Idx1 = MakeIndex(x, y, z);
auto Idx2 = MakeIndex(x, MaxY - y, z);
std::swap(m_BlockTypes[Idx1], m_BlockTypes[Idx2]);
- NIBBLETYPE Meta1 = BlockHandler(m_BlockTypes[Idx2])->MetaMirrorXZ(m_BlockMetas[Idx1]);
- NIBBLETYPE Meta2 = BlockHandler(m_BlockTypes[Idx1])->MetaMirrorXZ(m_BlockMetas[Idx2]);
+ NIBBLETYPE Meta1 = cBlockHandler::For(m_BlockTypes[Idx2]).MetaMirrorXZ(m_BlockMetas[Idx1]);
+ NIBBLETYPE Meta2 = cBlockHandler::For(m_BlockTypes[Idx1]).MetaMirrorXZ(m_BlockMetas[Idx2]);
m_BlockMetas[Idx1] = Meta2;
m_BlockMetas[Idx2] = Meta1;
} // for x
@@ -1299,8 +1299,8 @@ void cBlockArea::MirrorYZ(void)
auto Idx1 = MakeIndex(x, y, z);
auto Idx2 = MakeIndex(MaxX - x, y, z);
std::swap(m_BlockTypes[Idx1], m_BlockTypes[Idx2]);
- NIBBLETYPE Meta1 = BlockHandler(m_BlockTypes[Idx2])->MetaMirrorYZ(m_BlockMetas[Idx1]);
- NIBBLETYPE Meta2 = BlockHandler(m_BlockTypes[Idx1])->MetaMirrorYZ(m_BlockMetas[Idx2]);
+ NIBBLETYPE Meta1 = cBlockHandler::For(m_BlockTypes[Idx2]).MetaMirrorYZ(m_BlockMetas[Idx1]);
+ NIBBLETYPE Meta2 = cBlockHandler::For(m_BlockTypes[Idx1]).MetaMirrorYZ(m_BlockMetas[Idx2]);
m_BlockMetas[Idx1] = Meta2;
m_BlockMetas[Idx2] = Meta1;
} // for x
@@ -2204,21 +2204,6 @@ bool cBlockArea::ForEachBlockEntity(cBlockEntityCallback a_Callback)
-cItems cBlockArea::PickupsFromBlock(Vector3i a_AbsPos, const cEntity * a_Digger, const cItem * a_Tool)
-{
- auto relPos = a_AbsPos - m_Origin;
- BLOCKTYPE blockType;
- NIBBLETYPE blockMeta;
- GetRelBlockTypeMeta(relPos.x, relPos.y, relPos.z, blockType, blockMeta);
- auto blockEntity = GetBlockEntityRel(relPos);
- auto handler = BlockHandler(blockType);
- return handler->ConvertToPickups(blockMeta, blockEntity, a_Digger, a_Tool);
-}
-
-
-
-
-
void cBlockArea::SetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Value, NIBBLETYPE * a_Array)
{
if (a_Array == nullptr)
diff --git a/src/BlockArea.h b/src/BlockArea.h
index f9dd388c0..50bb54a4c 100644
--- a/src/BlockArea.h
+++ b/src/BlockArea.h
@@ -425,8 +425,6 @@ public:
/** Direct read-only access to block entities. */
const cBlockEntities & GetBlockEntities(void) const { ASSERT(HasBlockEntities()); return *m_BlockEntities; }
- /** Returns the pickups that would result if the block at the specified position was mined by a_Digger, using a_Tool. */
- cItems PickupsFromBlock(Vector3i a_AbsPos, const cEntity * a_Digger = nullptr, const cItem * a_Tool = nullptr);
protected:
diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp
index f7f2b392c..5078997a8 100644
--- a/src/BlockInfo.cpp
+++ b/src/BlockInfo.cpp
@@ -2,7 +2,6 @@
#include "BlockInfo.h"
#include "BlockType.h"
-#include "Blocks/BlockHandler.h"
@@ -422,15 +421,6 @@ cBlockInfo::cBlockInfo():
-cBlockHandler * cBlockInfo::GetHandler(BLOCKTYPE a_Type)
-{
- return &cBlockHandler::GetBlockHandler(a_Type);
-}
-
-
-
-
-
float cBlockInfo::GetExplosionAbsorption(const BLOCKTYPE Block)
{
switch (Block)
diff --git a/src/BlockInfo.h b/src/BlockInfo.h
index 44e8b5d43..01b5557d4 100644
--- a/src/BlockInfo.h
+++ b/src/BlockInfo.h
@@ -5,12 +5,6 @@
-// fwd:
-class cBlockHandler;
-
-
-
-
// tolua_begin
class cBlockInfo
{
@@ -54,9 +48,6 @@ public:
/** Creates a default BlockInfo structure, initializes all values to their defaults */
cBlockInfo();
- /** Gets the blockhandler for the given block type. */
- static cBlockHandler * GetHandler(BLOCKTYPE a_Type);
-
private:
/** Storage for all the BlockInfo structures. */
@@ -157,13 +148,3 @@ inline const cBlockInfo & cBlockInfo::Get(BLOCKTYPE a_Type)
static const cBlockInfoArray ms_Info;
return ms_Info[a_Type];
}
-
-
-
-
-
-// Shortcut to get the blockhandler for a specific block
-inline cBlockHandler * BlockHandler(BLOCKTYPE a_BlockType)
-{
- return cBlockInfo::GetHandler(a_BlockType);
-}
diff --git a/src/Blocks/BlockAnvil.h b/src/Blocks/BlockAnvil.h
index 927d55786..c3a7f5745 100644
--- a/src/Blocks/BlockAnvil.h
+++ b/src/Blocks/BlockAnvil.h
@@ -17,16 +17,11 @@ class cBlockAnvilHandler:
public:
- cBlockAnvilHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+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
{
return cItem(m_BlockType, 1, a_BlockMeta >> 2);
}
@@ -42,7 +37,7 @@ public:
const Vector3i a_BlockPos,
eBlockFace a_BlockFace,
const Vector3i a_CursorPos
- ) override
+ ) const override
{
cWindow * Window = new cAnvilWindow(a_BlockPos);
a_Player.OpenWindow(*Window);
@@ -60,7 +55,7 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
if (!Super::GetPlacementBlockTypeMeta(a_ChunkInterface, a_Player, a_PlacedBlockPos, a_ClickedBlockFace, a_CursorPos, a_BlockType, a_BlockMeta))
{
@@ -75,7 +70,7 @@ public:
- virtual bool IsUseable() override
+ virtual bool IsUseable() const override
{
return true;
}
@@ -84,7 +79,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 6;
diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp
index 79e4a0019..0277f522c 100644
--- a/src/Blocks/BlockBed.cpp
+++ b/src/Blocks/BlockBed.cpp
@@ -19,7 +19,7 @@ void cBlockBedHandler::OnBroken(
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface,
const Vector3i a_BlockPos,
BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta
-)
+) const
{
auto Direction = MetaDataToDirection(a_OldBlockMeta & 0x03);
if ((a_OldBlockMeta & 0x08) != 0)
@@ -61,7 +61,7 @@ bool cBlockBedHandler::OnUse(
const Vector3i a_BlockPos,
eBlockFace a_BlockFace,
const Vector3i a_CursorPos
-)
+) const
{
// Sleeping in bed only allowed in Overworld, beds explode elsewhere:
if (a_WorldInterface.GetDimension() != dimOverworld)
@@ -154,7 +154,7 @@ bool cBlockBedHandler::OnUse(
-void cBlockBedHandler::OnPlacedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, const sSetBlock & a_BlockChange)
+void cBlockBedHandler::OnPlacedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, const sSetBlock & a_BlockChange) const
{
a_Player.GetWorld()->DoWithBedAt(a_BlockChange.GetX(), a_BlockChange.GetY(), a_BlockChange.GetZ(), [&](cBedEntity & a_Bed)
{
@@ -168,7 +168,7 @@ void cBlockBedHandler::OnPlacedByPlayer(cChunkInterface & a_ChunkInterface, cWor
-cItems cBlockBedHandler::ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool)
+cItems cBlockBedHandler::ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const
{
short color = E_META_WOOL_RED;
if (a_BlockEntity != nullptr)
diff --git a/src/Blocks/BlockBed.h b/src/Blocks/BlockBed.h
index 0a5a0e300..aacd26e73 100644
--- a/src/Blocks/BlockBed.h
+++ b/src/Blocks/BlockBed.h
@@ -22,75 +22,62 @@ class cBlockBedHandler :
public:
- cBlockBedHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
+ using Super::Super;
+
+ static Vector3i MetaDataToDirection(NIBBLETYPE a_MetaData)
{
+ switch (a_MetaData)
+ {
+ case 0: return Vector3i(0, 0, 1);
+ case 1: return Vector3i(-1, 0, 0);
+ case 2: return Vector3i(0, 0, -1);
+ case 3: return Vector3i(1, 0, 0);
+ }
+ return Vector3i();
}
+ static void SetBedOccupationState(cChunkInterface & a_ChunkInterface, Vector3i a_BedPosition, bool a_IsOccupied)
+ {
+ auto Meta = a_ChunkInterface.GetBlockMeta(a_BedPosition);
+ if (a_IsOccupied)
+ {
+ Meta |= 0x04; // Where 0x4 = occupied bit
+ }
+ else
+ {
+ Meta &= 0x0b; // Clear the "occupied" bit of the bed's block
+ }
+ a_ChunkInterface.SetBlockMeta(a_BedPosition, Meta);
+ }
-
+private:
// Overrides:
virtual void OnBroken(
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface,
const Vector3i a_BlockPos,
BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta
- ) override;
+ ) const override;
virtual bool OnUse(
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player,
const Vector3i a_ClickedBlockPos,
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos
- ) override;
+ ) const override;
virtual cItems ConvertToPickups(
NIBBLETYPE a_BlockMeta,
cBlockEntity * a_BlockEntity,
const cEntity * a_Digger,
const cItem * a_Tool
- ) override;
+ ) const override;
virtual void OnPlacedByPlayer(
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player,
const sSetBlock & a_BlockChange
- ) override;
-
-
-
-
-
- static Vector3i MetaDataToDirection(NIBBLETYPE a_MetaData)
- {
- switch (a_MetaData)
- {
- case 0: return Vector3i( 0, 0, 1);
- case 1: return Vector3i(-1, 0, 0);
- case 2: return Vector3i( 0, 0, -1);
- case 3: return Vector3i( 1, 0, 0);
- }
- return Vector3i();
- }
-
-
-
-
-
- static void SetBedOccupationState(cChunkInterface & a_ChunkInterface, Vector3i a_BedPosition, bool a_IsOccupied)
- {
- auto Meta = a_ChunkInterface.GetBlockMeta(a_BedPosition);
- if (a_IsOccupied)
- {
- Meta |= 0x04; // Where 0x4 = occupied bit
- }
- else
- {
- Meta &= 0x0b; // Clear the "occupied" bit of the bed's block
- }
-
- a_ChunkInterface.SetBlockMeta(a_BedPosition, Meta);
- }
+ ) const override;
@@ -102,7 +89,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 28;
diff --git a/src/Blocks/BlockBigFlower.h b/src/Blocks/BlockBigFlower.h
index 150ae6633..cb2053c77 100644
--- a/src/Blocks/BlockBigFlower.h
+++ b/src/Blocks/BlockBigFlower.h
@@ -16,16 +16,11 @@ class cBlockBigFlowerHandler:
public:
- cBlockBigFlowerHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+private:
- virtual bool DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface, Vector3i a_Pos, cPlayer & a_Player, NIBBLETYPE a_Meta) override
+ virtual bool DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface, Vector3i a_Pos, cPlayer & a_Player, NIBBLETYPE a_Meta) const override
{
if (IsMetaTopPart(a_Meta))
{
@@ -52,7 +47,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
{
if (IsMetaTopPart(a_BlockMeta))
{
@@ -86,7 +81,7 @@ public:
- bool IsMetaTopPart(NIBBLETYPE a_Meta)
+ static bool IsMetaTopPart(NIBBLETYPE a_Meta)
{
return ((a_Meta & 0x08) != 0);
}
@@ -95,7 +90,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
if (a_RelPos.y <= 0)
{
@@ -112,7 +107,7 @@ public:
- virtual void OnBroken(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, const Vector3i a_BlockPos, BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta) override
+ virtual void OnBroken(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, const Vector3i a_BlockPos, BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta) const override
{
if ((a_OldBlockMeta & 0x8) != 0)
{
@@ -138,7 +133,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 7;
diff --git a/src/Blocks/BlockBookShelf.h b/src/Blocks/BlockBookShelf.h
index 4d1afb1fa..28994c009 100644
--- a/src/Blocks/BlockBookShelf.h
+++ b/src/Blocks/BlockBookShelf.h
@@ -1,26 +1,26 @@
-
-#pragma once
-
-#include "BlockHandler.h"
-
-
-
-
-class cBlockBookShelfHandler :
- public cBlockHandler
-{
- public:
- cBlockBookShelfHandler(BLOCKTYPE a_BlockType) :
- cBlockHandler(a_BlockType)
- {
- }
-
- virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override
- {
- if (ToolHasSilkTouch(a_Tool))
- {
- return cItem(m_BlockType, 1);
- }
- return cItem(E_ITEM_BOOK, 3);
- }
-};
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+class cBlockBookShelfHandler :
+ public cBlockHandler
+{
+public:
+
+ using cBlockHandler::cBlockHandler;
+
+private:
+
+ virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
+ {
+ if (ToolHasSilkTouch(a_Tool))
+ {
+ return cItem(m_BlockType, 1);
+ }
+ return cItem(E_ITEM_BOOK, 3);
+ }
+};
diff --git a/src/Blocks/BlockBrewingStand.h b/src/Blocks/BlockBrewingStand.h
index b8a8b2dc0..e23a60b67 100644
--- a/src/Blocks/BlockBrewingStand.h
+++ b/src/Blocks/BlockBrewingStand.h
@@ -15,16 +15,11 @@ class cBlockBrewingStandHandler :
public:
- cBlockBrewingStandHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+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
{
cItems res(cItem(E_ITEM_BREWING_STAND, 1)); // We have to drop the item form of a brewing stand
if (a_BlockEntity != nullptr)
@@ -39,7 +34,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 6;
diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h
index aba20f8a1..1ce0e619a 100644
--- a/src/Blocks/BlockButton.h
+++ b/src/Blocks/BlockButton.h
@@ -16,14 +16,45 @@ class cBlockButtonHandler :
public:
- cBlockButtonHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
+ using Super::Super;
+
+ /** Extracts the ON bit from metadata and returns if true if it is set */
+ static bool IsButtonOn(NIBBLETYPE a_Meta)
{
+ return (a_Meta & 0x08) == 0x08;
}
+ /** Event handler for an arrow striking a block.
+ Performs appropriate handling if the arrow intersected a wooden button. */
+ static void OnArrowHit(cWorld & a_World, const Vector3i a_Position, const eBlockFace a_HitFace)
+ {
+ BLOCKTYPE Type;
+ NIBBLETYPE Meta;
+ const auto Pos = AddFaceDirection(a_Position, a_HitFace);
+ if (
+ !a_World.GetBlockTypeMeta(Pos, Type, Meta) ||
+ IsButtonOn(Meta) ||
+ !IsButtonPressedByArrow(a_World, Pos, Type, Meta)
+ )
+ {
+ // Bail if we're not specifically a wooden button, or it's already on
+ // or if the arrow didn't intersect. It is very important that nothing is
+ // done if the button is depressed, since the release task will already be queued
+ return;
+ }
+ a_World.SetBlockMeta(Pos, Meta | 0x08);
+ a_World.WakeUpSimulators(Pos);
+ // sound name is ok to be wood, because only wood gets triggered by arrow
+ a_World.GetBroadcastManager().BroadcastSoundEffect("block.wood_button.click_on", Pos, 0.5f, 0.6f);
+
+ // Queue a button reset
+ QueueButtonRelease(a_World, Pos, Type);
+ }
+
+private:
virtual bool OnUse(
cChunkInterface & a_ChunkInterface,
@@ -32,7 +63,7 @@ public:
const Vector3i a_BlockPos,
eBlockFace a_BlockFace,
const Vector3i a_CursorPos
- ) override
+ ) const override
{
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockPos);
@@ -61,7 +92,7 @@ public:
- virtual bool IsUseable(void) override
+ virtual bool IsUseable(void) const override
{
return true;
}
@@ -77,7 +108,7 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
a_BlockType = m_BlockType;
a_BlockMeta = BlockFaceToMetaData(a_ClickedBlockFace);
@@ -135,7 +166,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
auto Meta = a_Chunk.GetMeta(a_RelPos);
auto SupportRelPos = AddFaceDirection(a_RelPos, BlockMetaDataToBlockFace(Meta), true);
@@ -153,50 +184,12 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 0;
}
- /** Extracts the ON bit from metadata and returns if true if it is set */
- static bool IsButtonOn(NIBBLETYPE a_Meta)
- {
- return (a_Meta & 0x08) == 0x08;
- }
-
- /** Event handler for an arrow striking a block.
- Performs appropriate handling if the arrow intersected a wooden button. */
- static void OnArrowHit(cWorld & a_World, const Vector3i a_Position, const eBlockFace a_HitFace)
- {
- BLOCKTYPE Type;
- NIBBLETYPE Meta;
- const auto Pos = AddFaceDirection(a_Position, a_HitFace);
-
- if (
- !a_World.GetBlockTypeMeta(Pos, Type, Meta) ||
- IsButtonOn(Meta) ||
- !IsButtonPressedByArrow(a_World, Pos, Type, Meta)
- )
- {
- // Bail if we're not specifically a wooden button, or it's already on
- // or if the arrow didn't intersect. It is very important that nothing is
- // done if the button is depressed, since the release task will already be queued
- return;
- }
-
- a_World.SetBlockMeta(Pos, Meta | 0x08);
- a_World.WakeUpSimulators(Pos);
-
- // sound name is ok to be wood, because only wood gets triggered by arrow
- a_World.GetBroadcastManager().BroadcastSoundEffect("block.wood_button.click_on", Pos, 0.5f, 0.6f);
-
- // Queue a button reset
- QueueButtonRelease(a_World, Pos, Type);
- }
-
-private:
-
/** Schedules a recurring event at appropriate intervals to release a button at a given position.
The given block type is checked when the task is executed to ensure the position still contains a button. */
static void QueueButtonRelease(cWorld & a_ButtonWorld, const Vector3i a_Position, const BLOCKTYPE a_BlockType)
diff --git a/src/Blocks/BlockCactus.h b/src/Blocks/BlockCactus.h
index 15d585eac..64feac77d 100644
--- a/src/Blocks/BlockCactus.h
+++ b/src/Blocks/BlockCactus.h
@@ -14,14 +14,9 @@ class cBlockCactusHandler :
public:
- cBlockCactusHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+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. */
@@ -32,7 +27,7 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
if (
a_Player.GetWorld()->DoWithChunkAt(a_PlacedBlockPos,
@@ -57,7 +52,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
if (a_RelPos.y <= 0)
{
@@ -102,7 +97,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 7;
@@ -111,7 +106,7 @@ public:
- virtual int Grow(cChunk & a_Chunk, Vector3i a_RelPos, int a_NumStages = 1) override
+ virtual int Grow(cChunk & a_Chunk, Vector3i a_RelPos, int a_NumStages = 1) const override
{
// Check the total height of the cacti blocks here:
int top = a_RelPos.y + 1;
@@ -179,13 +174,7 @@ public:
return numToGrow;
}
-
-
-
-
-protected:
-
- virtual PlantAction CanGrow(cChunk & a_Chunk, Vector3i a_RelPos) override
+ virtual PlantAction CanGrow(cChunk & a_Chunk, Vector3i a_RelPos) const override
{
// Only allow growing if there's an air block above:
if (((a_RelPos.y + 1) < cChunkDef::Height) && (a_Chunk.GetBlock(a_RelPos.addedY(1)) == E_BLOCK_AIR))
diff --git a/src/Blocks/BlockCake.h b/src/Blocks/BlockCake.h
index b7506f2e7..089dc58bd 100644
--- a/src/Blocks/BlockCake.h
+++ b/src/Blocks/BlockCake.h
@@ -10,15 +10,12 @@ class cBlockCakeHandler:
public cBlockHandler
{
using Super = cBlockHandler;
-public:
- cBlockCakeHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
+public:
+ using Super::Super;
+private:
virtual bool OnUse(
cChunkInterface & a_ChunkInterface,
@@ -27,7 +24,7 @@ public:
const Vector3i a_BlockPos,
eBlockFace a_BlockFace,
const Vector3i a_CursorPos
- ) override
+ ) const override
{
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockPos);
@@ -52,7 +49,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
{
// Give nothing
return {};
@@ -62,12 +59,12 @@ public:
- virtual bool IsUseable(void) override
+ virtual bool IsUseable(void) const override
{
return true;
}
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 14;
diff --git a/src/Blocks/BlockCarpet.h b/src/Blocks/BlockCarpet.h
index 41e84c47b..fff31d8fe 100644
--- a/src/Blocks/BlockCarpet.h
+++ b/src/Blocks/BlockCarpet.h
@@ -21,14 +21,9 @@ class cBlockCarpetHandler:
public:
- cBlockCarpetHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+private:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface,
@@ -37,7 +32,7 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
a_BlockType = m_BlockType;
a_BlockMeta = a_Player.GetEquippedItem().m_ItemDamage & 0x0f;
@@ -48,7 +43,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
return (a_RelPos.y > 0) && (a_Chunk.GetBlock(a_RelPos.addedY(-1)) != E_BLOCK_AIR);
}
@@ -57,7 +52,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
switch (a_Meta)
{
diff --git a/src/Blocks/BlockCauldron.h b/src/Blocks/BlockCauldron.h
index be9b8d64f..9f2d0c82e 100644
--- a/src/Blocks/BlockCauldron.h
+++ b/src/Blocks/BlockCauldron.h
@@ -15,16 +15,11 @@ class cBlockCauldronHandler :
public:
- cBlockCauldronHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+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
{
return cItem(E_ITEM_CAULDRON, 1, 0);
}
@@ -40,7 +35,7 @@ public:
const Vector3i a_BlockPos,
eBlockFace a_BlockFace,
const Vector3i a_CursorPos
- ) override
+ ) const override
{
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockPos);
auto EquippedItem = a_Player.GetEquippedItem();
@@ -162,7 +157,7 @@ public:
- virtual bool IsUseable() override
+ virtual bool IsUseable() const override
{
return true;
}
@@ -177,7 +172,7 @@ public:
cBlockPluginInterface & a_PluginInterface,
cChunk & a_Chunk,
const Vector3i a_RelPos
- ) override
+ ) const override
{
auto WorldPos = a_Chunk.RelativeToAbsolute(a_RelPos);
if (!a_WorldInterface.IsWeatherWetAtXYZ(WorldPos.addedY(1)))
@@ -197,7 +192,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 21;
diff --git a/src/Blocks/BlockChest.h b/src/Blocks/BlockChest.h
index d28ea81fd..122a345ca 100644
--- a/src/Blocks/BlockChest.h
+++ b/src/Blocks/BlockChest.h
@@ -17,14 +17,36 @@ class cBlockChestHandler :
public:
- cBlockChestHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
+ using Super::Super;
+ /** Translates player yaw when placing a chest into the chest block metadata. Valid for single chests only */
+ static NIBBLETYPE PlayerYawToMetaData(double a_Yaw)
+ {
+ a_Yaw += 90 + 45; // So its not aligned with axis
+ if (a_Yaw > 360.f)
+ {
+ a_Yaw -= 360.f;
+ }
+ if ((a_Yaw >= 0.f) && (a_Yaw < 90.f))
+ {
+ return 0x04;
+ }
+ else if ((a_Yaw >= 180) && (a_Yaw < 270))
+ {
+ return 0x05;
+ }
+ else if ((a_Yaw >= 90) && (a_Yaw < 180))
+ {
+ return 0x02;
+ }
+ else
+ {
+ return 0x03;
+ }
+ }
+private:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface,
@@ -33,7 +55,7 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
// Cannot place right next to double-chest:
if (!CanBeAt(a_ChunkInterface, a_PlacedBlockPos))
@@ -82,7 +104,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
auto BlockPos = a_Chunk.RelativeToAbsolute(a_RelPos);
return CanBeAt(a_ChunkInterface, BlockPos);
@@ -92,7 +114,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_BlockPos)
+ bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_BlockPos) const
{
cBlockArea Area;
if (!Area.Read(a_ChunkInterface, a_BlockPos - Vector3i(2, 0, 2), a_BlockPos + Vector3i(2, 0, 2)))
@@ -161,39 +183,8 @@ public:
- /** Translates player yaw when placing a chest into the chest block metadata. Valid for single chests only */
- static NIBBLETYPE PlayerYawToMetaData(double a_Yaw)
- {
- a_Yaw += 90 + 45; // So its not aligned with axis
-
- if (a_Yaw > 360.f)
- {
- a_Yaw -= 360.f;
- }
- if ((a_Yaw >= 0.f) && (a_Yaw < 90.f))
- {
- return 0x04;
- }
- else if ((a_Yaw >= 180) && (a_Yaw < 270))
- {
- return 0x05;
- }
- else if ((a_Yaw >= 90) && (a_Yaw < 180))
- {
- return 0x02;
- }
- else
- {
- return 0x03;
- }
- }
-
-
-
-
-
/** If there's a chest in the a_Area in the specified coords, modifies its meta to a_NewMeta and returns true. */
- bool CheckAndAdjustNeighbor(cChunkInterface & a_ChunkInterface, const cBlockArea & a_Area, int a_RelX, int a_RelZ, NIBBLETYPE a_NewMeta)
+ bool CheckAndAdjustNeighbor(cChunkInterface & a_ChunkInterface, const cBlockArea & a_Area, int a_RelX, int a_RelZ, NIBBLETYPE a_NewMeta) const
{
if (a_Area.GetRelBlockType(a_RelX, 0, a_RelZ) != m_BlockType)
{
@@ -207,7 +198,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 13;
diff --git a/src/Blocks/BlockCloth.h b/src/Blocks/BlockCloth.h
index a46cfafb2..0e24e7d37 100644
--- a/src/Blocks/BlockCloth.h
+++ b/src/Blocks/BlockCloth.h
@@ -11,12 +11,12 @@ class cBlockClothHandler :
public cBlockHandler
{
public:
- cBlockClothHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ using cBlockHandler::cBlockHandler;
+
+private:
+
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
switch (a_Meta)
{
@@ -44,7 +44,3 @@ public:
}
}
} ;
-
-
-
-
diff --git a/src/Blocks/BlockCobWeb.h b/src/Blocks/BlockCobWeb.h
index 0c80edd2d..661880141 100644
--- a/src/Blocks/BlockCobWeb.h
+++ b/src/Blocks/BlockCobWeb.h
@@ -13,16 +13,12 @@ class cBlockCobWebHandler :
public cBlockHandler
{
public:
- cBlockCobWebHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
+ using cBlockHandler::cBlockHandler;
+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
{
// Silk touch gives cobweb, anything else gives just string:
if (ToolHasSilkTouch(a_Tool))
@@ -39,7 +35,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 3;
diff --git a/src/Blocks/BlockCocoaPod.h b/src/Blocks/BlockCocoaPod.h
index 955a2e3fc..6cf2e0e5d 100644
--- a/src/Blocks/BlockCocoaPod.h
+++ b/src/Blocks/BlockCocoaPod.h
@@ -13,16 +13,31 @@ class cBlockCocoaPodHandler :
using Super = cBlockHandler;
public:
- cBlockCocoaPodHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
+ using Super::Super;
+ static NIBBLETYPE BlockFaceToMeta(eBlockFace a_BlockFace)
+ {
+ switch (a_BlockFace)
+ {
+ case BLOCK_FACE_ZM: return 0;
+ case BLOCK_FACE_XM: return 3;
+ case BLOCK_FACE_XP: return 1;
+ case BLOCK_FACE_ZP: return 2;
+ case BLOCK_FACE_NONE:
+ case BLOCK_FACE_YM:
+ case BLOCK_FACE_YP:
+ {
+ ASSERT(!"Unknown face");
+ return 0;
+ }
+ }
+ UNREACHABLE("Unsupported block face");
+ }
+private:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
// Check that we're attached to a jungle log block:
eBlockFace BlockFace = MetaToBlockFace(a_Chunk.GetMeta(a_RelPos));
@@ -43,7 +58,7 @@ public:
cBlockPluginInterface & a_PluginInterface,
cChunk & a_Chunk,
const Vector3i a_RelPos
- ) override
+ ) const override
{
if (GetRandomProvider().RandBool(0.20))
{
@@ -55,7 +70,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
{
// If fully grown, give 3 items, otherwise just one:
auto growState = a_BlockMeta >> 2;
@@ -66,7 +81,7 @@ public:
- virtual int Grow(cChunk & a_Chunk, Vector3i a_RelPos, int a_NumStages = 1) override
+ virtual int Grow(cChunk & a_Chunk, Vector3i a_RelPos, int a_NumStages = 1) const override
{
auto meta = a_Chunk.GetMeta(a_RelPos);
auto typeMeta = meta & 0x03;
@@ -105,30 +120,7 @@ public:
- static NIBBLETYPE BlockFaceToMeta(eBlockFace a_BlockFace)
- {
- switch (a_BlockFace)
- {
- case BLOCK_FACE_ZM: return 0;
- case BLOCK_FACE_XM: return 3;
- case BLOCK_FACE_XP: return 1;
- case BLOCK_FACE_ZP: return 2;
- case BLOCK_FACE_NONE:
- case BLOCK_FACE_YM:
- case BLOCK_FACE_YP:
- {
- ASSERT(!"Unknown face");
- return 0;
- }
- }
- UNREACHABLE("Unsupported block face");
- }
-
-
-
-
-
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 34;
diff --git a/src/Blocks/BlockCommandBlock.h b/src/Blocks/BlockCommandBlock.h
index 4bd47963c..6d4aad40a 100644
--- a/src/Blocks/BlockCommandBlock.h
+++ b/src/Blocks/BlockCommandBlock.h
@@ -14,16 +14,11 @@ class cBlockCommandBlockHandler :
public:
- cBlockCommandBlockHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+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 allow as a pickup:
return {};
@@ -33,7 +28,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 10;
diff --git a/src/Blocks/BlockComparator.h b/src/Blocks/BlockComparator.h
index ba939b41f..53edaca50 100644
--- a/src/Blocks/BlockComparator.h
+++ b/src/Blocks/BlockComparator.h
@@ -16,14 +16,90 @@ class cBlockComparatorHandler :
public:
- cBlockComparatorHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
+ using Super::Super;
+
+ inline static bool IsInSubtractionMode(NIBBLETYPE a_Meta)
{
+ return ((a_Meta & 0x4) == 0x4);
}
+ inline static Vector3i GetFrontCoordinate(Vector3i a_Position, NIBBLETYPE a_Meta)
+ {
+ switch (a_Meta)
+ {
+ case 0x0: a_Position.z--; break;
+ case 0x1: a_Position.x++; break;
+ case 0x2: a_Position.z++; break;
+ case 0x3: a_Position.x--; break;
+ default:
+ {
+ LOGWARNING("%s: Unknown metadata: %d", __FUNCTION__, a_Meta);
+ ASSERT(!"Unknown metadata while determining orientation of comparator!");
+ break;
+ }
+ }
+ return a_Position;
+ }
+ inline static Vector3i GetSideCoordinate(Vector3i a_Position, NIBBLETYPE a_Meta, bool a_bInverse)
+ {
+ if (!a_bInverse)
+ {
+ switch (a_Meta)
+ {
+ case 0x0: a_Position.x++; break;
+ case 0x1: a_Position.z--; break;
+ case 0x2: a_Position.x--; break;
+ case 0x3: a_Position.z++; break;
+ default:
+ {
+ LOGWARNING("%s: Unknown metadata: %d", __FUNCTION__, a_Meta);
+ ASSERT(!"Unknown metadata while determining orientation of comparator!");
+ break;
+ }
+ }
+ }
+ else
+ {
+ switch (a_Meta)
+ {
+ case 0x0: a_Position.x--; break;
+ case 0x1: a_Position.z++; break;
+ case 0x2: a_Position.x++; break;
+ case 0x3: a_Position.z--; break;
+ default:
+ {
+ LOGWARNING("%s: Unknown metadata: %d", __FUNCTION__, a_Meta);
+ ASSERT(!"Unknown metadata while determining orientation of comparator!");
+ break;
+ }
+ }
+ }
+ return a_Position;
+ }
+
+ inline static Vector3i GetRearCoordinate(Vector3i a_Position, NIBBLETYPE a_Meta)
+ {
+ switch (a_Meta)
+ {
+ case 0x0: a_Position.z++; break;
+ case 0x1: a_Position.x--; break;
+ case 0x2: a_Position.z--; break;
+ case 0x3: a_Position.x++; break;
+ default:
+ {
+ LOGWARNING("%s: Unknown metadata: %d", __FUNCTION__, a_Meta);
+ ASSERT(!"Unknown metadata while determining orientation of comparator!");
+ break;
+ }
+ }
+
+ return a_Position;
+ }
+
+private:
virtual bool OnUse(
cChunkInterface & a_ChunkInterface,
@@ -32,7 +108,7 @@ public:
const Vector3i a_BlockPos,
eBlockFace a_BlockFace,
const Vector3i a_CursorPos
- ) override
+ ) const override
{
const auto Meta = a_ChunkInterface.GetBlockMeta(a_BlockPos);
@@ -54,7 +130,7 @@ public:
cPlayer & a_Player,
const Vector3i a_BlockPos,
eBlockFace a_BlockFace
- ) override
+ ) const override
{
UNUSED(a_ChunkInterface);
UNUSED(a_BlockFace);
@@ -67,7 +143,7 @@ public:
- virtual bool IsUseable(void) override
+ virtual bool IsUseable(void) const override
{
return true;
}
@@ -76,7 +152,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
if (a_RelPos.y <= 0)
{
@@ -106,7 +182,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
{
return cItem(E_ITEM_COMPARATOR, 1, 0);
}
@@ -115,104 +191,7 @@ public:
- inline static bool IsInSubtractionMode(NIBBLETYPE a_Meta)
- {
- return ((a_Meta & 0x4) == 0x4);
- }
-
-
-
-
-
- inline static Vector3i GetSideCoordinate(Vector3i a_Position, NIBBLETYPE a_Meta, bool a_bInverse)
- {
- if (!a_bInverse)
- {
- switch (a_Meta)
- {
- case 0x0: a_Position.x++; break;
- case 0x1: a_Position.z--; break;
- case 0x2: a_Position.x--; break;
- case 0x3: a_Position.z++; break;
- default:
- {
- LOGWARNING("%s: Unknown metadata: %d", __FUNCTION__, a_Meta);
- ASSERT(!"Unknown metadata while determining orientation of comparator!");
- break;
- }
- }
- }
- else
- {
- switch (a_Meta)
- {
- case 0x0: a_Position.x--; break;
- case 0x1: a_Position.z++; break;
- case 0x2: a_Position.x++; break;
- case 0x3: a_Position.z--; break;
- default:
- {
- LOGWARNING("%s: Unknown metadata: %d", __FUNCTION__, a_Meta);
- ASSERT(!"Unknown metadata while determining orientation of comparator!");
- break;
- }
- }
- }
-
- return a_Position;
- }
-
-
-
-
-
- inline static Vector3i GetRearCoordinate(Vector3i a_Position, NIBBLETYPE a_Meta)
- {
- switch (a_Meta)
- {
- case 0x0: a_Position.z++; break;
- case 0x1: a_Position.x--; break;
- case 0x2: a_Position.z--; break;
- case 0x3: a_Position.x++; break;
- default:
- {
- LOGWARNING("%s: Unknown metadata: %d", __FUNCTION__, a_Meta);
- ASSERT(!"Unknown metadata while determining orientation of comparator!");
- break;
- }
- }
-
- return a_Position;
- }
-
-
-
-
-
- inline static Vector3i GetFrontCoordinate(Vector3i a_Position, NIBBLETYPE a_Meta)
- {
- switch (a_Meta)
- {
- case 0x0: a_Position.z--; break;
- case 0x1: a_Position.x++; break;
- case 0x2: a_Position.z++; break;
- case 0x3: a_Position.x--; break;
- default:
- {
- LOGWARNING("%s: Unknown metadata: %d", __FUNCTION__, a_Meta);
- ASSERT(!"Unknown metadata while determining orientation of comparator!");
- break;
- }
- }
-
- return a_Position;
- }
-
-
-
-
-
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 11;
diff --git a/src/Blocks/BlockConcretePowder.h b/src/Blocks/BlockConcretePowder.h
index 7cd99149e..83a475b88 100644
--- a/src/Blocks/BlockConcretePowder.h
+++ b/src/Blocks/BlockConcretePowder.h
@@ -14,27 +14,26 @@ class cBlockConcretePowderHandler :
public:
- cBlockConcretePowderHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
+ using Super::Super;
+
+private:
virtual void OnPlaced(
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface,
Vector3i a_BlockPos,
BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta
- ) override
+ ) const override
{
OnNeighborChanged(a_ChunkInterface, a_BlockPos, BLOCK_FACE_NONE);
}
- virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) override
+ virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const override
{
a_ChunkInterface.DoWithChunkAt(a_BlockPos, [&](cChunk & a_Chunk) { CheckSoaked(a_Chunk.AbsoluteToRelative(a_BlockPos), a_Chunk); return true; });
}
/** Check blocks above and around to see if they are water. If one is, converts this into concrete block. */
- void CheckSoaked(Vector3i a_Rel, cChunk & a_Chunk)
+ static void CheckSoaked(Vector3i a_Rel, cChunk & a_Chunk)
{
const auto & WaterCheck = cSimulator::AdjacentOffsets;
const bool ShouldSoak = std::any_of(WaterCheck.cbegin(), WaterCheck.cend(), [a_Rel, & a_Chunk](Vector3i a_Offset)
@@ -54,7 +53,7 @@ public:
}
}
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
switch (a_Meta)
{
diff --git a/src/Blocks/BlockCrops.h b/src/Blocks/BlockCrops.h
index 05bb0d2f1..7208c8ff8 100644
--- a/src/Blocks/BlockCrops.h
+++ b/src/Blocks/BlockCrops.h
@@ -17,16 +17,11 @@ class cBlockCropsHandler:
public:
- cBlockCropsHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+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
{
auto & rand = GetRandomProvider();
@@ -90,7 +85,7 @@ public:
- virtual int Grow(cChunk & a_Chunk, Vector3i a_RelPos, int a_NumStages = 1) override
+ virtual int Grow(cChunk & a_Chunk, Vector3i a_RelPos, int a_NumStages = 1) const override
{
auto oldMeta = a_Chunk.GetMeta(a_RelPos);
if (oldMeta >= RipeMeta)
@@ -108,7 +103,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
return ((a_RelPos.y > 0) && (a_Chunk.GetBlock(a_RelPos.addedY(-1)) == E_BLOCK_FARMLAND));
}
@@ -117,7 +112,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 7;
diff --git a/src/Blocks/BlockDeadBush.h b/src/Blocks/BlockDeadBush.h
index 9eb0c8e84..0653f538b 100644
--- a/src/Blocks/BlockDeadBush.h
+++ b/src/Blocks/BlockDeadBush.h
@@ -13,16 +13,12 @@ class cBlockDeadBushHandler:
using Super = cBlockHandler;
public:
- cBlockDeadBushHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
+ using Super::Super;
+private:
- virtual bool DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface, Vector3i a_Pos, cPlayer & a_Player, NIBBLETYPE a_Meta) override
+ virtual bool DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface, Vector3i a_Pos, cPlayer & a_Player, NIBBLETYPE a_Meta) const override
{
return true;
}
@@ -31,7 +27,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
if (a_RelPos.y <= 0)
{
@@ -56,7 +52,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
{
// If cutting down with shears, drop self:
if ((a_Tool != nullptr) && (a_Tool->m_ItemType == E_ITEM_SHEARS))
@@ -77,7 +73,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 0;
diff --git a/src/Blocks/BlockDirt.h b/src/Blocks/BlockDirt.h
index 24c726149..860bc66c8 100644
--- a/src/Blocks/BlockDirt.h
+++ b/src/Blocks/BlockDirt.h
@@ -14,16 +14,11 @@ class cBlockDirtHandler :
public:
- cBlockDirtHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+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
{
if (a_BlockMeta == E_META_DIRT_COARSE)
{
@@ -40,7 +35,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 10;
diff --git a/src/Blocks/BlockDoor.cpp b/src/Blocks/BlockDoor.cpp
index 5c5a4b545..fbd236b1d 100644
--- a/src/Blocks/BlockDoor.cpp
+++ b/src/Blocks/BlockDoor.cpp
@@ -7,16 +7,7 @@
-cBlockDoorHandler::cBlockDoorHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
-{
-}
-
-
-
-
-
-void cBlockDoorHandler::OnBroken(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta)
+void cBlockDoorHandler::OnBroken(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta) const
{
// A part of the multiblock door was broken; the relevant half will drop any pickups as required.
// All that is left to do is to delete the other half of the multiblock.
@@ -52,7 +43,7 @@ bool cBlockDoorHandler::OnUse(
const Vector3i a_BlockPos,
eBlockFace a_BlockFace,
const Vector3i a_CursorPos
-)
+) const
{
UNUSED(a_WorldInterface);
UNUSED(a_BlockFace);
@@ -98,7 +89,7 @@ void cBlockDoorHandler::OnCancelRightClick(
cPlayer & a_Player,
const Vector3i a_BlockPos,
eBlockFace a_BlockFace
-)
+) const
{
UNUSED(a_ChunkInterface);
UNUSED(a_BlockFace);
@@ -122,7 +113,7 @@ void cBlockDoorHandler::OnCancelRightClick(
-cBoundingBox cBlockDoorHandler::GetPlacementCollisionBox(BLOCKTYPE a_XM, BLOCKTYPE a_XP, BLOCKTYPE a_YM, BLOCKTYPE a_YP, BLOCKTYPE a_ZM, BLOCKTYPE a_ZP)
+cBoundingBox cBlockDoorHandler::GetPlacementCollisionBox(BLOCKTYPE a_XM, BLOCKTYPE a_XP, BLOCKTYPE a_YM, BLOCKTYPE a_YP, BLOCKTYPE a_ZM, BLOCKTYPE a_ZP) const
{
// Doors can be placed inside the player
return cBoundingBox(0, 0, 0, 0, 0, 0);
@@ -132,7 +123,7 @@ cBoundingBox cBlockDoorHandler::GetPlacementCollisionBox(BLOCKTYPE a_XM, BLOCKTY
-NIBBLETYPE cBlockDoorHandler::MetaRotateCCW(NIBBLETYPE a_Meta)
+NIBBLETYPE cBlockDoorHandler::MetaRotateCCW(NIBBLETYPE a_Meta) const
{
if (a_Meta & 0x08)
{
@@ -150,7 +141,7 @@ NIBBLETYPE cBlockDoorHandler::MetaRotateCCW(NIBBLETYPE a_Meta)
-NIBBLETYPE cBlockDoorHandler::MetaRotateCW(NIBBLETYPE a_Meta)
+NIBBLETYPE cBlockDoorHandler::MetaRotateCW(NIBBLETYPE a_Meta) const
{
if (a_Meta & 0x08)
{
@@ -168,7 +159,7 @@ NIBBLETYPE cBlockDoorHandler::MetaRotateCW(NIBBLETYPE a_Meta)
-NIBBLETYPE cBlockDoorHandler::MetaMirrorXY(NIBBLETYPE a_Meta)
+NIBBLETYPE cBlockDoorHandler::MetaMirrorXY(NIBBLETYPE a_Meta) const
{
/*
Top bit (0x08) contains door block position (Top / Bottom). Only Bottom blocks contain position data
@@ -202,7 +193,7 @@ NIBBLETYPE cBlockDoorHandler::MetaMirrorXY(NIBBLETYPE a_Meta)
-NIBBLETYPE cBlockDoorHandler::MetaMirrorYZ(NIBBLETYPE a_Meta)
+NIBBLETYPE cBlockDoorHandler::MetaMirrorYZ(NIBBLETYPE a_Meta) const
{
// Top bit (0x08) contains door panel type (Top / Bottom panel) Only Bottom panels contain position data
// Return a_Meta if panel is a top panel (0x08 bit is set to 1)
diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h
index a953a8553..ff3757d79 100644
--- a/src/Blocks/BlockDoor.h
+++ b/src/Blocks/BlockDoor.h
@@ -18,13 +18,124 @@ class cBlockDoorHandler :
public:
- cBlockDoorHandler(BLOCKTYPE a_BlockType);
+ using Super::Super;
+
+ /** Returns true if door can be placed on the specified block type. */
+ static bool CanBeOn(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+ {
+ // Vanilla refuses to place doors on transparent blocks, except top-half slabs and other doors
+ // We need to keep the door compatible with itself, otherwise the top half drops while the bottom half stays
+
+ // Doors can be placed on upside-down slabs
+ if (cBlockSlabHandler::IsAnySlabType(a_BlockType) && ((a_BlockMeta & 0x08) != 0))
+ {
+ return true;
+ }
+ // Doors can also be placed on other doors
+ else if (IsDoorBlockType(a_BlockType))
+ {
+ return true;
+ }
+ // Doors can not be placed on transparent blocks, but on any other block
+ else
+ {
+ return !cBlockInfo::IsTransparent(a_BlockType);
+ }
+ }
+
+ static bool CanReplaceBlock(BLOCKTYPE a_BlockType)
+ {
+ switch (a_BlockType)
+ {
+ case E_BLOCK_AIR:
+ case E_BLOCK_TALL_GRASS:
+ case E_BLOCK_WATER:
+ case E_BLOCK_STATIONARY_WATER:
+ case E_BLOCK_LAVA:
+ case E_BLOCK_STATIONARY_LAVA:
+ case E_BLOCK_SNOW:
+ case E_BLOCK_FIRE:
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /** Returns a vector pointing one block in the direction the door is facing (where the outside is). */
+ inline static Vector3i GetRelativeDirectionToOutside(NIBBLETYPE a_BlockMeta)
+ {
+ switch (a_BlockMeta & 0x03)
+ {
+ case 0: return Vector3i(-1, 0, 0); // Facing West / XM
+ case 1: return Vector3i(0, 0, -1); // Facing North / ZM
+ case 2: return Vector3i(1, 0, 0); // Facing East / XP
+ default: return Vector3i(0, 0, 1); // Facing South / ZP
+ }
+ }
+
+ /** Returns true if the specified blocktype is any kind of door */
+ inline static bool IsDoorBlockType(BLOCKTYPE a_Block)
+ {
+ switch (a_Block)
+ {
+ case E_BLOCK_ACACIA_DOOR:
+ case E_BLOCK_BIRCH_DOOR:
+ case E_BLOCK_DARK_OAK_DOOR:
+ case E_BLOCK_IRON_DOOR:
+ case E_BLOCK_JUNGLE_DOOR:
+ case E_BLOCK_SPRUCE_DOOR:
+ case E_BLOCK_OAK_DOOR:
+ {
+ return true;
+ }
+ default:
+ {
+ return false;
+ }
+ }
+ }
+
+ /** Sets the door to the specified state. If the door is already in that state, does nothing. */
+ static void SetOpen(cChunkInterface & a_ChunkInterface, const Vector3i a_BlockPos, bool a_Open)
+ {
+ BLOCKTYPE Block = a_ChunkInterface.GetBlock(a_BlockPos);
+ if (!IsDoorBlockType(Block))
+ {
+ return;
+ }
+
+ NIBBLETYPE Meta = GetCompleteDoorMeta(a_ChunkInterface, a_BlockPos);
+ bool IsOpened = ((Meta & 0x04) != 0);
+ if (IsOpened == a_Open)
+ {
+ return;
+ }
+
+ // Change the door
+ NIBBLETYPE NewMeta = (Meta & 0x07) ^ 0x04; // Flip the "IsOpen" bit (0x04)
+ if ((Meta & 0x08) == 0)
+ {
+ // The block is the bottom part of the door
+ a_ChunkInterface.SetBlockMeta(a_BlockPos, NewMeta);
+ }
+ else
+ {
+ // The block is the top part of the door, set the meta to the corresponding top part
+ if (a_BlockPos.y > 0)
+ {
+ a_ChunkInterface.SetBlockMeta(a_BlockPos.addedY(-1), NewMeta);
+ }
+ }
+ }
+
+private:
virtual void OnBroken(
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface,
Vector3i a_BlockPos,
BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta
- ) override;
+ ) const override;
virtual bool OnUse(
cChunkInterface & a_ChunkInterface,
@@ -33,7 +144,7 @@ public:
const Vector3i a_BlockPos,
eBlockFace a_BlockFace,
const Vector3i a_CursorPos
- ) override;
+ ) const override;
virtual void OnCancelRightClick(
cChunkInterface & a_ChunkInterface,
@@ -41,12 +152,12 @@ public:
cPlayer & a_Player,
const Vector3i a_BlockPos,
eBlockFace a_BlockFace
- ) override;
+ ) const override;
- virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override;
- virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override;
- virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override;
- virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override;
+ virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) const override;
+ virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) const override;
+ virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) const override;
+ virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) const override;
@@ -59,7 +170,7 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
// If clicking a bottom face, place the door one block lower:
auto PlacedPos = a_PlacedBlockPos;
@@ -79,13 +190,13 @@ public:
return Super::GetPlacementBlockTypeMeta(a_ChunkInterface, a_Player, PlacedPos, a_ClickedBlockFace, a_CursorPos, a_BlockType, a_BlockMeta);
}
- virtual cBoundingBox GetPlacementCollisionBox(BLOCKTYPE a_XM, BLOCKTYPE a_XP, BLOCKTYPE a_YM, BLOCKTYPE a_YP, BLOCKTYPE a_ZM, BLOCKTYPE a_ZP) override;
+ virtual cBoundingBox GetPlacementCollisionBox(BLOCKTYPE a_XM, BLOCKTYPE a_XP, BLOCKTYPE a_YM, BLOCKTYPE a_YP, BLOCKTYPE a_ZM, BLOCKTYPE a_ZP) const override;
- 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
{
switch (m_BlockType)
{
@@ -108,7 +219,7 @@ public:
- virtual bool IsUseable(void) override
+ virtual bool IsUseable(void) const override
{
return true;
}
@@ -117,7 +228,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
return ((a_RelPos.y > 0) && CanBeOn(a_Chunk.GetBlock(a_RelPos.addedY(-1)), a_Chunk.GetMeta(a_RelPos.addedY(-1))));
}
@@ -126,94 +237,6 @@ public:
- /** Returns true if door can be placed on the specified block type. */
- static bool CanBeOn(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
- {
- // Vanilla refuses to place doors on transparent blocks, except top-half slabs and other doors
- // We need to keep the door compatible with itself, otherwise the top half drops while the bottom half stays
-
- // Doors can be placed on upside-down slabs
- if (cBlockSlabHandler::IsAnySlabType(a_BlockType) && ((a_BlockMeta & 0x08) != 0))
- {
- return true;
- }
- // Doors can also be placed on other doors
- else if (IsDoorBlockType(a_BlockType))
- {
- return true;
- }
- // Doors can not be placed on transparent blocks, but on any other block
- else
- {
- return !cBlockInfo::IsTransparent(a_BlockType);
- }
- }
-
- static bool CanReplaceBlock(BLOCKTYPE a_BlockType)
- {
- switch (a_BlockType)
- {
- case E_BLOCK_AIR:
- case E_BLOCK_TALL_GRASS:
- case E_BLOCK_WATER:
- case E_BLOCK_STATIONARY_WATER:
- case E_BLOCK_LAVA:
- case E_BLOCK_STATIONARY_LAVA:
- case E_BLOCK_SNOW:
- case E_BLOCK_FIRE:
- {
- return true;
- }
- }
- return false;
- }
-
-
-
-
-
- /** Returns a vector pointing one block in the direction the door is facing (where the outside is). */
- inline static Vector3i GetRelativeDirectionToOutside(NIBBLETYPE a_BlockMeta)
- {
- switch (a_BlockMeta & 0x03)
- {
- case 0: return Vector3i(-1, 0, 0); // Facing West / XM
- case 1: return Vector3i( 0, 0, -1); // Facing North / ZM
- case 2: return Vector3i( 1, 0, 0); // Facing East / XP
- default: return Vector3i( 0, 0, 1); // Facing South / ZP
- }
- }
-
-
-
-
-
- /** Returns true if the specified blocktype is any kind of door */
- inline static bool IsDoorBlockType(BLOCKTYPE a_Block)
- {
- switch (a_Block)
- {
- case E_BLOCK_ACACIA_DOOR:
- case E_BLOCK_BIRCH_DOOR:
- case E_BLOCK_DARK_OAK_DOOR:
- case E_BLOCK_IRON_DOOR:
- case E_BLOCK_JUNGLE_DOOR:
- case E_BLOCK_SPRUCE_DOOR:
- case E_BLOCK_OAK_DOOR:
- {
- return true;
- }
- default:
- {
- return false;
- }
- }
- }
-
-
-
-
-
/** Returns true iff the door at the specified coords is open.
The coords may point to either the top part or the bottom part of the door. */
static NIBBLETYPE IsOpen(cChunkInterface & a_ChunkInterface, const Vector3i a_BlockPos)
@@ -262,43 +285,6 @@ public:
- /** Sets the door to the specified state. If the door is already in that state, does nothing. */
- static void SetOpen(cChunkInterface & a_ChunkInterface, const Vector3i a_BlockPos, bool a_Open)
- {
- BLOCKTYPE Block = a_ChunkInterface.GetBlock(a_BlockPos);
- if (!IsDoorBlockType(Block))
- {
- return;
- }
-
- NIBBLETYPE Meta = GetCompleteDoorMeta(a_ChunkInterface, a_BlockPos);
- bool IsOpened = ((Meta & 0x04) != 0);
- if (IsOpened == a_Open)
- {
- return;
- }
-
- // Change the door
- NIBBLETYPE NewMeta = (Meta & 0x07) ^ 0x04; // Flip the "IsOpen" bit (0x04)
- if ((Meta & 0x08) == 0)
- {
- // The block is the bottom part of the door
- a_ChunkInterface.SetBlockMeta(a_BlockPos, NewMeta);
- }
- else
- {
- // The block is the top part of the door, set the meta to the corresponding top part
- if (a_BlockPos.y > 0)
- {
- a_ChunkInterface.SetBlockMeta(a_BlockPos.addedY(-1), NewMeta);
- }
- }
- }
-
-
-
-
-
/** Changes the door at the specified coords from open to close or vice versa */
static void ChangeDoor(cChunkInterface & a_ChunkInterface, const Vector3i a_BlockPos)
{
@@ -309,7 +295,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
switch (m_BlockType)
diff --git a/src/Blocks/BlockDropSpenser.h b/src/Blocks/BlockDropSpenser.h
index 90ed1b7d7..fa591bf93 100644
--- a/src/Blocks/BlockDropSpenser.h
+++ b/src/Blocks/BlockDropSpenser.h
@@ -20,16 +20,11 @@ class cBlockDropSpenserHandler :
public:
- cBlockDropSpenserHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+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
{
cItems res(cItem(m_BlockType, 1));
if (a_BlockEntity != nullptr)
@@ -44,7 +39,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 11;
diff --git a/src/Blocks/BlockEnchantingTable.h b/src/Blocks/BlockEnchantingTable.h
index ddd25182b..a03ae7a2a 100644
--- a/src/Blocks/BlockEnchantingTable.h
+++ b/src/Blocks/BlockEnchantingTable.h
@@ -29,7 +29,7 @@ private:
const Vector3i a_BlockPos,
eBlockFace a_BlockFace,
const Vector3i a_CursorPos
- ) override
+ ) const override
{
AString WindowName = "Enchant";
a_WorldInterface.DoWithBlockEntityAt(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, [&WindowName](cBlockEntity & a_Entity)
@@ -56,13 +56,13 @@ private:
}
- virtual bool IsUseable(void) override
+ virtual bool IsUseable(void) const override
{
return true;
}
- 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
{
if ((a_BlockEntity == nullptr) || (a_BlockEntity->GetBlockType() != E_BLOCK_ENCHANTMENT_TABLE))
{
@@ -76,7 +76,7 @@ private:
}
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 29;
diff --git a/src/Blocks/BlockEndPortalFrame.h b/src/Blocks/BlockEndPortalFrame.h
index 567de8bcc..2aa0327cf 100644
--- a/src/Blocks/BlockEndPortalFrame.h
+++ b/src/Blocks/BlockEndPortalFrame.h
@@ -25,14 +25,9 @@ class cBlockEndPortalFrameHandler:
public:
- cBlockEndPortalFrameHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+private:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface,
@@ -41,7 +36,7 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
a_BlockType = m_BlockType;
a_BlockMeta = YawToMetaData(a_Player.GetYaw());
@@ -82,7 +77,167 @@ public:
- virtual bool IsClickedThrough(void) override
+ virtual void OnPlaced(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) const override
+ {
+ // E_META_END_PORTAL_FRAME_EYE is the bit which signifies the eye of ender is in it.
+ // LOG("PortalPlaced, meta %d", a_BlockMeta);
+ if ((a_BlockMeta & E_META_END_PORTAL_FRAME_EYE) == E_META_END_PORTAL_FRAME_EYE)
+ {
+ // LOG("Location is %d %d %d", a_BlockX, a_BlockY, a_BlockZ);
+ // Direction is the first two bits, masked by 0x3
+ FindAndSetPortal(a_BlockPos, a_BlockMeta & 3, a_ChunkInterface, a_WorldInterface);
+ }
+ }
+
+
+
+
+
+ /** Returns false if portal cannot be made, true if portal was made. */
+ static bool FindAndSetPortal(Vector3i a_FirstFrame, NIBBLETYPE a_Direction, cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface)
+ {
+ /*
+ PORTAL FINDING ALGORITH
+ =======================
+ - Get clicked base block
+ - Check diagonally (clockwise) for another portal block
+ - if exists, and has eye, Continue. Abort if any are facing the wrong direction.
+ - if doesn't exist, check horizontally (the block to the left of this block). Abort if there is no horizontal block.
+ - After a corner has been met, traverse the portal clockwise, ensuring valid portal frames connect the rectangle.
+ - Track the NorthWest Corner, and the dimensions.
+ - If dimensions are valid, create the portal.
+ */
+
+ static_assert((E_META_END_PORTAL_FRAME_ZM - E_META_END_PORTAL_FRAME_XM) == 1, "Should be going clockwise");
+
+ const int MIN_PORTAL_WIDTH = 3;
+ const int MAX_PORTAL_WIDTH = 4;
+
+ // Directions to use for the clockwise traversal.
+ static const Vector3i Left[] =
+ {
+ { 1, 0, 0}, // 0, South, left block is East / XP
+ { 0, 0, 1}, // 1, West, left block is South / ZP
+ {-1, 0, 0}, // 2, North, left block is West / XM
+ { 0, 0, -1}, // 3, East, left block is North / ZM
+ };
+ static const Vector3i LeftForward[] =
+ {
+ { 1, 0, 1}, // 0, South, left block is SouthEast / XP ZP
+ {-1, 0, 1}, // 1, West, left block is SouthWest / XM ZP
+ {-1, 0, -1}, // 2, North, left block is NorthWest / XM ZM
+ { 1, 0, -1}, // 3, East, left block is NorthEast / XP ZM
+ };
+
+
+ int EdgesComplete = -1; // We start search _before_ finding the first edge
+ Vector3i NorthWestCorner;
+ int EdgeWidth[4] = { 1, 1, 1, 1 };
+ NIBBLETYPE CurrentDirection = a_Direction;
+ Vector3i CurrentPos = a_FirstFrame;
+
+ // Scan clockwise until we have seen all 4 edges
+ while (EdgesComplete < 4)
+ {
+ // Check if we are at a corner
+ Vector3i NextPos = CurrentPos + LeftForward[CurrentDirection];
+ if (IsPortalFrame(a_ChunkInterface.GetBlock(NextPos)))
+ {
+ // We have found the corner, move clockwise to next edge
+ if (CurrentDirection == E_META_END_PORTAL_FRAME_XP)
+ {
+ // We are on the NW (XM, ZM) Corner
+ // Relative to the previous frame, the portal should appear to the right of this portal frame.
+ NorthWestCorner = NextPos - Left[CurrentDirection];
+ }
+
+ if (EdgesComplete == -1)
+ {
+ // Reset current width, we will revisit it last
+ EdgeWidth[CurrentDirection] = 1;
+ }
+
+ // Rotate 90 degrees clockwise
+ CurrentDirection = (CurrentDirection + 1) % 4;
+ EdgesComplete++;
+ }
+ else
+ {
+ // We are not at a corner, keep walking the edge
+ NextPos = CurrentPos + Left[CurrentDirection];
+
+ EdgeWidth[CurrentDirection]++;
+ if (EdgeWidth[CurrentDirection] > MAX_PORTAL_WIDTH)
+ {
+ // Don't build a portal that is too long.
+ return false;
+ }
+ }
+
+ if (!IsValidFrameAtPos(a_ChunkInterface, NextPos, CurrentDirection))
+ {
+ // Neither the edge nor the corner are valid portal blocks.
+ return false;
+ }
+
+ CurrentPos = NextPos;
+ }
+
+ if ((EdgeWidth[0] != EdgeWidth[2]) || (EdgeWidth[1] != EdgeWidth[3]))
+ {
+ // Mismatched Portal Dimensions.
+ return false;
+ }
+ if ((EdgeWidth[0] < MIN_PORTAL_WIDTH) || (EdgeWidth[1] < MIN_PORTAL_WIDTH))
+ {
+ // Portal too small.
+ return false;
+ }
+
+ // LOG("NW corner (low corner) %d %d %d", Corner.x, Corner.y, Corner.z);
+ // LOG("%d by %d", Width[0], Width[1]);
+ for (int i = 0; i < EdgeWidth[0]; i++)
+ {
+ for (int j = 0; j < EdgeWidth[1]; j++)
+ {
+ a_ChunkInterface.SetBlock(NorthWestCorner.x + i, NorthWestCorner.y, NorthWestCorner.z + j, E_BLOCK_END_PORTAL, 0);
+ // TODO: Create block entity so portal doesn't become invisible on relog.
+ }
+ }
+ return true;
+ }
+
+
+
+
+
+ /** Return true if this block is a portal frame, has an eye, and is facing the correct direction. */
+ static bool IsValidFrameAtPos(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, NIBBLETYPE a_ShouldFace)
+ {
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+
+ return (
+ a_ChunkInterface.GetBlockTypeMeta(a_BlockPos, BlockType, BlockMeta) &&
+ (BlockType == E_BLOCK_END_PORTAL_FRAME) &&
+ (BlockMeta == (a_ShouldFace | E_META_END_PORTAL_FRAME_EYE))
+ );
+ }
+
+
+
+
+ /** Return true if this block is a portal frame. */
+ static bool IsPortalFrame(BLOCKTYPE BlockType)
+ {
+ return (BlockType == E_BLOCK_END_PORTAL_FRAME);
+ }
+
+
+
+
+
+ virtual bool IsClickedThrough(void) const override
{
// TODO: Colision
return true;
@@ -92,7 +247,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 27;
diff --git a/src/Blocks/BlockEnderchest.h b/src/Blocks/BlockEnderchest.h
index a5f45df78..93009da64 100644
--- a/src/Blocks/BlockEnderchest.h
+++ b/src/Blocks/BlockEnderchest.h
@@ -14,16 +14,11 @@ class cBlockEnderchestHandler :
public:
- cBlockEnderchestHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+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
{
// Only drop something when mined with a pickaxe:
if (
diff --git a/src/Blocks/BlockEntity.h b/src/Blocks/BlockEntity.h
index 9fbb77a1f..b1aee7526 100644
--- a/src/Blocks/BlockEntity.h
+++ b/src/Blocks/BlockEntity.h
@@ -19,14 +19,9 @@ class cBlockEntityHandler:
public:
- cBlockEntityHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+private:
virtual bool OnUse(
cChunkInterface & a_ChunkInterface,
@@ -35,7 +30,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);
}
@@ -44,7 +39,7 @@ public:
- virtual bool IsUseable() override
+ virtual bool IsUseable() const override
{
return true;
}
@@ -62,16 +57,14 @@ class cContainerEntityHandler:
{
public:
- cContainerEntityHandler(BLOCKTYPE a_BlockType):
+ constexpr cContainerEntityHandler(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 meta to 0
cItems res(cItem(Base::m_BlockType, 1, 0));
diff --git a/src/Blocks/BlockFarmland.h b/src/Blocks/BlockFarmland.h
index 82c4db923..c6340f58a 100644
--- a/src/Blocks/BlockFarmland.h
+++ b/src/Blocks/BlockFarmland.h
@@ -23,16 +23,11 @@ class cBlockFarmlandHandler :
public:
- cBlockFarmlandHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+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
{
return cItem(E_BLOCK_DIRT, 1, 0);
}
@@ -47,7 +42,7 @@ public:
cBlockPluginInterface & a_PluginInterface,
cChunk & a_Chunk,
const Vector3i a_RelPos
- ) override
+ ) const override
{
auto BlockMeta = a_Chunk.GetMeta(a_RelPos);
@@ -91,7 +86,7 @@ public:
- virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) override
+ virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const override
{
// Don't care about any neighbor but the one above us (fix recursion loop in #2213):
if (a_WhichNeighbor != BLOCK_FACE_YP)
@@ -118,7 +113,7 @@ public:
/** Returns true if there's either a water source block close enough to hydrate the specified position, or it's raining there. */
- bool IsWaterInNear(cChunk & a_Chunk, const Vector3i a_RelPos)
+ static bool IsWaterInNear(const cChunk & a_Chunk, const Vector3i a_RelPos)
{
const auto WorldPos = a_Chunk.RelativeToAbsolute(a_RelPos);
if (a_Chunk.GetWorld()->IsWeatherWetAtXYZ(WorldPos))
@@ -154,7 +149,7 @@ public:
- virtual bool CanSustainPlant(BLOCKTYPE a_Plant) override
+ virtual bool CanSustainPlant(BLOCKTYPE a_Plant) const override
{
return (
(a_Plant == E_BLOCK_BEETROOTS) ||
diff --git a/src/Blocks/BlockFence.h b/src/Blocks/BlockFence.h
index 35a9b139a..13c4a6979 100644
--- a/src/Blocks/BlockFence.h
+++ b/src/Blocks/BlockFence.h
@@ -17,22 +17,17 @@ class cBlockFenceHandler:
public:
+ using Super::Super;
+
+private:
+
// These are the min and max coordinates (X and Z) for a straight fence.
// 0.4 and 0.6 are really just guesses, but they seem pretty good.
// (0.4 to 0.6 is a fence that's 0.2 wide, down the center of the block)
- const double MIN_COORD = 0.4;
- const double MAX_COORD = 0.6;
-
- cBlockFenceHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
-
+ static constexpr double MIN_COORD = 0.4;
+ static constexpr double MAX_COORD = 0.6;
- virtual cBoundingBox GetPlacementCollisionBox(BLOCKTYPE a_XM, BLOCKTYPE a_XP, BLOCKTYPE a_YM, BLOCKTYPE a_YP, BLOCKTYPE a_ZM, BLOCKTYPE a_ZP) override
+ virtual cBoundingBox GetPlacementCollisionBox(BLOCKTYPE a_XM, BLOCKTYPE a_XP, BLOCKTYPE a_YM, BLOCKTYPE a_YP, BLOCKTYPE a_ZM, BLOCKTYPE a_ZP) const override
{
bool XMSolid = cBlockInfo::IsSolid(a_XM);
bool XPSolid = cBlockInfo::IsSolid(a_XP);
@@ -94,7 +89,7 @@ public:
const Vector3i a_BlockPos,
eBlockFace a_BlockFace,
const Vector3i a_CursorPos
- ) override
+ ) const override
{
auto LeashKnot = cLeashKnot::FindKnotAtPos(*a_Player.GetWorld(), a_BlockPos);
auto KnotAlreadyExists = (LeashKnot != nullptr);
@@ -140,7 +135,7 @@ public:
cPlayer & a_Player,
const Vector3i a_BlockPos,
eBlockFace a_BlockFace
- ) override
+ ) const override
{
a_WorldInterface.SendBlockTo(a_BlockPos, a_Player);
}
@@ -149,7 +144,7 @@ public:
- virtual bool IsUseable(void) override
+ virtual bool IsUseable(void) const override
{
return true;
}
@@ -162,7 +157,7 @@ public:
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface,
Vector3i a_BlockPos,
BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta
- ) override
+ ) const override
{
// Destroy any leash knot tied to the fence:
auto leashKnot = cLeashKnot::FindKnotAtPos(a_WorldInterface, a_BlockPos);
diff --git a/src/Blocks/BlockFenceGate.h b/src/Blocks/BlockFenceGate.h
index bba308230..2f691790d 100644
--- a/src/Blocks/BlockFenceGate.h
+++ b/src/Blocks/BlockFenceGate.h
@@ -15,14 +15,9 @@ class cBlockFenceGateHandler :
public:
- cBlockFenceGateHandler(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
{
NIBBLETYPE OldMetaData = a_ChunkInterface.GetBlockMeta(a_BlockPos);
NIBBLETYPE NewMetaData = YawToMetaData(a_Player.GetYaw());
@@ -61,7 +56,7 @@ public:
cPlayer & a_Player,
const Vector3i a_BlockPos,
eBlockFace a_BlockFace
- ) override
+ ) const override
{
a_WorldInterface.SendBlockTo(a_BlockPos, a_Player);
}
@@ -70,7 +65,7 @@ public:
- virtual bool IsUseable(void) override
+ virtual bool IsUseable(void) const override
{
return true;
}
@@ -79,7 +74,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
switch (m_BlockType)
diff --git a/src/Blocks/BlockFire.h b/src/Blocks/BlockFire.h
index afc8ecf7a..eff29d03e 100644
--- a/src/Blocks/BlockFire.h
+++ b/src/Blocks/BlockFire.h
@@ -11,23 +11,23 @@ class cBlockFireHandler :
public cBlockHandler
{
public:
- cBlockFireHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType),
- XZP(0), XZM(0), Dir(0)
- {
- }
- /** Portal boundary and direction variables */
- // TODO: These need to be removed, BlockHandler instances are shared for all blocks in all worlds on the server
- // and are not supposed to have any data in them.
- int XZP, XZM;
- NIBBLETYPE Dir;
+ using cBlockHandler::cBlockHandler;
+
+private:
+
+ struct Scratch
+ {
+ /** Portal boundary and direction variables */
+ int XZP = 0, XZM = 0;
+ NIBBLETYPE Dir = 0;
+ };
- virtual void OnPlaced(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override
+ virtual void OnPlaced(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) const override
{
/*
PORTAL FINDING ALGORITH
@@ -42,15 +42,17 @@ public:
- Loop through boundary variables, and fill with portal blocks based on Dir with meta from Dir
*/
+ Scratch Scratch;
+
// a_BlockY - 1: Because we want the block below the fire
- FindAndSetPortalFrame(a_BlockPos.x, a_BlockPos.y - 1, a_BlockPos.z, a_ChunkInterface, a_WorldInterface);
+ FindAndSetPortalFrame(a_BlockPos.x, a_BlockPos.y - 1, a_BlockPos.z, a_ChunkInterface, a_WorldInterface, Scratch);
}
- 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 from this block
return {};
@@ -60,14 +62,14 @@ public:
- virtual bool IsClickedThrough(void) override
+ virtual bool IsClickedThrough(void) const override
{
return true;
}
/** Traces along YP until it finds an obsidian block, returns Y difference or 0 if no portal, and -1 for border
Takes the X, Y, and Z of the base block; with an optional MaxY for portal border finding */
- int FindObsidianCeiling(int X, int Y, int Z, cChunkInterface & a_ChunkInterface, int MaxY = 0)
+ static int FindObsidianCeiling(int X, int Y, int Z, cChunkInterface & a_ChunkInterface, int MaxY = 0)
{
if (a_ChunkInterface.GetBlock({X, Y, Z}) != E_BLOCK_OBSIDIAN)
{
@@ -102,7 +104,7 @@ public:
}
/** Evaluates if coords have a valid border on top, based on MaxY */
- bool EvaluatePortalBorder(int X, int FoundObsidianY, int Z, int MaxY, cChunkInterface & a_ChunkInterface)
+ static bool EvaluatePortalBorder(int X, int FoundObsidianY, int Z, int MaxY, cChunkInterface & a_ChunkInterface)
{
for (int checkBorder = FoundObsidianY + 1; checkBorder <= MaxY - 1; checkBorder++) // FoundObsidianY + 1: FoundObsidianY has already been checked in FindObsidianCeiling; MaxY - 1: portal doesn't need corners
{
@@ -121,7 +123,7 @@ public:
/** Finds entire frame in any direction with the coordinates of a base block and fills hole with nether portal (START HERE) */
- void FindAndSetPortalFrame(int X, int Y, int Z, cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface)
+ static void FindAndSetPortalFrame(int X, int Y, int Z, cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, Scratch & a_Scratch)
{
int MaxY = FindObsidianCeiling(X, Y, Z, a_ChunkInterface); // Get topmost obsidian block as reference for all other checks
int X1 = X + 1, Z1 = Z + 1, X2 = X - 1, Z2 = Z - 1; // Duplicate XZ values, add / subtract one as we've checked the original already the line above
@@ -131,16 +133,16 @@ public:
return;
}
- if (!FindPortalSliceX(X1, X2, Y, Z, MaxY, a_ChunkInterface))
+ if (!FindPortalSliceX(X1, X2, Y, Z, MaxY, a_ChunkInterface, a_Scratch))
{
- if (!FindPortalSliceZ(X, Y, Z1, Z2, MaxY, a_ChunkInterface))
+ if (!FindPortalSliceZ(X, Y, Z1, Z2, MaxY, a_ChunkInterface, a_Scratch))
{
return; // No eligible portal construct, abort abort abort!!
}
}
int PortalHeight = MaxY - Y - 1;
- int PortalWidth = XZP - XZM + 1;
+ int PortalWidth = a_Scratch.XZP - a_Scratch.XZM + 1;
if ((PortalHeight < a_WorldInterface.GetMinNetherPortalHeight()) || (PortalHeight > a_WorldInterface.GetMaxNetherPortalHeight()))
{
// The portal isn't high enough, or is too high
@@ -155,15 +157,15 @@ public:
for (int Height = Y + 1; Height <= MaxY - 1; Height++) // Loop through boundary to set portal blocks
{
- for (int Width = XZM; Width <= XZP; Width++)
+ for (int Width = a_Scratch.XZM; Width <= a_Scratch.XZP; Width++)
{
- if (Dir == 1)
+ if (a_Scratch.Dir == 1)
{
- a_ChunkInterface.SetBlock(Width, Height, Z, E_BLOCK_NETHER_PORTAL, Dir);
+ a_ChunkInterface.SetBlock(Width, Height, Z, E_BLOCK_NETHER_PORTAL, a_Scratch.Dir);
}
else
{
- a_ChunkInterface.SetBlock(X, Height, Width, E_BLOCK_NETHER_PORTAL, Dir);
+ a_ChunkInterface.SetBlock(X, Height, Width, E_BLOCK_NETHER_PORTAL, a_Scratch.Dir);
}
}
}
@@ -171,9 +173,9 @@ public:
/** Evaluates if coordinates are a portal going XP / XM; returns true if so, and writes boundaries to variable
Takes coordinates of base block and Y coord of target obsidian ceiling */
- bool FindPortalSliceX(int X1, int X2, int Y, int Z, int MaxY, cChunkInterface & a_ChunkInterface)
+ static bool FindPortalSliceX(int X1, int X2, int Y, int Z, int MaxY, cChunkInterface & a_ChunkInterface, Scratch & a_Scratch)
{
- Dir = 1; // Set assumed direction (will change if portal turns out to be facing the other direction)
+ a_Scratch.Dir = 1; // Set assumed direction (will change if portal turns out to be facing the other direction)
bool FoundFrameXP = false, FoundFrameXM = false;
for (; ((a_ChunkInterface.GetBlock({X1, Y, Z}) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock({X1, Y + 1, Z}) == E_BLOCK_OBSIDIAN)); X1++) // Check XP for obsidian blocks, exempting corners
{
@@ -189,7 +191,7 @@ public:
return false; // Not valid slice, no portal can be formed
}
}
- XZP = X1 - 1; // Set boundary of frame interior
+ a_Scratch.XZP = X1 - 1; // Set boundary of frame interior
for (; ((a_ChunkInterface.GetBlock({X2, Y, Z}) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock({X2, Y + 1, Z}) == E_BLOCK_OBSIDIAN)); X2--) // Go the other direction (XM)
{
int Value = FindObsidianCeiling(X2, Y, Z, a_ChunkInterface, MaxY);
@@ -204,15 +206,15 @@ public:
return false;
}
}
- XZM = X2 + 1; // Set boundary, see previous
+ a_Scratch.XZM = X2 + 1; // Set boundary, see previous
return (FoundFrameXP && FoundFrameXM);
}
/** Evaluates if coords are a portal going ZP / ZM; returns true if so, and writes boundaries to variable */
- bool FindPortalSliceZ(int X, int Y, int Z1, int Z2, int MaxY, cChunkInterface & a_ChunkInterface)
+ static bool FindPortalSliceZ(int X, int Y, int Z1, int Z2, int MaxY, cChunkInterface & a_ChunkInterface, Scratch & a_Scratch)
{
- Dir = 2;
+ a_Scratch.Dir = 2;
bool FoundFrameZP = false, FoundFrameZM = false;
for (; ((a_ChunkInterface.GetBlock({X, Y, Z1}) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock({X, Y + 1, Z1}) == E_BLOCK_OBSIDIAN)); Z1++)
{
@@ -228,7 +230,7 @@ public:
return false;
}
}
- XZP = Z1 - 1;
+ a_Scratch.XZP = Z1 - 1;
for (; ((a_ChunkInterface.GetBlock({X, Y, Z2}) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock({X, Y + 1, Z2}) == E_BLOCK_OBSIDIAN)); Z2--)
{
int Value = FindObsidianCeiling(X, Y, Z2, a_ChunkInterface, MaxY);
@@ -243,17 +245,17 @@ public:
return false;
}
}
- XZM = Z2 + 1;
+ a_Scratch.XZM = Z2 + 1;
return (FoundFrameZP && FoundFrameZM);
}
- virtual bool DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface, Vector3i a_Pos, cPlayer & a_Player, NIBBLETYPE a_Meta) override
+ virtual bool DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface, Vector3i a_Pos, cPlayer & a_Player, NIBBLETYPE a_Meta) const override
{
return true;
}
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 15;
diff --git a/src/Blocks/BlockFlower.h b/src/Blocks/BlockFlower.h
index 714ff9cab..527be7d5d 100644
--- a/src/Blocks/BlockFlower.h
+++ b/src/Blocks/BlockFlower.h
@@ -14,16 +14,11 @@ class cBlockFlowerHandler:
public:
- cBlockFlowerHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+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
{
NIBBLETYPE meta = a_BlockMeta & 0x7;
return cItem(m_BlockType, 1, meta);
@@ -33,7 +28,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
return ((a_RelPos.y > 0) && IsBlockTypeOfDirt(a_Chunk.GetBlock(a_RelPos.addedY(-1))));
}
@@ -42,7 +37,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 7;
diff --git a/src/Blocks/BlockFlowerPot.h b/src/Blocks/BlockFlowerPot.h
index 6d64eb5f8..d91347654 100644
--- a/src/Blocks/BlockFlowerPot.h
+++ b/src/Blocks/BlockFlowerPot.h
@@ -14,16 +14,11 @@ class cBlockFlowerPotHandler :
public:
- cBlockFlowerPotHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+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
{
return cItem(E_ITEM_FLOWER_POT, 1, 0);
}
@@ -32,7 +27,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 0;
diff --git a/src/Blocks/BlockFluid.h b/src/Blocks/BlockFluid.h
index 35b702f4b..b7510b9a9 100644
--- a/src/Blocks/BlockFluid.h
+++ b/src/Blocks/BlockFluid.h
@@ -14,17 +14,11 @@ class cBlockFluidHandler:
public:
- cBlockFluidHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
-
- }
-
-
-
+ using Super::Super;
+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
{
// No pickups
return {};
@@ -34,7 +28,7 @@ public:
- virtual bool DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface, Vector3i a_Pos, cPlayer & a_Player, NIBBLETYPE a_Meta) override
+ virtual bool DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface, Vector3i a_Pos, cPlayer & a_Player, NIBBLETYPE a_Meta) const override
{
return true;
}
@@ -43,7 +37,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
if (IsBlockWater(m_BlockType))
@@ -58,7 +52,7 @@ public:
- virtual bool CanSustainPlant(BLOCKTYPE a_Plant) override
+ virtual bool CanSustainPlant(BLOCKTYPE a_Plant) const override
{
return (
(a_Plant == E_BLOCK_BEETROOTS) ||
@@ -82,14 +76,9 @@ class cBlockLavaHandler:
public:
- cBlockLavaHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+private:
virtual void OnUpdate(
cChunkInterface & a_ChunkInterface,
@@ -97,7 +86,7 @@ public:
cBlockPluginInterface & a_PluginInterface,
cChunk & a_Chunk,
const Vector3i a_RelPos
- ) override
+ ) const override
{
if (a_Chunk.GetWorld()->ShouldLavaSpawnFire())
{
@@ -165,7 +154,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 4;
@@ -175,7 +164,7 @@ public:
- virtual bool CanSustainPlant(BLOCKTYPE a_Plant) override
+ virtual bool CanSustainPlant(BLOCKTYPE a_Plant) const override
{
return false;
}
diff --git a/src/Blocks/BlockFurnace.h b/src/Blocks/BlockFurnace.h
index b4efb6638..781843f5a 100644
--- a/src/Blocks/BlockFurnace.h
+++ b/src/Blocks/BlockFurnace.h
@@ -15,16 +15,11 @@ class cBlockFurnaceHandler :
public:
- cBlockFurnaceHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+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
{
cItems res(cItem(E_BLOCK_FURNACE, 1)); // We can't drop a lit furnace
if (a_BlockEntity != nullptr)
@@ -39,7 +34,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 11;
diff --git a/src/Blocks/BlockGlass.h b/src/Blocks/BlockGlass.h
index 8d082a2bf..5269402d4 100644
--- a/src/Blocks/BlockGlass.h
+++ b/src/Blocks/BlockGlass.h
@@ -11,16 +11,12 @@ class cBlockGlassHandler :
public cBlockHandler
{
public:
- cBlockGlassHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
+ using cBlockHandler::cBlockHandler;
+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
{
// Only drop self when mined with silk-touch:
if (ToolHasSilkTouch(a_Tool))
@@ -34,7 +30,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 0;
diff --git a/src/Blocks/BlockGlowstone.h b/src/Blocks/BlockGlowstone.h
index eddbf30d9..d43581a4d 100644
--- a/src/Blocks/BlockGlowstone.h
+++ b/src/Blocks/BlockGlowstone.h
@@ -11,16 +11,12 @@ class cBlockGlowstoneHandler :
public cBlockHandler
{
public:
- cBlockGlowstoneHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
+ using cBlockHandler::cBlockHandler;
+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
{
// Drop self only when using silk-touch:
if (ToolHasSilkTouch(a_Tool))
@@ -38,7 +34,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 2;
diff --git a/src/Blocks/BlockGrass.h b/src/Blocks/BlockGrass.h
index d91a6ef2e..65a3f5908 100644
--- a/src/Blocks/BlockGrass.h
+++ b/src/Blocks/BlockGrass.h
@@ -13,7 +13,11 @@
class cBlockGrassHandler :
public cBlockHandler
{
- using super = cBlockHandler;
+public:
+
+ using cBlockHandler::cBlockHandler;
+
+private:
enum class Survivability
{
@@ -27,18 +31,7 @@ class cBlockGrassHandler :
DieInDarkness
};
-public:
-
- cBlockGrassHandler(BLOCKTYPE a_BlockType):
- super(a_BlockType)
- {
- }
-
-
-
-
-
- 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
{
if (!ToolHasSilkTouch(a_Tool))
{
@@ -57,7 +50,7 @@ public:
cBlockPluginInterface & a_PluginInterface,
cChunk & a_Chunk,
const Vector3i a_RelPos
- ) override
+ ) const override
{
if (!a_Chunk.GetWorld()->IsChunkLighted(a_Chunk.GetPosX(), a_Chunk.GetPosZ()))
{
@@ -92,7 +85,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 1;
diff --git a/src/Blocks/BlockGravel.h b/src/Blocks/BlockGravel.h
index fe93dc96b..6e26c92ed 100644
--- a/src/Blocks/BlockGravel.h
+++ b/src/Blocks/BlockGravel.h
@@ -11,16 +11,12 @@ class cBlockGravelHandler :
public cBlockHandler
{
public:
- cBlockGravelHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
-
-
+ using cBlockHandler::cBlockHandler;
+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
{
// TODO: Handle the Fortune and Silk touch enchantments here
if (GetRandomProvider().RandBool(0.10))
@@ -37,7 +33,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 11;
diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp
index 20ba6edb5..67cef6cd5 100644
--- a/src/Blocks/BlockHandler.cpp
+++ b/src/Blocks/BlockHandler.cpp
@@ -189,260 +189,262 @@ public:
+/** Static list of all block handlers.
+Ensures that a handler can never be nullptr (FS #243) on invalid during restarts or other transition periods. */
namespace
{
- cBlockDoorHandler BlockAcaciaDoorHandler (E_BLOCK_ACACIA_DOOR);
- cBlockFenceGateHandler BlockAcaciaFenceGateHandler (E_BLOCK_ACACIA_FENCE_GATE);
- cBlockFenceHandler BlockAcaciaFenceHandler (E_BLOCK_ACACIA_FENCE);
- cBlockStairsHandler BlockAcaciaWoodStairsHandler (E_BLOCK_ACACIA_WOOD_STAIRS);
- cBlockRailHandler BlockActivatorRailHandler (E_BLOCK_ACTIVATOR_RAIL);
- cBlockComparatorHandler BlockActiveComparatorHandler (E_BLOCK_ACTIVE_COMPARATOR);
- cBlockWithNoDrops<> BlockAirHandler (E_BLOCK_AIR);
- cBlockAnvilHandler BlockAnvilHandler (E_BLOCK_ANVIL);
- cBlockHandler BlockBarrierHandler (E_BLOCK_BARRIER);
- cBlockEntityHandler BlockBeaconHandler (E_BLOCK_BEACON);
- cBlockBedHandler BlockBedHandler (E_BLOCK_BED);
- cBlockHandler BlockBedrockHandler (E_BLOCK_BEDROCK);
- cBlockCropsHandler<3> BlockBeetrootsHandler (E_BLOCK_BEETROOTS); // 4 stages of growth
- cBlockBigFlowerHandler BlockBigFlowerHandler (E_BLOCK_BIG_FLOWER);
- cBlockDoorHandler BlockBirchDoorHandler (E_BLOCK_BIRCH_DOOR);
- cBlockFenceGateHandler BlockBirchFenceGateHandler (E_BLOCK_BIRCH_FENCE_GATE);
- cBlockFenceHandler BlockBirchFenceHandler (E_BLOCK_BIRCH_FENCE);
- cBlockStairsHandler BlockBirchWoodStairsHandler (E_BLOCK_BIRCH_WOOD_STAIRS);
- cBlockGlazedTerracottaHandler BlockBlackGlazedTerracottaHandler (E_BLOCK_BLACK_GLAZED_TERRACOTTA);
- cBlockHandler BlockBlackShulkerBoxHandler (E_BLOCK_BLACK_SHULKER_BOX);
- cBlockHandler BlockBlockOfCoalHandler (E_BLOCK_BLOCK_OF_COAL);
- cBlockHandler BlockBlockOfRedstoneHandler (E_BLOCK_BLOCK_OF_REDSTONE);
- cBlockGlazedTerracottaHandler BlockBlueGlazedTerracottaHandler (E_BLOCK_BLUE_GLAZED_TERRACOTTA);
- cBlockHandler BlockBlueShulkerBoxHandler (E_BLOCK_BLUE_SHULKER_BOX);
- cBlockHandler BlockBoneBlockHandler (E_BLOCK_BONE_BLOCK);
- cBlockBookShelfHandler BlockBookcaseHandler (E_BLOCK_BOOKCASE);
- cBlockBrewingStandHandler BlockBrewingStandHandler (E_BLOCK_BREWING_STAND);
- cBlockHandler BlockBrickHandler (E_BLOCK_BRICK);
- cBlockStairsHandler BlockBrickStairsHandler (E_BLOCK_BRICK_STAIRS);
- cBlockGlazedTerracottaHandler BlockBrownGlazedTerracottaHandler (E_BLOCK_BROWN_GLAZED_TERRACOTTA);
- cBlockMushroomHandler BlockBrownMushroomHandler (E_BLOCK_BROWN_MUSHROOM);
- cBlockHandler BlockBrownShulkerBoxHandler (E_BLOCK_BROWN_SHULKER_BOX);
- cBlockCactusHandler BlockCactusHandler (E_BLOCK_CACTUS);
- cBlockCakeHandler BlockCakeHandler (E_BLOCK_CAKE);
- cBlockCarpetHandler BlockCarpetHandler (E_BLOCK_CARPET);
- cBlockCropsHandler<7> BlockCarrotsHandler (E_BLOCK_CARROTS); // 8 stages of growth
- cBlockCauldronHandler BlockCauldronHandler (E_BLOCK_CAULDRON);
- cBlockCommandBlockHandler BlockChainCommandBlockHandler (E_BLOCK_CHAIN_COMMAND_BLOCK);
- cBlockChestHandler BlockChestHandler (E_BLOCK_CHEST);
- cBlockHandler BlockChorusFlowerHandler (E_BLOCK_CHORUS_FLOWER);
- cBlockHandler BlockChorusPlantHandler (E_BLOCK_CHORUS_PLANT);
- cBlockOreHandler BlockClayHandler (E_BLOCK_CLAY);
- cBlockOreHandler BlockCoalOreHandler (E_BLOCK_COAL_ORE);
- cBlockStoneHandler BlockCobblestoneHandler (E_BLOCK_COBBLESTONE);
- cBlockStairsHandler BlockCobblestoneStairsHandler (E_BLOCK_COBBLESTONE_STAIRS);
- cBlockHandler BlockCobblestoneWallHandler (E_BLOCK_COBBLESTONE_WALL);
- cBlockCobWebHandler BlockCobwebHandler (E_BLOCK_COBWEB);
- cBlockCocoaPodHandler BlockCocoaPodHandler (E_BLOCK_COCOA_POD);
- cBlockCommandBlockHandler BlockCommandBlockHandler (E_BLOCK_COMMAND_BLOCK);
- cBlockHandler BlockConcreteHandler (E_BLOCK_CONCRETE);
- cBlockConcretePowderHandler BlockConcretePowderHandler (E_BLOCK_CONCRETE_POWDER);
- cBlockCropsHandler<7> BlockCropsHandler (E_BLOCK_CROPS); // 8 stages of growth
- cBlockGlazedTerracottaHandler BlockCyanGlazedTerracottaHandler (E_BLOCK_CYAN_GLAZED_TERRACOTTA);
- cBlockHandler BlockCyanShulkerBoxHandler (E_BLOCK_CYAN_SHULKER_BOX);
- cBlockDoorHandler BlockDarkOakDoorHandler (E_BLOCK_DARK_OAK_DOOR);
- cBlockFenceGateHandler BlockDarkOakFenceGateHandler (E_BLOCK_DARK_OAK_FENCE_GATE);
- cBlockFenceHandler BlockDarkOakFenceHandler (E_BLOCK_DARK_OAK_FENCE);
- cBlockStairsHandler BlockDarkOakWoodStairsHandler (E_BLOCK_DARK_OAK_WOOD_STAIRS);
- cBlockHandler BlockDaylightSensorHandler (E_BLOCK_DAYLIGHT_SENSOR);
- cBlockDeadBushHandler BlockDeadBushHandler (E_BLOCK_DEAD_BUSH);
- cBlockRailHandler BlockDetectorRailHandler (E_BLOCK_DETECTOR_RAIL);
- cBlockHandler BlockDiamondBlockHandler (E_BLOCK_DIAMOND_BLOCK);
- cBlockOreHandler BlockDiamondOreHandler (E_BLOCK_DIAMOND_ORE);
- cBlockDirtHandler BlockDirtHandler (E_BLOCK_DIRT);
- cBlockDropSpenserHandler BlockDispenserHandler (E_BLOCK_DISPENSER);
- cBlockDoubleSlabHandler BlockDoubleRedSandstoneSlabHandler(E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB);
- cBlockDoubleSlabHandler BlockDoubleStoneSlabHandler (E_BLOCK_DOUBLE_STONE_SLAB);
- cBlockDoubleSlabHandler BlockDoubleWoodenSlabHandler (E_BLOCK_DOUBLE_WOODEN_SLAB);
- cBlockHandler BlockDragonEggHandler (E_BLOCK_DRAGON_EGG);
- cBlockDropSpenserHandler BlockDropperHandler (E_BLOCK_DROPPER);
- cBlockHandler BlockEmeraldBlockHandler (E_BLOCK_EMERALD_BLOCK);
- cBlockOreHandler BlockEmeraldOreHandler (E_BLOCK_EMERALD_ORE);
- cBlockEnchantingTableHandler BlockEnchantingTableHandler (E_BLOCK_ENCHANTMENT_TABLE);
- cBlockHandler BlockEndBricksHandler (E_BLOCK_END_BRICKS);
- cBlockHandler BlockEndGatewayHandler (E_BLOCK_END_GATEWAY);
- cBlockEndPortalFrameHandler BlockEndPortalFrameHandler (E_BLOCK_END_PORTAL_FRAME);
- cBlockHandler BlockEndPortalHandler (E_BLOCK_END_PORTAL);
- cBlockHandler BlockEndRodHandler (E_BLOCK_END_ROD);
- cBlockHandler BlockEndStoneHandler (E_BLOCK_END_STONE);
- cBlockEnderchestHandler BlockEnderChestHandler (E_BLOCK_ENDER_CHEST);
- cBlockFarmlandHandler BlockFarmlandHandler (E_BLOCK_FARMLAND);
- cBlockFenceHandler BlockFenceHandler (E_BLOCK_FENCE);
- cBlockFireHandler BlockFireHandler (E_BLOCK_FIRE);
- cBlockFlowerPotHandler BlockFlowerPotHandler (E_BLOCK_FLOWER_POT);
- cBlockIceHandler BlockFrostedIceHandler (E_BLOCK_FROSTED_ICE);
- cBlockFurnaceHandler BlockFurnaceHandler (E_BLOCK_FURNACE);
- cBlockGlassHandler BlockGlassHandler (E_BLOCK_GLASS);
- cBlockGlassHandler BlockGlassPaneHandler (E_BLOCK_GLASS_PANE);
- cBlockGlowstoneHandler BlockGlowstoneHandler (E_BLOCK_GLOWSTONE);
- cBlockHandler BlockGoldBlockHandler (E_BLOCK_GOLD_BLOCK);
- cBlockOreHandler BlockGoldOreHandler (E_BLOCK_GOLD_ORE);
- cBlockGrassHandler BlockGrassHandler (E_BLOCK_GRASS);
- cBlockHandler BlockGrassPathHandler (E_BLOCK_GRASS_PATH);
- cBlockGravelHandler BlockGravelHandler (E_BLOCK_GRAVEL);
- cBlockGlazedTerracottaHandler BlockGrayGlazedTerracottaHandler (E_BLOCK_GRAY_GLAZED_TERRACOTTA);
- cBlockHandler BlockGrayShulkerBoxHandler (E_BLOCK_GRAY_SHULKER_BOX);
- cBlockGlazedTerracottaHandler BlockGreenGlazedTerracottaHandler (E_BLOCK_GREEN_GLAZED_TERRACOTTA);
- cBlockHandler BlockGreenShulkerBoxHandler (E_BLOCK_GREEN_SHULKER_BOX);
- cBlockHandler BlockHardenedClayHandler (E_BLOCK_HARDENED_CLAY);
- cBlockSidewaysHandler BlockHayBaleHandler (E_BLOCK_HAY_BALE);
- cBlockMobHeadHandler BlockHeadHandler (E_BLOCK_HEAD);
- cBlockPressurePlateHandler BlockHeavyWeightedPressurePHandler(E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE);
- cBlockHopperHandler BlockHopperHandler (E_BLOCK_HOPPER);
- cBlockHandler BlockHugeBrownMushroomHandler (E_BLOCK_HUGE_BROWN_MUSHROOM);
- cBlockHandler BlockHugeRedMushroomHandler (E_BLOCK_HUGE_RED_MUSHROOM);
- cBlockIceHandler BlockIceHandler (E_BLOCK_ICE);
- cBlockComparatorHandler BlockInactiveComparatorHandler (E_BLOCK_INACTIVE_COMPARATOR);
- cBlockHandler BlockInfestedBlockHandler (E_BLOCK_SILVERFISH_EGG);
- cBlockHandler BlockIronBarsHandler (E_BLOCK_IRON_BARS);
- cBlockHandler BlockIronBlockHandler (E_BLOCK_IRON_BLOCK);
- cBlockDoorHandler BlockIronDoorHandler (E_BLOCK_IRON_DOOR);
- cBlockOreHandler BlockIronOreHandler (E_BLOCK_IRON_ORE);
- cBlockTrapdoorHandler BlockIronTrapdoorHandler (E_BLOCK_IRON_TRAPDOOR);
- cBlockPumpkinHandler BlockJackOLanternHandler (E_BLOCK_JACK_O_LANTERN);
- cBlockJukeboxHandler BlockJukeboxHandler (E_BLOCK_JUKEBOX);
- cBlockDoorHandler BlockJungleDoorHandler (E_BLOCK_JUNGLE_DOOR);
- cBlockFenceGateHandler BlockJungleFenceGateHandler (E_BLOCK_JUNGLE_FENCE_GATE);
- cBlockFenceHandler BlockJungleFenceHandler (E_BLOCK_JUNGLE_FENCE);
- cBlockStairsHandler BlockJungleWoodStairsHandler (E_BLOCK_JUNGLE_WOOD_STAIRS);
- cBlockLadderHandler BlockLadderHandler (E_BLOCK_LADDER);
- cBlockHandler BlockLapisBlockHandler (E_BLOCK_LAPIS_BLOCK);
- cBlockOreHandler BlockLapisOreHandler (E_BLOCK_LAPIS_ORE);
- cBlockLavaHandler BlockLavaHandler (E_BLOCK_LAVA);
- cBlockLeavesHandler BlockLeavesHandler (E_BLOCK_LEAVES);
- cBlockLeverHandler BlockLeverHandler (E_BLOCK_LEVER);
- cBlockGlazedTerracottaHandler BlockLightBlueGlazedTerracoHandler(E_BLOCK_LIGHT_BLUE_GLAZED_TERRACOTTA);
- cBlockHandler BlockLightBlueShulkerBoxHandler (E_BLOCK_LIGHT_BLUE_SHULKER_BOX);
- cBlockGlazedTerracottaHandler BlockLightGrayGlazedTerracoHandler(E_BLOCK_LIGHT_GRAY_GLAZED_TERRACOTTA);
- cBlockHandler BlockLightGrayShulkerBoxHandler (E_BLOCK_LIGHT_GRAY_SHULKER_BOX);
- cBlockPressurePlateHandler BlockLightWeightedPressurePHandler(E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE);
- cBlockLilypadHandler BlockLilyPadHandler (E_BLOCK_LILY_PAD);
- cBlockGlazedTerracottaHandler BlockLimeGlazedTerracottaHandler (E_BLOCK_LIME_GLAZED_TERRACOTTA);
- cBlockHandler BlockLimeShulkerBoxHandler (E_BLOCK_LIME_SHULKER_BOX);
- cBlockFurnaceHandler BlockLitFurnaceHandler (E_BLOCK_LIT_FURNACE);
- cBlockSidewaysHandler BlockLogHandler (E_BLOCK_LOG);
- cBlockGlazedTerracottaHandler BlockMagentaGlazedTerracottHandler(E_BLOCK_MAGENTA_GLAZED_TERRACOTTA);
- cBlockHandler BlockMagentaShulkerBoxHandler (E_BLOCK_MAGENTA_SHULKER_BOX);
- cBlockHandler BlockMagmaHandler (E_BLOCK_MAGMA);
- cBlockMelonHandler BlockMelonHandler (E_BLOCK_MELON);
- cBlockMelonStemHandler BlockMelonStemHandler (E_BLOCK_MELON_STEM);
- cBlockMobSpawnerHandler BlockMobSpawnerHandler (E_BLOCK_MOB_SPAWNER);
- cBlockHandler BlockMossyCobblestoneHandler (E_BLOCK_MOSSY_COBBLESTONE);
- cBlockMyceliumHandler BlockMyceliumHandler (E_BLOCK_MYCELIUM);
- cBlockFenceHandler BlockNetherBrickFenceHandler (E_BLOCK_NETHER_BRICK_FENCE);
- cBlockHandler BlockNetherBrickHandler (E_BLOCK_NETHER_BRICK);
- cBlockStairsHandler BlockNetherBrickStairsHandler (E_BLOCK_NETHER_BRICK_STAIRS);
- cBlockPortalHandler BlockNetherPortalHandler (E_BLOCK_NETHER_PORTAL);
- cBlockOreHandler BlockNetherQuartzOreHandler (E_BLOCK_NETHER_QUARTZ_ORE);
- cBlockHandler BlockNetherWartBlockHandler (E_BLOCK_NETHER_WART_BLOCK);
- cBlockNetherWartHandler BlockNetherWartHandler (E_BLOCK_NETHER_WART);
- cBlockNetherrack BlockNetherrackHandler (E_BLOCK_NETHERRACK);
- cBlockLeavesHandler BlockNewLeavesHandler (E_BLOCK_NEW_LEAVES);
- cBlockSidewaysHandler BlockNewLogHandler (E_BLOCK_NEW_LOG);
- cBlockEntityHandler BlockNoteBlockHandler (E_BLOCK_NOTE_BLOCK);
- cBlockDoorHandler BlockOakDoorHandler (E_BLOCK_OAK_DOOR);
- cBlockFenceGateHandler BlockOakFenceGateHandler (E_BLOCK_OAK_FENCE_GATE);
- cBlockStairsHandler BlockOakWoodStairsHandler (E_BLOCK_OAK_WOOD_STAIRS);
- cBlockObserverHandler BlockObserverHandler (E_BLOCK_OBSERVER);
- cBlockHandler BlockObsidianHandler (E_BLOCK_OBSIDIAN);
- cBlockGlazedTerracottaHandler BlockOrangeGlazedTerracottaHandler(E_BLOCK_ORANGE_GLAZED_TERRACOTTA);
- cBlockHandler BlockOrangeShulkerBoxHandler (E_BLOCK_ORANGE_SHULKER_BOX);
- cBlockIceHandler BlockPackedIceHandler (E_BLOCK_PACKED_ICE);
- cBlockGlazedTerracottaHandler BlockPinkGlazedTerracottaHandler (E_BLOCK_PINK_GLAZED_TERRACOTTA);
- cBlockHandler BlockPinkShulkerBoxHandler (E_BLOCK_PINK_SHULKER_BOX);
- cBlockPistonHandler BlockPistonHandler (E_BLOCK_PISTON);
- cBlockPistonHeadHandler BlockPistonHeadHandler;
- cBlockHandler BlockPistonMovedBlockHandler (E_BLOCK_PISTON_MOVED_BLOCK);
- cBlockPlanksHandler BlockPlanksHandler (E_BLOCK_PLANKS);
- cBlockCropsHandler<7> BlockPotatoesHandler (E_BLOCK_POTATOES); // 8 stages of growth
- cBlockRailHandler BlockPoweredRailHandler (E_BLOCK_POWERED_RAIL);
- cBlockHandler BlockPrismarineBlockHandler (E_BLOCK_PRISMARINE_BLOCK);
- cBlockPumpkinHandler BlockPumpkinHandler (E_BLOCK_PUMPKIN);
- cBlockPumpkinStemHandler BlockPumpkinStemHandler (E_BLOCK_PUMPKIN_STEM);
- cBlockGlazedTerracottaHandler BlockPurpleGlazedTerracottaHandler(E_BLOCK_PURPLE_GLAZED_TERRACOTTA);
- cBlockHandler BlockPurpleShulkerBoxHandler (E_BLOCK_PURPLE_SHULKER_BOX);
- cBlockHandler BlockPurpurBlockHandler (E_BLOCK_PURPUR_BLOCK);
- cBlockDoubleSlabHandler BlockPurpurDoubleSlabHandler (E_BLOCK_PURPUR_DOUBLE_SLAB);
- cBlockHandler BlockPurpurPillarHandler (E_BLOCK_PURPUR_PILLAR);
- cBlockSlabHandler BlockPurpurSlabHandler (E_BLOCK_PURPUR_SLAB);
- cBlockStairsHandler BlockPurpurStairsHandler (E_BLOCK_PURPUR_STAIRS);
- cBlockQuartzHandler BlockQuartzBlockHandler (E_BLOCK_QUARTZ_BLOCK);
- cBlockStairsHandler BlockQuartzStairsHandler (E_BLOCK_QUARTZ_STAIRS);
- cBlockRailHandler BlockRailHandler (E_BLOCK_RAIL);
- cBlockGlazedTerracottaHandler BlockRedGlazedTerracottaHandler (E_BLOCK_RED_GLAZED_TERRACOTTA);
- cBlockMushroomHandler BlockRedMushroomHandler (E_BLOCK_RED_MUSHROOM);
- cBlockHandler BlockRedNetherBrickHandler (E_BLOCK_RED_NETHER_BRICK);
- cBlockFlowerHandler BlockRedRoseHandler (E_BLOCK_RED_ROSE);
- cBlockHandler BlockRedSandstoneHandler (E_BLOCK_RED_SANDSTONE);
- cBlockSlabHandler BlockRedSandstoneSlabHandler (E_BLOCK_RED_SANDSTONE_SLAB);
- cBlockStairsHandler BlockRedSandstoneStairsHandler (E_BLOCK_RED_SANDSTONE_STAIRS);
- cBlockHandler BlockRedShulkerBoxHandler (E_BLOCK_RED_SHULKER_BOX);
- cBlockRedstoneLampHandler BlockRedstoneLampHandler (E_BLOCK_REDSTONE_LAMP_ON);
- cBlockGlowingRedstoneOreHandler BlockRedstoneOreGlowingHandler (E_BLOCK_REDSTONE_ORE_GLOWING);
- cBlockRedstoneOreHandler BlockRedstoneOreHandler (E_BLOCK_REDSTONE_ORE);
- cBlockRedstoneRepeaterHandler BlockRedstoneRepeaterOffHandler (E_BLOCK_REDSTONE_REPEATER_OFF);
- cBlockRedstoneRepeaterHandler BlockRedstoneRepeaterOnHandler (E_BLOCK_REDSTONE_REPEATER_ON);
- cBlockRedstoneTorchHandler BlockRedstoneTorchOffHandler (E_BLOCK_REDSTONE_TORCH_OFF);
- cBlockRedstoneTorchHandler BlockRedstoneTorchOnHandler (E_BLOCK_REDSTONE_TORCH_ON);
- cBlockRedstoneHandler BlockRedstoneWireHandler (E_BLOCK_REDSTONE_WIRE);
- cBlockCommandBlockHandler BlockRepeatingCommandBlockHandler (E_BLOCK_REPEATING_COMMAND_BLOCK);
- cBlockSandHandler BlockSandHandler (E_BLOCK_SAND);
- cBlockHandler BlockSandstoneHandler (E_BLOCK_SANDSTONE);
- cBlockStairsHandler BlockSandstoneStairsHandler (E_BLOCK_SANDSTONE_STAIRS);
- cBlockSaplingHandler BlockSaplingHandler (E_BLOCK_SAPLING);
- cBlockSeaLanternHandler BlockSeaLanternHandler (E_BLOCK_SEA_LANTERN);
- cBlockSignPostHandler BlockSignPostHandler (E_BLOCK_SIGN_POST);
- cBlockSlimeHandler BlockSlimeBlockHandler (E_BLOCK_SLIME_BLOCK);
- cBlockHandler BlockSnowBlockHandler (E_BLOCK_SNOW_BLOCK);
- cBlockSnowHandler BlockSnowHandler (E_BLOCK_SNOW);
- cBlockHandler BlockSoulSandHandler (E_BLOCK_SOULSAND);
- cBlockSpongeHandler BlockSpongeHandler (E_BLOCK_SPONGE);
- cBlockDoorHandler BlockSpruceDoorHandler (E_BLOCK_SPRUCE_DOOR);
- cBlockFenceGateHandler BlockSpruceFenceGateHandler (E_BLOCK_SPRUCE_FENCE_GATE);
- cBlockFenceHandler BlockSpruceFenceHandler (E_BLOCK_SPRUCE_FENCE);
- cBlockStairsHandler BlockSpruceWoodStairsHandler (E_BLOCK_SPRUCE_WOOD_STAIRS);
- cBlockHandler BlockStainedClayHandler (E_BLOCK_STAINED_CLAY);
- cBlockGlassHandler BlockStainedGlassHandler (E_BLOCK_STAINED_GLASS);
- cBlockGlassHandler BlockStainedGlassPaneHandler (E_BLOCK_STAINED_GLASS_PANE);
- cBlockHandler BlockStandingBannerHandler (E_BLOCK_STANDING_BANNER); // TODO: drops correct?
- cBlockLavaHandler BlockStationaryLavaHandler (E_BLOCK_STATIONARY_LAVA);
- cBlockFluidHandler BlockStationaryWaterHandler (E_BLOCK_STATIONARY_WATER);
- cBlockPistonHandler BlockStickyPistonHandler (E_BLOCK_STICKY_PISTON);
- cBlockStairsHandler BlockStoneBrickStairsHandler (E_BLOCK_STONE_BRICK_STAIRS);
- cBlockHandler BlockStoneBricksHandler (E_BLOCK_STONE_BRICKS);
- cBlockButtonHandler BlockStoneButtonHandler (E_BLOCK_STONE_BUTTON);
- cBlockStoneHandler BlockStoneHandler (E_BLOCK_STONE);
- cBlockPressurePlateHandler BlockStonePressurePlateHandler (E_BLOCK_STONE_PRESSURE_PLATE);
- cBlockSlabHandler BlockStoneSlabHandler (E_BLOCK_STONE_SLAB);
- cBlockHandler BlockStructureBlockHandler (E_BLOCK_STRUCTURE_BLOCK);
- cBlockHandler BlockStructureVoidHandler (E_BLOCK_STRUCTURE_VOID);
- cBlockSugarcaneHandler BlockSugarcaneHandler (E_BLOCK_SUGARCANE);
- cBlockTallGrassHandler BlockTallGrassHandler (E_BLOCK_TALL_GRASS);
- cBlockTNTHandler BlockTntHandler (E_BLOCK_TNT);
- cBlockTorchHandler BlockTorchHandler (E_BLOCK_TORCH);
- cBlockTrapdoorHandler BlockTrapdoorHandler (E_BLOCK_TRAPDOOR);
- cBlockChestHandler BlockTrappedChestHandler (E_BLOCK_TRAPPED_CHEST);
- cBlockTripwireHandler BlockTripwireHandler (E_BLOCK_TRIPWIRE);
- cBlockTripwireHookHandler BlockTripwireHookHandler (E_BLOCK_TRIPWIRE_HOOK);
- cBlockVineHandler BlockVinesHandler (E_BLOCK_VINES);
- cBlockHandler BlockWallBannerHandler (E_BLOCK_WALL_BANNER); // TODO: drops correct?
- cBlockWallSignHandler BlockWallsignHandler (E_BLOCK_WALLSIGN);
- cBlockFluidHandler BlockWaterHandler (E_BLOCK_WATER);
- cBlockGlazedTerracottaHandler BlockWhiteGlazedTerracottaHandler (E_BLOCK_WHITE_GLAZED_TERRACOTTA);
- cBlockHandler BlockWhiteShulkerBoxHandler (E_BLOCK_WHITE_SHULKER_BOX);
- cBlockButtonHandler BlockWoodenButtonHandler (E_BLOCK_WOODEN_BUTTON);
- cBlockPressurePlateHandler BlockWoodenPressurePlateHandler (E_BLOCK_WOODEN_PRESSURE_PLATE);
- cBlockSlabHandler BlockWoodenSlabHandler (E_BLOCK_WOODEN_SLAB);
- cBlockClothHandler BlockWoolHandler (E_BLOCK_WOOL);
- cBlockWorkbenchHandler BlockWorkbenchHandler (E_BLOCK_WORKBENCH);
- cBlockFlowerHandler BlockYellowFlowerHandler (E_BLOCK_YELLOW_FLOWER);
- cBlockGlazedTerracottaHandler BlockYellowGlazedTerracottaHandler(E_BLOCK_YELLOW_GLAZED_TERRACOTTA);
- cBlockHandler BlockYellowShulkerBoxHandler (E_BLOCK_YELLOW_SHULKER_BOX);
+ constexpr cBlockDoorHandler BlockAcaciaDoorHandler (E_BLOCK_ACACIA_DOOR);
+ constexpr cBlockFenceGateHandler BlockAcaciaFenceGateHandler (E_BLOCK_ACACIA_FENCE_GATE);
+ constexpr cBlockFenceHandler BlockAcaciaFenceHandler (E_BLOCK_ACACIA_FENCE);
+ constexpr cBlockStairsHandler BlockAcaciaWoodStairsHandler (E_BLOCK_ACACIA_WOOD_STAIRS);
+ constexpr cBlockRailHandler BlockActivatorRailHandler (E_BLOCK_ACTIVATOR_RAIL);
+ constexpr cBlockComparatorHandler BlockActiveComparatorHandler (E_BLOCK_ACTIVE_COMPARATOR);
+ constexpr cBlockWithNoDrops<> BlockAirHandler (E_BLOCK_AIR);
+ constexpr cBlockAnvilHandler BlockAnvilHandler (E_BLOCK_ANVIL);
+ constexpr cBlockHandler BlockBarrierHandler (E_BLOCK_BARRIER);
+ constexpr cBlockEntityHandler BlockBeaconHandler (E_BLOCK_BEACON);
+ constexpr cBlockBedHandler BlockBedHandler (E_BLOCK_BED);
+ constexpr cBlockHandler BlockBedrockHandler (E_BLOCK_BEDROCK);
+ constexpr cBlockCropsHandler<3> BlockBeetrootsHandler (E_BLOCK_BEETROOTS); // 4 stages of growth
+ constexpr cBlockBigFlowerHandler BlockBigFlowerHandler (E_BLOCK_BIG_FLOWER);
+ constexpr cBlockDoorHandler BlockBirchDoorHandler (E_BLOCK_BIRCH_DOOR);
+ constexpr cBlockFenceGateHandler BlockBirchFenceGateHandler (E_BLOCK_BIRCH_FENCE_GATE);
+ constexpr cBlockFenceHandler BlockBirchFenceHandler (E_BLOCK_BIRCH_FENCE);
+ constexpr cBlockStairsHandler BlockBirchWoodStairsHandler (E_BLOCK_BIRCH_WOOD_STAIRS);
+ constexpr cBlockGlazedTerracottaHandler BlockBlackGlazedTerracottaHandler (E_BLOCK_BLACK_GLAZED_TERRACOTTA);
+ constexpr cBlockHandler BlockBlackShulkerBoxHandler (E_BLOCK_BLACK_SHULKER_BOX);
+ constexpr cBlockHandler BlockBlockOfCoalHandler (E_BLOCK_BLOCK_OF_COAL);
+ constexpr cBlockHandler BlockBlockOfRedstoneHandler (E_BLOCK_BLOCK_OF_REDSTONE);
+ constexpr cBlockGlazedTerracottaHandler BlockBlueGlazedTerracottaHandler (E_BLOCK_BLUE_GLAZED_TERRACOTTA);
+ constexpr cBlockHandler BlockBlueShulkerBoxHandler (E_BLOCK_BLUE_SHULKER_BOX);
+ constexpr cBlockHandler BlockBoneBlockHandler (E_BLOCK_BONE_BLOCK);
+ constexpr cBlockBookShelfHandler BlockBookcaseHandler (E_BLOCK_BOOKCASE);
+ constexpr cBlockBrewingStandHandler BlockBrewingStandHandler (E_BLOCK_BREWING_STAND);
+ constexpr cBlockHandler BlockBrickHandler (E_BLOCK_BRICK);
+ constexpr cBlockStairsHandler BlockBrickStairsHandler (E_BLOCK_BRICK_STAIRS);
+ constexpr cBlockGlazedTerracottaHandler BlockBrownGlazedTerracottaHandler (E_BLOCK_BROWN_GLAZED_TERRACOTTA);
+ constexpr cBlockMushroomHandler BlockBrownMushroomHandler (E_BLOCK_BROWN_MUSHROOM);
+ constexpr cBlockHandler BlockBrownShulkerBoxHandler (E_BLOCK_BROWN_SHULKER_BOX);
+ constexpr cBlockCactusHandler BlockCactusHandler (E_BLOCK_CACTUS);
+ constexpr cBlockCakeHandler BlockCakeHandler (E_BLOCK_CAKE);
+ constexpr cBlockCarpetHandler BlockCarpetHandler (E_BLOCK_CARPET);
+ constexpr cBlockCropsHandler<7> BlockCarrotsHandler (E_BLOCK_CARROTS); // 8 stages of growth
+ constexpr cBlockCauldronHandler BlockCauldronHandler (E_BLOCK_CAULDRON);
+ constexpr cBlockCommandBlockHandler BlockChainCommandBlockHandler (E_BLOCK_CHAIN_COMMAND_BLOCK);
+ constexpr cBlockChestHandler BlockChestHandler (E_BLOCK_CHEST);
+ constexpr cBlockHandler BlockChorusFlowerHandler (E_BLOCK_CHORUS_FLOWER);
+ constexpr cBlockHandler BlockChorusPlantHandler (E_BLOCK_CHORUS_PLANT);
+ constexpr cBlockOreHandler BlockClayHandler (E_BLOCK_CLAY);
+ constexpr cBlockOreHandler BlockCoalOreHandler (E_BLOCK_COAL_ORE);
+ constexpr cBlockStoneHandler BlockCobblestoneHandler (E_BLOCK_COBBLESTONE);
+ constexpr cBlockStairsHandler BlockCobblestoneStairsHandler (E_BLOCK_COBBLESTONE_STAIRS);
+ constexpr cBlockHandler BlockCobblestoneWallHandler (E_BLOCK_COBBLESTONE_WALL);
+ constexpr cBlockCobWebHandler BlockCobwebHandler (E_BLOCK_COBWEB);
+ constexpr cBlockCocoaPodHandler BlockCocoaPodHandler (E_BLOCK_COCOA_POD);
+ constexpr cBlockCommandBlockHandler BlockCommandBlockHandler (E_BLOCK_COMMAND_BLOCK);
+ constexpr cBlockHandler BlockConcreteHandler (E_BLOCK_CONCRETE);
+ constexpr cBlockConcretePowderHandler BlockConcretePowderHandler (E_BLOCK_CONCRETE_POWDER);
+ constexpr cBlockCropsHandler<7> BlockCropsHandler (E_BLOCK_CROPS); // 8 stages of growth
+ constexpr cBlockGlazedTerracottaHandler BlockCyanGlazedTerracottaHandler (E_BLOCK_CYAN_GLAZED_TERRACOTTA);
+ constexpr cBlockHandler BlockCyanShulkerBoxHandler (E_BLOCK_CYAN_SHULKER_BOX);
+ constexpr cBlockDoorHandler BlockDarkOakDoorHandler (E_BLOCK_DARK_OAK_DOOR);
+ constexpr cBlockFenceGateHandler BlockDarkOakFenceGateHandler (E_BLOCK_DARK_OAK_FENCE_GATE);
+ constexpr cBlockFenceHandler BlockDarkOakFenceHandler (E_BLOCK_DARK_OAK_FENCE);
+ constexpr cBlockStairsHandler BlockDarkOakWoodStairsHandler (E_BLOCK_DARK_OAK_WOOD_STAIRS);
+ constexpr cBlockHandler BlockDaylightSensorHandler (E_BLOCK_DAYLIGHT_SENSOR);
+ constexpr cBlockDeadBushHandler BlockDeadBushHandler (E_BLOCK_DEAD_BUSH);
+ constexpr cBlockRailHandler BlockDetectorRailHandler (E_BLOCK_DETECTOR_RAIL);
+ constexpr cBlockHandler BlockDiamondBlockHandler (E_BLOCK_DIAMOND_BLOCK);
+ constexpr cBlockOreHandler BlockDiamondOreHandler (E_BLOCK_DIAMOND_ORE);
+ constexpr cBlockDirtHandler BlockDirtHandler (E_BLOCK_DIRT);
+ constexpr cBlockDropSpenserHandler BlockDispenserHandler (E_BLOCK_DISPENSER);
+ constexpr cBlockDoubleSlabHandler BlockDoubleRedSandstoneSlabHandler(E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB);
+ constexpr cBlockDoubleSlabHandler BlockDoubleStoneSlabHandler (E_BLOCK_DOUBLE_STONE_SLAB);
+ constexpr cBlockDoubleSlabHandler BlockDoubleWoodenSlabHandler (E_BLOCK_DOUBLE_WOODEN_SLAB);
+ constexpr cBlockHandler BlockDragonEggHandler (E_BLOCK_DRAGON_EGG);
+ constexpr cBlockDropSpenserHandler BlockDropperHandler (E_BLOCK_DROPPER);
+ constexpr cBlockHandler BlockEmeraldBlockHandler (E_BLOCK_EMERALD_BLOCK);
+ constexpr cBlockOreHandler BlockEmeraldOreHandler (E_BLOCK_EMERALD_ORE);
+ constexpr cBlockEnchantingTableHandler BlockEnchantingTableHandler (E_BLOCK_ENCHANTMENT_TABLE);
+ constexpr cBlockHandler BlockEndBricksHandler (E_BLOCK_END_BRICKS);
+ constexpr cBlockHandler BlockEndGatewayHandler (E_BLOCK_END_GATEWAY);
+ constexpr cBlockEndPortalFrameHandler BlockEndPortalFrameHandler (E_BLOCK_END_PORTAL_FRAME);
+ constexpr cBlockHandler BlockEndPortalHandler (E_BLOCK_END_PORTAL);
+ constexpr cBlockHandler BlockEndRodHandler (E_BLOCK_END_ROD);
+ constexpr cBlockHandler BlockEndStoneHandler (E_BLOCK_END_STONE);
+ constexpr cBlockEnderchestHandler BlockEnderChestHandler (E_BLOCK_ENDER_CHEST);
+ constexpr cBlockFarmlandHandler BlockFarmlandHandler (E_BLOCK_FARMLAND);
+ constexpr cBlockFenceHandler BlockFenceHandler (E_BLOCK_FENCE);
+ constexpr cBlockFireHandler BlockFireHandler (E_BLOCK_FIRE);
+ constexpr cBlockFlowerPotHandler BlockFlowerPotHandler (E_BLOCK_FLOWER_POT);
+ constexpr cBlockIceHandler BlockFrostedIceHandler (E_BLOCK_FROSTED_ICE);
+ constexpr cBlockFurnaceHandler BlockFurnaceHandler (E_BLOCK_FURNACE);
+ constexpr cBlockGlassHandler BlockGlassHandler (E_BLOCK_GLASS);
+ constexpr cBlockGlassHandler BlockGlassPaneHandler (E_BLOCK_GLASS_PANE);
+ constexpr cBlockGlowstoneHandler BlockGlowstoneHandler (E_BLOCK_GLOWSTONE);
+ constexpr cBlockHandler BlockGoldBlockHandler (E_BLOCK_GOLD_BLOCK);
+ constexpr cBlockOreHandler BlockGoldOreHandler (E_BLOCK_GOLD_ORE);
+ constexpr cBlockGrassHandler BlockGrassHandler (E_BLOCK_GRASS);
+ constexpr cBlockHandler BlockGrassPathHandler (E_BLOCK_GRASS_PATH);
+ constexpr cBlockGravelHandler BlockGravelHandler (E_BLOCK_GRAVEL);
+ constexpr cBlockGlazedTerracottaHandler BlockGrayGlazedTerracottaHandler (E_BLOCK_GRAY_GLAZED_TERRACOTTA);
+ constexpr cBlockHandler BlockGrayShulkerBoxHandler (E_BLOCK_GRAY_SHULKER_BOX);
+ constexpr cBlockGlazedTerracottaHandler BlockGreenGlazedTerracottaHandler (E_BLOCK_GREEN_GLAZED_TERRACOTTA);
+ constexpr cBlockHandler BlockGreenShulkerBoxHandler (E_BLOCK_GREEN_SHULKER_BOX);
+ constexpr cBlockHandler BlockHardenedClayHandler (E_BLOCK_HARDENED_CLAY);
+ constexpr cBlockSidewaysHandler BlockHayBaleHandler (E_BLOCK_HAY_BALE);
+ constexpr cBlockMobHeadHandler BlockHeadHandler (E_BLOCK_HEAD);
+ constexpr cBlockPressurePlateHandler BlockHeavyWeightedPressurePHandler(E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE);
+ constexpr cBlockHopperHandler BlockHopperHandler (E_BLOCK_HOPPER);
+ constexpr cBlockHandler BlockHugeBrownMushroomHandler (E_BLOCK_HUGE_BROWN_MUSHROOM);
+ constexpr cBlockHandler BlockHugeRedMushroomHandler (E_BLOCK_HUGE_RED_MUSHROOM);
+ constexpr cBlockIceHandler BlockIceHandler (E_BLOCK_ICE);
+ constexpr cBlockComparatorHandler BlockInactiveComparatorHandler (E_BLOCK_INACTIVE_COMPARATOR);
+ constexpr cBlockHandler BlockInfestedBlockHandler (E_BLOCK_SILVERFISH_EGG);
+ constexpr cBlockHandler BlockIronBarsHandler (E_BLOCK_IRON_BARS);
+ constexpr cBlockHandler BlockIronBlockHandler (E_BLOCK_IRON_BLOCK);
+ constexpr cBlockDoorHandler BlockIronDoorHandler (E_BLOCK_IRON_DOOR);
+ constexpr cBlockOreHandler BlockIronOreHandler (E_BLOCK_IRON_ORE);
+ constexpr cBlockTrapdoorHandler BlockIronTrapdoorHandler (E_BLOCK_IRON_TRAPDOOR);
+ constexpr cBlockPumpkinHandler BlockJackOLanternHandler (E_BLOCK_JACK_O_LANTERN);
+ constexpr cBlockJukeboxHandler BlockJukeboxHandler (E_BLOCK_JUKEBOX);
+ constexpr cBlockDoorHandler BlockJungleDoorHandler (E_BLOCK_JUNGLE_DOOR);
+ constexpr cBlockFenceGateHandler BlockJungleFenceGateHandler (E_BLOCK_JUNGLE_FENCE_GATE);
+ constexpr cBlockFenceHandler BlockJungleFenceHandler (E_BLOCK_JUNGLE_FENCE);
+ constexpr cBlockStairsHandler BlockJungleWoodStairsHandler (E_BLOCK_JUNGLE_WOOD_STAIRS);
+ constexpr cBlockLadderHandler BlockLadderHandler (E_BLOCK_LADDER);
+ constexpr cBlockHandler BlockLapisBlockHandler (E_BLOCK_LAPIS_BLOCK);
+ constexpr cBlockOreHandler BlockLapisOreHandler (E_BLOCK_LAPIS_ORE);
+ constexpr cBlockLavaHandler BlockLavaHandler (E_BLOCK_LAVA);
+ constexpr cBlockLeavesHandler BlockLeavesHandler (E_BLOCK_LEAVES);
+ constexpr cBlockLeverHandler BlockLeverHandler (E_BLOCK_LEVER);
+ constexpr cBlockGlazedTerracottaHandler BlockLightBlueGlazedTerracoHandler(E_BLOCK_LIGHT_BLUE_GLAZED_TERRACOTTA);
+ constexpr cBlockHandler BlockLightBlueShulkerBoxHandler (E_BLOCK_LIGHT_BLUE_SHULKER_BOX);
+ constexpr cBlockGlazedTerracottaHandler BlockLightGrayGlazedTerracoHandler(E_BLOCK_LIGHT_GRAY_GLAZED_TERRACOTTA);
+ constexpr cBlockHandler BlockLightGrayShulkerBoxHandler (E_BLOCK_LIGHT_GRAY_SHULKER_BOX);
+ constexpr cBlockPressurePlateHandler BlockLightWeightedPressurePHandler(E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE);
+ constexpr cBlockLilypadHandler BlockLilyPadHandler (E_BLOCK_LILY_PAD);
+ constexpr cBlockGlazedTerracottaHandler BlockLimeGlazedTerracottaHandler (E_BLOCK_LIME_GLAZED_TERRACOTTA);
+ constexpr cBlockHandler BlockLimeShulkerBoxHandler (E_BLOCK_LIME_SHULKER_BOX);
+ constexpr cBlockFurnaceHandler BlockLitFurnaceHandler (E_BLOCK_LIT_FURNACE);
+ constexpr cBlockSidewaysHandler BlockLogHandler (E_BLOCK_LOG);
+ constexpr cBlockGlazedTerracottaHandler BlockMagentaGlazedTerracottHandler(E_BLOCK_MAGENTA_GLAZED_TERRACOTTA);
+ constexpr cBlockHandler BlockMagentaShulkerBoxHandler (E_BLOCK_MAGENTA_SHULKER_BOX);
+ constexpr cBlockHandler BlockMagmaHandler (E_BLOCK_MAGMA);
+ constexpr cBlockMelonHandler BlockMelonHandler (E_BLOCK_MELON);
+ constexpr cBlockMelonStemHandler BlockMelonStemHandler (E_BLOCK_MELON_STEM);
+ constexpr cBlockMobSpawnerHandler BlockMobSpawnerHandler (E_BLOCK_MOB_SPAWNER);
+ constexpr cBlockHandler BlockMossyCobblestoneHandler (E_BLOCK_MOSSY_COBBLESTONE);
+ constexpr cBlockMyceliumHandler BlockMyceliumHandler (E_BLOCK_MYCELIUM);
+ constexpr cBlockFenceHandler BlockNetherBrickFenceHandler (E_BLOCK_NETHER_BRICK_FENCE);
+ constexpr cBlockHandler BlockNetherBrickHandler (E_BLOCK_NETHER_BRICK);
+ constexpr cBlockStairsHandler BlockNetherBrickStairsHandler (E_BLOCK_NETHER_BRICK_STAIRS);
+ constexpr cBlockPortalHandler BlockNetherPortalHandler (E_BLOCK_NETHER_PORTAL);
+ constexpr cBlockOreHandler BlockNetherQuartzOreHandler (E_BLOCK_NETHER_QUARTZ_ORE);
+ constexpr cBlockHandler BlockNetherWartBlockHandler (E_BLOCK_NETHER_WART_BLOCK);
+ constexpr cBlockNetherWartHandler BlockNetherWartHandler (E_BLOCK_NETHER_WART);
+ constexpr cBlockNetherrack BlockNetherrackHandler (E_BLOCK_NETHERRACK);
+ constexpr cBlockLeavesHandler BlockNewLeavesHandler (E_BLOCK_NEW_LEAVES);
+ constexpr cBlockSidewaysHandler BlockNewLogHandler (E_BLOCK_NEW_LOG);
+ constexpr cBlockEntityHandler BlockNoteBlockHandler (E_BLOCK_NOTE_BLOCK);
+ constexpr cBlockDoorHandler BlockOakDoorHandler (E_BLOCK_OAK_DOOR);
+ constexpr cBlockFenceGateHandler BlockOakFenceGateHandler (E_BLOCK_OAK_FENCE_GATE);
+ constexpr cBlockStairsHandler BlockOakWoodStairsHandler (E_BLOCK_OAK_WOOD_STAIRS);
+ constexpr cBlockObserverHandler BlockObserverHandler (E_BLOCK_OBSERVER);
+ constexpr cBlockHandler BlockObsidianHandler (E_BLOCK_OBSIDIAN);
+ constexpr cBlockGlazedTerracottaHandler BlockOrangeGlazedTerracottaHandler(E_BLOCK_ORANGE_GLAZED_TERRACOTTA);
+ constexpr cBlockHandler BlockOrangeShulkerBoxHandler (E_BLOCK_ORANGE_SHULKER_BOX);
+ constexpr cBlockIceHandler BlockPackedIceHandler (E_BLOCK_PACKED_ICE);
+ constexpr cBlockGlazedTerracottaHandler BlockPinkGlazedTerracottaHandler (E_BLOCK_PINK_GLAZED_TERRACOTTA);
+ constexpr cBlockHandler BlockPinkShulkerBoxHandler (E_BLOCK_PINK_SHULKER_BOX);
+ constexpr cBlockPistonHandler BlockPistonHandler (E_BLOCK_PISTON);
+ constexpr cBlockPistonHeadHandler BlockPistonHeadHandler;
+ constexpr cBlockHandler BlockPistonMovedBlockHandler (E_BLOCK_PISTON_MOVED_BLOCK);
+ constexpr cBlockPlanksHandler BlockPlanksHandler (E_BLOCK_PLANKS);
+ constexpr cBlockCropsHandler<7> BlockPotatoesHandler (E_BLOCK_POTATOES); // 8 stages of growth
+ constexpr cBlockRailHandler BlockPoweredRailHandler (E_BLOCK_POWERED_RAIL);
+ constexpr cBlockHandler BlockPrismarineBlockHandler (E_BLOCK_PRISMARINE_BLOCK);
+ constexpr cBlockPumpkinHandler BlockPumpkinHandler (E_BLOCK_PUMPKIN);
+ constexpr cBlockPumpkinStemHandler BlockPumpkinStemHandler (E_BLOCK_PUMPKIN_STEM);
+ constexpr cBlockGlazedTerracottaHandler BlockPurpleGlazedTerracottaHandler(E_BLOCK_PURPLE_GLAZED_TERRACOTTA);
+ constexpr cBlockHandler BlockPurpleShulkerBoxHandler (E_BLOCK_PURPLE_SHULKER_BOX);
+ constexpr cBlockHandler BlockPurpurBlockHandler (E_BLOCK_PURPUR_BLOCK);
+ constexpr cBlockDoubleSlabHandler BlockPurpurDoubleSlabHandler (E_BLOCK_PURPUR_DOUBLE_SLAB);
+ constexpr cBlockHandler BlockPurpurPillarHandler (E_BLOCK_PURPUR_PILLAR);
+ constexpr cBlockSlabHandler BlockPurpurSlabHandler (E_BLOCK_PURPUR_SLAB);
+ constexpr cBlockStairsHandler BlockPurpurStairsHandler (E_BLOCK_PURPUR_STAIRS);
+ constexpr cBlockQuartzHandler BlockQuartzBlockHandler (E_BLOCK_QUARTZ_BLOCK);
+ constexpr cBlockStairsHandler BlockQuartzStairsHandler (E_BLOCK_QUARTZ_STAIRS);
+ constexpr cBlockRailHandler BlockRailHandler (E_BLOCK_RAIL);
+ constexpr cBlockGlazedTerracottaHandler BlockRedGlazedTerracottaHandler (E_BLOCK_RED_GLAZED_TERRACOTTA);
+ constexpr cBlockMushroomHandler BlockRedMushroomHandler (E_BLOCK_RED_MUSHROOM);
+ constexpr cBlockHandler BlockRedNetherBrickHandler (E_BLOCK_RED_NETHER_BRICK);
+ constexpr cBlockFlowerHandler BlockRedRoseHandler (E_BLOCK_RED_ROSE);
+ constexpr cBlockHandler BlockRedSandstoneHandler (E_BLOCK_RED_SANDSTONE);
+ constexpr cBlockSlabHandler BlockRedSandstoneSlabHandler (E_BLOCK_RED_SANDSTONE_SLAB);
+ constexpr cBlockStairsHandler BlockRedSandstoneStairsHandler (E_BLOCK_RED_SANDSTONE_STAIRS);
+ constexpr cBlockHandler BlockRedShulkerBoxHandler (E_BLOCK_RED_SHULKER_BOX);
+ constexpr cBlockRedstoneLampHandler BlockRedstoneLampHandler (E_BLOCK_REDSTONE_LAMP_ON);
+ constexpr cBlockGlowingRedstoneOreHandler BlockRedstoneOreGlowingHandler (E_BLOCK_REDSTONE_ORE_GLOWING);
+ constexpr cBlockRedstoneOreHandler BlockRedstoneOreHandler (E_BLOCK_REDSTONE_ORE);
+ constexpr cBlockRedstoneRepeaterHandler BlockRedstoneRepeaterOffHandler (E_BLOCK_REDSTONE_REPEATER_OFF);
+ constexpr cBlockRedstoneRepeaterHandler BlockRedstoneRepeaterOnHandler (E_BLOCK_REDSTONE_REPEATER_ON);
+ constexpr cBlockRedstoneTorchHandler BlockRedstoneTorchOffHandler (E_BLOCK_REDSTONE_TORCH_OFF);
+ constexpr cBlockRedstoneTorchHandler BlockRedstoneTorchOnHandler (E_BLOCK_REDSTONE_TORCH_ON);
+ constexpr cBlockRedstoneHandler BlockRedstoneWireHandler (E_BLOCK_REDSTONE_WIRE);
+ constexpr cBlockCommandBlockHandler BlockRepeatingCommandBlockHandler (E_BLOCK_REPEATING_COMMAND_BLOCK);
+ constexpr cBlockSandHandler BlockSandHandler (E_BLOCK_SAND);
+ constexpr cBlockHandler BlockSandstoneHandler (E_BLOCK_SANDSTONE);
+ constexpr cBlockStairsHandler BlockSandstoneStairsHandler (E_BLOCK_SANDSTONE_STAIRS);
+ constexpr cBlockSaplingHandler BlockSaplingHandler (E_BLOCK_SAPLING);
+ constexpr cBlockSeaLanternHandler BlockSeaLanternHandler (E_BLOCK_SEA_LANTERN);
+ constexpr cBlockSignPostHandler BlockSignPostHandler (E_BLOCK_SIGN_POST);
+ constexpr cBlockSlimeHandler BlockSlimeBlockHandler (E_BLOCK_SLIME_BLOCK);
+ constexpr cBlockHandler BlockSnowBlockHandler (E_BLOCK_SNOW_BLOCK);
+ constexpr cBlockSnowHandler BlockSnowHandler (E_BLOCK_SNOW);
+ constexpr cBlockHandler BlockSoulSandHandler (E_BLOCK_SOULSAND);
+ constexpr cBlockSpongeHandler BlockSpongeHandler (E_BLOCK_SPONGE);
+ constexpr cBlockDoorHandler BlockSpruceDoorHandler (E_BLOCK_SPRUCE_DOOR);
+ constexpr cBlockFenceGateHandler BlockSpruceFenceGateHandler (E_BLOCK_SPRUCE_FENCE_GATE);
+ constexpr cBlockFenceHandler BlockSpruceFenceHandler (E_BLOCK_SPRUCE_FENCE);
+ constexpr cBlockStairsHandler BlockSpruceWoodStairsHandler (E_BLOCK_SPRUCE_WOOD_STAIRS);
+ constexpr cBlockHandler BlockStainedClayHandler (E_BLOCK_STAINED_CLAY);
+ constexpr cBlockGlassHandler BlockStainedGlassHandler (E_BLOCK_STAINED_GLASS);
+ constexpr cBlockGlassHandler BlockStainedGlassPaneHandler (E_BLOCK_STAINED_GLASS_PANE);
+ constexpr cBlockHandler BlockStandingBannerHandler (E_BLOCK_STANDING_BANNER); // TODO: drops correct?
+ constexpr cBlockLavaHandler BlockStationaryLavaHandler (E_BLOCK_STATIONARY_LAVA);
+ constexpr cBlockFluidHandler BlockStationaryWaterHandler (E_BLOCK_STATIONARY_WATER);
+ constexpr cBlockPistonHandler BlockStickyPistonHandler (E_BLOCK_STICKY_PISTON);
+ constexpr cBlockStairsHandler BlockStoneBrickStairsHandler (E_BLOCK_STONE_BRICK_STAIRS);
+ constexpr cBlockHandler BlockStoneBricksHandler (E_BLOCK_STONE_BRICKS);
+ constexpr cBlockButtonHandler BlockStoneButtonHandler (E_BLOCK_STONE_BUTTON);
+ constexpr cBlockStoneHandler BlockStoneHandler (E_BLOCK_STONE);
+ constexpr cBlockPressurePlateHandler BlockStonePressurePlateHandler (E_BLOCK_STONE_PRESSURE_PLATE);
+ constexpr cBlockSlabHandler BlockStoneSlabHandler (E_BLOCK_STONE_SLAB);
+ constexpr cBlockHandler BlockStructureBlockHandler (E_BLOCK_STRUCTURE_BLOCK);
+ constexpr cBlockHandler BlockStructureVoidHandler (E_BLOCK_STRUCTURE_VOID);
+ constexpr cBlockSugarcaneHandler BlockSugarcaneHandler (E_BLOCK_SUGARCANE);
+ constexpr cBlockTallGrassHandler BlockTallGrassHandler (E_BLOCK_TALL_GRASS);
+ constexpr cBlockTNTHandler BlockTntHandler (E_BLOCK_TNT);
+ constexpr cBlockTorchHandler BlockTorchHandler (E_BLOCK_TORCH);
+ constexpr cBlockTrapdoorHandler BlockTrapdoorHandler (E_BLOCK_TRAPDOOR);
+ constexpr cBlockChestHandler BlockTrappedChestHandler (E_BLOCK_TRAPPED_CHEST);
+ constexpr cBlockTripwireHandler BlockTripwireHandler (E_BLOCK_TRIPWIRE);
+ constexpr cBlockTripwireHookHandler BlockTripwireHookHandler (E_BLOCK_TRIPWIRE_HOOK);
+ constexpr cBlockVineHandler BlockVinesHandler (E_BLOCK_VINES);
+ constexpr cBlockHandler BlockWallBannerHandler (E_BLOCK_WALL_BANNER); // TODO: drops correct?
+ constexpr cBlockWallSignHandler BlockWallsignHandler (E_BLOCK_WALLSIGN);
+ constexpr cBlockFluidHandler BlockWaterHandler (E_BLOCK_WATER);
+ constexpr cBlockGlazedTerracottaHandler BlockWhiteGlazedTerracottaHandler (E_BLOCK_WHITE_GLAZED_TERRACOTTA);
+ constexpr cBlockHandler BlockWhiteShulkerBoxHandler (E_BLOCK_WHITE_SHULKER_BOX);
+ constexpr cBlockButtonHandler BlockWoodenButtonHandler (E_BLOCK_WOODEN_BUTTON);
+ constexpr cBlockPressurePlateHandler BlockWoodenPressurePlateHandler (E_BLOCK_WOODEN_PRESSURE_PLATE);
+ constexpr cBlockSlabHandler BlockWoodenSlabHandler (E_BLOCK_WOODEN_SLAB);
+ constexpr cBlockClothHandler BlockWoolHandler (E_BLOCK_WOOL);
+ constexpr cBlockWorkbenchHandler BlockWorkbenchHandler (E_BLOCK_WORKBENCH);
+ constexpr cBlockFlowerHandler BlockYellowFlowerHandler (E_BLOCK_YELLOW_FLOWER);
+ constexpr cBlockGlazedTerracottaHandler BlockYellowGlazedTerracottaHandler(E_BLOCK_YELLOW_GLAZED_TERRACOTTA);
+ constexpr cBlockHandler BlockYellowShulkerBoxHandler (E_BLOCK_YELLOW_SHULKER_BOX);
}
@@ -452,22 +454,13 @@ namespace
////////////////////////////////////////////////////////////////////////////////
// cBlockHandler:
-cBlockHandler::cBlockHandler(BLOCKTYPE a_BlockType)
-{
- m_BlockType = a_BlockType;
-}
-
-
-
-
-
bool cBlockHandler::GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer & a_Player,
const Vector3i a_ClickedBlockPos,
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
-)
+) const
{
// By default, all blocks can be placed and the meta is copied over from the item's damage value:
a_BlockType = m_BlockType;
@@ -485,7 +478,7 @@ void cBlockHandler::OnUpdate(
cBlockPluginInterface & a_PluginInterface,
cChunk & a_Chunk,
const Vector3i a_RelPos
-)
+) const
{
}
@@ -493,7 +486,7 @@ void cBlockHandler::OnUpdate(
-void cBlockHandler::OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor)
+void cBlockHandler::OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const
{
if (a_ChunkInterface.DoWithChunkAt(a_BlockPos, [&](cChunk & a_Chunk) { return CanBeAt(a_ChunkInterface, a_Chunk.AbsoluteToRelative(a_BlockPos), a_Chunk); }))
{
@@ -521,7 +514,7 @@ void cBlockHandler::NeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i
return;
}
- cBlockInfo::GetHandler(a_ChunkInterface.GetBlock(a_NeighborPos))->OnNeighborChanged(a_ChunkInterface, a_NeighborPos, a_WhichNeighbor);
+ cBlockHandler::For(a_ChunkInterface.GetBlock(a_NeighborPos)).OnNeighborChanged(a_ChunkInterface, a_NeighborPos, a_WhichNeighbor);
}
@@ -533,7 +526,7 @@ cItems cBlockHandler::ConvertToPickups(
cBlockEntity * a_BlockEntity,
const cEntity * a_Digger,
const cItem * a_Tool
-)
+) const
{
UNUSED(a_BlockEntity);
UNUSED(a_Digger);
@@ -549,7 +542,7 @@ cItems cBlockHandler::ConvertToPickups(
-bool cBlockHandler::CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk)
+bool cBlockHandler::CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const
{
return true;
}
@@ -558,7 +551,7 @@ bool cBlockHandler::CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a
-bool cBlockHandler::IsUseable()
+bool cBlockHandler::IsUseable() const
{
return false;
}
@@ -567,7 +560,7 @@ bool cBlockHandler::IsUseable()
-bool cBlockHandler::IsClickedThrough(void)
+bool cBlockHandler::IsClickedThrough(void) const
{
return false;
}
@@ -576,7 +569,7 @@ bool cBlockHandler::IsClickedThrough(void)
-bool cBlockHandler::DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface, Vector3i a_Pos, cPlayer & a_Player, NIBBLETYPE a_Meta)
+bool cBlockHandler::DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface, Vector3i a_Pos, cPlayer & a_Player, NIBBLETYPE a_Meta) const
{
return (m_BlockType == E_BLOCK_AIR);
}
@@ -585,7 +578,7 @@ bool cBlockHandler::DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface,
-bool cBlockHandler::DoesDropOnUnsuitable(void)
+bool cBlockHandler::DoesDropOnUnsuitable(void) const
{
return true;
}
@@ -594,7 +587,7 @@ bool cBlockHandler::DoesDropOnUnsuitable(void)
-bool cBlockHandler::IsInsideBlock(const Vector3d a_RelPosition, const NIBBLETYPE a_BlockMeta)
+bool cBlockHandler::IsInsideBlock(const Vector3d a_RelPosition, const NIBBLETYPE a_BlockMeta) const
{
// Default functionality: Test the height, since we assume full voxels with varying height
return (a_RelPosition.y < cBlockInfo::GetBlockHeight(m_BlockType));
@@ -604,7 +597,7 @@ bool cBlockHandler::IsInsideBlock(const Vector3d a_RelPosition, const NIBBLETYPE
-cBoundingBox cBlockHandler::GetPlacementCollisionBox(BLOCKTYPE a_XM, BLOCKTYPE a_XP, BLOCKTYPE a_YM, BLOCKTYPE a_YP, BLOCKTYPE a_ZM, BLOCKTYPE a_ZP)
+cBoundingBox cBlockHandler::GetPlacementCollisionBox(BLOCKTYPE a_XM, BLOCKTYPE a_XP, BLOCKTYPE a_YM, BLOCKTYPE a_YP, BLOCKTYPE a_ZM, BLOCKTYPE a_ZP) const
{
if (!cBlockInfo::IsSolid(m_BlockType))
{
@@ -622,7 +615,7 @@ void cBlockHandler::Check(
cChunkInterface & a_ChunkInterface, cBlockPluginInterface & a_PluginInterface,
Vector3i a_RelPos,
cChunk & a_Chunk
-)
+) const
{
const auto Position = cChunkDef::RelativeToAbsolute(a_RelPos, a_Chunk.GetPos());
NeighborChanged(a_ChunkInterface, Position.addedX(-1), BLOCK_FACE_XP);
@@ -637,7 +630,7 @@ void cBlockHandler::Check(
-ColourID cBlockHandler::GetMapBaseColourID(NIBBLETYPE a_Meta)
+ColourID cBlockHandler::GetMapBaseColourID(NIBBLETYPE a_Meta) const
{
// Zero for transparent
return 0;
@@ -656,7 +649,7 @@ bool cBlockHandler::ToolHasSilkTouch(const cItem * a_Tool)
-cBlockHandler & cBlockHandler::GetBlockHandler(BLOCKTYPE a_BlockType)
+const cBlockHandler & cBlockHandler::For(BLOCKTYPE a_BlockType)
{
// Switch on the block type, as an enumeration
// Clang will fail if any type is unhandled:
diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h
index 96e251f49..447fc7dc6 100644
--- a/src/Blocks/BlockHandler.h
+++ b/src/Blocks/BlockHandler.h
@@ -25,9 +25,11 @@ class BlockTypeRegistry;
class cBlockHandler
{
public:
- cBlockHandler(BLOCKTYPE a_BlockType);
- virtual ~cBlockHandler() {}
+ constexpr cBlockHandler(BLOCKTYPE a_BlockType) :
+ m_BlockType(a_BlockType)
+ {
+ }
/** Called when the block gets ticked either by a random tick or by a queued tick.
Note that the coords in a_RelPos are chunk-relative! */
@@ -37,12 +39,12 @@ public:
cBlockPluginInterface & a_BlockPluginInterface,
cChunk & a_Chunk,
const Vector3i a_RelPos
- );
+ ) const;
/** Returns the relative bounding box that must be entity-free in
order for the block to be placed. a_XM, a_XP, etc. stand for the
blocktype of the minus-X neighbor, the positive-X neighbor, etc. */
- virtual cBoundingBox GetPlacementCollisionBox(BLOCKTYPE a_XM, BLOCKTYPE a_XP, BLOCKTYPE a_YM, BLOCKTYPE a_YP, BLOCKTYPE a_ZM, BLOCKTYPE a_ZP);
+ virtual cBoundingBox GetPlacementCollisionBox(BLOCKTYPE a_XM, BLOCKTYPE a_XP, BLOCKTYPE a_YM, BLOCKTYPE a_YP, BLOCKTYPE a_ZM, BLOCKTYPE a_ZP) const;
/** Called before a block is placed into a world by player, by cItemHandler::GetPlacementBlockTypeMeta().
The handler should return true to allow placement, false to refuse.
@@ -58,19 +60,19 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- );
+ ) const;
/** Called by cWorld::SetBlock() after the block has been set */
virtual void OnPlaced(
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface,
Vector3i a_BlockPos,
BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta
- ) {};
+ ) const {};
/** Called by cPlayer::PlaceBlocks() for each block after it has been set to the world. Called after OnPlaced(). */
virtual void OnPlacedByPlayer(
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, const sSetBlock & a_BlockChange
- ) {};
+ ) const {};
/** Called just after the player breaks the block.
The block is already dug up in the world, the original block type and meta is passed in a_OldBlockType and a_OldBlockMeta.
@@ -80,7 +82,7 @@ public:
cPlayer & a_Player,
Vector3i a_BlockPos,
BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta
- ) {}
+ ) const {}
/** Called after a block gets broken (replaced with air), either by player or by natural means.
If by player, it is called before the OnPlayerBrokeBlock() callback.
@@ -90,13 +92,13 @@ public:
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface,
Vector3i a_BlockPos,
BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta
- ) {};
+ ) const {};
/** Called when a direct neighbor of this block has been changed.
The position is the block's own position, NOT the changed neighbor's position.
a_WhichNeighbor indicates which neighbor has changed. For example, BLOCK_FACE_YP meant the neighbor above has changed.
BLOCK_FACE_NONE means that it is a neighbor not directly adjacent (diagonal, etc.) */
- virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor);
+ virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const;
/** Notifies the specified neighbor that the current block has changed.
a_NeighborPos are the coords of the neighbor to be notified
@@ -111,7 +113,7 @@ public:
cWorldInterface & a_WorldInterface,
cPlayer & a_Player,
const Vector3i a_BlockPos
- )
+ ) const
{
}
@@ -125,7 +127,7 @@ public:
const Vector3i a_BlockPos,
eBlockFace a_BlockFace,
const Vector3i a_CursorPos
- )
+ ) const
{
return false;
}
@@ -138,7 +140,7 @@ public:
cPlayer & a_Player,
const Vector3i a_BlockPos,
eBlockFace a_BlockFace
- )
+ ) const
{
}
@@ -153,40 +155,40 @@ public:
cBlockEntity * a_BlockEntity,
const cEntity * a_Digger = nullptr,
const cItem * a_Tool = nullptr
- );
+ ) const;
/** Checks if the block can stay at the specified relative coords in the chunk */
virtual bool CanBeAt(
cChunkInterface & a_ChunkInterface,
const Vector3i a_RelPos,
const cChunk & a_Chunk
- );
+ ) const;
/** Checks whether the block has an effect on growing the plant */
- virtual bool CanSustainPlant(BLOCKTYPE a_Plant) { return false; }
+ virtual bool CanSustainPlant(BLOCKTYPE a_Plant) const { return false; }
/** Called to check whether this block supports a rclk action.
If it returns true, OnUse() is called */
- virtual bool IsUseable(void);
+ virtual bool IsUseable(void) const;
/** Indicates whether the client will click through this block.
For example digging a fire will hit the block below the fire so fire is clicked through. */
- virtual bool IsClickedThrough(void);
+ virtual bool IsClickedThrough(void) const;
/** Checks if the player can build "inside" this block.
For example blocks placed "on" snow will be placed at the same position. So: Snow ignores Build collision
@param a_Pos Position of the block
@param a_Player Player trying to build on the block
@param a_Meta Meta value of the block currently at a_Pos */
- virtual bool DoesIgnoreBuildCollision(cChunkInterface & ChunkInterface, const Vector3i a_Pos, cPlayer & a_Player, NIBBLETYPE a_Meta);
+ virtual bool DoesIgnoreBuildCollision(cChunkInterface & ChunkInterface, const Vector3i a_Pos, cPlayer & a_Player, NIBBLETYPE a_Meta) const;
/** Returns if this block drops if it gets destroyed by an unsuitable situation.
Default: true */
- virtual bool DoesDropOnUnsuitable(void);
+ virtual bool DoesDropOnUnsuitable(void) const;
/** Tests if a_RelPosition is inside the block, where a_RelPosition is relative to the origin of the block.
Coords in a_RelPosition are guaranteed to be in the [0..1] range. */
- virtual bool IsInsideBlock(const Vector3d a_RelPosition, const NIBBLETYPE a_BlockMeta);
+ virtual bool IsInsideBlock(const Vector3d a_RelPosition, const NIBBLETYPE a_BlockMeta) const;
/** Called when one of the neighbors gets set; equivalent to MC block update.
By default drops (DropBlockAsPickup() / SetBlock()) if the position is no longer suitable (CanBeAt(), DoesDropOnUnsuitable()),
@@ -195,47 +197,45 @@ public:
cChunkInterface & ChunkInterface, cBlockPluginInterface & a_PluginInterface,
Vector3i a_RelPos,
cChunk & a_Chunk
- );
+ ) const;
/** Returns the base colour ID of the block, as will be represented on a map, as per documentation: https://minecraft.gamepedia.com/Map_item_format */
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta);
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const;
/** Rotates a given block meta counter-clockwise. Default: no change
Returns block meta following rotation */
- virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) { return a_Meta; }
+ virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) const { return a_Meta; }
/** Rotates a given block meta clockwise. Default: no change
Returns block meta following rotation */
- virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) { return a_Meta; }
+ virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) const { return a_Meta; }
/** Mirrors a given block meta around the XY plane. Default: no change
Returns block meta following rotation */
- virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) { return a_Meta; }
+ virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) const { return a_Meta; }
/** Mirros a given block meta around the XZ plane. Default: no change
Returns block meta following rotation */
- virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) { return a_Meta; }
+ virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) const { return a_Meta; }
/** Mirros a given block meta around the YZ plane. Default: no change
Returns block meta following rotation */
- virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) { return a_Meta; }
+ virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) const { return a_Meta; }
/** Grows this block, if it supports growing, by the specified amount of stages (at most).
Returns the number of stages actually grown, zero if not supported (default). */
- virtual int Grow(cChunk & a_Chunk, Vector3i a_RelPos, int a_NumStages = 1) { return 0; }
+ virtual int Grow(cChunk & a_Chunk, Vector3i a_RelPos, int a_NumStages = 1) const { return 0; }
/** Returns true if the specified tool is valid and has a non-zero silk-touch enchantment.
Helper used in many ConvertToPickups() implementations. */
static bool ToolHasSilkTouch(const cItem * a_Tool);
// Gets the blockhandler for the given block type.
- static cBlockHandler & GetBlockHandler(BLOCKTYPE a_BlockType);
+ static const cBlockHandler & For(BLOCKTYPE a_BlockType);
protected:
BLOCKTYPE m_BlockType;
-
- friend class cBlockInfo;
};
diff --git a/src/Blocks/BlockHopper.h b/src/Blocks/BlockHopper.h
index cb1ddf7d1..d05bb3bf8 100644
--- a/src/Blocks/BlockHopper.h
+++ b/src/Blocks/BlockHopper.h
@@ -14,14 +14,9 @@ class cBlockHopperHandler :
public:
- cBlockHopperHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+private:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface,
@@ -30,7 +25,7 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
a_BlockType = m_BlockType;
@@ -52,7 +47,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 11;
diff --git a/src/Blocks/BlockIce.h b/src/Blocks/BlockIce.h
index a4372d0ea..e20ce6daa 100644
--- a/src/Blocks/BlockIce.h
+++ b/src/Blocks/BlockIce.h
@@ -14,12 +14,11 @@ class cBlockIceHandler :
public:
- cBlockIceHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
+ using Super::Super;
+
+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
{
// Only drop self when using silk-touch:
if (ToolHasSilkTouch(a_Tool))
@@ -36,7 +35,7 @@ public:
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface,
Vector3i a_BlockPos,
BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta
- ) override
+ ) const override
{
// If there's a solid block or a liquid underneath, convert to water, rather than air
if (a_BlockPos.y <= 0)
@@ -51,7 +50,7 @@ public:
}
}
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 5;
diff --git a/src/Blocks/BlockJukebox.h b/src/Blocks/BlockJukebox.h
index 22b02a2c7..5b655e71d 100644
--- a/src/Blocks/BlockJukebox.h
+++ b/src/Blocks/BlockJukebox.h
@@ -11,26 +11,15 @@
class cBlockJukeboxHandler :
public cClearMetaOnDrop<cBlockEntityHandler>
{
- using super = cClearMetaOnDrop<cBlockEntityHandler>;
-
public:
- cBlockJukeboxHandler(BLOCKTYPE a_BlockType):
- super(a_BlockType)
- {
- }
-
-
+ using cClearMetaOnDrop<cBlockEntityHandler>::cClearMetaOnDrop;
+private:
-
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 6;
}
} ;
-
-
-
-
diff --git a/src/Blocks/BlockLadder.h b/src/Blocks/BlockLadder.h
index 3f38d2c0c..59c13a406 100644
--- a/src/Blocks/BlockLadder.h
+++ b/src/Blocks/BlockLadder.h
@@ -15,14 +15,9 @@ class cBlockLadderHandler:
public:
- cBlockLadderHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+private:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface,
@@ -31,7 +26,7 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
// Try finding a suitable neighbor block face for the ladder; start with the given one.
if (!LadderCanBePlacedAt(a_ChunkInterface, a_PlacedBlockPos, a_ClickedBlockFace))
@@ -132,7 +127,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
auto NeighborBlockFace = MetaDataToBlockFace(a_Chunk.GetMeta(a_RelPos));
auto LadderAbsPos = a_Chunk.RelativeToAbsolute(a_RelPos);
@@ -143,7 +138,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 0;
diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h
index cd2b62743..647f96211 100644
--- a/src/Blocks/BlockLeaves.h
+++ b/src/Blocks/BlockLeaves.h
@@ -19,6 +19,12 @@ class cBlockLeavesHandler:
{
using Super = cBlockHandler;
+public:
+
+ using Super::Super;
+
+private:
+
/** Returns true if the area contains a continous path from the specified block to a log block entirely made out of leaves blocks. */
static bool HasNearLog(cBlockArea & a_Area, const Vector3i a_BlockPos)
{
@@ -87,19 +93,7 @@ class cBlockLeavesHandler:
return false;
}
-
-public:
-
- cBlockLeavesHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
-
-
- 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
{
// If breaking with shears, drop self:
if ((a_Tool != nullptr) && (a_Tool->m_ItemType == E_ITEM_SHEARS))
@@ -148,7 +142,7 @@ public:
- virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) override
+ virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const override
{
auto meta = a_ChunkInterface.GetBlockMeta(a_BlockPos);
@@ -169,7 +163,7 @@ public:
cBlockPluginInterface & a_PluginInterface,
cChunk & a_Chunk,
const Vector3i a_RelPos
- ) override
+ ) const override
{
auto Meta = a_Chunk.GetMeta(a_RelPos);
if ((Meta & 0x04) != 0)
@@ -213,7 +207,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 7;
diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h
index 4a682322d..14389add0 100644
--- a/src/Blocks/BlockLever.h
+++ b/src/Blocks/BlockLever.h
@@ -13,14 +13,15 @@ class cBlockLeverHandler:
public:
- cBlockLeverHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
+ using Super::Super;
+
+ /** Extracts the ON bit from metadata and returns if true if it is set */
+ static bool IsLeverOn(NIBBLETYPE a_BlockMeta)
{
+ return ((a_BlockMeta & 0x8) == 0x8);
}
-
-
-
+private:
virtual bool OnUse(
cChunkInterface & a_ChunkInterface,
@@ -29,7 +30,7 @@ public:
const Vector3i a_BlockPos,
eBlockFace a_BlockFace,
const Vector3i a_CursorPos
- ) override
+ ) const override
{
// Flip the ON bit on / off using the XOR bitwise operation
NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockPos) ^ 0x08);
@@ -44,7 +45,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
{
// Reset meta to zero:
return cItem(E_BLOCK_LEVER, 1, 0);
@@ -54,7 +55,7 @@ public:
- virtual bool IsUseable(void) override
+ virtual bool IsUseable(void) const override
{
return true;
}
@@ -70,7 +71,7 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
a_BlockType = m_BlockType;
a_BlockMeta = LeverDirectionToMetaData(a_ClickedBlockFace);
@@ -127,7 +128,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
// Find the type of block the lever is attached to:
auto Meta = a_Chunk.GetMeta(a_RelPos);
@@ -163,7 +164,7 @@ public:
- virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
+ virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) const override
{
switch (a_Meta)
{
@@ -181,7 +182,7 @@ public:
- virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
+ virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) const override
{
switch (a_Meta)
{
@@ -199,21 +200,11 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 0;
}
-
-
-
-
-
- /** Extracts the ON bit from metadata and returns if true if it is set */
- static bool IsLeverOn(NIBBLETYPE a_BlockMeta)
- {
- return ((a_BlockMeta & 0x8) == 0x8);
- }
} ;
diff --git a/src/Blocks/BlockLilypad.h b/src/Blocks/BlockLilypad.h
index 8ffc8fd20..4ee0e8133 100644
--- a/src/Blocks/BlockLilypad.h
+++ b/src/Blocks/BlockLilypad.h
@@ -14,16 +14,11 @@ class cBlockLilypadHandler:
public:
- cBlockLilypadHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+private:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 7;
@@ -33,7 +28,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
auto UnderPos = a_RelPos.addedY(-1);
if (!cChunkDef::IsValidHeight(UnderPos.y))
diff --git a/src/Blocks/BlockMelon.h b/src/Blocks/BlockMelon.h
index d6b9e6a46..f5230b7e5 100644
--- a/src/Blocks/BlockMelon.h
+++ b/src/Blocks/BlockMelon.h
@@ -14,16 +14,11 @@ class cBlockMelonHandler :
public:
- cBlockMelonHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+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
{
return cItem(E_ITEM_MELON_SLICE, GetRandomProvider().RandInt<char>(3, 7), 0);
}
@@ -32,7 +27,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 19;
diff --git a/src/Blocks/BlockMobHead.h b/src/Blocks/BlockMobHead.h
index 2fc8b177d..71fb6c958 100644
--- a/src/Blocks/BlockMobHead.h
+++ b/src/Blocks/BlockMobHead.h
@@ -14,16 +14,12 @@ class cBlockMobHeadHandler :
using Super = cBlockEntityHandler;
public:
- cBlockMobHeadHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
+ using Super::Super;
+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
{
if ((a_BlockEntity == nullptr) || (a_BlockEntity->GetBlockType() != E_BLOCK_HEAD))
{
@@ -37,7 +33,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 0;
diff --git a/src/Blocks/BlockMobSpawner.h b/src/Blocks/BlockMobSpawner.h
index 78fa9ec31..5e3592f84 100644
--- a/src/Blocks/BlockMobSpawner.h
+++ b/src/Blocks/BlockMobSpawner.h
@@ -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))
diff --git a/src/Blocks/BlockMushroom.h b/src/Blocks/BlockMushroom.h
index e40031465..c025f3ad5 100644
--- a/src/Blocks/BlockMushroom.h
+++ b/src/Blocks/BlockMushroom.h
@@ -15,22 +15,13 @@ class cBlockMushroomHandler:
public:
- cBlockMushroomHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+private:
// TODO: Add Mushroom Spread
-
-
-
-
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
if (a_RelPos.y <= 0)
{
@@ -58,7 +49,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 0;
diff --git a/src/Blocks/BlockMycelium.h b/src/Blocks/BlockMycelium.h
index e91d45b98..322c9d4d5 100644
--- a/src/Blocks/BlockMycelium.h
+++ b/src/Blocks/BlockMycelium.h
@@ -11,18 +11,14 @@ class cBlockMyceliumHandler:
public cBlockHandler
{
public:
- cBlockMyceliumHandler(BLOCKTYPE a_BlockType):
- cBlockHandler(a_BlockType)
- {
- }
-
- // TODO: Add Mycel Spread
-
+ using cBlockHandler::cBlockHandler;
+private:
+ // TODO: Add Mycel Spread
- 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
{
return cItem(E_BLOCK_DIRT, 1, 0);
}
@@ -31,7 +27,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 24;
diff --git a/src/Blocks/BlockNetherWart.h b/src/Blocks/BlockNetherWart.h
index 86e348cf1..c1226224f 100644
--- a/src/Blocks/BlockNetherWart.h
+++ b/src/Blocks/BlockNetherWart.h
@@ -15,16 +15,11 @@ class cBlockNetherWartHandler:
public:
- cBlockNetherWartHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+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
{
if (a_BlockMeta == 0x03)
{
@@ -42,7 +37,7 @@ public:
- virtual int Grow(cChunk & a_Chunk, Vector3i a_RelPos, int a_NumStages = 1) override
+ virtual int Grow(cChunk & a_Chunk, Vector3i a_RelPos, int a_NumStages = 1) const override
{
auto oldMeta = a_Chunk.GetMeta(a_RelPos);
auto meta = std::min(oldMeta + a_NumStages, 3);
@@ -64,7 +59,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
// Needs to be placed on top of a Soulsand block:
return ((a_RelPos.y > 0) && (a_Chunk.GetBlock(a_RelPos.addedY(-1)) == E_BLOCK_SOULSAND));
@@ -74,7 +69,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 35;
diff --git a/src/Blocks/BlockNetherrack.h b/src/Blocks/BlockNetherrack.h
index 3ccd811f3..4c839d5ee 100644
--- a/src/Blocks/BlockNetherrack.h
+++ b/src/Blocks/BlockNetherrack.h
@@ -1,12 +1,22 @@
-#pragma once
+#pragma once
#include "BlockHandler.h"
+
+
+
+
class cBlockNetherrack : public cBlockHandler
{
public:
- cBlockNetherrack(BLOCKTYPE a_Type) : cBlockHandler(a_Type){}
- virtual bool CanSustainPlant(BLOCKTYPE a_Plant) override { return (a_Plant == E_BLOCK_NETHER_WART); }
+ using cBlockHandler::cBlockHandler;
+
+private:
+
+ virtual bool CanSustainPlant(BLOCKTYPE a_Plant) const override
+ {
+ return a_Plant == E_BLOCK_NETHER_WART;
+ }
};
diff --git a/src/Blocks/BlockObserver.h b/src/Blocks/BlockObserver.h
index 78a4c05b2..5c3f62fbd 100644
--- a/src/Blocks/BlockObserver.h
+++ b/src/Blocks/BlockObserver.h
@@ -12,9 +12,7 @@ class cBlockObserverHandler:
public:
- cBlockObserverHandler(BLOCKTYPE a_BlockType) : Super(a_BlockType)
- {
- }
+ using Super::Super;
inline static Vector3i GetObservingFaceOffset(NIBBLETYPE a_Meta)
{
diff --git a/src/Blocks/BlockOre.h b/src/Blocks/BlockOre.h
index 46b18f008..e329a5781 100644
--- a/src/Blocks/BlockOre.h
+++ b/src/Blocks/BlockOre.h
@@ -13,16 +13,12 @@ class cBlockOreHandler:
using Super = cBlockHandler;
public:
- cBlockOreHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
+ using Super::Super;
+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
{
// If using silk-touch, drop self rather than the resource:
if (ToolHasSilkTouch(a_Tool))
@@ -62,7 +58,7 @@ public:
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface,
cPlayer & a_Player, Vector3i a_BlockPos,
BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta
- ) override
+ ) const override
{
if (!a_Player.IsGameModeSurvival())
{
diff --git a/src/Blocks/BlockPiston.cpp b/src/Blocks/BlockPiston.cpp
index b68a59461..87b5c1480 100644
--- a/src/Blocks/BlockPiston.cpp
+++ b/src/Blocks/BlockPiston.cpp
@@ -17,40 +17,6 @@
-cBlockPistonHandler::cBlockPistonHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
-{
-}
-
-
-
-
-
-void cBlockPistonHandler::OnBroken(
- cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface,
- Vector3i a_BlockPos,
- BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta
-)
-{
- if (!IsExtended(a_OldBlockMeta))
- {
- return;
- }
-
- const auto Extension = a_BlockPos + MetadataToOffset(a_OldBlockMeta);
- if (
- cChunkDef::IsValidHeight(Extension.y) &&
- (a_ChunkInterface.GetBlock(Extension) == E_BLOCK_PISTON_EXTENSION)
- )
- {
- // If the piston is extended, destroy the extension as well:
- a_ChunkInterface.SetBlock(Extension, E_BLOCK_AIR, 0);
- }
-}
-
-
-
-
Vector3i cBlockPistonHandler::MetadataToOffset(NIBBLETYPE a_PistonMeta)
{
@@ -75,118 +41,6 @@ Vector3i cBlockPistonHandler::MetadataToOffset(NIBBLETYPE a_PistonMeta)
-void cBlockPistonHandler::PushBlocks(
- const Vector3iSet & a_BlocksToPush,
- cWorld & a_World, const Vector3i & a_PushDir
-)
-{
- // Sort blocks to move the blocks first, which are farthest away from the piston
- // This prevents the overwriting of existing blocks
- std::vector<Vector3i> sortedBlocks(a_BlocksToPush.begin(), a_BlocksToPush.end());
- std::sort(sortedBlocks.begin(), sortedBlocks.end(), [a_PushDir](const Vector3i & a, const Vector3i & b)
- {
- return (a.Dot(a_PushDir) > b.Dot(a_PushDir));
- });
-
- // Move every block
- BLOCKTYPE moveBlock;
- NIBBLETYPE moveMeta;
- for (auto & moveBlockPos : sortedBlocks)
- {
- a_World.GetBlockTypeMeta(moveBlockPos.x, moveBlockPos.y, moveBlockPos.z, moveBlock, moveMeta);
-
- if (cBlockInfo::IsPistonBreakable(moveBlock))
- {
- // Block is breakable, drop it:
- a_World.DropBlockAsPickups(moveBlockPos, nullptr, nullptr);
- }
- else
- {
- // Not breakable, just move it
- a_World.SetBlock(moveBlockPos.x, moveBlockPos.y, moveBlockPos.z, E_BLOCK_AIR, 0);
- moveBlockPos += a_PushDir;
- a_World.SetBlock(moveBlockPos.x, moveBlockPos.y, moveBlockPos.z, moveBlock, moveMeta);
- }
- }
-}
-
-
-
-
-
-bool cBlockPistonHandler::CanPushBlock(
- const Vector3i & a_BlockPos, cWorld & a_World, bool a_RequirePushable,
- Vector3iSet & a_BlocksPushed, const Vector3i & a_PushDir
-)
-{
- const static std::array<Vector3i, 6> pushingDirs =
- {
- {
- Vector3i(-1, 0, 0), Vector3i(1, 0, 0),
- Vector3i( 0, -1, 0), Vector3i(0, 1, 0),
- Vector3i( 0, 0, -1), Vector3i(0, 0, 1)
- }
- };
-
- BLOCKTYPE currBlock;
- NIBBLETYPE currMeta;
- a_World.GetBlockTypeMeta(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, currBlock, currMeta);
-
- if (!cChunkDef::IsValidHeight(a_BlockPos.y))
- {
- return !a_RequirePushable;
- }
-
- if (currBlock == E_BLOCK_AIR)
- {
- // Air can be pushed
- return true;
- }
-
- if (!a_RequirePushable && cBlockInfo::IsPistonBreakable(currBlock))
- {
- // Block should not be broken, when it's not in the pushing direction
- return true;
- }
-
- if (!CanPush(currBlock, currMeta))
- {
- // When it's not required to push this block, don't fail
- return !a_RequirePushable;
- }
-
- if (a_BlocksPushed.size() >= PISTON_MAX_PUSH_DISTANCE)
- {
- // Do not allow to push too much blocks
- return false;
- }
-
- if (!a_BlocksPushed.insert(a_BlockPos).second || cBlockInfo::IsPistonBreakable(currBlock))
- {
- return true; // Element exist already
- }
-
- if (currBlock == E_BLOCK_SLIME_BLOCK)
- {
- // Try to push the other directions
- for (const auto & testDir : pushingDirs)
- {
- if (!CanPushBlock(a_BlockPos + testDir, a_World, false, a_BlocksPushed, a_PushDir))
- {
- // When it's not possible for a direction, then fail
- return false;
- }
- }
- }
-
- // Try to push the block in front of this block
- return CanPushBlock(a_BlockPos + a_PushDir, a_World, true, a_BlocksPushed, a_PushDir);
-}
-
-
-
-
-
void cBlockPistonHandler::ExtendPiston(Vector3i a_BlockPos, cWorld & a_World)
{
{
@@ -320,23 +174,152 @@ void cBlockPistonHandler::RetractPiston(Vector3i a_BlockPos, cWorld & a_World)
-////////////////////////////////////////////////////////////////////////////////
-// cBlockPistonHeadHandler:
+void cBlockPistonHandler::PushBlocks(
+ const Vector3iSet & a_BlocksToPush,
+ cWorld & a_World, const Vector3i & a_PushDir
+)
+{
+ // Sort blocks to move the blocks first, which are farthest away from the piston
+ // This prevents the overwriting of existing blocks
+ std::vector<Vector3i> sortedBlocks(a_BlocksToPush.begin(), a_BlocksToPush.end());
+ std::sort(sortedBlocks.begin(), sortedBlocks.end(), [a_PushDir](const Vector3i & a, const Vector3i & b)
+ {
+ return (a.Dot(a_PushDir) > b.Dot(a_PushDir));
+ });
+
+ // Move every block
+ BLOCKTYPE moveBlock;
+ NIBBLETYPE moveMeta;
+ for (auto & moveBlockPos : sortedBlocks)
+ {
+ a_World.GetBlockTypeMeta(moveBlockPos.x, moveBlockPos.y, moveBlockPos.z, moveBlock, moveMeta);
+
+ if (cBlockInfo::IsPistonBreakable(moveBlock))
+ {
+ // Block is breakable, drop it:
+ a_World.DropBlockAsPickups(moveBlockPos, nullptr, nullptr);
+ }
+ else
+ {
+ // Not breakable, just move it
+ a_World.SetBlock(moveBlockPos.x, moveBlockPos.y, moveBlockPos.z, E_BLOCK_AIR, 0);
+ moveBlockPos += a_PushDir;
+ a_World.SetBlock(moveBlockPos.x, moveBlockPos.y, moveBlockPos.z, moveBlock, moveMeta);
+ }
+ }
+}
+
+
+
+
+
+bool cBlockPistonHandler::CanPushBlock(
+ const Vector3i & a_BlockPos, cWorld & a_World, bool a_RequirePushable,
+ Vector3iSet & a_BlocksPushed, const Vector3i & a_PushDir
+)
+{
+ const static std::array<Vector3i, 6> pushingDirs =
+ {
+ {
+ Vector3i(-1, 0, 0), Vector3i(1, 0, 0),
+ Vector3i( 0, -1, 0), Vector3i(0, 1, 0),
+ Vector3i( 0, 0, -1), Vector3i(0, 0, 1)
+ }
+ };
+
+ BLOCKTYPE currBlock;
+ NIBBLETYPE currMeta;
+ a_World.GetBlockTypeMeta(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, currBlock, currMeta);
+
+ if (!cChunkDef::IsValidHeight(a_BlockPos.y))
+ {
+ return !a_RequirePushable;
+ }
+
+ if (currBlock == E_BLOCK_AIR)
+ {
+ // Air can be pushed
+ return true;
+ }
+
+ if (!a_RequirePushable && cBlockInfo::IsPistonBreakable(currBlock))
+ {
+ // Block should not be broken, when it's not in the pushing direction
+ return true;
+ }
-cBlockPistonHeadHandler::cBlockPistonHeadHandler(void) :
- Super(E_BLOCK_PISTON_EXTENSION)
+ if (!CanPush(currBlock, currMeta))
+ {
+ // When it's not required to push this block, don't fail
+ return !a_RequirePushable;
+ }
+
+ if (a_BlocksPushed.size() >= PISTON_MAX_PUSH_DISTANCE)
+ {
+ // Do not allow to push too much blocks
+ return false;
+ }
+
+ if (!a_BlocksPushed.insert(a_BlockPos).second || cBlockInfo::IsPistonBreakable(currBlock))
+ {
+ return true; // Element exist already
+ }
+
+ if (currBlock == E_BLOCK_SLIME_BLOCK)
+ {
+ // Try to push the other directions
+ for (const auto & testDir : pushingDirs)
+ {
+ if (!CanPushBlock(a_BlockPos + testDir, a_World, false, a_BlocksPushed, a_PushDir))
+ {
+ // When it's not possible for a direction, then fail
+ return false;
+ }
+ }
+ }
+
+ // Try to push the block in front of this block
+ return CanPushBlock(a_BlockPos + a_PushDir, a_World, true, a_BlocksPushed, a_PushDir);
+}
+
+
+
+
+
+void cBlockPistonHandler::OnBroken(
+ cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface,
+ Vector3i a_BlockPos,
+ BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta
+) const
{
+ if (!IsExtended(a_OldBlockMeta))
+ {
+ return;
+ }
+
+ const auto Extension = a_BlockPos + MetadataToOffset(a_OldBlockMeta);
+ if (
+ cChunkDef::IsValidHeight(Extension.y) &&
+ (a_ChunkInterface.GetBlock(Extension) == E_BLOCK_PISTON_EXTENSION)
+ )
+ {
+ // If the piston is extended, destroy the extension as well:
+ a_ChunkInterface.SetBlock(Extension, E_BLOCK_AIR, 0);
+ }
}
+////////////////////////////////////////////////////////////////////////////////
+// cBlockPistonHeadHandler:
+
void cBlockPistonHeadHandler::OnBroken(
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface,
Vector3i a_BlockPos,
BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta
-)
+) const
{
const auto Base = a_BlockPos - cBlockPistonHandler::MetadataToOffset(a_OldBlockMeta);
if (!cChunkDef::IsValidHeight(Base.y))
@@ -356,7 +339,7 @@ void cBlockPistonHeadHandler::OnBroken(
-cItems cBlockPistonHeadHandler::ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool)
+cItems cBlockPistonHeadHandler::ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const
{
// Give a normal\sticky piston base, not piston extension
// With 1.7, the item forms of these technical blocks have been removed, so giving someone this will crash their client...
diff --git a/src/Blocks/BlockPiston.h b/src/Blocks/BlockPiston.h
index 8799ba3ca..f8d155196 100644
--- a/src/Blocks/BlockPiston.h
+++ b/src/Blocks/BlockPiston.h
@@ -22,13 +22,7 @@ class cBlockPistonHandler:
public:
- cBlockPistonHandler(BLOCKTYPE a_BlockType);
-
- virtual void OnBroken(
- cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface,
- Vector3i a_BlockPos,
- BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta
- ) override;
+ using Super::Super;
static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData)
{
@@ -54,12 +48,6 @@ public:
static void ExtendPiston(Vector3i a_BlockPos, cWorld & a_World);
static void RetractPiston(Vector3i a_BlockPos, cWorld & a_World);
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
- {
- UNUSED(a_Meta);
- return 11;
- }
-
/** Returns true if the piston (with the specified meta) is extended */
static inline bool IsExtended(NIBBLETYPE a_PistonMeta) { return ((a_PistonMeta & 0x8) != 0x0); }
@@ -131,6 +119,18 @@ private:
Vector3iSet & a_BlocksPushed, const Vector3i & a_PushDir
);
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
+ {
+ UNUSED(a_Meta);
+ return 11;
+ }
+
+ virtual void OnBroken(
+ cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface,
+ Vector3i a_BlockPos,
+ BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta
+ ) const override;
+
/** Moves a list of blocks in a specific direction */
static void PushBlocks(const Vector3iSet & a_BlocksToPush,
cWorld & a_World, const Vector3i & a_PushDir
@@ -147,13 +147,17 @@ class cBlockPistonHeadHandler:
using Super = cBlockHandler;
public:
- cBlockPistonHeadHandler(void);
+
+ constexpr cBlockPistonHeadHandler(void) :
+ Super(E_BLOCK_PISTON_EXTENSION)
+ {
+ }
virtual void OnBroken(
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface,
Vector3i a_BlockPos,
BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta
- ) override;
+ ) const override;
- 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;
} ;
diff --git a/src/Blocks/BlockPlanks.h b/src/Blocks/BlockPlanks.h
index ea7d91398..158b9451d 100644
--- a/src/Blocks/BlockPlanks.h
+++ b/src/Blocks/BlockPlanks.h
@@ -14,14 +14,9 @@ class cBlockPlanksHandler:
public:
- cBlockPlanksHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+private:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface,
@@ -30,7 +25,7 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
a_BlockType = m_BlockType;
a_BlockMeta = static_cast<NIBBLETYPE>(a_Player.GetEquippedItem().m_ItemDamage);
@@ -41,7 +36,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
switch (a_Meta)
{
diff --git a/src/Blocks/BlockPlant.h b/src/Blocks/BlockPlant.h
index a0d6ffe52..e99a0b130 100644
--- a/src/Blocks/BlockPlant.h
+++ b/src/Blocks/BlockPlant.h
@@ -14,17 +14,11 @@ class cBlockPlant:
{
using Super = cBlockHandler;
-
public:
- cBlockPlant(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+private:
virtual void OnUpdate(
cChunkInterface & a_ChunkInterface,
@@ -32,7 +26,7 @@ public:
cBlockPluginInterface & a_PluginInterface,
cChunk & a_Chunk,
const Vector3i a_RelPos
- ) override
+ ) const override
{
auto Action = CanGrow(a_Chunk, a_RelPos);
switch (Action)
@@ -74,7 +68,7 @@ protected:
If the plant requires light to grow and there is enough light, it returns paGrowth.
If the plant requires light to grow and there isn't enough light, it returns paStay.
If the plant requires light to grow and there is too little light, it returns paDeath. */
- PlantAction HasEnoughLight(cChunk & a_Chunk, Vector3i a_RelPos)
+ static PlantAction HasEnoughLight(cChunk & a_Chunk, Vector3i a_RelPos)
{
// If the plant requires light to grow, check to see if there is enough light
// Otherwise, return true
@@ -117,7 +111,7 @@ protected:
paDeath is returned when there isn't enough light for the plant to survive.
Plants that don't require light will never have a paDeath returned
*/
- virtual PlantAction CanGrow(cChunk & a_Chunk, Vector3i a_RelPos)
+ virtual PlantAction CanGrow(cChunk & a_Chunk, Vector3i a_RelPos) const
{
// Plant can grow if it has the required amount of light, and it passes a random chance based on surrounding blocks
auto action = HasEnoughLight(a_Chunk, a_RelPos);
@@ -134,7 +128,7 @@ protected:
/** Generates an int value between 4 and 25 based on surrounding blocks that affect how quickly the plant grows.
The higher the value, the less likely the plant is to grow */
- virtual int GetGrowthChance(cChunk & a_Chunk, Vector3i a_RelPos)
+ virtual int GetGrowthChance(cChunk & a_Chunk, Vector3i a_RelPos) const
{
float Chance = 1.0f;
a_RelPos.y -= 1;
@@ -149,10 +143,8 @@ protected:
// If the chunk we are trying to get the block information from is loaded
if (a_Chunk.UnboundedRelGetBlock(a_RelPos + Vector3i(x, 0, z), Block, Meta))
{
- cBlockHandler * Handler = BlockHandler(Block);
-
// If the block affects growth, add to the adjustment
- if (Handler->CanSustainPlant(m_BlockType))
+ if (cBlockHandler::For(Block).CanSustainPlant(m_BlockType))
{
Adjustment = 1.0f;
diff --git a/src/Blocks/BlockPortal.h b/src/Blocks/BlockPortal.h
index c18da10be..e3970bbbb 100644
--- a/src/Blocks/BlockPortal.h
+++ b/src/Blocks/BlockPortal.h
@@ -11,16 +11,12 @@ class cBlockPortalHandler:
public cBlockHandler
{
using Super = cBlockHandler;
-public:
-
- cBlockPortalHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
+public:
+ using Super::Super;
+private:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface,
@@ -29,7 +25,7 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
// We set meta to zero so Cuberite doesn't stop a Creative-mode player from building custom portal shapes
// CanBeAt doesn't do anything if meta is zero
@@ -44,7 +40,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 {};
@@ -60,7 +56,7 @@ public:
cBlockPluginInterface & a_PluginInterface,
cChunk & a_Chunk,
const Vector3i a_RelPos
- ) override
+ ) const override
{
// Spawn zombie pigmen with a 0.05% chance:
if (GetRandomProvider().RandBool(0.9995))
@@ -75,7 +71,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
if ((a_RelPos.y <= 0) || (a_RelPos.y >= cChunkDef::Height - 1))
{
@@ -138,7 +134,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 24;
diff --git a/src/Blocks/BlockPressurePlate.h b/src/Blocks/BlockPressurePlate.h
index 445ec9ff6..3bf0e0861 100644
--- a/src/Blocks/BlockPressurePlate.h
+++ b/src/Blocks/BlockPressurePlate.h
@@ -13,16 +13,11 @@ class cBlockPressurePlateHandler :
public:
- cBlockPressurePlateHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+private:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
if (a_RelPos.y <= 1)
{
@@ -55,7 +50,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
switch (m_BlockType)
diff --git a/src/Blocks/BlockPumpkin.h b/src/Blocks/BlockPumpkin.h
index 81ba080be..d1ca23790 100644
--- a/src/Blocks/BlockPumpkin.h
+++ b/src/Blocks/BlockPumpkin.h
@@ -9,14 +9,14 @@ class cBlockPumpkinHandler :
public cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03>>
{
using Super = cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03>>;
+
public:
- cBlockPumpkinHandler(BLOCKTYPE a_BlockType) :
- Super(a_BlockType)
- {
- }
+ using Super::Super;
+
+private:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 15;
diff --git a/src/Blocks/BlockQuartz.h b/src/Blocks/BlockQuartz.h
index 27d6b9984..cb10cbb04 100644
--- a/src/Blocks/BlockQuartz.h
+++ b/src/Blocks/BlockQuartz.h
@@ -14,14 +14,9 @@ class cBlockQuartzHandler:
public:
- cBlockQuartzHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+private:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface,
@@ -30,7 +25,7 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
a_BlockType = m_BlockType;
auto Meta = static_cast<NIBBLETYPE>(a_Player.GetEquippedItem().m_ItemDamage);
@@ -83,7 +78,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 8;
diff --git a/src/Blocks/BlockRail.h b/src/Blocks/BlockRail.h
index 16e05351d..513ba26c0 100644
--- a/src/Blocks/BlockRail.h
+++ b/src/Blocks/BlockRail.h
@@ -23,14 +23,9 @@ class cBlockRailHandler :
public:
- cBlockRailHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+private:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface,
@@ -39,7 +34,7 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
a_BlockType = m_BlockType;
a_BlockMeta = FindMeta(a_ChunkInterface, a_PlacedBlockPos);
@@ -60,7 +55,7 @@ public:
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface,
Vector3i a_BlockPos,
BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta
- ) override
+ ) const override
{
Super::OnPlaced(a_ChunkInterface, a_WorldInterface, a_BlockPos, a_BlockType, a_BlockMeta);
@@ -83,7 +78,7 @@ public:
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface,
Vector3i a_BlockPos,
BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta
- ) override
+ ) const override
{
Super::OnBroken(a_ChunkInterface, a_WorldInterface, a_BlockPos, a_OldBlockType, a_OldBlockMeta);
@@ -102,7 +97,7 @@ public:
- virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) override
+ virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const override
{
const auto Meta = a_ChunkInterface.GetBlockMeta(a_BlockPos);
const auto NewMeta = FindMeta(a_ChunkInterface, a_BlockPos);
@@ -118,7 +113,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
if (a_RelPos.y <= 0)
{
@@ -163,7 +158,7 @@ public:
- NIBBLETYPE FindMeta(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos)
+ NIBBLETYPE FindMeta(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos) const
{
NIBBLETYPE Meta = 0;
char RailsCnt = 0;
@@ -288,13 +283,13 @@ public:
}
- inline bool CanThisRailCurve(void)
+ bool CanThisRailCurve(void) const
{
return m_BlockType == E_BLOCK_RAIL;
}
- bool IsUnstable(cChunkInterface & a_ChunkInterface, Vector3i a_Pos)
+ static bool IsUnstable(cChunkInterface & a_ChunkInterface, Vector3i a_Pos)
{
if (!IsBlockRail(a_ChunkInterface.GetBlock(a_Pos)))
{
@@ -427,7 +422,7 @@ public:
}
- bool IsNotConnected(cChunkInterface & a_ChunkInterface, Vector3i a_Pos, eBlockFace a_BlockFace, char a_Pure = 0)
+ static bool IsNotConnected(cChunkInterface & a_ChunkInterface, Vector3i a_Pos, eBlockFace a_BlockFace, char a_Pure = 0)
{
AddFaceDirection(a_Pos.x, a_Pos.y, a_Pos.z, a_BlockFace, false);
NIBBLETYPE Meta;
@@ -525,7 +520,7 @@ public:
}
- virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
+ virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) const override
{
// Bit 0x08 is a flag when a_Meta is in the range 0x00--0x05 and 0x0A--0x0F.
// Bit 0x08 specifies direction when a_Meta is in the range 0x06-0x09.
@@ -562,7 +557,7 @@ public:
}
- virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
+ virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) const override
{
// Bit 0x08 is a flag for value in the range 0x00--0x05 and specifies direction for values withint 0x006--0x09.
if ((a_Meta < 0x06) || (a_Meta > 0x09))
@@ -598,7 +593,7 @@ public:
}
- virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
+ virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) const override
{
// MirrorXY basically flips the ZP and ZM parts of the meta
if (m_BlockType == E_BLOCK_RAIL)
@@ -637,7 +632,7 @@ public:
}
- virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
+ virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) const override
{
// MirrorYZ basically flips the XP and XM parts of the meta
if (m_BlockType == E_BLOCK_RAIL)
@@ -676,7 +671,7 @@ public:
}
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 0;
diff --git a/src/Blocks/BlockRedstone.h b/src/Blocks/BlockRedstone.h
index e91c605db..14af7fe8a 100644
--- a/src/Blocks/BlockRedstone.h
+++ b/src/Blocks/BlockRedstone.h
@@ -15,16 +15,11 @@ class cBlockRedstoneHandler:
public:
- cBlockRedstoneHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+private:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
if (a_RelPos.y <= 0)
{
@@ -54,7 +49,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
{
return cItem(E_ITEM_REDSTONE_DUST, 1, 0);
}
@@ -63,7 +58,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 0;
diff --git a/src/Blocks/BlockRedstoneLamp.h b/src/Blocks/BlockRedstoneLamp.h
index 576467c12..1f3016e40 100644
--- a/src/Blocks/BlockRedstoneLamp.h
+++ b/src/Blocks/BlockRedstoneLamp.h
@@ -11,16 +11,12 @@ class cBlockRedstoneLampHandler:
public cBlockHandler
{
public:
- cBlockRedstoneLampHandler(BLOCKTYPE a_BlockType):
- cBlockHandler(a_BlockType)
- {
- }
-
-
+ using cBlockHandler::cBlockHandler;
+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
{
// Always drop the Off variant:
return(cItem(E_BLOCK_REDSTONE_LAMP_OFF, 1, 0));
@@ -30,7 +26,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 15;
diff --git a/src/Blocks/BlockRedstoneOre.h b/src/Blocks/BlockRedstoneOre.h
index 9042d7cc6..bdba531f5 100644
--- a/src/Blocks/BlockRedstoneOre.h
+++ b/src/Blocks/BlockRedstoneOre.h
@@ -26,7 +26,7 @@ public:
const Vector3i a_BlockPos,
eBlockFace a_BlockFace,
const Vector3i a_CursorPos
- ) override
+ ) const override
{
a_ChunkInterface.SetBlock(a_BlockPos, E_BLOCK_REDSTONE_ORE_GLOWING, 0);
return false;
@@ -41,7 +41,7 @@ public:
cWorldInterface & a_WorldInterface,
cPlayer & a_Player,
const Vector3i a_BlockPos
- ) override
+ ) const override
{
a_ChunkInterface.SetBlock(a_BlockPos, E_BLOCK_REDSTONE_ORE_GLOWING, 0);
}
@@ -50,7 +50,7 @@ public:
- virtual bool IsUseable() override
+ virtual bool IsUseable() const override
{
return true;
}
@@ -79,7 +79,7 @@ public:
cBlockPluginInterface & a_BlockPluginInterface,
cChunk & a_Chunk,
const Vector3i a_RelPos
- ) override
+ ) const override
{
auto BlockPos = a_Chunk.RelativeToAbsolute(a_RelPos);
a_ChunkInterface.SetBlock(BlockPos, E_BLOCK_REDSTONE_ORE, 0);
diff --git a/src/Blocks/BlockRedstoneRepeater.h b/src/Blocks/BlockRedstoneRepeater.h
index e0b748821..332f39cea 100644
--- a/src/Blocks/BlockRedstoneRepeater.h
+++ b/src/Blocks/BlockRedstoneRepeater.h
@@ -18,14 +18,49 @@ class cBlockRedstoneRepeaterHandler:
public:
- cBlockRedstoneRepeaterHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
+ using Super::Super;
+
+ inline static Vector3i GetFrontCoordinateOffset(NIBBLETYPE a_Meta)
{
+ return -GetRearCoordinateOffset(a_Meta);
}
+ inline static Vector3i GetLeftCoordinateOffset(NIBBLETYPE a_Meta)
+ {
+ switch (a_Meta & E_META_REDSTONE_REPEATER_FACING_MASK) // We only want the direction (bottom) bits
+ {
+ case E_META_REDSTONE_REPEATER_FACING_ZM: return { -1, 0, 0 };
+ case E_META_REDSTONE_REPEATER_FACING_XP: return { 0, 0, -1 };
+ case E_META_REDSTONE_REPEATER_FACING_ZP: return { 1, 0, 0 };
+ case E_META_REDSTONE_REPEATER_FACING_XM: return { 0, 0, 1 };
+ default:
+ {
+ LOGWARNING("%s: Unknown metadata: %d", __FUNCTION__, a_Meta);
+ ASSERT(!"Unknown metadata while determining orientation of repeater!");
+ return { 0, 0, 0 };
+ }
+ }
+ }
+ inline static Vector3i GetRearCoordinateOffset(NIBBLETYPE a_Meta)
+ {
+ switch (a_Meta & E_META_REDSTONE_REPEATER_FACING_MASK) // We only want the direction (bottom) bits
+ {
+ case E_META_REDSTONE_REPEATER_FACING_ZM: return { 0, 0, 1 };
+ case E_META_REDSTONE_REPEATER_FACING_XP: return { -1, 0, 0 };
+ case E_META_REDSTONE_REPEATER_FACING_ZP: return { 0, 0, -1 };
+ case E_META_REDSTONE_REPEATER_FACING_XM: return { 1, 0, 0 };
+ default:
+ {
+ LOGWARNING("%s: Unknown metadata: %d", __FUNCTION__, a_Meta);
+ ASSERT(!"Unknown metadata while determining orientation of repeater!");
+ return { 0, 0, 0 };
+ }
+ }
+ }
+private:
virtual bool OnUse(
cChunkInterface & a_ChunkInterface,
@@ -34,7 +69,7 @@ public:
const Vector3i a_BlockPos,
eBlockFace a_BlockFace,
const Vector3i a_CursorPos
- ) override
+ ) const override
{
// Increment the delay setting:
a_ChunkInterface.SetBlockMeta(a_BlockPos, ((a_ChunkInterface.GetBlockMeta(a_BlockPos) + 0x04) & 0x0f));
@@ -51,7 +86,7 @@ public:
cPlayer & a_Player,
const Vector3i a_BlockPos,
eBlockFace a_BlockFace
- ) override
+ ) const override
{
UNUSED(a_ChunkInterface);
a_WorldInterface.SendBlockTo(a_BlockPos, a_Player);
@@ -61,7 +96,7 @@ public:
- virtual bool IsUseable(void) override
+ virtual bool IsUseable(void) const override
{
return true;
}
@@ -70,7 +105,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
if (a_RelPos.y <= 0)
{
@@ -100,7 +135,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
{
return cItem(E_ITEM_REDSTONE_REPEATER, 1, 0);
}
@@ -109,62 +144,11 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 11;
}
-
-
-
-
-
- inline static Vector3i GetLeftCoordinateOffset(NIBBLETYPE a_Meta)
- {
- switch (a_Meta & E_META_REDSTONE_REPEATER_FACING_MASK) // We only want the direction (bottom) bits
- {
- case E_META_REDSTONE_REPEATER_FACING_ZM: return { -1, 0, 0 };
- case E_META_REDSTONE_REPEATER_FACING_XP: return { 0, 0, -1 };
- case E_META_REDSTONE_REPEATER_FACING_ZP: return { 1, 0, 0 };
- case E_META_REDSTONE_REPEATER_FACING_XM: return { 0, 0, 1 };
-
- default:
- {
- LOGWARNING("%s: Unknown metadata: %d", __FUNCTION__, a_Meta);
- ASSERT(!"Unknown metadata while determining orientation of repeater!");
- return { 0, 0, 0 };
- }
- }
- }
-
-
-
-
- inline static Vector3i GetFrontCoordinateOffset(NIBBLETYPE a_Meta)
- {
- return -GetRearCoordinateOffset(a_Meta);
- }
-
-
-
-
-
- inline static Vector3i GetRearCoordinateOffset(NIBBLETYPE a_Meta)
- {
- switch (a_Meta & E_META_REDSTONE_REPEATER_FACING_MASK) // We only want the direction (bottom) bits
- {
- case E_META_REDSTONE_REPEATER_FACING_ZM: return { 0, 0, 1 };
- case E_META_REDSTONE_REPEATER_FACING_XP: return { -1, 0, 0 };
- case E_META_REDSTONE_REPEATER_FACING_ZP: return { 0, 0, -1 };
- case E_META_REDSTONE_REPEATER_FACING_XM: return { 1, 0, 0 };
- default:
- {
- LOGWARNING("%s: Unknown metadata: %d", __FUNCTION__, a_Meta);
- ASSERT(!"Unknown metadata while determining orientation of repeater!");
- return { 0, 0, 0 };
- }
- }
- }
} ;
diff --git a/src/Blocks/BlockRedstoneTorch.h b/src/Blocks/BlockRedstoneTorch.h
index 22a3cf52d..d26b0bd8a 100644
--- a/src/Blocks/BlockRedstoneTorch.h
+++ b/src/Blocks/BlockRedstoneTorch.h
@@ -14,16 +14,11 @@ class cBlockRedstoneTorchHandler :
public:
- cBlockRedstoneTorchHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+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
{
// Always drop the ON torch, meta 0
return cItem(E_BLOCK_REDSTONE_TORCH_ON, 1, 0);
@@ -33,7 +28,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 0;
diff --git a/src/Blocks/BlockSand.h b/src/Blocks/BlockSand.h
index 30d5ae59d..9011766c5 100644
--- a/src/Blocks/BlockSand.h
+++ b/src/Blocks/BlockSand.h
@@ -11,18 +11,14 @@ class cBlockSandHandler :
public cBlockHandler
{
public:
- cBlockSandHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
- {
- }
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ using cBlockHandler::cBlockHandler;
+
+private:
+
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 2;
}
};
-
-
-
-
diff --git a/src/Blocks/BlockSapling.h b/src/Blocks/BlockSapling.h
index e52ae5fc7..3ee48b1ed 100644
--- a/src/Blocks/BlockSapling.h
+++ b/src/Blocks/BlockSapling.h
@@ -15,16 +15,11 @@ class cBlockSaplingHandler :
public:
- cBlockSaplingHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+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
{
// The low 3 bits store the sapling type; bit 0x08 is the growth timer (not used in pickups)
return cItem(m_BlockType, 1, a_BlockMeta & 0x07);
@@ -34,7 +29,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
return (a_RelPos.y > 0) && IsBlockTypeOfDirt(a_Chunk.GetBlock(a_RelPos.addedY(-1)));
}
@@ -49,7 +44,7 @@ public:
cBlockPluginInterface & a_PluginInterface,
cChunk & a_Chunk,
const Vector3i a_RelPos
- ) override
+ ) const override
{
auto Meta = a_Chunk.GetMeta(a_RelPos);
auto Light = std::max(a_Chunk.GetBlockLight(a_RelPos), a_Chunk.GetTimeAlteredLight(a_Chunk.GetSkyLight(a_RelPos)));
@@ -76,7 +71,7 @@ public:
- bool CanGrowAt(cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta)
+ static bool CanGrowAt(cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta)
{
a_Meta = a_Meta & 0x07;
int CheckHeight = 0;
@@ -190,7 +185,7 @@ public:
- virtual int Grow(cChunk & a_Chunk, Vector3i a_RelPos, int a_NumStages = 1) override
+ virtual int Grow(cChunk & a_Chunk, Vector3i a_RelPos, int a_NumStages = 1) const override
{
auto blockMeta = a_Chunk.GetMeta(a_RelPos);
auto typeMeta = blockMeta & 0x07;
@@ -219,19 +214,13 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 7;
}
-
-
-
-
-private:
-
- bool IsLargeTree(cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta)
+ static bool IsLargeTree(cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta)
{
BLOCKTYPE type;
NIBBLETYPE meta;
diff --git a/src/Blocks/BlockSeaLantern.h b/src/Blocks/BlockSeaLantern.h
index 5ec671f07..c24476e0b 100644
--- a/src/Blocks/BlockSeaLantern.h
+++ b/src/Blocks/BlockSeaLantern.h
@@ -14,23 +14,14 @@ class cBlockSeaLanternHandler :
public:
- cBlockSeaLanternHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+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 meta to 0
// TODO: Handle the Fortune enchantment
return cItem(E_ITEM_PRISMARINE_CRYSTALS, GetRandomProvider().RandInt<char>(2, 3), 0);
}
} ;
-
-
-
-
diff --git a/src/Blocks/BlockSideways.h b/src/Blocks/BlockSideways.h
index b94b9f8f3..c846c5543 100644
--- a/src/Blocks/BlockSideways.h
+++ b/src/Blocks/BlockSideways.h
@@ -17,14 +17,9 @@ class cBlockSidewaysHandler:
public:
- cBlockSidewaysHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+private:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface,
@@ -33,7 +28,7 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
a_BlockType = m_BlockType;
NIBBLETYPE Meta = static_cast<NIBBLETYPE>(a_Player.GetEquippedItem().m_ItemDamage);
@@ -45,7 +40,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
{
// Reset the orientation part of meta, keep the sub-type part of meta
return cItem(m_BlockType, 1, a_BlockMeta & 0x03);
diff --git a/src/Blocks/BlockSignPost.h b/src/Blocks/BlockSignPost.h
index f493cb355..717a85ecf 100644
--- a/src/Blocks/BlockSignPost.h
+++ b/src/Blocks/BlockSignPost.h
@@ -15,15 +15,25 @@ class cBlockSignPostHandler:
public:
- cBlockSignPostHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
+ using Super::Super;
+
+ /** Converts the (player) rotation to placed-signpost block meta. */
+ static NIBBLETYPE RotationToMetaData(double a_Rotation)
{
- }
+ a_Rotation += 180 + (180 / 16); // So it's not aligned with axis
+ if (a_Rotation > 360)
+ {
+ a_Rotation -= 360;
+ }
+ a_Rotation = (a_Rotation / 360) * 16;
+ return (static_cast<char>(a_Rotation)) % 16;
+ }
+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
{
return cItem(E_ITEM_SIGN, 1, 0);
}
@@ -32,7 +42,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
if (a_RelPos.y <= 0)
{
@@ -46,25 +56,7 @@ public:
- /** Converts the (player) rotation to placed-signpost block meta. */
- static NIBBLETYPE RotationToMetaData(double a_Rotation)
- {
- a_Rotation += 180 + (180 / 16); // So it's not aligned with axis
- if (a_Rotation > 360)
- {
- a_Rotation -= 360;
- }
-
- a_Rotation = (a_Rotation / 360) * 16;
-
- return (static_cast<char>(a_Rotation)) % 16;
- }
-
-
-
-
-
- virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
+ virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) const override
{
return (a_Meta + 4) & 0x0f;
}
@@ -73,7 +65,7 @@ public:
- virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
+ virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) const override
{
return (a_Meta + 12) & 0x0f;
}
@@ -82,7 +74,7 @@ public:
- virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
+ virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) const override
{
// Mirrors signs over the XY plane (North-South Mirroring)
@@ -95,7 +87,7 @@ public:
- virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
+ virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) const override
{
// Mirrors signs over the YZ plane (East-West Mirroring)
@@ -108,7 +100,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 13;
diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h
index c59dc6f06..0f6b0442f 100644
--- a/src/Blocks/BlockSlab.h
+++ b/src/Blocks/BlockSlab.h
@@ -24,16 +24,22 @@ class cBlockSlabHandler :
public:
- cBlockSlabHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
+ using Super::Super;
+
+ /** Returns true if the specified blocktype is one of the slabs handled by this handler */
+ static bool IsAnySlabType(BLOCKTYPE a_BlockType)
{
+ return (
+ (a_BlockType == E_BLOCK_WOODEN_SLAB) ||
+ (a_BlockType == E_BLOCK_STONE_SLAB) ||
+ (a_BlockType == E_BLOCK_RED_SANDSTONE_SLAB) ||
+ (a_BlockType == E_BLOCK_PURPUR_SLAB)
+ );
}
+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 "top half" flag:
return cItem(m_BlockType, 1, a_BlockMeta & 0x07);
@@ -50,7 +56,7 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
a_BlockType = m_BlockType;
NIBBLETYPE Meta = static_cast<NIBBLETYPE>(a_Player.GetEquippedItem().m_ItemDamage);
@@ -104,28 +110,13 @@ public:
- /** Returns true if the specified blocktype is one of the slabs handled by this handler */
- static bool IsAnySlabType(BLOCKTYPE a_BlockType)
- {
- return (
- (a_BlockType == E_BLOCK_WOODEN_SLAB) ||
- (a_BlockType == E_BLOCK_STONE_SLAB) ||
- (a_BlockType == E_BLOCK_RED_SANDSTONE_SLAB) ||
- (a_BlockType == E_BLOCK_PURPUR_SLAB)
- );
- }
-
-
-
-
-
virtual void OnCancelRightClick(
cChunkInterface & a_ChunkInterface,
cWorldInterface & a_WorldInterface,
cPlayer & a_Player,
const Vector3i a_BlockPos,
eBlockFace a_BlockFace
- ) override
+ ) const override
{
if ((a_BlockFace == BLOCK_FACE_NONE) || (a_Player.GetEquippedItem().m_ItemType != static_cast<short>(m_BlockType)))
{
@@ -158,7 +149,7 @@ public:
- virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override
+ virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) const override
{
// Toggle the 4th bit - up / down:
return (a_Meta ^ 0x08);
@@ -168,7 +159,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
a_Meta &= 0x7;
@@ -230,7 +221,7 @@ public:
- virtual bool IsInsideBlock(Vector3d a_Position, const NIBBLETYPE a_BlockMeta) override
+ virtual bool IsInsideBlock(Vector3d a_Position, const NIBBLETYPE a_BlockMeta) const override
{
if (a_BlockMeta & 0x08) // top half
{
@@ -251,16 +242,11 @@ class cBlockDoubleSlabHandler:
public:
- cBlockDoubleSlabHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+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
{
BLOCKTYPE Block = GetSingleSlabType(m_BlockType);
return cItem(Block, 2, a_BlockMeta & 0x7);
@@ -287,10 +273,10 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
// For doule slabs, the meta values are the same. Only the meaning of the 4th bit changes, but that's ignored in the below handler
- return BlockHandler(GetSingleSlabType(m_BlockType))->GetMapBaseColourID(a_Meta);
+ return cBlockHandler::For(GetSingleSlabType(m_BlockType)).GetMapBaseColourID(a_Meta);
}
} ;
diff --git a/src/Blocks/BlockSlime.h b/src/Blocks/BlockSlime.h
index bbf28fa16..87a2faa05 100644
--- a/src/Blocks/BlockSlime.h
+++ b/src/Blocks/BlockSlime.h
@@ -9,26 +9,15 @@
class cBlockSlimeHandler:
public cClearMetaOnDrop<cBlockHandler>
{
- using super = cClearMetaOnDrop<cBlockHandler>;
-
public:
- cBlockSlimeHandler(BLOCKTYPE a_BlockType):
- super(a_BlockType)
- {
- }
-
-
+ using cClearMetaOnDrop<cBlockHandler>::cClearMetaOnDrop;
+private:
-
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 1;
}
};
-
-
-
-
diff --git a/src/Blocks/BlockSnow.h b/src/Blocks/BlockSnow.h
index 9b9ee85c0..527d2c3b4 100644
--- a/src/Blocks/BlockSnow.h
+++ b/src/Blocks/BlockSnow.h
@@ -14,21 +14,15 @@ class cBlockSnowHandler :
public:
+ using Super::Super;
+
+private:
+
enum
{
FullBlockMeta = 7 // Meta value of a full-height snow block
};
-
- cBlockSnowHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
-
-
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface,
cPlayer & a_Player,
@@ -36,7 +30,7 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
a_BlockType = m_BlockType;
@@ -68,7 +62,7 @@ public:
- virtual bool DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface, Vector3i a_Pos, cPlayer & a_Player, NIBBLETYPE a_Meta) override
+ virtual bool DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface, Vector3i a_Pos, cPlayer & a_Player, NIBBLETYPE a_Meta) const override
{
if ((a_Player.GetEquippedItem().m_ItemType == E_BLOCK_SNOW) && (a_Meta < FullBlockMeta))
{
@@ -87,7 +81,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 drop unless dug up with a shovel
if ((a_Tool == nullptr) || !ItemCategory::IsShovel(a_Tool->m_ItemType))
@@ -110,7 +104,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
if (a_RelPos.y <= 0)
{
@@ -126,7 +120,7 @@ public:
- virtual bool DoesDropOnUnsuitable(void) override
+ virtual bool DoesDropOnUnsuitable(void) const override
{
return false;
}
@@ -135,7 +129,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 14;
@@ -145,7 +139,7 @@ public:
- virtual bool IsInsideBlock(const Vector3d a_RelPosition, const NIBBLETYPE a_BlockMeta) override
+ virtual bool IsInsideBlock(const Vector3d a_RelPosition, const NIBBLETYPE a_BlockMeta) const override
{
return a_RelPosition.y < (cBlockInfo::GetBlockHeight(m_BlockType) * (a_BlockMeta & 0x07));
}
diff --git a/src/Blocks/BlockSponge.h b/src/Blocks/BlockSponge.h
index 2ef078ea1..097b89cf9 100644
--- a/src/Blocks/BlockSponge.h
+++ b/src/Blocks/BlockSponge.h
@@ -14,21 +14,20 @@ class cBlockSpongeHandler :
public:
- cBlockSpongeHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
+ using Super::Super;
+
+private:
virtual void OnPlaced(
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface,
Vector3i a_BlockPos,
BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta
- ) override
+ ) const override
{
OnNeighborChanged(a_ChunkInterface, a_BlockPos, BLOCK_FACE_NONE);
}
- virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) override
+ virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const override
{
a_ChunkInterface.DoWithChunkAt(a_BlockPos, [&](cChunk & a_Chunk) { CheckSoaked(a_Chunk.AbsoluteToRelative(a_BlockPos), a_Chunk); return true; });
}
@@ -36,7 +35,7 @@ public:
/** Check blocks around the sponge to see if they are water.
If a dry sponge is touching water, soak up up to 65 blocks of water,
with a taxicab distance of 7, and turn the sponge into a wet sponge. */
- void CheckSoaked(Vector3i a_Rel, cChunk & a_Chunk)
+ static void CheckSoaked(Vector3i a_Rel, cChunk & a_Chunk)
{
struct sSeed
{
@@ -117,7 +116,7 @@ public:
return(a_Chunk.UnboundedRelGetBlockType(a_Rel.x, a_Rel.y, a_Rel.z, Type) && IsBlockWater(Type));
}
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 18;
diff --git a/src/Blocks/BlockStairs.h b/src/Blocks/BlockStairs.h
index d616f5d67..be86faa1b 100644
--- a/src/Blocks/BlockStairs.h
+++ b/src/Blocks/BlockStairs.h
@@ -14,14 +14,9 @@ class cBlockStairsHandler :
public:
- cBlockStairsHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+private:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface,
@@ -30,7 +25,7 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
UNUSED(a_ChunkInterface);
UNUSED(a_PlacedBlockPos);
@@ -91,7 +86,7 @@ public:
- virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override
+ virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) const override
{
// Toggle bit 3:
return (a_Meta & 0x0b) | ((~a_Meta) & 0x04);
@@ -101,7 +96,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
switch (m_BlockType)
diff --git a/src/Blocks/BlockStems.h b/src/Blocks/BlockStems.h
index 0e4b01c5a..1742fe7e4 100644
--- a/src/Blocks/BlockStems.h
+++ b/src/Blocks/BlockStems.h
@@ -18,16 +18,11 @@ class cBlockStemsHandler:
public:
- cBlockStemsHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+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
{
return cItem(StemPickupType, 1, 0);
}
@@ -36,7 +31,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
return ((a_RelPos.y > 0) && (a_Chunk.GetBlock(a_RelPos.addedY(-1)) == E_BLOCK_FARMLAND));
}
@@ -45,7 +40,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 7;
@@ -55,7 +50,7 @@ public:
- virtual int Grow(cChunk & a_Chunk, Vector3i a_RelPos, int a_NumStages = 1) override
+ virtual int Grow(cChunk & a_Chunk, Vector3i a_RelPos, int a_NumStages = 1) const override
{
auto oldMeta = a_Chunk.GetMeta(a_RelPos);
auto meta = oldMeta + a_NumStages;
@@ -74,14 +69,9 @@ public:
return meta - oldMeta;
}
-
-
-
-protected:
-
/** Grows the final produce next to the stem at the specified pos.
Returns true if successful, false if not. */
- bool growProduce(cChunk & a_Chunk, Vector3i a_StemRelPos)
+ static bool growProduce(cChunk & a_Chunk, Vector3i a_StemRelPos)
{
auto & random = GetRandomProvider();
diff --git a/src/Blocks/BlockStone.h b/src/Blocks/BlockStone.h
index 9da61c263..910473623 100644
--- a/src/Blocks/BlockStone.h
+++ b/src/Blocks/BlockStone.h
@@ -13,16 +13,11 @@ class cBlockStoneHandler:
public:
- cBlockStoneHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+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
{
// Convert stone to cobblestone, unless using silk-touch:
if (
@@ -39,7 +34,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 11;
diff --git a/src/Blocks/BlockSugarcane.h b/src/Blocks/BlockSugarcane.h
index fa153bd28..49cf9db07 100644
--- a/src/Blocks/BlockSugarcane.h
+++ b/src/Blocks/BlockSugarcane.h
@@ -14,16 +14,11 @@ class cBlockSugarcaneHandler :
public:
- cBlockSugarcaneHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+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
{
return cItem(E_ITEM_SUGARCANE, 1, 0);
}
@@ -32,7 +27,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
if (a_RelPos.y <= 0)
{
@@ -82,7 +77,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 7;
@@ -92,7 +87,7 @@ public:
- virtual int Grow(cChunk & a_Chunk, Vector3i a_RelPos, int a_NumStages = 1) override
+ virtual int Grow(cChunk & a_Chunk, Vector3i a_RelPos, int a_NumStages = 1) const override
{
// Check the total height of the sugarcane blocks here:
int top = a_RelPos.y + 1;
@@ -129,13 +124,7 @@ public:
return toGrow;
}
-
-
-
-
-protected:
-
- virtual PlantAction CanGrow(cChunk & a_Chunk, Vector3i a_RelPos) override
+ virtual PlantAction CanGrow(cChunk & a_Chunk, Vector3i a_RelPos) const override
{
// Only allow growing if there's an air block above:
if (((a_RelPos.y + 1) < cChunkDef::Height) && (a_Chunk.GetBlock(a_RelPos.addedY(1)) == E_BLOCK_AIR))
diff --git a/src/Blocks/BlockTNT.h b/src/Blocks/BlockTNT.h
index fafa289da..ed478ce94 100644
--- a/src/Blocks/BlockTNT.h
+++ b/src/Blocks/BlockTNT.h
@@ -14,14 +14,9 @@ class cBlockTNTHandler :
public:
- cBlockTNTHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+private:
virtual void OnCancelRightClick(
cChunkInterface & a_ChunkInterface,
@@ -29,7 +24,7 @@ public:
cPlayer & a_Player,
const Vector3i a_BlockPos,
eBlockFace a_BlockFace
- ) override
+ ) const override
{
a_WorldInterface.SendBlockTo(a_BlockPos, a_Player);
}
@@ -38,7 +33,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 4;
diff --git a/src/Blocks/BlockTallGrass.h b/src/Blocks/BlockTallGrass.h
index 4cf115efd..2ae6e1910 100644
--- a/src/Blocks/BlockTallGrass.h
+++ b/src/Blocks/BlockTallGrass.h
@@ -16,16 +16,11 @@ class cBlockTallGrassHandler:
public:
- cBlockTallGrassHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+private:
- virtual bool DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface, Vector3i a_Pos, cPlayer & a_Player, NIBBLETYPE a_Meta) override
+ virtual bool DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface, Vector3i a_Pos, cPlayer & a_Player, NIBBLETYPE a_Meta) const override
{
return true;
}
@@ -34,7 +29,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
{
// If using shears, drop self:
if ((a_Tool != nullptr) && (a_Tool->m_ItemType == E_ITEM_SHEARS))
@@ -54,7 +49,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
if (a_RelPos.y <= 0)
{
@@ -70,7 +65,7 @@ public:
/** Growing a tall grass produces a big flower (2-block high fern or double-tall grass). */
- virtual int Grow(cChunk & a_Chunk, Vector3i a_RelPos, int a_NumStages = 1) override
+ virtual int Grow(cChunk & a_Chunk, Vector3i a_RelPos, int a_NumStages = 1) const override
{
if (a_RelPos.y > (cChunkDef::Height - 2))
{
@@ -93,7 +88,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 7;
diff --git a/src/Blocks/BlockTorch.h b/src/Blocks/BlockTorch.h
index e2a2dfcc9..a3ded9369 100644
--- a/src/Blocks/BlockTorch.h
+++ b/src/Blocks/BlockTorch.h
@@ -15,14 +15,9 @@ class cBlockTorchHandler:
public:
- cBlockTorchHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+private:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface,
@@ -31,7 +26,7 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
BLOCKTYPE ClickedBlockType;
NIBBLETYPE ClickedBlockMeta;
@@ -190,7 +185,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
auto Face = MetaDataToBlockFace(a_Chunk.GetMeta(a_RelPos));
auto NeighborRelPos = AddFaceDirection(a_RelPos, Face, true);
@@ -209,7 +204,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 0;
diff --git a/src/Blocks/BlockTrapdoor.h b/src/Blocks/BlockTrapdoor.h
index f0c821764..dce246dea 100644
--- a/src/Blocks/BlockTrapdoor.h
+++ b/src/Blocks/BlockTrapdoor.h
@@ -15,15 +15,11 @@ class cBlockTrapdoorHandler :
public:
- cBlockTrapdoorHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
+ using Super::Super;
+private:
- virtual bool IsUseable(void) override
+ virtual bool IsUseable(void) const override
{
return true;
}
@@ -39,7 +35,7 @@ public:
const Vector3i a_BlockPos,
eBlockFace a_BlockFace,
const Vector3i a_CursorPos
- ) override
+ ) const override
{
if (m_BlockType == E_BLOCK_IRON_TRAPDOOR)
{
@@ -65,7 +61,7 @@ public:
cPlayer & a_Player,
const Vector3i a_BlockPos,
eBlockFace a_BlockFace
- ) override
+ ) const override
{
UNUSED(a_ChunkInterface);
a_WorldInterface.SendBlockTo(a_BlockPos, a_Player);
@@ -82,7 +78,7 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
a_BlockType = m_BlockType;
a_BlockMeta = BlockFaceToMetaData(a_ClickedBlockFace);
@@ -141,7 +137,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
switch (m_BlockType)
diff --git a/src/Blocks/BlockTripwire.h b/src/Blocks/BlockTripwire.h
index f2fe31a96..b818a3628 100644
--- a/src/Blocks/BlockTripwire.h
+++ b/src/Blocks/BlockTripwire.h
@@ -14,16 +14,11 @@ class cBlockTripwireHandler :
public:
- cBlockTripwireHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+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
{
return cItem(E_ITEM_STRING, 1, 0);
}
@@ -32,7 +27,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 0;
diff --git a/src/Blocks/BlockTripwireHook.h b/src/Blocks/BlockTripwireHook.h
index f28b94b46..466ca2502 100644
--- a/src/Blocks/BlockTripwireHook.h
+++ b/src/Blocks/BlockTripwireHook.h
@@ -14,14 +14,21 @@ class cBlockTripwireHookHandler :
public:
- cBlockTripwireHookHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
+ using Super::Super;
+
+ inline static eBlockFace MetadataToDirection(NIBBLETYPE a_Meta)
{
+ switch (a_Meta & 0x03)
+ {
+ case 0x1: return BLOCK_FACE_XM;
+ case 0x3: return BLOCK_FACE_XP;
+ case 0x2: return BLOCK_FACE_ZM;
+ case 0x0: return BLOCK_FACE_ZP;
+ default: ASSERT(!"Unhandled tripwire hook metadata!"); return BLOCK_FACE_NONE;
+ }
}
-
-
-
+private:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface,
@@ -30,7 +37,7 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
a_BlockType = m_BlockType;
@@ -71,23 +78,7 @@ public:
- inline static eBlockFace MetadataToDirection(NIBBLETYPE a_Meta)
- {
- switch (a_Meta & 0x03)
- {
- case 0x1: return BLOCK_FACE_XM;
- case 0x3: return BLOCK_FACE_XP;
- case 0x2: return BLOCK_FACE_ZM;
- case 0x0: return BLOCK_FACE_ZP;
- default: ASSERT(!"Unhandled tripwire hook metadata!"); return BLOCK_FACE_NONE;
- }
- }
-
-
-
-
-
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
const auto Meta = a_Chunk.GetMeta(a_RelPos);
const auto RearPosition = AddFaceDirection(a_RelPos, MetadataToDirection(Meta), true);
@@ -105,7 +96,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 0;
diff --git a/src/Blocks/BlockVine.h b/src/Blocks/BlockVine.h
index 25b6efe47..b652a2498 100644
--- a/src/Blocks/BlockVine.h
+++ b/src/Blocks/BlockVine.h
@@ -13,14 +13,9 @@ class cBlockVineHandler :
public:
- cBlockVineHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+private:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface,
@@ -29,7 +24,7 @@ public:
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
- ) override
+ ) const override
{
// TODO: Disallow placement where the vine doesn't attach to something properly
BLOCKTYPE BlockType = 0;
@@ -51,7 +46,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
{
// Only drops self when using shears, otherwise drops nothing:
if ((a_Tool == nullptr) || (a_Tool->m_ItemType != E_ITEM_SHEARS))
@@ -128,7 +123,7 @@ public:
/** Returns the meta that has the maximum allowable sides of the vine, given the surroundings */
- NIBBLETYPE GetMaxMeta(cChunk & a_Chunk, Vector3i a_RelPos)
+ static NIBBLETYPE GetMaxMeta(cChunk & a_Chunk, Vector3i a_RelPos)
{
static const struct
{
@@ -162,7 +157,7 @@ public:
- virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) override
+ virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const override
{
a_ChunkInterface.DoWithChunkAt(a_BlockPos, [&](cChunk & a_Chunk)
{
@@ -203,7 +198,7 @@ public:
- virtual bool DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface, Vector3i a_Pos, cPlayer & a_Player, NIBBLETYPE a_Meta) override
+ virtual bool DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface, Vector3i a_Pos, cPlayer & a_Player, NIBBLETYPE a_Meta) const override
{
return true;
}
@@ -212,7 +207,7 @@ public:
- virtual bool DoesDropOnUnsuitable(void) override
+ virtual bool DoesDropOnUnsuitable(void) const override
{
return false;
}
@@ -227,7 +222,7 @@ public:
cBlockPluginInterface & a_PluginInterface,
cChunk & a_Chunk,
const Vector3i a_RelPos
- ) override
+ ) const override
{
UNUSED(a_ChunkInterface);
UNUSED(a_WorldInterface);
@@ -256,7 +251,7 @@ public:
- virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
+ virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) const override
{
return ((a_Meta >> 1) | (a_Meta << 3)) & 0x0f; // Rotate bits to the right
}
@@ -265,7 +260,7 @@ public:
- virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
+ virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) const override
{
return ((a_Meta << 1) | (a_Meta >> 3)) & 0x0f; // Rotate bits to the left
}
@@ -274,7 +269,7 @@ public:
- virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
+ virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) const override
{
// Bits 2 and 4 stay, bits 1 and 3 swap
return static_cast<NIBBLETYPE>((a_Meta & 0x0a) | ((a_Meta & 0x01) << 2) | ((a_Meta & 0x04) >> 2));
@@ -284,7 +279,7 @@ public:
- virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
+ virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) const override
{
// Bits 1 and 3 stay, bits 2 and 4 swap
return static_cast<NIBBLETYPE>((a_Meta & 0x05) | ((a_Meta & 0x02) << 2) | ((a_Meta & 0x08) >> 2));
@@ -294,7 +289,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 7;
diff --git a/src/Blocks/BlockWallSign.h b/src/Blocks/BlockWallSign.h
index 87c0355a9..1e9ea2e1f 100644
--- a/src/Blocks/BlockWallSign.h
+++ b/src/Blocks/BlockWallSign.h
@@ -15,16 +15,30 @@ class cBlockWallSignHandler:
public:
- cBlockWallSignHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
+ using Super::Super;
+
+ /** Converts the block face of the neighbor to which the wallsign is attached to the wallsign block's meta. */
+ static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_NeighborBlockFace)
{
+ switch (a_NeighborBlockFace)
+ {
+ case BLOCK_FACE_ZM: return 0x02;
+ case BLOCK_FACE_ZP: return 0x03;
+ case BLOCK_FACE_XM: return 0x04;
+ case BLOCK_FACE_XP: return 0x05;
+ case BLOCK_FACE_NONE:
+ case BLOCK_FACE_YP:
+ case BLOCK_FACE_YM:
+ {
+ break;
+ }
+ }
+ return 0x02;
}
+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
{
return cItem(E_ITEM_SIGN, 1, 0);
}
@@ -33,7 +47,7 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
{
auto NeighborPos = a_RelPos + GetOffsetBehindTheSign(a_Chunk.GetMeta(a_RelPos));
BLOCKTYPE NeighborType;
@@ -68,30 +82,7 @@ public:
- /** Converts the block face of the neighbor to which the wallsign is attached to the wallsign block's meta. */
- static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_NeighborBlockFace)
- {
- switch (a_NeighborBlockFace)
- {
- case BLOCK_FACE_ZM: return 0x02;
- case BLOCK_FACE_ZP: return 0x03;
- case BLOCK_FACE_XM: return 0x04;
- case BLOCK_FACE_XP: return 0x05;
- case BLOCK_FACE_NONE:
- case BLOCK_FACE_YP:
- case BLOCK_FACE_YM:
- {
- break;
- }
- }
- return 0x02;
- }
-
-
-
-
-
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 13;
diff --git a/src/Blocks/BlockWorkbench.h b/src/Blocks/BlockWorkbench.h
index 329a1ddeb..5b1e8705b 100644
--- a/src/Blocks/BlockWorkbench.h
+++ b/src/Blocks/BlockWorkbench.h
@@ -16,14 +16,9 @@ class cBlockWorkbenchHandler:
public:
- cBlockWorkbenchHandler(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+private:
virtual bool OnUse(
cChunkInterface & a_ChunkInterface,
@@ -32,7 +27,7 @@ public:
const Vector3i a_BlockPos,
eBlockFace a_BlockFace,
const Vector3i a_CursorPos
- ) override
+ ) const override
{
a_Player.GetStatManager().AddValue(Statistic::InteractWithCraftingTable);
@@ -45,7 +40,7 @@ public:
- virtual bool IsUseable(void) override
+ virtual bool IsUseable(void) const override
{
return true;
}
@@ -54,7 +49,7 @@ public:
- virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 13;
diff --git a/src/Blocks/ChunkInterface.cpp b/src/Blocks/ChunkInterface.cpp
index f497b94a0..3af085c2a 100644
--- a/src/Blocks/ChunkInterface.cpp
+++ b/src/Blocks/ChunkInterface.cpp
@@ -6,7 +6,6 @@
#include "WorldInterface.h"
#include "../ChunkMap.h"
#include "../World.h"
-#include "../BlockInfo.h"
@@ -113,7 +112,7 @@ bool cChunkInterface::DigBlock(cWorldInterface & a_WorldInterface, Vector3i a_Bl
return false;
}
- cBlockInfo::GetHandler(BlockType)->OnBroken(*this, a_WorldInterface, a_BlockPos, BlockType, BlockMeta);
+ cBlockHandler::For(BlockType).OnBroken(*this, a_WorldInterface, a_BlockPos, BlockType, BlockMeta);
return true;
}
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)
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index 3abdc6ff8..a2dd73b51 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -706,11 +706,9 @@ void cChunk::Tick(std::chrono::milliseconds a_Dt)
void cChunk::TickBlock(const Vector3i a_RelPos)
{
- cBlockHandler * Handler = BlockHandler(GetBlock(a_RelPos));
- ASSERT(Handler != nullptr); // Happenned on server restart, FS #243
cChunkInterface ChunkInterface(this->GetWorld()->GetChunkMap());
cBlockInServerPluginInterface PluginInterface(*this->GetWorld());
- Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface, *this, a_RelPos);
+ cBlockHandler::For(GetBlock(a_RelPos)).OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface, *this, a_RelPos);
}
@@ -802,8 +800,7 @@ void cChunk::CheckBlocks()
m_ToTickBlocks.pop();
Count--;
- cBlockHandler * Handler = BlockHandler(GetBlock(Pos));
- Handler->Check(ChunkInterface, PluginInterface, Pos, *this);
+ cBlockHandler::For(GetBlock(Pos)).Check(ChunkInterface, PluginInterface, Pos, *this);
}
}
@@ -827,9 +824,7 @@ void cChunk::TickBlocks(void)
continue; // It's all air up here
}
- cBlockHandler * Handler = BlockHandler(GetBlock(Pos));
- ASSERT(Handler != nullptr); // Happenned on server restart, FS #243
- Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface, *this, Pos);
+ cBlockHandler::For(GetBlock(Pos)).OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface, *this, Pos);
} // for i
// Set a new random coord for the next tick:
@@ -938,14 +933,13 @@ cItems cChunk::PickupsFromBlock(Vector3i a_RelPos, const cEntity * a_Digger, con
BLOCKTYPE blockType;
NIBBLETYPE blockMeta;
GetBlockTypeMeta(a_RelPos, blockType, blockMeta);
- auto blockHandler = cBlockInfo::GetHandler(blockType);
auto blockEntity = GetBlockEntityRel(a_RelPos);
cItems pickups (0);
auto toolHandler = a_Tool ? a_Tool->GetHandler() : cItemHandler::GetItemHandler(E_ITEM_EMPTY);
auto canHarvestBlock = toolHandler->CanHarvestBlock(blockType);
if (canHarvestBlock)
{
- pickups = blockHandler->ConvertToPickups(blockMeta, blockEntity, a_Digger, a_Tool);
+ pickups = cBlockHandler::For(blockType).ConvertToPickups(blockMeta, blockEntity, a_Digger, a_Tool);
}
auto absPos = RelativeToAbsolute(a_RelPos);
cRoot::Get()->GetPluginManager()->CallHookBlockToPickups(*m_World, absPos, blockType, blockMeta, blockEntity, a_Digger, a_Tool, pickups);
@@ -958,8 +952,7 @@ cItems cChunk::PickupsFromBlock(Vector3i a_RelPos, const cEntity * a_Digger, con
int cChunk::GrowPlantAt(Vector3i a_RelPos, int a_NumStages)
{
- auto blockHandler = BlockHandler(GetBlock(a_RelPos));
- return blockHandler->Grow(*this, a_RelPos, a_NumStages);
+ return cBlockHandler::For(GetBlock(a_RelPos)).Grow(*this, a_RelPos, a_NumStages);
}
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 690998711..ce4a56ae0 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -1103,7 +1103,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
if (
cChunkDef::IsValidHeight(BlockY) &&
- cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(BlockX, BlockY, BlockZ))->IsClickedThrough()
+ cBlockHandler::For(m_Player->GetWorld()->GetBlock(BlockX, BlockY, BlockZ)).IsClickedThrough()
)
{
a_BlockX = BlockX;
@@ -1293,8 +1293,7 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc
cWorld * World = m_Player->GetWorld();
cChunkInterface ChunkInterface(World->GetChunkMap());
- cBlockHandler * Handler = cBlockInfo::GetHandler(a_OldBlock);
- Handler->OnDigging(ChunkInterface, *World, *m_Player, {a_BlockX, a_BlockY, a_BlockZ});
+ cBlockHandler::For(a_OldBlock).OnDigging(ChunkInterface, *World, *m_Player, {a_BlockX, a_BlockY, a_BlockZ});
cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem());
ItemHandler->OnDiggingBlock(World, m_Player, m_Player->GetEquippedItem(), {a_BlockX, a_BlockY, a_BlockZ}, a_BlockFace);
@@ -1371,7 +1370,6 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo
m_Player->AddFoodExhaustion(0.025);
cChunkInterface ChunkInterface(World->GetChunkMap());
- auto blockHandler = BlockHandler(a_OldBlock);
Vector3i absPos(a_BlockX, a_BlockY, a_BlockZ);
if (m_Player->IsGameModeSurvival())
{
@@ -1383,11 +1381,11 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo
}
// Damage the tool:
- auto dlAction = (cBlockInfo::IsOneHitDig(a_OldBlock) ? cItemHandler::dlaBreakBlockInstant : cItemHandler::dlaBreakBlock);
+ auto dlAction = cBlockInfo::IsOneHitDig(a_OldBlock) ? cItemHandler::dlaBreakBlockInstant : cItemHandler::dlaBreakBlock;
m_Player->UseEquippedItem(dlAction);
World->BroadcastSoundParticleEffect(EffectID::PARTICLE_SMOKE, absPos, a_OldBlock, this);
- blockHandler->OnPlayerBrokeBlock(ChunkInterface, *World, *m_Player, absPos, a_OldBlock, a_OldMeta);
+ cBlockHandler::For(a_OldBlock).OnPlayerBrokeBlock(ChunkInterface, *World, *m_Player, absPos, a_OldBlock, a_OldMeta);
cRoot::Get()->GetPluginManager()->CallHookPlayerBrokenBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_OldBlock, a_OldMeta);
}
@@ -1466,10 +1464,10 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
BLOCKTYPE BlockType;
NIBBLETYPE BlockMeta;
World->GetBlockTypeMeta(ClickedBlockPos, BlockType, BlockMeta);
- cBlockHandler * BlockHandler = cBlockInfo::GetHandler(BlockType);
+ const auto & BlockHandler = cBlockHandler::For(BlockType);
bool Placeable = ItemHandler->IsPlaceable() && !m_Player->IsGameModeAdventure() && !m_Player->IsGameModeSpectator();
- bool BlockUsable = BlockHandler->IsUseable() && (!m_Player->IsGameModeSpectator() || cBlockInfo::IsUseableBySpectator(BlockType));
+ bool BlockUsable = BlockHandler.IsUseable() && (!m_Player->IsGameModeSpectator() || cBlockInfo::IsUseableBySpectator(BlockType));
if (BlockUsable && !(m_Player->IsCrouched() && !HeldItem.IsEmpty()))
{
@@ -1477,7 +1475,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
cChunkInterface ChunkInterface(World->GetChunkMap());
if (!PlgMgr->CallHookPlayerUsingBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta))
{
- if (BlockHandler->OnUse(ChunkInterface, *World, *m_Player, ClickedBlockPos, a_BlockFace, CursorPos))
+ if (BlockHandler.OnUse(ChunkInterface, *World, *m_Player, ClickedBlockPos, a_BlockFace, CursorPos))
{
// block use was successful, we're done
PlgMgr->CallHookPlayerUsedBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta);
@@ -1495,7 +1493,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
{
// TODO: OnCancelRightClick seems to do the same thing with updating blocks at the end of this function. Need to double check
// A plugin doesn't agree with the action, replace the block on the client and quit:
- BlockHandler->OnCancelRightClick(ChunkInterface, *World, *m_Player, {a_BlockX, a_BlockY, a_BlockZ}, a_BlockFace);
+ BlockHandler.OnCancelRightClick(ChunkInterface, *World, *m_Player, {a_BlockX, a_BlockY, a_BlockZ}, a_BlockFace);
}
}
else if (Placeable)
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 550d86e35..9857fa29c 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -370,7 +370,7 @@ void cPawn::HandleFalling(void)
}
/* If the block is solid, and the blockhandler confirms the block to be inside, we're officially on the ground. */
- if ((cBlockInfo::IsSolid(BlockType)) && (cBlockInfo::GetHandler(BlockType)->IsInsideBlock(CrossTestPosition - BlockTestPosition, BlockMeta)))
+ if ((cBlockInfo::IsSolid(BlockType)) && (cBlockHandler::For(BlockType).IsInsideBlock(CrossTestPosition - BlockTestPosition, BlockMeta)))
{
OnGround = true;
}
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index d9353f67f..95b231d04 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -2849,11 +2849,10 @@ bool cPlayer::DoesPlacingBlocksIntersectEntity(const sSetBlockVector & a_Blocks)
bool HasInitializedBounds = false;
for (auto blk: a_Blocks)
{
- cBlockHandler * BlockHandler = cBlockInfo::GetHandler(blk.m_BlockType);
int x = blk.GetX();
int y = blk.GetY();
int z = blk.GetZ();
- cBoundingBox BlockBox = BlockHandler->GetPlacementCollisionBox(
+ cBoundingBox BlockBox = cBlockHandler::For(blk.m_BlockType).GetPlacementCollisionBox(
m_World->GetBlock(x - 1, y, z),
m_World->GetBlock(x + 1, y, z),
(y == 0) ? E_BLOCK_AIR : m_World->GetBlock(x, y - 1, z),
@@ -2941,8 +2940,7 @@ bool cPlayer::PlaceBlocks(const sSetBlockVector & a_Blocks)
m_World->PlaceBlock(blk.GetAbsolutePos(), blk.m_BlockType, blk.m_BlockMeta);
// Notify the blockhandlers:
- cBlockHandler * newBlock = BlockHandler(blk.m_BlockType);
- newBlock->OnPlacedByPlayer(ChunkInterface, *m_World, *this, blk);
+ cBlockHandler::For(blk.m_BlockType).OnPlacedByPlayer(ChunkInterface, *m_World, *this, blk);
// Call the "placed" hooks:
pm->CallHookPlayerPlacedBlock(*this, blk);
diff --git a/src/Items/ItemBigFlower.h b/src/Items/ItemBigFlower.h
index a126a72bc..a67ca8d0a 100644
--- a/src/Items/ItemBigFlower.h
+++ b/src/Items/ItemBigFlower.h
@@ -52,7 +52,7 @@ public:
a_World.GetBlockTypeMeta(TopPos, TopType, TopMeta);
cChunkInterface ChunkInterface(a_World.GetChunkMap());
- if (!BlockHandler(TopType)->DoesIgnoreBuildCollision(ChunkInterface, TopPos, a_Player, TopMeta))
+ if (!cBlockHandler::For(TopType).DoesIgnoreBuildCollision(ChunkInterface, TopPos, a_Player, TopMeta))
{
return false;
}
diff --git a/src/Items/ItemChest.h b/src/Items/ItemChest.h
index ecd957a59..8548f8d25 100644
--- a/src/Items/ItemChest.h
+++ b/src/Items/ItemChest.h
@@ -50,9 +50,8 @@ public:
NIBBLETYPE ClickedBlockMeta;
a_World.GetBlockTypeMeta(a_ClickedBlockPos, ClickedBlockType, ClickedBlockMeta);
cChunkInterface ChunkInterface(a_World.GetChunkMap());
- auto blockHandler = BlockHandler(ClickedBlockType);
Vector3i PlacePos;
- if (blockHandler->DoesIgnoreBuildCollision(ChunkInterface, a_ClickedBlockPos, a_Player, ClickedBlockMeta))
+ if (cBlockHandler::For(ClickedBlockType).DoesIgnoreBuildCollision(ChunkInterface, a_ClickedBlockPos, a_Player, ClickedBlockMeta))
{
PlacePos = a_ClickedBlockPos;
}
@@ -69,8 +68,7 @@ public:
BLOCKTYPE PlaceBlock;
NIBBLETYPE PlaceMeta;
a_World.GetBlockTypeMeta(PlacePos, PlaceBlock, PlaceMeta);
- blockHandler = BlockHandler(PlaceBlock);
- if (!blockHandler->DoesIgnoreBuildCollision(ChunkInterface, PlacePos, a_Player, PlaceMeta))
+ if (!cBlockHandler::For(PlaceBlock).DoesIgnoreBuildCollision(ChunkInterface, PlacePos, a_Player, PlaceMeta))
{
return false;
}
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index d9f9c3168..fcdbe109b 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -370,9 +370,8 @@ bool cItemHandler::OnPlayerPlace(
cChunkInterface ChunkInterface(a_World.GetChunkMap());
// Check if the block ignores build collision (water, grass etc.):
- auto HandlerB = BlockHandler(ClickedBlockType);
auto PlacedBlockPos = AddFaceDirection(a_ClickedBlockPos, a_ClickedBlockFace);
- if (HandlerB->DoesIgnoreBuildCollision(ChunkInterface, a_ClickedBlockPos, a_Player, ClickedBlockMeta))
+ if (cBlockHandler::For(ClickedBlockType).DoesIgnoreBuildCollision(ChunkInterface, a_ClickedBlockPos, a_Player, ClickedBlockMeta))
{
// Replace the clicked block:
a_World.DropBlockAsPickups(a_ClickedBlockPos, &a_Player, nullptr);
@@ -392,7 +391,7 @@ bool cItemHandler::OnPlayerPlace(
// Clicked on side of block, make sure that placement won't be cancelled if there is a slab able to be double slabbed.
// No need to do combinability (dblslab) checks, client will do that here.
- if (!BlockHandler(PlaceBlock)->DoesIgnoreBuildCollision(ChunkInterface, PlacedBlockPos, a_Player, PlaceMeta))
+ if (!cBlockHandler::For(PlaceBlock).DoesIgnoreBuildCollision(ChunkInterface, PlacedBlockPos, a_Player, PlaceMeta))
{
// Tried to place a block into another?
// Happens when you place a block aiming at side of block with a torch on it or stem beside it
@@ -832,9 +831,8 @@ bool cItemHandler::GetPlacementBlockTypeMeta(
return false;
}
- cBlockHandler * BlockH = BlockHandler(static_cast<BLOCKTYPE>(m_ItemType));
cChunkInterface ChunkInterface(a_World->GetChunkMap());
- return BlockH->GetPlacementBlockTypeMeta(
+ return cBlockHandler::For(static_cast<BLOCKTYPE>(m_ItemType)).GetPlacementBlockTypeMeta(
ChunkInterface, *a_Player,
a_PlacedBlockPos, a_ClickedBlockFace,
a_CursorPos,
diff --git a/src/Items/ItemSign.h b/src/Items/ItemSign.h
index cb9136db1..64d162f8d 100644
--- a/src/Items/ItemSign.h
+++ b/src/Items/ItemSign.h
@@ -41,7 +41,7 @@ public:
NIBBLETYPE ClickedBlockMeta;
a_World.GetBlockTypeMeta(a_ClickedBlockPos, ClickedBlockType, ClickedBlockMeta);
cChunkInterface ChunkInterface(a_World.GetChunkMap());
- bool IsReplacingClickedBlock = BlockHandler(ClickedBlockType)->DoesIgnoreBuildCollision(ChunkInterface, a_ClickedBlockPos, a_Player, ClickedBlockMeta);
+ bool IsReplacingClickedBlock = cBlockHandler::For(ClickedBlockType).DoesIgnoreBuildCollision(ChunkInterface, a_ClickedBlockPos, a_Player, ClickedBlockMeta);
// If the regular placement doesn't work, do no further processing:
if (!Super::OnPlayerPlace(a_World, a_Player, a_EquippedItem, a_ClickedBlockPos, a_ClickedBlockFace, a_CursorPos))
diff --git a/src/Map.cpp b/src/Map.cpp
index 30d761154..c02cd80f8 100644
--- a/src/Map.cpp
+++ b/src/Map.cpp
@@ -3,14 +3,14 @@
#include "Globals.h"
-#include "Map.h"
#include "BlockInfo.h"
-#include "World.h"
+#include "Blocks/BlockHandler.h"
#include "Chunk.h"
+#include "ClientHandle.h"
#include "Entities/Player.h"
#include "FastRandom.h"
-#include "Blocks/BlockHandler.h"
-#include "ClientHandle.h"
+#include "Map.h"
+#include "World.h"
@@ -139,7 +139,7 @@ bool cMap::UpdatePixel(unsigned int a_X, unsigned int a_Z)
auto Height = a_Chunk.GetHeight(RelX, RelZ);
auto ChunkHeight = cChunkDef::Height;
a_Chunk.GetBlockTypeMeta(RelX, Height, RelZ, TargetBlock, TargetMeta);
- auto ColourID = BlockHandler(TargetBlock)->GetMapBaseColourID(TargetMeta);
+ auto ColourID = cBlockHandler::For(TargetBlock).GetMapBaseColourID(TargetMeta);
if (IsBlockWater(TargetBlock))
{
@@ -151,7 +151,7 @@ bool cMap::UpdatePixel(unsigned int a_X, unsigned int a_Z)
}
else if (ColourID == 0)
{
- while (((--Height) != -1) && ((ColourID = BlockHandler(a_Chunk.GetBlock(RelX, Height, RelZ))->GetMapBaseColourID(a_Chunk.GetMeta(RelX, Height, RelZ))) == 0))
+ while (((--Height) != -1) && ((ColourID = cBlockHandler::For(a_Chunk.GetBlock(RelX, Height, RelZ)).GetMapBaseColourID(a_Chunk.GetMeta(RelX, Height, RelZ))) == 0))
{
continue;
}
diff --git a/src/Physics/Explodinator.cpp b/src/Physics/Explodinator.cpp
index 3bfb78611..c6f254cfc 100644
--- a/src/Physics/Explodinator.cpp
+++ b/src/Physics/Explodinator.cpp
@@ -111,7 +111,7 @@ namespace Explodinator
a_Chunk.SetBlock(a_RelativePosition, a_NewBlock, 0);
cChunkInterface Interface(a_World.GetChunkMap());
- cBlockInfo::GetHandler(a_DestroyedBlock)->OnBroken(Interface, a_World, a_AbsolutePosition, a_DestroyedBlock, DestroyedMeta);
+ cBlockHandler::For(a_DestroyedBlock).OnBroken(Interface, a_World, a_AbsolutePosition, a_DestroyedBlock, DestroyedMeta);
}
/** Sets the block at the given Position to air, updates surroundings, and spawns pickups, fire, shrapnel according to Minecraft rules.
@@ -141,7 +141,7 @@ namespace Explodinator
{
const auto DestroyedMeta = a_Chunk.GetMeta(a_Position);
a_Chunk.GetWorld()->SpawnItemPickups(
- cBlockInfo::GetHandler(DestroyedBlock)->ConvertToPickups(DestroyedMeta, a_Chunk.GetBlockEntityRel(a_Position)),
+ cBlockHandler::For(DestroyedBlock).ConvertToPickups(DestroyedMeta, a_Chunk.GetBlockEntityRel(a_Position)),
Absolute
);
}
diff --git a/src/Simulator/FloodyFluidSimulator.cpp b/src/Simulator/FloodyFluidSimulator.cpp
index 5f4d5ba85..ff611bbc3 100644
--- a/src/Simulator/FloodyFluidSimulator.cpp
+++ b/src/Simulator/FloodyFluidSimulator.cpp
@@ -299,8 +299,7 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
// Wash away the block there, if possible:
if (CanWashAway(BlockType))
{
- cBlockHandler * Handler = BlockHandler(BlockType);
- if (Handler->DoesDropOnUnsuitable())
+ if (cBlockHandler::For(BlockType).DoesDropOnUnsuitable())
{
m_World.DropBlockAsPickups(absPos, nullptr, nullptr);
}
diff --git a/src/World.cpp b/src/World.cpp
index b1f2a29df..3b82d9e97 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -2154,7 +2154,7 @@ void cWorld::PlaceBlock(const Vector3i a_Position, const BLOCKTYPE a_BlockType,
SetBlock(a_Position, a_BlockType, a_BlockMeta);
cChunkInterface ChunkInterface(GetChunkMap());
- cBlockInfo::GetHandler(a_BlockType)->OnPlaced(ChunkInterface, *this, a_Position, a_BlockType, a_BlockMeta);
+ cBlockHandler::For(a_BlockType).OnPlaced(ChunkInterface, *this, a_Position, a_BlockType, a_BlockMeta);
}
@@ -2182,7 +2182,7 @@ bool cWorld::DigBlock(Vector3i a_BlockPos)
}
cChunkInterface ChunkInterface(GetChunkMap());
- cBlockInfo::GetHandler(BlockType)->OnBroken(ChunkInterface, *this, a_BlockPos, BlockType, BlockMeta);
+ cBlockHandler::For(BlockType).OnBroken(ChunkInterface, *this, a_BlockPos, BlockType, BlockMeta);
return true;
}