summaryrefslogtreecommitdiffstats
path: root/src/Entities/Minecart.cpp
diff options
context:
space:
mode:
authorMichal Havlíček <80639037+havel06@users.noreply.github.com>2023-01-25 21:50:08 +0100
committerGitHub <noreply@github.com>2023-01-25 21:50:08 +0100
commit847884b6a803650903b871054adcde19921af8b5 (patch)
tree6a2db0672130b74ba90794423188aa727d3c718a /src/Entities/Minecart.cpp
parentAllow certain blocks to be placed on top of upside-down stairs/slabs (#5468) (diff)
downloadcuberite-847884b6a803650903b871054adcde19921af8b5.tar
cuberite-847884b6a803650903b871054adcde19921af8b5.tar.gz
cuberite-847884b6a803650903b871054adcde19921af8b5.tar.bz2
cuberite-847884b6a803650903b871054adcde19921af8b5.tar.lz
cuberite-847884b6a803650903b871054adcde19921af8b5.tar.xz
cuberite-847884b6a803650903b871054adcde19921af8b5.tar.zst
cuberite-847884b6a803650903b871054adcde19921af8b5.zip
Diffstat (limited to 'src/Entities/Minecart.cpp')
-rw-r--r--src/Entities/Minecart.cpp48
1 files changed, 46 insertions, 2 deletions
diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp
index 50be91e4e..d8dbc10c1 100644
--- a/src/Entities/Minecart.cpp
+++ b/src/Entities/Minecart.cpp
@@ -6,6 +6,8 @@
// Indiana Jones!
#include "Globals.h"
+#include "ChunkDef.h"
+#include "Defines.h"
#include "Minecart.h"
#include "../BlockInfo.h"
#include "../ClientHandle.h"
@@ -223,7 +225,7 @@ void cMinecart::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
switch (InsideType)
{
case E_BLOCK_RAIL: HandleRailPhysics(InsideMeta, a_Dt); break;
- case E_BLOCK_ACTIVATOR_RAIL: break;
+ case E_BLOCK_ACTIVATOR_RAIL: HandleActivatorRailPhysics(InsideMeta, a_Dt); break;
case E_BLOCK_POWERED_RAIL: HandlePoweredRailPhysics(InsideMeta); break;
case E_BLOCK_DETECTOR_RAIL:
{
@@ -678,6 +680,7 @@ void cMinecart::HandleDetectorRailPhysics(NIBBLETYPE a_RailMeta, std::chrono::mi
void cMinecart::HandleActivatorRailPhysics(NIBBLETYPE a_RailMeta, std::chrono::milliseconds a_Dt)
{
HandleRailPhysics(a_RailMeta & 0x07, a_Dt);
+ // TODO - shake minecart, throw entities out
}
@@ -1516,7 +1519,22 @@ cMinecartWithTNT::cMinecartWithTNT(Vector3d a_Pos):
{
}
-// TODO: Make it activate when passing over activator rail
+
+
+
+
+void cMinecartWithTNT::HandleActivatorRailPhysics(NIBBLETYPE a_RailMeta, std::chrono::milliseconds a_Dt)
+{
+ Super::HandleActivatorRailPhysics(a_RailMeta, a_Dt);
+
+ if ((a_RailMeta & 0x08) && !m_isTNTFused)
+ {
+ m_isTNTFused = true;
+ m_TNTFuseTicksLeft = 80;
+ m_World->BroadcastSoundEffect("entity.tnt.primed", GetPosition(), 1.0f, 1.0f);
+ m_World->BroadcastEntityAnimation(*this, EntityAnimation::MinecartTNTIgnites);
+ }
+}
@@ -1531,6 +1549,32 @@ void cMinecartWithTNT::GetDrops(cItems & a_Drops, cEntity * a_Killer)
+void cMinecartWithTNT::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
+{
+ Super::Tick(a_Dt, a_Chunk);
+ if (!IsTicking())
+ {
+ return;
+ }
+
+ if (m_isTNTFused)
+ {
+ if (m_TNTFuseTicksLeft > 0)
+ {
+ --m_TNTFuseTicksLeft;
+ }
+ else
+ {
+ Destroy();
+ m_World->DoExplosionAt(4.0, GetPosX(), GetPosY() + GetHeight() / 2, GetPosZ(), true, esTNTMinecart, this);
+ }
+ }
+}
+
+
+
+
+
////////////////////////////////////////////////////////////////////////////////
// cMinecartWithHopper: