Skip to content

Improve assembly block handling to prevent item duplication#632

Open
SAILQAQ wants to merge 1 commit intoryanhcode:mainfrom
SAILQAQ:main
Open

Improve assembly block handling to prevent item duplication#632
SAILQAQ wants to merge 1 commit intoryanhcode:mainfrom
SAILQAQ:main

Conversation

@SAILQAQ
Copy link
Copy Markdown

@SAILQAQ SAILQAQ commented Apr 29, 2026

Two fixes combined:

  1. From Fix for #48 (items duping upon assembly/disassembly) #365: Replace old blocks with barriers before removal. This prevents brittle blocks (torches, buttons, etc.) from breaking when their supportblock is removed, which could also cause duplication.

  2. New fix: After saving BE NBT, call level.removeBlockEntity() to detach the block entity from the world before it can drop items. Then destroy barriers via level.setBlock() with UPDATE_MOVE_BY_PISTON | UPDATE_SUPPRESS_DROPS | UPDATE_CLIENTS — the same approach Create uses in its contraption system.

Two fixes combined:
1. From pr-365: Replace old blocks with barriers before removal. This prevents brittle blocks (torches, buttons, etc.) from breaking when their supportblock is removed, which could also cause duplication.

2. New fix: After saving BE NBT, call level.removeBlockEntity() to detach the block entity from the world before it can drop items. Then destroy barriers via level.setBlock() with UPDATE_MOVE_BY_PISTON | UPDATE_SUPPRESS_DROPS | UPDATE_CLIENTS — the same approach Create uses in its contraption system.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 29, 2026

CLA assistant check
All committers have signed the CLA.

@SAILQAQ SAILQAQ changed the title Fix item duplication when assembling block entities into sub-levels Improve assembly block handling to prevent item duplication Apr 29, 2026
@SAILQAQ
Copy link
Copy Markdown
Author

SAILQAQ commented Apr 29, 2026

This should fix the duplication issues for most modded containers (those that don't implement Clearable) and attachable blocks.

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