Skip to content

Allow making component changes conditional on predicates (fixes empty shulker box stacking)#20

Open
0x4e49434f4c45 wants to merge 3 commits intoboyonk913:masterfrom
0x4e49434f4c45:predicates_1.2_rebase
Open

Allow making component changes conditional on predicates (fixes empty shulker box stacking)#20
0x4e49434f4c45 wants to merge 3 commits intoboyonk913:masterfrom
0x4e49434f4c45:predicates_1.2_rebase

Conversation

@0x4e49434f4c45
Copy link
Copy Markdown
Contributor

@0x4e49434f4c45 0x4e49434f4c45 commented Jul 12, 2025

Fixes #13

This change allows datapacks to specify a predicate in addition to an item or tag, which is evaluated before applying the changes.

The motivating use case is to allow only empty shulker boxes to stack. The existing implementation supports stacking shulker boxes, but also allows stacking full shulker boxes if their contents match. With this change, a predicate can be used to modify the shulker box max stack size only if the box is empty. But because predicates are used, any condition can be applied which can be expressed as a predicate.

The approach in this PR is to apply conditional changes (those that contain predicates) at the ItemStack level instead of the Item level. Unconditional changes (those without predicates) are still applied at the Item level to avoid taking any performance penalty. That being said, this change set has been used to implement stackable empty shulker boxes on the tech server I run for the last year without any measurable performance impact.

UPDATE: This PR now also updates the pack.mcmeta files for compatibility with Minecraft 1.21.9+.

@motyI
Copy link
Copy Markdown

motyI commented Feb 7, 2026

@0x4e49434f4c45 how does one download this fork as a mod, and what is the correct syntax for specifying custom components? since the mod author is currently silent i doubt they will merge the pr and release the update anytime soon

@0x4e49434f4c45
Copy link
Copy Markdown
Contributor Author

You can download/clone the forked repo and then just run gradlew.bat build (Windows) or ./gradlew build (Mac/Linux). The .jar file will show up under build/libs.

I'm not sure what you mean by your second question, but the datapacks folder has plenty of examples. If you're asking how to use the new predicate feature, the file datapacks/stackable_shulker_boxes/data/stackable_shulker_boxes/item_components/shulker_boxes.json shows an example.

@motyI
Copy link
Copy Markdown

motyI commented Feb 7, 2026

That is precisely what I meant, I must have missed the edits made to the shulker boxes datapack in this PR. Thank you and have a good one

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.

Feature Request: Conditions

2 participants