summaryrefslogtreecommitdiffstats
path: root/src/Entities/Floater.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2013-12-19 22:51:21 +0100
committerMattes D <github@xoft.cz>2013-12-19 22:51:21 +0100
commit03ec64aee153a4c217f0794e9310d80eda7629e6 (patch)
treecb5f0e532d5bcfc25324207f0c088507f6b6c6bc /src/Entities/Floater.cpp
parentMerge pull request #448 from mc-server/testbranch (diff)
parentFixed #include in Floater.cpp. (diff)
downloadcuberite-03ec64aee153a4c217f0794e9310d80eda7629e6.tar
cuberite-03ec64aee153a4c217f0794e9310d80eda7629e6.tar.gz
cuberite-03ec64aee153a4c217f0794e9310d80eda7629e6.tar.bz2
cuberite-03ec64aee153a4c217f0794e9310d80eda7629e6.tar.lz
cuberite-03ec64aee153a4c217f0794e9310d80eda7629e6.tar.xz
cuberite-03ec64aee153a4c217f0794e9310d80eda7629e6.tar.zst
cuberite-03ec64aee153a4c217f0794e9310d80eda7629e6.zip
Diffstat (limited to 'src/Entities/Floater.cpp')
-rw-r--r--src/Entities/Floater.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/Entities/Floater.cpp b/src/Entities/Floater.cpp
new file mode 100644
index 000000000..1aa0413d9
--- /dev/null
+++ b/src/Entities/Floater.cpp
@@ -0,0 +1,58 @@
+#include "Globals.h"
+
+#include "Floater.h"
+#include "Player.h"
+#include "../ClientHandle.h"
+
+cFloater::cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_PlayerID) :
+ cEntity(etFloater, a_X, a_Y, a_Z, 0.98, 0.98),
+ m_PlayerID(a_PlayerID),
+ m_CanPickupItem(false),
+ m_PickupCountDown(0)
+{
+ SetSpeed(a_Speed);
+}
+
+
+
+
+
+void cFloater::SpawnOn(cClientHandle & a_Client)
+{
+ a_Client.SendSpawnObject(*this, 90, m_PlayerID, 0, 0);
+}
+
+
+
+
+
+void cFloater::Tick(float a_Dt, cChunk & a_Chunk)
+{
+ HandlePhysics(a_Dt, a_Chunk);
+ if (IsBlockWater(m_World->GetBlock((int) GetPosX(), (int) GetPosY(), (int) GetPosZ())))
+ {
+ if (m_World->GetTickRandomNumber(100) == 0)
+ {
+ SetPosY(GetPosY() - 1);
+ m_CanPickupItem = true;
+ m_PickupCountDown = 20;
+ LOGD("Floater %i can be picked up", GetUniqueID());
+ }
+ else
+ {
+ SetSpeedY(1);
+ }
+ }
+ SetSpeedX(GetSpeedX() * 0.95);
+ SetSpeedZ(GetSpeedZ() * 0.95);
+ if (CanPickup())
+ {
+ m_PickupCountDown--;
+ if (m_PickupCountDown == 0)
+ {
+ m_CanPickupItem = false;
+ LOGD("The fish is gone. Floater %i can not pick an item up.", GetUniqueID());
+ }
+ }
+ BroadcastMovementUpdate();
+} \ No newline at end of file