summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-01-15 15:45:34 +0100
committerMattes D <github@xoft.cz>2014-01-15 15:45:34 +0100
commit0571b1a7e6423902284c54aeab2658517dce5e29 (patch)
treee73549cf547185ecfa25c43d2e4452972f3b8d61 /src
parentUpdated Core! ±±±___±±± (diff)
parentFurnace minecarts now stop being active after a while. (diff)
downloadcuberite-0571b1a7e6423902284c54aeab2658517dce5e29.tar
cuberite-0571b1a7e6423902284c54aeab2658517dce5e29.tar.gz
cuberite-0571b1a7e6423902284c54aeab2658517dce5e29.tar.bz2
cuberite-0571b1a7e6423902284c54aeab2658517dce5e29.tar.lz
cuberite-0571b1a7e6423902284c54aeab2658517dce5e29.tar.xz
cuberite-0571b1a7e6423902284c54aeab2658517dce5e29.tar.zst
cuberite-0571b1a7e6423902284c54aeab2658517dce5e29.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Minecart.cpp35
-rw-r--r--src/Entities/Minecart.h10
2 files changed, 42 insertions, 3 deletions
diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp
index be95b2128..7f3fea5ec 100644
--- a/src/Entities/Minecart.cpp
+++ b/src/Entities/Minecart.cpp
@@ -750,7 +750,8 @@ void cMinecartWithChest::OnRightClicked(cPlayer & a_Player)
cMinecartWithFurnace::cMinecartWithFurnace(double a_X, double a_Y, double a_Z) :
super(mpFurnace, a_X, a_Y, a_Z),
- m_IsFueled(false)
+ m_IsFueled(false),
+ m_FueledTimeLeft(-1)
{
}
@@ -766,8 +767,12 @@ void cMinecartWithFurnace::OnRightClicked(cPlayer & a_Player)
{
a_Player.GetInventory().RemoveOneEquippedItem();
}
-
+ if (!m_IsFueled) // We don't want to change the direction by right clicking it.
+ {
+ AddSpeed(a_Player.GetLookVector().x, 0, a_Player.GetLookVector().z);
+ }
m_IsFueled = true;
+ m_FueledTimeLeft = m_FueledTimeLeft + 600; // The minecart will be active 600 more ticks.
m_World->BroadcastEntityMetadata(*this);
}
}
@@ -776,6 +781,32 @@ void cMinecartWithFurnace::OnRightClicked(cPlayer & a_Player)
+void cMinecartWithFurnace::Tick(float a_Dt, cChunk & a_Chunk)
+{
+ super::Tick(a_Dt, a_Chunk);
+
+ if (m_IsFueled)
+ {
+ m_FueledTimeLeft--;
+ if (m_FueledTimeLeft < 0)
+ {
+ m_IsFueled = false;
+ m_World->BroadcastEntityMetadata(*this);
+ return;
+ }
+
+ if (GetSpeed().Length() > 6)
+ {
+ return;
+ }
+ AddSpeed(GetSpeed() / 4);
+ }
+}
+
+
+
+
+
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cMinecartWithTNT:
diff --git a/src/Entities/Minecart.h b/src/Entities/Minecart.h
index feb700b71..1ebddfdda 100644
--- a/src/Entities/Minecart.h
+++ b/src/Entities/Minecart.h
@@ -151,10 +151,18 @@ public:
// cEntity overrides:
virtual void OnRightClicked(cPlayer & a_Player) override;
- bool IsFueled (void) const { return m_IsFueled; }
+ virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+
+ // Set functions.
+ void SetIsFueled(bool a_IsFueled, int a_FueledTimeLeft = -1) {m_IsFueled = a_IsFueled; m_FueledTimeLeft = a_FueledTimeLeft;}
+
+ // Get functions.
+ int GetFueledTimeLeft(void) const {return m_FueledTimeLeft; }
+ bool IsFueled (void) const {return m_IsFueled;}
private:
+ int m_FueledTimeLeft;
bool m_IsFueled;
} ;