Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions Minecraft.World/LivingEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -986,9 +986,31 @@ bool LivingEntity::onLadder()
int yt = Mth::floor(bb->y0);
int zt = Mth::floor(z);

// 4J-PB - TU9 - add climbable vines
int iTile = level->getTile(xt, yt, zt);
return (iTile== Tile::ladder_Id) || (iTile== Tile::vine_Id);
switch (iTile)
{
case Tile::ladder_Id:
case Tile::vine_Id: // 4J-PB - TU9 - add climbable vines
return true;
case Tile::trapdoor_Id: // hexagonny - add climbable (opened) trapdoors
{
if ((level->getData(xt, yt, zt) & 0x4) != 0)
{
switch (level->getTile(xt, yt + 1, zt))
{
case Tile::ladder_Id:
case Tile::vine_Id:
return false; // Opened trapdoor should only be climbable when it's only at the top.
default:
return level->getTile(xt, yt - 1, zt) == Tile::ladder_Id;
}
}
break;
}
default:
break;
}
return false;
}

bool LivingEntity::isShootable()
Expand Down
25 changes: 24 additions & 1 deletion Minecraft.World/TrapDoorTile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "net.minecraft.world.level.tile.h"
#include "net.minecraft.h"
#include "TrapDoorTile.h"

#include "AABB.h"

TrapDoorTile::TrapDoorTile(int id, Material *material) : Tile(id, material,isSolidRender())
{
Expand Down Expand Up @@ -50,6 +50,29 @@ AABB *TrapDoorTile::getTileAABB(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);
if (isOpen(data))
{
int xt = x, zt = z;
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)))
{
float r = 2 / 16.0f; // From LadderTile

int dir = data & 3;

// Using only newTemp from AABB to just manipulate collision to our liking
if (dir == 0) return AABB::newTemp(x + 0, y + 0, z + 1 - r, x + 1, y + 1, z + 1);
if (dir == 1) return AABB::newTemp(x + 0, y + 0, z + 0, x + 1, y + 1, z + r);
if (dir == 2) return AABB::newTemp(x + 1 - r, y + 0, z + 0, x + 1, y + 1, z + 1);
if (dir == 3) return AABB::newTemp(x + 0, y + 0, z + 0, x + r, y + 1, z + 1);
}
}
// Default behaviour
updateShape(level, x, y, z);
return Tile::getAABB(level, x, y, z);
}
Expand Down
Loading