Skip to content

Make it possible to specify that a block should be destroyed/dropped when replaced by another block#2990

Open
DellieDelta wants to merge 5 commits intoPixelGuys:masterfrom
DellieDelta:block-drop-on-crush
Open

Make it possible to specify that a block should be destroyed/dropped when replaced by another block#2990
DellieDelta wants to merge 5 commits intoPixelGuys:masterfrom
DellieDelta:block-drop-on-crush

Conversation

@DellieDelta
Copy link
Copy Markdown
Contributor

Progress towards #1558

It's a little bit of a workaround because we don't have something like BreakBlock or ReplaceBlock yet instead of UpdateBlock, but it should be easy enough to pull apart when the time comes

Most relevant changes are in the first commit :)

@Wunka Wunka moved this to High Priority in PRs to review Apr 29, 2026
Comment thread src/blocks.zig
Comment on lines +74 to +77
const Replaceability = enum {
none,
destroy,
drop,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We might as well

Suggested change
const Replaceability = enum {
none,
destroy,
drop,
const Replaceability = enum {
no,
yes,
yesWithDrop,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In my opinion the original names are clearer and more extensible. For example if you want to add a fourth mode in the future that does something very different

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  1. Future proofing doesn't work. A simple example of extension would be to add support for different drop than usually is dropped when block is broken. That would require you to use union instead of enum, a major refactor either way.
  2. Similar pattern was already established in rotation.RotationMode.CanBeChangedInto

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeahhh, you're right. Next to yes or no I don't see it getting a "maybe" loll, unless we go to a more complex structure anyway. That makes it more like a property with subproperties kind of, but with enums you can just make it flat

Comment thread src/blocks.zig
_degradable[size] = zon.get(bool, "degradable", false);
_selectionRule[size] = zon.get(SelectionRule, "selectionRule", .always);
_replaceable[size] = zon.get(bool, "replaceable", false);
_replaceability[size] = zon.get(Replaceability, "replaceability", .none);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Its a property, it should be adjective, not a noun

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I see it more like a mode of replacement, then a noun makes more sense I think

@Wunka Wunka moved this from High Priority to Low Priority in PRs to review Apr 30, 2026
@Argmaster
Copy link
Copy Markdown
Collaborator

So, overall I am not sure if this is flexible enough. What if instead we would support multiple onUpdate callbacks?
We will have to go somewhat this route anyway.

Also I see either vine_decay (by me) or other callbacks violate naming convention... Sorry for that

@DellieDelta
Copy link
Copy Markdown
Contributor Author

Interestingg, you'd almost need like an onReplace callback where you can say that it should drop an item, or at least some way to do that within onUpdate. It might be a bit overkill for now, but on the other hand you don't want to introduce a configuration like yesWithDrop only to remove it later again anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Low Priority

Development

Successfully merging this pull request may close these issues.

3 participants