Skip to content
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

Block break progress improvement #6500

Open
wants to merge 15 commits into
base: minor-next
Choose a base branch
from

Conversation

GameParrot
Copy link
Contributor

Fixes block break progress being inaccurate when not on ground or swimming. Also fixes syncing block break speed with client.

Related issues & PRs

Changes

API changes

Added Player::isActuallyOnGround(), more accurate than Player::isOnGround() but slower.

Behavioural changes

Block breaking progress is now much closer to vanilla.

In-Game Testing

Before:
https://github.com/user-attachments/assets/22f50b6e-f994-4a17-8dfc-53df70a8d6eb
After:
https://github.com/user-attachments/assets/3341eaaf-2bbc-4ac1-ad35-39947e907080

@GameParrot GameParrot requested a review from a team as a code owner November 13, 2024 15:45
@dktapps
Copy link
Member

dktapps commented Nov 13, 2024

Duplicates #5581

@dktapps
Copy link
Member

dktapps commented Nov 14, 2024

@GameParrot what's your source of information for the data in this PR?

@dktapps dktapps added Category: Gameplay Related to Minecraft gameplay experience Type: Enhancement Contributes features or other improvements to PocketMine-MP Status: Insufficiently Tested labels Nov 14, 2024
@GameParrot
Copy link
Contributor Author

@GameParrot what's your source of information for the data in this PR?

Haste speed modifier was from the wiki, mining fatigue speed modifier was found by testing (wiki numbers inaccurate)

@dktapps
Copy link
Member

dktapps commented Nov 15, 2024

I'd test those thoroughly if I were you. The last guy that tried to do this in #5581 couldn't get them to fully match up, not with wiki sources and not by guesswork either.

Even better if you can pull up an old BDS in IDA and find the code that handles this in vanilla.

@GameParrot
Copy link
Contributor Author

I'd test those thoroughly if I were you. The last guy that tried to do this in #5581 couldn't get them to fully match up, not with wiki sources and not by guesswork either.

Even better if you can pull up an old BDS in IDA and find the code that handles this in vanilla.

Haste and mining fatigue seem pretty much perfect from my testing (tested with both low and high levels)

src/player/SurvivalBlockBreakHandler.php Outdated Show resolved Hide resolved
src/player/SurvivalBlockBreakHandler.php Outdated Show resolved Hide resolved
@GameParrot GameParrot requested a review from dktapps November 19, 2024 02:20
/**
* Checks if the player is currently on the ground. This is more accurate than {@link Player::isOnGround()} but slower.
*/
public function isActuallyOnGround() : bool{
Copy link
Member

Choose a reason for hiding this comment

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

Something like calculate or smth in the name can be better than this function combined with docs ?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I'm not a fan of this naming either. Also, why do we actually need this?

Copy link
Contributor Author

@GameParrot GameParrot Nov 21, 2024

Choose a reason for hiding this comment

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

Yeah, I'm not a fan of this naming either. Also, why do we actually need this?

We need it because when using the normal is on ground method the break progress indicator is still too fast when jumping. What should it be renamed to?

Copy link
Member

Choose a reason for hiding this comment

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

Sounds like that warrants investigation into regular onGround behaviour.

Copy link
Member

Choose a reason for hiding this comment

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

Legend has it that PlayerAuthInputPacket should allow making onGround checks more accurate, so this hack wouldn't be needed anymore.

Copy link
Member

Choose a reason for hiding this comment

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

I think the PR should use the built-in onGround for now. It doesn't make sense to add an extra function specifically for this.

Once the proper onGround is fixed per #6547 we won't need this workaround. I don't like adding stuff to the API that we know we're gonna delete anyway.

src/player/Player.php Outdated Show resolved Hide resolved
src/player/SurvivalBlockBreakHandler.php Show resolved Hide resolved
src/player/SurvivalBlockBreakHandler.php Show resolved Hide resolved
src/player/SurvivalBlockBreakHandler.php Show resolved Hide resolved
@@ -869,7 +869,7 @@ static function() : void{
* Checks if the player is currently on the ground. This is more accurate than {@link Player::isOnGround()} but slower.
*/
public function isActuallyOnGround() : bool{
$bb = $this->boundingBox->expandedCopy(0, 0.001, 0);
$bb = $this->boundingBox->expandedCopy(-0.001, 0.001, -0.001);
Copy link
Member

Choose a reason for hiding this comment

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

This change doesn't look related to the PR. Why would this be needed for ground calculation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixes inaccurate progress at high x/z coordinates

Copy link
Member

Choose a reason for hiding this comment

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

Many things break down at large coordinates. I doubt this is the proper fix for the problem.

Copy link
Member

@dktapps dktapps left a comment

Choose a reason for hiding this comment

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

Please change this to use the normal onGround() and remove isActuallyOnGround().

Fixing onGround() needs to be done separately from this change as it affects a variety of other functions and the way this PR is doing it isn't the right way.

Including this change in here is blocking the PR.

@dktapps dktapps added Status: Waiting on Author and removed Status: Blocked Depends on other changes which are yet to be completed labels Jan 8, 2025
Copy link

This PR has been marked as "Waiting on Author", but we haven't seen any activity in 7 days.

If there is no further activity, it will be closed in 28 days.

Note for maintainers: Adding an assignee to the PR will prevent it from being marked as stale.

@github-actions github-actions bot added the Stale label Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Gameplay Related to Minecraft gameplay experience Stale Status: Insufficiently Tested Status: Waiting on Author Type: Enhancement Contributes features or other improvements to PocketMine-MP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants