1
0

TNT Spawns Pickups

Fixes FS#397.
This commit is contained in:
Tiger Wang 2013-10-23 23:40:59 +01:00
parent cb9ccb36ac
commit 442c428f5b

View File

@ -12,6 +12,7 @@
#include "BlockArea.h"
#include "PluginManager.h"
#include "Entities/TNTEntity.h"
#include "Blocks/BlockHandler.h"
#ifndef _WIN32
#include <cstdlib> // abs
@ -1608,7 +1609,9 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
// Too far away
continue;
}
switch (area.GetBlockType(bx + x, by + y, bz + z))
BLOCKTYPE Block = area.GetBlockType(bx + x, by + y, bz + z);
switch (Block)
{
case E_BLOCK_TNT:
{
@ -1644,6 +1647,17 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
default:
{
if (Block != E_BLOCK_AIR) // No pickups for air
{
if (m_World->GetTickRandomNumber(10) == 5)
{
cItems Drops;
cBlockHandler * Handler = BlockHandler(Block);
Handler->ConvertToPickups(Drops, area.GetBlockMeta(bx + x, by + y, bz + z)); // Saves us from a massive switch
m_World->SpawnItemPickups(Drops, bx + x, by + y, bz + z);
}
}
area.SetBlockType(bx + x, by + y, bz + z, E_BLOCK_AIR);
a_BlocksAffected.push_back(Vector3i(bx + x, by + y, bz + z));
}