Skip to content

Refactor block dropping when breaking block with a tool - #3533

Merged
IntegratedQuantum merged 19 commits into
PixelGuys:masterfrom
DellieDelta:with-item-blockdrop-refactor
Aug 26, 2026
Merged

Refactor block dropping when breaking block with a tool#3533
IntegratedQuantum merged 19 commits into
PixelGuys:masterfrom
DellieDelta:with-item-blockdrop-refactor

Conversation

@DellieDelta

Copy link
Copy Markdown
Contributor

Related to #3532

Progress towards #2385

@IntegratedQuantum IntegratedQuantum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think this is the right place for this functionality. blocks.zig is already a big file and so far it has mostly definitions of block properties and loading/access thereof, but little functionality (and all functions on Block are retrieving properties, none are actually doing things).

In the issue I proposed to move them to the server world, which is also maybe a bit too big right now.

So maybe the BlockDrop struct deserves its own file (and in server, since blockdrops are not done on the client). And all the helper structs and functions (including #3532) could be defined there.

@DellieDelta

Copy link
Copy Markdown
Contributor Author

I agree. I'll make a new PR for moving BlockDrop to its own file then because it applies to both changes

@DellieDelta
DellieDelta marked this pull request as draft August 20, 2026 16:12
IntegratedQuantum pushed a commit that referenced this pull request Aug 20, 2026
@DellieDelta
DellieDelta force-pushed the with-item-blockdrop-refactor branch from 369b410 to c54395f Compare August 20, 2026 18:15
@DellieDelta
DellieDelta marked this pull request as ready for review August 20, 2026 18:30
@DellieDelta
DellieDelta marked this pull request as draft August 20, 2026 18:31
@DellieDelta
DellieDelta marked this pull request as ready for review August 20, 2026 18:31
@Wunka Wunka moved this to Easy to Review in PRs to review Aug 21, 2026
Comment thread src/blocks.zig Outdated
@IntegratedQuantum IntegratedQuantum moved this from Easy to Review to In review in PRs to review Aug 21, 2026
Comment thread src/server/BlockDrop.zig Outdated
const dropAmount = self.oldBlock.mode().itemDropsOnChange(self.oldBlock, self.newBlock);
if (dropAmount == 0) return;

if (self.item) |item| {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This now only drops anything if it was broken by an item (i.e. no apples)

Comment thread src/server/BlockDrop.zig Outdated
return true;
}

pub fn tryDropWhenBrokenWithItem(self: @This(), item: Item, pos: Vec3d, dir: Vec3f, velocity: f32) void {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this name is rather awkward, also in my option the item should be checked at the callsite instead.

Comment thread src/server/BlockDrop.zig Outdated
@IntegratedQuantum
IntegratedQuantum merged commit 8c77a12 into PixelGuys:master Aug 26, 2026
1 check passed
@DellieDelta
DellieDelta deleted the with-item-blockdrop-refactor branch August 26, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants