Skip to content

Commit

Permalink
* Fix a bug with pressure plates
Browse files Browse the repository at this point in the history
  • Loading branch information
iProgramMC committed Apr 8, 2024
1 parent 02f046e commit d3c87d3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions source/world/item/DoorItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ bool DoorItem::useOn(ItemInstance* inst, Player* player, Level* level, int x, in
faceDir = 4 + ((faceDir - 1) & 3);

// congratulations! You can now have a door.
level->field_30 = true;
level->setTile(x, y + 1, z, pTile->m_ID);
level->setData(x, y + 1, z, faceDir);
level->field_30 = false;
level->setTile(x, y + 2, z, pTile->m_ID);
level->setData(x, y + 2, z, faceDir + 8);
inst->m_amount--;
Expand Down
5 changes: 5 additions & 0 deletions source/world/tile/DoorTile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ void DoorTile::neighborChanged(Level* level, int x, int y, int z, int newTile)
if (level->hasNeighborSignal(x, y, z) || level->hasNeighborSignal(x, y + 1, z))
bOpen = true;

// NOTE: If you're wondering why placing redstone next to a door in the formation
// where two doors are side by side, facing each other (handle in the middle), opens
// the right door, that's because there's only four bits in the state, and the bits
// are all used (bit 3 is "top", bit 2 is "open", bits 1 and 0 are direction)
// Oh well...
setOpen(level, x, y, z, bOpen);
}
}
5 changes: 2 additions & 3 deletions source/world/tile/PressurePlateTile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,15 @@ void PressurePlateTile::updateShape(LevelSource* level, int x, int y, int z)
setShape(0.0625f, 0.0f, 0.0625f, 0.9375f, 0.0625f, 0.9375f);
}

void PressurePlateTile::destroy(Level* level, int x, int y, int z, int pdir)
void PressurePlateTile::destroy(Level* level, int x, int y, int z, int data)
{
int data = level->getData(x, y, z);
if (data > 0)
{
level->updateNeighborsAt(x, y, z, m_ID);
level->updateNeighborsAt(x, y - 1, z, m_ID);
}

Tile::destroy(level, x, y, z, pdir);
Tile::destroy(level, x, y, z, data);
}

int PressurePlateTile::getSignal(LevelSource* level, int x, int y, int z, int dir)
Expand Down

0 comments on commit d3c87d3

Please sign in to comment.