summaryrefslogtreecommitdiffstats
path: root/src/BlockEntities/HopperEntity.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/BlockEntities/HopperEntity.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp
index 9c9f229e4..58a5fd565 100644
--- a/src/BlockEntities/HopperEntity.cpp
+++ b/src/BlockEntities/HopperEntity.cpp
@@ -17,6 +17,13 @@
+// How many ticks at minimum between two item transfers to or from the hopper.
+#define TICKS_PER_TRANSFER 8_tick
+
+
+
+
+
cHopperEntity::cHopperEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World):
Super(a_BlockType, a_BlockMeta, a_Pos, ContentsWidth, ContentsHeight, a_World),
m_LastMoveItemsInTick(0),
@@ -76,14 +83,14 @@ void cHopperEntity::CopyFrom(const cBlockEntity & a_Src)
bool cHopperEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
UNUSED(a_Dt);
- Int64 CurrentTick = a_Chunk.GetWorld()->GetWorldAge();
bool isDirty = false;
if (!m_Locked)
{
- isDirty = MoveItemsIn (a_Chunk, CurrentTick) || isDirty;
- isDirty = MovePickupsIn(a_Chunk, CurrentTick) || isDirty;
- isDirty = MoveItemsOut (a_Chunk, CurrentTick) || isDirty;
+ const auto CurrentTick = a_Chunk.GetWorld()->GetWorldAge();
+ isDirty = MoveItemsIn(a_Chunk, CurrentTick) || isDirty;
+ isDirty = MovePickupsIn(a_Chunk) || isDirty;
+ isDirty = MoveItemsOut(a_Chunk, CurrentTick) || isDirty;
}
return isDirty;
}
@@ -147,7 +154,7 @@ void cHopperEntity::OpenNewWindow(void)
-bool cHopperEntity::MoveItemsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
+bool cHopperEntity::MoveItemsIn(cChunk & a_Chunk, const cTickTimeLong a_CurrentTick)
{
if (m_Pos.y >= cChunkDef::Height)
{
@@ -155,7 +162,7 @@ bool cHopperEntity::MoveItemsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
return false;
}
- if (a_CurrentTick - m_LastMoveItemsInTick < TICKS_PER_TRANSFER)
+ if ((a_CurrentTick - m_LastMoveItemsInTick) < TICKS_PER_TRANSFER)
{
// Too early after the previous transfer
return false;
@@ -201,10 +208,8 @@ bool cHopperEntity::MoveItemsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
-bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
+bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk)
{
- UNUSED(a_CurrentTick);
-
class cHopperPickupSearchCallback
{
public:
@@ -290,9 +295,9 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
-bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
+bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, const cTickTimeLong a_CurrentTick)
{
- if (a_CurrentTick - m_LastMoveItemsOutTick < TICKS_PER_TRANSFER)
+ if ((a_CurrentTick - m_LastMoveItemsOutTick) < TICKS_PER_TRANSFER)
{
// Too early after the previous transfer
return false;