diff options
author | Howaner <franzi.moos@googlemail.com> | 2014-02-28 15:29:50 +0100 |
---|---|---|
committer | Howaner <franzi.moos@googlemail.com> | 2014-02-28 15:29:50 +0100 |
commit | 27b98dec2b62a1fe88130c6a5c2c840dde293a5e (patch) | |
tree | 6c92a2e4f8614e74362d2695961a9ffba8d08965 /src/BlockEntities/JukeboxEntity.cpp | |
parent | Fix Double Slabs, fix Slab Meta and add more things to burnable (diff) | |
parent | Merge pull request #709 from Howaner/GlobalFixes (diff) | |
download | cuberite-27b98dec2b62a1fe88130c6a5c2c840dde293a5e.tar cuberite-27b98dec2b62a1fe88130c6a5c2c840dde293a5e.tar.gz cuberite-27b98dec2b62a1fe88130c6a5c2c840dde293a5e.tar.bz2 cuberite-27b98dec2b62a1fe88130c6a5c2c840dde293a5e.tar.lz cuberite-27b98dec2b62a1fe88130c6a5c2c840dde293a5e.tar.xz cuberite-27b98dec2b62a1fe88130c6a5c2c840dde293a5e.tar.zst cuberite-27b98dec2b62a1fe88130c6a5c2c840dde293a5e.zip |
Diffstat (limited to '')
-rw-r--r-- | src/BlockEntities/JukeboxEntity.cpp | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/src/BlockEntities/JukeboxEntity.cpp b/src/BlockEntities/JukeboxEntity.cpp index 33042179d..c96253b11 100644 --- a/src/BlockEntities/JukeboxEntity.cpp +++ b/src/BlockEntities/JukeboxEntity.cpp @@ -30,48 +30,70 @@ cJukeboxEntity::~cJukeboxEntity() void cJukeboxEntity::UsedBy(cPlayer * a_Player) { - if (m_Record == 0) + if (IsPlayingRecord()) + { + EjectRecord(); + } + else { const cItem & HeldItem = a_Player->GetEquippedItem(); - if (HeldItem.m_ItemType >= 2256 && HeldItem.m_ItemType <= 2267) + if (PlayRecord(HeldItem.m_ItemType)) { - m_Record = HeldItem.m_ItemType; a_Player->GetInventory().RemoveOneEquippedItem(); - PlayRecord(); } } - else - { - EjectRecord(); - } } -void cJukeboxEntity::PlayRecord(void) +bool cJukeboxEntity::PlayRecord(int a_Record) { + if (!IsRecordItem(a_Record)) + { + // This isn't a Record Item + return false; + } + if (IsPlayingRecord()) + { + // A Record is already in the Jukebox. + EjectRecord(); + } + m_Record = a_Record; m_World->BroadcastSoundParticleEffect(1005, m_PosX, m_PosY, m_PosZ, m_Record); + m_World->SetBlockMeta(m_PosX, m_PosY, m_PosZ, E_META_JUKEBOX_ON); + return true; } -void cJukeboxEntity::EjectRecord(void) +bool cJukeboxEntity::EjectRecord(void) { - if ((m_Record < E_ITEM_FIRST_DISC) || (m_Record > E_ITEM_LAST_DISC)) + if (!IsPlayingRecord()) { // There's no record here - return; + return false; } cItems Drops; Drops.push_back(cItem(m_Record, 1, 0)); + m_Record = 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; + m_World->SetBlockMeta(m_PosX, m_PosY, m_PosZ, E_META_JUKEBOX_OFF); + return true; +} + + + + + +bool cJukeboxEntity::IsPlayingRecord(void) +{ + return (m_Record != 0); } |