diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2021-04-05 02:38:43 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2021-04-12 23:35:07 +0200 |
commit | 4cd49d7eca5f8fd53eb98577a1f218a5086704bb (patch) | |
tree | 09bf29a1d30a37445796ed70867f934435c4261f /src/BlockEntities/HopperEntity.cpp | |
parent | Fixed generator for the Mega Taiga biome (#5129) (diff) | |
download | cuberite-4cd49d7eca5f8fd53eb98577a1f218a5086704bb.tar cuberite-4cd49d7eca5f8fd53eb98577a1f218a5086704bb.tar.gz cuberite-4cd49d7eca5f8fd53eb98577a1f218a5086704bb.tar.bz2 cuberite-4cd49d7eca5f8fd53eb98577a1f218a5086704bb.tar.lz cuberite-4cd49d7eca5f8fd53eb98577a1f218a5086704bb.tar.xz cuberite-4cd49d7eca5f8fd53eb98577a1f218a5086704bb.tar.zst cuberite-4cd49d7eca5f8fd53eb98577a1f218a5086704bb.zip |
Diffstat (limited to 'src/BlockEntities/HopperEntity.cpp')
-rw-r--r-- | src/BlockEntities/HopperEntity.cpp | 27 |
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; |