1
0

Implemented the SlimeBlock into the CanPush method to allow slimeblocks to work correctly when pushed

This commit is contained in:
bibo38 2015-11-05 10:25:59 +01:00
parent 8f066a16ec
commit 59a9ac5e6f

View File

@ -8,6 +8,7 @@
#include "ChunkInterface.h"
#include <vector>
#include <array>
@ -93,6 +94,9 @@ bool cBlockPistonHandler::CanPushBlock(
std::unordered_set<Vector3i, VectorHasher<int>> & a_BlocksPushed, NIBBLETYPE a_PistonMeta
)
{
const static std::array<Vector3i, 6> pushingDirs = {{ Vector3i(-1, 0, 0), Vector3i(1, 0, 0), Vector3i(0, -1, 0), Vector3i(0, 1, 0),
Vector3i(0, 0, -1), Vector3i(0, 0, 1) }};
BLOCKTYPE currBlock;
NIBBLETYPE currMeta;
a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, currBlock, currMeta);
@ -118,6 +122,18 @@ bool cBlockPistonHandler::CanPushBlock(
return true; // Element exist already
}
if(currBlock == E_BLOCK_SLIME_BLOCK)
{
// Try to push the other directions
for(const Vector3i & testDir : pushingDirs)
{
if(!CanPushBlock(a_BlockX + testDir.x, a_BlockY + testDir.y, a_BlockZ + testDir.z, a_World, false, a_BlocksPushed, a_PistonMeta))
{
return false;
}
}
}
AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, a_PistonMeta, 1);
return CanPushBlock(a_BlockX, a_BlockY, a_BlockZ, a_World, true, a_BlocksPushed, a_PistonMeta);
}
@ -283,8 +299,3 @@ void cBlockPistonHeadHandler::OnDestroyedByPlayer(cChunkInterface & a_ChunkInter
a_WorldInterface.SpawnItemPickups(Pickups, a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5);
}
}