diff options
author | Mat <mail@mathias.is> | 2020-03-23 14:45:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-23 14:45:09 +0100 |
commit | f5d24746d662f12b0446d82b0e49f7dec495c748 (patch) | |
tree | 7bed8eab2c49f2985ef5e3e0ceaea7dbd3d2df13 /src/BlockEntities/JukeboxEntity.cpp | |
parent | Update .gitignore; new files added to APIDump are no longer ignored (diff) | |
download | cuberite-f5d24746d662f12b0446d82b0e49f7dec495c748.tar cuberite-f5d24746d662f12b0446d82b0e49f7dec495c748.tar.gz cuberite-f5d24746d662f12b0446d82b0e49f7dec495c748.tar.bz2 cuberite-f5d24746d662f12b0446d82b0e49f7dec495c748.tar.lz cuberite-f5d24746d662f12b0446d82b0e49f7dec495c748.tar.xz cuberite-f5d24746d662f12b0446d82b0e49f7dec495c748.tar.zst cuberite-f5d24746d662f12b0446d82b0e49f7dec495c748.zip |
Diffstat (limited to 'src/BlockEntities/JukeboxEntity.cpp')
-rw-r--r-- | src/BlockEntities/JukeboxEntity.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/BlockEntities/JukeboxEntity.cpp b/src/BlockEntities/JukeboxEntity.cpp index a4905cab2..9efd4f0ac 100644 --- a/src/BlockEntities/JukeboxEntity.cpp +++ b/src/BlockEntities/JukeboxEntity.cpp @@ -1,6 +1,9 @@ -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules +// JukeboxEntity.cpp + +// Implements the cJukeboxEntity class representing a single jukebox in the world +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "JukeboxEntity.h" #include "../World.h" #include "../EffectID.h" @@ -23,6 +26,21 @@ cJukeboxEntity::cJukeboxEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Ve cJukeboxEntity::~cJukeboxEntity() { + if (m_World && IsPlayingRecord()) + { + // Stop playing music when destroyed by any means + m_World->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_PLAY_MUSIC_DISC, GetPos(), 0); + } +} + + + + + +void cJukeboxEntity::Destroy(void) +{ + ASSERT(m_World != nullptr); + EjectRecord(); } @@ -50,7 +68,7 @@ bool cJukeboxEntity::UsedBy(cPlayer * a_Player) else { const cItem & HeldItem = a_Player->GetEquippedItem(); - if (PlayRecord(HeldItem.m_ItemType)) + if (PlayRecord(HeldItem.m_ItemType) && !a_Player->IsGameModeCreative()) { a_Player->GetInventory().RemoveOneEquippedItem(); return true; @@ -96,9 +114,9 @@ bool cJukeboxEntity::EjectRecord(void) cItems Drops; Drops.push_back(cItem(static_cast<short>(m_Record), 1, 0)); m_Record = 0; - m_World->SpawnItemPickups(Drops, Vector3d(0.5, 1, 0.5) + m_Pos, 8); - m_World->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_PLAY_MUSIC_DISC, GetPos(), 0); + m_World->SpawnItemPickups(Drops, Vector3d(0.5, 0.5, 0.5) + m_Pos, 10); m_World->SetBlockMeta(m_Pos, E_META_JUKEBOX_OFF); + m_World->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_PLAY_MUSIC_DISC, GetPos(), 0); return true; } |