From 0f8c24e04d60aa1642a5fe7346941ccd7697977e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 17 Jul 2014 22:26:53 +0100 Subject: Fixed issues relating to saplings and leaves - Removed cBlockInfo::RequiresSpecialTool * Fixes #1195 * Fixes #1201 --- src/Blocks/BlockBigFlower.h | 6 +++--- src/Blocks/BlockHandler.cpp | 46 +++++++++++---------------------------------- src/Blocks/BlockHandler.h | 10 +++++----- src/Blocks/BlockLeaves.h | 10 ++++++++-- src/Blocks/BlockSapling.h | 4 ++-- 5 files changed, 29 insertions(+), 47 deletions(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockBigFlower.h b/src/Blocks/BlockBigFlower.h index 39fd3cac8..0ba997a68 100644 --- a/src/Blocks/BlockBigFlower.h +++ b/src/Blocks/BlockBigFlower.h @@ -19,16 +19,16 @@ public: } - virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ) override + virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim) override { NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); if (Meta & 0x8) { - super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY - 1, a_BlockZ); + super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY - 1, a_BlockZ, a_DropVerbatim); } else { - super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY, a_BlockZ); + super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_DropVerbatim); } } diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index cef1f5f09..233070b14 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -407,39 +407,6 @@ void cBlockHandler::NeighborChanged(cChunkInterface & a_ChunkInterface, int a_Bl - -void cBlockHandler::OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) -{ -} - - - - - -void cBlockHandler::OnDigging(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) -{ -} - - - - - -void cBlockHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) -{ -} - - - - - -void cBlockHandler::OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) -{ -} - - - - - void cBlockHandler::ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) { // Setting the meta to a_BlockMeta keeps most textures. The few other blocks have to override this. @@ -450,11 +417,20 @@ void cBlockHandler::ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) -void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ) +void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim) { cItems Pickups; NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - ConvertToPickups(Pickups, Meta); + + if (!a_DropVerbatim) + { + ConvertToPickups(Pickups, Meta); + } + else + { + // TODO: Add a proper overridable function for this + Pickups.Add(m_BlockType, 1, Meta); + } // Allow plugins to modify the pickups: a_BlockPluginInterface.CallHookBlockToPickups(a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Pickups); diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index fb6cae729..ee4d4a6fe 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -60,25 +60,25 @@ public: virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ); /// Called when a direct neighbor of this block has been changed (The position is the own position, not the neighbor position) - virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ); + virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) {}; /// Notifies all neighbors of the given block about a change static void NeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ); /// Called while the player diggs the block. - virtual void OnDigging(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ); + virtual void OnDigging(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) {}; /// Called if the user right clicks the block and the block is useable - virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ); + virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) {}; /** Called when a Right Click to this Block is cancelled */ - virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace); + virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) {}; /// Called when the item is mined to convert it into pickups. Pickups may specify multiple items. Appends items to a_Pickups, preserves its original contents virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta); /// Handles the dropping of a block based on what ConvertToDrops() returns. This will not destroy the block. a_Digger is the entity causing the drop; it may be NULL - virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ); + virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim = false); /// Returns step sound name of block virtual const char * GetStepSound(void); diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h index 495e849fa..67c4535b8 100644 --- a/src/Blocks/BlockLeaves.h +++ b/src/Blocks/BlockLeaves.h @@ -43,11 +43,17 @@ public: // Only the first 2 bits contain the display information, the others are for growing if (rand.NextInt(6) == 0) { - a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 3)); + a_Pickups.push_back( + cItem( + E_BLOCK_SAPLING, + 1, + (m_BlockType == E_BLOCK_LEAVES) ? (a_BlockMeta & 0x03) : (2 << (a_BlockMeta & 0x01)) // Old leaves - 3 bits contain display; new leaves - 1st bit, shifted left two for saplings to understand + ) + ); } // 1 % chance of dropping an apple, if the leaves' type is Apple Leaves - if ((a_BlockMeta & 3) == E_META_LEAVES_APPLE) + if ((m_BlockType == E_BLOCK_LEAVES) && ((a_BlockMeta & 0x03) == E_META_LEAVES_APPLE)) { if (rand.NextInt(101) == 0) { diff --git a/src/Blocks/BlockSapling.h b/src/Blocks/BlockSapling.h index 3d925029a..e965809a3 100644 --- a/src/Blocks/BlockSapling.h +++ b/src/Blocks/BlockSapling.h @@ -20,8 +20,8 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - // Only the first 2 bits contain the display information, the others are for growing - a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 3)); + // Only the first 5 bits contain the display information, 8th bit for growth indicator (but we use 0x07 for forward compatibility) + a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 0x07)); } -- cgit v1.2.3 From eeacb6f2223f88a64ce877458c58fa60194e45a6 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 02:19:30 +0200 Subject: Added a extra wall sign handler. Fixes #1119 --- src/Blocks/BlockHandler.cpp | 7 +-- src/Blocks/BlockSign.h | 109 -------------------------------------------- src/Blocks/BlockSignPost.h | 103 +++++++++++++++++++++++++++++++++++++++++ src/Blocks/BlockWallSign.h | 62 +++++++++++++++++++++++++ 4 files changed, 169 insertions(+), 112 deletions(-) delete mode 100644 src/Blocks/BlockSign.h create mode 100644 src/Blocks/BlockSignPost.h create mode 100644 src/Blocks/BlockWallSign.h (limited to 'src/Blocks') diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 97762f9bd..8ab4116f4 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -70,7 +70,7 @@ #include "BlockSand.h" #include "BlockSapling.h" #include "BlockSideways.h" -#include "BlockSign.h" +#include "BlockSignPost.h" #include "BlockSlab.h" #include "BlockSnow.h" #include "BlockStairs.h" @@ -81,6 +81,7 @@ #include "BlockTorch.h" #include "BlockTrapdoor.h" #include "BlockVine.h" +#include "BlockWallSign.h" #include "BlockWorkbench.h" @@ -275,7 +276,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_SAND: return new cBlockSandHandler (a_BlockType); case E_BLOCK_SANDSTONE_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_SAPLING: return new cBlockSaplingHandler (a_BlockType); - case E_BLOCK_SIGN_POST: return new cBlockSignHandler (a_BlockType); + case E_BLOCK_SIGN_POST: return new cBlockSignPostHandler (a_BlockType); case E_BLOCK_SNOW: return new cBlockSnowHandler (a_BlockType); case E_BLOCK_SPRUCE_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_STAINED_GLASS: return new cBlockGlassHandler (a_BlockType); @@ -297,7 +298,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_TRIPWIRE: return new cBlockTripwireHandler (a_BlockType); case E_BLOCK_TRIPWIRE_HOOK: return new cBlockTripwireHookHandler (a_BlockType); case E_BLOCK_VINES: return new cBlockVineHandler (a_BlockType); - case E_BLOCK_WALLSIGN: return new cBlockSignHandler (a_BlockType); // TODO: This needs a special handler + case E_BLOCK_WALLSIGN: return new cBlockWallSignHandler (a_BlockType); case E_BLOCK_WATER: return new cBlockFluidHandler (a_BlockType); case E_BLOCK_WOODEN_BUTTON: return new cBlockButtonHandler (a_BlockType); case E_BLOCK_WOODEN_DOOR: return new cBlockDoorHandler (a_BlockType); diff --git a/src/Blocks/BlockSign.h b/src/Blocks/BlockSign.h deleted file mode 100644 index 5aa8ade3d..000000000 --- a/src/Blocks/BlockSign.h +++ /dev/null @@ -1,109 +0,0 @@ - -#pragma once - -#include "BlockHandler.h" -#include "../Entities/Player.h" -#include "Chunk.h" - - - - - -class cBlockSignHandler : - public cBlockHandler -{ -public: - cBlockSignHandler(BLOCKTYPE a_BlockType) - : cBlockHandler(a_BlockType) - { - } - - - virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override - { - a_Pickups.push_back(cItem(E_ITEM_SIGN, 1, 0)); - } - - - virtual const char * GetStepSound(void) override - { - return "step.wood"; - } - - - static NIBBLETYPE RotationToMetaData(double a_Rotation) - { - a_Rotation += 180 + (180 / 16); // So it's not aligned with axis - if (a_Rotation > 360) - { - a_Rotation -= 360; - } - - a_Rotation = (a_Rotation / 360) * 16; - - return ((char)a_Rotation) % 16; - } - - - static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction) - { - switch (a_Direction) - { - case 0x2: return 0x2; - case 0x3: return 0x3; - case 0x4: return 0x4; - case 0x5: return 0x5; - default: - { - break; - } - } - return 0x2; - } - - - virtual void OnPlacedByPlayer( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, - int a_CursorX, int a_CursorY, int a_CursorZ, - BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta - ) override - { - a_Player->GetClientHandle()->SendEditSign(a_BlockX, a_BlockY, a_BlockZ); - } - - - virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override - { - return (a_Meta + 4) & 0x0f; - } - - - virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override - { - return (a_Meta + 12) & 0x0f; - } - - virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override - { - // Mirrors signs over the XY plane (North-South Mirroring) - - // There are 16 meta values which correspond to different directions. - // These values are equated to angles on a circle; 0x08 = 180 degrees. - return (a_Meta < 0x08) ? (0x08 + a_Meta) : (0x08 - a_Meta); - } - - - virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override - { - // Mirrors signs over the YZ plane (East-West Mirroring) - - // There are 16 meta values which correspond to different directions. - // These values are equated to angles on a circle; 0x10 = 360 degrees. - return 0x10 - a_Meta; - } -} ; - - - - diff --git a/src/Blocks/BlockSignPost.h b/src/Blocks/BlockSignPost.h new file mode 100644 index 000000000..d5b0c0b5f --- /dev/null +++ b/src/Blocks/BlockSignPost.h @@ -0,0 +1,103 @@ + +#pragma once + +#include "BlockHandler.h" +#include "../Entities/Player.h" +#include "Chunk.h" + + + + + +class cBlockSignPostHandler : + public cBlockHandler +{ +public: + cBlockSignPostHandler(BLOCKTYPE a_BlockType) + : cBlockHandler(a_BlockType) + { + } + + + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + a_Pickups.push_back(cItem(E_ITEM_SIGN, 1, 0)); + } + + + virtual const char * GetStepSound(void) override + { + return "step.wood"; + } + + + virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override + { + if (a_RelY <= 0) + { + return false; + } + + return (cBlockInfo::IsSolid(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ))); + } + + + static NIBBLETYPE RotationToMetaData(double a_Rotation) + { + a_Rotation += 180 + (180 / 16); // So it's not aligned with axis + if (a_Rotation > 360) + { + a_Rotation -= 360; + } + + a_Rotation = (a_Rotation / 360) * 16; + + return ((char)a_Rotation) % 16; + } + + + virtual void OnPlacedByPlayer( + cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_CursorX, int a_CursorY, int a_CursorZ, + BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta + ) override + { + a_Player->GetClientHandle()->SendEditSign(a_BlockX, a_BlockY, a_BlockZ); + } + + + virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override + { + return (a_Meta + 4) & 0x0f; + } + + + virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override + { + return (a_Meta + 12) & 0x0f; + } + + virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override + { + // Mirrors signs over the XY plane (North-South Mirroring) + + // There are 16 meta values which correspond to different directions. + // These values are equated to angles on a circle; 0x08 = 180 degrees. + return (a_Meta < 0x08) ? (0x08 + a_Meta) : (0x08 - a_Meta); + } + + + virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override + { + // Mirrors signs over the YZ plane (East-West Mirroring) + + // There are 16 meta values which correspond to different directions. + // These values are equated to angles on a circle; 0x10 = 360 degrees. + return 0x10 - a_Meta; + } +} ; + + + + diff --git a/src/Blocks/BlockWallSign.h b/src/Blocks/BlockWallSign.h new file mode 100644 index 000000000..037a7bd19 --- /dev/null +++ b/src/Blocks/BlockWallSign.h @@ -0,0 +1,62 @@ + +#pragma once + +#include "Chunk.h" + + + + + +class cBlockWallSignHandler : + public cBlockSignPostHandler +{ +public: + cBlockWallSignHandler(BLOCKTYPE a_BlockType) + : cBlockSignPostHandler(a_BlockType) + { + } + + + virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override + { + int BlockX = (a_Chunk.GetPosX() * cChunkDef::Width) + a_RelX; + int BlockZ = (a_Chunk.GetPosZ() * cChunkDef::Width) + a_RelZ; + GetBlockCoordsBehindTheSign(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ), BlockX, BlockZ); + + return (cBlockInfo::IsSolid(a_ChunkInterface.GetBlock(BlockX, a_RelY, BlockZ))); + } + + + virtual void GetBlockCoordsBehindTheSign(NIBBLETYPE a_BlockMeta, int & a_BlockX, int & a_BlockZ) + { + switch (a_BlockMeta) + { + case 2: a_BlockZ++; break; + case 3: a_BlockZ--; break; + case 4: a_BlockX++; break; + case 5: a_BlockX--; break; + default: break; + } + } + + + static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction) + { + switch (a_Direction) + { + case 0x2: return 0x2; + case 0x3: return 0x3; + case 0x4: return 0x4; + case 0x5: return 0x5; + default: + { + break; + } + } + return 0x2; + } +} ; + + + + -- cgit v1.2.3 From 44c944716b4fd933547d76d09bccce72e8959abb Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 17:04:01 +0200 Subject: Removed cBlockSignPostHandler descend. --- src/Blocks/BlockWallSign.h | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockWallSign.h b/src/Blocks/BlockWallSign.h index 037a7bd19..b0f4015b6 100644 --- a/src/Blocks/BlockWallSign.h +++ b/src/Blocks/BlockWallSign.h @@ -1,6 +1,8 @@ #pragma once +#include "BlockHandler.h" +#include "../Entities/Player.h" #include "Chunk.h" @@ -8,15 +10,39 @@ class cBlockWallSignHandler : - public cBlockSignPostHandler + public cBlockHandler { + typedef cBlockHandler super; public: cBlockWallSignHandler(BLOCKTYPE a_BlockType) - : cBlockSignPostHandler(a_BlockType) + : cBlockHandler(a_BlockType) { } + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + a_Pickups.push_back(cItem(E_ITEM_SIGN, 1, 0)); + } + + + virtual const char * GetStepSound(void) override + { + return "step.wood"; + } + + + virtual void OnPlacedByPlayer( + cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_CursorX, int a_CursorY, int a_CursorZ, + BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta + ) override + { + a_Player->GetClientHandle()->SendEditSign(a_BlockX, a_BlockY, a_BlockZ); + } + + virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { int BlockX = (a_Chunk.GetPosX() * cChunkDef::Width) + a_RelX; -- cgit v1.2.3 From 23037ce7ec1f7ff290bd18f30d5fb25b91b5e61c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Jul 2014 22:41:48 +0200 Subject: Normalized code style for both sign handlers. --- src/Blocks/BlockSignPost.h | 19 +++++++++++-------- src/Blocks/BlockWallSign.h | 17 +++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockSignPost.h b/src/Blocks/BlockSignPost.h index d5b0c0b5f..ee65d099a 100644 --- a/src/Blocks/BlockSignPost.h +++ b/src/Blocks/BlockSignPost.h @@ -12,9 +12,11 @@ class cBlockSignPostHandler : public cBlockHandler { + typedef cBlockHandler super; + public: - cBlockSignPostHandler(BLOCKTYPE a_BlockType) - : cBlockHandler(a_BlockType) + cBlockSignPostHandler(BLOCKTYPE a_BlockType) : + super(a_BlockType) { } @@ -78,22 +80,23 @@ public: return (a_Meta + 12) & 0x0f; } + virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override { - // Mirrors signs over the XY plane (North-South Mirroring) + // Mirrors signs over the XY plane (North-South Mirroring) - // There are 16 meta values which correspond to different directions. - // These values are equated to angles on a circle; 0x08 = 180 degrees. + // There are 16 meta values which correspond to different directions. + // These values are equated to angles on a circle; 0x08 = 180 degrees. return (a_Meta < 0x08) ? (0x08 + a_Meta) : (0x08 - a_Meta); } virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override { - // Mirrors signs over the YZ plane (East-West Mirroring) + // Mirrors signs over the YZ plane (East-West Mirroring) - // There are 16 meta values which correspond to different directions. - // These values are equated to angles on a circle; 0x10 = 360 degrees. + // There are 16 meta values which correspond to different directions. + // These values are equated to angles on a circle; 0x10 = 360 degrees. return 0x10 - a_Meta; } } ; diff --git a/src/Blocks/BlockWallSign.h b/src/Blocks/BlockWallSign.h index b0f4015b6..e837b315e 100644 --- a/src/Blocks/BlockWallSign.h +++ b/src/Blocks/BlockWallSign.h @@ -13,9 +13,10 @@ class cBlockWallSignHandler : public cBlockHandler { typedef cBlockHandler super; + public: - cBlockWallSignHandler(BLOCKTYPE a_BlockType) - : cBlockHandler(a_BlockType) + cBlockWallSignHandler(BLOCKTYPE a_BlockType) : + super(a_BlockType) { } @@ -53,15 +54,15 @@ public: } - virtual void GetBlockCoordsBehindTheSign(NIBBLETYPE a_BlockMeta, int & a_BlockX, int & a_BlockZ) + static void GetBlockCoordsBehindTheSign(NIBBLETYPE a_BlockMeta, int & a_BlockX, int & a_BlockZ) { switch (a_BlockMeta) { - case 2: a_BlockZ++; break; - case 3: a_BlockZ--; break; - case 4: a_BlockX++; break; - case 5: a_BlockX--; break; - default: break; + case 2: a_BlockZ++; break; + case 3: a_BlockZ--; break; + case 4: a_BlockX++; break; + case 5: a_BlockX--; break; + default: break; } } -- cgit v1.2.3 From 61c4e2e5cbe93592a5dc1d704ca29a405ac61428 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 00:01:26 -0700 Subject: Blocks/CMakeLists.txt: Replaced glob with list of files --- src/Blocks/CMakeLists.txt | 97 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 92 insertions(+), 5 deletions(-) (limited to 'src/Blocks') diff --git a/src/Blocks/CMakeLists.txt b/src/Blocks/CMakeLists.txt index 4b8c745ad..d356d151b 100644 --- a/src/Blocks/CMakeLists.txt +++ b/src/Blocks/CMakeLists.txt @@ -4,9 +4,96 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + BlockBed.cpp + BlockDoor.cpp + BlockHandler.cpp + BlockPiston.cpp + ChunkInterface.cpp) -add_library(Blocks ${SOURCE}) +SET (HDRS + BlockAnvil.h + BlockBed.h + BlockBigFlower.h + BlockBrewingStand.h + BlockButton.h + BlockCactus.h + BlockCake.h + BlockCarpet.h + BlockCauldron.h + BlockChest.h + BlockCloth.h + BlockCobWeb.h + BlockCommandBlock.h + BlockComparator.h + BlockCrops.h + BlockDeadBush.h + BlockDirt.h + BlockDoor.h + BlockDropSpenser.h + BlockEnchantmentTable.h + BlockEnderchest.h + BlockEntity.h + BlockFarmland.h + BlockFenceGate.h + BlockFire.h + BlockFlower.h + BlockFlowerPot.h + BlockFluid.h + BlockFurnace.h + BlockGlass.h + BlockGlowstone.h + BlockGravel.h + BlockHandler.h + BlockHayBale.h + BlockHopper.h + BlockIce.h + BlockLadder.h + BlockLeaves.h + BlockLever.h + BlockLilypad.h + BlockMelon.h + BlockMobHead.h + BlockMushroom.h + BlockMycelium.h + BlockNetherWart.h + BlockNewLeaves.h + BlockNote.h + BlockOre.h + BlockPiston.h + BlockPlanks.h + BlockPluginInterface.h + BlockPortal.h + BlockPressurePlate.h + BlockPumpkin.h + BlockQuartz.h + BlockRail.h + BlockRedstone.h + BlockRedstoneLamp.h + BlockRedstoneRepeater.h + BlockRedstoneTorch.h + BlockSand.h + BlockSapling.h + BlockSideways.h + BlockSign.h + BlockSlab.h + BlockSnow.h + BlockStairs.h + BlockStems.h + BlockStone.h + BlockSugarcane.h + BlockTNT.h + BlockTallGrass.h + BlockTorch.h + BlockTrapdoor.h + BlockTripwire.h + BlockTripwireHook.h + BlockVine.h + BlockWorkbench.h + BroadcastInterface.h + ChunkInterface.h + ClearMetaOnDrop.h + MetaRotator.h + WorldInterface.h) + +add_library(Blocks ${SRCS} ${HDRS}) -- cgit v1.2.3 From 725d1fd1e2995b1720673c280fea1125ac338b3c Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 13:26:43 -0700 Subject: Subdirs: Only add_library if not using MSVC --- src/Blocks/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/Blocks') diff --git a/src/Blocks/CMakeLists.txt b/src/Blocks/CMakeLists.txt index d356d151b..d7edf7f29 100644 --- a/src/Blocks/CMakeLists.txt +++ b/src/Blocks/CMakeLists.txt @@ -96,4 +96,6 @@ SET (HDRS MetaRotator.h WorldInterface.h) -add_library(Blocks ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(Blocks ${SRCS} ${HDRS}) +endif() -- cgit v1.2.3 From 3d368b015e2032f86130b8a3f4d05ca72287c63a Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 15:41:42 -0700 Subject: Blocks/CMakeLists.txt: Fixed header list after merge of master --- src/Blocks/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Blocks') diff --git a/src/Blocks/CMakeLists.txt b/src/Blocks/CMakeLists.txt index d7edf7f29..05b7bfab4 100644 --- a/src/Blocks/CMakeLists.txt +++ b/src/Blocks/CMakeLists.txt @@ -75,7 +75,7 @@ SET (HDRS BlockSand.h BlockSapling.h BlockSideways.h - BlockSign.h + BlockSignPost.h BlockSlab.h BlockSnow.h BlockStairs.h @@ -89,6 +89,7 @@ SET (HDRS BlockTripwire.h BlockTripwireHook.h BlockVine.h + BlockWallSign.h BlockWorkbench.h BroadcastInterface.h ChunkInterface.h -- cgit v1.2.3 From 00c524519ef6c7ceaf4ac91307617cfd65d7cf21 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Jul 2014 14:53:41 +0200 Subject: Fixed style: spaces after commas. --- src/Blocks/BlockBed.cpp | 2 +- src/Blocks/BlockBed.h | 2 +- src/Blocks/BlockLadder.h | 2 +- src/Blocks/BlockLeaves.h | 2 +- src/Blocks/BlockPortal.h | 4 ++-- src/Blocks/ChunkInterface.h | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp index fbf98044c..fbc82b440 100644 --- a/src/Blocks/BlockBed.cpp +++ b/src/Blocks/BlockBed.cpp @@ -15,7 +15,7 @@ void cBlockBedHandler::OnPlacedByPlayer( if (a_BlockMeta < 8) { Vector3i Direction = MetaDataToDirection(a_BlockMeta); - a_ChunkInterface.SetBlock(a_WorldInterface,a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z, E_BLOCK_BED, a_BlockMeta | 0x8); + a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z, E_BLOCK_BED, a_BlockMeta | 0x8); } } diff --git a/src/Blocks/BlockBed.h b/src/Blocks/BlockBed.h index 51e79b888..bf9d9c01d 100644 --- a/src/Blocks/BlockBed.h +++ b/src/Blocks/BlockBed.h @@ -16,7 +16,7 @@ class cBlockBedHandler : { public: cBlockBedHandler(BLOCKTYPE a_BlockType) - : cMetaRotator(a_BlockType) + : cMetaRotator(a_BlockType) { } diff --git a/src/Blocks/BlockLadder.h b/src/Blocks/BlockLadder.h index 72acced41..284d1d732 100644 --- a/src/Blocks/BlockLadder.h +++ b/src/Blocks/BlockLadder.h @@ -103,7 +103,7 @@ public: } - virtual bool CanBeAt(cChunkInterface & a_ChunkInterface,int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override + virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { // TODO: Use AdjustCoordsByMeta(), then cChunk::UnboundedRelGetBlock() and finally some comparison eBlockFace BlockFace = MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ)); diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h index d0baab013..797824506 100644 --- a/src/Blocks/BlockLeaves.h +++ b/src/Blocks/BlockLeaves.h @@ -11,7 +11,7 @@ // Leaves can be this many blocks that away (inclusive) from the log not to decay #define LEAVES_CHECK_DISTANCE 6 -#define PROCESS_NEIGHBOR(x,y,z) \ +#define PROCESS_NEIGHBOR(x, y, z) \ switch (a_Area.GetBlockType(x, y, z)) \ { \ case E_BLOCK_LEAVES: a_Area.SetBlockType(x, y, z, (BLOCKTYPE)(E_BLOCK_SPONGE + i + 1)); break; \ diff --git a/src/Blocks/BlockPortal.h b/src/Blocks/BlockPortal.h index 9ee5d69e2..fc74e89d0 100644 --- a/src/Blocks/BlockPortal.h +++ b/src/Blocks/BlockPortal.h @@ -70,7 +70,7 @@ public: } PortalCheck[] = { { 0, 1, 0}, - { 0,-1, 0}, + { 0, -1, 0}, { 1, 0, 0}, {-1, 0, 0}, } ; @@ -95,7 +95,7 @@ public: } PortalCheck[] = { { 0, 1, 0}, - { 0,-1, 0}, + { 0, -1, 0}, { 0, 0, -1}, { 0, 0, 1}, } ; diff --git a/src/Blocks/ChunkInterface.h b/src/Blocks/ChunkInterface.h index f9cbe3a2d..3bab60be6 100644 --- a/src/Blocks/ChunkInterface.h +++ b/src/Blocks/ChunkInterface.h @@ -18,7 +18,7 @@ public: BLOCKTYPE GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ) { - return m_ChunkMap->GetBlock(a_BlockX,a_BlockY,a_BlockZ); + return m_ChunkMap->GetBlock(a_BlockX, a_BlockY, a_BlockZ); } BLOCKTYPE GetBlock(const Vector3i & a_Pos) { -- cgit v1.2.3 From f68b04e0294e5bc854fa6daad061e0280e5bb4f6 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 20 Jul 2014 12:00:20 +0100 Subject: Proper comment for DropBlock() --- src/Blocks/BlockHandler.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index ee4d4a6fe..a6810933c 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -71,13 +71,16 @@ public: /// Called if the user right clicks the block and the block is useable virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) {}; - /** Called when a Right Click to this Block is cancelled */ + /** Called when a right click to this block is cancelled */ virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) {}; /// Called when the item is mined to convert it into pickups. Pickups may specify multiple items. Appends items to a_Pickups, preserves its original contents virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta); - /// Handles the dropping of a block based on what ConvertToDrops() returns. This will not destroy the block. a_Digger is the entity causing the drop; it may be NULL + /** Handles the dropping, but not destruction, of a block based on what ConvertTo(Verbatim)Pickups() returns, including the spawning of pickups and alertion of plugins + @param a_Digger The entity causing the drop; it may be NULL + @param a_DropVerbatim Calls ConvertToVerbatimPickups() instead of its counterpart, meaning the block itself is dropped by default (due to a speical tool or enchantment) + */ virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim = false); /// Returns step sound name of block -- cgit v1.2.3 From 6be79575fd50e37ac275bd0cb9d16f9e51e8a225 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 20 Jul 2014 23:10:31 +0200 Subject: Style: Normalized spaces after if, for and while. --- src/Blocks/BlockTorch.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockTorch.h b/src/Blocks/BlockTorch.h index 73f2bf9a8..b62268187 100644 --- a/src/Blocks/BlockTorch.h +++ b/src/Blocks/BlockTorch.h @@ -99,7 +99,7 @@ public: static bool CanBePlacedOn(BLOCKTYPE a_BlockType, eBlockFace a_BlockFace) { - if ( !cBlockInfo::FullyOccupiesVoxel(a_BlockType) ) + if (!cBlockInfo::FullyOccupiesVoxel(a_BlockType) ) { return (a_BlockFace == BLOCK_FACE_TOP); // Allow placement only when torch upright (for glass, etc.); exceptions won't even be sent by client, no need to handle } @@ -119,7 +119,8 @@ public: AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, Face, true); BLOCKTYPE BlockInQuestion = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ); - if ( // If on a block that can only hold a torch if torch is standing on it, return that face + // If on a block that can only hold a torch if torch is standing on it, return that face + if ( ((BlockInQuestion == E_BLOCK_GLASS) || (BlockInQuestion == E_BLOCK_FENCE) || (BlockInQuestion == E_BLOCK_NETHER_BRICK_FENCE) || @@ -167,7 +168,7 @@ public: // No need to check for upright orientation, it was done when the torch was placed return true; } - else if ( !cBlockInfo::FullyOccupiesVoxel(BlockInQuestion) ) + else if (!cBlockInfo::FullyOccupiesVoxel(BlockInQuestion) ) { return false; } -- cgit v1.2.3 From 93d29555e58df172bafba530afbc593c16ec66a3 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 21 Jul 2014 15:19:48 +0200 Subject: Style: Normalized to no spaces before closing parenthesis. --- src/Blocks/BlockBed.cpp | 4 ++-- src/Blocks/BlockHandler.cpp | 4 ++-- src/Blocks/BlockTorch.h | 4 ++-- src/Blocks/BlockVine.h | 2 +- src/Blocks/BroadcastInterface.h | 2 +- src/Blocks/ChunkInterface.h | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp index fbc82b440..80ac18560 100644 --- a/src/Blocks/BlockBed.cpp +++ b/src/Blocks/BlockBed.cpp @@ -27,8 +27,8 @@ void cBlockBedHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInt { NIBBLETYPE OldMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - Vector3i ThisPos( a_BlockX, a_BlockY, a_BlockZ ); - Vector3i Direction = MetaDataToDirection( OldMeta & 0x7 ); + Vector3i ThisPos( a_BlockX, a_BlockY, a_BlockZ); + Vector3i Direction = MetaDataToDirection( OldMeta & 0x7); if (OldMeta & 0x8) { // Was pillow diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 8ab4116f4..b6ef23cb9 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -175,7 +175,7 @@ public: cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) { - switch(a_BlockType) + switch (a_BlockType) { // Block handlers, alphabetically sorted: case E_BLOCK_ACACIA_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType); @@ -254,7 +254,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_NEW_LOG: return new cBlockSidewaysHandler (a_BlockType); case E_BLOCK_NOTE_BLOCK: return new cBlockNoteHandler (a_BlockType); case E_BLOCK_PISTON: return new cBlockPistonHandler (a_BlockType); - case E_BLOCK_PISTON_EXTENSION: return new cBlockPistonHeadHandler ( ); + case E_BLOCK_PISTON_EXTENSION: return new cBlockPistonHeadHandler; case E_BLOCK_PLANKS: return new cBlockPlanksHandler (a_BlockType); case E_BLOCK_POTATOES: return new cBlockCropsHandler (a_BlockType); case E_BLOCK_POWERED_RAIL: return new cBlockRailHandler (a_BlockType); diff --git a/src/Blocks/BlockTorch.h b/src/Blocks/BlockTorch.h index b62268187..c73118870 100644 --- a/src/Blocks/BlockTorch.h +++ b/src/Blocks/BlockTorch.h @@ -99,7 +99,7 @@ public: static bool CanBePlacedOn(BLOCKTYPE a_BlockType, eBlockFace a_BlockFace) { - if (!cBlockInfo::FullyOccupiesVoxel(a_BlockType) ) + if (!cBlockInfo::FullyOccupiesVoxel(a_BlockType)) { return (a_BlockFace == BLOCK_FACE_TOP); // Allow placement only when torch upright (for glass, etc.); exceptions won't even be sent by client, no need to handle } @@ -168,7 +168,7 @@ public: // No need to check for upright orientation, it was done when the torch was placed return true; } - else if (!cBlockInfo::FullyOccupiesVoxel(BlockInQuestion) ) + else if (!cBlockInfo::FullyOccupiesVoxel(BlockInQuestion)) { return false; } diff --git a/src/Blocks/BlockVine.h b/src/Blocks/BlockVine.h index c2d82eb4d..61092af3e 100644 --- a/src/Blocks/BlockVine.h +++ b/src/Blocks/BlockVine.h @@ -59,7 +59,7 @@ public: static char MetaDataToDirection(NIBBLETYPE a_MetaData) { - switch(a_MetaData) + switch (a_MetaData) { case 0x1: return BLOCK_FACE_NORTH; case 0x4: return BLOCK_FACE_SOUTH; diff --git a/src/Blocks/BroadcastInterface.h b/src/Blocks/BroadcastInterface.h index c8593c76a..cf332b153 100644 --- a/src/Blocks/BroadcastInterface.h +++ b/src/Blocks/BroadcastInterface.h @@ -6,7 +6,7 @@ class cBroadcastInterface public: virtual ~cBroadcastInterface() {} - virtual void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) = 0; + virtual void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) = 0; virtual void BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL) = 0; virtual void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL) = 0; }; diff --git a/src/Blocks/ChunkInterface.h b/src/Blocks/ChunkInterface.h index 3bab60be6..dea9d7c7e 100644 --- a/src/Blocks/ChunkInterface.h +++ b/src/Blocks/ChunkInterface.h @@ -61,9 +61,9 @@ public: m_ChunkMap->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta); } - void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) + void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { - FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta ); + FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta); } void UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) -- cgit v1.2.3 From bc5db3274fe101afcd9081857bd9b66c12e19906 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 22 Jul 2014 21:09:37 +0100 Subject: Fix misguided comment on bits... ...obviously written by someone very confused, also known as me --- src/Blocks/BlockSapling.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockSapling.h b/src/Blocks/BlockSapling.h index e965809a3..de28273d5 100644 --- a/src/Blocks/BlockSapling.h +++ b/src/Blocks/BlockSapling.h @@ -20,7 +20,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - // Only the first 5 bits contain the display information, 8th bit for growth indicator (but we use 0x07 for forward compatibility) + // Only the first 2 bits contain the display information and the 4th bit is for the growth indicator, but, we use 0x07 for forward compatibility a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 0x07)); } -- cgit v1.2.3 From dfadcf745384f574e751e78bc3e2ddb262fe1fdf Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 23 Jul 2014 09:11:42 +0200 Subject: BlockLeaves: Fixed comment style. --- src/Blocks/BlockLeaves.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h index 1635eba08..e426c89e0 100644 --- a/src/Blocks/BlockLeaves.h +++ b/src/Blocks/BlockLeaves.h @@ -40,14 +40,14 @@ public: { cFastRandom rand; - // Only the first 2 bits contain the display information, the others are for growing + // Old leaves - 3 bits contain display; new leaves - 1st bit, shifted left two for saplings to understand if (rand.NextInt(6) == 0) { a_Pickups.push_back( cItem( E_BLOCK_SAPLING, 1, - (m_BlockType == E_BLOCK_LEAVES) ? (a_BlockMeta & 0x03) : (2 << (a_BlockMeta & 0x01)) // Old leaves - 3 bits contain display; new leaves - 1st bit, shifted left two for saplings to understand + (m_BlockType == E_BLOCK_LEAVES) ? (a_BlockMeta & 0x03) : (2 << (a_BlockMeta & 0x01)) ) ); } -- cgit v1.2.3 From 4191be7ddba820af4ed0c505a8d62416c2b7a8b4 Mon Sep 17 00:00:00 2001 From: archshift Date: Tue, 22 Jul 2014 15:36:13 -0700 Subject: Removed redundant semicolons and re-added warning --- src/Blocks/BlockHandler.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index 01c64b457..94ab8d8c6 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -60,19 +60,19 @@ public: virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ); /// Called when a direct neighbor of this block has been changed (The position is the own position, not the neighbor position) - virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) {}; + virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) {} /// Notifies all neighbors of the given block about a change static void NeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ); /// Called while the player diggs the block. - virtual void OnDigging(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) {}; + virtual void OnDigging(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) {} /// Called if the user right clicks the block and the block is useable - virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) {}; + virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) {} /** Called when a right click to this block is cancelled */ - virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) {}; + virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) {} /// Called when the item is mined to convert it into pickups. Pickups may specify multiple items. Appends items to a_Pickups, preserves its original contents virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta); -- cgit v1.2.3 From 3a6002de5b13c1cd56d904892e5af6123978225d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 24 Jul 2014 21:38:25 +0100 Subject: Fixed block drops * Fixes #1242 (the issue addressed within) --- src/Blocks/BlockBigFlower.h | 6 +++--- src/Blocks/BlockHandler.cpp | 19 +++++++++++-------- src/Blocks/BlockHandler.h | 3 ++- 3 files changed, 16 insertions(+), 12 deletions(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockBigFlower.h b/src/Blocks/BlockBigFlower.h index bc7098aa0..0b6ac9d8a 100644 --- a/src/Blocks/BlockBigFlower.h +++ b/src/Blocks/BlockBigFlower.h @@ -19,16 +19,16 @@ public: } - virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim) override + virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop, bool a_DropVerbatim) override { NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); if (Meta & 0x8) { - super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY - 1, a_BlockZ, a_DropVerbatim); + super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY - 1, a_BlockZ, a_CanDrop, a_DropVerbatim); } else { - super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_DropVerbatim); + super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_CanDrop, a_DropVerbatim); } } diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 3e16f970a..ddb0186c9 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -418,19 +418,22 @@ void cBlockHandler::ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) -void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim) +void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop, bool a_DropVerbatim) { cItems Pickups; NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - if (!a_DropVerbatim) + if (a_CanDrop) { - ConvertToPickups(Pickups, Meta); - } - else - { - // TODO: Add a proper overridable function for this - Pickups.Add(m_BlockType, 1, Meta); + if (!a_DropVerbatim) + { + ConvertToPickups(Pickups, Meta); + } + else + { + // TODO: Add a proper overridable function for this + Pickups.Add(m_BlockType, 1, Meta); + } } // Allow plugins to modify the pickups: diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index 01c64b457..a5d15d930 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -79,9 +79,10 @@ public: /** Handles the dropping, but not destruction, of a block based on what ConvertTo(Verbatim)Pickups() returns, including the spawning of pickups and alertion of plugins @param a_Digger The entity causing the drop; it may be NULL + @param a_CanDrop Informs the handler whether the block should be dropped at all. One example when this is false is when stone is destroyed by hand @param a_DropVerbatim Calls ConvertToVerbatimPickups() instead of its counterpart, meaning the block itself is dropped by default (due to a speical tool or enchantment) */ - virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim = false); + virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop = true, bool a_DropVerbatim = false); /// Returns step sound name of block virtual const char * GetStepSound(void); -- cgit v1.2.3