mirror of
https://github.com/cuberite/cuberite.git
synced 2025-01-08 11:57:39 +08:00
TNT minecarts exploding when riding over activator rails (#5469)
* TNT Minecarts exploding via activator rails * Fuse animation * Add TNT minecart explosion source to APIDesc
This commit is contained in:
parent
7fdfb86441
commit
847884b6a8
@ -17949,6 +17949,10 @@ end
|
|||||||
{
|
{
|
||||||
Notes = "A TNT explosion. The SourceData param is the {{cTNTEntity|TNT entity}} object.",
|
Notes = "A TNT explosion. The SourceData param is the {{cTNTEntity|TNT entity}} object.",
|
||||||
},
|
},
|
||||||
|
esTNTMinecart =
|
||||||
|
{
|
||||||
|
Notes = "A TNT minecart explosion. The SourceData param is the {{cMinecartWithTNT|Minecart with TNT entity}} object.",
|
||||||
|
},
|
||||||
esWitherBirth =
|
esWitherBirth =
|
||||||
{
|
{
|
||||||
Notes = "An explosion at a wither's birth. The SourceData param is the {{cMonster|wither entity}} object.",
|
Notes = "An explosion at a wither's birth. The SourceData param is the {{cMonster|wither entity}} object.",
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
// Implements the cPluginLua class representing a plugin written in Lua
|
// Implements the cPluginLua class representing a plugin written in Lua
|
||||||
|
|
||||||
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
||||||
|
#include "Defines.h"
|
||||||
|
#include "Entities/Minecart.h"
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#define LUA_USE_MACOSX
|
#define LUA_USE_MACOSX
|
||||||
@ -431,6 +433,7 @@ bool cPluginLua::OnExploded(cWorld & a_World, double a_ExplosionSize, bool a_Can
|
|||||||
case esOther: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, cLuaState::Return, res); break;
|
case esOther: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, cLuaState::Return, res); break;
|
||||||
case esPlugin: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, cLuaState::Return, res); break;
|
case esPlugin: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, cLuaState::Return, res); break;
|
||||||
case esPrimedTNT: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, static_cast<cTNTEntity *> (a_SourceData), cLuaState::Return, res); break;
|
case esPrimedTNT: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, static_cast<cTNTEntity *> (a_SourceData), cLuaState::Return, res); break;
|
||||||
|
case esTNTMinecart: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, static_cast<cMinecartWithTNT *> (a_SourceData), cLuaState::Return, res); break;
|
||||||
case esWitherBirth: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, static_cast<cMonster *> (a_SourceData), cLuaState::Return, res); break;
|
case esWitherBirth: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, static_cast<cMonster *> (a_SourceData), cLuaState::Return, res); break;
|
||||||
case esWitherSkull: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, static_cast<cWitherSkullEntity *> (a_SourceData), cLuaState::Return, res); break;
|
case esWitherSkull: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, static_cast<cWitherSkullEntity *> (a_SourceData), cLuaState::Return, res); break;
|
||||||
case esMax:
|
case esMax:
|
||||||
@ -471,6 +474,7 @@ bool cPluginLua::OnExploding(cWorld & a_World, double & a_ExplosionSize, bool &
|
|||||||
case esOther: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
|
case esOther: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
|
||||||
case esPlugin: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
|
case esPlugin: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
|
||||||
case esPrimedTNT: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, static_cast<cTNTEntity *> (a_SourceData), cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
|
case esPrimedTNT: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, static_cast<cTNTEntity *> (a_SourceData), cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
|
||||||
|
case esTNTMinecart: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, static_cast<cMinecartWithTNT *> (a_SourceData), cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
|
||||||
case esWitherBirth: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, static_cast<cMonster *> (a_SourceData), cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
|
case esWitherBirth: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, static_cast<cMonster *> (a_SourceData), cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
|
||||||
case esWitherSkull: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, static_cast<cWitherSkullEntity *> (a_SourceData), cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
|
case esWitherSkull: hook->Call(&a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, static_cast<cWitherSkullEntity *> (a_SourceData), cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
|
||||||
case esMax:
|
case esMax:
|
||||||
|
@ -314,6 +314,7 @@ enum eExplosionSource
|
|||||||
esOther,
|
esOther,
|
||||||
esPlugin,
|
esPlugin,
|
||||||
esPrimedTNT,
|
esPrimedTNT,
|
||||||
|
esTNTMinecart,
|
||||||
esWitherBirth,
|
esWitherBirth,
|
||||||
esWitherSkull,
|
esWitherSkull,
|
||||||
esMax,
|
esMax,
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
// Indiana Jones!
|
// Indiana Jones!
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
|
#include "ChunkDef.h"
|
||||||
|
#include "Defines.h"
|
||||||
#include "Minecart.h"
|
#include "Minecart.h"
|
||||||
#include "../BlockInfo.h"
|
#include "../BlockInfo.h"
|
||||||
#include "../ClientHandle.h"
|
#include "../ClientHandle.h"
|
||||||
@ -223,7 +225,7 @@ void cMinecart::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
|||||||
switch (InsideType)
|
switch (InsideType)
|
||||||
{
|
{
|
||||||
case E_BLOCK_RAIL: HandleRailPhysics(InsideMeta, a_Dt); break;
|
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_POWERED_RAIL: HandlePoweredRailPhysics(InsideMeta); break;
|
||||||
case E_BLOCK_DETECTOR_RAIL:
|
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)
|
void cMinecart::HandleActivatorRailPhysics(NIBBLETYPE a_RailMeta, std::chrono::milliseconds a_Dt)
|
||||||
{
|
{
|
||||||
HandleRailPhysics(a_RailMeta & 0x07, 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:
|
// cMinecartWithHopper:
|
||||||
|
|
||||||
|
@ -72,8 +72,8 @@ protected:
|
|||||||
*/
|
*/
|
||||||
void HandleDetectorRailPhysics(NIBBLETYPE a_RailMeta, std::chrono::milliseconds a_Dt);
|
void HandleDetectorRailPhysics(NIBBLETYPE a_RailMeta, std::chrono::milliseconds a_Dt);
|
||||||
|
|
||||||
/** Handles activator rails - placeholder for future implementation */
|
/** Handles activator rails */
|
||||||
void HandleActivatorRailPhysics(NIBBLETYPE a_RailMeta, std::chrono::milliseconds a_Dt);
|
virtual void HandleActivatorRailPhysics(NIBBLETYPE a_RailMeta, std::chrono::milliseconds a_Dt);
|
||||||
|
|
||||||
/** Snaps a mincecart to a rail's axis, resetting its speed
|
/** Snaps a mincecart to a rail's axis, resetting its speed
|
||||||
For curved rails, it changes the cart's direction as well as snapping it to axis */
|
For curved rails, it changes the cart's direction as well as snapping it to axis */
|
||||||
@ -89,7 +89,6 @@ protected:
|
|||||||
|
|
||||||
/** Tests if this mincecart's bounding box is intersecting another entity's bounding box (collision) and pushes mincecart away if necessary */
|
/** Tests if this mincecart's bounding box is intersecting another entity's bounding box (collision) and pushes mincecart away if necessary */
|
||||||
bool TestEntityCollision(NIBBLETYPE a_RailMeta);
|
bool TestEntityCollision(NIBBLETYPE a_RailMeta);
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
@ -222,10 +221,14 @@ public:
|
|||||||
CLASS_PROTODEF(cMinecartWithTNT)
|
CLASS_PROTODEF(cMinecartWithTNT)
|
||||||
|
|
||||||
cMinecartWithTNT(Vector3d a_Pos);
|
cMinecartWithTNT(Vector3d a_Pos);
|
||||||
|
void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int m_TNTFuseTicksLeft;
|
||||||
|
bool m_isTNTFused = false;
|
||||||
|
|
||||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
|
||||||
|
void HandleActivatorRailPhysics(NIBBLETYPE a_RailMeta, std::chrono::milliseconds a_Dt) override;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1395,6 +1395,7 @@ void cWorld::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_Blo
|
|||||||
case eExplosionSource::esGhastFireball:
|
case eExplosionSource::esGhastFireball:
|
||||||
case eExplosionSource::esMonster:
|
case eExplosionSource::esMonster:
|
||||||
case eExplosionSource::esPrimedTNT:
|
case eExplosionSource::esPrimedTNT:
|
||||||
|
case eExplosionSource::esTNTMinecart:
|
||||||
case eExplosionSource::esWitherBirth:
|
case eExplosionSource::esWitherBirth:
|
||||||
case eExplosionSource::esWitherSkull:
|
case eExplosionSource::esWitherSkull:
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user