Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I added the durability bar to tools to replace the original randomly-broken logic.
Earlier discussion is in issues/172
When I was playing Minecraft, I have a principle that only let one of my pickaxes has it's durability bar. in other words, keep the extra tools completely new. But if the tools even don't have the durability bar and just broken randomly, it really makes me uneasy. Sometimes, I even think I was playing Terraria! That's why I made this pull request.
In this pull request, I used the amount of tool (inventory_count field) to store the durability message. In Minecraft, the tools can only have one in each slot, which means the inventory_count field of a tool is always set to a meaningless number 1. I just made the number 1 means the full durability when the number 255 means the tool should broken. It causes no extra memory usage but preformed well.
Accordingly, I also made the following changes:
Since the inventory_count field only ranging from 0 to 255, it is not enough to store the exact durability. Considered that what I have added is just a durability bar rather than the number of the durability, I made the durability decreased randomly. While not pixel-perfect, it's statistically accurate. As long as you isn't boring enough to count how many blocks a pickaxe can break, It is completely same as the vanilla Minecraft.
This is my first github pull request. If my pull request is incorrect or has any issues, I’m happy to make corrections.
Thank you for creating and maintaining such an inspiring project. I’d be grateful if you could take a moment to review.