From ca3954694f9ab678787aa18041f042fbc50889bc Mon Sep 17 00:00:00 2001 From: semleks Date: Wed, 8 Jul 2026 09:49:21 +0300 Subject: [PATCH 1/2] fix(Physics): Fixed the physics of loose snow with leather boots. --- .../botcraft/Game/Physics/PhysicsManager.hpp | 1 + botcraft/src/Game/Physics/PhysicsManager.cpp | 31 +++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/botcraft/include/botcraft/Game/Physics/PhysicsManager.hpp b/botcraft/include/botcraft/Game/Physics/PhysicsManager.hpp index 5dcb113da..974dabb48 100644 --- a/botcraft/include/botcraft/Game/Physics/PhysicsManager.hpp +++ b/botcraft/include/botcraft/Game/Physics/PhysicsManager.hpp @@ -115,6 +115,7 @@ namespace Botcraft std::thread thread_physics; // Thread running to compute position and send it to the server every tick const Item* elytra_item; + const Item* leather_boots_item; #if PROTOCOL_VERSION > 764 /* > 1.20.2 */ std::atomic ms_per_tick = 50.0; diff --git a/botcraft/src/Game/Physics/PhysicsManager.cpp b/botcraft/src/Game/Physics/PhysicsManager.cpp index fe88fab4c..2636cbeac 100644 --- a/botcraft/src/Game/Physics/PhysicsManager.cpp +++ b/botcraft/src/Game/Physics/PhysicsManager.cpp @@ -47,6 +47,12 @@ namespace Botcraft { throw std::runtime_error("Unknown item minecraft:elytra"); } + + leather_boots_item = AssetsManager::getInstance().GetItem("minecraft:leather_boots"); + if (leather_boots_item == nullptr) + { + throw std::runtime_error("Unknown item minecraft:leather_boots"); + } } PhysicsManager::~PhysicsManager() @@ -1280,8 +1286,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) 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(player->pitch * 0.017453292f /* PI/180 */)); const double cos_pitch_sqr = cos_pitch * cos_pitch; @@ -1353,12 +1359,31 @@ namespace Botcraft ApplyMovement(); // If colliding and in climbable, go up if ((player->horizontal_collision || player->inputs.jump) && - (player->on_climbable) // TODO: or in powder snow with leather boots + (player->on_climbable) ) { player->speed.y = 0.2; } +#if PROTOCOL_VERSION > 754 /* > 1.17+ */ + // If in powder snow with leather boots go up + + const Blockstate* feet_block = world->GetBlock(Position( + static_cast(std::floor(player->position.x)), + static_cast(std::floor(player->position.y)), + static_cast(std::floor(player->position.z)) + )); + + if (feet_block != nullptr && feet_block->IsPowderSnow()) { + const auto feet_slot = inventory_manager->GetPlayerInventory()->GetSlot(Window::INVENTORY_FEET_ARMOR); + + if ((player->horizontal_collision || player->inputs.jump) && feet_slot.GetItemId() == leather_boots_item->GetId()) + { + player->speed.y = 0.2; + } + } +#endif + unsigned char levitation = 0; for (const auto& effect : player->effects) { From 10f403fa26f6eb049ad49ecdbe4751bcafd59d8b Mon Sep 17 00:00:00 2001 From: semleks Date: Wed, 8 Jul 2026 10:10:52 +0300 Subject: [PATCH 2/2] fix(Physics): fixed encoding in comments --- botcraft/src/Game/Physics/PhysicsManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/botcraft/src/Game/Physics/PhysicsManager.cpp b/botcraft/src/Game/Physics/PhysicsManager.cpp index 2636cbeac..4f771d070 100644 --- a/botcraft/src/Game/Physics/PhysicsManager.cpp +++ b/botcraft/src/Game/Physics/PhysicsManager.cpp @@ -1286,8 +1286,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^2 + front_vector.z^2) to follow vanilla code + // it's equal to cos(pitch) (as -90°<=pitch<=90°, cos(pitch) >= 0.0) 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(player->pitch * 0.017453292f /* PI/180 */)); const double cos_pitch_sqr = cos_pitch * cos_pitch;