diff options
Diffstat (limited to 'src/Blocks')
-rw-r--r-- | src/Blocks/BlockCloth.h | 7 | ||||
-rw-r--r-- | src/Blocks/BlockFarmland.h | 11 | ||||
-rw-r--r-- | src/Blocks/BlockHandler.cpp | 2 | ||||
-rw-r--r-- | src/Blocks/BlockHayBale.h | 1 | ||||
-rw-r--r-- | src/Blocks/BlockLadder.h | 28 | ||||
-rw-r--r-- | src/Blocks/BlockLilypad.h | 14 | ||||
-rw-r--r-- | src/Blocks/BlockPiston.h | 1 | ||||
-rw-r--r-- | src/Blocks/BlockPumpkin.h | 9 | ||||
-rw-r--r-- | src/Blocks/BlockSideways.h | 12 | ||||
-rw-r--r-- | src/Blocks/ClearMetaOnDrop.h | 24 |
10 files changed, 67 insertions, 42 deletions
diff --git a/src/Blocks/BlockCloth.h b/src/Blocks/BlockCloth.h index a136d3b9d..3c1ae7c25 100644 --- a/src/Blocks/BlockCloth.h +++ b/src/Blocks/BlockCloth.h @@ -16,13 +16,6 @@ public: { } - - virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override - { - a_Pickups.push_back(cItem(E_BLOCK_WOOL, 1, a_BlockMeta)); - } - - virtual const char * GetStepSound(void) override { return "step.cloth"; diff --git a/src/Blocks/BlockFarmland.h b/src/Blocks/BlockFarmland.h index 3dd5bcd1d..390b6e5ee 100644 --- a/src/Blocks/BlockFarmland.h +++ b/src/Blocks/BlockFarmland.h @@ -19,15 +19,13 @@ class cBlockFarmlandHandler : public cBlockHandler { - typedef cBlockHandler super; public: - cBlockFarmlandHandler(void) : - super(E_BLOCK_FARMLAND) + cBlockFarmlandHandler(BLOCKTYPE a_BlockType) : + cBlockHandler(a_BlockType) { } - virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override { bool Found = false; @@ -105,6 +103,11 @@ public: } } } + + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + a_Pickups.Add(E_BLOCK_DIRT, 1, 0); // Reset meta + } } ; diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 730774ab1..cef1f5f09 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -211,7 +211,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_EMERALD_ORE: return new cBlockOreHandler (a_BlockType); case E_BLOCK_ENCHANTMENT_TABLE: return new cBlockEnchantmentTableHandler(a_BlockType); case E_BLOCK_ENDER_CHEST: return new cBlockEnderchestHandler (a_BlockType); - case E_BLOCK_FARMLAND: return new cBlockFarmlandHandler ( ); + case E_BLOCK_FARMLAND: return new cBlockFarmlandHandler (a_BlockType); case E_BLOCK_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType); case E_BLOCK_FIRE: return new cBlockFireHandler (a_BlockType); case E_BLOCK_FLOWER_POT: return new cBlockFlowerPotHandler (a_BlockType); diff --git a/src/Blocks/BlockHayBale.h b/src/Blocks/BlockHayBale.h index 5b646e264..3c6472adb 100644 --- a/src/Blocks/BlockHayBale.h +++ b/src/Blocks/BlockHayBale.h @@ -1,7 +1,6 @@ #pragma once -#include "BlockHandler.h" #include "BlockSideways.h" diff --git a/src/Blocks/BlockLadder.h b/src/Blocks/BlockLadder.h index a605edf3f..120396c7d 100644 --- a/src/Blocks/BlockLadder.h +++ b/src/Blocks/BlockLadder.h @@ -3,17 +3,19 @@ #include "BlockHandler.h" #include "../World.h" +#include "ClearMetaOnDrop.h" class cBlockLadderHandler : - public cMetaRotator<cBlockHandler, 0x07, 0x02, 0x05, 0x03, 0x04> + public cClearMetaOnDrop<cMetaRotator<cBlockHandler, 0x07, 0x02, 0x05, 0x03, 0x04> > { + typedef cClearMetaOnDrop<cMetaRotator<cBlockHandler, 0x07, 0x02, 0x05, 0x03, 0x04> > super; public: cBlockLadderHandler(BLOCKTYPE a_BlockType) - : cMetaRotator<cBlockHandler, 0x07, 0x02, 0x05, 0x03, 0x04>(a_BlockType) + : super(a_BlockType) { } @@ -41,21 +43,27 @@ public: } - static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction) // tolua_export - { // tolua_export + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + a_Pickups.Add(m_BlockType, 1, 0); // Reset meta + } + + + static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction) + { switch (a_Direction) { case BLOCK_FACE_ZM: return 0x2; case BLOCK_FACE_ZP: return 0x3; case BLOCK_FACE_XM: return 0x4; case BLOCK_FACE_XP: return 0x5; - default: return 0x2; + default: return 0x2; } - } // tolua_export + } - static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData) // tolua_export - { // tolua_export + static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData) + { switch (a_MetaData) { case 0x2: return BLOCK_FACE_ZM; @@ -64,10 +72,10 @@ public: case 0x5: return BLOCK_FACE_XP; default: return BLOCK_FACE_ZM; } - } // tolua_export + } - /// Finds a suitable Direction for the Ladder. Returns BLOCK_FACE_BOTTOM on failure + /** Finds a suitable Direction for the Ladder. Returns BLOCK_FACE_BOTTOM on failure */ static eBlockFace FindSuitableBlockFace(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { for (int FaceInt = BLOCK_FACE_ZM; FaceInt <= BLOCK_FACE_XP; FaceInt++) diff --git a/src/Blocks/BlockLilypad.h b/src/Blocks/BlockLilypad.h index 2dd4ec768..53277caa5 100644 --- a/src/Blocks/BlockLilypad.h +++ b/src/Blocks/BlockLilypad.h @@ -8,18 +8,14 @@ class cBlockLilypadHandler : - public cBlockHandler + public cClearMetaOnDrop<cBlockHandler> { + typedef cClearMetaOnDrop<cBlockHandler> super; public: - cBlockLilypadHandler(BLOCKTYPE a_BlockType) - : cBlockHandler(a_BlockType) - { - } - - virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + + cBlockLilypadHandler(BLOCKTYPE a_BlockType) : + super(a_BlockType) { - // Reset meta to zero - a_Pickups.push_back(cItem(E_BLOCK_LILY_PAD, 1, 0)); } }; diff --git a/src/Blocks/BlockPiston.h b/src/Blocks/BlockPiston.h index 27a44d829..1c8ac6a35 100644 --- a/src/Blocks/BlockPiston.h +++ b/src/Blocks/BlockPiston.h @@ -94,7 +94,6 @@ private: switch (a_BlockType) { case E_BLOCK_ANVIL: - case E_BLOCK_BED: case E_BLOCK_BEDROCK: case E_BLOCK_BREWING_STAND: case E_BLOCK_CHEST: diff --git a/src/Blocks/BlockPumpkin.h b/src/Blocks/BlockPumpkin.h index ac2b9817a..4692a47df 100644 --- a/src/Blocks/BlockPumpkin.h +++ b/src/Blocks/BlockPumpkin.h @@ -6,13 +6,16 @@ class cBlockPumpkinHandler : - public cMetaRotator<cBlockHandler, 0x07, 0x02, 0x03, 0x00, 0x01, false> + public cClearMetaOnDrop<cMetaRotator<cBlockHandler, 0x07, 0x02, 0x03, 0x00, 0x01, false> > { + typedef cClearMetaOnDrop<cMetaRotator<cBlockHandler, 0x07, 0x02, 0x03, 0x00, 0x01, false> > super; public: - cBlockPumpkinHandler(BLOCKTYPE a_BlockType) - : cMetaRotator<cBlockHandler, 0x07, 0x02, 0x03, 0x00, 0x01, false>(a_BlockType) + + cBlockPumpkinHandler(BLOCKTYPE a_BlockType) : + super(a_BlockType) { } + 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 { diff --git a/src/Blocks/BlockSideways.h b/src/Blocks/BlockSideways.h index d67c3aa24..5b37efd75 100644 --- a/src/Blocks/BlockSideways.h +++ b/src/Blocks/BlockSideways.h @@ -32,36 +32,36 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - a_Pickups.Add(m_BlockType, 1, a_BlockMeta & 0x3); + a_Pickups.Add(m_BlockType, 1, a_BlockMeta & 0x3); // Reset meta } - inline static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_BlockFace, NIBBLETYPE a_WoodMeta) + inline static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_BlockFace, NIBBLETYPE a_Meta) { switch (a_BlockFace) { case BLOCK_FACE_YM: case BLOCK_FACE_YP: { - return a_WoodMeta; // Top or bottom, just return original + return a_Meta; // Top or bottom, just return original } case BLOCK_FACE_ZP: case BLOCK_FACE_ZM: { - return a_WoodMeta | 0x8; // North or south + return a_Meta | 0x8; // North or south } case BLOCK_FACE_XP: case BLOCK_FACE_XM: { - return a_WoodMeta | 0x4; // East or west + return a_Meta | 0x4; // East or west } default: { ASSERT(!"Unhandled block face!"); - return a_WoodMeta | 0xC; // No idea, give a special meta (all sides bark) + return a_Meta | 0xC; // No idea, give a special meta } } } diff --git a/src/Blocks/ClearMetaOnDrop.h b/src/Blocks/ClearMetaOnDrop.h new file mode 100644 index 000000000..3f8c33819 --- /dev/null +++ b/src/Blocks/ClearMetaOnDrop.h @@ -0,0 +1,24 @@ + +#pragma once + +// mixin for use to clear meta values when the block is converted to a pickup + +// Usage: inherit from this class, passing the parent class as the parameter Base +// For example to use in class Foo which should inherit Bar use +// class Foo : public cClearMetaOnDrop<Bar>; + +template<class Base> +class cClearMetaOnDrop : public Base +{ +public: + + cClearMetaOnDrop(BLOCKTYPE a_BlockType) : + Base(a_BlockType) + {} + + virtual ~cClearMetaOnDrop() {} + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + a_Pickups.push_back(cItem(this->m_BlockType)); + } +}; |