1
0
This commit is contained in:
daniel0916 2014-07-10 17:46:07 +02:00
parent 944c04a209
commit a8efb62088

View File

@ -100,19 +100,19 @@ public:
return false; return false;
} }
BLOCKTYPE CurrentBlock;
Vector3i BlockPos; Vector3i BlockPos;
if (!GetPlaceableBlockFromTrace(a_World, a_Player, BlockPos)) if (!GetPlaceableBlockFromTrace(a_World, a_Player, BlockPos, CurrentBlock))
{ {
return false; return false;
} }
BLOCKTYPE CurrentBlock = a_World->GetBlock(BlockPos);
bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock); bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock);
if (!CanWashAway) if (!CanWashAway)
{ {
// The block pointed at cannot be washed away, so put fluid on top of it / on its sides // The block pointed at cannot be washed away, so put fluid on top of it / on its sides
//AddFaceDirection(BlockPos.x, BlockPos.y, BlockPos.z, a_BlockFace); // AddFaceDirection(BlockPos.x, BlockPos.y, BlockPos.z, a_BlockFace);
CurrentBlock = a_World->GetBlock(BlockPos); // CurrentBlock = a_World->GetBlock(BlockPos);
} }
if ( if (
!CanWashAway && !CanWashAway &&
@ -161,7 +161,7 @@ public:
} }
bool GetBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & BlockPos) bool GetBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos)
{ {
class cCallbacks : class cCallbacks :
public cBlockTracer::cCallbacks public cBlockTracer::cCallbacks
@ -204,19 +204,20 @@ public:
} }
BlockPos.Set(Callbacks.m_Pos.x, Callbacks.m_Pos.y, Callbacks.m_Pos.z); a_BlockPos = Callbacks.m_Pos;
return true; return true;
} }
bool GetPlaceableBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & BlockPos) bool GetPlaceableBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos, BLOCKTYPE & a_BlockType)
{ {
class cCallbacks : class cCallbacks :
public cBlockTracer::cCallbacks public cBlockTracer::cCallbacks
{ {
public: public:
Vector3i m_Pos; Vector3i m_Pos;
bool m_HasHitLastBlock; bool m_HasHitLastBlock;
BLOCKTYPE m_LastBlock;
cCallbacks(void) : cCallbacks(void) :
@ -226,15 +227,16 @@ public:
virtual bool OnNextBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, char a_EntryFace) override virtual bool OnNextBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, char a_EntryFace) override
{ {
if (a_BlockType != E_BLOCK_AIR) if (a_BlockType != E_BLOCK_AIR)
{ {
m_HasHitLastBlock = true; m_HasHitLastBlock = true;
return true; return true;
} }
m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ); m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ);
m_LastBlock = a_BlockType;
return false;
return false;
} }
} Callbacks; } Callbacks;
@ -249,8 +251,8 @@ public:
return false; return false;
} }
a_BlockPos = Callbacks.m_Pos;
BlockPos.Set(Callbacks.m_Pos.x, Callbacks.m_Pos.y, Callbacks.m_Pos.z); a_BlockType = Callbacks.m_LastBlock;
return true; return true;
} }
}; };