diff options
Diffstat (limited to 'src/Blocks')
110 files changed, 2040 insertions, 2297 deletions
diff --git a/src/Blocks/BlockAir.h b/src/Blocks/BlockAir.h index 8338735b5..dd072067c 100644 --- a/src/Blocks/BlockAir.h +++ b/src/Blocks/BlockAir.h @@ -5,15 +5,12 @@ -class cBlockAirHandler final : - public cBlockHandler +class cBlockAirHandler final : public cBlockHandler { -public: - + public: using cBlockHandler::cBlockHandler; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { // Don't drop anything: diff --git a/src/Blocks/BlockAnvil.h b/src/Blocks/BlockAnvil.h index bc031216a..e07325693 100644 --- a/src/Blocks/BlockAnvil.h +++ b/src/Blocks/BlockAnvil.h @@ -10,17 +10,14 @@ -class cBlockAnvilHandler final : - public cYawRotator<cBlockHandler, 0x03, 0x03, 0x00, 0x01, 0x02> +class cBlockAnvilHandler final : public cYawRotator<cBlockHandler, 0x03, 0x03, 0x00, 0x01, 0x02> { using Super = cYawRotator<cBlockHandler, 0x03, 0x03, 0x00, 0x01, 0x02>; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { return cItem(m_BlockType, 1, a_BlockMeta >> 2); @@ -48,10 +45,7 @@ private: - virtual bool IsUseable() const override - { - return true; - } + virtual bool IsUseable() const override { return true; } @@ -62,8 +56,4 @@ private: UNUSED(a_Meta); return 6; } -} ; - - - - +}; diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp index a18d95196..5013983d1 100644 --- a/src/Blocks/BlockBed.cpp +++ b/src/Blocks/BlockBed.cpp @@ -15,9 +15,11 @@ void cBlockBedHandler::OnBroken( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, const Vector3i a_BlockPos, - BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta, + BLOCKTYPE a_OldBlockType, + NIBBLETYPE a_OldBlockMeta, const cEntity * a_Digger ) const { @@ -94,10 +96,8 @@ bool cBlockBedHandler::OnUse( a_Player.SetBedPos(a_BlockPos); // Sleeping is allowed only during night and thunderstorms: - if ( - !(((a_WorldInterface.GetTimeOfDay() > 12541_tick) && (a_WorldInterface.GetTimeOfDay() < 23458_tick)) || - (a_Player.GetWorld()->GetWeather() == wThunderstorm)) - ) + if (!(((a_WorldInterface.GetTimeOfDay() > 12541_tick) && (a_WorldInterface.GetTimeOfDay() < 23458_tick)) || + (a_Player.GetWorld()->GetWeather() == wThunderstorm))) { a_Player.SendAboveActionBarMessage("You can only sleep at night and during thunderstorms"); return true; @@ -111,12 +111,11 @@ bool cBlockBedHandler::OnUse( } // Cannot sleep if there are hostile mobs nearby: - if ( - !a_Player.GetWorld()->ForEachEntityInBox({ a_Player.GetPosition().addedY(-5), 8, 10 }, [](cEntity & a_Entity) - { - return a_Entity.IsMob() && (static_cast<cMonster&>(a_Entity).GetMobFamily() == cMonster::mfHostile); - }) - ) + if (!a_Player.GetWorld()->ForEachEntityInBox( + {a_Player.GetPosition().addedY(-5), 8, 10}, + [](cEntity & a_Entity) + { return a_Entity.IsMob() && (static_cast<cMonster &>(a_Entity).GetMobFamily() == cMonster::mfHostile); } + )) { a_Player.SendAboveActionBarMessage("You may not rest now, there are monsters nearby"); return true; @@ -137,16 +136,20 @@ bool cBlockBedHandler::OnUse( // When sleeping, the player's bounding box moves to approximately where his head is. // Set the player's position to somewhere close to the edge of the pillow block: - a_Player.SetPosition(Vector3f(0.4f, 1, 0.4f) * MetaDataToDirection(Meta & 0x03) + Vector3f(0.5f, 0.6875, 0.5f) + a_BlockPos); + a_Player.SetPosition( + Vector3f(0.4f, 1, 0.4f) * MetaDataToDirection(Meta & 0x03) + Vector3f(0.5f, 0.6875, 0.5f) + a_BlockPos + ); // Fast-forward the time if all players in the world are in their beds: if (a_WorldInterface.ForEachPlayer([](cPlayer & a_OtherPlayer) { return !a_OtherPlayer.IsInBed(); })) { - a_WorldInterface.ForEachPlayer([&a_ChunkInterface](cPlayer & a_OtherPlayer) - { - VacateBed(a_ChunkInterface, a_OtherPlayer); - return false; - }); + a_WorldInterface.ForEachPlayer( + [&a_ChunkInterface](cPlayer & a_OtherPlayer) + { + VacateBed(a_ChunkInterface, a_OtherPlayer); + return false; + } + ); a_WorldInterface.SetTimeOfDay(0_tick); } diff --git a/src/Blocks/BlockBed.h b/src/Blocks/BlockBed.h index a6b2814b9..f0814c169 100644 --- a/src/Blocks/BlockBed.h +++ b/src/Blocks/BlockBed.h @@ -19,13 +19,11 @@ class cWorldInterface; -class cBlockBedHandler final : - public cYawRotator<cBlockEntityHandler, 0x03, 0x02, 0x03, 0x00, 0x01> +class cBlockBedHandler final : public cYawRotator<cBlockEntityHandler, 0x03, 0x02, 0x03, 0x00, 0x01> { using Super = cYawRotator<cBlockEntityHandler, 0x03, 0x02, 0x03, 0x00, 0x01>; -public: - + public: using Super::Super; static Vector3i MetaDataToDirection(NIBBLETYPE a_MetaData) @@ -76,18 +74,21 @@ public: a_Player.SetIsInBed(false); } -private: - + private: // Overrides: virtual void OnBroken( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, const Vector3i a_BlockPos, - BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta, + BLOCKTYPE a_OldBlockType, + NIBBLETYPE a_OldBlockMeta, const cEntity * a_Digger ) const override; virtual bool OnUse( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, + cPlayer & a_Player, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPos @@ -104,4 +105,4 @@ private: UNUSED(a_Meta); return 28; } -} ; +}; diff --git a/src/Blocks/BlockBigFlower.h b/src/Blocks/BlockBigFlower.h index 1b2c0d735..80e2d258a 100644 --- a/src/Blocks/BlockBigFlower.h +++ b/src/Blocks/BlockBigFlower.h @@ -9,27 +9,28 @@ -class cBlockBigFlowerHandler final : - public cBlockHandler +class cBlockBigFlowerHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - - virtual bool DoesIgnoreBuildCollision(const cWorld & a_World, const cItem & a_HeldItem, const Vector3i a_Position, NIBBLETYPE a_Meta, const eBlockFace a_ClickedBlockFace, const bool a_ClickedDirectly) const override + private: + virtual bool DoesIgnoreBuildCollision( + const cWorld & a_World, + const cItem & a_HeldItem, + const Vector3i a_Position, + NIBBLETYPE a_Meta, + const eBlockFace a_ClickedBlockFace, + const bool a_ClickedDirectly + ) const override { if (IsMetaTopPart(a_Meta)) { BLOCKTYPE BottomType; - if ( - (a_Position.y < 1) || - !a_World.GetBlockTypeMeta(a_Position - Vector3i(0, 1, 0), BottomType, a_Meta) || - (BottomType != E_BLOCK_BIG_FLOWER) - ) + if ((a_Position.y < 1) || !a_World.GetBlockTypeMeta(a_Position - Vector3i(0, 1, 0), BottomType, a_Meta) || + (BottomType != E_BLOCK_BIG_FLOWER)) { // Can't find the flower meta so assume grass return true; @@ -37,10 +38,7 @@ private: } NIBBLETYPE FlowerMeta = a_Meta & 0x07; - return ( - (FlowerMeta == E_META_BIG_FLOWER_DOUBLE_TALL_GRASS) || - (FlowerMeta == E_META_BIG_FLOWER_LARGE_FERN) - ); + return ((FlowerMeta == E_META_BIG_FLOWER_DOUBLE_TALL_GRASS) || (FlowerMeta == E_META_BIG_FLOWER_LARGE_FERN)); } @@ -89,10 +87,7 @@ private: - static bool IsMetaTopPart(NIBBLETYPE a_Meta) - { - return ((a_Meta & 0x08) != 0); - } + static bool IsMetaTopPart(NIBBLETYPE a_Meta) { return ((a_Meta & 0x08) != 0); } @@ -112,9 +107,11 @@ private: virtual void OnBroken( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, const Vector3i a_BlockPos, - BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta, + BLOCKTYPE a_OldBlockType, + NIBBLETYPE a_OldBlockMeta, const cEntity * a_Digger ) const override { @@ -124,8 +121,10 @@ private: if (a_ChunkInterface.GetBlock(LowerPart) == a_OldBlockType) { // Prevent creative punches from dropping pickups. - // TODO: Simplify to SetBlock and remove the IsMetaTopPart check in DropBlockAsPickups when 1.13 blockstates arrive. - if ((a_Digger != nullptr) && a_Digger->IsPlayer() && static_cast<const cPlayer *>(a_Digger)->IsGameModeCreative()) + // TODO: Simplify to SetBlock and remove the IsMetaTopPart check in DropBlockAsPickups when 1.13 + // blockstates arrive. + if ((a_Digger != nullptr) && a_Digger->IsPlayer() && + static_cast<const cPlayer *>(a_Digger)->IsGameModeCreative()) { a_ChunkInterface.SetBlock(LowerPart, E_BLOCK_AIR, 0); } @@ -154,4 +153,4 @@ private: UNUSED(a_Meta); return 7; } -} ; +}; diff --git a/src/Blocks/BlockBookShelf.h b/src/Blocks/BlockBookShelf.h index 151925340..f523d944b 100644 --- a/src/Blocks/BlockBookShelf.h +++ b/src/Blocks/BlockBookShelf.h @@ -6,15 +6,12 @@ -class cBlockBookShelfHandler final : - public cBlockHandler +class cBlockBookShelfHandler final : public cBlockHandler { -public: - + public: using cBlockHandler::cBlockHandler; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { if (ToolHasSilkTouch(a_Tool)) diff --git a/src/Blocks/BlockBrewingStand.h b/src/Blocks/BlockBrewingStand.h index d1595c690..cd1f911ac 100644 --- a/src/Blocks/BlockBrewingStand.h +++ b/src/Blocks/BlockBrewingStand.h @@ -7,17 +7,14 @@ -class cBlockBrewingStandHandler final : - public cBlockEntityHandler +class cBlockBrewingStandHandler final : public cBlockEntityHandler { using Super = cBlockEntityHandler; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { return cItem(E_ITEM_BREWING_STAND); // We have to drop the item form of a brewing stand @@ -32,8 +29,4 @@ private: UNUSED(a_Meta); return 6; } -} ; - - - - +}; diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h index 1a141eff3..2a40f838e 100644 --- a/src/Blocks/BlockButton.h +++ b/src/Blocks/BlockButton.h @@ -14,20 +14,16 @@ -class cBlockButtonHandler final : - public cClearMetaOnDrop<cMetaRotator<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, true>> +class cBlockButtonHandler final + : public cClearMetaOnDrop<cMetaRotator<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, true>> { using Super = cClearMetaOnDrop<cMetaRotator<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, true>>; -public: - + public: 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; - } + 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. */ @@ -37,11 +33,8 @@ public: 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) - ) + 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 @@ -59,8 +52,7 @@ public: QueueButtonRelease(a_World, Pos, Type); } -private: - + private: virtual bool OnUse( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, @@ -81,11 +73,13 @@ private: // Set the ON bit to on Meta |= 0x08; - const auto SoundToPlay = (m_BlockType == E_BLOCK_STONE_BUTTON) ? "block.stone_button.click_on" : "block.wood_button.click_on"; + const auto SoundToPlay = + (m_BlockType == E_BLOCK_STONE_BUTTON) ? "block.stone_button.click_on" : "block.wood_button.click_on"; a_ChunkInterface.SetBlockMeta(a_BlockPos, Meta); a_WorldInterface.WakeUpSimulators(a_BlockPos); - a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect(SoundToPlay, a_BlockPos, 0.5f, 0.6f, a_Player.GetClientHandle()); + a_WorldInterface.GetBroadcastManager() + .BroadcastSoundEffect(SoundToPlay, a_BlockPos, 0.5f, 0.6f, a_Player.GetClientHandle()); // Queue a button reset (unpress) QueueButtonRelease(*a_Player.GetWorld(), a_BlockPos, m_BlockType); @@ -97,10 +91,7 @@ private: - virtual bool IsUseable(void) const override - { - return true; - } + virtual bool IsUseable(void) const override { return true; } @@ -152,16 +143,11 @@ private: { switch (Face) { - case eBlockFace::BLOCK_FACE_YP: - return (SupportBlockMeta & E_BLOCK_STAIRS_UPSIDE_DOWN); - case eBlockFace::BLOCK_FACE_XP: - return ((SupportBlockMeta & 0b11) == E_BLOCK_STAIRS_XP); - case eBlockFace::BLOCK_FACE_XM: - return ((SupportBlockMeta & 0b11) == E_BLOCK_STAIRS_XM); - case eBlockFace::BLOCK_FACE_ZP: - return ((SupportBlockMeta & 0b11) == E_BLOCK_STAIRS_ZP); - case eBlockFace::BLOCK_FACE_ZM: - return ((SupportBlockMeta & 0b11) == E_BLOCK_STAIRS_ZM); + case eBlockFace::BLOCK_FACE_YP: return (SupportBlockMeta & E_BLOCK_STAIRS_UPSIDE_DOWN); + case eBlockFace::BLOCK_FACE_XP: return ((SupportBlockMeta & 0b11) == E_BLOCK_STAIRS_XP); + case eBlockFace::BLOCK_FACE_XM: return ((SupportBlockMeta & 0b11) == E_BLOCK_STAIRS_XM); + case eBlockFace::BLOCK_FACE_ZP: return ((SupportBlockMeta & 0b11) == E_BLOCK_STAIRS_ZP); + case eBlockFace::BLOCK_FACE_ZM: return ((SupportBlockMeta & 0b11) == E_BLOCK_STAIRS_ZM); default: { return false; @@ -194,10 +180,7 @@ private: BLOCKTYPE Type; NIBBLETYPE Meta; - if ( - !a_World.GetBlockTypeMeta(a_Position, Type, Meta) || - (Type != a_BlockType) || !IsButtonOn(Meta) - ) + if (!a_World.GetBlockTypeMeta(a_Position, Type, Meta) || (Type != a_BlockType) || !IsButtonOn(Meta)) { // Total failure or block changed, bail return; @@ -211,7 +194,8 @@ private: } // Block hasn't change in the meantime; release it - const auto SoundToPlayOnRelease = (Type == E_BLOCK_STONE_BUTTON) ? "block.stone_button.click_off" : "block.wood_button.click_off"; + const auto SoundToPlayOnRelease = + (Type == E_BLOCK_STONE_BUTTON) ? "block.stone_button.click_off" : "block.wood_button.click_off"; a_World.SetBlockMeta(a_Position, Meta & 0x07); a_World.WakeUpSimulators(a_Position); @@ -221,7 +205,12 @@ private: } /** Returns true if an arrow was found in the wooden button */ - static bool IsButtonPressedByArrow(cWorld & a_World, const Vector3i a_ButtonPosition, const BLOCKTYPE a_BlockType, const NIBBLETYPE a_Meta) + static bool IsButtonPressedByArrow( + cWorld & a_World, + const Vector3i a_ButtonPosition, + const BLOCKTYPE a_BlockType, + const NIBBLETYPE a_Meta + ) { if (a_BlockType != E_BLOCK_WOODEN_BUTTON) { @@ -231,10 +220,7 @@ private: const auto FaceOffset = GetButtonOffsetOnBlock(a_Meta); const bool FoundArrow = !a_World.ForEachEntityInBox( cBoundingBox(FaceOffset + a_ButtonPosition, 0.2, 0.2), - [](cEntity & a_Entity) - { - return a_Entity.IsArrow(); - } + [](cEntity & a_Entity) { return a_Entity.IsArrow(); } ); return FoundArrow; @@ -249,12 +235,12 @@ private: { switch (BlockMetaDataToBlockFace(a_Meta)) { - case BLOCK_FACE_YM: return { 0.5, 1, 0.5 }; - case BLOCK_FACE_XP: return { 0, 0.5, 0.5 }; - case BLOCK_FACE_XM: return { 1, 0.5, 0.5 }; - case BLOCK_FACE_ZP: return { 0.5, 0.5, 0 }; - case BLOCK_FACE_ZM: return { 0.5, 0.5, 1 }; - case BLOCK_FACE_YP: return { 0.5, 0, 0.5 }; + case BLOCK_FACE_YM: return {0.5, 1, 0.5}; + case BLOCK_FACE_XP: return {0, 0.5, 0.5}; + case BLOCK_FACE_XM: return {1, 0.5, 0.5}; + case BLOCK_FACE_ZP: return {0.5, 0.5, 0}; + case BLOCK_FACE_ZM: return {0.5, 0.5, 1}; + case BLOCK_FACE_YP: return {0.5, 0, 0.5}; case BLOCK_FACE_NONE: { break; @@ -262,4 +248,4 @@ private: } UNREACHABLE("Unhandled block face!"); } -} ; +}; diff --git a/src/Blocks/BlockCactus.h b/src/Blocks/BlockCactus.h index 23c4d3421..21e198309 100644 --- a/src/Blocks/BlockCactus.h +++ b/src/Blocks/BlockCactus.h @@ -7,17 +7,14 @@ -class cBlockCactusHandler final : - public cClearMetaOnDrop<cBlockPlant<false>> +class cBlockCactusHandler final : public cClearMetaOnDrop<cBlockPlant<false>> { using Super = cClearMetaOnDrop<cBlockPlant<false>>; -public: - + public: using Super::Super; -private: - + private: virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override { if (a_Position.y <= 0) @@ -32,25 +29,19 @@ private: } // Check surroundings. Cacti may ONLY be surrounded by non-solid blocks - static const Vector3i Coords[] = - { - {-1, 0, 0}, - { 1, 0, 0}, - { 0, 0, -1}, - { 0, 0, 1}, + static const Vector3i Coords[] = { + {-1, 0, 0}, + {1, 0, 0}, + {0, 0, -1}, + {0, 0, 1}, }; for (size_t i = 0; i < ARRAYCOUNT(Coords); i++) { BLOCKTYPE BlockType; NIBBLETYPE BlockMeta; - if ( - a_Chunk.UnboundedRelGetBlock(a_Position + Coords[i], BlockType, BlockMeta) && - ( - cBlockInfo::IsSolid(BlockType) || - (BlockType == E_BLOCK_LAVA) || - (BlockType == E_BLOCK_STATIONARY_LAVA) - ) - ) + if (a_Chunk.UnboundedRelGetBlock(a_Position + Coords[i], BlockType, BlockMeta) && + (cBlockInfo::IsSolid(BlockType) || (BlockType == E_BLOCK_LAVA) || (BlockType == E_BLOCK_STATIONARY_LAVA) + )) { return false; } @@ -76,18 +67,12 @@ private: { // Check the total height of the cacti blocks here: int top = a_RelPos.y + 1; - while ( - (top < cChunkDef::Height) && - (a_Chunk.GetBlock({a_RelPos.x, top, a_RelPos.z}) == E_BLOCK_CACTUS) - ) + while ((top < cChunkDef::Height) && (a_Chunk.GetBlock({a_RelPos.x, top, a_RelPos.z}) == E_BLOCK_CACTUS)) { ++top; } int bottom = a_RelPos.y - 1; - while ( - (bottom > 0) && - (a_Chunk.GetBlock({a_RelPos.x, bottom, a_RelPos.z}) == E_BLOCK_CACTUS) - ) + while ((bottom > 0) && (a_Chunk.GetBlock({a_RelPos.x, bottom, a_RelPos.z}) == E_BLOCK_CACTUS)) { --bottom; } @@ -111,24 +96,19 @@ private: a_Chunk.UnboundedRelFastSetBlock(pos, E_BLOCK_CACTUS, 0); - // Check surroundings. Cacti may ONLY be surrounded by non-solid blocks; if they aren't, drop as pickup and bail out the growing - static const Vector3i neighborOffsets[] = - { - {-1, 0, 0}, - { 1, 0, 0}, - { 0, 0, -1}, - { 0, 0, 1}, - } ; - for (const auto & ofs: neighborOffsets) + // Check surroundings. Cacti may ONLY be surrounded by non-solid blocks; if they aren't, drop as pickup and + // bail out the growing + static const Vector3i neighborOffsets[] = { + {-1, 0, 0}, + {1, 0, 0}, + {0, 0, -1}, + {0, 0, 1}, + }; + for (const auto & ofs : neighborOffsets) { - if ( - a_Chunk.UnboundedRelGetBlockType(pos + ofs, blockType) && - ( - cBlockInfo::IsSolid(blockType) || - (blockType == E_BLOCK_LAVA) || - (blockType == E_BLOCK_STATIONARY_LAVA) - ) - ) + if (a_Chunk.UnboundedRelGetBlockType(pos + ofs, blockType) && + (cBlockInfo::IsSolid(blockType) || (blockType == E_BLOCK_LAVA) || + (blockType == E_BLOCK_STATIONARY_LAVA))) { // Remove the cactus auto absPos = a_Chunk.RelativeToAbsolute(pos); @@ -149,8 +129,4 @@ private: } return paStay; } -} ; - - - - +}; diff --git a/src/Blocks/BlockCake.h b/src/Blocks/BlockCake.h index 4b238fa48..06f91af9b 100644 --- a/src/Blocks/BlockCake.h +++ b/src/Blocks/BlockCake.h @@ -6,17 +6,14 @@ -class cBlockCakeHandler final : - public cBlockHandler +class cBlockCakeHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual bool OnUse( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, @@ -59,18 +56,11 @@ private: - virtual bool IsUseable(void) const override - { - return true; - } + virtual bool IsUseable(void) const override { return true; } 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 841e94b11..5d7320752 100644 --- a/src/Blocks/BlockCarpet.h +++ b/src/Blocks/BlockCarpet.h @@ -14,17 +14,14 @@ -class cBlockCarpetHandler final : - public cBlockHandler +class cBlockCarpetHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override { return (a_Position.y > 0) && (a_Chunk.GetBlock(a_Position.addedY(-1)) != E_BLOCK_AIR); @@ -38,22 +35,22 @@ private: { switch (a_Meta) { - case E_META_CARPET_WHITE: return 14; - case E_META_CARPET_ORANGE: return 15; - case E_META_CARPET_MAGENTA: return 16; - case E_META_CARPET_LIGHTBLUE: return 17; - case E_META_CARPET_YELLOW: return 18; + case E_META_CARPET_WHITE: return 14; + case E_META_CARPET_ORANGE: return 15; + case E_META_CARPET_MAGENTA: return 16; + case E_META_CARPET_LIGHTBLUE: return 17; + case E_META_CARPET_YELLOW: return 18; case E_META_CARPET_LIGHTGREEN: return 19; - case E_META_CARPET_PINK: return 20; - case E_META_CARPET_GRAY: return 21; - case E_META_CARPET_LIGHTGRAY: return 22; - case E_META_CARPET_CYAN: return 23; - case E_META_CARPET_PURPLE: return 24; - case E_META_CARPET_BLUE: return 25; - case E_META_CARPET_BROWN: return 26; - case E_META_CARPET_GREEN: return 27; - case E_META_CARPET_RED: return 28; - case E_META_CARPET_BLACK: return 29; + case E_META_CARPET_PINK: return 20; + case E_META_CARPET_GRAY: return 21; + case E_META_CARPET_LIGHTGRAY: return 22; + case E_META_CARPET_CYAN: return 23; + case E_META_CARPET_PURPLE: return 24; + case E_META_CARPET_BLUE: return 25; + case E_META_CARPET_BROWN: return 26; + case E_META_CARPET_GREEN: return 27; + case E_META_CARPET_RED: return 28; + case E_META_CARPET_BLACK: return 29; default: { ASSERT(!"Unhandled meta in carpet handler!"); @@ -61,8 +58,4 @@ private: } } } -} ; - - - - +}; diff --git a/src/Blocks/BlockCauldron.h b/src/Blocks/BlockCauldron.h index 82247944c..cc3800f93 100644 --- a/src/Blocks/BlockCauldron.h +++ b/src/Blocks/BlockCauldron.h @@ -8,17 +8,14 @@ -class cBlockCauldronHandler final : - public cBlockHandler +class cBlockCauldronHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { return cItem(E_ITEM_CAULDRON, 1, 0); @@ -103,7 +100,9 @@ private: case E_ITEM_LEATHER_TUNIC: { // Resets any color to default: - if ((Meta > 0) && ((EquippedItem.m_ItemColor.GetRed() != 255) || (EquippedItem.m_ItemColor.GetBlue() != 255) || (EquippedItem.m_ItemColor.GetGreen() != 255))) + if ((Meta > 0) && + ((EquippedItem.m_ItemColor.GetRed() != 255) || (EquippedItem.m_ItemColor.GetBlue() != 255) || + (EquippedItem.m_ItemColor.GetGreen() != 255))) { a_ChunkInterface.SetBlockMeta(a_BlockPos, --Meta); auto NewItem = cItem(EquippedItem); @@ -129,7 +128,8 @@ private: { // Resets shulker box color. - // TODO: When there is an actual default shulker box add the appropriate changes here! - 19.09.2020 - 12xx12 + // TODO: When there is an actual default shulker box add the appropriate changes here! - 19.09.2020 - + // 12xx12 if (Meta == 0) { // The cauldron is empty: @@ -168,10 +168,7 @@ private: - virtual bool IsUseable() const override - { - return true; - } + virtual bool IsUseable() const override { return true; } @@ -208,8 +205,4 @@ private: UNUSED(a_Meta); return 21; } -} ; - - - - +}; diff --git a/src/Blocks/BlockChest.h b/src/Blocks/BlockChest.h index 119216d00..f1ee9acf7 100644 --- a/src/Blocks/BlockChest.h +++ b/src/Blocks/BlockChest.h @@ -9,13 +9,11 @@ -class cBlockChestHandler final : - public cYawRotator<cClearMetaOnDrop<cBlockEntityHandler>, 0x07, 0x03, 0x04, 0x02, 0x05> +class cBlockChestHandler final : public cYawRotator<cClearMetaOnDrop<cBlockEntityHandler>, 0x07, 0x03, 0x04, 0x02, 0x05> { using Super = cYawRotator<cClearMetaOnDrop<cBlockEntityHandler>, 0x07, 0x03, 0x04, 0x02, 0x05>; -public: - + public: using Super::Super; @@ -24,4 +22,4 @@ public: UNUSED(a_Meta); return 13; } -} ; +}; diff --git a/src/Blocks/BlockCloth.h b/src/Blocks/BlockCloth.h index 8c0607f36..d40041429 100644 --- a/src/Blocks/BlockCloth.h +++ b/src/Blocks/BlockCloth.h @@ -7,35 +7,32 @@ -class cBlockClothHandler final : - public cBlockHandler +class cBlockClothHandler final : public cBlockHandler { -public: - + public: using cBlockHandler::cBlockHandler; -private: - + private: virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override { switch (a_Meta) { - case E_META_WOOL_WHITE: return 14; - case E_META_WOOL_ORANGE: return 15; - case E_META_WOOL_MAGENTA: return 16; - case E_META_WOOL_LIGHTBLUE: return 17; - case E_META_WOOL_YELLOW: return 18; + case E_META_WOOL_WHITE: return 14; + case E_META_WOOL_ORANGE: return 15; + case E_META_WOOL_MAGENTA: return 16; + case E_META_WOOL_LIGHTBLUE: return 17; + case E_META_WOOL_YELLOW: return 18; case E_META_WOOL_LIGHTGREEN: return 19; - case E_META_WOOL_PINK: return 20; - case E_META_WOOL_GRAY: return 21; - case E_META_WOOL_LIGHTGRAY: return 22; - case E_META_WOOL_CYAN: return 23; - case E_META_WOOL_PURPLE: return 24; - case E_META_WOOL_BLUE: return 25; - case E_META_WOOL_BROWN: return 26; - case E_META_WOOL_GREEN: return 27; - case E_META_WOOL_RED: return 28; - case E_META_WOOL_BLACK: return 29; + case E_META_WOOL_PINK: return 20; + case E_META_WOOL_GRAY: return 21; + case E_META_WOOL_LIGHTGRAY: return 22; + case E_META_WOOL_CYAN: return 23; + case E_META_WOOL_PURPLE: return 24; + case E_META_WOOL_BLUE: return 25; + case E_META_WOOL_BROWN: return 26; + case E_META_WOOL_GREEN: return 27; + case E_META_WOOL_RED: return 28; + case E_META_WOOL_BLACK: return 29; default: { ASSERT(!"Unhandled meta in wool handler!"); @@ -43,4 +40,4 @@ private: } } } -} ; +}; diff --git a/src/Blocks/BlockCobWeb.h b/src/Blocks/BlockCobWeb.h index 60ccbf53a..567b8c2e5 100644 --- a/src/Blocks/BlockCobWeb.h +++ b/src/Blocks/BlockCobWeb.h @@ -9,15 +9,12 @@ -class cBlockCobWebHandler final : - public cBlockHandler +class cBlockCobWebHandler final : public cBlockHandler { -public: - + public: using cBlockHandler::cBlockHandler; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { // Silk touch gives cobweb, anything else gives just string: @@ -40,8 +37,4 @@ private: UNUSED(a_Meta); return 3; } -} ; - - - - +}; diff --git a/src/Blocks/BlockCocoaPod.h b/src/Blocks/BlockCocoaPod.h index e018388c5..d95849d84 100644 --- a/src/Blocks/BlockCocoaPod.h +++ b/src/Blocks/BlockCocoaPod.h @@ -7,13 +7,11 @@ -class cBlockCocoaPodHandler final : - public cBlockHandler +class cBlockCocoaPodHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; static NIBBLETYPE BlockFaceToMeta(eBlockFace a_BlockFace) @@ -34,8 +32,7 @@ public: UNREACHABLE("Unsupported block face"); } -private: - + private: virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override { // Check that we're attached to a jungle log block: @@ -124,8 +121,4 @@ private: UNUSED(a_Meta); return 34; } -} ; - - - - +}; diff --git a/src/Blocks/BlockCommandBlock.h b/src/Blocks/BlockCommandBlock.h index 9409e6004..400e78c8b 100644 --- a/src/Blocks/BlockCommandBlock.h +++ b/src/Blocks/BlockCommandBlock.h @@ -7,17 +7,14 @@ -class cBlockCommandBlockHandler final : - public cBlockEntityHandler +class cBlockCommandBlockHandler final : public cBlockEntityHandler { using Super = cBlockEntityHandler; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { // Don't allow as a pickup: @@ -33,8 +30,4 @@ private: UNUSED(a_Meta); return 10; } -} ; - - - - +}; diff --git a/src/Blocks/BlockComparator.h b/src/Blocks/BlockComparator.h index 18aa2a8b9..33ed194bc 100644 --- a/src/Blocks/BlockComparator.h +++ b/src/Blocks/BlockComparator.h @@ -9,19 +9,14 @@ -class cBlockComparatorHandler final : - public cYawRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03> +class cBlockComparatorHandler final : public cYawRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03> { using Super = cYawRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03>; -public: - + public: using Super::Super; - inline static bool IsInSubtractionMode(NIBBLETYPE a_Meta) - { - return ((a_Meta & 0x4) == 0x4); - } + inline static bool IsInSubtractionMode(NIBBLETYPE a_Meta) { return ((a_Meta & 0x4) == 0x4); } inline static Vector3i GetFrontCoordinate(Vector3i a_Position, NIBBLETYPE a_Meta) { @@ -99,8 +94,7 @@ public: return a_Position; } -private: - + private: virtual bool OnUse( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, @@ -143,10 +137,7 @@ private: - virtual bool IsUseable(void) const override - { - return true; - } + virtual bool IsUseable(void) const override { return true; } @@ -201,8 +192,4 @@ private: UNUSED(a_Meta); return 11; } -} ; - - - - +}; diff --git a/src/Blocks/BlockConcretePowder.h b/src/Blocks/BlockConcretePowder.h index 52591b3c1..facd115dd 100644 --- a/src/Blocks/BlockConcretePowder.h +++ b/src/Blocks/BlockConcretePowder.h @@ -7,43 +7,59 @@ -class cBlockConcretePowderHandler final : - public cBlockHandler +class cBlockConcretePowderHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual void OnPlaced( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, - BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta + BLOCKTYPE a_BlockType, + NIBBLETYPE a_BlockMeta ) const override { OnNeighborChanged(a_ChunkInterface, a_BlockPos, BLOCK_FACE_NONE); } - virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const override + virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) + const override { - a_ChunkInterface.DoWithChunkAt(a_BlockPos, [&](cChunk & a_Chunk) { CheckSoaked(cChunkDef::AbsoluteToRelative(a_BlockPos), a_Chunk); return true; }); + a_ChunkInterface.DoWithChunkAt( + a_BlockPos, + [&](cChunk & a_Chunk) + { + CheckSoaked(cChunkDef::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. */ 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) - { - BLOCKTYPE NeighborType; - return ( - a_Chunk.UnboundedRelGetBlockType(a_Rel.x + a_Offset.x, a_Rel.y + a_Offset.y, a_Rel.z + a_Offset.z, NeighborType) - && IsBlockWater(NeighborType) - ); - }); + const bool ShouldSoak = std::any_of( + WaterCheck.cbegin(), + WaterCheck.cend(), + [a_Rel, &a_Chunk](Vector3i a_Offset) + { + BLOCKTYPE NeighborType; + return ( + a_Chunk.UnboundedRelGetBlockType( + a_Rel.x + a_Offset.x, + a_Rel.y + a_Offset.y, + a_Rel.z + a_Offset.z, + NeighborType + ) && + IsBlockWater(NeighborType) + ); + } + ); if (ShouldSoak) { @@ -57,22 +73,22 @@ private: { switch (a_Meta) { - case E_META_CONCRETE_POWDER_WHITE: return 8; - case E_META_CONCRETE_POWDER_ORANGE: return 15; - case E_META_CONCRETE_POWDER_MAGENTA: return 16; - case E_META_CONCRETE_POWDER_LIGHTBLUE: return 17; - case E_META_CONCRETE_POWDER_YELLOW: return 18; + case E_META_CONCRETE_POWDER_WHITE: return 8; + case E_META_CONCRETE_POWDER_ORANGE: return 15; + case E_META_CONCRETE_POWDER_MAGENTA: return 16; + case E_META_CONCRETE_POWDER_LIGHTBLUE: return 17; + case E_META_CONCRETE_POWDER_YELLOW: return 18; case E_META_CONCRETE_POWDER_LIGHTGREEN: return 19; - case E_META_CONCRETE_POWDER_PINK: return 20; - case E_META_CONCRETE_POWDER_GRAY: return 21; - case E_META_CONCRETE_POWDER_LIGHTGRAY: return 22; - case E_META_CONCRETE_POWDER_CYAN: return 23; - case E_META_CONCRETE_POWDER_PURPLE: return 24; - case E_META_CONCRETE_POWDER_BLUE: return 25; - case E_META_CONCRETE_POWDER_BROWN: return 26; - case E_META_CONCRETE_POWDER_GREEN: return 27; - case E_META_CONCRETE_POWDER_RED: return 28; - case E_META_CONCRETE_POWDER_BLACK: return 29; + case E_META_CONCRETE_POWDER_PINK: return 20; + case E_META_CONCRETE_POWDER_GRAY: return 21; + case E_META_CONCRETE_POWDER_LIGHTGRAY: return 22; + case E_META_CONCRETE_POWDER_CYAN: return 23; + case E_META_CONCRETE_POWDER_PURPLE: return 24; + case E_META_CONCRETE_POWDER_BLUE: return 25; + case E_META_CONCRETE_POWDER_BROWN: return 26; + case E_META_CONCRETE_POWDER_GREEN: return 27; + case E_META_CONCRETE_POWDER_RED: return 28; + case E_META_CONCRETE_POWDER_BLACK: return 29; default: { ASSERT(!"Unhandled meta in concrete powder handler!"); diff --git a/src/Blocks/BlockCrops.h b/src/Blocks/BlockCrops.h index b323ace10..6a9a18637 100644 --- a/src/Blocks/BlockCrops.h +++ b/src/Blocks/BlockCrops.h @@ -9,18 +9,14 @@ /** Common class that takes care of beetroots, carrots, potatoes and wheat */ -template <NIBBLETYPE RipeMeta> -class cBlockCropsHandler final : - public cBlockPlant<true> +template <NIBBLETYPE RipeMeta> class cBlockCropsHandler final : public cBlockPlant<true> { using Super = cBlockPlant<true>; -public: - + public: using Super::Super; -private: - + private: /** Calculate the number of seeds to drop when the crop is broken. */ static char CalculateSeedCount(char a_Min, char a_BaseRolls, unsigned char a_FortuneLevel) { diff --git a/src/Blocks/BlockDaylightSensor.h b/src/Blocks/BlockDaylightSensor.h index 792e7d042..42de03683 100644 --- a/src/Blocks/BlockDaylightSensor.h +++ b/src/Blocks/BlockDaylightSensor.h @@ -7,17 +7,14 @@ -class cBlockDaylightSensorHandler final : - public cBlockHandler +class cBlockDaylightSensorHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual bool OnUse( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, @@ -43,12 +40,9 @@ private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { // Always drop the regular daylight sensor: - return { E_BLOCK_DAYLIGHT_SENSOR }; + return {E_BLOCK_DAYLIGHT_SENSOR}; } - virtual bool IsUseable(void) const override - { - return true; - } + virtual bool IsUseable(void) const override { return true; } }; diff --git a/src/Blocks/BlockDeadBush.h b/src/Blocks/BlockDeadBush.h index 080dd150c..b0a77daf2 100644 --- a/src/Blocks/BlockDeadBush.h +++ b/src/Blocks/BlockDeadBush.h @@ -7,18 +7,22 @@ -class cBlockDeadBushHandler final : - public cBlockHandler +class cBlockDeadBushHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - - virtual bool DoesIgnoreBuildCollision(const cWorld & a_World, const cItem & a_HeldItem, const Vector3i a_Position, const NIBBLETYPE a_Meta, const eBlockFace a_ClickedBlockFace, const bool a_ClickedDirectly) const override + private: + virtual bool DoesIgnoreBuildCollision( + const cWorld & a_World, + const cItem & a_HeldItem, + const Vector3i a_Position, + const NIBBLETYPE a_Meta, + const eBlockFace a_ClickedBlockFace, + const bool a_ClickedDirectly + ) const override { return true; } @@ -78,4 +82,4 @@ private: UNUSED(a_Meta); return 0; } -} ; +}; diff --git a/src/Blocks/BlockDefaultBlock.h b/src/Blocks/BlockDefaultBlock.h index 5aed0749b..b1fd961be 100644 --- a/src/Blocks/BlockDefaultBlock.h +++ b/src/Blocks/BlockDefaultBlock.h @@ -5,10 +5,8 @@ -class cDefaultBlockHandler final : - public cBlockHandler +class cDefaultBlockHandler final : public cBlockHandler { -public: - + public: using cBlockHandler::cBlockHandler; }; diff --git a/src/Blocks/BlockDirt.h b/src/Blocks/BlockDirt.h index 1a6483367..34202865a 100644 --- a/src/Blocks/BlockDirt.h +++ b/src/Blocks/BlockDirt.h @@ -7,17 +7,14 @@ -class cBlockDirtHandler final : - public cBlockHandler +class cBlockDirtHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { if (a_BlockMeta == E_META_DIRT_COARSE) @@ -40,8 +37,4 @@ private: UNUSED(a_Meta); return 10; } -} ; - - - - +}; diff --git a/src/Blocks/BlockDoor.cpp b/src/Blocks/BlockDoor.cpp index d97bd9696..c980a74c6 100644 --- a/src/Blocks/BlockDoor.cpp +++ b/src/Blocks/BlockDoor.cpp @@ -8,10 +8,12 @@ void cBlockDoorHandler::OnBroken( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, - Vector3i a_BlockPos, BLOCKTYPE a_OldBlockType, - NIBBLETYPE a_OldBlockMeta, - const cEntity * a_Digger + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, + Vector3i a_BlockPos, + BLOCKTYPE a_OldBlockType, + NIBBLETYPE a_OldBlockMeta, + const cEntity * a_Digger ) const { UNUSED(a_Digger); @@ -69,7 +71,12 @@ bool cBlockDoorHandler::OnUse( case E_BLOCK_OAK_DOOR: { ChangeDoor(a_ChunkInterface, a_BlockPos); - a_Player.GetWorld()->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_WOODEN_DOOR_OPEN, a_BlockPos, 0, a_Player.GetClientHandle()); + a_Player.GetWorld()->BroadcastSoundParticleEffect( + EffectID::SFX_RANDOM_WOODEN_DOOR_OPEN, + a_BlockPos, + 0, + a_Player.GetClientHandle() + ); break; } case E_BLOCK_IRON_DOOR: @@ -119,7 +126,14 @@ void cBlockDoorHandler::OnCancelRightClick( -cBoundingBox cBlockDoorHandler::GetPlacementCollisionBox(BLOCKTYPE a_XM, BLOCKTYPE a_XP, BLOCKTYPE a_YM, BLOCKTYPE a_YP, BLOCKTYPE a_ZM, BLOCKTYPE a_ZP) const +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); @@ -173,9 +187,9 @@ NIBBLETYPE cBlockDoorHandler::MetaMirrorXY(NIBBLETYPE a_Meta) const */ // Note: Currently, you can not properly mirror the hinges on a double door. The orientation of the door is stored - // in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time, - // so the function can only see either the hinge position or orientation, but not both, at any given time. The class itself - // needs extra datamembers. + // in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at + // a time, so the function can only see either the hinge position or orientation, but not both, at any given time. + // The class itself needs extra datamembers. if (a_Meta & 0x08) { return a_Meta; @@ -205,9 +219,9 @@ NIBBLETYPE cBlockDoorHandler::MetaMirrorYZ(NIBBLETYPE a_Meta) const // Return a_Meta if panel is a top panel (0x08 bit is set to 1) // Note: Currently, you can not properly mirror the hinges on a double door. The orientation of the door is stored - // in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time, - // so the function can only see either the hinge position or orientation, but not both, at any given time.The class itself - // needs extra datamembers. + // in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at + // a time, so the function can only see either the hinge position or orientation, but not both, at any given + // time.The class itself needs extra datamembers. if (a_Meta & 0x08) { @@ -227,6 +241,3 @@ NIBBLETYPE cBlockDoorHandler::MetaMirrorYZ(NIBBLETYPE a_Meta) const // Not Facing North or South; No change. return a_Meta; } - - - diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h index 1b5c33d46..8647dc965 100644 --- a/src/Blocks/BlockDoor.h +++ b/src/Blocks/BlockDoor.h @@ -13,13 +13,11 @@ -class cBlockDoorHandler final : - public cYawRotator<cBlockHandler, 0x03, 0x03, 0x00, 0x01, 0x02> +class cBlockDoorHandler final : public cYawRotator<cBlockHandler, 0x03, 0x03, 0x00, 0x01, 0x02> { using Super = cYawRotator<cBlockHandler, 0x03, 0x03, 0x00, 0x01, 0x02>; -public: - + public: using Super::Super; /** Returns true if door can be placed on the specified block type. */ @@ -120,12 +118,13 @@ public: } } -private: - + private: virtual void OnBroken( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, - BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta, + BLOCKTYPE a_OldBlockType, + NIBBLETYPE a_OldBlockMeta, const cEntity * a_Digger ) const override; @@ -147,10 +146,17 @@ private: ) const 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; - virtual cBoundingBox GetPlacementCollisionBox(BLOCKTYPE a_XM, BLOCKTYPE a_XP, BLOCKTYPE a_YM, BLOCKTYPE a_YP, BLOCKTYPE a_ZM, BLOCKTYPE a_ZP) 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; + virtual cBoundingBox GetPlacementCollisionBox( + BLOCKTYPE a_XM, + BLOCKTYPE a_XP, + BLOCKTYPE a_YM, + BLOCKTYPE a_YP, + BLOCKTYPE a_ZM, + BLOCKTYPE a_ZP + ) const override; @@ -179,10 +185,7 @@ private: - virtual bool IsUseable(void) const override - { - return true; - } + virtual bool IsUseable(void) const override { return true; } @@ -256,13 +259,13 @@ private: UNUSED(a_Meta); switch (m_BlockType) { - case E_BLOCK_OAK_DOOR: return 13; - case E_BLOCK_SPRUCE_DOOR: return 34; - case E_BLOCK_BIRCH_DOOR: return 2; - case E_BLOCK_JUNGLE_DOOR: return 10; + case E_BLOCK_OAK_DOOR: return 13; + case E_BLOCK_SPRUCE_DOOR: return 34; + case E_BLOCK_BIRCH_DOOR: return 2; + case E_BLOCK_JUNGLE_DOOR: return 10; case E_BLOCK_DARK_OAK_DOOR: return 26; - case E_BLOCK_ACACIA_DOOR: return 15; - case E_BLOCK_IRON_DOOR: return 6; + case E_BLOCK_ACACIA_DOOR: return 15; + case E_BLOCK_IRON_DOOR: return 6; default: { ASSERT(!"Unhandled blocktype in door handler!"); @@ -270,8 +273,4 @@ private: } } } -} ; - - - - +}; diff --git a/src/Blocks/BlockDropSpenser.h b/src/Blocks/BlockDropSpenser.h index 050adf0f1..8f5881d70 100644 --- a/src/Blocks/BlockDropSpenser.h +++ b/src/Blocks/BlockDropSpenser.h @@ -11,20 +11,19 @@ -class cBlockDropSpenserHandler final : - public cDisplacementYawRotator<cClearMetaOnDrop<cBlockEntityHandler>, 0x07, 0x03, 0x04, 0x02, 0x05, 0x01, 0x00> +class cBlockDropSpenserHandler final + : public cDisplacementYawRotator<cClearMetaOnDrop<cBlockEntityHandler>, 0x07, 0x03, 0x04, 0x02, 0x05, 0x01, 0x00> { - using Super = cDisplacementYawRotator<cClearMetaOnDrop<cBlockEntityHandler>, 0x07, 0x03, 0x04, 0x02, 0x05, 0x01, 0x00>; - -public: + using Super = + cDisplacementYawRotator<cClearMetaOnDrop<cBlockEntityHandler>, 0x07, 0x03, 0x04, 0x02, 0x05, 0x01, 0x00>; + public: using Super::Super; -private: - + private: 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 ba3932e5c..17db41cc4 100644 --- a/src/Blocks/BlockEnchantingTable.h +++ b/src/Blocks/BlockEnchantingTable.h @@ -11,17 +11,14 @@ -class cBlockEnchantingTableHandler final : - public cBlockHandler +class cBlockEnchantingTableHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual bool OnUse( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, @@ -32,19 +29,22 @@ private: ) const override { AString WindowName = "Enchant"; - a_WorldInterface.DoWithBlockEntityAt(a_BlockPos, [&WindowName](cBlockEntity & a_Entity) - { - ASSERT(a_Entity.GetBlockType() == E_BLOCK_ENCHANTMENT_TABLE); - - const auto & EnchantingTable = static_cast<cEnchantingTableEntity &>(a_Entity); - const auto & CustomName = EnchantingTable.GetCustomName(); - if (!CustomName.empty()) + a_WorldInterface.DoWithBlockEntityAt( + a_BlockPos, + [&WindowName](cBlockEntity & a_Entity) { - WindowName = CustomName; - } + ASSERT(a_Entity.GetBlockType() == E_BLOCK_ENCHANTMENT_TABLE); - return false; - }); + const auto & EnchantingTable = static_cast<cEnchantingTableEntity &>(a_Entity); + const auto & CustomName = EnchantingTable.GetCustomName(); + if (!CustomName.empty()) + { + WindowName = CustomName; + } + + return false; + } + ); cWindow * Window = new cEnchantingWindow(a_BlockPos, std::move(WindowName)); a_Player.OpenWindow(*Window); @@ -53,10 +53,7 @@ private: } - virtual bool IsUseable(void) const override - { - return true; - } + virtual bool IsUseable(void) const override { return true; } virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override diff --git a/src/Blocks/BlockEndPortalFrame.h b/src/Blocks/BlockEndPortalFrame.h index 68e6e09fe..8dd09aafd 100644 --- a/src/Blocks/BlockEndPortalFrame.h +++ b/src/Blocks/BlockEndPortalFrame.h @@ -7,29 +7,33 @@ -class cBlockEndPortalFrameHandler final : - public cYawRotator<cBlockHandler, 0x03, - E_META_END_PORTAL_FRAME_ZP, - E_META_END_PORTAL_FRAME_XM, - E_META_END_PORTAL_FRAME_ZM, - E_META_END_PORTAL_FRAME_XP - > +class cBlockEndPortalFrameHandler final : public cYawRotator< + cBlockHandler, + 0x03, + E_META_END_PORTAL_FRAME_ZP, + E_META_END_PORTAL_FRAME_XM, + E_META_END_PORTAL_FRAME_ZM, + E_META_END_PORTAL_FRAME_XP> { using Super = cYawRotator< - cBlockHandler, 0x03, + cBlockHandler, + 0x03, E_META_END_PORTAL_FRAME_ZP, E_META_END_PORTAL_FRAME_XM, E_META_END_PORTAL_FRAME_ZM, - E_META_END_PORTAL_FRAME_XP - >; - -public: + E_META_END_PORTAL_FRAME_XP>; + public: using Super::Super; -private: - - virtual void OnPlaced(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) const override + private: + 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); @@ -46,7 +50,12 @@ private: /** 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) + static bool FindAndSetPortal( + Vector3i a_FirstFrame, + NIBBLETYPE a_Direction, + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface + ) { /* PORTAL FINDING ALGORITH @@ -54,8 +63,10 @@ private: - 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. + - 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. */ @@ -66,25 +77,23 @@ private: 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 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 + 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 + {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 }; + int EdgeWidth[4] = {1, 1, 1, 1}; NIBBLETYPE CurrentDirection = a_Direction; Vector3i CurrentPos = a_FirstFrame; @@ -152,7 +161,8 @@ private: { for (int j = 0; j < EdgeWidth[1]; j++) { - a_ChunkInterface.SetBlock(NorthWestCorner.x + i, NorthWestCorner.y, NorthWestCorner.z + j, E_BLOCK_END_PORTAL, 0); + 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. } } @@ -171,8 +181,7 @@ private: return ( a_ChunkInterface.GetBlockTypeMeta(a_BlockPos, BlockType, BlockMeta) && - (BlockType == E_BLOCK_END_PORTAL_FRAME) && - (BlockMeta == (a_ShouldFace | E_META_END_PORTAL_FRAME_EYE)) + (BlockType == E_BLOCK_END_PORTAL_FRAME) && (BlockMeta == (a_ShouldFace | E_META_END_PORTAL_FRAME_EYE)) ); } @@ -180,10 +189,7 @@ private: /** Return true if this block is a portal frame. */ - static bool IsPortalFrame(BLOCKTYPE BlockType) - { - return (BlockType == E_BLOCK_END_PORTAL_FRAME); - } + static bool IsPortalFrame(BLOCKTYPE BlockType) { return (BlockType == E_BLOCK_END_PORTAL_FRAME); } @@ -195,7 +201,3 @@ private: return 27; } }; - - - - diff --git a/src/Blocks/BlockEnderChest.h b/src/Blocks/BlockEnderChest.h index 2e0da0f17..d2fb6c983 100644 --- a/src/Blocks/BlockEnderChest.h +++ b/src/Blocks/BlockEnderChest.h @@ -6,24 +6,18 @@ -class cBlockEnderChestHandler final : - public cYawRotator<cBlockEntityHandler, 0x07, 0x03, 0x04, 0x02, 0x05> +class cBlockEnderChestHandler final : public cYawRotator<cBlockEntityHandler, 0x07, 0x03, 0x04, 0x02, 0x05> { using Super = cYawRotator<cBlockEntityHandler, 0x07, 0x03, 0x04, 0x02, 0x05>; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { // Only drop something when mined with a pickaxe: - if ( - (a_Tool != nullptr) && - ItemCategory::IsPickaxe(a_Tool->m_ItemType) - ) + if ((a_Tool != nullptr) && ItemCategory::IsPickaxe(a_Tool->m_ItemType)) { // Only drop self when mined with a silk-touch pickaxe: if (a_Tool->m_Enchantments.GetLevel(cEnchantments::enchSilkTouch) > 0) @@ -36,5 +30,4 @@ private: return {}; } - }; diff --git a/src/Blocks/BlockEntity.h b/src/Blocks/BlockEntity.h index c10f5d769..9f1ebe751 100644 --- a/src/Blocks/BlockEntity.h +++ b/src/Blocks/BlockEntity.h @@ -11,21 +11,17 @@ /** Wrapper for blocks that have a cBlockEntity descendant attached to them and can be "used" by the player. Forwards the "use" event to the block entity. */ -class cBlockEntityHandler : - public cBlockHandler +class cBlockEntityHandler : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -protected: - + protected: ~cBlockEntityHandler() = default; -private: - + private: virtual bool OnUse( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, @@ -38,20 +34,15 @@ private: return a_ChunkInterface.UseBlockEntity(&a_Player, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z); } - virtual bool IsUseable() const override - { - return true; - } + virtual bool IsUseable() const override { return true; } }; -class cDefaultBlockEntityHandler final : - public cBlockEntityHandler +class cDefaultBlockEntityHandler final : public cBlockEntityHandler { -public: - + public: using cBlockEntityHandler::cBlockEntityHandler; }; diff --git a/src/Blocks/BlockFarmland.h b/src/Blocks/BlockFarmland.h index 8641238ed..8b9d9f57b 100644 --- a/src/Blocks/BlockFarmland.h +++ b/src/Blocks/BlockFarmland.h @@ -19,13 +19,11 @@ -class cBlockFarmlandHandler final : - public cBlockHandler +class cBlockFarmlandHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; /** Turns farmland into dirt. @@ -79,7 +77,8 @@ public: Entity.SetPosY(GroundHeight); return false; - }); + } + ); a_Chunk.SetBlock(a_RelPos, E_BLOCK_DIRT, 0); } @@ -88,8 +87,7 @@ public: -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { return cItem(E_BLOCK_DIRT, 1, 0); @@ -124,7 +122,8 @@ private: } // Farmland too dry. If nothing is growing on top, turn back to dirt: - auto UpperBlock = cChunkDef::IsValidHeight(a_RelPos.addedY(1)) ? a_Chunk.GetBlock(a_RelPos.addedY(1)) : E_BLOCK_AIR; + auto UpperBlock = + cChunkDef::IsValidHeight(a_RelPos.addedY(1)) ? a_Chunk.GetBlock(a_RelPos.addedY(1)) : E_BLOCK_AIR; switch (UpperBlock) { case E_BLOCK_BEETROOTS: @@ -150,7 +149,8 @@ private: - virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const 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) @@ -171,11 +171,14 @@ private: { // Until the fix above is done, this line should also suffice: // a_ChunkInterface.SetBlock(a_BlockPos, E_BLOCK_DIRT, 0); - a_ChunkInterface.DoWithChunkAt(a_BlockPos, [&](cChunk & Chunk) - { - TurnToDirt(Chunk, a_BlockPos); - return true; - }); + a_ChunkInterface.DoWithChunkAt( + a_BlockPos, + [&](cChunk & Chunk) + { + TurnToDirt(Chunk, a_BlockPos); + return true; + } + ); } } @@ -183,7 +186,8 @@ private: - /** Returns true if there's either a water source block close enough to hydrate the specified position, or it's raining there. */ + /** Returns true if there's either a water source block close enough to hydrate the specified position, or it's + * raining there. */ static bool IsWaterInNear(const cChunk & a_Chunk, const Vector3i a_RelPos) { if (a_Chunk.IsWeatherWetAt(a_RelPos.addedY(1))) @@ -224,12 +228,8 @@ private: virtual bool CanSustainPlant(BLOCKTYPE a_Plant) const override { return ( - (a_Plant == E_BLOCK_BEETROOTS) || - (a_Plant == E_BLOCK_CROPS) || - (a_Plant == E_BLOCK_CARROTS) || - (a_Plant == E_BLOCK_POTATOES) || - (a_Plant == E_BLOCK_MELON_STEM) || - (a_Plant == E_BLOCK_PUMPKIN_STEM) + (a_Plant == E_BLOCK_BEETROOTS) || (a_Plant == E_BLOCK_CROPS) || (a_Plant == E_BLOCK_CARROTS) || + (a_Plant == E_BLOCK_POTATOES) || (a_Plant == E_BLOCK_MELON_STEM) || (a_Plant == E_BLOCK_PUMPKIN_STEM) ); } -} ; +}; diff --git a/src/Blocks/BlockFence.h b/src/Blocks/BlockFence.h index cc4f35fea..674a9c2a0 100644 --- a/src/Blocks/BlockFence.h +++ b/src/Blocks/BlockFence.h @@ -10,24 +10,28 @@ -class cBlockFenceHandler final : - public cBlockHandler +class cBlockFenceHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + 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) 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) const 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); @@ -144,19 +148,18 @@ private: - virtual bool IsUseable(void) const override - { - return true; - } + virtual bool IsUseable(void) const override { return true; } virtual void OnBroken( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, - BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta, + BLOCKTYPE a_OldBlockType, + NIBBLETYPE a_OldBlockMeta, const cEntity * a_Digger ) const override { @@ -169,7 +172,3 @@ private: } } }; - - - - diff --git a/src/Blocks/BlockFenceGate.h b/src/Blocks/BlockFenceGate.h index f52d8df9c..c188b6a0a 100644 --- a/src/Blocks/BlockFenceGate.h +++ b/src/Blocks/BlockFenceGate.h @@ -8,17 +8,14 @@ -class cBlockFenceGateHandler final : - public cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x03, 0x02, 0x03, 0x00, 0x01>> +class cBlockFenceGateHandler final : public cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x03, 0x02, 0x03, 0x00, 0x01>> { using Super = cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x03, 0x02, 0x03, 0x00, 0x01>>; -public: - + public: using Super::Super; -private: - + private: virtual bool OnUse( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, @@ -42,7 +39,12 @@ private: // Standing aside - use last direction a_ChunkInterface.SetBlockMeta(a_BlockPos, OldMetaData); } - a_Player.GetWorld()->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_FENCE_GATE_OPEN, a_BlockPos, 0, a_Player.GetClientHandle()); + a_Player.GetWorld()->BroadcastSoundParticleEffect( + EffectID::SFX_RANDOM_FENCE_GATE_OPEN, + a_BlockPos, + 0, + a_Player.GetClientHandle() + ); return true; } @@ -65,10 +67,7 @@ private: - virtual bool IsUseable(void) const override - { - return true; - } + virtual bool IsUseable(void) const override { return true; } @@ -79,12 +78,12 @@ private: UNUSED(a_Meta); switch (m_BlockType) { - case E_BLOCK_OAK_FENCE_GATE: return 13; - case E_BLOCK_SPRUCE_FENCE_GATE: return 34; - case E_BLOCK_BIRCH_FENCE_GATE: return 2; - case E_BLOCK_JUNGLE_FENCE_GATE: return 10; + case E_BLOCK_OAK_FENCE_GATE: return 13; + case E_BLOCK_SPRUCE_FENCE_GATE: return 34; + case E_BLOCK_BIRCH_FENCE_GATE: return 2; + case E_BLOCK_JUNGLE_FENCE_GATE: return 10; case E_BLOCK_DARK_OAK_FENCE_GATE: return 26; - case E_BLOCK_ACACIA_FENCE_GATE: return 15; + case E_BLOCK_ACACIA_FENCE_GATE: return 15; default: { ASSERT(!"Unhandled blocktype in fence gate handler!"); @@ -92,8 +91,4 @@ private: } } } -} ; - - - - +}; diff --git a/src/Blocks/BlockFire.h b/src/Blocks/BlockFire.h index a0f5e9a69..caafd4a88 100644 --- a/src/Blocks/BlockFire.h +++ b/src/Blocks/BlockFire.h @@ -7,15 +7,12 @@ -class cBlockFireHandler final : - public cBlockHandler +class cBlockFireHandler final : public cBlockHandler { -public: - + public: using cBlockHandler::cBlockHandler; -private: - + private: struct Scratch { /** Portal boundary and direction variables */ @@ -27,7 +24,13 @@ private: - virtual void OnPlaced(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) const override + virtual void OnPlaced( + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, + Vector3i a_BlockPos, + BLOCKTYPE a_BlockType, + NIBBLETYPE a_BlockMeta + ) const override { /* PORTAL FINDING ALGORITH @@ -36,7 +39,8 @@ private: - Trace upwards to find first obsidian block; aborts if anything other than obsidian or air is encountered. Uses this value as a reference (the 'ceiling') - For both directions (if one fails, try the other), BASE (clicked) block: - - Go in one direction, only stop if a non obsidian block is encountered (abort) OR a portal border is encountered (FindObsidianCeiling returns -1) + - Go in one direction, only stop if a non obsidian block is encountered (abort) OR a portal border is + encountered (FindObsidianCeiling returns -1) - If a border was encountered, go the other direction and repeat above - Write borders to XZP and XZM, write direction portal faces to Dir - Loop through boundary variables, and fill with portal blocks based on Dir with meta from Dir @@ -51,7 +55,14 @@ private: 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, Scratch); + FindAndSetPortalFrame( + a_BlockPos.x, + a_BlockPos.y - 1, + a_BlockPos.z, + a_ChunkInterface, + a_WorldInterface, + Scratch + ); } @@ -104,7 +115,9 @@ private: /** Evaluates if coords have a valid border on top, based on MaxY */ 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 + 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 { if (a_ChunkInterface.GetBlock({X, checkBorder, Z}) != E_BLOCK_OBSIDIAN) { @@ -120,11 +133,25 @@ private: - /** Finds entire frame in any direction with the coordinates of a base block and fills hole with nether portal (START HERE) */ - static void FindAndSetPortalFrame(int X, int Y, int Z, cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, Scratch & a_Scratch) + /** Finds entire frame in any direction with the coordinates of a base block and fills hole with nether portal + * (START HERE) */ + 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 + 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 if (MaxY == 0) // Oh noes! Not a portal coordinate :( { @@ -141,13 +168,15 @@ private: int PortalHeight = MaxY - Y - 1; int PortalWidth = a_Scratch.XZP - a_Scratch.XZM + 1; - if ((PortalHeight < a_WorldInterface.GetMinNetherPortalHeight()) || (PortalHeight > a_WorldInterface.GetMaxNetherPortalHeight())) + if ((PortalHeight < a_WorldInterface.GetMinNetherPortalHeight()) || + (PortalHeight > a_WorldInterface.GetMaxNetherPortalHeight())) { // The portal isn't high enough, or is too high return; } - if ((PortalWidth < a_WorldInterface.GetMinNetherPortalWidth()) || (PortalWidth > a_WorldInterface.GetMaxNetherPortalWidth())) + if ((PortalWidth < a_WorldInterface.GetMinNetherPortalWidth()) || + (PortalWidth > a_WorldInterface.GetMaxNetherPortalWidth())) { // The portal isn't wide enough, or is too wide return; @@ -171,17 +200,28 @@ private: /** 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 */ - static bool FindPortalSliceX(int X1, int X2, int Y, int Z, int MaxY, cChunkInterface & a_ChunkInterface, Scratch & a_Scratch) + static bool FindPortalSliceX( + int X1, + int X2, + int Y, + int Z, + int MaxY, + cChunkInterface & a_ChunkInterface, + Scratch & a_Scratch + ) { 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 + 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 { int Value = FindObsidianCeiling(X1, Y, Z, a_ChunkInterface, MaxY); int ValueTwo = FindObsidianCeiling(X1, Y + 1, Z, a_ChunkInterface, MaxY); // For corners without obsidian if ((Value == -1) || (ValueTwo == -1)) // FindObsidianCeiling returns -1 upon frame-find { - FoundFrameXP = true; // Found a frame border in this direction, proceed in other direction (don't go further) + FoundFrameXP = + true; // Found a frame border in this direction, proceed in other direction (don't go further) break; } else if ((Value != MaxY) && (ValueTwo != MaxY)) // Make sure that there is a valid portal 'slice' @@ -190,7 +230,9 @@ private: } } 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) + 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); int ValueTwo = FindObsidianCeiling(X2, Y + 1, Z, a_ChunkInterface, MaxY); @@ -210,11 +252,21 @@ private: } /** Evaluates if coords are a portal going ZP / ZM; returns true if so, and writes boundaries to variable */ - static bool FindPortalSliceZ(int X, int Y, int Z1, int Z2, int MaxY, cChunkInterface & a_ChunkInterface, Scratch & a_Scratch) + static bool FindPortalSliceZ( + int X, + int Y, + int Z1, + int Z2, + int MaxY, + cChunkInterface & a_ChunkInterface, + Scratch & a_Scratch + ) { 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++) + for (; ((a_ChunkInterface.GetBlock({X, Y, Z1}) == E_BLOCK_OBSIDIAN) || + (a_ChunkInterface.GetBlock({X, Y + 1, Z1}) == E_BLOCK_OBSIDIAN)); + Z1++) { int Value = FindObsidianCeiling(X, Y, Z1, a_ChunkInterface, MaxY); int ValueTwo = FindObsidianCeiling(X, Y + 1, Z1, a_ChunkInterface, MaxY); @@ -229,7 +281,9 @@ private: } } 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--) + 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); int ValueTwo = FindObsidianCeiling(X, Y + 1, Z2, a_ChunkInterface, MaxY); @@ -248,7 +302,14 @@ private: return (FoundFrameZP && FoundFrameZM); } - virtual bool DoesIgnoreBuildCollision(const cWorld & a_World, const cItem & a_HeldItem, const Vector3i a_Position, const NIBBLETYPE a_Meta, const eBlockFace a_ClickedBlockFace, const bool a_ClickedDirectly) const override + virtual bool DoesIgnoreBuildCollision( + const cWorld & a_World, + const cItem & a_HeldItem, + const Vector3i a_Position, + const NIBBLETYPE a_Meta, + const eBlockFace a_ClickedBlockFace, + const bool a_ClickedDirectly + ) const override { return true; } @@ -259,7 +320,3 @@ private: return 15; } }; - - - - diff --git a/src/Blocks/BlockFlower.h b/src/Blocks/BlockFlower.h index 023ba4a37..49a606853 100644 --- a/src/Blocks/BlockFlower.h +++ b/src/Blocks/BlockFlower.h @@ -7,17 +7,14 @@ -class cBlockFlowerHandler final : - public cBlockHandler +class cBlockFlowerHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { NIBBLETYPE meta = a_BlockMeta & 0x7; @@ -42,8 +39,4 @@ private: UNUSED(a_Meta); return 7; } -} ; - - - - +}; diff --git a/src/Blocks/BlockFlowerPot.h b/src/Blocks/BlockFlowerPot.h index 3e12e2d02..b5c1d785e 100644 --- a/src/Blocks/BlockFlowerPot.h +++ b/src/Blocks/BlockFlowerPot.h @@ -5,17 +5,14 @@ -class cBlockFlowerPotHandler final : - public cBlockEntityHandler +class cBlockFlowerPotHandler final : public cBlockEntityHandler { using Super = cBlockEntityHandler; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { return cItem(E_ITEM_FLOWER_POT, 1, 0); @@ -30,8 +27,4 @@ private: UNUSED(a_Meta); return 0; } -} ; - - - - +}; diff --git a/src/Blocks/BlockFluid.h b/src/Blocks/BlockFluid.h index ab71ee7c3..587e8a049 100644 --- a/src/Blocks/BlockFluid.h +++ b/src/Blocks/BlockFluid.h @@ -7,21 +7,17 @@ -class cBlockFluidHandler : - public cBlockHandler +class cBlockFluidHandler : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -protected: - + protected: ~cBlockFluidHandler() = default; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { // No pickups @@ -32,27 +28,31 @@ private: - virtual bool DoesIgnoreBuildCollision(const cWorld & a_World, const cItem & a_HeldItem, const Vector3i a_Position, const NIBBLETYPE a_Meta, const eBlockFace a_ClickedBlockFace, const bool a_ClickedDirectly) const override + virtual bool DoesIgnoreBuildCollision( + const cWorld & a_World, + const cItem & a_HeldItem, + const Vector3i a_Position, + const NIBBLETYPE a_Meta, + const eBlockFace a_ClickedBlockFace, + const bool a_ClickedDirectly + ) const override { return true; } -} ; +}; -class cBlockLavaHandler final : - public cBlockFluidHandler +class cBlockLavaHandler final : public cBlockFluidHandler { using Super = cBlockFluidHandler; -public: - + public: using Super::Super; -private: - + private: virtual void OnUpdate( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, @@ -80,40 +80,33 @@ private: { // Pick a random block next to this lava block: int rnd = a_Chunk.GetWorld()->GetTickRandomNumber(cChunkDef::NumBlocks * 8) / 7; - int x = (rnd % 3) - 1; // -1 .. 1 - int y = ((rnd / 4) % 4) - 1; // -1 .. 2 + int x = (rnd % 3) - 1; // -1 .. 1 + int y = ((rnd / 4) % 4) - 1; // -1 .. 2 int z = ((rnd / 16) % 3) - 1; // -1 .. 1 auto Pos = a_RelPos + Vector3i(x, y, z); // Check if it's fuel: BLOCKTYPE BlockType; - if ( - !cChunkDef::IsValidHeight(Pos) || - !a_Chunk.UnboundedRelGetBlockType(Pos, BlockType) || - !cFireSimulator::IsFuel(BlockType) - ) + if (!cChunkDef::IsValidHeight(Pos) || !a_Chunk.UnboundedRelGetBlockType(Pos, BlockType) || + !cFireSimulator::IsFuel(BlockType)) { return false; } // Try to set it on fire: - static Vector3i CrossCoords[] = - { - {-1, 0, 0}, - { 1, 0, 0}, - { 0, -1, 0}, - { 0, 1, 0}, - { 0, 0, -1}, - { 0, 0, 1}, - } ; + static Vector3i CrossCoords[] = { + {-1, 0, 0}, + {1, 0, 0}, + {0, -1, 0}, + {0, 1, 0}, + {0, 0, -1}, + {0, 0, 1}, + }; for (size_t i = 0; i < ARRAYCOUNT(CrossCoords); i++) { auto NeighborPos = Pos + CrossCoords[i]; - if ( - cChunkDef::IsValidHeight(NeighborPos) && - a_Chunk.UnboundedRelGetBlockType(NeighborPos, BlockType) && - (BlockType == E_BLOCK_AIR) - ) + if (cChunkDef::IsValidHeight(NeighborPos) && a_Chunk.UnboundedRelGetBlockType(NeighborPos, BlockType) && + (BlockType == E_BLOCK_AIR)) { // This is an air block next to a fuel next to lava, light the fuel block up: a_Chunk.UnboundedRelSetBlock(NeighborPos, E_BLOCK_FIRE, 0); @@ -137,25 +130,19 @@ private: - virtual bool CanSustainPlant(BLOCKTYPE a_Plant) const override - { - return false; - } -} ; + virtual bool CanSustainPlant(BLOCKTYPE a_Plant) const override { return false; } +}; -class cBlockWaterHandler final : - public cBlockFluidHandler +class cBlockWaterHandler final : public cBlockFluidHandler { -public: - + public: using cBlockFluidHandler::cBlockFluidHandler; -private: - + private: virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override { UNUSED(a_Meta); @@ -170,12 +157,8 @@ private: virtual bool CanSustainPlant(BLOCKTYPE a_Plant) const override { return ( - (a_Plant == E_BLOCK_BEETROOTS) || - (a_Plant == E_BLOCK_CROPS) || - (a_Plant == E_BLOCK_CARROTS) || - (a_Plant == E_BLOCK_POTATOES) || - (a_Plant == E_BLOCK_MELON_STEM) || - (a_Plant == E_BLOCK_PUMPKIN_STEM) + (a_Plant == E_BLOCK_BEETROOTS) || (a_Plant == E_BLOCK_CROPS) || (a_Plant == E_BLOCK_CARROTS) || + (a_Plant == E_BLOCK_POTATOES) || (a_Plant == E_BLOCK_MELON_STEM) || (a_Plant == E_BLOCK_PUMPKIN_STEM) ); } }; diff --git a/src/Blocks/BlockFurnace.h b/src/Blocks/BlockFurnace.h index 8cdc9489a..a140c9d28 100644 --- a/src/Blocks/BlockFurnace.h +++ b/src/Blocks/BlockFurnace.h @@ -6,17 +6,14 @@ -class cBlockFurnaceHandler final : - public cYawRotator<cBlockEntityHandler, 0x07, 0x03, 0x04, 0x02, 0x05> +class cBlockFurnaceHandler final : public cYawRotator<cBlockEntityHandler, 0x07, 0x03, 0x04, 0x02, 0x05> { using Super = cYawRotator<cBlockEntityHandler, 0x07, 0x03, 0x04, 0x02, 0x05>; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { return cItem(E_BLOCK_FURNACE); // We can't drop a lit furnace @@ -31,8 +28,4 @@ private: UNUSED(a_Meta); return 11; } -} ; - - - - +}; diff --git a/src/Blocks/BlockGlass.h b/src/Blocks/BlockGlass.h index 6b4bb79de..82b05fe2c 100644 --- a/src/Blocks/BlockGlass.h +++ b/src/Blocks/BlockGlass.h @@ -7,15 +7,12 @@ -class cBlockGlassHandler final : - public cBlockHandler +class cBlockGlassHandler final : public cBlockHandler { -public: - + public: using cBlockHandler::cBlockHandler; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { // Only drop self when mined with silk-touch: @@ -35,8 +32,4 @@ private: UNUSED(a_Meta); return 0; } -} ; - - - - +}; diff --git a/src/Blocks/BlockGlazedTerracotta.h b/src/Blocks/BlockGlazedTerracotta.h index 0975f1ecd..63ec84ec0 100644 --- a/src/Blocks/BlockGlazedTerracotta.h +++ b/src/Blocks/BlockGlazedTerracotta.h @@ -7,12 +7,11 @@ -class cBlockGlazedTerracottaHandler final : - public cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03>> +class cBlockGlazedTerracottaHandler final + : public cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03>> { using Super = cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03>>; -public: - + public: using Super::Super; }; diff --git a/src/Blocks/BlockGlowstone.h b/src/Blocks/BlockGlowstone.h index f9fd8842c..f04e16a9c 100644 --- a/src/Blocks/BlockGlowstone.h +++ b/src/Blocks/BlockGlowstone.h @@ -7,15 +7,12 @@ -class cBlockGlowstoneHandler final : - public cBlockHandler +class cBlockGlowstoneHandler final : public cBlockHandler { -public: - + public: using cBlockHandler::cBlockHandler; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { // Drop self only when using silk-touch: @@ -38,8 +35,4 @@ private: UNUSED(a_Meta); return 2; } -} ; - - - - +}; diff --git a/src/Blocks/BlockGrass.h b/src/Blocks/BlockGrass.h index 412291382..7c465256a 100644 --- a/src/Blocks/BlockGrass.h +++ b/src/Blocks/BlockGrass.h @@ -10,15 +10,12 @@ -class cBlockGrassHandler final : - public cBlockHandler +class cBlockGrassHandler final : public cBlockHandler { -public: - + public: using cBlockHandler::cBlockHandler; -private: - + private: enum class Survivability { // Light level so good that the grass can try to spread to neighbours @@ -91,8 +88,7 @@ private: return 1; } -private: - + private: /** Check if conditions are favourable to a grass block at the given position. If they are not, the grass dies and is turned to dirt. Returns whether conditions are so good that the grass can try to spread to neighbours. */ @@ -107,9 +103,7 @@ private: // Grass turns back to dirt when the block above it is not transparent or water. // It does not turn to dirt when a snow layer is above. const auto Above = a_Chunk.GetBlock(AbovePos); - if ( - (Above != E_BLOCK_SNOW) && - (!cBlockInfo::IsTransparent(Above) || IsBlockWater(Above))) + if ((Above != E_BLOCK_SNOW) && (!cBlockInfo::IsTransparent(Above) || IsBlockWater(Above))) { return Survivability::DieInDarkness; } @@ -139,7 +133,7 @@ private: return; } - BLOCKTYPE DestBlock; + BLOCKTYPE DestBlock; NIBBLETYPE DestMeta; Chunk->GetBlockTypeMeta(a_RelPos, DestBlock, DestMeta); @@ -153,12 +147,7 @@ private: const auto Above = Chunk->GetBlock(AbovePos); const auto Light = std::max(Chunk->GetBlockLight(AbovePos), Chunk->GetSkyLightAltered(AbovePos)); - if ( - (Light > 4) && - cBlockInfo::IsTransparent(Above) && - !IsBlockLava(Above) && - !IsBlockWaterOrIce(Above) - ) + if ((Light > 4) && cBlockInfo::IsTransparent(Above) && !IsBlockLava(Above) && !IsBlockWaterOrIce(Above)) { const auto AbsPos = Chunk->RelativeToAbsolute(a_RelPos); if (!cRoot::Get()->GetPluginManager()->CallHookBlockSpread(*Chunk->GetWorld(), AbsPos, ssGrassSpread)) @@ -167,4 +156,4 @@ private: } } } -} ; +}; diff --git a/src/Blocks/BlockGravel.h b/src/Blocks/BlockGravel.h index 4713e6488..1818e8d9f 100644 --- a/src/Blocks/BlockGravel.h +++ b/src/Blocks/BlockGravel.h @@ -7,15 +7,12 @@ -class cBlockGravelHandler final : - public cBlockHandler +class cBlockGravelHandler final : public cBlockHandler { -public: - + public: using cBlockHandler::cBlockHandler; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { if (ToolHasSilkTouch(a_Tool)) @@ -42,8 +39,4 @@ private: UNUSED(a_Meta); return 11; } -} ; - - - - +}; diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 6691f151f..c03523dfb 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -129,29 +129,34 @@ public: { // Test the CW / CCW rotations: NIBBLETYPE TestMeta; - TestMeta = Handler->MetaRotateCW(Handler->MetaRotateCW(Handler->MetaRotateCW(Handler->MetaRotateCW(Meta)))); - if (TestMeta != Meta) + TestMeta = +Handler->MetaRotateCW(Handler->MetaRotateCW(Handler->MetaRotateCW(Handler->MetaRotateCW(Meta)))); if (TestMeta != Meta) { // 4 CW rotations should produce no change in the meta - printf("Handler for blocktype %d (%s) fails CW 4-rotation test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta); + printf("Handler for blocktype %d (%s) fails CW 4-rotation test for meta %d: got back %d\n", Type, +BlockName.c_str(), Meta, TestMeta); } - TestMeta = Handler->MetaRotateCCW(Handler->MetaRotateCCW(Handler->MetaRotateCCW(Handler->MetaRotateCCW(Meta)))); - if (TestMeta != Meta) + TestMeta = +Handler->MetaRotateCCW(Handler->MetaRotateCCW(Handler->MetaRotateCCW(Handler->MetaRotateCCW(Meta)))); if (TestMeta != +Meta) { // 4 CCW rotations should produce no change in the meta - printf("Handler for blocktype %d (%s) fails CCW 4-rotation test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta); + printf("Handler for blocktype %d (%s) fails CCW 4-rotation test for meta %d: got back %d\n", Type, +BlockName.c_str(), Meta, TestMeta); } TestMeta = Handler->MetaRotateCCW(Handler->MetaRotateCW(Meta)); if (TestMeta != Meta) { // CCW rotation of a CW rotation should produce no change in the meta - printf("Handler for blocktype %d (%s) fails CCW(CW) rotation test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta); + printf("Handler for blocktype %d (%s) fails CCW(CW) rotation test for meta %d: got back %d\n", Type, +BlockName.c_str(), Meta, TestMeta); } TestMeta = Handler->MetaRotateCW(Handler->MetaRotateCCW(Meta)); if (TestMeta != Meta) { // CW rotation of a CCW rotation should produce no change in the meta - printf("Handler for blocktype %d (%s) fails CW(CCW) rotation test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta); + printf("Handler for blocktype %d (%s) fails CW(CCW) rotation test for meta %d: got back %d\n", Type, +BlockName.c_str(), Meta, TestMeta); } // Test the mirroring: @@ -159,27 +164,31 @@ public: if (TestMeta != Meta) { // Double-mirroring should produce the same meta: - printf("Handler for blocktype %d (%s) fails XY mirror test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta); + printf("Handler for blocktype %d (%s) fails XY mirror test for meta %d: got back %d\n", Type, +BlockName.c_str(), Meta, TestMeta); } TestMeta = Handler->MetaMirrorXZ(Handler->MetaMirrorXZ(Meta)); if (TestMeta != Meta) { // Double-mirroring should produce the same meta: - printf("Handler for blocktype %d (%s) fails XZ mirror test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta); + printf("Handler for blocktype %d (%s) fails XZ mirror test for meta %d: got back %d\n", Type, +BlockName.c_str(), Meta, TestMeta); } TestMeta = Handler->MetaMirrorYZ(Handler->MetaMirrorYZ(Meta)); if (TestMeta != Meta) { // Double-mirroring should produce the same meta: - printf("Handler for blocktype %d (%s) fails YZ mirror test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta); + printf("Handler for blocktype %d (%s) fails YZ mirror test for meta %d: got back %d\n", Type, +BlockName.c_str(), Meta, TestMeta); } // Test mirror-rotating: - TestMeta = Handler->MetaRotateCW(Handler->MetaRotateCW(Handler->MetaMirrorXY(Handler->MetaMirrorYZ(Meta)))); - if (TestMeta != Meta) + TestMeta = +Handler->MetaRotateCW(Handler->MetaRotateCW(Handler->MetaMirrorXY(Handler->MetaMirrorYZ(Meta)))); if (TestMeta != Meta) { // 2 CW rotations should be the same as XY, YZ mirroring: - printf("Handler for blocktype %d (%s) fails rotation-mirror test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta); + printf("Handler for blocktype %d (%s) fails rotation-mirror test for meta %d: got back %d\n", Type, +BlockName.c_str(), Meta, TestMeta); } } } // for Type @@ -196,259 +205,259 @@ public: Ensures that a handler can never be nullptr (FS #243) on invalid during restarts or other transition periods. */ namespace { - 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 cBlockAirHandler BlockAirHandler (E_BLOCK_AIR); - constexpr cBlockAnvilHandler BlockAnvilHandler (E_BLOCK_ANVIL); - constexpr cDefaultBlockHandler BlockBarrierHandler (E_BLOCK_BARRIER); - constexpr cDefaultBlockEntityHandler BlockBeaconHandler (E_BLOCK_BEACON); - constexpr cBlockBedHandler BlockBedHandler (E_BLOCK_BED); - constexpr cDefaultBlockHandler 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 cDefaultBlockHandler BlockBlackShulkerBoxHandler (E_BLOCK_BLACK_SHULKER_BOX); - constexpr cBlockGlazedTerracottaHandler BlockBlueGlazedTerracottaHandler (E_BLOCK_BLUE_GLAZED_TERRACOTTA); - constexpr cDefaultBlockHandler BlockBlueShulkerBoxHandler (E_BLOCK_BLUE_SHULKER_BOX); - constexpr cDefaultBlockHandler BlockBoneBlockHandler (E_BLOCK_BONE_BLOCK); - constexpr cBlockBookShelfHandler BlockBookcaseHandler (E_BLOCK_BOOKCASE); - constexpr cBlockBrewingStandHandler BlockBrewingStandHandler (E_BLOCK_BREWING_STAND); - constexpr cDefaultBlockHandler BlockBricksHandler (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 cDefaultBlockHandler 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 cDefaultBlockHandler BlockChorusFlowerHandler (E_BLOCK_CHORUS_FLOWER); - constexpr cDefaultBlockHandler BlockChorusPlantHandler (E_BLOCK_CHORUS_PLANT); - constexpr cDefaultOreHandler BlockClayHandler (E_BLOCK_CLAY); - constexpr cDefaultBlockHandler BlockCoalBlockHandler (E_BLOCK_BLOCK_OF_COAL); - constexpr cDefaultOreHandler BlockCoalOreHandler (E_BLOCK_COAL_ORE); - constexpr cDefaultBlockHandler BlockCobblestoneHandler (E_BLOCK_COBBLESTONE); - constexpr cBlockStairsHandler BlockCobblestoneStairsHandler (E_BLOCK_COBBLESTONE_STAIRS); - constexpr cDefaultBlockHandler 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 cDefaultBlockHandler 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 cDefaultBlockHandler 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 cBlockDaylightSensorHandler BlockDaylightSensorHandler (E_BLOCK_DAYLIGHT_SENSOR); - constexpr cBlockDeadBushHandler BlockDeadBushHandler (E_BLOCK_DEAD_BUSH); - constexpr cBlockRailHandler BlockDetectorRailHandler (E_BLOCK_DETECTOR_RAIL); - constexpr cDefaultBlockHandler BlockDiamondBlockHandler (E_BLOCK_DIAMOND_BLOCK); - constexpr cDefaultOreHandler 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 cDefaultBlockHandler BlockDragonEggHandler (E_BLOCK_DRAGON_EGG); - constexpr cBlockDropSpenserHandler BlockDropperHandler (E_BLOCK_DROPPER); - constexpr cDefaultBlockHandler BlockEmeraldBlockHandler (E_BLOCK_EMERALD_BLOCK); - constexpr cDefaultOreHandler BlockEmeraldOreHandler (E_BLOCK_EMERALD_ORE); - constexpr cBlockEnchantingTableHandler BlockEnchantingTableHandler (E_BLOCK_ENCHANTMENT_TABLE); - constexpr cDefaultBlockHandler BlockEndBricksHandler (E_BLOCK_END_BRICKS); - constexpr cBlockEnderChestHandler BlockEnderChestHandler (E_BLOCK_ENDER_CHEST); - constexpr cDefaultBlockHandler BlockEndGatewayHandler (E_BLOCK_END_GATEWAY); - constexpr cBlockEndPortalFrameHandler BlockEndPortalFrameHandler (E_BLOCK_END_PORTAL_FRAME); - constexpr cDefaultBlockHandler BlockEndPortalHandler (E_BLOCK_END_PORTAL); - constexpr cDefaultBlockHandler BlockEndRodHandler (E_BLOCK_END_ROD); - constexpr cDefaultBlockHandler BlockEndStoneHandler (E_BLOCK_END_STONE); - 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 cDefaultBlockHandler BlockGoldBlockHandler (E_BLOCK_GOLD_BLOCK); - constexpr cDefaultOreHandler BlockGoldOreHandler (E_BLOCK_GOLD_ORE); - constexpr cBlockGrassHandler BlockGrassHandler (E_BLOCK_GRASS); - constexpr cDefaultBlockHandler BlockGrassPathHandler (E_BLOCK_GRASS_PATH); - constexpr cBlockGravelHandler BlockGravelHandler (E_BLOCK_GRAVEL); - constexpr cBlockGlazedTerracottaHandler BlockGrayGlazedTerracottaHandler (E_BLOCK_GRAY_GLAZED_TERRACOTTA); - constexpr cDefaultBlockHandler BlockGrayShulkerBoxHandler (E_BLOCK_GRAY_SHULKER_BOX); - constexpr cBlockGlazedTerracottaHandler BlockGreenGlazedTerracottaHandler (E_BLOCK_GREEN_GLAZED_TERRACOTTA); - constexpr cDefaultBlockHandler BlockGreenShulkerBoxHandler (E_BLOCK_GREEN_SHULKER_BOX); - constexpr cDefaultBlockHandler 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 cBlockHugeMushroomHandler BlockHugeBrownMushroomHandler (E_BLOCK_HUGE_BROWN_MUSHROOM); - constexpr cBlockHugeMushroomHandler BlockHugeRedMushroomHandler (E_BLOCK_HUGE_RED_MUSHROOM); - constexpr cBlockIceHandler BlockIceHandler (E_BLOCK_ICE); - constexpr cBlockComparatorHandler BlockInactiveComparatorHandler (E_BLOCK_INACTIVE_COMPARATOR); - constexpr cBlockInfestedHandler BlockInfestedBlockHandler (E_BLOCK_SILVERFISH_EGG); - constexpr cDefaultBlockHandler BlockIronBarsHandler (E_BLOCK_IRON_BARS); - constexpr cDefaultBlockHandler BlockIronBlockHandler (E_BLOCK_IRON_BLOCK); - constexpr cBlockDoorHandler BlockIronDoorHandler (E_BLOCK_IRON_DOOR); - constexpr cDefaultOreHandler 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 cDefaultBlockHandler BlockLapisBlockHandler (E_BLOCK_LAPIS_BLOCK); - constexpr cDefaultOreHandler 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 cDefaultBlockHandler BlockLightBlueShulkerBoxHandler (E_BLOCK_LIGHT_BLUE_SHULKER_BOX); - constexpr cBlockGlazedTerracottaHandler BlockLightGrayGlazedTerracoHandler(E_BLOCK_LIGHT_GRAY_GLAZED_TERRACOTTA); - constexpr cDefaultBlockHandler 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 cDefaultBlockHandler 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 cDefaultBlockHandler BlockMagentaShulkerBoxHandler (E_BLOCK_MAGENTA_SHULKER_BOX); - constexpr cDefaultBlockHandler 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 cDefaultBlockHandler BlockMossyCobblestoneHandler (E_BLOCK_MOSSY_COBBLESTONE); - constexpr cBlockMyceliumHandler BlockMyceliumHandler (E_BLOCK_MYCELIUM); - constexpr cBlockFenceHandler BlockNetherBrickFenceHandler (E_BLOCK_NETHER_BRICK_FENCE); - constexpr cDefaultBlockHandler BlockNetherBricksHandler (E_BLOCK_NETHER_BRICK); - constexpr cBlockStairsHandler BlockNetherBrickStairsHandler (E_BLOCK_NETHER_BRICK_STAIRS); - constexpr cBlockPortalHandler BlockNetherPortalHandler (E_BLOCK_NETHER_PORTAL); - constexpr cDefaultOreHandler BlockNetherQuartzOreHandler (E_BLOCK_NETHER_QUARTZ_ORE); - constexpr cBlockNetherrack BlockNetherrackHandler (E_BLOCK_NETHERRACK); - constexpr cDefaultBlockHandler BlockNetherWartBlockHandler (E_BLOCK_NETHER_WART_BLOCK); - constexpr cBlockNetherWartHandler BlockNetherWartHandler (E_BLOCK_NETHER_WART); - constexpr cBlockLeavesHandler BlockNewLeavesHandler (E_BLOCK_NEW_LEAVES); - constexpr cBlockSidewaysHandler BlockNewLogHandler (E_BLOCK_NEW_LOG); - constexpr cBlockNoteBlockHandler 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 cDefaultBlockHandler BlockObsidianHandler (E_BLOCK_OBSIDIAN); - constexpr cBlockGlazedTerracottaHandler BlockOrangeGlazedTerracottaHandler(E_BLOCK_ORANGE_GLAZED_TERRACOTTA); - constexpr cDefaultBlockHandler BlockOrangeShulkerBoxHandler (E_BLOCK_ORANGE_SHULKER_BOX); - constexpr cBlockPackedIceHandler BlockPackedIceHandler (E_BLOCK_PACKED_ICE); - constexpr cBlockGlazedTerracottaHandler BlockPinkGlazedTerracottaHandler (E_BLOCK_PINK_GLAZED_TERRACOTTA); - constexpr cDefaultBlockHandler BlockPinkShulkerBoxHandler (E_BLOCK_PINK_SHULKER_BOX); - constexpr cBlockPistonHandler BlockPistonHandler (E_BLOCK_PISTON); - constexpr cBlockPistonHeadHandler BlockPistonHeadHandler; - constexpr cDefaultBlockHandler 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 cDefaultBlockHandler 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 cDefaultBlockHandler BlockPurpleShulkerBoxHandler (E_BLOCK_PURPLE_SHULKER_BOX); - constexpr cDefaultBlockHandler BlockPurpurBlockHandler (E_BLOCK_PURPUR_BLOCK); - constexpr cBlockDoubleSlabHandler BlockPurpurDoubleSlabHandler (E_BLOCK_PURPUR_DOUBLE_SLAB); - constexpr cDefaultBlockHandler 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 cDefaultBlockHandler BlockRedNetherBricksHandler (E_BLOCK_RED_NETHER_BRICK); - constexpr cBlockFlowerHandler BlockRedRoseHandler (E_BLOCK_RED_ROSE); - constexpr cDefaultBlockHandler BlockRedSandstoneHandler (E_BLOCK_RED_SANDSTONE); - constexpr cBlockSlabHandler BlockRedSandstoneSlabHandler (E_BLOCK_RED_SANDSTONE_SLAB); - constexpr cBlockStairsHandler BlockRedSandstoneStairsHandler (E_BLOCK_RED_SANDSTONE_STAIRS); - constexpr cDefaultBlockHandler BlockRedShulkerBoxHandler (E_BLOCK_RED_SHULKER_BOX); - constexpr cDefaultBlockHandler BlockRedstoneBlockHandler (E_BLOCK_BLOCK_OF_REDSTONE); - 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 cBlockRedstoneWireHandler BlockRedstoneWireHandler (E_BLOCK_REDSTONE_WIRE); - constexpr cBlockCommandBlockHandler BlockRepeatingCommandBlockHandler (E_BLOCK_REPEATING_COMMAND_BLOCK); - constexpr cBlockSandHandler BlockSandHandler (E_BLOCK_SAND); - constexpr cDefaultBlockHandler 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 cDefaultBlockHandler BlockSnowBlockHandler (E_BLOCK_SNOW_BLOCK); - constexpr cBlockSnowHandler BlockSnowHandler (E_BLOCK_SNOW); - constexpr cDefaultBlockHandler 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 cDefaultBlockHandler BlockStainedClayHandler (E_BLOCK_STAINED_CLAY); - constexpr cBlockGlassHandler BlockStainedGlassHandler (E_BLOCK_STAINED_GLASS); - constexpr cBlockGlassHandler BlockStainedGlassPaneHandler (E_BLOCK_STAINED_GLASS_PANE); - constexpr cBlockStandingBannerHandler BlockStandingBannerHandler (E_BLOCK_STANDING_BANNER); - constexpr cBlockLavaHandler BlockStationaryLavaHandler (E_BLOCK_STATIONARY_LAVA); - constexpr cBlockWaterHandler BlockStationaryWaterHandler (E_BLOCK_STATIONARY_WATER); - constexpr cBlockPistonHandler BlockStickyPistonHandler (E_BLOCK_STICKY_PISTON); - constexpr cDefaultBlockHandler BlockStoneBricksHandler (E_BLOCK_STONE_BRICKS); - constexpr cBlockStairsHandler BlockStoneBrickStairsHandler (E_BLOCK_STONE_BRICK_STAIRS); - 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 cDefaultBlockHandler BlockStructureBlockHandler (E_BLOCK_STRUCTURE_BLOCK); - constexpr cDefaultBlockHandler 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 cBlockVinesHandler BlockVinesHandler (E_BLOCK_VINES); - constexpr cBlockWallBannerHandler BlockWallBannerHandler (E_BLOCK_WALL_BANNER); - constexpr cBlockWallSignHandler BlockWallsignHandler (E_BLOCK_WALLSIGN); - constexpr cBlockWaterHandler BlockWaterHandler (E_BLOCK_WATER); - constexpr cBlockGlazedTerracottaHandler BlockWhiteGlazedTerracottaHandler (E_BLOCK_WHITE_GLAZED_TERRACOTTA); - constexpr cDefaultBlockHandler 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 cDefaultBlockHandler 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 cBlockAirHandler BlockAirHandler(E_BLOCK_AIR); +constexpr cBlockAnvilHandler BlockAnvilHandler(E_BLOCK_ANVIL); +constexpr cDefaultBlockHandler BlockBarrierHandler(E_BLOCK_BARRIER); +constexpr cDefaultBlockEntityHandler BlockBeaconHandler(E_BLOCK_BEACON); +constexpr cBlockBedHandler BlockBedHandler(E_BLOCK_BED); +constexpr cDefaultBlockHandler 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 cDefaultBlockHandler BlockBlackShulkerBoxHandler(E_BLOCK_BLACK_SHULKER_BOX); +constexpr cBlockGlazedTerracottaHandler BlockBlueGlazedTerracottaHandler(E_BLOCK_BLUE_GLAZED_TERRACOTTA); +constexpr cDefaultBlockHandler BlockBlueShulkerBoxHandler(E_BLOCK_BLUE_SHULKER_BOX); +constexpr cDefaultBlockHandler BlockBoneBlockHandler(E_BLOCK_BONE_BLOCK); +constexpr cBlockBookShelfHandler BlockBookcaseHandler(E_BLOCK_BOOKCASE); +constexpr cBlockBrewingStandHandler BlockBrewingStandHandler(E_BLOCK_BREWING_STAND); +constexpr cDefaultBlockHandler BlockBricksHandler(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 cDefaultBlockHandler 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 cDefaultBlockHandler BlockChorusFlowerHandler(E_BLOCK_CHORUS_FLOWER); +constexpr cDefaultBlockHandler BlockChorusPlantHandler(E_BLOCK_CHORUS_PLANT); +constexpr cDefaultOreHandler BlockClayHandler(E_BLOCK_CLAY); +constexpr cDefaultBlockHandler BlockCoalBlockHandler(E_BLOCK_BLOCK_OF_COAL); +constexpr cDefaultOreHandler BlockCoalOreHandler(E_BLOCK_COAL_ORE); +constexpr cDefaultBlockHandler BlockCobblestoneHandler(E_BLOCK_COBBLESTONE); +constexpr cBlockStairsHandler BlockCobblestoneStairsHandler(E_BLOCK_COBBLESTONE_STAIRS); +constexpr cDefaultBlockHandler 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 cDefaultBlockHandler 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 cDefaultBlockHandler 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 cBlockDaylightSensorHandler BlockDaylightSensorHandler(E_BLOCK_DAYLIGHT_SENSOR); +constexpr cBlockDeadBushHandler BlockDeadBushHandler(E_BLOCK_DEAD_BUSH); +constexpr cBlockRailHandler BlockDetectorRailHandler(E_BLOCK_DETECTOR_RAIL); +constexpr cDefaultBlockHandler BlockDiamondBlockHandler(E_BLOCK_DIAMOND_BLOCK); +constexpr cDefaultOreHandler 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 cDefaultBlockHandler BlockDragonEggHandler(E_BLOCK_DRAGON_EGG); +constexpr cBlockDropSpenserHandler BlockDropperHandler(E_BLOCK_DROPPER); +constexpr cDefaultBlockHandler BlockEmeraldBlockHandler(E_BLOCK_EMERALD_BLOCK); +constexpr cDefaultOreHandler BlockEmeraldOreHandler(E_BLOCK_EMERALD_ORE); +constexpr cBlockEnchantingTableHandler BlockEnchantingTableHandler(E_BLOCK_ENCHANTMENT_TABLE); +constexpr cDefaultBlockHandler BlockEndBricksHandler(E_BLOCK_END_BRICKS); +constexpr cBlockEnderChestHandler BlockEnderChestHandler(E_BLOCK_ENDER_CHEST); +constexpr cDefaultBlockHandler BlockEndGatewayHandler(E_BLOCK_END_GATEWAY); +constexpr cBlockEndPortalFrameHandler BlockEndPortalFrameHandler(E_BLOCK_END_PORTAL_FRAME); +constexpr cDefaultBlockHandler BlockEndPortalHandler(E_BLOCK_END_PORTAL); +constexpr cDefaultBlockHandler BlockEndRodHandler(E_BLOCK_END_ROD); +constexpr cDefaultBlockHandler BlockEndStoneHandler(E_BLOCK_END_STONE); +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 cDefaultBlockHandler BlockGoldBlockHandler(E_BLOCK_GOLD_BLOCK); +constexpr cDefaultOreHandler BlockGoldOreHandler(E_BLOCK_GOLD_ORE); +constexpr cBlockGrassHandler BlockGrassHandler(E_BLOCK_GRASS); +constexpr cDefaultBlockHandler BlockGrassPathHandler(E_BLOCK_GRASS_PATH); +constexpr cBlockGravelHandler BlockGravelHandler(E_BLOCK_GRAVEL); +constexpr cBlockGlazedTerracottaHandler BlockGrayGlazedTerracottaHandler(E_BLOCK_GRAY_GLAZED_TERRACOTTA); +constexpr cDefaultBlockHandler BlockGrayShulkerBoxHandler(E_BLOCK_GRAY_SHULKER_BOX); +constexpr cBlockGlazedTerracottaHandler BlockGreenGlazedTerracottaHandler(E_BLOCK_GREEN_GLAZED_TERRACOTTA); +constexpr cDefaultBlockHandler BlockGreenShulkerBoxHandler(E_BLOCK_GREEN_SHULKER_BOX); +constexpr cDefaultBlockHandler 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 cBlockHugeMushroomHandler BlockHugeBrownMushroomHandler(E_BLOCK_HUGE_BROWN_MUSHROOM); +constexpr cBlockHugeMushroomHandler BlockHugeRedMushroomHandler(E_BLOCK_HUGE_RED_MUSHROOM); +constexpr cBlockIceHandler BlockIceHandler(E_BLOCK_ICE); +constexpr cBlockComparatorHandler BlockInactiveComparatorHandler(E_BLOCK_INACTIVE_COMPARATOR); +constexpr cBlockInfestedHandler BlockInfestedBlockHandler(E_BLOCK_SILVERFISH_EGG); +constexpr cDefaultBlockHandler BlockIronBarsHandler(E_BLOCK_IRON_BARS); +constexpr cDefaultBlockHandler BlockIronBlockHandler(E_BLOCK_IRON_BLOCK); +constexpr cBlockDoorHandler BlockIronDoorHandler(E_BLOCK_IRON_DOOR); +constexpr cDefaultOreHandler 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 cDefaultBlockHandler BlockLapisBlockHandler(E_BLOCK_LAPIS_BLOCK); +constexpr cDefaultOreHandler 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 cDefaultBlockHandler BlockLightBlueShulkerBoxHandler(E_BLOCK_LIGHT_BLUE_SHULKER_BOX); +constexpr cBlockGlazedTerracottaHandler BlockLightGrayGlazedTerracoHandler(E_BLOCK_LIGHT_GRAY_GLAZED_TERRACOTTA); +constexpr cDefaultBlockHandler 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 cDefaultBlockHandler 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 cDefaultBlockHandler BlockMagentaShulkerBoxHandler(E_BLOCK_MAGENTA_SHULKER_BOX); +constexpr cDefaultBlockHandler 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 cDefaultBlockHandler BlockMossyCobblestoneHandler(E_BLOCK_MOSSY_COBBLESTONE); +constexpr cBlockMyceliumHandler BlockMyceliumHandler(E_BLOCK_MYCELIUM); +constexpr cBlockFenceHandler BlockNetherBrickFenceHandler(E_BLOCK_NETHER_BRICK_FENCE); +constexpr cDefaultBlockHandler BlockNetherBricksHandler(E_BLOCK_NETHER_BRICK); +constexpr cBlockStairsHandler BlockNetherBrickStairsHandler(E_BLOCK_NETHER_BRICK_STAIRS); +constexpr cBlockPortalHandler BlockNetherPortalHandler(E_BLOCK_NETHER_PORTAL); +constexpr cDefaultOreHandler BlockNetherQuartzOreHandler(E_BLOCK_NETHER_QUARTZ_ORE); +constexpr cBlockNetherrack BlockNetherrackHandler(E_BLOCK_NETHERRACK); +constexpr cDefaultBlockHandler BlockNetherWartBlockHandler(E_BLOCK_NETHER_WART_BLOCK); +constexpr cBlockNetherWartHandler BlockNetherWartHandler(E_BLOCK_NETHER_WART); +constexpr cBlockLeavesHandler BlockNewLeavesHandler(E_BLOCK_NEW_LEAVES); +constexpr cBlockSidewaysHandler BlockNewLogHandler(E_BLOCK_NEW_LOG); +constexpr cBlockNoteBlockHandler 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 cDefaultBlockHandler BlockObsidianHandler(E_BLOCK_OBSIDIAN); +constexpr cBlockGlazedTerracottaHandler BlockOrangeGlazedTerracottaHandler(E_BLOCK_ORANGE_GLAZED_TERRACOTTA); +constexpr cDefaultBlockHandler BlockOrangeShulkerBoxHandler(E_BLOCK_ORANGE_SHULKER_BOX); +constexpr cBlockPackedIceHandler BlockPackedIceHandler(E_BLOCK_PACKED_ICE); +constexpr cBlockGlazedTerracottaHandler BlockPinkGlazedTerracottaHandler(E_BLOCK_PINK_GLAZED_TERRACOTTA); +constexpr cDefaultBlockHandler BlockPinkShulkerBoxHandler(E_BLOCK_PINK_SHULKER_BOX); +constexpr cBlockPistonHandler BlockPistonHandler(E_BLOCK_PISTON); +constexpr cBlockPistonHeadHandler BlockPistonHeadHandler; +constexpr cDefaultBlockHandler 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 cDefaultBlockHandler 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 cDefaultBlockHandler BlockPurpleShulkerBoxHandler(E_BLOCK_PURPLE_SHULKER_BOX); +constexpr cDefaultBlockHandler BlockPurpurBlockHandler(E_BLOCK_PURPUR_BLOCK); +constexpr cBlockDoubleSlabHandler BlockPurpurDoubleSlabHandler(E_BLOCK_PURPUR_DOUBLE_SLAB); +constexpr cDefaultBlockHandler 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 cDefaultBlockHandler BlockRedNetherBricksHandler(E_BLOCK_RED_NETHER_BRICK); +constexpr cBlockFlowerHandler BlockRedRoseHandler(E_BLOCK_RED_ROSE); +constexpr cDefaultBlockHandler BlockRedSandstoneHandler(E_BLOCK_RED_SANDSTONE); +constexpr cBlockSlabHandler BlockRedSandstoneSlabHandler(E_BLOCK_RED_SANDSTONE_SLAB); +constexpr cBlockStairsHandler BlockRedSandstoneStairsHandler(E_BLOCK_RED_SANDSTONE_STAIRS); +constexpr cDefaultBlockHandler BlockRedShulkerBoxHandler(E_BLOCK_RED_SHULKER_BOX); +constexpr cDefaultBlockHandler BlockRedstoneBlockHandler(E_BLOCK_BLOCK_OF_REDSTONE); +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 cBlockRedstoneWireHandler BlockRedstoneWireHandler(E_BLOCK_REDSTONE_WIRE); +constexpr cBlockCommandBlockHandler BlockRepeatingCommandBlockHandler(E_BLOCK_REPEATING_COMMAND_BLOCK); +constexpr cBlockSandHandler BlockSandHandler(E_BLOCK_SAND); +constexpr cDefaultBlockHandler 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 cDefaultBlockHandler BlockSnowBlockHandler(E_BLOCK_SNOW_BLOCK); +constexpr cBlockSnowHandler BlockSnowHandler(E_BLOCK_SNOW); +constexpr cDefaultBlockHandler 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 cDefaultBlockHandler BlockStainedClayHandler(E_BLOCK_STAINED_CLAY); +constexpr cBlockGlassHandler BlockStainedGlassHandler(E_BLOCK_STAINED_GLASS); +constexpr cBlockGlassHandler BlockStainedGlassPaneHandler(E_BLOCK_STAINED_GLASS_PANE); +constexpr cBlockStandingBannerHandler BlockStandingBannerHandler(E_BLOCK_STANDING_BANNER); +constexpr cBlockLavaHandler BlockStationaryLavaHandler(E_BLOCK_STATIONARY_LAVA); +constexpr cBlockWaterHandler BlockStationaryWaterHandler(E_BLOCK_STATIONARY_WATER); +constexpr cBlockPistonHandler BlockStickyPistonHandler(E_BLOCK_STICKY_PISTON); +constexpr cDefaultBlockHandler BlockStoneBricksHandler(E_BLOCK_STONE_BRICKS); +constexpr cBlockStairsHandler BlockStoneBrickStairsHandler(E_BLOCK_STONE_BRICK_STAIRS); +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 cDefaultBlockHandler BlockStructureBlockHandler(E_BLOCK_STRUCTURE_BLOCK); +constexpr cDefaultBlockHandler 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 cBlockVinesHandler BlockVinesHandler(E_BLOCK_VINES); +constexpr cBlockWallBannerHandler BlockWallBannerHandler(E_BLOCK_WALL_BANNER); +constexpr cBlockWallSignHandler BlockWallsignHandler(E_BLOCK_WALLSIGN); +constexpr cBlockWaterHandler BlockWaterHandler(E_BLOCK_WATER); +constexpr cBlockGlazedTerracottaHandler BlockWhiteGlazedTerracottaHandler(E_BLOCK_WHITE_GLAZED_TERRACOTTA); +constexpr cDefaultBlockHandler 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 cDefaultBlockHandler BlockYellowShulkerBoxHandler(E_BLOCK_YELLOW_SHULKER_BOX); +} // namespace @@ -471,9 +480,23 @@ void cBlockHandler::OnUpdate( -void cBlockHandler::OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const +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_Chunk, cChunkDef::AbsoluteToRelative(a_BlockPos), a_Chunk.GetMeta(cChunkDef::AbsoluteToRelative(a_BlockPos))); })) + if (a_ChunkInterface.DoWithChunkAt( + a_BlockPos, + [&](cChunk & a_Chunk) + { + return CanBeAt( + a_Chunk, + cChunkDef::AbsoluteToRelative(a_BlockPos), + a_Chunk.GetMeta(cChunkDef::AbsoluteToRelative(a_BlockPos)) + ); + } + )) { return; } @@ -485,14 +508,19 @@ void cBlockHandler::OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector -void cBlockHandler::NeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_NeighborPos, eBlockFace a_WhichNeighbor) +void cBlockHandler::NeighborChanged( + cChunkInterface & a_ChunkInterface, + Vector3i a_NeighborPos, + eBlockFace a_WhichNeighbor +) { if (!cChunkDef::IsValidHeight(a_NeighborPos)) { return; } - cBlockHandler::For(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); } @@ -529,7 +557,14 @@ bool cBlockHandler::IsUseable() const -bool cBlockHandler::DoesIgnoreBuildCollision(const cWorld & a_World, const cItem & a_HeldItem, const Vector3i a_Position, const NIBBLETYPE a_Meta, const eBlockFace a_ClickedBlockFace, const bool a_ClickedDirectly) const +bool cBlockHandler::DoesIgnoreBuildCollision( + const cWorld & a_World, + const cItem & a_HeldItem, + const Vector3i a_Position, + const NIBBLETYPE a_Meta, + const eBlockFace a_ClickedBlockFace, + const bool a_ClickedDirectly +) const { return m_BlockType == E_BLOCK_AIR; } @@ -548,7 +583,14 @@ 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) const +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)) { @@ -563,7 +605,8 @@ cBoundingBox cBlockHandler::GetPlacementCollisionBox(BLOCKTYPE a_XM, BLOCKTYPE a void cBlockHandler::Check( - cChunkInterface & a_ChunkInterface, cBlockPluginInterface & a_PluginInterface, + cChunkInterface & a_ChunkInterface, + cBlockPluginInterface & a_PluginInterface, Vector3i a_RelPos, cChunk & a_Chunk ) const @@ -604,7 +647,8 @@ unsigned char cBlockHandler::ToolFortuneLevel(const cItem * a_Tool) { if ((a_Tool != nullptr) && ItemCategory::IsTool(a_Tool->m_ItemType)) { - // Return enchantment level, limited to avoid spawning excessive pickups (crashing the server) when modified items are used: + // Return enchantment level, limited to avoid spawning excessive pickups (crashing the server) when modified + // items are used: return static_cast<unsigned char>(std::min(8U, a_Tool->m_Enchantments.GetLevel(cEnchantments::enchFortune))); } @@ -893,7 +937,7 @@ const cBlockHandler & cBlockHandler::For(BLOCKTYPE a_BlockType) // TODO: these will be removed in 1.13+ migration case E_BLOCK_NUMBER_OF_TYPES: - case E_BLOCK_UNFINISHED: return BlockAirHandler; + case E_BLOCK_UNFINISHED: return BlockAirHandler; } UNREACHABLE("Getting handler for unexpected block type"); } diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index 1e5dd6fcf..1f3203579 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -24,8 +24,7 @@ class cItems; class cBlockHandler { -public: - + public: constexpr cBlockHandler(BLOCKTYPE a_BlockType) : m_BlockType(a_BlockType) { @@ -44,31 +43,47 @@ public: /** 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) const; + virtual cBoundingBox GetPlacementCollisionBox( + BLOCKTYPE a_XM, + BLOCKTYPE a_XP, + BLOCKTYPE a_YM, + BLOCKTYPE a_YP, + BLOCKTYPE a_ZM, + BLOCKTYPE a_ZP + ) const; /** Called by cWorld::SetBlock() after the block has been set */ virtual void OnPlaced( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, - BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta - ) const {} + BLOCKTYPE a_BlockType, + NIBBLETYPE a_BlockMeta + ) const + { + } /** Called after a block gets broken (replaced with air), by natural means. - The block is already dug up in the world, the original block type and meta is passed in a_OldBlockType and a_OldBlockMeta. - By default notifies all direct neighbors via their OnNeighborChanged() callbacks. - You can determine what kind of entity broke the block (e.g. player) by checking a_Digger! */ + The block is already dug up in the world, the original block type and meta is passed in a_OldBlockType and + a_OldBlockMeta. By default notifies all direct neighbors via their OnNeighborChanged() callbacks. You can determine + what kind of entity broke the block (e.g. player) by checking a_Digger! */ virtual void OnBroken( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, - BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta, + BLOCKTYPE a_OldBlockType, + NIBBLETYPE a_OldBlockMeta, const cEntity * a_Digger - ) const {} + ) 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) const; + 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) + const; /** Notifies the specified neighbor that the current block has changed. a_NeighborPos are the coords of the neighbor to be notified @@ -103,7 +118,8 @@ public: } /** Called when a right click to this block is cancelled. - Descendants should force the server to send the real state of a block to the client to prevent client assuming the operation was successfull. */ + Descendants should force the server to send the real state of a block to the client to prevent client assuming the + operation was successfull. */ virtual void OnCancelRightClick( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, @@ -136,22 +152,31 @@ public: @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(const cWorld & a_World, const cItem & a_HeldItem, Vector3i a_Position, NIBBLETYPE a_Meta, eBlockFace a_ClickedBlockFace, bool a_ClickedDirectly) const; + virtual bool DoesIgnoreBuildCollision( + const cWorld & a_World, + const cItem & a_HeldItem, + Vector3i a_Position, + NIBBLETYPE a_Meta, + eBlockFace a_ClickedBlockFace, + bool a_ClickedDirectly + ) 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) 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()), - otherwise wakes up all simulators on the block. */ + By default drops (DropBlockAsPickup() / SetBlock()) if the position is no longer suitable (CanBeAt(), + DoesDropOnUnsuitable()), otherwise wakes up all simulators on the block. */ void Check( - cChunkInterface & ChunkInterface, cBlockPluginInterface & a_PluginInterface, + 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.wiki/w/Map_item_format */ + /** Returns the base colour ID of the block, as will be represented on a map, as per documentation: + * https://minecraft.wiki/w/Map_item_format */ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const; /** Rotates a given block meta counter-clockwise. Default: no change @@ -198,8 +223,7 @@ public: // Gets the blockhandler for the given block type. static const cBlockHandler & For(BLOCKTYPE a_BlockType); -protected: - + protected: ~cBlockHandler() = default; const BLOCKTYPE m_BlockType; diff --git a/src/Blocks/BlockHopper.h b/src/Blocks/BlockHopper.h index 930f1e0bc..b008003e4 100644 --- a/src/Blocks/BlockHopper.h +++ b/src/Blocks/BlockHopper.h @@ -7,20 +7,29 @@ -class cBlockHopperHandler final : - public cClearMetaOnDrop<cMetaRotator<cBlockEntityHandler, 0x7, E_META_HOPPER_FACING_ZP, E_META_HOPPER_FACING_XM, E_META_HOPPER_FACING_ZM, E_META_HOPPER_FACING_XP>> +class cBlockHopperHandler final : public cClearMetaOnDrop<cMetaRotator< + cBlockEntityHandler, + 0x7, + E_META_HOPPER_FACING_ZP, + E_META_HOPPER_FACING_XM, + E_META_HOPPER_FACING_ZM, + E_META_HOPPER_FACING_XP>> { - using Super = cClearMetaOnDrop<cMetaRotator<cBlockEntityHandler, 0x7, E_META_HOPPER_FACING_ZP, E_META_HOPPER_FACING_XM, E_META_HOPPER_FACING_ZM, E_META_HOPPER_FACING_XP>>; - -public: - + using Super = cClearMetaOnDrop<cMetaRotator< + cBlockEntityHandler, + 0x7, + E_META_HOPPER_FACING_ZP, + E_META_HOPPER_FACING_XM, + E_META_HOPPER_FACING_ZM, + E_META_HOPPER_FACING_XP>>; + + public: using Super::Super; -private: - + private: virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override { UNUSED(a_Meta); return 11; } -} ; +}; diff --git a/src/Blocks/BlockHugeMushroom.h b/src/Blocks/BlockHugeMushroom.h index 122a6ba4c..bd54ef99a 100644 --- a/src/Blocks/BlockHugeMushroom.h +++ b/src/Blocks/BlockHugeMushroom.h @@ -8,17 +8,14 @@ /** Handler for huge mushroom blocks. */ -class cBlockHugeMushroomHandler final : - public cBlockHandler +class cBlockHugeMushroomHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { if (ToolHasSilkTouch(a_Tool)) @@ -31,7 +28,8 @@ private: return cItem(); } - const auto MushroomType = (m_BlockType == E_BLOCK_HUGE_BROWN_MUSHROOM) ? E_BLOCK_BROWN_MUSHROOM : E_BLOCK_RED_MUSHROOM; + const auto MushroomType = + (m_BlockType == E_BLOCK_HUGE_BROWN_MUSHROOM) ? E_BLOCK_BROWN_MUSHROOM : E_BLOCK_RED_MUSHROOM; const auto DropNum = GetRandomProvider().RandInt<char>(2); return cItem(MushroomType, DropNum); @@ -46,8 +44,4 @@ private: UNUSED(a_Meta); return (m_BlockType == E_BLOCK_HUGE_BROWN_MUSHROOM) ? 10 : 28; } -} ; - - - - +}; diff --git a/src/Blocks/BlockIce.h b/src/Blocks/BlockIce.h index 35228f4ea..1ce01873d 100644 --- a/src/Blocks/BlockIce.h +++ b/src/Blocks/BlockIce.h @@ -7,17 +7,14 @@ -class cBlockIceHandler final : - public cBlockHandler +class cBlockIceHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { // Only drop self when using silk-touch: @@ -45,13 +42,8 @@ private: } // Artificial light on any of the surrounding block > 11 leads to melting the ice. - static const std::array<Vector3i, 7> Adjacents - { - { - { 1, 0, 0 }, { -1, 0, 0 }, - { 0, 1, 0 }, { 0, -1, 0 }, - { 0, 0, 1 }, { 0, 0, -1 } - } + static const std::array<Vector3i, 7> Adjacents { + {{1, 0, 0}, {-1, 0, 0}, {0, 1, 0}, {0, -1, 0}, {0, 0, 1}, {0, 0, -1}} }; for (const auto & Offset : Adjacents) @@ -79,9 +71,11 @@ private: } virtual void OnBroken( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, - BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta, + BLOCKTYPE a_OldBlockType, + NIBBLETYPE a_OldBlockMeta, const cEntity * a_Digger ) const override { @@ -108,4 +102,4 @@ private: UNUSED(a_Meta); return 5; } -} ; +}; diff --git a/src/Blocks/BlockInfested.h b/src/Blocks/BlockInfested.h index 03977daad..ad177c276 100644 --- a/src/Blocks/BlockInfested.h +++ b/src/Blocks/BlockInfested.h @@ -1,7 +1,8 @@ // BlockInfested.h -// Declares the cBlockInfestedHandler class representing the handler for Silverfish blocks (Mojang calls them Monster Eggs) +// Declares the cBlockInfestedHandler class representing the handler for Silverfish blocks (Mojang calls them Monster +// Eggs) #include "../Entities/Player.h" @@ -9,17 +10,14 @@ -class cBlockInfestedHandler final: - public cBlockHandler +class cBlockInfestedHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: static void SpawnSilverfish(cWorldInterface & a_WorldInterface, Vector3i a_BlockPos) { // TODO: only display animation if the difficulty allows mob spawns - Add when difficulty is implemented @@ -38,18 +36,21 @@ private: { if (ToolHasSilkTouch(a_Tool)) { - return { E_BLOCK_STONE }; + return {E_BLOCK_STONE}; } else { - return { E_BLOCK_COBBLESTONE }; + return {E_BLOCK_COBBLESTONE}; } } - case E_META_SILVERFISH_EGG_COBBLESTONE: return { E_BLOCK_COBBLESTONE }; - case E_META_SILVERFISH_EGG_STONE_BRICK: return { E_BLOCK_STONE_BRICKS }; - case E_META_SILVERFISH_EGG_MOSSY_STONE_BRICK: return cItem(E_BLOCK_STONE_BRICKS, 1, E_META_STONE_BRICK_MOSSY); - case E_META_SILVERFISH_EGG_CRACKED_STONE_BRICK: return cItem(E_BLOCK_STONE_BRICKS, 1, E_META_STONE_BRICK_CRACKED); - case E_META_SILVERFISH_EGG_CHISELED_STONE_BRICK: return cItem(E_BLOCK_STONE_BRICKS, 1, E_META_STONE_BRICK_ORNAMENT); + case E_META_SILVERFISH_EGG_COBBLESTONE: return {E_BLOCK_COBBLESTONE}; + case E_META_SILVERFISH_EGG_STONE_BRICK: return {E_BLOCK_STONE_BRICKS}; + case E_META_SILVERFISH_EGG_MOSSY_STONE_BRICK: + return cItem(E_BLOCK_STONE_BRICKS, 1, E_META_STONE_BRICK_MOSSY); + case E_META_SILVERFISH_EGG_CRACKED_STONE_BRICK: + return cItem(E_BLOCK_STONE_BRICKS, 1, E_META_STONE_BRICK_CRACKED); + case E_META_SILVERFISH_EGG_CHISELED_STONE_BRICK: + return cItem(E_BLOCK_STONE_BRICKS, 1, E_META_STONE_BRICK_ORNAMENT); } return {}; @@ -57,9 +58,11 @@ private: virtual void OnBroken( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, - BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta, + BLOCKTYPE a_OldBlockType, + NIBBLETYPE a_OldBlockMeta, const cEntity * a_Digger ) const override { @@ -82,8 +85,5 @@ private: } - virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override - { - return 11; - } -} ; + virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override { return 11; } +}; diff --git a/src/Blocks/BlockJukebox.h b/src/Blocks/BlockJukebox.h index 970f10fc1..6fec18f2c 100644 --- a/src/Blocks/BlockJukebox.h +++ b/src/Blocks/BlockJukebox.h @@ -8,18 +8,15 @@ -class cBlockJukeboxHandler final : - public cClearMetaOnDrop<cBlockEntityHandler> +class cBlockJukeboxHandler final : public cClearMetaOnDrop<cBlockEntityHandler> { -public: - + public: using cClearMetaOnDrop<cBlockEntityHandler>::cClearMetaOnDrop; -private: - + private: virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override { UNUSED(a_Meta); return 10; } -} ; +}; diff --git a/src/Blocks/BlockLadder.h b/src/Blocks/BlockLadder.h index bab51b2d3..62363878c 100644 --- a/src/Blocks/BlockLadder.h +++ b/src/Blocks/BlockLadder.h @@ -9,24 +9,18 @@ -class cBlockLadderHandler final : - public cClearMetaOnDrop<cMetaRotator<cBlockHandler, 0x07, 0x02, 0x05, 0x03, 0x04> > +class cBlockLadderHandler final : public cClearMetaOnDrop<cMetaRotator<cBlockHandler, 0x07, 0x02, 0x05, 0x03, 0x04>> { using Super = cClearMetaOnDrop<cMetaRotator<cBlockHandler, 0x07, 0x02, 0x05, 0x03, 0x04>>; -public: - + public: using Super::Super; /** Returns true if the ladder will be supported by the block through the given blockface. */ static bool CanBePlacedOn(const BLOCKTYPE a_BlockType, const eBlockFace a_BlockFace) { - if ( - (a_BlockFace == BLOCK_FACE_NONE) || - (a_BlockFace == BLOCK_FACE_BOTTOM) || - (a_BlockFace == BLOCK_FACE_TOP) - ) + if ((a_BlockFace == BLOCK_FACE_NONE) || (a_BlockFace == BLOCK_FACE_BOTTOM) || (a_BlockFace == BLOCK_FACE_TOP)) { return false; } @@ -34,8 +28,7 @@ public: return cBlockInfo::FullyOccupiesVoxel(a_BlockType); } -private: - + private: /** Converts the ladder block's meta to the block face of the neighbor to which the ladder is attached. */ static eBlockFace MetaDataToBlockFace(NIBBLETYPE a_MetaData) { @@ -71,8 +64,4 @@ private: UNUSED(a_Meta); return 0; } -} ; - - - - +}; diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h index c5e46926b..39f15dae3 100644 --- a/src/Blocks/BlockLeaves.h +++ b/src/Blocks/BlockLeaves.h @@ -14,18 +14,19 @@ -class cBlockLeavesHandler final : - public cBlockHandler +class cBlockLeavesHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - - static double FortuneDropProbability(unsigned char a_DefaultDenominator, unsigned char a_FirstDenominatorReduction, unsigned char a_FortuneLevel) + private: + static double FortuneDropProbability( + unsigned char a_DefaultDenominator, + unsigned char a_FirstDenominatorReduction, + unsigned char a_FortuneLevel + ) { // Fortune 3 behaves like fortune 4 for some reason if (a_FortuneLevel == 3) @@ -34,7 +35,8 @@ private: } // Denominator, capped at minimum of 10. - const auto Denominator = std::max<unsigned char>(10, a_DefaultDenominator - a_FortuneLevel * a_FirstDenominatorReduction); + const auto Denominator = + std::max<unsigned char>(10, a_DefaultDenominator - a_FortuneLevel * a_FirstDenominatorReduction); return 1.0 / Denominator; } @@ -42,7 +44,8 @@ private: - /** Returns true if the area contains a continous path from the specified block to a log block entirely made out of leaves blocks. */ + /** 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) { // Filter the blocks into a {leaves, log, other (air)} set: @@ -67,7 +70,8 @@ private: } // for i - Types[] // Perform a breadth-first search to see if there's a log connected within 4 blocks of the leaves block: - // Simply replace all reachable leaves blocks with a sponge block plus iteration (in the Area) and see if we can reach a log + // Simply replace all reachable leaves blocks with a sponge block plus iteration (in the Area) and see if we can + // reach a log a_Area.SetBlockType(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, E_BLOCK_SPONGE); for (int i = 0; i < LEAVES_CHECK_DISTANCE; i++) { @@ -75,9 +79,13 @@ private: { switch (a_Area.GetBlockType(cbx, cby, cbz)) { - case E_BLOCK_LEAVES: a_Area.SetBlockType(cbx, cby, cbz, static_cast<BLOCKTYPE>(E_BLOCK_SPONGE + i + 1)); break; + case E_BLOCK_LEAVES: + a_Area.SetBlockType(cbx, cby, cbz, static_cast<BLOCKTYPE>(E_BLOCK_SPONGE + i + 1)); + break; case E_BLOCK_LOG: return true; - case E_BLOCK_NEW_LEAVES: a_Area.SetBlockType(cbx, cby, cbz, static_cast<BLOCKTYPE>(E_BLOCK_SPONGE + i + 1)); break; + case E_BLOCK_NEW_LEAVES: + a_Area.SetBlockType(cbx, cby, cbz, static_cast<BLOCKTYPE>(E_BLOCK_SPONGE + i + 1)); + break; case E_BLOCK_NEW_LOG: return true; } return false; @@ -92,14 +100,9 @@ private: { continue; } - if ( - ProcessNeighbor(x - 1, y, z) || - ProcessNeighbor(x + 1, y, z) || - ProcessNeighbor(x, y, z - 1) || - ProcessNeighbor(x, y, z + 1) || - ProcessNeighbor(x, y + 1, z) || - ProcessNeighbor(x, y - 1, z) - ) + if (ProcessNeighbor(x - 1, y, z) || ProcessNeighbor(x + 1, y, z) || + ProcessNeighbor(x, y, z - 1) || ProcessNeighbor(x, y, z + 1) || + ProcessNeighbor(x, y + 1, z) || ProcessNeighbor(x, y - 1, z)) { return true; } @@ -171,7 +174,8 @@ private: - virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const override + virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) + const override { auto meta = a_ChunkInterface.GetBlockMeta(a_BlockPos); @@ -211,11 +215,11 @@ private: auto worldPos = a_Chunk.RelativeToAbsolute(a_RelPos); cBlockArea Area; if (!Area.Read( - *a_Chunk.GetWorld(), - worldPos - Vector3i(LEAVES_CHECK_DISTANCE, LEAVES_CHECK_DISTANCE, LEAVES_CHECK_DISTANCE), - worldPos + Vector3i(LEAVES_CHECK_DISTANCE, LEAVES_CHECK_DISTANCE, LEAVES_CHECK_DISTANCE), - cBlockArea::baTypes) - ) + *a_Chunk.GetWorld(), + worldPos - Vector3i(LEAVES_CHECK_DISTANCE, LEAVES_CHECK_DISTANCE, LEAVES_CHECK_DISTANCE), + worldPos + Vector3i(LEAVES_CHECK_DISTANCE, LEAVES_CHECK_DISTANCE, LEAVES_CHECK_DISTANCE), + cBlockArea::baTypes + )) { // Cannot check leaves, a chunk is missing too close return; @@ -241,4 +245,4 @@ private: UNUSED(a_Meta); return 7; } -} ; +}; diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h index 60db4ddee..09e4cfe21 100644 --- a/src/Blocks/BlockLever.h +++ b/src/Blocks/BlockLever.h @@ -9,23 +9,17 @@ #include "BlockSlab.h" -class cBlockLeverHandler final : - public cMetaRotator<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, false> +class cBlockLeverHandler final : public cMetaRotator<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, false> { using Super = cMetaRotator<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, false>; -public: - + public: 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: + static bool IsLeverOn(NIBBLETYPE a_BlockMeta) { return ((a_BlockMeta & 0x8) == 0x8); } + private: virtual bool OnUse( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, @@ -40,7 +34,8 @@ private: a_ChunkInterface.SetBlockMeta(a_BlockPos, Meta); a_WorldInterface.WakeUpSimulators(a_BlockPos); - a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("block.lever.click", a_BlockPos, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f); + a_WorldInterface.GetBroadcastManager() + .BroadcastSoundEffect("block.lever.click", a_BlockPos, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f); return true; } @@ -58,10 +53,7 @@ private: - virtual bool IsUseable(void) const override - { - return true; - } + virtual bool IsUseable(void) const override { return true; } @@ -117,25 +109,19 @@ private: { return ( (((NeighborMeta & 0x08) == 0x08) && (NeighborFace == BLOCK_FACE_TOP)) || - (((NeighborMeta & 0x08) == 0) && (NeighborFace == BLOCK_FACE_BOTTOM)) + (((NeighborMeta & 0x08) == 0) && (NeighborFace == BLOCK_FACE_BOTTOM)) ); } else if (cBlockStairsHandler::IsAnyStairType(NeighborBlockType)) { switch (NeighborFace) { - case eBlockFace::BLOCK_FACE_YM: - return !(NeighborMeta & E_BLOCK_STAIRS_UPSIDE_DOWN); - case eBlockFace::BLOCK_FACE_YP: - return (NeighborMeta & E_BLOCK_STAIRS_UPSIDE_DOWN); - case eBlockFace::BLOCK_FACE_XP: - return ((NeighborMeta & 0b11) == E_BLOCK_STAIRS_XP); - case eBlockFace::BLOCK_FACE_XM: - return ((NeighborMeta & 0b11) == E_BLOCK_STAIRS_XM); - case eBlockFace::BLOCK_FACE_ZP: - return ((NeighborMeta & 0b11) == E_BLOCK_STAIRS_ZP); - case eBlockFace::BLOCK_FACE_ZM: - return ((NeighborMeta & 0b11) == E_BLOCK_STAIRS_ZM); + case eBlockFace::BLOCK_FACE_YM: return !(NeighborMeta & E_BLOCK_STAIRS_UPSIDE_DOWN); + case eBlockFace::BLOCK_FACE_YP: return (NeighborMeta & E_BLOCK_STAIRS_UPSIDE_DOWN); + case eBlockFace::BLOCK_FACE_XP: return ((NeighborMeta & 0b11) == E_BLOCK_STAIRS_XP); + case eBlockFace::BLOCK_FACE_XM: return ((NeighborMeta & 0b11) == E_BLOCK_STAIRS_XM); + case eBlockFace::BLOCK_FACE_ZP: return ((NeighborMeta & 0b11) == E_BLOCK_STAIRS_ZP); + case eBlockFace::BLOCK_FACE_ZM: return ((NeighborMeta & 0b11) == E_BLOCK_STAIRS_ZM); default: { return false; @@ -159,7 +145,7 @@ private: case 0x05: return 0x06; // Ground rotation case 0x06: return 0x05; - default: return Super::MetaRotateCCW(a_Meta); // Wall Rotation + default: return Super::MetaRotateCCW(a_Meta); // Wall Rotation } } @@ -177,7 +163,7 @@ private: case 0x05: return 0x06; // Ground rotation case 0x06: return 0x05; - default: return Super::MetaRotateCW(a_Meta); // Wall Rotation + default: return Super::MetaRotateCW(a_Meta); // Wall Rotation } } @@ -190,8 +176,4 @@ private: UNUSED(a_Meta); return 0; } -} ; - - - - +}; diff --git a/src/Blocks/BlockLilypad.h b/src/Blocks/BlockLilypad.h index e39d34566..741fdf79f 100644 --- a/src/Blocks/BlockLilypad.h +++ b/src/Blocks/BlockLilypad.h @@ -7,17 +7,14 @@ -class cBlockLilypadHandler final : - public cClearMetaOnDrop<cBlockHandler> +class cBlockLilypadHandler final : public cClearMetaOnDrop<cBlockHandler> { using Super = cClearMetaOnDrop<cBlockHandler>; -public: - + public: using Super::Super; -private: - + private: virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override { UNUSED(a_Meta); @@ -39,12 +36,10 @@ private: NIBBLETYPE UnderMeta; a_Chunk.GetBlockTypeMeta(UnderPos, UnderType, UnderMeta); return ( - (((UnderType == E_BLOCK_STATIONARY_WATER) || (UnderType == E_BLOCK_WATER)) && (UnderMeta == 0)) || // A water source is below - (UnderType == E_BLOCK_ICE) || (UnderType == E_BLOCK_FROSTED_ICE) // Or (frosted) ice + (((UnderType == E_BLOCK_STATIONARY_WATER) || (UnderType == E_BLOCK_WATER)) && (UnderMeta == 0) + ) || // A water source is below + (UnderType == E_BLOCK_ICE) || + (UnderType == E_BLOCK_FROSTED_ICE) // Or (frosted) ice ); } }; - - - - diff --git a/src/Blocks/BlockMelon.h b/src/Blocks/BlockMelon.h index 9fa68fc1e..a9a7cb58f 100644 --- a/src/Blocks/BlockMelon.h +++ b/src/Blocks/BlockMelon.h @@ -7,17 +7,14 @@ -class cBlockMelonHandler final : - public cBlockHandler +class cBlockMelonHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { const auto DropNum = FortuneDiscreteRandom(3, 7, ToolFortuneLevel(a_Tool), 9); @@ -33,8 +30,4 @@ private: UNUSED(a_Meta); return 19; } -} ; - - - - +}; diff --git a/src/Blocks/BlockMobHead.h b/src/Blocks/BlockMobHead.h index 7b632e0a2..b01d2c45b 100644 --- a/src/Blocks/BlockMobHead.h +++ b/src/Blocks/BlockMobHead.h @@ -7,17 +7,14 @@ -class cBlockMobHeadHandler final : - public cBlockEntityHandler +class cBlockMobHeadHandler final : public cBlockEntityHandler { using Super = cBlockEntityHandler; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { // Drops handled by the block entity: @@ -33,8 +30,4 @@ private: UNUSED(a_Meta); return 0; } -} ; - - - - +}; diff --git a/src/Blocks/BlockMobSpawner.h b/src/Blocks/BlockMobSpawner.h index b4981abe9..72b279700 100644 --- a/src/Blocks/BlockMobSpawner.h +++ b/src/Blocks/BlockMobSpawner.h @@ -8,17 +8,14 @@ -class cBlockMobSpawnerHandler final : - public cBlockHandler +class cBlockMobSpawnerHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual bool OnUse( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, @@ -35,10 +32,7 @@ private: - virtual bool IsUseable() const override - { - return true; - } + virtual bool IsUseable() const override { return true; } @@ -55,9 +49,11 @@ private: virtual void OnBroken( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, - BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta, + BLOCKTYPE a_OldBlockType, + NIBBLETYPE a_OldBlockMeta, const cEntity * a_Digger ) const override { @@ -81,4 +77,4 @@ private: int Reward = 15 + Random.RandInt(14) + Random.RandInt(14); a_WorldInterface.SpawnSplitExperienceOrbs(Vector3d(0.5, 0.5, 0.5) + a_BlockPos, Reward); } -} ; +}; diff --git a/src/Blocks/BlockMushroom.h b/src/Blocks/BlockMushroom.h index bed16c557..b51c46e51 100644 --- a/src/Blocks/BlockMushroom.h +++ b/src/Blocks/BlockMushroom.h @@ -8,17 +8,14 @@ /** Handler for the small (singleblock) mushrooms. */ -class cBlockMushroomHandler final : - public cClearMetaOnDrop<cBlockHandler> +class cBlockMushroomHandler final : public cClearMetaOnDrop<cBlockHandler> { using Super = cClearMetaOnDrop<cBlockHandler>; -public: - + public: using Super::Super; -private: - + private: // TODO: Add Mushroom Spread virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override @@ -54,8 +51,4 @@ private: UNUSED(a_Meta); return 0; } -} ; - - - - +}; diff --git a/src/Blocks/BlockMycelium.h b/src/Blocks/BlockMycelium.h index 62b1bbf7f..51146c10c 100644 --- a/src/Blocks/BlockMycelium.h +++ b/src/Blocks/BlockMycelium.h @@ -7,15 +7,12 @@ -class cBlockMyceliumHandler final : - public cBlockHandler +class cBlockMyceliumHandler final : public cBlockHandler { -public: - + public: using cBlockHandler::cBlockHandler; -private: - + private: // TODO: Add Mycel Spread virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override @@ -32,8 +29,4 @@ private: UNUSED(a_Meta); return 24; } -} ; - - - - +}; diff --git a/src/Blocks/BlockNetherWart.h b/src/Blocks/BlockNetherWart.h index 43081d511..3c96bec1e 100644 --- a/src/Blocks/BlockNetherWart.h +++ b/src/Blocks/BlockNetherWart.h @@ -8,17 +8,14 @@ -class cBlockNetherWartHandler final : - public cBlockPlant<false> +class cBlockNetherWartHandler final : public cBlockPlant<false> { using Super = cBlockPlant<false>; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { if (a_BlockMeta == 0x03) @@ -45,7 +42,8 @@ private: return meta - oldMeta; } - // In older versions of cuberite, there was a bug which made wart grow too much. This check fixes previously saved buggy warts. + // In older versions of cuberite, there was a bug which made wart grow too much. This check fixes previously + // saved buggy warts. if (oldMeta > 3) { a_Chunk.FastSetBlock(a_RelPos, m_BlockType, 3); @@ -72,4 +70,4 @@ private: UNUSED(a_Meta); return 35; } -} ; +}; diff --git a/src/Blocks/BlockNetherrack.h b/src/Blocks/BlockNetherrack.h index dfcfeacbd..f5a342539 100644 --- a/src/Blocks/BlockNetherrack.h +++ b/src/Blocks/BlockNetherrack.h @@ -9,14 +9,9 @@ class cBlockNetherrack final : public cBlockHandler { -public: - + public: using cBlockHandler::cBlockHandler; -private: - - virtual bool CanSustainPlant(BLOCKTYPE a_Plant) const override - { - return a_Plant == E_BLOCK_NETHER_WART; - } + private: + virtual bool CanSustainPlant(BLOCKTYPE a_Plant) const override { return a_Plant == E_BLOCK_NETHER_WART; } }; diff --git a/src/Blocks/BlockNoteBlock.h b/src/Blocks/BlockNoteBlock.h index f5ada0d2d..f2980e0c2 100644 --- a/src/Blocks/BlockNoteBlock.h +++ b/src/Blocks/BlockNoteBlock.h @@ -8,17 +8,14 @@ -class cBlockNoteBlockHandler final : - public cBlockEntityHandler +class cBlockNoteBlockHandler final : public cBlockEntityHandler { using Super = cBlockEntityHandler; -public: - + public: using Super::Super; -private: - + private: virtual void OnDigging( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, @@ -26,12 +23,15 @@ private: const Vector3i a_BlockPos ) const override { - a_WorldInterface.DoWithBlockEntityAt(a_BlockPos, [](cBlockEntity & a_BlockEntity) - { - ASSERT(a_BlockEntity.GetBlockType() == E_BLOCK_NOTE_BLOCK); - - static_cast<cNoteEntity &>(a_BlockEntity).MakeSound(); - return false; - }); + a_WorldInterface.DoWithBlockEntityAt( + a_BlockPos, + [](cBlockEntity & a_BlockEntity) + { + ASSERT(a_BlockEntity.GetBlockType() == E_BLOCK_NOTE_BLOCK); + + static_cast<cNoteEntity &>(a_BlockEntity).MakeSound(); + return false; + } + ); } }; diff --git a/src/Blocks/BlockObserver.h b/src/Blocks/BlockObserver.h index 13ffa4631..981fe777e 100644 --- a/src/Blocks/BlockObserver.h +++ b/src/Blocks/BlockObserver.h @@ -5,35 +5,30 @@ #include "Mixins.h" -class cBlockObserverHandler final : - public cClearMetaOnDrop<cDisplacementYawRotator<cBlockHandler>> +class cBlockObserverHandler final : public cClearMetaOnDrop<cDisplacementYawRotator<cBlockHandler>> { using Super = cClearMetaOnDrop<cDisplacementYawRotator<cBlockHandler>>; -public: - + public: using Super::Super; - inline static Vector3i GetObservingFaceOffset(NIBBLETYPE a_Meta) - { - return -GetSignalOutputOffset(a_Meta); - } + inline static Vector3i GetObservingFaceOffset(NIBBLETYPE a_Meta) { return -GetSignalOutputOffset(a_Meta); } inline static Vector3i GetSignalOutputOffset(NIBBLETYPE a_Meta) { switch (a_Meta & 0x7) { - case 0x00: return { 0, 1, 0 }; - case 0x01: return { 0, -1, 0 }; - case 0x02: return { 0, 0, 1 }; - case 0x03: return { 0, 0, -1 }; - case 0x04: return { 1, 0, 0 }; - case 0x05: return { -1, 0, 0 }; + case 0x00: return {0, 1, 0}; + case 0x01: return {0, -1, 0}; + case 0x02: return {0, 0, 1}; + case 0x03: return {0, 0, -1}; + case 0x04: return {1, 0, 0}; + case 0x05: return {-1, 0, 0}; default: { LOGWARNING("%s: Unknown metadata: %d", __FUNCTION__, a_Meta); ASSERT(!"Unknown metadata while determining orientation of observer!"); - return { 0, 0, 0 }; + return {0, 0, 0}; } } } diff --git a/src/Blocks/BlockOre.h b/src/Blocks/BlockOre.h index c2526e16c..45f88f3b0 100644 --- a/src/Blocks/BlockOre.h +++ b/src/Blocks/BlockOre.h @@ -8,21 +8,17 @@ -class cBlockOreHandler : - public cBlockHandler +class cBlockOreHandler : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -protected: - + protected: ~cBlockOreHandler() = default; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { // If using silk-touch, drop self rather than the resource: @@ -31,15 +27,15 @@ private: switch (m_BlockType) { // If it was a glowing redstone ore, drop a normal redstone ore: - case E_BLOCK_REDSTONE_ORE_GLOWING: return cItem(E_BLOCK_REDSTONE_ORE); - default: return cItem(m_BlockType); + case E_BLOCK_REDSTONE_ORE_GLOWING: return cItem(E_BLOCK_REDSTONE_ORE); + default: return cItem(m_BlockType); } } const auto FortuneLevel = ToolFortuneLevel(a_Tool); if ((m_BlockType == E_BLOCK_REDSTONE_ORE) || (m_BlockType == E_BLOCK_REDSTONE_ORE_GLOWING)) - { // Redstone follows the discrete random distribution, unlike other ores + { // Redstone follows the discrete random distribution, unlike other ores const auto DropNum = FortuneDiscreteRandom(4, 5, FortuneLevel); return cItem(E_ITEM_REDSTONE_DUST, DropNum); } @@ -48,12 +44,12 @@ private: const auto DropMult = std::max(static_cast<char>(1), FloorC<char>(Random.RandReal(FortuneLevel + 2.0))); switch (m_BlockType) { - case E_BLOCK_LAPIS_ORE: return cItem(E_ITEM_DYE, DropMult * Random.RandInt<char>(4, 9), 4); - case E_BLOCK_DIAMOND_ORE: return cItem(E_ITEM_DIAMOND, DropMult); - case E_BLOCK_EMERALD_ORE: return cItem(E_ITEM_EMERALD, DropMult); - case E_BLOCK_COAL_ORE: return cItem(E_ITEM_COAL, DropMult); - case E_BLOCK_NETHER_QUARTZ_ORE: return cItem(E_ITEM_NETHER_QUARTZ, DropMult); - case E_BLOCK_CLAY: return cItem(E_ITEM_CLAY, 4); + case E_BLOCK_LAPIS_ORE: return cItem(E_ITEM_DYE, DropMult * Random.RandInt<char>(4, 9), 4); + case E_BLOCK_DIAMOND_ORE: return cItem(E_ITEM_DIAMOND, DropMult); + case E_BLOCK_EMERALD_ORE: return cItem(E_ITEM_EMERALD, DropMult); + case E_BLOCK_COAL_ORE: return cItem(E_ITEM_COAL, DropMult); + case E_BLOCK_NETHER_QUARTZ_ORE: return cItem(E_ITEM_NETHER_QUARTZ, DropMult); + case E_BLOCK_CLAY: return cItem(E_ITEM_CLAY, 4); default: { return cItem(m_BlockType); @@ -66,9 +62,11 @@ private: virtual void OnBroken( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, - BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta, + BLOCKTYPE a_OldBlockType, + NIBBLETYPE a_OldBlockMeta, const cEntity * a_Digger ) const override { @@ -140,16 +138,14 @@ private: a_WorldInterface.SpawnSplitExperienceOrbs(Vector3d(0.5, 0.5, 0.5) + a_BlockPos, Reward); } } -} ; +}; -class cDefaultOreHandler final : - public cBlockOreHandler +class cDefaultOreHandler final : public cBlockOreHandler { -public: - + public: using cBlockOreHandler::cBlockOreHandler; }; diff --git a/src/Blocks/BlockPackedIce.h b/src/Blocks/BlockPackedIce.h index 7c6b68b05..5619cf978 100644 --- a/src/Blocks/BlockPackedIce.h +++ b/src/Blocks/BlockPackedIce.h @@ -7,17 +7,14 @@ -class cBlockPackedIceHandler final : - public cBlockHandler +class cBlockPackedIceHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { // Only drop self when using silk-touch: @@ -34,4 +31,4 @@ private: UNUSED(a_Meta); return 5; } -} ; +}; diff --git a/src/Blocks/BlockPiston.cpp b/src/Blocks/BlockPiston.cpp index 124757b44..bf2bf5408 100644 --- a/src/Blocks/BlockPiston.cpp +++ b/src/Blocks/BlockPiston.cpp @@ -22,12 +22,12 @@ Vector3i cBlockPistonHandler::MetadataToOffset(NIBBLETYPE a_PistonMeta) { switch (a_PistonMeta & 0x07) { - case 0: return Vector3i( 0, -1, 0); - case 1: return Vector3i( 0, 1, 0); - case 2: return Vector3i( 0, 0, -1); - case 3: return Vector3i( 0, 0, 1); - case 4: return Vector3i(-1, 0, 0); - case 5: return Vector3i( 1, 0, 0); + case 0: return Vector3i(0, -1, 0); + case 1: return Vector3i(0, 1, 0); + case 2: return Vector3i(0, 0, -1); + case 3: return Vector3i(0, 0, 1); + case 4: return Vector3i(-1, 0, 0); + case 5: return Vector3i(1, 0, 0); default: { LOGWARNING("%s: invalid direction %d, ignoring", __FUNCTION__, a_PistonMeta & 0x07); @@ -56,7 +56,9 @@ void cBlockPistonHandler::ExtendPiston(Vector3i a_BlockPos, cWorld & a_World) // However, we don't confuse animation with the underlying state of the world, so emulate by delaying 1 tick // (Probably why vanilla has so many dupe glitches with sand and pistons lolol) - a_World.ScheduleTask(1_tick, [a_BlockPos](cWorld & World) + a_World.ScheduleTask( + 1_tick, + [a_BlockPos](cWorld & World) { BLOCKTYPE pistonBlock; NIBBLETYPE pistonMeta; @@ -108,7 +110,9 @@ void cBlockPistonHandler::RetractPiston(Vector3i a_BlockPos, cWorld & a_World) a_World.BroadcastBlockAction(a_BlockPos, PistonRetractAction, pistonMeta, pistonBlock); } - a_World.ScheduleTask(1_tick, [a_BlockPos](cWorld & World) + a_World.ScheduleTask( + 1_tick, + [a_BlockPos](cWorld & World) { BLOCKTYPE pistonBlock; NIBBLETYPE pistonMeta; @@ -171,18 +175,16 @@ void cBlockPistonHandler::RetractPiston(Vector3i a_BlockPos, cWorld & a_World) -void cBlockPistonHandler::PushBlocks( - const Vector3iSet & a_BlocksToPush, - cWorld & a_World, const Vector3i & a_PushDir -) +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)); - }); + 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; @@ -211,8 +213,11 @@ void cBlockPistonHandler::PushBlocks( bool cBlockPistonHandler::CanPushBlock( - const Vector3i & a_BlockPos, cWorld & a_World, bool a_RequirePushable, - Vector3iSet & a_BlocksPushed, const Vector3i & a_PushDir + const Vector3i & a_BlockPos, + cWorld & a_World, + bool a_RequirePushable, + Vector3iSet & a_BlocksPushed, + const Vector3i & a_PushDir ) { if (!cChunkDef::IsValidHeight(a_BlockPos)) @@ -221,13 +226,13 @@ bool cBlockPistonHandler::CanPushBlock( return false; } - 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) - } + 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; @@ -285,9 +290,11 @@ bool cBlockPistonHandler::CanPushBlock( void cBlockPistonHandler::OnBroken( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, - BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta, + BLOCKTYPE a_OldBlockType, + NIBBLETYPE a_OldBlockMeta, const cEntity * a_Digger ) const { @@ -298,10 +305,7 @@ void cBlockPistonHandler::OnBroken( } const auto Extension = a_BlockPos + MetadataToOffset(a_OldBlockMeta); - if ( - cChunkDef::IsValidHeight(Extension) && - (a_ChunkInterface.GetBlock(Extension) == E_BLOCK_PISTON_EXTENSION) - ) + if (cChunkDef::IsValidHeight(Extension) && (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); @@ -316,9 +320,11 @@ void cBlockPistonHandler::OnBroken( // cBlockPistonHeadHandler: void cBlockPistonHeadHandler::OnBroken( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, - BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta, + BLOCKTYPE a_OldBlockType, + NIBBLETYPE a_OldBlockMeta, const cEntity * a_Digger ) const { @@ -344,6 +350,7 @@ void cBlockPistonHeadHandler::OnBroken( cItems cBlockPistonHeadHandler::ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const 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... - return { cItem(((a_BlockMeta & 0x8) == 0x8) ? E_BLOCK_STICKY_PISTON : E_BLOCK_PISTON) }; + // With 1.7, the item forms of these technical blocks have been removed, so giving someone this will crash their + // client... + return {cItem(((a_BlockMeta & 0x8) == 0x8) ? E_BLOCK_STICKY_PISTON : E_BLOCK_PISTON)}; } diff --git a/src/Blocks/BlockPiston.h b/src/Blocks/BlockPiston.h index 4afeb4767..637fcd32b 100644 --- a/src/Blocks/BlockPiston.h +++ b/src/Blocks/BlockPiston.h @@ -15,13 +15,12 @@ class cWorld; -class cBlockPistonHandler final : - public cClearMetaOnDrop<cDisplacementYawRotator<cBlockHandler, 0x07, 0x03, 0x04, 0x02, 0x05, 0x01, 0x00>> +class cBlockPistonHandler final + : public cClearMetaOnDrop<cDisplacementYawRotator<cBlockHandler, 0x07, 0x03, 0x04, 0x02, 0x05, 0x01, 0x00>> { using Super = cClearMetaOnDrop<cDisplacementYawRotator<cBlockHandler, 0x07, 0x03, 0x04, 0x02, 0x05, 0x01, 0x00>>; -public: - + public: using Super::Super; static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData) @@ -42,7 +41,8 @@ public: } } - /** Converts piston block's metadata into a unit vector representing the direction in which the piston will extend. */ + /** Converts piston block's metadata into a unit vector representing the direction in which the piston will extend. + */ static Vector3i MetadataToOffset(NIBBLETYPE a_PistonMeta); static void ExtendPiston(Vector3i a_BlockPos, cWorld & a_World); @@ -51,8 +51,7 @@ public: /** Returns true if the piston (with the specified meta) is extended */ static inline bool IsExtended(NIBBLETYPE a_PistonMeta) { return ((a_PistonMeta & 0x8) != 0x0); } -private: - + private: typedef std::unordered_set<Vector3i, VectorHasher<int>> Vector3iSet; /** Piston extension block action */ @@ -115,8 +114,11 @@ private: /** Tries to push a block and increases the pushed blocks variable. Returns true if the block is pushable */ static bool CanPushBlock( - const Vector3i & a_BlockPos, cWorld & a_World, bool a_RequirePushable, - Vector3iSet & a_BlocksPushed, const Vector3i & a_PushDir + const Vector3i & a_BlockPos, + cWorld & a_World, + bool a_RequirePushable, + Vector3iSet & a_BlocksPushed, + const Vector3i & a_PushDir ); virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override @@ -126,40 +128,40 @@ private: } virtual void OnBroken( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, - BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta, + BLOCKTYPE a_OldBlockType, + NIBBLETYPE a_OldBlockMeta, const cEntity * a_Digger ) 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 - ); -} ; + static void PushBlocks(const Vector3iSet & a_BlocksToPush, cWorld & a_World, const Vector3i & a_PushDir); +}; -class cBlockPistonHeadHandler final : - public cBlockHandler +class cBlockPistonHeadHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: constexpr cBlockPistonHeadHandler(void) : Super(E_BLOCK_PISTON_EXTENSION) { } virtual void OnBroken( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, - BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta, + BLOCKTYPE a_OldBlockType, + NIBBLETYPE a_OldBlockMeta, const cEntity * a_Digger ) const override; virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cItem * a_Tool) const override; -} ; +}; diff --git a/src/Blocks/BlockPlanks.h b/src/Blocks/BlockPlanks.h index d6e79b3c0..c0e099b33 100644 --- a/src/Blocks/BlockPlanks.h +++ b/src/Blocks/BlockPlanks.h @@ -7,27 +7,24 @@ -class cBlockPlanksHandler final : - public cBlockHandler +class cBlockPlanksHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override { switch (a_Meta) { - case E_META_PLANKS_BIRCH: return 2; - case E_META_PLANKS_JUNGLE: return 10; - case E_META_PLANKS_OAK: return 13; - case E_META_PLANKS_ACACIA: return 15; + case E_META_PLANKS_BIRCH: return 2; + case E_META_PLANKS_JUNGLE: return 10; + case E_META_PLANKS_OAK: return 13; + case E_META_PLANKS_ACACIA: return 15; case E_META_PLANKS_DARK_OAK: return 26; - case E_META_PLANKS_SPRUCE: return 34; + case E_META_PLANKS_SPRUCE: return 34; default: { ASSERT(!"Unhandled meta in planks handler!"); @@ -35,8 +32,4 @@ private: } } } -} ; - - - - +}; diff --git a/src/Blocks/BlockPlant.h b/src/Blocks/BlockPlant.h index ab3f137a5..d87bdb64b 100644 --- a/src/Blocks/BlockPlant.h +++ b/src/Blocks/BlockPlant.h @@ -7,19 +7,16 @@ /** Base class for plants that use light values to decide whether to grow or not. -On block update, the plant decides whether to grow, die or stay as-is, based on the CanGrow() overridable method result. */ -template <bool NeedsLightToGrow> -class cBlockPlant : - public cBlockHandler +On block update, the plant decides whether to grow, die or stay as-is, based on the CanGrow() overridable method result. +*/ +template <bool NeedsLightToGrow> class cBlockPlant : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -protected: - + protected: ~cBlockPlant() = default; /** The action the plant can take on an update. */ @@ -44,7 +41,7 @@ protected: return paGrowth; } NIBBLETYPE Blocklight = a_Chunk.GetBlockLight(a_RelPos); - NIBBLETYPE SkyLight = a_Chunk.GetSkyLight (a_RelPos); + NIBBLETYPE SkyLight = a_Chunk.GetSkyLight(a_RelPos); NIBBLETYPE Light = a_Chunk.GetTimeAlteredLight(SkyLight); // If the amount of light provided by blocks is greater than the sky light, use it instead @@ -80,7 +77,8 @@ protected: */ 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 + // 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); if ((action == paGrowth) && !GetRandomProvider().RandBool(1.0 / GetGrowthChance(a_Chunk, a_RelPos))) { @@ -135,8 +133,7 @@ protected: return FloorC(24.0f / Chance) + 1; } -private: - + private: virtual void OnUpdate( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, diff --git a/src/Blocks/BlockPluginInterface.h b/src/Blocks/BlockPluginInterface.h index 0cf3ef0e3..da9f5c7a2 100644 --- a/src/Blocks/BlockPluginInterface.h +++ b/src/Blocks/BlockPluginInterface.h @@ -1,7 +1,8 @@ // BlockPluginInterface.h -// Declares the cBlockPluginInterface class representing an interface that the blockhandlers and itemhandlers use for calling plugins +// Declares the cBlockPluginInterface class representing an interface that the blockhandlers and itemhandlers use for +// calling plugins @@ -26,14 +27,22 @@ the caller provides. */ class cBlockPluginInterface { -public: + public: virtual ~cBlockPluginInterface() {} virtual bool CallHookBlockSpread(Vector3i a_BlockPos, eSpreadSource a_Source) = 0; - virtual bool CallHookPlayerBreakingBlock(cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0; - virtual bool CallHookPlayerBrokenBlock(cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0; + virtual bool CallHookPlayerBreakingBlock( + cPlayer & a_Player, + Vector3i a_BlockPos, + eBlockFace a_BlockFace, + BLOCKTYPE a_BlockType, + NIBBLETYPE a_BlockMeta + ) = 0; + virtual bool CallHookPlayerBrokenBlock( + cPlayer & a_Player, + Vector3i a_BlockPos, + eBlockFace a_BlockFace, + BLOCKTYPE a_BlockType, + NIBBLETYPE a_BlockMeta + ) = 0; }; - - - - diff --git a/src/Blocks/BlockPortal.h b/src/Blocks/BlockPortal.h index 05daa9337..f704f2581 100644 --- a/src/Blocks/BlockPortal.h +++ b/src/Blocks/BlockPortal.h @@ -7,17 +7,14 @@ -class cBlockPortalHandler final : - public cBlockHandler +class cBlockPortalHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { // No pickups @@ -53,22 +50,20 @@ private: { if ((a_Position.y <= 0) || (a_Position.y >= cChunkDef::Height - 1)) { - return false; // In case someone places a portal with meta 1 or 2 at boundaries, and server tries to get invalid coords at Y - 1 or Y + 1. + return false; // In case someone places a portal with meta 1 or 2 at boundaries, and server tries to get + // invalid coords at Y - 1 or Y + 1. } switch (a_Meta) { case 0x1: { - static const std::array<Vector3i, 4> PortalCheck - { - { - { 0, 1, 0 }, - { 0, -1, 0 }, - { 1, 0, 0 }, - { -1, 0, 0 }, - } - }; + static const std::array<Vector3i, 4> PortalCheck {{ + {0, 1, 0}, + {0, -1, 0}, + {1, 0, 0}, + {-1, 0, 0}, + }}; for (const auto & Direction : PortalCheck) { @@ -83,15 +78,12 @@ private: } case 0x2: { - static const std::array<Vector3i, 4> PortalCheck - { - { - { 0, 1, 0 }, - { 0, -1, 0 }, - { 0, 0, -1 }, - { 0, 0, 1 }, - } - }; + static const std::array<Vector3i, 4> PortalCheck {{ + {0, 1, 0}, + {0, -1, 0}, + {0, 0, -1}, + {0, 0, 1}, + }}; for (const auto & Direction : PortalCheck) { @@ -117,8 +109,4 @@ private: UNUSED(a_Meta); return 24; } -} ; - - - - +}; diff --git a/src/Blocks/BlockPressurePlate.h b/src/Blocks/BlockPressurePlate.h index 6d852bfc0..bf78329b1 100644 --- a/src/Blocks/BlockPressurePlate.h +++ b/src/Blocks/BlockPressurePlate.h @@ -9,17 +9,14 @@ -class cBlockPressurePlateHandler final : - public cClearMetaOnDrop<cBlockHandler> +class cBlockPressurePlateHandler final : public cClearMetaOnDrop<cBlockHandler> { using Super = cClearMetaOnDrop<cBlockHandler>; -public: - + public: using Super::Super; -private: - + private: virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override { if (a_Position.y <= 0) @@ -72,8 +69,8 @@ private: UNUSED(a_Meta); switch (m_BlockType) { - case E_BLOCK_STONE_PRESSURE_PLATE: return 11; - case E_BLOCK_WOODEN_PRESSURE_PLATE: return 13; + case E_BLOCK_STONE_PRESSURE_PLATE: return 11; + case E_BLOCK_WOODEN_PRESSURE_PLATE: return 13; case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE: return 6; case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: return 30; default: @@ -83,8 +80,4 @@ private: } } } -} ; - - - - +}; diff --git a/src/Blocks/BlockPumpkin.h b/src/Blocks/BlockPumpkin.h index e627eeaee..ff9d96c43 100644 --- a/src/Blocks/BlockPumpkin.h +++ b/src/Blocks/BlockPumpkin.h @@ -5,24 +5,17 @@ -class cBlockPumpkinHandler final : - public cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03>> +class cBlockPumpkinHandler final : public cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03>> { using Super = cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03>>; -public: - + public: using Super::Super; -private: - + private: 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 bc10985df..968fa9fd3 100644 --- a/src/Blocks/BlockQuartz.h +++ b/src/Blocks/BlockQuartz.h @@ -7,20 +7,17 @@ -class cBlockQuartzHandler final : - public cBlockHandler +class cBlockQuartzHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: 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 4e2e6211f..be46fb642 100644 --- a/src/Blocks/BlockRail.h +++ b/src/Blocks/BlockRail.h @@ -24,13 +24,11 @@ enum ENUM_PURE -class cBlockRailHandler final : - public cClearMetaOnDrop<cBlockHandler> +class cBlockRailHandler final : public cClearMetaOnDrop<cBlockHandler> { using Super = cClearMetaOnDrop<cBlockHandler>; -public: - + public: using Super::Super; @@ -38,29 +36,50 @@ public: { NIBBLETYPE Meta = 0; char RailsCnt = 0; - bool Neighbors[8]; // 0 - EAST, 1 - WEST, 2 - NORTH, 3 - SOUTH, 4 - EAST UP, 5 - WEST UP, 6 - NORTH UP, 7 - SOUTH UP + bool Neighbors[8]; // 0 - EAST, 1 - WEST, 2 - NORTH, 3 - SOUTH, 4 - EAST UP, 5 - WEST UP, 6 - NORTH UP, 7 - + // SOUTH UP memset(Neighbors, 0, sizeof(Neighbors)); - Neighbors[0] = (IsUnstable(a_ChunkInterface, a_BlockPos + Vector3i(1, 0, 0)) || !IsNotConnected(a_ChunkInterface, a_BlockPos, BLOCK_FACE_EAST, E_PURE_DOWN)); - Neighbors[1] = (IsUnstable(a_ChunkInterface, a_BlockPos + Vector3i(-1, 0, 0)) || !IsNotConnected(a_ChunkInterface, a_BlockPos, BLOCK_FACE_WEST, E_PURE_DOWN)); - Neighbors[2] = (IsUnstable(a_ChunkInterface, a_BlockPos + Vector3i(0, 0, -1)) || !IsNotConnected(a_ChunkInterface, a_BlockPos, BLOCK_FACE_NORTH, E_PURE_DOWN)); - Neighbors[3] = (IsUnstable(a_ChunkInterface, a_BlockPos + Vector3i(0, 0, 1)) || !IsNotConnected(a_ChunkInterface, a_BlockPos, BLOCK_FACE_SOUTH, E_PURE_DOWN)); - Neighbors[4] = (IsUnstable(a_ChunkInterface, a_BlockPos + Vector3i(1, 1, 0)) || !IsNotConnected(a_ChunkInterface, a_BlockPos + Vector3i(0, 1, 0), BLOCK_FACE_EAST, E_PURE_NONE)); - Neighbors[5] = (IsUnstable(a_ChunkInterface, a_BlockPos + Vector3i(-1, 1, 0)) || !IsNotConnected(a_ChunkInterface, a_BlockPos + Vector3i(0, 1, 0), BLOCK_FACE_WEST, E_PURE_NONE)); - Neighbors[6] = (IsUnstable(a_ChunkInterface, a_BlockPos + Vector3i(0, 1, -1)) || !IsNotConnected(a_ChunkInterface, a_BlockPos + Vector3i(0, 1, 0), BLOCK_FACE_NORTH, E_PURE_NONE)); - Neighbors[7] = (IsUnstable(a_ChunkInterface, a_BlockPos + Vector3i(0, 1, 1)) || !IsNotConnected(a_ChunkInterface, a_BlockPos + Vector3i(0, 1, 0), BLOCK_FACE_SOUTH, E_PURE_NONE)); - if (IsUnstable(a_ChunkInterface, a_BlockPos + Vector3i(1, -1, 0)) || !IsNotConnected(a_ChunkInterface, a_BlockPos - Vector3i(0, 1, 0), BLOCK_FACE_EAST)) + Neighbors[0] = + (IsUnstable(a_ChunkInterface, a_BlockPos + Vector3i(1, 0, 0)) || + !IsNotConnected(a_ChunkInterface, a_BlockPos, BLOCK_FACE_EAST, E_PURE_DOWN)); + Neighbors[1] = + (IsUnstable(a_ChunkInterface, a_BlockPos + Vector3i(-1, 0, 0)) || + !IsNotConnected(a_ChunkInterface, a_BlockPos, BLOCK_FACE_WEST, E_PURE_DOWN)); + Neighbors[2] = + (IsUnstable(a_ChunkInterface, a_BlockPos + Vector3i(0, 0, -1)) || + !IsNotConnected(a_ChunkInterface, a_BlockPos, BLOCK_FACE_NORTH, E_PURE_DOWN)); + Neighbors[3] = + (IsUnstable(a_ChunkInterface, a_BlockPos + Vector3i(0, 0, 1)) || + !IsNotConnected(a_ChunkInterface, a_BlockPos, BLOCK_FACE_SOUTH, E_PURE_DOWN)); + Neighbors[4] = + (IsUnstable(a_ChunkInterface, a_BlockPos + Vector3i(1, 1, 0)) || + !IsNotConnected(a_ChunkInterface, a_BlockPos + Vector3i(0, 1, 0), BLOCK_FACE_EAST, E_PURE_NONE)); + Neighbors[5] = + (IsUnstable(a_ChunkInterface, a_BlockPos + Vector3i(-1, 1, 0)) || + !IsNotConnected(a_ChunkInterface, a_BlockPos + Vector3i(0, 1, 0), BLOCK_FACE_WEST, E_PURE_NONE)); + Neighbors[6] = + (IsUnstable(a_ChunkInterface, a_BlockPos + Vector3i(0, 1, -1)) || + !IsNotConnected(a_ChunkInterface, a_BlockPos + Vector3i(0, 1, 0), BLOCK_FACE_NORTH, E_PURE_NONE)); + Neighbors[7] = + (IsUnstable(a_ChunkInterface, a_BlockPos + Vector3i(0, 1, 1)) || + !IsNotConnected(a_ChunkInterface, a_BlockPos + Vector3i(0, 1, 0), BLOCK_FACE_SOUTH, E_PURE_NONE)); + if (IsUnstable(a_ChunkInterface, a_BlockPos + Vector3i(1, -1, 0)) || + !IsNotConnected(a_ChunkInterface, a_BlockPos - Vector3i(0, 1, 0), BLOCK_FACE_EAST)) { Neighbors[0] = true; } - if (IsUnstable(a_ChunkInterface, a_BlockPos - Vector3i(1, 1, 0)) || !IsNotConnected(a_ChunkInterface, a_BlockPos - Vector3i(0, 1, 0), BLOCK_FACE_WEST)) + if (IsUnstable(a_ChunkInterface, a_BlockPos - Vector3i(1, 1, 0)) || + !IsNotConnected(a_ChunkInterface, a_BlockPos - Vector3i(0, 1, 0), BLOCK_FACE_WEST)) { Neighbors[1] = true; } - if (IsUnstable(a_ChunkInterface, a_BlockPos - Vector3i(0, 1, 1)) || !IsNotConnected(a_ChunkInterface, a_BlockPos - Vector3i(0, 1, 0), BLOCK_FACE_NORTH)) + if (IsUnstable(a_ChunkInterface, a_BlockPos - Vector3i(0, 1, 1)) || + !IsNotConnected(a_ChunkInterface, a_BlockPos - Vector3i(0, 1, 0), BLOCK_FACE_NORTH)) { Neighbors[2] = true; } - if (IsUnstable(a_ChunkInterface, a_BlockPos + Vector3i(0, -1, 1)) || !IsNotConnected(a_ChunkInterface, a_BlockPos - Vector3i(0, 1, 0), BLOCK_FACE_SOUTH)) + if (IsUnstable(a_ChunkInterface, a_BlockPos + Vector3i(0, -1, 1)) || + !IsNotConnected(a_ChunkInterface, a_BlockPos - Vector3i(0, 1, 0), BLOCK_FACE_SOUTH)) { Neighbors[3] = true; } @@ -160,8 +179,7 @@ public: return Meta; } -private: - + private: static bool CanBeSupportedBy(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { if (cBlockSlabHandler::IsAnySlabType(a_BlockType)) @@ -195,14 +213,13 @@ private: { // Mapping between the meta and the neighbors that need checking a_Meta -= E_META_RAIL_ASCEND_XP; // Base index at zero - static const Vector3i Coords[] = - { - { 1, 0, 0}, // east, XP - {-1, 0, 0}, // west, XM - { 0, 0, -1}, // north, ZM - { 0, 0, 1}, // south, ZP - } ; - BLOCKTYPE BlockType; + static const Vector3i Coords[] = { + {1, 0, 0}, // east, XP + {-1, 0, 0}, // west, XM + {0, 0, -1}, // north, ZM + {0, 0, 1}, // south, ZP + }; + BLOCKTYPE BlockType; NIBBLETYPE BlockMeta; if (!a_Chunk.UnboundedRelGetBlock(a_Position + Coords[a_Meta], BlockType, BlockMeta)) { @@ -228,10 +245,8 @@ private: { case E_META_RAIL_ZM_ZP: { - if ( - IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_NORTH, E_PURE_DOWN) || - IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_SOUTH, E_PURE_DOWN) - ) + if (IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_NORTH, E_PURE_DOWN) || + IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_SOUTH, E_PURE_DOWN)) { return true; } @@ -240,10 +255,8 @@ private: case E_META_RAIL_XM_XP: { - if ( - IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_EAST, E_PURE_DOWN) || - IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_WEST, E_PURE_DOWN) - ) + if (IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_EAST, E_PURE_DOWN) || + IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_WEST, E_PURE_DOWN)) { return true; } @@ -252,10 +265,8 @@ private: case E_META_RAIL_ASCEND_XP: { - if ( - IsNotConnected(a_ChunkInterface, a_Pos + Vector3i(0, 1, 0), BLOCK_FACE_EAST) || - IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_WEST) - ) + if (IsNotConnected(a_ChunkInterface, a_Pos + Vector3i(0, 1, 0), BLOCK_FACE_EAST) || + IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_WEST)) { return true; } @@ -264,10 +275,8 @@ private: case E_META_RAIL_ASCEND_XM: { - if ( - IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_EAST) || - IsNotConnected(a_ChunkInterface, a_Pos + Vector3i(0, 1, 0), BLOCK_FACE_WEST) - ) + if (IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_EAST) || + IsNotConnected(a_ChunkInterface, a_Pos + Vector3i(0, 1, 0), BLOCK_FACE_WEST)) { return true; } @@ -276,10 +285,8 @@ private: case E_META_RAIL_ASCEND_ZM: { - if ( - IsNotConnected(a_ChunkInterface, a_Pos + Vector3i(0, 1, 0), BLOCK_FACE_NORTH) || - IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_SOUTH) - ) + if (IsNotConnected(a_ChunkInterface, a_Pos + Vector3i(0, 1, 0), BLOCK_FACE_NORTH) || + IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_SOUTH)) { return true; } @@ -288,10 +295,8 @@ private: case E_META_RAIL_ASCEND_ZP: { - if ( - IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_NORTH) || - IsNotConnected(a_ChunkInterface, a_Pos + Vector3i(0, 1, 0), BLOCK_FACE_SOUTH) - ) + if (IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_NORTH) || + IsNotConnected(a_ChunkInterface, a_Pos + Vector3i(0, 1, 0), BLOCK_FACE_SOUTH)) { return true; } @@ -300,10 +305,8 @@ private: case E_META_RAIL_CURVED_ZP_XP: { - if ( - IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_SOUTH) || - IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_EAST) - ) + if (IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_SOUTH) || + IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_EAST)) { return true; } @@ -312,10 +315,8 @@ private: case E_META_RAIL_CURVED_ZP_XM: { - if ( - IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_SOUTH) || - IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_WEST) - ) + if (IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_SOUTH) || + IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_WEST)) { return true; } @@ -324,10 +325,8 @@ private: case E_META_RAIL_CURVED_ZM_XM: { - if ( - IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_NORTH) || - IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_WEST) - ) + if (IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_NORTH) || + IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_WEST)) { return true; } @@ -336,10 +335,8 @@ private: case E_META_RAIL_CURVED_ZM_XP: { - if ( - IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_NORTH) || - IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_EAST) - ) + if (IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_NORTH) || + IsNotConnected(a_ChunkInterface, a_Pos, BLOCK_FACE_EAST)) { return true; } @@ -350,7 +347,12 @@ private: } - static 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 + ) { a_Pos = AddFaceDirection(a_Pos, a_BlockFace, false); @@ -383,13 +385,8 @@ private: { case BLOCK_FACE_NORTH: { - if ( - (Meta == E_META_RAIL_ZM_ZP) || - (Meta == E_META_RAIL_ASCEND_ZM) || - (Meta == E_META_RAIL_ASCEND_ZP) || - (Meta == E_META_RAIL_CURVED_ZP_XP) || - (Meta == E_META_RAIL_CURVED_ZP_XM) - ) + if ((Meta == E_META_RAIL_ZM_ZP) || (Meta == E_META_RAIL_ASCEND_ZM) || (Meta == E_META_RAIL_ASCEND_ZP) || + (Meta == E_META_RAIL_CURVED_ZP_XP) || (Meta == E_META_RAIL_CURVED_ZP_XM)) { return false; } @@ -398,13 +395,8 @@ private: case BLOCK_FACE_SOUTH: { - if ( - (Meta == E_META_RAIL_ZM_ZP) || - (Meta == E_META_RAIL_ASCEND_ZM) || - (Meta == E_META_RAIL_ASCEND_ZP) || - (Meta == E_META_RAIL_CURVED_ZM_XP) || - (Meta == E_META_RAIL_CURVED_ZM_XM) - ) + if ((Meta == E_META_RAIL_ZM_ZP) || (Meta == E_META_RAIL_ASCEND_ZM) || (Meta == E_META_RAIL_ASCEND_ZP) || + (Meta == E_META_RAIL_CURVED_ZM_XP) || (Meta == E_META_RAIL_CURVED_ZM_XM)) { return false; } @@ -413,13 +405,8 @@ private: case BLOCK_FACE_EAST: { - if ( - (Meta == E_META_RAIL_XM_XP) || - (Meta == E_META_RAIL_ASCEND_XP) || - (Meta == E_META_RAIL_ASCEND_XM) || - (Meta == E_META_RAIL_CURVED_ZP_XM) || - (Meta == E_META_RAIL_CURVED_ZM_XM) - ) + if ((Meta == E_META_RAIL_XM_XP) || (Meta == E_META_RAIL_ASCEND_XP) || (Meta == E_META_RAIL_ASCEND_XM) || + (Meta == E_META_RAIL_CURVED_ZP_XM) || (Meta == E_META_RAIL_CURVED_ZM_XM)) { return false; } @@ -427,13 +414,8 @@ private: } case BLOCK_FACE_WEST: { - if ( - (Meta == E_META_RAIL_XM_XP) || - (Meta == E_META_RAIL_ASCEND_XP) || - (Meta == E_META_RAIL_ASCEND_XM) || - (Meta == E_META_RAIL_CURVED_ZP_XP) || - (Meta == E_META_RAIL_CURVED_ZM_XP) - ) + if ((Meta == E_META_RAIL_XM_XP) || (Meta == E_META_RAIL_ASCEND_XP) || (Meta == E_META_RAIL_ASCEND_XM) || + (Meta == E_META_RAIL_CURVED_ZP_XP) || (Meta == E_META_RAIL_CURVED_ZM_XP)) { return false; } @@ -451,33 +433,40 @@ private: virtual void OnBroken( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, - BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta, + BLOCKTYPE a_OldBlockType, + NIBBLETYPE a_OldBlockMeta, const cEntity * a_Digger ) const override { Super::OnBroken(a_ChunkInterface, a_WorldInterface, a_BlockPos, a_OldBlockType, a_OldBlockMeta, a_Digger); // Alert diagonal rails: - NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i( 1, 1, 0), BLOCK_FACE_NONE); - NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i(-1, 1, 0), BLOCK_FACE_NONE); - NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i( 0, +1, 1), BLOCK_FACE_NONE); - NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i( 0, +1, -1), BLOCK_FACE_NONE); - NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i( 1, -1, 0), BLOCK_FACE_NONE); - NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i(-1, -1, 0), BLOCK_FACE_NONE); - NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i( 0, -1, 1), BLOCK_FACE_NONE); - NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i( 0, -1, -1), BLOCK_FACE_NONE); + NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i(1, 1, 0), BLOCK_FACE_NONE); + NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i(-1, 1, 0), BLOCK_FACE_NONE); + NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i(0, +1, 1), BLOCK_FACE_NONE); + NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i(0, +1, -1), BLOCK_FACE_NONE); + NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i(1, -1, 0), BLOCK_FACE_NONE); + NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i(-1, -1, 0), BLOCK_FACE_NONE); + NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i(0, -1, 1), BLOCK_FACE_NONE); + NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i(0, -1, -1), BLOCK_FACE_NONE); } - virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const 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, m_BlockType); if ((Meta != NewMeta) && IsUnstable(a_ChunkInterface, a_BlockPos)) { - a_ChunkInterface.FastSetBlock(a_BlockPos, m_BlockType, (m_BlockType == E_BLOCK_RAIL) ? NewMeta : NewMeta | (Meta & 0x08)); + a_ChunkInterface.FastSetBlock( + a_BlockPos, + m_BlockType, + (m_BlockType == E_BLOCK_RAIL) ? NewMeta : NewMeta | (Meta & 0x08) + ); } Super::OnNeighborChanged(a_ChunkInterface, a_BlockPos, a_WhichNeighbor); @@ -485,22 +474,24 @@ private: virtual void OnPlaced( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, - BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta + BLOCKTYPE a_BlockType, + NIBBLETYPE a_BlockMeta ) const override { Super::OnPlaced(a_ChunkInterface, a_WorldInterface, a_BlockPos, a_BlockType, a_BlockMeta); // Alert diagonal rails: - NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i( 1, 1, 0), BLOCK_FACE_NONE); - NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i(-1, 1, 0), BLOCK_FACE_NONE); - NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i( 0, +1, 1), BLOCK_FACE_NONE); - NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i( 0, +1, -1), BLOCK_FACE_NONE); - NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i( 1, -1, 0), BLOCK_FACE_NONE); - NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i(-1, -1, 0), BLOCK_FACE_NONE); - NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i( 0, -1, 1), BLOCK_FACE_NONE); - NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i( 0, -1, -1), BLOCK_FACE_NONE); + NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i(1, 1, 0), BLOCK_FACE_NONE); + NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i(-1, 1, 0), BLOCK_FACE_NONE); + NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i(0, +1, 1), BLOCK_FACE_NONE); + NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i(0, +1, -1), BLOCK_FACE_NONE); + NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i(1, -1, 0), BLOCK_FACE_NONE); + NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i(-1, -1, 0), BLOCK_FACE_NONE); + NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i(0, -1, 1), BLOCK_FACE_NONE); + NeighborChanged(a_ChunkInterface, a_BlockPos + Vector3i(0, -1, -1), BLOCK_FACE_NONE); } @@ -510,7 +501,7 @@ private: // Bit 0x08 specifies direction when a_Meta is in the range 0x06-0x09. if ((a_Meta < 0x06) || (a_Meta > 0x09)) { - // Save powered rail flag. + // Save powered rail flag. NIBBLETYPE OtherMeta = a_Meta & 0x08; // Rotates according to table; 0x07 == 0111. // Rails can either be flat (North / South) or Ascending (Asc. East) @@ -546,7 +537,7 @@ private: // 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)) { - // Save powered rail flag. + // Save powered rail flag. NIBBLETYPE OtherMeta = a_Meta & 0x08; // Rotates according to table; 0x07 == 0111. // Rails can either be flat (North / South) or Ascending (Asc. East) @@ -660,4 +651,4 @@ private: UNUSED(a_Meta); return 0; } -} ; +}; diff --git a/src/Blocks/BlockRedstoneLamp.h b/src/Blocks/BlockRedstoneLamp.h index fc0882a8f..b82c19a7b 100644 --- a/src/Blocks/BlockRedstoneLamp.h +++ b/src/Blocks/BlockRedstoneLamp.h @@ -7,19 +7,16 @@ -class cBlockRedstoneLampHandler final : - public cBlockHandler +class cBlockRedstoneLampHandler final : public cBlockHandler { -public: - + public: using cBlockHandler::cBlockHandler; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { // Always drop the Off variant: - return(cItem(E_BLOCK_REDSTONE_LAMP_OFF, 1, 0)); + return (cItem(E_BLOCK_REDSTONE_LAMP_OFF, 1, 0)); } @@ -32,7 +29,3 @@ private: return 15; } }; - - - - diff --git a/src/Blocks/BlockRedstoneOre.h b/src/Blocks/BlockRedstoneOre.h index 82e7c618c..e7be7658b 100644 --- a/src/Blocks/BlockRedstoneOre.h +++ b/src/Blocks/BlockRedstoneOre.h @@ -8,13 +8,11 @@ -class cBlockRedstoneOreHandler final : - public cBlockOreHandler +class cBlockRedstoneOreHandler final : public cBlockOreHandler { using Super = cBlockOreHandler; -public: - + public: using Super::Super; // Inherit constructor from base @@ -22,7 +20,9 @@ public: virtual bool OnUse( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, + cPlayer & a_Player, const Vector3i a_BlockPos, eBlockFace a_BlockFace, const Vector3i a_CursorPos @@ -50,23 +50,18 @@ public: - virtual bool IsUseable() const override - { - return true; - } + virtual bool IsUseable() const override { return true; } }; -class cBlockGlowingRedstoneOreHandler final : - public cBlockOreHandler +class cBlockGlowingRedstoneOreHandler final : public cBlockOreHandler { using Super = cBlockOreHandler; -public: - + public: using Super::Super; // Inherit constructor from base @@ -85,8 +80,3 @@ public: a_ChunkInterface.SetBlock(BlockPos, E_BLOCK_REDSTONE_ORE, 0); } }; - - - - - diff --git a/src/Blocks/BlockRedstoneRepeater.h b/src/Blocks/BlockRedstoneRepeater.h index 893691d7b..ce0615e00 100644 --- a/src/Blocks/BlockRedstoneRepeater.h +++ b/src/Blocks/BlockRedstoneRepeater.h @@ -13,34 +13,29 @@ -class cBlockRedstoneRepeaterHandler final : - public cYawRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03> +class cBlockRedstoneRepeaterHandler final : public cYawRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03> { using Super = cYawRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03>; -public: - + public: using Super::Super; - inline static Vector3i GetFrontCoordinateOffset(NIBBLETYPE a_Meta) - { - return -GetRearCoordinateOffset(a_Meta); - } + 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 }; + 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 }; + return {0, 0, 0}; } } } @@ -49,21 +44,20 @@ public: { 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 }; + 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 }; + return {0, 0, 0}; } } } -private: - + private: virtual bool OnUse( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, @@ -98,10 +92,7 @@ private: - virtual bool IsUseable(void) const override - { - return true; - } + virtual bool IsUseable(void) const override { return true; } @@ -156,8 +147,4 @@ private: UNUSED(a_Meta); return 11; } -} ; - - - - +}; diff --git a/src/Blocks/BlockRedstoneWire.h b/src/Blocks/BlockRedstoneWire.h index de8e59a40..6f26f8c89 100644 --- a/src/Blocks/BlockRedstoneWire.h +++ b/src/Blocks/BlockRedstoneWire.h @@ -9,17 +9,14 @@ -class cBlockRedstoneWireHandler final : - public cBlockHandler +class cBlockRedstoneWireHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override { if (a_Position.y <= 0) @@ -69,8 +66,4 @@ private: UNUSED(a_Meta); return 0; } -} ; - - - - +}; diff --git a/src/Blocks/BlockSand.h b/src/Blocks/BlockSand.h index 0c117c40f..f5f77a964 100644 --- a/src/Blocks/BlockSand.h +++ b/src/Blocks/BlockSand.h @@ -7,15 +7,12 @@ -class cBlockSandHandler final : - public cBlockHandler +class cBlockSandHandler final : public cBlockHandler { -public: - + public: using cBlockHandler::cBlockHandler; -private: - + private: virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override { UNUSED(a_Meta); diff --git a/src/Blocks/BlockSapling.h b/src/Blocks/BlockSapling.h index d32b9b449..782dcea1a 100644 --- a/src/Blocks/BlockSapling.h +++ b/src/Blocks/BlockSapling.h @@ -8,17 +8,14 @@ -class cBlockSaplingHandler final : - public cBlockHandler +class cBlockSaplingHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { // The low 3 bits store the sapling type; bit 0x08 is the growth timer (not used in pickups) @@ -47,14 +44,16 @@ private: ) 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))); + auto Light = + std::max(a_Chunk.GetBlockLight(a_RelPos), a_Chunk.GetTimeAlteredLight(a_Chunk.GetSkyLight(a_RelPos))); // Only grow if we have the right amount of light if (Light > 8) { auto & random = GetRandomProvider(); // Only grow if we are in the right growth stage and have the right amount of space around them. - if (((Meta & 0x08) != 0) && random.RandBool(0.45) && CanGrowAt(a_Chunk, a_RelPos.x, a_RelPos.y, a_RelPos.z, Meta)) + if (((Meta & 0x08) != 0) && random.RandBool(0.45) && + CanGrowAt(a_Chunk, a_RelPos.x, a_RelPos.y, a_RelPos.z, Meta)) { auto WorldPos = a_Chunk.RelativeToAbsolute(a_RelPos); a_Chunk.GetWorld()->GrowTree(WorldPos); @@ -236,8 +235,4 @@ private: return LargeTree; } -} ; - - - - +}; diff --git a/src/Blocks/BlockSeaLantern.h b/src/Blocks/BlockSeaLantern.h index 6dbaeda34..06b4fee14 100644 --- a/src/Blocks/BlockSeaLantern.h +++ b/src/Blocks/BlockSeaLantern.h @@ -7,17 +7,14 @@ -class cBlockSeaLanternHandler final : - public cBlockHandler +class cBlockSeaLanternHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { // Drop self only when using silk-touch: @@ -30,4 +27,4 @@ private: const auto DropNum = FortuneDiscreteRandom(2, 3, ToolFortuneLevel(a_Tool), 5); return cItem(E_ITEM_PRISMARINE_CRYSTALS, DropNum); } -} ; +}; diff --git a/src/Blocks/BlockSideways.h b/src/Blocks/BlockSideways.h index f2c4ce4e6..0c6fe4572 100644 --- a/src/Blocks/BlockSideways.h +++ b/src/Blocks/BlockSideways.h @@ -9,20 +9,17 @@ /** Handler for blocks that have 3 orientations (hay bale, log), specified by the upper 2 bits in meta. Additionally supports the metadata specifying block sub-type in its lower 2 bits. */ -class cBlockSidewaysHandler final : - public cBlockHandler +class cBlockSidewaysHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const 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 b96498cbd..43cdd1ac4 100644 --- a/src/Blocks/BlockSignPost.h +++ b/src/Blocks/BlockSignPost.h @@ -8,17 +8,14 @@ -class cBlockSignPostHandler final : - public cBlockHandler +class cBlockSignPostHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { return cItem(E_ITEM_SIGN, 1, 0); @@ -43,19 +40,13 @@ private: - virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) const override - { - return (a_Meta + 4) & 0x0f; - } + virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) const override { return (a_Meta + 4) & 0x0f; } - virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) const override - { - return (a_Meta + 12) & 0x0f; - } + virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) const override { return (a_Meta + 12) & 0x0f; } @@ -92,8 +83,4 @@ private: UNUSED(a_Meta); return 13; } -} ; - - - - +}; diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index 566c88c71..51a330de3 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -17,28 +17,23 @@ -class cBlockSlabHandler final : - public cBlockHandler +class cBlockSlabHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: 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) + (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: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { // Reset the "top half" flag: @@ -46,10 +41,17 @@ private: } - virtual bool DoesIgnoreBuildCollision(const cWorld & a_World, const cItem & a_HeldItem, const Vector3i a_Position, const NIBBLETYPE a_Meta, const eBlockFace a_ClickedBlockFace, const bool a_ClickedDirectly) const override + virtual bool DoesIgnoreBuildCollision( + const cWorld & a_World, + const cItem & a_HeldItem, + const Vector3i a_Position, + const NIBBLETYPE a_Meta, + const eBlockFace a_ClickedBlockFace, + const bool a_ClickedDirectly + ) const override { - /* Double slab combining uses build collision checks to replace single slabs with double slabs in the right conditions. - For us to be replaced, the player must be: + /* Double slab combining uses build collision checks to replace single slabs with double slabs in the right + conditions. For us to be replaced, the player must be: 1. Placing the same slab material. 2. Placing the same slab sub-kind (and existing slab is single). */ if ((m_BlockType != a_HeldItem.m_ItemType) || ((a_Meta & 0x07) != a_HeldItem.m_ItemDamage)) @@ -58,7 +60,8 @@ private: } const bool IsTopSlab = (a_Meta & 0x08) == 0x08; - const auto CanClickCombine = ((a_ClickedBlockFace == BLOCK_FACE_TOP) && !IsTopSlab) || ((a_ClickedBlockFace == BLOCK_FACE_BOTTOM) && IsTopSlab); + const auto CanClickCombine = ((a_ClickedBlockFace == BLOCK_FACE_TOP) && !IsTopSlab) || + ((a_ClickedBlockFace == BLOCK_FACE_BOTTOM) && IsTopSlab); /* When the player clicks on us directly, we'll combine if we're a bottom slab and he clicked the top, or vice versa. Clicking on the sides will not combine. @@ -79,7 +82,8 @@ private: eBlockFace a_BlockFace ) const override { - if ((a_BlockFace == BLOCK_FACE_NONE) || (a_Player.GetEquippedItem().m_ItemType != static_cast<short>(m_BlockType))) + if ((a_BlockFace == BLOCK_FACE_NONE) || + (a_Player.GetEquippedItem().m_ItemType != static_cast<short>(m_BlockType))) { return; } @@ -112,14 +116,14 @@ private: { switch (a_Meta) { - case E_META_STONE_SLAB_SANDSTONE: return 2; - case E_META_STONE_SLAB_PLANKS: return 13; + case E_META_STONE_SLAB_SANDSTONE: return 2; + case E_META_STONE_SLAB_PLANKS: return 13; case E_META_STONE_SLAB_STONE_BRICK: case E_META_STONE_SLAB_STONE: - case E_META_STONE_SLAB_COBBLESTONE: return 11; - case E_META_STONE_SLAB_BRICK: return 28; + case E_META_STONE_SLAB_COBBLESTONE: return 11; + case E_META_STONE_SLAB_BRICK: return 28; case E_META_STONE_SLAB_NETHER_BRICK: return 35; - case E_META_STONE_SLAB_QUARTZ: return 8; + case E_META_STONE_SLAB_QUARTZ: return 8; default: { ASSERT(!"Unhandled meta in slab handler!"); @@ -131,12 +135,12 @@ private: { switch (a_Meta) { - case E_META_WOODEN_SLAB_BIRCH: return 2; - case E_META_WOODEN_SLAB_JUNGLE: return 10; - case E_META_WOODEN_SLAB_OAK: return 13; - case E_META_WOODEN_SLAB_ACACIA: return 15; + case E_META_WOODEN_SLAB_BIRCH: return 2; + case E_META_WOODEN_SLAB_JUNGLE: return 10; + case E_META_WOODEN_SLAB_OAK: return 13; + case E_META_WOODEN_SLAB_ACACIA: return 15; case E_META_WOODEN_SLAB_DARK_OAK: return 26; - case E_META_WOODEN_SLAB_SPRUCE: return 34; + case E_META_WOODEN_SLAB_SPRUCE: return 34; default: { ASSERT(!"Unhandled meta in slab handler!"); @@ -172,23 +176,20 @@ private: } return cBlockHandler::IsInsideBlock(a_Position, a_BlockMeta); } -} ; +}; -class cBlockDoubleSlabHandler final : - public cBlockHandler +class cBlockDoubleSlabHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { BLOCKTYPE Block = GetSingleSlabType(m_BlockType); @@ -218,11 +219,8 @@ private: 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 + // 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 cBlockHandler::For(GetSingleSlabType(m_BlockType)).GetMapBaseColourID(a_Meta); } -} ; - - - - +}; diff --git a/src/Blocks/BlockSlime.h b/src/Blocks/BlockSlime.h index 28b50527d..e8fba95f3 100644 --- a/src/Blocks/BlockSlime.h +++ b/src/Blocks/BlockSlime.h @@ -6,15 +6,12 @@ -class cBlockSlimeHandler final : - public cClearMetaOnDrop<cBlockHandler> +class cBlockSlimeHandler final : public cClearMetaOnDrop<cBlockHandler> { -public: - + public: using cClearMetaOnDrop<cBlockHandler>::cClearMetaOnDrop; -private: - + private: virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override { UNUSED(a_Meta); diff --git a/src/Blocks/BlockSnow.h b/src/Blocks/BlockSnow.h index f3fa87a1b..7e85ed907 100644 --- a/src/Blocks/BlockSnow.h +++ b/src/Blocks/BlockSnow.h @@ -7,24 +7,28 @@ -class cBlockSnowHandler final : - public cBlockHandler +class cBlockSnowHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: enum { FullBlockMeta = 7 // Meta value of a full-height snow block. }; - virtual bool DoesIgnoreBuildCollision(const cWorld & a_World, const cItem & a_HeldItem, const Vector3i a_Position, const NIBBLETYPE a_Meta, const eBlockFace a_ClickedBlockFace, const bool a_ClickedDirectly) const override + virtual bool DoesIgnoreBuildCollision( + const cWorld & a_World, + const cItem & a_HeldItem, + const Vector3i a_Position, + const NIBBLETYPE a_Meta, + const eBlockFace a_ClickedBlockFace, + const bool a_ClickedDirectly + ) const override { if (a_Meta == 0) { @@ -34,7 +38,9 @@ private: // Special case if a player is holding a (thin) snow block and its size can be increased: if ((a_HeldItem.m_ItemType == E_BLOCK_SNOW) && (a_Meta < FullBlockMeta)) { - return !a_ClickedDirectly || (a_ClickedBlockFace == BLOCK_FACE_YP); // If clicked an adjacent block, or clicked YP directly, we ignore collision. + return !a_ClickedDirectly || + (a_ClickedBlockFace == BLOCK_FACE_YP + ); // If clicked an adjacent block, or clicked YP directly, we ignore collision. } return false; @@ -99,23 +105,13 @@ private: } -private: - + private: /** Returns true if snow can be placed on top of a block with the given type and meta. */ static bool CanBeOn(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { // If block below is snowable, or it is a thin snow block and is a full thin snow block, say yay: return ( - cBlockInfo::IsSnowable(a_BlockType) || - ( - (a_BlockType == E_BLOCK_SNOW) && - (a_BlockMeta == FullBlockMeta) - ) + cBlockInfo::IsSnowable(a_BlockType) || ((a_BlockType == E_BLOCK_SNOW) && (a_BlockMeta == FullBlockMeta)) ); } - -} ; - - - - +}; diff --git a/src/Blocks/BlockSponge.h b/src/Blocks/BlockSponge.h index 0e4865a8e..5cb445787 100644 --- a/src/Blocks/BlockSponge.h +++ b/src/Blocks/BlockSponge.h @@ -7,29 +7,36 @@ -class cBlockSpongeHandler final : - public cBlockHandler +class cBlockSpongeHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual void OnPlaced( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, - BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta + BLOCKTYPE a_BlockType, + NIBBLETYPE a_BlockMeta ) const override { OnNeighborChanged(a_ChunkInterface, a_BlockPos, BLOCK_FACE_NONE); } - virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const override + virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) + const override { - a_ChunkInterface.DoWithChunkAt(a_BlockPos, [&](cChunk & a_Chunk) { CheckSoaked(cChunkDef::AbsoluteToRelative(a_BlockPos), a_Chunk); return true; }); + a_ChunkInterface.DoWithChunkAt( + a_BlockPos, + [&](cChunk & a_Chunk) + { + CheckSoaked(cChunkDef::AbsoluteToRelative(a_BlockPos), a_Chunk); + return true; + } + ); } /** Check blocks around the sponge to see if they are water. @@ -56,10 +63,11 @@ private: } const auto & WaterCheck = cSimulator::AdjacentOffsets; - const bool ShouldSoak = std::any_of(WaterCheck.cbegin(), WaterCheck.cend(), [a_Rel, &a_Chunk](Vector3i a_Offset) - { - return IsWet(a_Rel + a_Offset, a_Chunk); - }); + const bool ShouldSoak = std::any_of( + WaterCheck.cbegin(), + WaterCheck.cend(), + [a_Rel, &a_Chunk](Vector3i a_Offset) { return IsWet(a_Rel + a_Offset, a_Chunk); } + ); // Early return if the sponge isn't touching any water. if (!ShouldSoak) @@ -113,7 +121,7 @@ private: { // TODO: support detecting waterlogged blocks. BLOCKTYPE Type; - return(a_Chunk.UnboundedRelGetBlockType(a_Rel.x, a_Rel.y, a_Rel.z, Type) && IsBlockWater(Type)); + return (a_Chunk.UnboundedRelGetBlockType(a_Rel.x, a_Rel.y, a_Rel.z, Type) && IsBlockWater(Type)); } virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override diff --git a/src/Blocks/BlockStairs.h b/src/Blocks/BlockStairs.h index 76614bb62..6482d005f 100644 --- a/src/Blocks/BlockStairs.h +++ b/src/Blocks/BlockStairs.h @@ -7,13 +7,12 @@ -class cBlockStairsHandler final : - public cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x03, 0x03, 0x00, 0x02, 0x01, true>> +class cBlockStairsHandler final + : public cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x03, 0x03, 0x00, 0x02, 0x01, true>> { using Super = cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x03, 0x03, 0x00, 0x02, 0x01, true>>; -public: - + public: using Super::Super; static bool IsAnyStairType(BLOCKTYPE a_Block) @@ -33,8 +32,7 @@ public: case E_BLOCK_DARK_OAK_WOOD_STAIRS: case E_BLOCK_BRICK_STAIRS: case E_BLOCK_NETHER_BRICK_STAIRS: - case E_BLOCK_SPRUCE_WOOD_STAIRS: - return true; + case E_BLOCK_SPRUCE_WOOD_STAIRS: return true; default: { return false; @@ -42,8 +40,7 @@ public: } } -private: - + private: virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) const override { // Toggle bit 3: @@ -57,19 +54,19 @@ private: switch (m_BlockType) { case E_BLOCK_SANDSTONE_STAIRS: - case E_BLOCK_BIRCH_WOOD_STAIRS: return 2; - case E_BLOCK_QUARTZ_STAIRS: return 8; + case E_BLOCK_BIRCH_WOOD_STAIRS: return 2; + case E_BLOCK_QUARTZ_STAIRS: return 8; case E_BLOCK_JUNGLE_WOOD_STAIRS: case E_BLOCK_RED_SANDSTONE_STAIRS: return 10; case E_BLOCK_COBBLESTONE_STAIRS: - case E_BLOCK_STONE_BRICK_STAIRS: return 11; - case E_BLOCK_OAK_WOOD_STAIRS: return 13; - case E_BLOCK_ACACIA_WOOD_STAIRS: return 15; - case E_BLOCK_PURPUR_STAIRS: return 16; + case E_BLOCK_STONE_BRICK_STAIRS: return 11; + case E_BLOCK_OAK_WOOD_STAIRS: return 13; + case E_BLOCK_ACACIA_WOOD_STAIRS: return 15; + case E_BLOCK_PURPUR_STAIRS: return 16; case E_BLOCK_DARK_OAK_WOOD_STAIRS: return 26; - case E_BLOCK_BRICK_STAIRS: return 28; - case E_BLOCK_NETHER_BRICK_STAIRS: return 35; - case E_BLOCK_SPRUCE_WOOD_STAIRS: return 34; + case E_BLOCK_BRICK_STAIRS: return 28; + case E_BLOCK_NETHER_BRICK_STAIRS: return 35; + case E_BLOCK_SPRUCE_WOOD_STAIRS: return 34; default: { ASSERT(!"Unhandled blocktype in stairs handler!"); @@ -82,11 +79,11 @@ private: - /** EXCEPTION a.k.a. why is this removed: - This collision-detection is actually more accurate than the client, but since the client itself - sends inaccurate / sparse data, it's easier to just err on the side of the client and keep the - two in sync by assuming that if a player hit ANY of the stair's bounding cube, it counts as the ground. */ - #if 0 +/** EXCEPTION a.k.a. why is this removed: +This collision-detection is actually more accurate than the client, but since the client itself +sends inaccurate / sparse data, it's easier to just err on the side of the client and keep the +two in sync by assuming that if a player hit ANY of the stair's bounding cube, it counts as the ground. */ +#if 0 bool IsInsideBlock(Vector3d a_RelPosition, const BLOCKTYPE a_BlockType, const NIBBLETYPE a_BlockMeta) { if (a_BlockMeta & 0x4) // upside down @@ -111,10 +108,5 @@ private: } return false; } - #endif - -} ; - - - - +#endif +}; diff --git a/src/Blocks/BlockStandingBanner.h b/src/Blocks/BlockStandingBanner.h index 391b7fde7..886bddcea 100644 --- a/src/Blocks/BlockStandingBanner.h +++ b/src/Blocks/BlockStandingBanner.h @@ -10,13 +10,11 @@ -class cBlockStandingBannerHandler final : - public cBlockEntityHandler +class cBlockStandingBannerHandler final : public cBlockEntityHandler { using Super = cBlockEntityHandler; -public: - + public: using Super::Super; virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override @@ -48,4 +46,4 @@ public: UNUSED(a_Meta); return 0; } -} ; +}; diff --git a/src/Blocks/BlockStems.h b/src/Blocks/BlockStems.h index 11cd83967..bf5a9fbf0 100644 --- a/src/Blocks/BlockStems.h +++ b/src/Blocks/BlockStems.h @@ -11,17 +11,14 @@ ProduceBlockType is the blocktype for the produce to be grown. StemPickupType is the item type for the pickup resulting from breaking the stem. */ template <BLOCKTYPE ProduceBlockType, ENUM_ITEM_TYPE StemPickupType> -class cBlockStemsHandler final : - public cBlockPlant<true> +class cBlockStemsHandler final : public cBlockPlant<true> { using Super = cBlockPlant<true>; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { /* @@ -92,27 +89,20 @@ private: auto & Random = GetRandomProvider(); // Check if there's another produce around the stem, if so, abort: - static constexpr std::array<Vector3i, 4> NeighborOfs = - { - { - { 1, 0, 0}, - {-1, 0, 0}, - { 0, 0, 1}, - { 0, 0, -1}, - } - }; + static constexpr std::array<Vector3i, 4> NeighborOfs = {{ + {1, 0, 0}, + {-1, 0, 0}, + {0, 0, 1}, + {0, 0, -1}, + }}; std::array<BLOCKTYPE, 4> BlockType; - if ( - !a_Chunk.UnboundedRelGetBlockType(a_StemRelPos + NeighborOfs[0], BlockType[0]) || + if (!a_Chunk.UnboundedRelGetBlockType(a_StemRelPos + NeighborOfs[0], BlockType[0]) || !a_Chunk.UnboundedRelGetBlockType(a_StemRelPos + NeighborOfs[1], BlockType[1]) || !a_Chunk.UnboundedRelGetBlockType(a_StemRelPos + NeighborOfs[2], BlockType[2]) || !a_Chunk.UnboundedRelGetBlockType(a_StemRelPos + NeighborOfs[3], BlockType[3]) || - (BlockType[0] == ProduceBlockType) || - (BlockType[1] == ProduceBlockType) || - (BlockType[2] == ProduceBlockType) || - (BlockType[3] == ProduceBlockType) - ) + (BlockType[0] == ProduceBlockType) || (BlockType[1] == ProduceBlockType) || + (BlockType[2] == ProduceBlockType) || (BlockType[3] == ProduceBlockType)) { // Neighbors not valid or already taken by the same produce: return; @@ -120,12 +110,13 @@ private: // Pick a direction in which to place the produce: int x = 0, z = 0; - const auto CheckType = Random.RandInt<size_t>(3); // The index to the neighbors array which should be checked for emptiness + const auto CheckType = + Random.RandInt<size_t>(3); // The index to the neighbors array which should be checked for emptiness switch (CheckType) { - case 0: x = 1; break; + case 0: x = 1; break; case 1: x = -1; break; - case 2: z = 1; break; + case 2: z = 1; break; case 3: z = -1; break; } @@ -153,11 +144,15 @@ private: case E_BLOCK_GRASS: case E_BLOCK_FARMLAND: { - const NIBBLETYPE Meta = (ProduceBlockType == E_BLOCK_MELON) ? 0 : static_cast<NIBBLETYPE>(Random.RandInt(4) % 4); + const NIBBLETYPE Meta = + (ProduceBlockType == E_BLOCK_MELON) ? 0 : static_cast<NIBBLETYPE>(Random.RandInt(4) % 4); - FLOGD("Growing melon / pumpkin at {0} (<{1}, {2}> from stem), overwriting {3}, growing on top of {4}, meta {5}", + FLOGD( + "Growing melon / pumpkin at {0} (<{1}, {2}> from stem), overwriting {3}, growing on top of {4}, " + "meta {5}", a_Chunk.RelativeToAbsolute(ProduceRelPos), - x, z, + x, + z, ItemTypeToString(BlockType[CheckType]), ItemTypeToString(SoilType), Meta @@ -169,42 +164,22 @@ private: } } -private: - + private: // https://minecraft.wiki/w/Pumpkin_Seeds#Breaking // https://minecraft.wiki/w/Melon_Seeds#Breaking - /** The array describes how many seed may be dropped at which age. The inner arrays describe the probability to drop 0, 1, 2, 3 seeds. - The outer describes the age of the stem. */ - static constexpr std::array<std::array<double, 4>, 8> m_AgeSeedDropProbability - { - { - { - 81.3, 17.42, 1.24, 0.03 - }, - { - 65.1, 30.04, 4.62, 0.24 - }, - { - 51.2, 38.4, 9.6, 0.8 - }, - { - 39.44, 43.02, 15.64, 1.9 - }, - { - 29.13, 44.44, 22.22, 3.7 - }, - { - 21.6, 43.2, 28.8, 6.4 - }, - { - 15.17, 39.82, 34.84, 10.16 - }, - { - 10.16, 34.84, 39.82, 15.17 - } - } + /** The array describes how many seed may be dropped at which age. The inner arrays describe the probability to drop + 0, 1, 2, 3 seeds. The outer describes the age of the stem. */ + static constexpr std::array<std::array<double, 4>, 8> m_AgeSeedDropProbability { + {{81.3, 17.42, 1.24, 0.03}, + {65.1, 30.04, 4.62, 0.24}, + {51.2, 38.4, 9.6, 0.8}, + {39.44, 43.02, 15.64, 1.9}, + {29.13, 44.44, 22.22, 3.7}, + {21.6, 43.2, 28.8, 6.4}, + {15.17, 39.82, 34.84, 10.16}, + {10.16, 34.84, 39.82, 15.17}} }; -} ; +}; -using cBlockMelonStemHandler = cBlockStemsHandler<E_BLOCK_MELON, E_ITEM_MELON_SEEDS>; +using cBlockMelonStemHandler = cBlockStemsHandler<E_BLOCK_MELON, E_ITEM_MELON_SEEDS>; using cBlockPumpkinStemHandler = cBlockStemsHandler<E_BLOCK_PUMPKIN, E_ITEM_PUMPKIN_SEEDS>; diff --git a/src/Blocks/BlockStone.h b/src/Blocks/BlockStone.h index 75af272b7..9b753b5e2 100644 --- a/src/Blocks/BlockStone.h +++ b/src/Blocks/BlockStone.h @@ -6,24 +6,18 @@ -class cBlockStoneHandler final : - public cBlockHandler +class cBlockStoneHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { // Convert stone to cobblestone, unless using silk-touch: - if ( - (a_BlockMeta == E_META_STONE_STONE) && - !ToolHasSilkTouch(a_Tool) - ) + if ((a_BlockMeta == E_META_STONE_STONE) && !ToolHasSilkTouch(a_Tool)) { return cItem(E_BLOCK_COBBLESTONE, 1, 0); } @@ -40,7 +34,3 @@ private: return 11; } }; - - - - diff --git a/src/Blocks/BlockSugarCane.h b/src/Blocks/BlockSugarCane.h index cffe667e5..d040b43a5 100644 --- a/src/Blocks/BlockSugarCane.h +++ b/src/Blocks/BlockSugarCane.h @@ -7,17 +7,14 @@ -class cBlockSugarCaneHandler final : - public cBlockPlant<false> +class cBlockSugarCaneHandler final : public cBlockPlant<false> { using Super = cBlockPlant<false>; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { return cItem(E_ITEM_SUGARCANE, 1, 0); @@ -41,13 +38,12 @@ private: case E_BLOCK_FARMLAND: case E_BLOCK_SAND: { - static const Vector3i Coords[] = - { - {-1, -1, 0}, - { 1, -1, 0}, - { 0, -1, -1}, - { 0, -1, 1}, - } ; + static const Vector3i Coords[] = { + {-1, -1, 0}, + {1, -1, 0}, + {0, -1, -1}, + {0, -1, 1}, + }; for (size_t i = 0; i < ARRAYCOUNT(Coords); i++) { BLOCKTYPE BlockType; @@ -91,18 +87,12 @@ private: { // Check the total height of the sugarcane blocks here: int top = a_RelPos.y + 1; - while ( - (top < cChunkDef::Height) && - (a_Chunk.GetBlock({a_RelPos.x, top, a_RelPos.z}) == E_BLOCK_SUGARCANE) - ) + while ((top < cChunkDef::Height) && (a_Chunk.GetBlock({a_RelPos.x, top, a_RelPos.z}) == E_BLOCK_SUGARCANE)) { ++top; } int bottom = a_RelPos.y - 1; - while ( - (bottom > 0) && - (a_Chunk.GetBlock({a_RelPos.x, bottom, a_RelPos.z}) == E_BLOCK_SUGARCANE) - ) + while ((bottom > 0) && (a_Chunk.GetBlock({a_RelPos.x, bottom, a_RelPos.z}) == E_BLOCK_SUGARCANE)) { --bottom; } @@ -133,8 +123,4 @@ private: } return paStay; } -} ; - - - - +}; diff --git a/src/Blocks/BlockTNT.h b/src/Blocks/BlockTNT.h index 470cfa91a..436d320bb 100644 --- a/src/Blocks/BlockTNT.h +++ b/src/Blocks/BlockTNT.h @@ -7,17 +7,14 @@ -class cBlockTNTHandler final : - public cBlockHandler +class cBlockTNTHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual void OnCancelRightClick( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, @@ -39,7 +36,3 @@ private: return 4; } }; - - - - diff --git a/src/Blocks/BlockTallGrass.h b/src/Blocks/BlockTallGrass.h index ea638c878..a98ca59b1 100644 --- a/src/Blocks/BlockTallGrass.h +++ b/src/Blocks/BlockTallGrass.h @@ -9,18 +9,22 @@ /** Handles the grass that is 1 block tall */ -class cBlockTallGrassHandler final : - public cBlockHandler +class cBlockTallGrassHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - - virtual bool DoesIgnoreBuildCollision(const cWorld & a_World, const cItem & a_HeldItem, const Vector3i a_Position, const NIBBLETYPE a_Meta, const eBlockFace a_ClickedBlockFace, const bool a_ClickedDirectly) const override + private: + virtual bool DoesIgnoreBuildCollision( + const cWorld & a_World, + const cItem & a_HeldItem, + const Vector3i a_Position, + const NIBBLETYPE a_Meta, + const eBlockFace a_ClickedBlockFace, + const bool a_ClickedDirectly + ) const override { return true; } @@ -82,7 +86,7 @@ private: case E_META_TALL_GRASS_FERN: largeFlowerMeta = E_META_BIG_FLOWER_LARGE_FERN; break; default: return 0; } - a_Chunk.SetBlock(a_RelPos, E_BLOCK_BIG_FLOWER, largeFlowerMeta); + a_Chunk.SetBlock(a_RelPos, E_BLOCK_BIG_FLOWER, largeFlowerMeta); a_Chunk.SetBlock(a_RelPos.addedY(1), E_BLOCK_BIG_FLOWER, E_META_BIG_FLOWER_TOP); return 1; } @@ -96,8 +100,4 @@ private: UNUSED(a_Meta); return 7; } -} ; - - - - +}; diff --git a/src/Blocks/BlockTorch.h b/src/Blocks/BlockTorch.h index ad69cf5eb..56ee63820 100644 --- a/src/Blocks/BlockTorch.h +++ b/src/Blocks/BlockTorch.h @@ -13,13 +13,11 @@ -class cBlockTorchBaseHandler : - public cMetaRotator<cBlockHandler, 0x7, 0x4, 0x1, 0x3, 0x2> +class cBlockTorchBaseHandler : public cMetaRotator<cBlockHandler, 0x7, 0x4, 0x1, 0x3, 0x2> { using Super = cMetaRotator<cBlockHandler, 0x7, 0x4, 0x1, 0x3, 0x2>; -public: - + public: using Super::Super; @@ -37,16 +35,11 @@ public: { switch (a_BlockFace) { - case eBlockFace::BLOCK_FACE_YP: - return (a_BlockMeta & E_BLOCK_STAIRS_UPSIDE_DOWN); - case eBlockFace::BLOCK_FACE_XP: - return ((a_BlockMeta & 0b11) == E_BLOCK_STAIRS_XP); - case eBlockFace::BLOCK_FACE_XM: - return ((a_BlockMeta & 0b11) == E_BLOCK_STAIRS_XM); - case eBlockFace::BLOCK_FACE_ZP: - return ((a_BlockMeta & 0b11) == E_BLOCK_STAIRS_ZP); - case eBlockFace::BLOCK_FACE_ZM: - return ((a_BlockMeta & 0b11) == E_BLOCK_STAIRS_ZM); + case eBlockFace::BLOCK_FACE_YP: return (a_BlockMeta & E_BLOCK_STAIRS_UPSIDE_DOWN); + case eBlockFace::BLOCK_FACE_XP: return ((a_BlockMeta & 0b11) == E_BLOCK_STAIRS_XP); + case eBlockFace::BLOCK_FACE_XM: return ((a_BlockMeta & 0b11) == E_BLOCK_STAIRS_XM); + case eBlockFace::BLOCK_FACE_ZP: return ((a_BlockMeta & 0b11) == E_BLOCK_STAIRS_ZP); + case eBlockFace::BLOCK_FACE_ZM: return ((a_BlockMeta & 0b11) == E_BLOCK_STAIRS_ZM); default: { return false; @@ -88,12 +81,10 @@ public: } } -protected: - + protected: ~cBlockTorchBaseHandler() = default; -private: - + private: /** Converts the torch block's meta to the block face of the neighbor to which the torch is attached. */ inline static eBlockFace MetaDataToBlockFace(NIBBLETYPE a_MetaData) { @@ -142,19 +133,17 @@ private: UNUSED(a_Meta); return 0; } -} ; +}; -class cBlockTorchHandler final : - public cClearMetaOnDrop<cBlockTorchBaseHandler> +class cBlockTorchHandler final : public cClearMetaOnDrop<cBlockTorchBaseHandler> { using Super = cClearMetaOnDrop<cBlockTorchBaseHandler>; -public: - + public: using Super::Super; }; @@ -162,21 +151,18 @@ public: -class cBlockRedstoneTorchHandler final : - public cBlockTorchBaseHandler +class cBlockRedstoneTorchHandler final : public cBlockTorchBaseHandler { using Super = cBlockTorchBaseHandler; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { // Always drop the ON torch, meta 0: - return { E_BLOCK_REDSTONE_TORCH_ON }; + return {E_BLOCK_REDSTONE_TORCH_ON}; } virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override diff --git a/src/Blocks/BlockTrapdoor.h b/src/Blocks/BlockTrapdoor.h index 7f6f70e1e..eb710fea1 100644 --- a/src/Blocks/BlockTrapdoor.h +++ b/src/Blocks/BlockTrapdoor.h @@ -8,21 +8,16 @@ -class cBlockTrapdoorHandler final : - public cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x03, 0x01, 0x02, 0x00, 0x03, false>> +class cBlockTrapdoorHandler final + : public cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x03, 0x01, 0x02, 0x00, 0x03, false>> { using Super = cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x03, 0x01, 0x02, 0x00, 0x03, false>>; -public: - + public: using Super::Super; -private: - - virtual bool IsUseable(void) const override - { - return true; - } + private: + virtual bool IsUseable(void) const override { return true; } @@ -46,7 +41,12 @@ private: // Flip the ON bit on / off using the XOR bitwise operation NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockPos) ^ 0x04); a_ChunkInterface.SetBlockMeta(a_BlockPos, Meta); - a_WorldInterface.GetBroadcastManager().BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_FENCE_GATE_OPEN, a_BlockPos, 0, a_Player.GetClientHandle()); + a_WorldInterface.GetBroadcastManager().BroadcastSoundParticleEffect( + EffectID::SFX_RANDOM_FENCE_GATE_OPEN, + a_BlockPos, + 0, + a_Player.GetClientHandle() + ); return true; } @@ -96,7 +96,7 @@ private: UNUSED(a_Meta); switch (m_BlockType) { - case E_BLOCK_TRAPDOOR: return 13; + case E_BLOCK_TRAPDOOR: return 13; case E_BLOCK_IRON_TRAPDOOR: return 6; default: { @@ -106,7 +106,3 @@ private: } } }; - - - - diff --git a/src/Blocks/BlockTripwire.h b/src/Blocks/BlockTripwire.h index a2c5328e4..4f78f8c0c 100644 --- a/src/Blocks/BlockTripwire.h +++ b/src/Blocks/BlockTripwire.h @@ -7,17 +7,14 @@ -class cBlockTripwireHandler final : - public cBlockHandler +class cBlockTripwireHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { return cItem(E_ITEM_STRING, 1, 0); @@ -33,7 +30,3 @@ private: return 0; } }; - - - - diff --git a/src/Blocks/BlockTripwireHook.h b/src/Blocks/BlockTripwireHook.h index ae553d66f..75f0fdd96 100644 --- a/src/Blocks/BlockTripwireHook.h +++ b/src/Blocks/BlockTripwireHook.h @@ -7,13 +7,12 @@ -class cBlockTripwireHookHandler final : - public cMetaRotator<cClearMetaOnDrop<cBlockHandler>, 0x03, 0x02, 0x03, 0x00, 0x01> +class cBlockTripwireHookHandler final + : public cMetaRotator<cClearMetaOnDrop<cBlockHandler>, 0x03, 0x02, 0x03, 0x00, 0x01> { using Super = cMetaRotator<cClearMetaOnDrop<cBlockHandler>, 0x03, 0x02, 0x03, 0x00, 0x01>; -public: - + public: using Super::Super; inline static eBlockFace MetadataToDirection(NIBBLETYPE a_Meta) @@ -24,12 +23,11 @@ public: 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; + default: ASSERT(!"Unhandled tripwire hook metadata!"); return BLOCK_FACE_NONE; } } -private: - + private: virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override { const auto RearPosition = AddFaceDirection(a_Position, MetadataToDirection(a_Meta), true); @@ -53,7 +51,3 @@ private: return 0; } }; - - - - diff --git a/src/Blocks/BlockVines.h b/src/Blocks/BlockVines.h index a23ba1489..bf4972c9c 100644 --- a/src/Blocks/BlockVines.h +++ b/src/Blocks/BlockVines.h @@ -6,17 +6,14 @@ -class cBlockVinesHandler final : - public cBlockHandler +class cBlockVinesHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: static const NIBBLETYPE VINE_LOST_SUPPORT = 16; static const NIBBLETYPE VINE_UNCHANGED = 17; @@ -95,24 +92,21 @@ private: { int x, z; NIBBLETYPE Bit; - } Coords[] = - { - { 0, 1, 1}, // south, ZP - {-1, 0, 2}, // west, XM - { 0, -1, 4}, // north, ZM - { 1, 0, 8}, // east, XP - } ; + } Coords[] = { + {0, 1, 1}, // south, ZP + {-1, 0, 2}, // west, XM + {0, -1, 4}, // north, ZM + {1, 0, 8}, // east, XP + }; NIBBLETYPE MaxMeta = 0; for (auto & Coord : Coords) { - BLOCKTYPE BlockType; + BLOCKTYPE BlockType; NIBBLETYPE BlockMeta; auto checkPos = a_Position.addedXZ(Coord.x, Coord.z); - if ( - a_Chunk.UnboundedRelGetBlock(checkPos.x, checkPos.y, checkPos.z, BlockType, BlockMeta) && - IsBlockAttachable(BlockType) - ) + if (a_Chunk.UnboundedRelGetBlock(checkPos.x, checkPos.y, checkPos.z, BlockType, BlockMeta) && + IsBlockAttachable(BlockType)) { MaxMeta |= Coord.Bit; } @@ -127,7 +121,8 @@ private: NIBBLETYPE Common = a_CurrentMeta & MaxMeta; // Neighbors that we have and are legal. if (Common != a_CurrentMeta) { - bool HasTop = (a_Position.y < (cChunkDef::Height - 1)) && IsBlockAttachable(a_Chunk.GetBlock(a_Position.addedY(1))); + bool HasTop = + (a_Position.y < (cChunkDef::Height - 1)) && IsBlockAttachable(a_Chunk.GetBlock(a_Position.addedY(1))); if ((Common == 0) && !HasTop) // Meta equals 0 also means top. Make a last-ditch attempt to save the vine. { return VINE_LOST_SUPPORT; @@ -143,41 +138,51 @@ private: - virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const override + virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) + const override { - a_ChunkInterface.DoWithChunkAt(a_BlockPos, [&](cChunk & a_Chunk) - { - - const auto Position = cChunkDef::AbsoluteToRelative(a_BlockPos); - const auto MaxMeta = GetMaxMeta(a_Chunk, Position, a_Chunk.GetMeta(Position)); - - if (MaxMeta == VINE_UNCHANGED) - { - return false; - } - - // There is a neighbor missing, need to update the meta or even destroy the block. - - if (MaxMeta == VINE_LOST_SUPPORT) - { - // The vine just lost all its support, destroy the block: - a_Chunk.SetBlock(Position, E_BLOCK_AIR, 0); - } - else - { - // It lost some of its support, set it to what remains (SetBlock to notify neighbors): - a_Chunk.SetBlock(Position, E_BLOCK_VINES, MaxMeta); - } + a_ChunkInterface.DoWithChunkAt( + a_BlockPos, + [&](cChunk & a_Chunk) + { + const auto Position = cChunkDef::AbsoluteToRelative(a_BlockPos); + const auto MaxMeta = GetMaxMeta(a_Chunk, Position, a_Chunk.GetMeta(Position)); + + if (MaxMeta == VINE_UNCHANGED) + { + return false; + } + + // There is a neighbor missing, need to update the meta or even destroy the block. + + if (MaxMeta == VINE_LOST_SUPPORT) + { + // The vine just lost all its support, destroy the block: + a_Chunk.SetBlock(Position, E_BLOCK_AIR, 0); + } + else + { + // It lost some of its support, set it to what remains (SetBlock to notify neighbors): + a_Chunk.SetBlock(Position, E_BLOCK_VINES, MaxMeta); + } - return false; - }); + return false; + } + ); } - virtual bool DoesIgnoreBuildCollision(const cWorld & a_World, const cItem & a_HeldItem, const Vector3i a_Position, const NIBBLETYPE a_Meta, const eBlockFace a_ClickedBlockFace, const bool a_ClickedDirectly) const override + virtual bool DoesIgnoreBuildCollision( + const cWorld & a_World, + const cItem & a_HeldItem, + const Vector3i a_Position, + const NIBBLETYPE a_Meta, + const eBlockFace a_ClickedBlockFace, + const bool a_ClickedDirectly + ) const override { return !a_ClickedDirectly || (a_HeldItem.m_ItemType != m_BlockType); } @@ -264,8 +269,4 @@ private: UNUSED(a_Meta); return 7; } -} ; - - - - +}; diff --git a/src/Blocks/BlockWallBanner.h b/src/Blocks/BlockWallBanner.h index e0ebb8eee..123fea5e7 100644 --- a/src/Blocks/BlockWallBanner.h +++ b/src/Blocks/BlockWallBanner.h @@ -10,13 +10,11 @@ -class cBlockWallBannerHandler final : - public cBlockEntityHandler +class cBlockWallBannerHandler final : public cBlockEntityHandler { using Super = cBlockEntityHandler; -public: - + public: using Super::Super; virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override @@ -35,11 +33,11 @@ public: switch (a_Meta) { - case BLOCK_FACE_ZM: Offset = Vector3i( 0, 0, 1); break; - case BLOCK_FACE_ZP: Offset = Vector3i( 0, 0, -1); break; - case BLOCK_FACE_XM: Offset = Vector3i( 1, 0, 0); break; - case BLOCK_FACE_XP: Offset = Vector3i(-1, 0, 0); break; - default: return false; + case BLOCK_FACE_ZM: Offset = Vector3i(0, 0, 1); break; + case BLOCK_FACE_ZP: Offset = Vector3i(0, 0, -1); break; + case BLOCK_FACE_XM: Offset = Vector3i(1, 0, 0); break; + case BLOCK_FACE_XP: Offset = Vector3i(-1, 0, 0); break; + default: return false; } auto NeighborPos = a_Position + Offset; @@ -61,4 +59,4 @@ public: UNUSED(a_Meta); return 0; } -} ; +}; diff --git a/src/Blocks/BlockWallSign.h b/src/Blocks/BlockWallSign.h index f19e408fa..728134cc0 100644 --- a/src/Blocks/BlockWallSign.h +++ b/src/Blocks/BlockWallSign.h @@ -8,17 +8,14 @@ -class cBlockWallSignHandler final : - public cBlockHandler +class cBlockWallSignHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { return cItem(E_ITEM_SIGN, 1, 0); @@ -37,23 +34,24 @@ private: // The neighbor is not accessible (unloaded chunk), bail out without changing this return true; } - return (NeighborType == E_BLOCK_WALLSIGN) || (NeighborType == E_BLOCK_SIGN_POST) || cBlockInfo::IsSolid(NeighborType); + return (NeighborType == E_BLOCK_WALLSIGN) || (NeighborType == E_BLOCK_SIGN_POST) || + cBlockInfo::IsSolid(NeighborType); } - /** Returns the offset from the sign coords to the block to which the wallsign is attached, based on the wallsign's block meta. - Asserts / returns a zero vector on wrong meta. */ + /** Returns the offset from the sign coords to the block to which the wallsign is attached, based on the wallsign's + block meta. Asserts / returns a zero vector on wrong meta. */ static Vector3i GetOffsetBehindTheSign(NIBBLETYPE a_BlockMeta) { switch (a_BlockMeta) { - case 2: return Vector3i( 0, 0, 1); - case 3: return Vector3i( 0, 0, -1); - case 4: return Vector3i( 1, 0, 0); - case 5: return Vector3i(-1, 0, 0); + case 2: return Vector3i(0, 0, 1); + case 3: return Vector3i(0, 0, -1); + case 4: return Vector3i(1, 0, 0); + case 5: return Vector3i(-1, 0, 0); } ASSERT(!"Invalid wallsign block meta"); return Vector3i(); @@ -68,8 +66,4 @@ private: UNUSED(a_Meta); return 13; } -} ; - - - - +}; diff --git a/src/Blocks/BlockWorkbench.h b/src/Blocks/BlockWorkbench.h index a0ec3df4a..ebcd989ae 100644 --- a/src/Blocks/BlockWorkbench.h +++ b/src/Blocks/BlockWorkbench.h @@ -9,17 +9,14 @@ -class cBlockWorkbenchHandler final : - public cBlockHandler +class cBlockWorkbenchHandler final : public cBlockHandler { using Super = cBlockHandler; -public: - + public: using Super::Super; -private: - + private: virtual bool OnUse( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, @@ -40,10 +37,7 @@ private: - virtual bool IsUseable(void) const override - { - return true; - } + virtual bool IsUseable(void) const override { return true; } @@ -54,8 +48,4 @@ private: UNUSED(a_Meta); return 13; } -} ; - - - - +}; diff --git a/src/Blocks/BroadcastInterface.h b/src/Blocks/BroadcastInterface.h index 6c52a5156..d7c17b564 100644 --- a/src/Blocks/BroadcastInterface.h +++ b/src/Blocks/BroadcastInterface.h @@ -15,53 +15,133 @@ enum class EffectID : Int32; class cBroadcastInterface { -public: + public: virtual ~cBroadcastInterface() {} // Broadcast respective packets to all clients of the chunk where the event is taking place // (Please keep these alpha-sorted) - virtual void BroadcastAttachEntity (const cEntity & a_Entity, const cEntity & a_Vehicle) = 0; - virtual void BroadcastBlockAction (Vector3i a_BlockPos, Byte a_Byte1, Byte a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastBlockBreakAnimation (UInt32 a_EntityID, Vector3i a_BlockPos, Int8 a_Stage, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastBlockEntity (Vector3i a_BlockPos, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastBossBarUpdateHealth (const cEntity & a_Entity, UInt32 a_UniqueID, float a_FractionFilled) = 0; - virtual void BroadcastChat (const AString & a_Message, const cClientHandle * a_Exclude = nullptr, eMessageType a_ChatPrefix = mtCustom) = 0; - virtual void BroadcastChatInfo (const AString & a_Message, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastChatFailure (const AString & a_Message, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastChatSuccess (const AString & a_Message, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastChatWarning (const AString & a_Message, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastChatFatal (const AString & a_Message, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastChatDeath (const AString & a_Message, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastChat (const cCompositeChat & a_Message, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastCollectEntity (const cEntity & a_Collected, const cEntity & a_Collector, unsigned a_Count, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastDetachEntity (const cEntity & a_Entity, const cEntity & a_PreviousVehicle) = 0; - virtual void BroadcastEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, int a_Duration, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastEntityHeadLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastEntityLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastEntityMetadata (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastEntityPosition (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastEntityVelocity (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastEntityAnimation (const cEntity & a_Entity, EntityAnimation a_Animation, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastLeashEntity (const cEntity & a_Entity, const cEntity & a_EntityLeashedTo) = 0; - virtual void BroadcastParticleEffect (const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastParticleEffect (const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastPlayerListAddPlayer (const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastPlayerListHeaderFooter (const cCompositeChat & a_Header, const cCompositeChat & a_Footer) = 0; - virtual void BroadcastPlayerListRemovePlayer (const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastPlayerListUpdateGameMode (const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastPlayerListUpdatePing () = 0; - virtual void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) = 0; - virtual void BroadcastScoreUpdate (const AString & a_Objective, const AString & a_PlayerName, cObjective::Score a_Score, Byte a_Mode) = 0; - virtual void BroadcastDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display) = 0; - virtual void BroadcastSoundEffect (const AString & a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastSoundParticleEffect (const EffectID a_EffectID, Vector3i a_SrcPos, int a_Data, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastSpawnEntity (cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastThunderbolt (Vector3i a_BlockPos, const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastTimeUpdate (const cClientHandle * a_Exclude = nullptr) = 0; - virtual void BroadcastUnleashEntity (const cEntity & a_Entity) = 0; - virtual void BroadcastWeather (eWeather a_Weather, const cClientHandle * a_Exclude = nullptr) = 0; + virtual void BroadcastAttachEntity(const cEntity & a_Entity, const cEntity & a_Vehicle) = 0; + virtual void BroadcastBlockAction( + Vector3i a_BlockPos, + Byte a_Byte1, + Byte a_Byte2, + BLOCKTYPE a_BlockType, + const cClientHandle * a_Exclude = nullptr + ) = 0; + virtual void BroadcastBlockBreakAnimation( + UInt32 a_EntityID, + Vector3i a_BlockPos, + Int8 a_Stage, + const cClientHandle * a_Exclude = nullptr + ) = 0; + virtual void BroadcastBlockEntity(Vector3i a_BlockPos, const cClientHandle * a_Exclude = nullptr) = 0; + virtual void BroadcastBossBarUpdateHealth(const cEntity & a_Entity, UInt32 a_UniqueID, float a_FractionFilled) = 0; + virtual void BroadcastChat( + const AString & a_Message, + const cClientHandle * a_Exclude = nullptr, + eMessageType a_ChatPrefix = mtCustom + ) = 0; + virtual void BroadcastChatInfo(const AString & a_Message, const cClientHandle * a_Exclude = nullptr) = 0; + virtual void BroadcastChatFailure(const AString & a_Message, const cClientHandle * a_Exclude = nullptr) = 0; + virtual void BroadcastChatSuccess(const AString & a_Message, const cClientHandle * a_Exclude = nullptr) = 0; + virtual void BroadcastChatWarning(const AString & a_Message, const cClientHandle * a_Exclude = nullptr) = 0; + virtual void BroadcastChatFatal(const AString & a_Message, const cClientHandle * a_Exclude = nullptr) = 0; + virtual void BroadcastChatDeath(const AString & a_Message, const cClientHandle * a_Exclude = nullptr) = 0; + virtual void BroadcastChat(const cCompositeChat & a_Message, const cClientHandle * a_Exclude = nullptr) = 0; + virtual void BroadcastCollectEntity( + const cEntity & a_Collected, + const cEntity & a_Collector, + unsigned a_Count, + const cClientHandle * a_Exclude = nullptr + ) = 0; + virtual void BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr) = 0; + virtual void BroadcastDetachEntity(const cEntity & a_Entity, const cEntity & a_PreviousVehicle) = 0; + virtual void BroadcastEntityEffect( + const cEntity & a_Entity, + int a_EffectID, + int a_Amplifier, + int a_Duration, + const cClientHandle * a_Exclude = nullptr + ) = 0; + virtual void BroadcastEntityEquipment( + const cEntity & a_Entity, + short a_SlotNum, + const cItem & a_Item, + const cClientHandle * a_Exclude = nullptr + ) = 0; + virtual void BroadcastEntityHeadLook(const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr) = 0; + virtual void BroadcastEntityLook(const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr) = 0; + virtual void BroadcastEntityMetadata(const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr) = 0; + virtual void BroadcastEntityPosition(const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr) = 0; + virtual void BroadcastEntityVelocity(const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr) = 0; + virtual void BroadcastEntityAnimation( + const cEntity & a_Entity, + EntityAnimation a_Animation, + const cClientHandle * a_Exclude = nullptr + ) = 0; + virtual void BroadcastLeashEntity(const cEntity & a_Entity, const cEntity & a_EntityLeashedTo) = 0; + virtual void BroadcastParticleEffect( + const AString & a_ParticleName, + Vector3f a_Src, + Vector3f a_Offset, + float a_ParticleData, + int a_ParticleAmount, + const cClientHandle * a_Exclude = nullptr + ) = 0; + virtual void BroadcastParticleEffect( + const AString & a_ParticleName, + Vector3f a_Src, + Vector3f a_Offset, + float a_ParticleData, + int a_ParticleAmount, + std::array<int, 2> a_Data, + const cClientHandle * a_Exclude = nullptr + ) = 0; + virtual void BroadcastPlayerListAddPlayer(const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr) = 0; + virtual void BroadcastPlayerListHeaderFooter(const cCompositeChat & a_Header, const cCompositeChat & a_Footer) = 0; + virtual void BroadcastPlayerListRemovePlayer( + const cPlayer & a_Player, + const cClientHandle * a_Exclude = nullptr + ) = 0; + virtual void BroadcastPlayerListUpdateDisplayName( + const cPlayer & a_Player, + const AString & a_CustomName, + const cClientHandle * a_Exclude = nullptr + ) = 0; + virtual void BroadcastPlayerListUpdateGameMode( + const cPlayer & a_Player, + const cClientHandle * a_Exclude = nullptr + ) = 0; + virtual void BroadcastPlayerListUpdatePing() = 0; + virtual void BroadcastRemoveEntityEffect( + const cEntity & a_Entity, + int a_EffectID, + const cClientHandle * a_Exclude = nullptr + ) = 0; + virtual void BroadcastScoreboardObjective(const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) = 0; + virtual void BroadcastScoreUpdate( + const AString & a_Objective, + const AString & a_PlayerName, + cObjective::Score a_Score, + Byte a_Mode + ) = 0; + virtual void BroadcastDisplayObjective(const AString & a_Objective, cScoreboard::eDisplaySlot a_Display) = 0; + virtual void BroadcastSoundEffect( + const AString & a_SoundName, + Vector3d a_Position, + float a_Volume, + float a_Pitch, + const cClientHandle * a_Exclude = nullptr + ) = 0; + virtual void BroadcastSoundParticleEffect( + const EffectID a_EffectID, + Vector3i a_SrcPos, + int a_Data, + const cClientHandle * a_Exclude = nullptr + ) = 0; + virtual void BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr) = 0; + virtual void BroadcastThunderbolt(Vector3i a_BlockPos, const cClientHandle * a_Exclude = nullptr) = 0; + virtual void BroadcastTimeUpdate(const cClientHandle * a_Exclude = nullptr) = 0; + virtual void BroadcastUnleashEntity(const cEntity & a_Entity) = 0; + virtual void BroadcastWeather(eWeather a_Weather, const cClientHandle * a_Exclude = nullptr) = 0; }; diff --git a/src/Blocks/ChunkInterface.cpp b/src/Blocks/ChunkInterface.cpp index 37ed70615..887598042 100644 --- a/src/Blocks/ChunkInterface.cpp +++ b/src/Blocks/ChunkInterface.cpp @@ -83,7 +83,13 @@ bool cChunkInterface::UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_Blo -bool cChunkInterface::ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback) +bool cChunkInterface::ForEachChunkInRect( + int a_MinChunkX, + int a_MaxChunkX, + int a_MinChunkZ, + int a_MaxChunkZ, + cChunkDataCallback & a_Callback +) { return m_ChunkMap->ForEachChunkInRect(a_MinChunkX, a_MaxChunkX, a_MinChunkZ, a_MaxChunkZ, a_Callback); } @@ -92,7 +98,13 @@ bool cChunkInterface::ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a -bool cChunkInterface::WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) +bool cChunkInterface::WriteBlockArea( + cBlockArea & a_Area, + int a_MinBlockX, + int a_MinBlockY, + int a_MinBlockZ, + int a_DataTypes +) { return m_ChunkMap->WriteBlockArea(a_Area, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_DataTypes); } diff --git a/src/Blocks/ChunkInterface.h b/src/Blocks/ChunkInterface.h index a8fcd6187..492390066 100644 --- a/src/Blocks/ChunkInterface.h +++ b/src/Blocks/ChunkInterface.h @@ -18,12 +18,13 @@ class cPlayer; -class cChunkInterface: - public cForEachChunkProvider +class cChunkInterface : public cForEachChunkProvider { -public: - - cChunkInterface(cChunkMap * a_ChunkMap) : m_ChunkMap(a_ChunkMap) {} + public: + cChunkInterface(cChunkMap * a_ChunkMap) : + m_ChunkMap(a_ChunkMap) + { + } bool DoWithChunkAt(Vector3i a_BlockPos, cFunctionRef<bool(cChunk &)> a_Callback); @@ -65,9 +66,16 @@ public: returns true if the use was successful, return false to use the block as a "normal" block */ bool UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ); - virtual bool ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback) override; + virtual bool ForEachChunkInRect( + int a_MinChunkX, + int a_MaxChunkX, + int a_MinChunkZ, + int a_MaxChunkZ, + cChunkDataCallback & a_Callback + ) override; - virtual bool WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) override; + virtual bool WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) + override; bool DigBlock(cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, cEntity * a_Digger); @@ -75,10 +83,6 @@ public: void DropBlockAsPickups(Vector3i a_BlockPos, const cEntity * a_Digger = nullptr, const cItem * a_Tool = nullptr); -private: + private: cChunkMap * m_ChunkMap; }; - - - - diff --git a/src/Blocks/GetHandlerCompileTimeTemplate.h b/src/Blocks/GetHandlerCompileTimeTemplate.h index deebd4030..519c60018 100644 --- a/src/Blocks/GetHandlerCompileTimeTemplate.h +++ b/src/Blocks/GetHandlerCompileTimeTemplate.h @@ -12,17 +12,15 @@ class cBlockPistonHandler; -template<BLOCKTYPE T> -class GetHandlerCompileTime; +template <BLOCKTYPE T> class GetHandlerCompileTime; -template<> -class GetHandlerCompileTime<E_BLOCK_TORCH> +template <> class GetHandlerCompileTime<E_BLOCK_TORCH> { -public: + public: typedef cBlockTorchHandler type; }; @@ -30,10 +28,9 @@ public: -template<> -class GetHandlerCompileTime<E_BLOCK_LEVER> +template <> class GetHandlerCompileTime<E_BLOCK_LEVER> { -public: + public: typedef cBlockLeverHandler type; }; @@ -41,10 +38,9 @@ public: -template<> -class GetHandlerCompileTime<E_BLOCK_STONE_BUTTON> +template <> class GetHandlerCompileTime<E_BLOCK_STONE_BUTTON> { -public: + public: typedef cBlockButtonHandler type; }; @@ -52,10 +48,9 @@ public: -template<> -class GetHandlerCompileTime<E_BLOCK_TRIPWIRE_HOOK> +template <> class GetHandlerCompileTime<E_BLOCK_TRIPWIRE_HOOK> { -public: + public: typedef cBlockTripwireHookHandler type; }; @@ -63,10 +58,9 @@ public: -template<> -class GetHandlerCompileTime<E_BLOCK_WOODEN_DOOR> +template <> class GetHandlerCompileTime<E_BLOCK_WOODEN_DOOR> { -public: + public: typedef cBlockDoorHandler type; }; @@ -74,10 +68,8 @@ public: -template<> -class GetHandlerCompileTime<E_BLOCK_PISTON> +template <> class GetHandlerCompileTime<E_BLOCK_PISTON> { -public: + public: typedef cBlockPistonHandler type; }; - diff --git a/src/Blocks/Mixins.h b/src/Blocks/Mixins.h index fa8985737..955957c72 100644 --- a/src/Blocks/Mixins.h +++ b/src/Blocks/Mixins.h @@ -17,7 +17,7 @@ class cBlockLadder: public cMetaRotator<cClearMetaOnDrop, ...> // MSVC generates warnings for the templated AssertIfNotMatched parameter conditions, so disable it: #ifdef _MSC_VER - #pragma warning(disable: 4127) // Conditional expression is constant +#pragma warning(disable : 4127) // Conditional expression is constant #endif @@ -25,23 +25,18 @@ class cBlockLadder: public cMetaRotator<cClearMetaOnDrop, ...> /** Mixin to clear the block's meta value when converting to a pickup. */ -template <class Base> -class cClearMetaOnDrop : - public Base +template <class Base> class cClearMetaOnDrop : public Base { -public: - - constexpr cClearMetaOnDrop(BLOCKTYPE a_BlockType): + public: + constexpr cClearMetaOnDrop(BLOCKTYPE a_BlockType) : Base(a_BlockType) { } -protected: - + protected: ~cClearMetaOnDrop() = default; -private: - + private: virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { // Reset the meta to zero: @@ -54,21 +49,26 @@ private: /** Mixin for rotations and reflections following the standard pattern of "apply mask, then use a switch". -Inherit from this class providing your base class as Base, the BitMask for the direction bits in bitmask and the masked value for the directions in North, East, South, West. -There is also an aptional parameter AssertIfNotMatched, set this if it is invalid for a block to exist in any other state. */ -template <class Base, NIBBLETYPE BitMask, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched = false> -class cMetaRotator : - public Base +Inherit from this class providing your base class as Base, the BitMask for the direction bits in bitmask and the masked +value for the directions in North, East, South, West. There is also an aptional parameter AssertIfNotMatched, set this +if it is invalid for a block to exist in any other state. */ +template < + class Base, + NIBBLETYPE BitMask, + NIBBLETYPE North, + NIBBLETYPE East, + NIBBLETYPE South, + NIBBLETYPE West, + bool AssertIfNotMatched = false> +class cMetaRotator : public Base { -public: - - constexpr cMetaRotator(BLOCKTYPE a_BlockType): + public: + constexpr cMetaRotator(BLOCKTYPE a_BlockType) : Base(a_BlockType) { } -protected: - + protected: ~cMetaRotator() = default; virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) const override @@ -76,9 +76,9 @@ protected: NIBBLETYPE OtherMeta = a_Meta & (~BitMask); switch (a_Meta & BitMask) { - case South: return East | OtherMeta; + case South: return East | OtherMeta; case East: return North | OtherMeta; - case North: return West | OtherMeta; + case North: return West | OtherMeta; case West: return South | OtherMeta; } if (AssertIfNotMatched) @@ -97,9 +97,9 @@ protected: NIBBLETYPE OtherMeta = a_Meta & (~BitMask); switch (a_Meta & BitMask) { - case South: return West | OtherMeta; + case South: return West | OtherMeta; case West: return North | OtherMeta; - case North: return East | OtherMeta; + case North: return East | OtherMeta; case East: return South | OtherMeta; } if (AssertIfNotMatched) @@ -155,15 +155,12 @@ template < NIBBLETYPE East = 0x05, NIBBLETYPE South = 0x03, NIBBLETYPE West = 0x04, - bool AssertIfNotMatched = false -> -class cYawRotator : - public cMetaRotator<Base, BitMask, North, East, South, West, AssertIfNotMatched> + bool AssertIfNotMatched = false> +class cYawRotator : public cMetaRotator<Base, BitMask, North, East, South, West, AssertIfNotMatched> { using Super = cMetaRotator<Base, BitMask, North, East, South, West, AssertIfNotMatched>; -public: - + public: using Super::Super; @@ -189,8 +186,7 @@ public: } } -protected: - + protected: ~cYawRotator() = default; }; @@ -208,26 +204,26 @@ template < NIBBLETYPE South = 0x03, NIBBLETYPE West = 0x04, NIBBLETYPE Up = 0x00, - NIBBLETYPE Down = 0x01 -> -class cDisplacementYawRotator: - public cYawRotator<Base, BitMask, North, East, South, West> + NIBBLETYPE Down = 0x01> +class cDisplacementYawRotator : public cYawRotator<Base, BitMask, North, East, South, West> { using Super = cYawRotator<Base, BitMask, North, East, South, West>; -public: - + public: using Super::Super; /** Converts the placement position, eye position as returned by cPlayer::GetEyePosition(), and - rotation value as returned by cPlayer::GetYaw() to the appropriate metadata value for a block placed by a player facing that way. */ - static NIBBLETYPE DisplacementYawToMetaData(const Vector3d a_PlacePosition, const Vector3d a_EyePosition, const double a_Rotation) + rotation value as returned by cPlayer::GetYaw() to the appropriate metadata value for a block placed by a player + facing that way. */ + static NIBBLETYPE DisplacementYawToMetaData( + const Vector3d a_PlacePosition, + const Vector3d a_EyePosition, + const double a_Rotation + ) { - if ( - const auto Displacement = a_EyePosition - a_PlacePosition.addedXZ(0.5, 0.5); - (std::abs(Displacement.x) < 2) && (std::abs(Displacement.z) < 2) - ) + if (const auto Displacement = a_EyePosition - a_PlacePosition.addedXZ(0.5, 0.5); + (std::abs(Displacement.x) < 2) && (std::abs(Displacement.z) < 2)) { if (Displacement.y > 2) { @@ -243,8 +239,7 @@ public: return Super::YawToMetaData(a_Rotation); } -protected: - + protected: ~cDisplacementYawRotator() = default; @@ -254,7 +249,7 @@ protected: switch (a_Meta & BitMask) { case Down: return Up | OtherMeta; // Down -> Up - case Up: return Down | OtherMeta; // Up -> Down + case Up: return Down | OtherMeta; // Up -> Down } // Not Facing Up or Down; No change. return a_Meta; diff --git a/src/Blocks/WorldInterface.h b/src/Blocks/WorldInterface.h index b3fc9878d..404a75407 100644 --- a/src/Blocks/WorldInterface.h +++ b/src/Blocks/WorldInterface.h @@ -10,36 +10,72 @@ class cItems; class cPlayer; using cBlockEntityCallback = cFunctionRef<bool(cBlockEntity &)>; -using cPlayerListCallback = cFunctionRef<bool(cPlayer &)>; -using cEntityCallback = cFunctionRef<bool(cEntity &)>; +using cPlayerListCallback = cFunctionRef<bool(cPlayer &)>; +using cEntityCallback = cFunctionRef<bool(cEntity &)>; class cWorldInterface { -public: + public: virtual ~cWorldInterface() {} virtual cTickTime GetTimeOfDay(void) const = 0; - virtual cTickTimeLong GetWorldAge(void) const = 0; + virtual cTickTimeLong GetWorldAge(void) const = 0; virtual eDimension GetDimension(void) const = 0; virtual cBroadcastInterface & GetBroadcastManager() = 0; - virtual void DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_BlockY, double a_BlockZ, bool a_CanCauseFire, eExplosionSource a_Source, void * a_SourceData) = 0; - - /** Calls the callback for the block entity at the specified coords; returns false if there's no block entity at those coords, true if found */ + virtual void DoExplosionAt( + double a_ExplosionSize, + double a_BlockX, + double a_BlockY, + double a_BlockZ, + bool a_CanCauseFire, + eExplosionSource a_Source, + void * a_SourceData + ) = 0; + + /** Calls the callback for the block entity at the specified coords; returns false if there's no block entity at + * those coords, true if found */ virtual bool DoWithBlockEntityAt(Vector3i a_Position, cBlockEntityCallback a_Callback) = 0; /** Spawns item pickups for each item in the list. May compress pickups if too many entities: */ - virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed = 1.0, bool IsPlayerCreated = false) = 0; - - /** Spawns item pickups for each item in the list. May compress pickups if too many entities. All pickups get the speed specified. */ - virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ, bool IsPlayerCreated = false) = 0; - - virtual UInt32 SpawnItemPickup(double a_PosX, double a_PosY, double a_PosZ, const cItem & a_Item, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f, int a_LifetimeTicks = 6000, bool a_CanCombine = true) = 0; + virtual void SpawnItemPickups( + const cItems & a_Pickups, + double a_BlockX, + double a_BlockY, + double a_BlockZ, + double a_FlyAwaySpeed = 1.0, + bool IsPlayerCreated = false + ) = 0; + + /** Spawns item pickups for each item in the list. May compress pickups if too many entities. All pickups get the + * speed specified. */ + virtual void SpawnItemPickups( + const cItems & a_Pickups, + double a_BlockX, + double a_BlockY, + double a_BlockZ, + double a_SpeedX, + double a_SpeedY, + double a_SpeedZ, + bool IsPlayerCreated = false + ) = 0; + + virtual UInt32 SpawnItemPickup( + double a_PosX, + double a_PosY, + double a_PosZ, + const cItem & a_Item, + float a_SpeedX = 0.f, + float a_SpeedY = 0.f, + float a_SpeedZ = 0.f, + int a_LifetimeTicks = 6000, + bool a_CanCombine = true + ) = 0; /** Spawns a mob of the specified type. Returns the mob's UniqueID if recognized and spawned, or cEntity::INVALID_ID on failure. */ @@ -49,8 +85,8 @@ public: Returns the UniqueID of the spawned experience orb, or cEntity::INVALID_ID on failure. */ virtual UInt32 SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward) = 0; - /** Spawns experience orbs of the specified total value at the given location. The orbs' values are split according to regular Minecraft rules. - Returns an vector of UniqueID of all the orbs. */ + /** Spawns experience orbs of the specified total value at the given location. The orbs' values are split according + to regular Minecraft rules. Returns an vector of UniqueID of all the orbs. */ virtual std::vector<UInt32> SpawnSplitExperienceOrbs(Vector3d a_Pos, int a_Reward) = 0; /** Sends the block on those coords to the player */ @@ -62,7 +98,8 @@ public: SendBlockTo(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_Player); } - /** Calls the callback for each player in the list; returns true if all players processed, false if the callback aborted by returning true */ + /** Calls the callback for each player in the list; returns true if all players processed, false if the callback + * aborted by returning true */ virtual bool ForEachPlayer(cPlayerListCallback a_Callback) = 0; /** Calls the callback for each entity that has a nonempty intersection with the specified boundingbox. @@ -96,5 +133,4 @@ public: /** Wakes up the simulators for the specified block */ virtual void WakeUpSimulators(Vector3i a_Block) = 0; - }; |