diff options
author | bibo38 <bibo38@github.com> | 2020-10-09 17:41:44 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2020-10-20 12:45:58 +0200 |
commit | c221aa3653c00cd2f942294690cbd21dea0daa85 (patch) | |
tree | 637c09ed878a789ceaf1395346d0d6f6f5cdb2c5 /src/BlockEntities/HopperEntity.cpp | |
parent | cBlockInfo: further cleanup (#5001) (diff) | |
download | cuberite-c221aa3653c00cd2f942294690cbd21dea0daa85.tar cuberite-c221aa3653c00cd2f942294690cbd21dea0daa85.tar.gz cuberite-c221aa3653c00cd2f942294690cbd21dea0daa85.tar.bz2 cuberite-c221aa3653c00cd2f942294690cbd21dea0daa85.tar.lz cuberite-c221aa3653c00cd2f942294690cbd21dea0daa85.tar.xz cuberite-c221aa3653c00cd2f942294690cbd21dea0daa85.tar.zst cuberite-c221aa3653c00cd2f942294690cbd21dea0daa85.zip |
Diffstat (limited to 'src/BlockEntities/HopperEntity.cpp')
-rw-r--r-- | src/BlockEntities/HopperEntity.cpp | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp index 2e4264204..616f1f7c7 100644 --- a/src/BlockEntities/HopperEntity.cpp +++ b/src/BlockEntities/HopperEntity.cpp @@ -383,14 +383,17 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk) return true; } - // Check if the chest is a double-chest (chest directly above was empty), if so, try to move from there: - static const Vector3i neighborOfs[] = + static constexpr std::array<Vector3i, 4> neighborOfs { - { 1, 1, 0}, - {-1, 1, 0}, - { 0, 1, 1}, - { 0, 1, -1}, - } ; + { + { 1, 1, 0 }, + { -1, 1, 0 }, + { 0, 1, 1 }, + { 0, 1, -1 } + } + }; + + // Check if the chest is a double-chest (chest directly above was empty), if so, try to move from there: for (const auto & ofs: neighborOfs) { auto neighborRelCoord = ofs.addedXZ(m_RelX, m_RelZ); @@ -546,15 +549,19 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, Vector3i a_Coords) return true; } + static constexpr std::array<Vector3i, 4> neighborOfs = + { + { + { 1, 0, 0 }, + { -1, 0, 0 }, + { 0, 0, 1 }, + { 0, 0, -1 } + } + }; + + const auto relCoord = a_Chunk.AbsoluteToRelative(a_Coords); + // Check if the chest is a double-chest (chest block directly connected was full), if so, try to move into the other half: - static const Vector3i neighborOfs [] = - { - { 1, 0, 0}, - {-1, 0, 0}, - { 0, 0, 1}, - { 0, 0, -1}, - } ; - auto relCoord = a_Chunk.AbsoluteToRelative(a_Coords); for (const auto & ofs: neighborOfs) { auto otherHalfRelCoord = relCoord + ofs; |