diff options
Diffstat (limited to '')
-rw-r--r-- | source/BlockEntities/JukeboxEntity.cpp | 38 | ||||
-rw-r--r-- | source/BlockEntities/JukeboxEntity.h | 28 |
2 files changed, 33 insertions, 33 deletions
diff --git a/source/BlockEntities/JukeboxEntity.cpp b/source/BlockEntities/JukeboxEntity.cpp index adf0f6af4..aca376dd3 100644 --- a/source/BlockEntities/JukeboxEntity.cpp +++ b/source/BlockEntities/JukeboxEntity.cpp @@ -9,16 +9,6 @@ -cJukeboxEntity::cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ) : - super(E_BLOCK_JUKEBOX, a_BlockX, a_BlockY, a_BlockZ, NULL), - m_Record(0) -{ -} - - - - - cJukeboxEntity::cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) : super(E_BLOCK_JUKEBOX, a_BlockX, a_BlockY, a_BlockZ, a_World), m_Record(0) @@ -31,11 +21,7 @@ cJukeboxEntity::cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld cJukeboxEntity::~cJukeboxEntity() { - if (m_Record >= 2256 && m_Record <= 2267) - { - EjectRecord(); - m_Record = 0; - } + EjectRecord(); } @@ -54,10 +40,9 @@ void cJukeboxEntity::UsedBy(cPlayer * a_Player) PlayRecord(); } } - else if (m_Record >= 2256 && m_Record <= 2267) + else { EjectRecord(); - m_Record = 0; } } @@ -65,7 +50,7 @@ void cJukeboxEntity::UsedBy(cPlayer * a_Player) -void cJukeboxEntity::PlayRecord( void ) +void cJukeboxEntity::PlayRecord(void) { m_World->BroadcastSoundParticleEffect(1005, m_PosX, m_PosY, m_PosZ, m_Record); } @@ -74,19 +59,26 @@ void cJukeboxEntity::PlayRecord( void ) -void cJukeboxEntity::EjectRecord( void ) +void cJukeboxEntity::EjectRecord(void) { + if ((m_Record < E_ITEM_FIRST_DISC) || (m_Record > E_ITEM_LAST_DISC)) + { + // There's no record here + return; + } + cItems Drops; Drops.push_back(cItem(m_Record, 1, 0)); m_World->SpawnItemPickups(Drops, m_PosX + 0.5, m_PosY + 1, m_PosZ + 0.5, 8); m_World->BroadcastSoundParticleEffect(1005, m_PosX, m_PosY, m_PosZ, 0); + m_Record = 0; } -int cJukeboxEntity::GetRecord( void ) +int cJukeboxEntity::GetRecord(void) { return m_Record; } @@ -95,7 +87,7 @@ int cJukeboxEntity::GetRecord( void ) -void cJukeboxEntity::SetRecord( int a_Record ) +void cJukeboxEntity::SetRecord(int a_Record) { m_Record = a_Record; } @@ -104,7 +96,7 @@ void cJukeboxEntity::SetRecord( int a_Record ) -bool cJukeboxEntity::LoadFromJson( const Json::Value & a_Value ) +bool cJukeboxEntity::LoadFromJson(const Json::Value & a_Value) { m_PosX = a_Value.get("x", 0).asInt(); m_PosY = a_Value.get("y", 0).asInt(); @@ -119,7 +111,7 @@ bool cJukeboxEntity::LoadFromJson( const Json::Value & a_Value ) -void cJukeboxEntity::SaveToJson( Json::Value & a_Value ) +void cJukeboxEntity::SaveToJson(Json::Value & a_Value) { a_Value["x"] = m_PosX; a_Value["y"] = m_PosY; diff --git a/source/BlockEntities/JukeboxEntity.h b/source/BlockEntities/JukeboxEntity.h index 2dd61a403..fcafdc479 100644 --- a/source/BlockEntities/JukeboxEntity.h +++ b/source/BlockEntities/JukeboxEntity.h @@ -17,31 +17,39 @@ namespace Json +// tolua_begin + class cJukeboxEntity : public cBlockEntity { typedef cBlockEntity super; public: - /// Creates a new jukebox entity that is not assigned to a world - cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ); + // tolua_end cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); virtual ~cJukeboxEntity(); - bool LoadFromJson( const Json::Value& a_Value ); - virtual void SaveToJson( Json::Value& a_Value ) override; + bool LoadFromJson(const Json::Value & a_Value); + virtual void SaveToJson(Json::Value & a_Value) override; - int GetRecord( void ); - void SetRecord( int a_Record ); - void PlayRecord( void ); - void EjectRecord( void ); - virtual void UsedBy( cPlayer * a_Player ) override; + // tolua_begin + + int GetRecord(void); + void SetRecord(int a_Record); + void PlayRecord(void); + + /// Ejects the currently held record as a pickup. Does nothing when no record inserted. + void EjectRecord(void); + + // tolua_end + + virtual void UsedBy(cPlayer * a_Player) override; virtual void SendTo(cClientHandle & a_Client) override { }; private: int m_Record; -}; +} ; // tolua_end |