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

Fix blocks only harvestable with tool not dropping item on last tool use #108

Merged
merged 1 commit into from
Oct 24, 2024

Conversation

zavdav
Copy link
Contributor

@zavdav zavdav commented Oct 23, 2024

When a block that can only be harvested with a tool (e.g. stone can only be harvested with a pickaxe) is broken and the tool is at 0 durability, nothing is dropped. This is because the tool is deleted before the server can check if the right tool is used to break the block in order to harvest it. This pull request fixes this.

...
ItemStack itemstack = this.player.G(); //get item in hand

        if (flag && this.player.b(Block.byId[l])) { //can player harvest block
            Block.byId[l].a(this.world, this.player, i, j, k, i1); //harvest block
            ((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.world));
        }

        if (itemstack != null) {
            itemstack.a(l, i, j, k, this.player); //increment statistic for tool usage
            if (itemstack.count == 0) {
                itemstack.a(this.player); //does literally nothing
                this.player.H(); //delete item
            }
        }
...

@AleksandarHaralanov
Copy link
Contributor

#55

Copy link
Member

@RhysB RhysB left a comment

Choose a reason for hiding this comment

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

Small change, tested by Zavdav

Copy link
Member

@RhysB RhysB left a comment

Choose a reason for hiding this comment

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

Small change, tested by Zavdav

@RhysB RhysB merged commit a6f0278 into retromcorg:master Oct 24, 2024
2 checks passed
@zavdav zavdav deleted the lastusefix branch October 29, 2024 20:42
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.

3 participants