diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2020-08-02 16:25:19 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2020-08-04 19:15:18 +0200 |
commit | 71ba18d6c6a5faa59410cca6b7f9f7a6a10ca738 (patch) | |
tree | 16cfab433cf5c393eb010510a186abd46c4cbef4 /src/Blocks/BlockDoor.cpp | |
parent | Corrected wakeup sequences (diff) | |
download | cuberite-71ba18d6c6a5faa59410cca6b7f9f7a6a10ca738.tar cuberite-71ba18d6c6a5faa59410cca6b7f9f7a6a10ca738.tar.gz cuberite-71ba18d6c6a5faa59410cca6b7f9f7a6a10ca738.tar.bz2 cuberite-71ba18d6c6a5faa59410cca6b7f9f7a6a10ca738.tar.lz cuberite-71ba18d6c6a5faa59410cca6b7f9f7a6a10ca738.tar.xz cuberite-71ba18d6c6a5faa59410cca6b7f9f7a6a10ca738.tar.zst cuberite-71ba18d6c6a5faa59410cca6b7f9f7a6a10ca738.zip |
Diffstat (limited to 'src/Blocks/BlockDoor.cpp')
-rw-r--r-- | src/Blocks/BlockDoor.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/Blocks/BlockDoor.cpp b/src/Blocks/BlockDoor.cpp index fcc4ddbe6..4e9ca725f 100644 --- a/src/Blocks/BlockDoor.cpp +++ b/src/Blocks/BlockDoor.cpp @@ -18,20 +18,25 @@ cBlockDoorHandler::cBlockDoorHandler(BLOCKTYPE a_BlockType): void cBlockDoorHandler::OnBroken(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta) { + // A part of the multiblock door was broken; the relevant half will drop any pickups as required. + // All that is left to do is to delete the other half of the multiblock. + if ((a_OldBlockMeta & 0x08) != 0) { - // Was upper part of door - if ((a_BlockPos.y > 0) && IsDoorBlockType(a_ChunkInterface.GetBlock(a_BlockPos.addedY(-1)))) + const auto Lower = a_BlockPos.addedY(-1); + if ((Lower.y >= 0) && IsDoorBlockType(a_ChunkInterface.GetBlock(Lower))) { - a_ChunkInterface.DropBlockAsPickups(a_BlockPos.addedY(-1)); + // Was upper part of door, remove lower: + a_ChunkInterface.SetBlock(Lower, E_BLOCK_AIR, 0); } } else { - // Was lower part - if ((a_BlockPos.y < cChunkDef::Height - 1) && IsDoorBlockType(a_ChunkInterface.GetBlock(a_BlockPos.addedY(1)))) + const auto Upper = a_BlockPos.addedY(1); + if ((Upper.y <= cChunkDef::Height - 1) && IsDoorBlockType(a_ChunkInterface.GetBlock(Upper))) { - a_ChunkInterface.DropBlockAsPickups(a_BlockPos.addedY(1)); + // Was lower part, remove upper: + a_ChunkInterface.SetBlock(Upper, E_BLOCK_AIR, 0); } } } |