summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2020-04-09 22:25:20 +0200
committerGitHub <noreply@github.com>2020-04-09 22:25:20 +0200
commitbdedab15c94956cbc74045ab242fd300d25f39e7 (patch)
tree900c4e7f662388e29405ccf059fcab767bbd8046 /src
parentWolves and mooshrooms are passive mobs (diff)
downloadcuberite-bdedab15c94956cbc74045ab242fd300d25f39e7.tar
cuberite-bdedab15c94956cbc74045ab242fd300d25f39e7.tar.gz
cuberite-bdedab15c94956cbc74045ab242fd300d25f39e7.tar.bz2
cuberite-bdedab15c94956cbc74045ab242fd300d25f39e7.tar.lz
cuberite-bdedab15c94956cbc74045ab242fd300d25f39e7.tar.xz
cuberite-bdedab15c94956cbc74045ab242fd300d25f39e7.tar.zst
cuberite-bdedab15c94956cbc74045ab242fd300d25f39e7.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/FallingBlock.cpp7
-rw-r--r--src/Entities/FallingBlock.h5
-rw-r--r--src/Simulator/SandSimulator.cpp7
-rw-r--r--src/World.cpp2
-rw-r--r--src/World.h14
5 files changed, 18 insertions, 17 deletions
diff --git a/src/Entities/FallingBlock.cpp b/src/Entities/FallingBlock.cpp
index 628e4d34c..18cd3e086 100644
--- a/src/Entities/FallingBlock.cpp
+++ b/src/Entities/FallingBlock.cpp
@@ -11,11 +11,10 @@
-cFallingBlock::cFallingBlock(Vector3i a_BlockPosition, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) :
- super(etFallingBlock, Vector3d(0.5, 0, 0.5) + a_BlockPosition, 0.98, 0.98),
+cFallingBlock::cFallingBlock(Vector3d a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta):
+ super(etFallingBlock, a_Position, 0.98, 0.98),
m_BlockType(a_BlockType),
- m_BlockMeta(a_BlockMeta),
- m_OriginalPosition(a_BlockPosition)
+ m_BlockMeta(a_BlockMeta)
{
SetGravity(-16.0f);
SetAirDrag(0.02f);
diff --git a/src/Entities/FallingBlock.h b/src/Entities/FallingBlock.h
index e4e9582d8..dfac287fd 100644
--- a/src/Entities/FallingBlock.h
+++ b/src/Entities/FallingBlock.h
@@ -20,8 +20,8 @@ public: // tolua_export
CLASS_PROTODEF(cFallingBlock)
/** Creates a new falling block.
- a_BlockPosition is expected in world coords */
- cFallingBlock(Vector3i a_BlockPosition, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
+ a_Position is expected in world coords */
+ cFallingBlock(Vector3d a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
// tolua_begin
@@ -37,7 +37,6 @@ public: // tolua_export
private:
BLOCKTYPE m_BlockType;
NIBBLETYPE m_BlockMeta;
- Vector3i m_OriginalPosition; // Position where the falling block has started, in world coords
} ; // tolua_export
diff --git a/src/Simulator/SandSimulator.cpp b/src/Simulator/SandSimulator.cpp
index 42bb521ed..ee2c45520 100644
--- a/src/Simulator/SandSimulator.cpp
+++ b/src/Simulator/SandSimulator.cpp
@@ -62,12 +62,7 @@ void cSandSimulator::SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX,
);
*/
- auto FallingBlock = cpp14::make_unique<cFallingBlock>(Pos, BlockType, a_Chunk->GetMeta(itr->x, itr->y, itr->z));
- auto FallingBlockPtr = FallingBlock.get();
- if (!FallingBlockPtr->Initialize(std::move(FallingBlock), m_World))
- {
- continue;
- }
+ m_World.SpawnFallingBlock(Pos, BlockType, a_Chunk->GetMeta(itr->x, itr->y, itr->z));
a_Chunk->SetBlock({itr->x, itr->y, itr->z}, E_BLOCK_AIR, 0);
}
}
diff --git a/src/World.cpp b/src/World.cpp
index ee521f254..fdb66b87d 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -2039,7 +2039,7 @@ UInt32 cWorld::SpawnItemPickup(Vector3d a_Pos, const cItem & a_Item, Vector3f a_
-UInt32 cWorld::SpawnFallingBlock(Vector3i a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+UInt32 cWorld::SpawnFallingBlock(Vector3d a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
auto fallingBlock = cpp14::make_unique<cFallingBlock>(a_Pos, a_BlockType, a_BlockMeta);
auto fallingBlockPtr = fallingBlock.get();
diff --git a/src/World.h b/src/World.h
index b46440410..4b0947003 100644
--- a/src/World.h
+++ b/src/World.h
@@ -564,14 +564,22 @@ public:
/** Spawns an falling block entity at the given position.
Returns the UniqueID of the spawned falling block, or cEntity::INVALID_ID on failure. */
- UInt32 SpawnFallingBlock(Vector3i a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
+ UInt32 SpawnFallingBlock(Vector3d a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
- /** OBSOLETE, use the Vector3i-based overload instead.
+ /** Spawns an falling block entity at the given position.
+ Returns the UniqueID of the spawned falling block, or cEntity::INVALID_ID on failure. */
+ UInt32 SpawnFallingBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+ {
+ // When creating from a block position (Vector3i), move the spawn point to the middle of the block by adding (0.5, 0, 0.5)
+ return SpawnFallingBlock(Vector3d(0.5, 0, 0.5) + a_BlockPos, a_BlockType, a_BlockMeta);
+ }
+
+ /** OBSOLETE, use the Vector3-based overload instead.
Spawns an falling block entity at the given position.
Returns the UniqueID of the spawned falling block, or cEntity::INVALID_ID on failure. */
UInt32 SpawnFallingBlock(int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- return SpawnFallingBlock({a_X, a_Y, a_Z}, a_BlockType, a_BlockMeta);
+ return SpawnFallingBlock(Vector3i{a_X, a_Y, a_Z}, a_BlockType, a_BlockMeta);
}
/** Spawns an minecart at the given coordinates.