-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
First look at block hardness & blast resistance autogen #6629
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: minor-next
Are you sure you want to change the base?
Conversation
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. |
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 |
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. |
Good work |
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.
The ambition behind one constant per block seems OK to me. The question of wood seems to me to be one to be asked when Mojang has decided to separate the game, for later.
I thought this was a good idea originally, but after seeing the changes it requires I think it's a bad idea to go forward. I think we'd be better with a unit test to not have to add a bunch of noise to the code or use the constants in weird ways. |
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 producesBlockHardnessValues
andBlockBlastResistanceValues
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.