Skip to content

fix(Physics): Fixed the physics of loose snow with leather boots.#358

Open
Semleks wants to merge 2 commits into
adepierre:masterfrom
Semleks:feature/todo-physics
Open

fix(Physics): Fixed the physics of loose snow with leather boots.#358
Semleks wants to merge 2 commits into
adepierre:masterfrom
Semleks:feature/todo-physics

Conversation

@Semleks

@Semleks Semleks commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Hi!

This PR addresses the TODO for powder snow physics and wearing leather boots inside the PhysicsManager.

What changed:

  • Vanilla climbing logic: Implemented the mechanic where a player climbs upwards in powder snow at 0.2 speed when wearing leather boots and holding the jump key.
  • Registry-driven IDs: Added leather_boots_item initialization to the constructor via AssetsManager to prevent version-specific ID hardcoding.
  • Performance optimization:
    • Placed the inventory/slot checks behind a lazy evaluation guard (feet_block->IsPowderSnow()), meaning we only read the inventory and incur ref-count operations when the bot is actually standing in powder snow.

Let me know if this looks good to merge!

@adepierre adepierre left a comment

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.

Thanks for the PR. I added a few comments if you want to take a look.

Powder snow has other interactions with the boots that are currently not handled (going down to the next block top surface when crouching, walking on them without sinking).
Are you interested in adding these too or is this PR limited to just the up direction?
Also it might be a good idea to add dedicated physics tests for the powder snow physics to be sure the implementation is correct. Feel free to let me know if it's something you want to do.

player->speed.y = 0.2;
}

#if PROTOCOL_VERSION > 754 /* > 1.17+ */

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.

It should be > 1.17 without the + sign to be consistent with the repo

));

if (feet_block != nullptr && feet_block->IsPowderSnow()) {
const auto feet_slot = inventory_manager->GetPlayerInventory()->GetSlot(Window::INVENTORY_FEET_ARMOR);

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.

There's no reason to use auto here it's a ProtocolCraft::Slot and with the using namespace we can just use Slot.

static_cast<int>(std::floor(player->position.z))
));

if (feet_block != nullptr && feet_block->IsPowderSnow()) {

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 { should be on the next line to be consistent with the rest of the codebase.
Also the condition in java code is this.wasInPowderSnow, did you check that your feet block check is the exact same thing (i.e. feet block check only and without a tick delay)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants