Added a check if trapdoor is attached.

Just incase if neighborChanged is modified.
This commit is contained in:
disintegrate 2026-03-18 17:00:50 +08:00
parent 9983a74198
commit ab9a7ae831
2 changed files with 12 additions and 13 deletions

View file

@ -994,19 +994,15 @@ bool LivingEntity::onLadder()
return true; return true;
case Tile::trapdoor_Id: // hexagonny - add climbable (opened) trapdoors case Tile::trapdoor_Id: // hexagonny - add climbable (opened) trapdoors
{ {
int data = level->getData(xt, yt, zt); if ((level->getData(xt, yt, zt) & 0x4) != 0)
bool isOpen = (data & 0x4) != 0;
if (isOpen)
{ {
int aboveTile = level->getTile(xt, yt + 1, zt); switch (level->getTile(xt, yt + 1, zt))
int belowTile = level->getTile(xt, yt - 1, zt);
switch (aboveTile)
{ {
case Tile::ladder_Id: case Tile::ladder_Id:
case Tile::vine_Id: case Tile::vine_Id:
return false; // Opened trapdoor should only be climbable when it's only at the top. return false; // Opened trapdoor should only be climbable when it's only at the top.
default: default:
return belowTile == Tile::ladder_Id; return level->getTile(xt, yt - 1, zt) == Tile::ladder_Id;
} }
} }
break; break;

View file

@ -51,14 +51,17 @@ AABB *TrapDoorTile::getTileAABB(Level *level, int x, int y, int z)
AABB *TrapDoorTile::getAABB(Level *level, int x, int y, int z) AABB *TrapDoorTile::getAABB(Level *level, int x, int y, int z)
{ {
int data = level->getData(x, y, z); int data = level->getData(x, y, z);
bool isOpen = (data & 0x4) != 0; if (isOpen(data))
if (isOpen)
{ {
int belowTile = level->getTile(x, y - 1, z); int xt = x, zt = z;
if (belowTile == Tile::ladder_Id) if ((data & 3) == 0) zt++;
if ((data & 3) == 1) zt--;
if ((data & 3) == 2) xt++;
if ((data & 3) == 3) xt--;
if (level->getTile(x, y - 1, z) == Tile::ladder_Id && attachesTo(level->getTile(xt, y, zt)))
{ {
return nullptr; // No collision when open above ladder return nullptr; // No collision when open above ladder (add is attached to a block)
} }
} }
// Default behaviour // Default behaviour