Fix explosion interaction with block entities. (#4052)
* WriteBlockArea: Fix erasing of block entities. * cChunkMap::DoExplosionAt destroys block entities
This commit is contained in:
parent
4b14a5b4c1
commit
8866a28cf8
@ -452,14 +452,15 @@ void cChunk::WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlock
|
|||||||
} // for y
|
} // for y
|
||||||
|
|
||||||
// Erase all affected block entities:
|
// Erase all affected block entities:
|
||||||
cCuboid affectedArea(
|
cCuboid affectedArea( // In world coordinates
|
||||||
{OffX, a_MinBlockY, OffZ},
|
{BlockStartX, a_MinBlockY, BlockStartZ},
|
||||||
{OffX + SizeX - 1, a_MinBlockY + SizeY - 1, OffZ + SizeZ - 1}
|
{BlockEndX, a_MinBlockY + SizeY - 1, BlockEndZ}
|
||||||
);
|
);
|
||||||
for (auto itr = m_BlockEntities.begin(); itr != m_BlockEntities.end();)
|
for (auto itr = m_BlockEntities.begin(); itr != m_BlockEntities.end();)
|
||||||
{
|
{
|
||||||
if (affectedArea.IsInside(itr->second->GetPos()))
|
if (affectedArea.IsInside(itr->second->GetPos()))
|
||||||
{
|
{
|
||||||
|
delete itr->second;
|
||||||
itr = m_BlockEntities.erase(itr);
|
itr = m_BlockEntities.erase(itr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "Blocks/ChunkInterface.h"
|
#include "Blocks/ChunkInterface.h"
|
||||||
#include "Entities/Pickup.h"
|
#include "Entities/Pickup.h"
|
||||||
#include "DeadlockDetect.h"
|
#include "DeadlockDetect.h"
|
||||||
|
#include "BlockEntities/BlockEntity.h"
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <cstdlib> // abs
|
#include <cstdlib> // abs
|
||||||
@ -1763,6 +1764,18 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Destroy any block entities
|
||||||
|
if (cBlockEntity::IsBlockEntityBlockType(Block))
|
||||||
|
{
|
||||||
|
Vector3i BlockPos(bx + x, by + y, bz + z);
|
||||||
|
DoWithBlockEntityAt(BlockPos.x, BlockPos.y, BlockPos.z, [](cBlockEntity & a_BE)
|
||||||
|
{
|
||||||
|
a_BE.Destroy();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
area.SetBlockTypeMeta(bx + x, by + y, bz + z, E_BLOCK_AIR, 0);
|
area.SetBlockTypeMeta(bx + x, by + y, bz + z, E_BLOCK_AIR, 0);
|
||||||
a_BlocksAffected.push_back(Vector3i(bx + x, by + y, bz + z));
|
a_BlocksAffected.push_back(Vector3i(bx + x, by + y, bz + z));
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user