Skip to content
Open
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
31 changes: 26 additions & 5 deletions botcraft/src/Game/Physics/PhysicsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1171,9 +1171,30 @@ namespace Botcraft
static_cast<int>(std::floor(player->position.z))
));

// TODO: if trapdoor AND below block is a ladder with the same facing property
// as the trapdoor then the trapdoor is a climbable block too
return feet_block != nullptr && feet_block->IsClimbable();
if (feet_block != nullptr && feet_block->IsClimbable())
return true;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if body should be between {} to be consistent with the rest of the repo.


if (feet_block != nullptr && feet_block->GetName().find("trapdoor") != std::string::npos)
{
if (feet_block->GetVariableValue("open") == "true")
{
const Blockstate* below_block = world->GetBlock(Position(
static_cast<int>(std::floor(player->position.x)),
static_cast<int>(std::floor(player->position.y)) - 1,
static_cast<int>(std::floor(player->position.z))
));

if (below_block != nullptr && below_block != nullptr && below_block->GetName().find("ladder") != std::string::npos)
{
if (feet_block->GetVariableValue("facing") == below_block->GetVariableValue("facing"))
{
return true;
}
}
}
}

return false;
}

void PhysicsManager::MovePlayer() const
Expand Down Expand Up @@ -1280,8 +1301,8 @@ namespace Botcraft
// Move with elytra
else if (player->GetDataSharedFlagsIdImpl(EntitySharedFlagsId::FallFlying))
{
// sqrt(front_vector.x� + front_vector.z�) to follow vanilla code
// it's equal to cos(pitch) (as -90�<=pitch<=90�, cos(pitch) >= 0.0)
// sqrt(front_vector.x� + front_vector.z�) to follow vanilla code
// it's equal to cos(pitch) (as -90�<=pitch<=90�, cos(pitch) >= 0.0)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have some encoding issues similar to the ones in your other PR.

const double cos_pitch_from_length = std::sqrt(player->front_vector.x * player->front_vector.x + player->front_vector.z * player->front_vector.z);
const double cos_pitch = std::cos(static_cast<double>(player->pitch * 0.017453292f /* PI/180 */));
const double cos_pitch_sqr = cos_pitch * cos_pitch;
Expand Down