summaryrefslogtreecommitdiffstats
path: root/source/LineBlockTracer.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-08-04 16:07:15 +0200
committermadmaxoft <github@xoft.cz>2013-08-04 16:07:15 +0200
commit654714e7bc34b61d01202e3f87adc2fa60baeeab (patch)
tree4c6ce5f258d84772caa130f43ffa925110a39ec4 /source/LineBlockTracer.cpp
parentcItem: Removed a warning emitted when creating an item from air (diff)
downloadcuberite-654714e7bc34b61d01202e3f87adc2fa60baeeab.tar
cuberite-654714e7bc34b61d01202e3f87adc2fa60baeeab.tar.gz
cuberite-654714e7bc34b61d01202e3f87adc2fa60baeeab.tar.bz2
cuberite-654714e7bc34b61d01202e3f87adc2fa60baeeab.tar.lz
cuberite-654714e7bc34b61d01202e3f87adc2fa60baeeab.tar.xz
cuberite-654714e7bc34b61d01202e3f87adc2fa60baeeab.tar.zst
cuberite-654714e7bc34b61d01202e3f87adc2fa60baeeab.zip
Diffstat (limited to 'source/LineBlockTracer.cpp')
-rw-r--r--source/LineBlockTracer.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/source/LineBlockTracer.cpp b/source/LineBlockTracer.cpp
index c5939cb78..03464314a 100644
--- a/source/LineBlockTracer.cpp
+++ b/source/LineBlockTracer.cpp
@@ -148,8 +148,11 @@ bool cLineBlockTracer::MoveToNextBlock(void)
if (abs(m_DiffX) > EPS)
{
double DestX = (m_DirX > 0) ? (m_CurrentX + 1) : m_CurrentX;
- Coeff = (m_EndX - DestX) / m_DiffX;
- Direction = dirX;
+ Coeff = (DestX - m_StartX) / m_DiffX;
+ if (Coeff <= 1)
+ {
+ Direction = dirX;
+ }
}
if (abs(m_DiffY) > EPS)
{
@@ -205,8 +208,8 @@ bool cLineBlockTracer::Item(cChunk * a_Chunk)
{
BLOCKTYPE BlockType;
NIBBLETYPE BlockMeta;
- int RelX = FAST_FLOOR_DIV(m_CurrentX, cChunkDef::Width);
- int RelZ = FAST_FLOOR_DIV(m_CurrentZ, cChunkDef::Width);
+ int RelX = m_CurrentX - a_Chunk->GetPosX() * cChunkDef::Width;
+ int RelZ = m_CurrentZ - a_Chunk->GetPosZ() * cChunkDef::Width;
a_Chunk->GetBlockTypeMeta(RelX, m_CurrentY, RelZ, BlockType, BlockMeta);
if (m_Callbacks->OnNextBlock(m_CurrentX, m_CurrentY, m_CurrentZ, BlockType, BlockMeta))
{