summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-12 23:50:28 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-12 23:50:28 +0200
commit9f4348fb09ae77aebcf0cdcfc2139613756dbcdc (patch)
treec8950c8e74fe97292bed40c4dc9c9cc813f8d61e
parentMerge pull request #1162 from daniel0916/Fixes (diff)
downloadcuberite-9f4348fb09ae77aebcf0cdcfc2139613756dbcdc.tar
cuberite-9f4348fb09ae77aebcf0cdcfc2139613756dbcdc.tar.gz
cuberite-9f4348fb09ae77aebcf0cdcfc2139613756dbcdc.tar.bz2
cuberite-9f4348fb09ae77aebcf0cdcfc2139613756dbcdc.tar.lz
cuberite-9f4348fb09ae77aebcf0cdcfc2139613756dbcdc.tar.xz
cuberite-9f4348fb09ae77aebcf0cdcfc2139613756dbcdc.tar.zst
cuberite-9f4348fb09ae77aebcf0cdcfc2139613756dbcdc.zip
Diffstat (limited to '')
-rw-r--r--src/Items/ItemBucket.h47
1 files changed, 15 insertions, 32 deletions
diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h
index b3f008229..20d955de4 100644
--- a/src/Items/ItemBucket.h
+++ b/src/Items/ItemBucket.h
@@ -196,54 +196,37 @@ public:
{
public:
Vector3i m_Pos;
- bool m_HasHitLastBlock;
- BLOCKTYPE m_LastBlock;
-
-
- cCallbacks(void) :
- m_HasHitLastBlock(false)
- {
- }
+ BLOCKTYPE m_ReplacedBlock;
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)
{
- bool CanWashAway = cFluidSimulator::CanWashAway(m_LastBlock);
- if (
- !CanWashAway &&
- (m_LastBlock != E_BLOCK_AIR) &&
- !IsBlockWater(m_LastBlock) &&
- !IsBlockLava(m_LastBlock)
- )
+ m_ReplacedBlock = a_BlockType;
+ if (!cFluidSimulator::CanWashAway(a_BlockType))
{
- return true;
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, (eBlockFace)a_EntryFace); // Was a unwashawayable block, can't overwrite it!
}
-
- m_HasHitLastBlock = true;
- return true;
- }
-
- m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ);
- m_LastBlock = a_BlockType;
-
+ m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ); // (Block could be washed away, replace it)
+ return true; // Abort tracing
+ }
return false;
}
} Callbacks;
cLineBlockTracer Tracer(*a_World, Callbacks);
Vector3d Start(a_Player->GetEyePosition() + a_Player->GetLookVector());
- Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5);
-
- Tracer.Trace(Start.x, Start.y, Start.z, End.x, End.y, End.z);
+ Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5);
- if (!Callbacks.m_HasHitLastBlock)
+ // cTracer::Trace returns true when whole line was traversed. By returning true when we hit something, we ensure that this never happens if liquid could be placed
+ // Use this to judge whether the position is valid
+ if (!Tracer.Trace(Start.x, Start.y, Start.z, End.x, End.y, End.z))
{
- return false;
+ a_BlockPos = Callbacks.m_Pos;
+ a_BlockType = Callbacks.m_ReplacedBlock;
+ return true;
}
- a_BlockPos = Callbacks.m_Pos;
- a_BlockType = Callbacks.m_LastBlock;
- return true;
+ return false;
}
};