Browse Source

Fix doors and trapdoors closing on server restart

master
Peter Bell 2 years ago
committed by Tiger Wang
parent
commit
fa917259a5
  1. 4
      src/Simulator/IncrementalRedstoneSimulator/DoorHandler.h
  2. 4
      src/Simulator/IncrementalRedstoneSimulator/SmallGateHandler.h

4
src/Simulator/IncrementalRedstoneSimulator/DoorHandler.h

@ -40,9 +40,11 @@ namespace DoorHandler
Power = std::max(Power, Callback.Power);
cChunkInterface ChunkInterface(a_Chunk.GetWorld()->GetChunkMap());
// Use redstone data rather than block state so players can override redstone control
const auto Previous = DataForChunk(a_Chunk).ExchangeUpdateOncePowerData(a_Position, Power);
const bool IsOpen = (Previous != 0);
const bool ShouldBeOpen = Power != 0;
const auto AbsolutePosition = cChunkDef::RelativeToAbsolute(a_Position, a_Chunk.GetPos());
const bool IsOpen = cBlockDoorHandler::IsOpen(ChunkInterface, AbsolutePosition);
if (ShouldBeOpen != IsOpen)
{

4
src/Simulator/IncrementalRedstoneSimulator/SmallGateHandler.h

@ -22,8 +22,10 @@ namespace SmallGateHandler
{
// LOGD("Evaluating gateydory the fence gate/trapdoor (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
// Use redstone data rather than block state so players can override redstone control
const auto Previous = DataForChunk(a_Chunk).ExchangeUpdateOncePowerData(a_Position, Power);
const bool IsOpen = (Previous != 0);
const bool ShouldBeOpen = Power != 0;
const bool IsOpen = (a_Meta & 0x4) == 0x4;
if (ShouldBeOpen != IsOpen)
{

Loading…
Cancel
Save