summaryrefslogtreecommitdiffstats
path: root/src/BlockEntities/FurnaceEntity.cpp
diff options
context:
space:
mode:
authorAlex Sweet <sweet.giorni@gmail.com>2018-04-11 08:46:11 +0200
committerAlexander Harkness <me@bearbin.net>2018-04-11 08:46:11 +0200
commita0896c63d7a02d1b90572d591a16a79b4274feac (patch)
treee3b58fdc79e6891181e057824c8a39769da4ee72 /src/BlockEntities/FurnaceEntity.cpp
parentFix cUUID::Variant (#4213) (diff)
downloadcuberite-a0896c63d7a02d1b90572d591a16a79b4274feac.tar
cuberite-a0896c63d7a02d1b90572d591a16a79b4274feac.tar.gz
cuberite-a0896c63d7a02d1b90572d591a16a79b4274feac.tar.bz2
cuberite-a0896c63d7a02d1b90572d591a16a79b4274feac.tar.lz
cuberite-a0896c63d7a02d1b90572d591a16a79b4274feac.tar.xz
cuberite-a0896c63d7a02d1b90572d591a16a79b4274feac.tar.zst
cuberite-a0896c63d7a02d1b90572d591a16a79b4274feac.zip
Diffstat (limited to 'src/BlockEntities/FurnaceEntity.cpp')
-rw-r--r--src/BlockEntities/FurnaceEntity.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/BlockEntities/FurnaceEntity.cpp b/src/BlockEntities/FurnaceEntity.cpp
index 1f7f6e023..96a17782a 100644
--- a/src/BlockEntities/FurnaceEntity.cpp
+++ b/src/BlockEntities/FurnaceEntity.cpp
@@ -32,6 +32,7 @@ cFurnaceEntity::cFurnaceEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, in
m_TimeCooked(0),
m_FuelBurnTime(0),
m_TimeBurned(0),
+ m_RewardCounter(0),
m_IsLoading(false)
{
m_Contents.AddListener(*this);
@@ -173,6 +174,23 @@ bool cFurnaceEntity::ContinueCooking(void)
+int cFurnaceEntity::GetAndResetReward(void)
+{
+ int Reward = FloorC(m_RewardCounter);
+ float Remainder = m_RewardCounter - static_cast<float>(Reward);
+ // Remainder is used as the percent chance of getting an extra xp point
+ if (GetRandomProvider().RandBool(Remainder))
+ {
+ Reward++;
+ }
+ m_RewardCounter = 0.0;
+ return Reward;
+}
+
+
+
+
+
void cFurnaceEntity::BroadcastProgress(short a_ProgressbarID, short a_Value)
{
cWindow * Window = GetWindow();
@@ -189,6 +207,7 @@ void cFurnaceEntity::BroadcastProgress(short a_ProgressbarID, short a_Value)
void cFurnaceEntity::FinishOne()
{
m_TimeCooked = 0;
+ m_RewardCounter += m_CurrentRecipe->Reward;
if (m_Contents.GetSlot(fsOutput).IsEmpty())
{