summaryrefslogtreecommitdiffstats
path: root/src/Simulator/IncrementalRedstoneSimulator/HopperHandler.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Simulator/IncrementalRedstoneSimulator/HopperHandler.h')
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/HopperHandler.h19
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;
});
}