summaryrefslogtreecommitdiffstats
path: root/source/FallingBlock.cpp
diff options
context:
space:
mode:
authorfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-09-30 18:37:44 +0200
committerfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-09-30 18:37:44 +0200
commitba2a9b6b2c1519563662a6a1147a82f96afb36dc (patch)
treef176e14fa7afa14a3e598350779bcb755b9d0339 /source/FallingBlock.cpp
parentFixed initial player head rotation when a player is being spawned on another client (diff)
downloadcuberite-ba2a9b6b2c1519563662a6a1147a82f96afb36dc.tar
cuberite-ba2a9b6b2c1519563662a6a1147a82f96afb36dc.tar.gz
cuberite-ba2a9b6b2c1519563662a6a1147a82f96afb36dc.tar.bz2
cuberite-ba2a9b6b2c1519563662a6a1147a82f96afb36dc.tar.lz
cuberite-ba2a9b6b2c1519563662a6a1147a82f96afb36dc.tar.xz
cuberite-ba2a9b6b2c1519563662a6a1147a82f96afb36dc.tar.zst
cuberite-ba2a9b6b2c1519563662a6a1147a82f96afb36dc.zip
Diffstat (limited to '')
-rw-r--r--source/FallingBlock.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/source/FallingBlock.cpp b/source/FallingBlock.cpp
new file mode 100644
index 000000000..1ed9cd5ed
--- /dev/null
+++ b/source/FallingBlock.cpp
@@ -0,0 +1,64 @@
+#include "Globals.h"
+
+#include "FallingBlock.h"
+#include "World.h"
+#include "ClientHandle.h"
+
+
+CLASS_DEFINITION( cFallingBlock, cEntity )
+
+
+cFallingBlock::cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType)
+ : super( a_BlockPosition.x + 0.5f, a_BlockPosition.y + 0.5f, a_BlockPosition.z + 0.5f )
+ , m_BlockType( a_BlockType )
+ , m_OriginalPosition( a_BlockPosition )
+ , m_SpeedY( 0 )
+{
+}
+
+
+
+
+
+cFallingBlock::~cFallingBlock()
+{
+}
+
+
+
+
+
+void cFallingBlock::Initialize(cWorld * a_World)
+{
+ super::Initialize( a_World );
+ a_World->BroadcastSpawn(*this);
+}
+
+
+
+
+
+void cFallingBlock::SpawnOn(cClientHandle & a_ClientHandle)
+{
+ a_ClientHandle.SendSpawnObject(*this, 70, m_BlockType, 0, 0, 0);
+}
+
+
+
+
+
+void cFallingBlock::Tick(float a_Dt)
+{
+ float MilliDt = a_Dt * 0.001f;
+ m_SpeedY -= MilliDt * 9.8f;
+ m_Pos.y += m_SpeedY * MilliDt;
+
+ //GetWorld()->BroadcastTeleportEntity(*this); // Testing position
+
+ Vector3i BlockPos( m_OriginalPosition.x, (int)(m_Pos.y-0.5), m_OriginalPosition.z );
+ if( !IsPassable( GetWorld()->GetBlock( BlockPos ) ) )
+ {
+ Destroy();
+ GetWorld()->SetBlock( BlockPos.x, BlockPos.y+1, BlockPos.z, m_BlockType, 0 );
+ }
+} \ No newline at end of file