summaryrefslogtreecommitdiffstats
path: root/src/BlockEntities/BrewingstandEntity.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2017-06-15 15:32:33 +0200
committerLukas Pioch <lukas@zgow.de>2017-06-16 14:11:28 +0200
commit0dd1cd750bb51403d85a226a97a5ad93eb99b144 (patch)
tree8c7a4e8580a780e1ed27f4141c32de7ec3087710 /src/BlockEntities/BrewingstandEntity.cpp
parentChoose # of threads based on system info (#3644) (diff)
downloadcuberite-0dd1cd750bb51403d85a226a97a5ad93eb99b144.tar
cuberite-0dd1cd750bb51403d85a226a97a5ad93eb99b144.tar.gz
cuberite-0dd1cd750bb51403d85a226a97a5ad93eb99b144.tar.bz2
cuberite-0dd1cd750bb51403d85a226a97a5ad93eb99b144.tar.lz
cuberite-0dd1cd750bb51403d85a226a97a5ad93eb99b144.tar.xz
cuberite-0dd1cd750bb51403d85a226a97a5ad93eb99b144.tar.zst
cuberite-0dd1cd750bb51403d85a226a97a5ad93eb99b144.zip
Diffstat (limited to '')
-rw-r--r--src/BlockEntities/BrewingstandEntity.cpp88
1 files changed, 57 insertions, 31 deletions
diff --git a/src/BlockEntities/BrewingstandEntity.cpp b/src/BlockEntities/BrewingstandEntity.cpp
index 464d175c9..28c6e2f43 100644
--- a/src/BlockEntities/BrewingstandEntity.cpp
+++ b/src/BlockEntities/BrewingstandEntity.cpp
@@ -19,19 +19,14 @@
-cBrewingstandEntity::cBrewingstandEntity(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cWorld * a_World) :
- super(a_BlockType, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World),
- m_BlockMeta(a_BlockMeta),
+cBrewingstandEntity::cBrewingstandEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World):
+ Super(a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World),
m_IsDestroyed(false),
m_IsBrewing(false),
m_TimeBrewed(0),
m_RemainingFuel(0)
{
m_Contents.AddListener(*this);
- for (int i = 0; i < 3; i++)
- {
- m_Results[i] = cItem{};
- }
}
@@ -52,33 +47,41 @@ cBrewingstandEntity::~cBrewingstandEntity()
-bool cBrewingstandEntity::UsedBy(cPlayer * a_Player)
+void cBrewingstandEntity::Destroy()
{
- cWindow * Window = GetWindow();
- if (Window == nullptr)
- {
- OpenWindow(new cBrewingstandWindow(m_PosX, m_PosY, m_PosZ, this));
- Window = GetWindow();
- }
+ m_IsDestroyed = true;
+ Super::Destroy();
+}
- if (Window != nullptr)
- {
- if (a_Player->GetWindow() != Window)
- {
- a_Player->OpenWindow(*Window);
- }
- }
- if (m_IsBrewing)
+
+
+
+void cBrewingstandEntity::CopyFrom(const cBlockEntity & a_Src)
+{
+ Super::CopyFrom(a_Src);
+ auto & src = reinterpret_cast<const cBrewingstandEntity &>(a_Src);
+ m_IsBrewing = src.m_IsBrewing;
+ for (size_t i = 0; i < ARRAYCOUNT(m_CurrentBrewingRecipes); ++i)
{
- BroadcastProgress(0, m_NeedBrewingTime - m_TimeBrewed);
+ m_CurrentBrewingRecipes[i] = src.m_CurrentBrewingRecipes[i];
}
- else
+ for (size_t i = 0; i < ARRAYCOUNT(m_Results); ++i)
{
- BroadcastProgress(0, 0);
+ m_Results[i] = src.m_Results[i];
}
- BroadcastProgress(1, m_RemainingFuel);
- return true;
+ m_TimeBrewed = src.m_TimeBrewed;
+ m_RemainingFuel = src.m_RemainingFuel;
+}
+
+
+
+
+
+void cBrewingstandEntity::SendTo(cClientHandle & a_Client)
+{
+ // Nothing needs to be sent
+ UNUSED(a_Client);
}
@@ -159,10 +162,33 @@ bool cBrewingstandEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
-void cBrewingstandEntity::SendTo(cClientHandle & a_Client)
+bool cBrewingstandEntity::UsedBy(cPlayer * a_Player)
{
- // Nothing needs to be sent
- UNUSED(a_Client);
+ cWindow * Window = GetWindow();
+ if (Window == nullptr)
+ {
+ OpenWindow(new cBrewingstandWindow(m_PosX, m_PosY, m_PosZ, this));
+ Window = GetWindow();
+ }
+
+ if (Window != nullptr)
+ {
+ if (a_Player->GetWindow() != Window)
+ {
+ a_Player->OpenWindow(*Window);
+ }
+ }
+
+ if (m_IsBrewing)
+ {
+ BroadcastProgress(0, m_NeedBrewingTime - m_TimeBrewed);
+ }
+ else
+ {
+ BroadcastProgress(0, 0);
+ }
+ BroadcastProgress(1, m_RemainingFuel);
+ return true;
}
@@ -185,7 +211,7 @@ void cBrewingstandEntity::BroadcastProgress(short a_ProgressbarID, short a_Value
void cBrewingstandEntity::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
{
- super::OnSlotChanged(a_ItemGrid, a_SlotNum);
+ Super::OnSlotChanged(a_ItemGrid, a_SlotNum);
if (m_IsDestroyed)
{