diff options
author | Mattes D <github@xoft.cz> | 2019-10-16 10:06:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-16 10:06:34 +0200 |
commit | 221cc4ec5cb6301743e947eaabed3fecedba796f (patch) | |
tree | 4e44c8bb7523e5d1d04468fc906ae24674c10abc /src/Blocks/BlockDoor.h | |
parent | Fixed crash in hopper while pulling items from blockentity above itself (#4412) (diff) | |
download | cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.gz cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.bz2 cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.lz cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.xz cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.zst cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.zip |
Diffstat (limited to 'src/Blocks/BlockDoor.h')
-rw-r--r-- | src/Blocks/BlockDoor.h | 68 |
1 files changed, 26 insertions, 42 deletions
diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h index 04d63141d..b1a606f67 100644 --- a/src/Blocks/BlockDoor.h +++ b/src/Blocks/BlockDoor.h @@ -4,7 +4,7 @@ #include "BlockHandler.h" #include "../Entities/Player.h" #include "../Chunk.h" -#include "MetaRotator.h" +#include "Mixins.h" #include "ChunkInterface.h" #include "BlockSlab.h" @@ -13,11 +13,13 @@ class cBlockDoorHandler : public cMetaRotator<cBlockHandler, 0x03, 0x01, 0x02, 0x03, 0x00, true> { - typedef cMetaRotator<cBlockHandler, 0x03, 0x01, 0x02, 0x03, 0x00, true> super; + using super = cMetaRotator<cBlockHandler, 0x03, 0x01, 0x02, 0x03, 0x00, true>; + public: + cBlockDoorHandler(BLOCKTYPE a_BlockType); - virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override; + virtual void OnBroken(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta) override; virtual bool 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) override; virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override; @@ -54,57 +56,39 @@ public: virtual cBoundingBox GetPlacementCollisionBox(BLOCKTYPE a_XM, BLOCKTYPE a_XP, BLOCKTYPE a_YM, BLOCKTYPE a_YP, BLOCKTYPE a_ZM, BLOCKTYPE a_ZP) override; - virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + + + + + virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override { - if ((a_BlockMeta & 0x08) != 0) // is top part of door + // Top part of a door doesn't drop anything: + if ((a_BlockMeta & 0x08) != 0) { - return; + return {}; } + switch (m_BlockType) { - case E_BLOCK_OAK_DOOR: - { - a_Pickups.Add(E_ITEM_WOODEN_DOOR); - break; - } - case E_BLOCK_ACACIA_DOOR: - { - a_Pickups.Add(E_ITEM_ACACIA_DOOR); - break; - } - case E_BLOCK_BIRCH_DOOR: - { - a_Pickups.Add(E_ITEM_BIRCH_DOOR); - break; - } - case E_BLOCK_DARK_OAK_DOOR: - { - a_Pickups.Add(E_ITEM_DARK_OAK_DOOR); - break; - } - case E_BLOCK_JUNGLE_DOOR: - { - a_Pickups.Add(E_ITEM_JUNGLE_DOOR); - break; - } - case E_BLOCK_SPRUCE_DOOR: - { - a_Pickups.Add(E_ITEM_SPRUCE_DOOR); - break; - } - case E_BLOCK_IRON_DOOR: - { - a_Pickups.Add(E_ITEM_IRON_DOOR); - break; - } + case E_BLOCK_OAK_DOOR: return cItem(E_ITEM_WOODEN_DOOR); + case E_BLOCK_ACACIA_DOOR: return cItem(E_ITEM_ACACIA_DOOR); + case E_BLOCK_BIRCH_DOOR: return cItem(E_ITEM_BIRCH_DOOR); + case E_BLOCK_DARK_OAK_DOOR: return cItem(E_ITEM_DARK_OAK_DOOR); + case E_BLOCK_JUNGLE_DOOR: return cItem(E_ITEM_JUNGLE_DOOR); + case E_BLOCK_SPRUCE_DOOR: return cItem(E_ITEM_SPRUCE_DOOR); + case E_BLOCK_IRON_DOOR: return cItem(E_ITEM_IRON_DOOR); default: { ASSERT(!"Unhandled door type!"); - break; + return {}; } } } + + + + virtual bool IsUseable(void) override { return true; |