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

First look at block hardness & blast resistance autogen #6629

Open
wants to merge 1 commit into
base: minor-next
Choose a base branch
from

Conversation

ipad54
Copy link
Member

@ipad54 ipad54 commented Feb 15, 2025

This PR implements block hardness & blast resistance autogeneration from BedrockData block properties table to make sure the values are always up to date because of Mojang frequent changes.

Changes

Added build\generate-block-break-info.php tool which produces BlockHardnessValues and BlockBlastResistanceValues classes in \pocketmine\data\bedrock\block.

VanillaBlocks now always refers to hardness & blast resistance constant values in these classes when registering a block. However, if a block is indestructible in the game, I don't use the hardness value and only the blast resistance one. I did this because some obvious indestructible blocks (like water and lava) have positive hardness which can be exploited by hackers to destroy them in survival.

Tests

This has been briefly tested in the game. I didn't notice any behaviour changes with block breaking and explosions.

@ipad54 ipad54 requested a review from a team as a code owner February 15, 2025 19:46
@dktapps
Copy link
Member

dktapps commented Feb 16, 2025

Good work on this so far.

I didn't realize how much this was going to suck for shared properties though. Since we have constants for every block, we're not able to share break infos between different blocks. That's made me hesitate with this.

@ipad54
Copy link
Member Author

ipad54 commented Feb 16, 2025

Yes, but we don't actually know about Mojang plans, maybe they will add its own hardness to every block in the same group. Moreover, I've found some TODOs about this. The only thing I didn't solve yet is wood type hardness registration. It seems like we will have to return something like WoodLikeBlockIdHelper but with hardness & blast resistance, but for now all wood blocks use oak values until we discuss what to do about this.

@dktapps
Copy link
Member

dktapps commented Feb 16, 2025

It seems like we will have to return something like WoodLikeBlockIdHelper but with hardness & blast resistance, but for now all wood blocks use oak values until we discuss what to do about this.

I really don't want to go down that road. I'm starting to see why you wanted to unit-test this instead of doing it this way.

@dktapps dktapps added Category: Core Related to internal functionality Type: Enhancement Contributes features or other improvements to PocketMine-MP labels Feb 17, 2025
@ShockedPlot7560
Copy link
Member

Good work
I hope for your mind that you've managed to find an easy way to replace the VanillaBlock :/
It's sad for wood, but adding another class with mapping doesn't seem like a very good solution, especially if we want to withdraw from this type of class.
Having one constant per block doesn't shock me that much. It allows more flexibility if mojang decides to change the hardness separately for groups of blocks, as ipad says.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Core Related to internal functionality 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