void cFurnaceEntity::UpdateProgressBars(bool a_ForceUpdate) { // In order to preserve bandwidth, an update is sent only every 10th tick if (!a_ForceUpdate && (m_World->GetWorldAge() % 10 != 0)) { return; } int CurFuel = (m_FuelBurnTime > 0) ? 200 - (200 * m_TimeBurned / m_FuelBurnTime) : 0; BroadcastProgress(PROGRESSBAR_FUEL, static_cast<short>(CurFuel)); int CurCook = (m_NeedCookTime > 0) ? (200 * m_TimeCooked / m_NeedCookTime) : 0; BroadcastProgress(PROGRESSBAR_SMELTING_CONFIRM, 200); // Post 1.8, Mojang requires a random packet with an ID of three and value of 200. Wat. Wat. Wat. BroadcastProgress(PROGRESSBAR_SMELTING, static_cast<short>(CurCook)); }
void cFurnaceEntity::UsedBy(cPlayer * a_Player) { if (GetWindow() == NULL) { OpenWindow(new cFurnaceWindow(m_PosX, m_PosY, m_PosZ, this)); } cWindow * Window = GetWindow(); if (Window != NULL) { if (a_Player->GetWindow() != Window) { a_Player->OpenWindow(Window); BroadcastProgress(PROGRESSBAR_FUEL, (short)m_LastProgressFuel); BroadcastProgress(PROGRESSBAR_SMELTING, (short)m_LastProgressCook); } } }
/// Broadcasts progressbar updates, if needed void cFurnaceEntity::UpdateProgressBars(void) { // In order to preserve bandwidth, an update is sent only every 10th tick // That's why the comparisons use the division by eight int CurFuel = (m_FuelBurnTime > 0) ? (200 - 200 * m_TimeBurned / m_FuelBurnTime) : 0; if ((CurFuel / 8) != (m_LastProgressFuel / 8)) { BroadcastProgress(PROGRESSBAR_FUEL, (short)CurFuel); m_LastProgressFuel = CurFuel; } int CurCook = (m_NeedCookTime > 0) ? (200 * m_TimeCooked / m_NeedCookTime) : 0; if ((CurCook / 8) != (m_LastProgressCook / 8)) { BroadcastProgress(PROGRESSBAR_SMELTING, (short)CurCook); m_LastProgressCook = CurCook; } }