summaryrefslogtreecommitdiffstats
path: root/source/cFurnaceEntity.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-13 22:47:03 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-13 22:47:03 +0100
commit4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c (patch)
treefebea3ecd89c0d4aa83924e430bf11366d754733 /source/cFurnaceEntity.cpp
parentNew makefile with automatic *.cpp sourcefile import, automatic header file dependencies and switchable debug / release configuration. gnumake-specific :( (diff)
downloadcuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.gz
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.bz2
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.lz
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.xz
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.zst
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.zip
Diffstat (limited to 'source/cFurnaceEntity.cpp')
-rw-r--r--source/cFurnaceEntity.cpp62
1 files changed, 45 insertions, 17 deletions
diff --git a/source/cFurnaceEntity.cpp b/source/cFurnaceEntity.cpp
index e07a1685d..d5bd192c5 100644
--- a/source/cFurnaceEntity.cpp
+++ b/source/cFurnaceEntity.cpp
@@ -18,8 +18,12 @@
#include <json/json.h>
-cFurnaceEntity::cFurnaceEntity(int a_X, int a_Y, int a_Z, cChunk* a_Chunk)
- : cBlockEntity( E_BLOCK_FURNACE, a_X, a_Y, a_Z, a_Chunk )
+
+
+
+
+cFurnaceEntity::cFurnaceEntity(int a_X, int a_Y, int a_Z, cWorld * a_World)
+ : cBlockEntity( E_BLOCK_FURNACE, a_X, a_Y, a_Z, a_World )
, m_Items( new cItem[3] )
, m_CookingItem( 0 )
, m_CookTime( 0 )
@@ -29,6 +33,10 @@ cFurnaceEntity::cFurnaceEntity(int a_X, int a_Y, int a_Z, cChunk* a_Chunk)
{
}
+
+
+
+
cFurnaceEntity::~cFurnaceEntity()
{
// Tell window its owner is destroyed
@@ -44,6 +52,10 @@ cFurnaceEntity::~cFurnaceEntity()
}
}
+
+
+
+
void cFurnaceEntity::Destroy()
{
// Drop items
@@ -51,16 +63,17 @@ void cFurnaceEntity::Destroy()
{
if( !m_Items[i].IsEmpty() )
{
- cPickup* Pickup = new cPickup( m_PosX*32 + 16, m_PosY*32 + 16, m_PosZ*32 + 16, m_Items[i], 0, 1.f, 0 );
- Pickup->Initialize( m_Chunk->GetWorld() );
+ cPickup* Pickup = new cPickup( m_PosX * 32 + 16, m_PosY * 32 + 16, m_PosZ * 32 + 16, m_Items[i], 0, 1.f, 0 );
+ Pickup->Initialize(m_World);
m_Items[i].Empty();
}
}
-
- // Remove from tick list
- GetChunk()->RemoveTickBlockEntity( this );
}
+
+
+
+
void cFurnaceEntity::UsedBy( cPlayer & a_Player )
{
LOG("Used a furnace");
@@ -84,6 +97,10 @@ void cFurnaceEntity::UsedBy( cPlayer & a_Player )
}
}
+
+
+
+
bool cFurnaceEntity::Tick( float a_Dt )
{
//LOG("Time left: %0.1f Time burned: %0.1f Burn time: %0.1f", m_CookTime - m_TimeCooked, m_TimeBurned, m_BurnTime );
@@ -173,6 +190,10 @@ bool cFurnaceEntity::Tick( float a_Dt )
return ((m_CookingItem != 0) || (m_TimeBurned < m_BurnTime)) && m_BurnTime > 0.f; // Keep on ticking, if there's more to cook, or if it's cooking
}
+
+
+
+
bool cFurnaceEntity::StartCooking()
{
cFurnaceRecipe* FR = cRoot::Get()->GetFurnaceRecipe();
@@ -200,7 +221,6 @@ bool cFurnaceEntity::StartCooking()
m_TimeCooked = 0.f;
m_CookTime = R->CookTime;
}
- GetChunk()->AddTickBlockEntity( this );
return true;
}
}
@@ -208,13 +228,14 @@ bool cFurnaceEntity::StartCooking()
return false;
}
+
+
+
+
void cFurnaceEntity::ResetCookTimer()
{
- if( m_CookingItem )
- {
- delete m_CookingItem;
- m_CookingItem = 0;
- }
+ delete m_CookingItem;
+ m_CookingItem = NULL;
m_TimeCooked = 0.f;
m_CookTime = 0.f;
}
@@ -290,18 +311,21 @@ bool cFurnaceEntity::LoadFromJson( const Json::Value& a_Value )
if( !Item.IsEmpty() )
{
m_CookingItem = new cItem( Item );
- GetChunk()->AddTickBlockEntity( this );
}
}
- m_CookTime = (float)a_Value.get("CookTime", 0).asDouble();
+ m_CookTime = (float)a_Value.get("CookTime", 0).asDouble();
m_TimeCooked = (float)a_Value.get("TimeCooked", 0).asDouble();
- m_BurnTime = (float)a_Value.get("BurnTime", 0).asDouble();
+ m_BurnTime = (float)a_Value.get("BurnTime", 0).asDouble();
m_TimeBurned = (float)a_Value.get("TimeBurned", 0).asDouble();
return true;
}
+
+
+
+
void cFurnaceEntity::SaveToJson( Json::Value& a_Value )
{
a_Value["x"] = m_PosX;
@@ -329,4 +353,8 @@ void cFurnaceEntity::SaveToJson( Json::Value& a_Value )
a_Value["TimeCooked"] = m_TimeCooked;
a_Value["BurnTime"] = m_BurnTime;
a_Value["TimeBurned"] = m_TimeBurned;
-} \ No newline at end of file
+}
+
+
+
+