diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2021-04-10 18:17:15 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2021-04-12 23:35:07 +0200 |
commit | 7080c4d3e2df1276ddc5c73444521fdfe3731496 (patch) | |
tree | 2e537188a9960b3d64a08c6348216a3be65397a9 /src | |
parent | Thrown potions/enderpearls: cleanup (diff) | |
download | cuberite-7080c4d3e2df1276ddc5c73444521fdfe3731496.tar cuberite-7080c4d3e2df1276ddc5c73444521fdfe3731496.tar.gz cuberite-7080c4d3e2df1276ddc5c73444521fdfe3731496.tar.bz2 cuberite-7080c4d3e2df1276ddc5c73444521fdfe3731496.tar.lz cuberite-7080c4d3e2df1276ddc5c73444521fdfe3731496.tar.xz cuberite-7080c4d3e2df1276ddc5c73444521fdfe3731496.tar.zst cuberite-7080c4d3e2df1276ddc5c73444521fdfe3731496.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/Simulator/IncrementalRedstoneSimulator/HopperHandler.h | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/Simulator/IncrementalRedstoneSimulator/HopperHandler.h b/src/Simulator/IncrementalRedstoneSimulator/HopperHandler.h index 379f7c7d8..ca820441c 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/HopperHandler.h +++ b/src/Simulator/IncrementalRedstoneSimulator/HopperHandler.h @@ -24,20 +24,31 @@ namespace HopperHandler { // LOGD("Evaluating holey the hopper (%d %d %d)", a_Position.x, a_Position.y, a_Position.z); - const auto Previous = DataForChunk(a_Chunk).ExchangeUpdateOncePowerData(a_Position, Power); - if (Previous == Power) + const bool ShouldBeLocked = Power != 0; + const bool PreviouslyLocked = (a_Meta & 0x8) == 0x8; + + if (ShouldBeLocked == PreviouslyLocked) { return; } - a_Chunk.DoWithBlockEntityAt(a_Position, [Power](cBlockEntity & a_BlockEntity) + if (ShouldBeLocked) + { + a_Chunk.SetMeta(a_Position, a_Meta | 0x8); + } + else + { + a_Chunk.SetMeta(a_Position, a_Meta & ~0x8); + } + + a_Chunk.DoWithBlockEntityAt(a_Position, [ShouldBeLocked](cBlockEntity & a_BlockEntity) { if (a_BlockEntity.GetBlockType() != E_BLOCK_HOPPER) { return false; } - static_cast<cHopperEntity &>(a_BlockEntity).SetLocked(Power != 0); + static_cast<cHopperEntity &>(a_BlockEntity).SetLocked(ShouldBeLocked); return false; }); } |