diff options
author | keyboard.osh@gmail.com <keyboard.osh@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-05-04 08:25:58 +0200 |
---|---|---|
committer | keyboard.osh@gmail.com <keyboard.osh@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-05-04 08:25:58 +0200 |
commit | c1e6fb454fc6d9e15e93665c9184503c0af6021f (patch) | |
tree | cbbc2d4e25b67250db5d5ae871f0772032dd30d2 /source/ChunkMap.cpp | |
parent | Added lots of new options in the world config tab. (diff) | |
download | cuberite-c1e6fb454fc6d9e15e93665c9184503c0af6021f.tar cuberite-c1e6fb454fc6d9e15e93665c9184503c0af6021f.tar.gz cuberite-c1e6fb454fc6d9e15e93665c9184503c0af6021f.tar.bz2 cuberite-c1e6fb454fc6d9e15e93665c9184503c0af6021f.tar.lz cuberite-c1e6fb454fc6d9e15e93665c9184503c0af6021f.tar.xz cuberite-c1e6fb454fc6d9e15e93665c9184503c0af6021f.tar.zst cuberite-c1e6fb454fc6d9e15e93665c9184503c0af6021f.zip |
Diffstat (limited to '')
-rw-r--r-- | source/ChunkMap.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source/ChunkMap.cpp b/source/ChunkMap.cpp index 7a7eeb25a..3e9fd4a81 100644 --- a/source/ChunkMap.cpp +++ b/source/ChunkMap.cpp @@ -1450,6 +1450,36 @@ bool cChunkMap::ForEachEntityInChunk(int a_ChunkX, int a_ChunkZ, cEntityCallback +cVector3iArray *cChunkMap::DoExplosiontAt(float a_ExplosionSize, int a_BlockX, int a_BlockY, int a_BlockZ) +{ + cBlockArea area; + cVector3iArray *BlocksAffected = new cVector3iArray(); + int ExplosionSizeInt = (int) ceil(a_ExplosionSize); + BlocksAffected->reserve(8 * ExplosionSizeInt * ExplosionSizeInt * ExplosionSizeInt); + area.Read(m_World,a_BlockX - ExplosionSizeInt,a_BlockX + ExplosionSizeInt,a_BlockY - ExplosionSizeInt,a_BlockY + ExplosionSizeInt,a_BlockZ - ExplosionSizeInt,a_BlockZ + ExplosionSizeInt); + for (int x = -ExplosionSizeInt; x < ExplosionSizeInt; x++) + { + for (int y = -ExplosionSizeInt; y < ExplosionSizeInt; y++) + { + for (int z = -ExplosionSizeInt; z < ExplosionSizeInt; z++) + { + if ((x*x + y*y + z*z) < (ExplosionSizeInt * ExplosionSizeInt)) + { + area.SetBlockType(a_BlockX + x, a_BlockY + y, a_BlockZ + z,E_BLOCK_AIR); + BlocksAffected->push_back(Vector3i(a_BlockX + x, a_BlockY + y, a_BlockZ + z)); + } + } + } + + } + area.Write(m_World,a_BlockX - ExplosionSizeInt,a_BlockY - ExplosionSizeInt,a_BlockZ - ExplosionSizeInt); + return BlocksAffected; +} + + + + + bool cChunkMap::DoWithEntityByID(int a_UniqueID, cEntityCallback & a_Callback) { cCSLock Lock(m_CSLayers); |