Skip to content

[no squash] Improve building into spot dug same cycle - #133

Merged
SmallJoker merged 2 commits into
minetest-mods:masterfrom
j-r:build_into_dug_same_cycle
Aug 28, 2026
Merged

[no squash] Improve building into spot dug same cycle#133
SmallJoker merged 2 commits into
minetest-mods:masterfrom
j-r:build_into_dug_same_cycle

Conversation

@j-r

@j-r j-r commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

NOTE: this PR also includes two mostly unrelated changes, because they touch the same code, but I'll remove the second change if requested

Digging and building in the same cycle doesn't remove the dug node, but directly tries to place the new node. Unfortunately when the new node requires its custom on_place to be called this will often not work, because that on_place will typically check for the target position to be air or buildable_to which for a node dug in the same cycle mostly won't be the case.

There doesn't seem to be an issue for that, but it is easily reproduced using default:torch:

  • build a digtron with a builder directly behind a digger (i.e. both targeting the same position in a cycle)
  • configure the builder to place torches on the ground
  • run the digtron on flat ground and note that it places torches on the ground
  • place a stone in front of the digger, and start the digtron seeing that it removes the stone, but fails to place the torch (and a warning from core.item_place_node is logged)

This PR fixes this by explicitly removing the dug node before invoking on_place of the new node.

Now that the code knows whether it builds into a spot dug the same cycle, this PR also introduces a small, but neat feature: allow extrusion to be zero, meaning to only build, if the target position was dug the same cycle. This e.g. allows to use soft material digger to detect an unstable roof and have the builder seal it using stone, but not build a roof if there is air above (e.g. in a large cave). This change is really small, so I included it here, but I can submit it separately (if the fix is merged).

Comment thread util_item_place_node.lua Outdated
@SmallJoker SmallJoker changed the title Improve building into spot dug same cycle [no squash] Improve building into spot dug same cycle Aug 22, 2026
j-r and others added 2 commits August 28, 2026 14:54
This fixes failure to build nodes with on_place callbacks checking for air or
buildable_to (e.g. default:torch) into blocks that were dug in the same cycle.

Co-authored-by: SmallJoker <mk939@ymail.com>
@j-r
j-r force-pushed the build_into_dug_same_cycle branch from 0ee4c5e to 9af5c55 Compare August 28, 2026 12:56
@j-r

j-r commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Hopefully improved the comment. It is still a bit longer than your suggestion, because a reminder that the dug node isn't removed yet would have helped me back then.

@SmallJoker
SmallJoker merged commit 6f948b9 into minetest-mods:master Aug 28, 2026
1 check passed
@j-r
j-r deleted the build_into_dug_same_cycle branch August 28, 2026 15:26
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.

2 participants