-
Notifications
You must be signed in to change notification settings - Fork 60
fix(Physics): Fixed the physics of loose snow with leather boots. #358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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^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<double>(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<int>(std::floor(player->position.x)), | ||
| static_cast<int>(std::floor(player->position.y)), | ||
| static_cast<int>(std::floor(player->position.z)) | ||
| )); | ||
|
|
||
| if (feet_block != nullptr && feet_block->IsPowderSnow()) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The { should be on the next line to be consistent with the rest of the codebase. |
||
| const auto feet_slot = inventory_manager->GetPlayerInventory()->GetSlot(Window::INVENTORY_FEET_ARMOR); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no reason to use auto here it's a ProtocolCraft::Slot and with the using namespace we can just use Slot. |
||
|
|
||
| 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) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be > 1.17 without the + sign to be consistent with the repo