Door drops respect player gamemode
* Rely on caller to handle converting to pickups, all OnBroken needs to do is to maintain the unity of the door * Fixes #4797 * Fixes #4796
This commit is contained in:
parent
c3d6afe47e
commit
71ba18d6c6
@ -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)
|
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)
|
if ((a_OldBlockMeta & 0x08) != 0)
|
||||||
{
|
{
|
||||||
// Was upper part of door
|
const auto Lower = a_BlockPos.addedY(-1);
|
||||||
if ((a_BlockPos.y > 0) && IsDoorBlockType(a_ChunkInterface.GetBlock(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
|
else
|
||||||
{
|
{
|
||||||
// Was lower part
|
const auto Upper = a_BlockPos.addedY(1);
|
||||||
if ((a_BlockPos.y < cChunkDef::Height - 1) && IsDoorBlockType(a_ChunkInterface.GetBlock(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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,12 +87,6 @@ public:
|
|||||||
|
|
||||||
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override
|
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override
|
||||||
{
|
{
|
||||||
// Top part of a door doesn't drop anything:
|
|
||||||
if ((a_BlockMeta & 0x08) != 0)
|
|
||||||
{
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (m_BlockType)
|
switch (m_BlockType)
|
||||||
{
|
{
|
||||||
case E_BLOCK_OAK_DOOR: return cItem(E_ITEM_WOODEN_DOOR);
|
case E_BLOCK_OAK_DOOR: return cItem(E_ITEM_WOODEN_DOOR);
|
||||||
|
Loading…
Reference in New Issue
Block a user