Skip to content

Colossal Chests 2: refuse chest cores carrying items in chests - #227

Open
rubensworks wants to merge 1 commit into
feature/1.21-lts-v2from
feature/1.21-lts-v2-no-nested-cores
Open

rubensworks wants to merge 1 commit into
feature/1.21-lts-v2from
feature/1.21-lts-v2-no-nested-cores

Conversation

@rubensworks

@rubensworks rubensworks commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

A chest core that holds items keeps them on its item when it is mined. Storing such a core in another chest nests the contents, and repeating that grows saved data without limit until the NBT overflows. This PR makes chests refuse those items.

Summary

  • What is refused: any item carrying a core's contents (the colossalchests2:chest_contents item component), and any item holding one inside vanilla containers: shulker boxes (minecraft:container) and bundles (minecraft:bundle_contents), at any depth. That closes the indirect route of a core in a shulker box in a chest.
  • Where: in ChestStorage.canAccept, which every insert path goes through (GUI clicks and shift-clicks, hoppers and other automation, the Display wall, the item handler's isItemValid; the Magnet wall in Colossal Chests 2, Phase 7: Magnet wall #226 inserts the same way), and in lockTo, since a locked slot stores its type with all components too.
  • Still allowed: empty cores, cores without contents (e.g. with only upgrades), and shulker boxes or bundles with other items.
  • Depth cap: items nested more than 8 containers deep are refused outright, so a crafted stack can't make the check itself expensive. Vanilla play never gets near that.
  • Detection by component id: the check compares the component's registry id instead of using the registered holder, so it also works where the mod's registries aren't loaded, such as unit tests. A game test asserts the id matches the real component.

Design notes

  • I did not stop filled cores from going into shulker boxes. Vanilla's hook for that (Item#canFitInsideContainerItems) applies to every stack of an item, so it would also forbid empty cores, and Fabric has no per-stack variant. Refusing on our side covers the recursion: a core's contents can never hold a filled core, directly or through vanilla containers.
  • Containers from other mods with their own item components are not inspected.

Validation

Criterion Covered by
A real filled core (from breaking a chest with stone) is refused by insert, insertAutomated, the item handler, and lockTo; a shulker box holding it and a bundle holding that shulker box are refused; an empty core and a shulker box with stone are accepted; the component id matches Game test testFilledCoresCanNotBeStored
Plain items and vanilla containers are allowed, nesting deeper than 8 is refused Unit tests TestNestedChests (3)

Totals: 293 unit tests; game tests Fabric 74, Forge 72, NeoForge 72, all passing.

In-game (clientdevbridge): script in clientdevbridge-screenshots/nested-cores. On NeoForge, a core carrying 100 stone (from breaking a real chest), a shulker box holding it, and a shulker box holding stone were shift-clicked into another chest. Read back from the world: only the stone shulker box was stored; the other two stayed in the inventory. No screenshots, as the result is in the state.

Known issues

  • No feedback: a refused shift-click silently does nothing, like any item the chest can't take. A tooltip line on filled cores could explain it; I'd do that with the Phase 9 tooltips.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RSz5r6eowhjNuANBjZE2v6

A chest core that holds items keeps them on its item when mined. Storing
such a core in another chest nests the contents, and doing that
repeatedly grows saved data without limit until it overflows. Chests now
refuse items that carry a core's contents, also inside shulker boxes and
bundles, through every insert path and for locking a slot to a type.
Empty cores and other containers are still accepted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RSz5r6eowhjNuANBjZE2v6
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