Fixes multiple furnace issues, including from loading world storage
This commit is contained in:
parent
3142598dee
commit
e82cd6e4eb
@ -8,6 +8,7 @@ derouinw
|
|||||||
Diusrex
|
Diusrex
|
||||||
Duralex
|
Duralex
|
||||||
FakeTruth (founder)
|
FakeTruth (founder)
|
||||||
|
HaoTNN
|
||||||
Howaner
|
Howaner
|
||||||
jasperarmstrong
|
jasperarmstrong
|
||||||
keyboard
|
keyboard
|
||||||
|
@ -32,7 +32,8 @@ cFurnaceEntity::cFurnaceEntity(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTY
|
|||||||
m_NeedCookTime(0),
|
m_NeedCookTime(0),
|
||||||
m_TimeCooked(0),
|
m_TimeCooked(0),
|
||||||
m_FuelBurnTime(0),
|
m_FuelBurnTime(0),
|
||||||
m_TimeBurned(0)
|
m_TimeBurned(0),
|
||||||
|
m_IsLoading(false)
|
||||||
{
|
{
|
||||||
m_Contents.AddListener(*this);
|
m_Contents.AddListener(*this);
|
||||||
}
|
}
|
||||||
@ -178,21 +179,15 @@ void cFurnaceEntity::BurnNewFuel(void)
|
|||||||
{
|
{
|
||||||
cFurnaceRecipe * FR = cRoot::Get()->GetFurnaceRecipe();
|
cFurnaceRecipe * FR = cRoot::Get()->GetFurnaceRecipe();
|
||||||
int NewTime = FR->GetBurnTime(m_Contents.GetSlot(fsFuel));
|
int NewTime = FR->GetBurnTime(m_Contents.GetSlot(fsFuel));
|
||||||
if (NewTime == 0)
|
if ((NewTime == 0) || !CanCookInputToOutput())
|
||||||
{
|
{
|
||||||
// The item in the fuel slot is not suitable
|
// The item in the fuel slot is not suitable
|
||||||
|
// or the input and output isn't available for cooking
|
||||||
SetBurnTimes(0, 0);
|
SetBurnTimes(0, 0);
|
||||||
SetIsCooking(false);
|
SetIsCooking(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is the input and output ready for cooking?
|
|
||||||
if (!CanCookInputToOutput())
|
|
||||||
{
|
|
||||||
SetBurnTimes(0, 0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Burn one new fuel:
|
// Burn one new fuel:
|
||||||
SetBurnTimes(NewTime, 0);
|
SetBurnTimes(NewTime, 0);
|
||||||
SetIsCooking(true);
|
SetIsCooking(true);
|
||||||
@ -219,6 +214,11 @@ void cFurnaceEntity::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_IsLoading)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ASSERT(a_ItemGrid == &m_Contents);
|
ASSERT(a_ItemGrid == &m_Contents);
|
||||||
switch (a_SlotNum)
|
switch (a_SlotNum)
|
||||||
{
|
{
|
||||||
@ -239,7 +239,10 @@ void cFurnaceEntity::UpdateInput(void)
|
|||||||
if (!m_Contents.GetSlot(fsInput).IsEqual(m_LastInput))
|
if (!m_Contents.GetSlot(fsInput).IsEqual(m_LastInput))
|
||||||
{
|
{
|
||||||
// The input is different from what we had before, reset the cooking time
|
// The input is different from what we had before, reset the cooking time
|
||||||
m_TimeCooked = 0;
|
if (!m_IsLoading)
|
||||||
|
{
|
||||||
|
m_TimeCooked = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m_LastInput = m_Contents.GetSlot(fsInput);
|
m_LastInput = m_Contents.GetSlot(fsInput);
|
||||||
|
|
||||||
@ -254,13 +257,17 @@ void cFurnaceEntity::UpdateInput(void)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_NeedCookTime = m_CurrentRecipe->CookTime;
|
m_NeedCookTime = m_CurrentRecipe->CookTime;
|
||||||
SetIsCooking(true);
|
|
||||||
|
|
||||||
// Start burning new fuel if there's no flame now:
|
// Start burning new fuel if there's no flame now:
|
||||||
if (GetFuelBurnTimeLeft() <= 0)
|
if (GetFuelBurnTimeLeft() <= 0)
|
||||||
{
|
{
|
||||||
BurnNewFuel();
|
BurnNewFuel();
|
||||||
}
|
}
|
||||||
|
// Already burning, set cooking to ensure that cooking is occuring
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetIsCooking(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,11 +301,19 @@ void cFurnaceEntity::UpdateOutput(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// No need to burn new fuel, the Tick() function will take care of that
|
|
||||||
|
|
||||||
// Can cook, start cooking if not already underway:
|
// Can cook, start cooking if not already underway:
|
||||||
m_NeedCookTime = m_CurrentRecipe->CookTime;
|
m_NeedCookTime = m_CurrentRecipe->CookTime;
|
||||||
SetIsCooking(m_FuelBurnTime > 0);
|
|
||||||
|
// Check if fuel needs to start a burn
|
||||||
|
if (GetFuelBurnTimeLeft() <= 0)
|
||||||
|
{
|
||||||
|
BurnNewFuel();
|
||||||
|
}
|
||||||
|
// Already burning, set cooking to ensure that cooking is occuring
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetIsCooking(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,6 +101,11 @@ public:
|
|||||||
m_TimeCooked = a_TimeCooked;
|
m_TimeCooked = a_TimeCooked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetLoading(bool a_IsLoading)
|
||||||
|
{
|
||||||
|
m_IsLoading = a_IsLoading;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/** Block meta of the block currently represented by this entity */
|
/** Block meta of the block currently represented by this entity */
|
||||||
@ -129,6 +134,9 @@ protected:
|
|||||||
|
|
||||||
/** Amount of ticks that the current fuel has been burning */
|
/** Amount of ticks that the current fuel has been burning */
|
||||||
int m_TimeBurned;
|
int m_TimeBurned;
|
||||||
|
|
||||||
|
/** Is the block currently being loaded into the world? */
|
||||||
|
bool m_IsLoading;
|
||||||
|
|
||||||
/** Sends the specified progressbar value to all clients of the window */
|
/** Sends the specified progressbar value to all clients of the window */
|
||||||
void BroadcastProgress(short a_ProgressbarID, short a_Value);
|
void BroadcastProgress(short a_ProgressbarID, short a_Value);
|
||||||
|
@ -1052,7 +1052,8 @@ cBlockEntity * cWSSAnvil::LoadFurnaceFromNBT(const cParsedNBT & a_NBT, int a_Tag
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<cFurnaceEntity> Furnace(new cFurnaceEntity(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, m_World));
|
std::unique_ptr<cFurnaceEntity> Furnace(new cFurnaceEntity(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, m_World));
|
||||||
|
Furnace->SetLoading(true);
|
||||||
|
|
||||||
// Load slots:
|
// Load slots:
|
||||||
for (int Child = a_NBT.GetFirstChild(Items); Child != -1; Child = a_NBT.GetNextSibling(Child))
|
for (int Child = a_NBT.GetFirstChild(Items); Child != -1; Child = a_NBT.GetNextSibling(Child))
|
||||||
{
|
{
|
||||||
@ -1085,9 +1086,9 @@ cBlockEntity * cWSSAnvil::LoadFurnaceFromNBT(const cParsedNBT & a_NBT, int a_Tag
|
|||||||
// Anvil doesn't store the time that an item takes to cook. We simply use the default - 10 seconds (200 ticks)
|
// Anvil doesn't store the time that an item takes to cook. We simply use the default - 10 seconds (200 ticks)
|
||||||
Furnace->SetCookTimes(200, ct);
|
Furnace->SetCookTimes(200, ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restart cooking:
|
// Restart cooking:
|
||||||
Furnace->ContinueCooking();
|
Furnace->ContinueCooking();
|
||||||
|
Furnace->SetLoading(false);
|
||||||
return Furnace.release();
|
return Furnace.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user