summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-19 13:49:01 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-19 13:49:01 +0200
commit34fa53ca3a78fc32003c85256eeb623f96bc663f (patch)
tree56f0e623b3275da0b55d76bc775ec29f5dbfdf1a
parentWebAdmin: The plugin list is sorted alphabetically and if they are enabled or disabled. (diff)
downloadcuberite-34fa53ca3a78fc32003c85256eeb623f96bc663f.tar
cuberite-34fa53ca3a78fc32003c85256eeb623f96bc663f.tar.gz
cuberite-34fa53ca3a78fc32003c85256eeb623f96bc663f.tar.bz2
cuberite-34fa53ca3a78fc32003c85256eeb623f96bc663f.tar.lz
cuberite-34fa53ca3a78fc32003c85256eeb623f96bc663f.tar.xz
cuberite-34fa53ca3a78fc32003c85256eeb623f96bc663f.tar.zst
cuberite-34fa53ca3a78fc32003c85256eeb623f96bc663f.zip
-rw-r--r--source/Chunk.cpp4
-rw-r--r--source/Entity.h4
-rw-r--r--source/FallingBlock.cpp13
-rw-r--r--source/FallingBlock.h3
-rw-r--r--source/Simulator/SandSimulator.cpp6
5 files changed, 24 insertions, 6 deletions
diff --git a/source/Chunk.cpp b/source/Chunk.cpp
index 72313fa08..264fe1170 100644
--- a/source/Chunk.cpp
+++ b/source/Chunk.cpp
@@ -500,7 +500,7 @@ void cChunk::Tick(float a_Dt)
void cChunk::MoveEntityToNewChunk(cEntity * a_Entity)
{
- cChunk * Neighbor = GetNeighborChunk((int)a_Entity->GetPosX(), (int)a_Entity->GetPosZ());
+ cChunk * Neighbor = GetNeighborChunk(a_Entity->GetChunkX() * cChunkDef::Width, a_Entity->GetChunkZ() * cChunkDef::Width);
if (Neighbor == NULL)
{
Neighbor = m_ChunkMap->GetChunkNoLoad(a_Entity->GetChunkX(), ZERO_CHUNK_Y, a_Entity->GetChunkZ());
@@ -512,6 +512,8 @@ void cChunk::MoveEntityToNewChunk(cEntity * a_Entity)
}
}
+ ASSERT(Neighbor != this); // Moving into the same chunk? wtf?
+
Neighbor->AddEntity(a_Entity);
class cMover :
diff --git a/source/Entity.h b/source/Entity.h
index d80c622e3..bc3d90b15 100644
--- a/source/Entity.h
+++ b/source/Entity.h
@@ -122,8 +122,8 @@ public:
double GetSpeedY (void) const { return m_Speed.y; }
double GetSpeedZ (void) const { return m_Speed.z; }
- int GetChunkX(void) const {return FAST_FLOOR_DIV(((int)m_Pos.x), cChunkDef::Width); }
- int GetChunkZ(void) const {return FAST_FLOOR_DIV(((int)m_Pos.z), cChunkDef::Width); }
+ int GetChunkX(void) const {return (int)floor(m_Pos.x / cChunkDef::Width); }
+ int GetChunkZ(void) const {return (int)floor(m_Pos.z / cChunkDef::Width); }
void SetHeadYaw (double a_HeadYaw);
void SetMass (double a_Mass);
diff --git a/source/FallingBlock.cpp b/source/FallingBlock.cpp
index db5679454..f20abe3ba 100644
--- a/source/FallingBlock.cpp
+++ b/source/FallingBlock.cpp
@@ -49,9 +49,9 @@ void cFallingBlock::Tick(float a_Dt, cChunk & a_Chunk)
// GetWorld()->BroadcastTeleportEntity(*this); // Test position
- int BlockX = (int)m_OriginalPosition.x;
+ int BlockX = m_OriginalPosition.x;
int BlockY = (int)(GetPosY() - 0.5);
- int BlockZ = (int)m_OriginalPosition.z;
+ int BlockZ = m_OriginalPosition.z;
if (BlockY < 0)
{
@@ -83,6 +83,15 @@ void cFallingBlock::Tick(float a_Dt, cChunk & a_Chunk)
else if (!cSandSimulator::CanContinueFallThrough(BlockBelow))
{
// Fallen onto a solid block
+ /*
+ LOGD(
+ "Sand: Checked below at {%d, %d, %d} (rel {%d, %d, %d}), it's %s, finishing the fall.",
+ BlockX, BlockY, BlockZ,
+ BlockX - a_Chunk.GetPosX() * cChunkDef::Width, BlockY, BlockZ - a_Chunk.GetPosZ() * cChunkDef::Width,
+ ItemTypeToString(BlockBelow).c_str()
+ );
+ */
+
cSandSimulator::FinishFalling(m_World, BlockX, BlockY + 1, BlockZ, m_BlockType, m_BlockMeta);
Destroy();
return;
diff --git a/source/FallingBlock.h b/source/FallingBlock.h
index dd70eb1d1..b7d448327 100644
--- a/source/FallingBlock.h
+++ b/source/FallingBlock.h
@@ -23,6 +23,7 @@ class cFallingBlock :
public:
CLASS_PROTODEF(cFallingBlock);
+ /// Creates a new falling block. a_BlockPosition is expected in world coords
cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
BLOCKTYPE GetBlockType(void) const { return m_BlockType; }
@@ -36,7 +37,7 @@ public:
private:
BLOCKTYPE m_BlockType;
NIBBLETYPE m_BlockMeta;
- Vector3i m_OriginalPosition;
+ Vector3i m_OriginalPosition; // Position where the falling block has started, in world coords
} ;
diff --git a/source/Simulator/SandSimulator.cpp b/source/Simulator/SandSimulator.cpp
index bed95029e..6ba33a9c1 100644
--- a/source/Simulator/SandSimulator.cpp
+++ b/source/Simulator/SandSimulator.cpp
@@ -53,6 +53,12 @@ void cSandSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChun
Pos.x = itr->x + BaseX;
Pos.y = itr->y;
Pos.z = itr->z + BaseZ;
+ /*
+ LOGD(
+ "Creating a falling block at {%d, %d, %d} of type %s, block below: %s",
+ Pos.x, Pos.y, Pos.z, ItemTypeToString(BlockType).c_str(), ItemTypeToString(BlockBelow).c_str()
+ );
+ */
cFallingBlock * FallingBlock = new cFallingBlock(Pos, BlockType, a_Chunk->GetMeta(itr->x, itr->y, itr->z));
FallingBlock->Initialize(&m_World);
a_Chunk->SetBlock(itr->x, itr->y, itr->z, E_BLOCK_AIR, 0);