Skip to content

feat: exact component match on item acceptors - #154

Merged
Ampflower merged 5 commits into
ModFest:26.3from
cassiancc:exact-component-match
Oct 17, 2026
Merged

Ampflower merged 5 commits into
ModFest:26.3from
cassiancc:exact-component-match

Conversation

@cassiancc

Copy link
Copy Markdown

This PR makes it possible for item acceptors to make exact component matches on the item stacks they accept. I opted to make the format for this the same as /give, relying on Minecraft's existing parsers for components. This meant switching the backing Identifier out for a String, as Identifier has strict restrictions on allowed characters that prevent even simple components from functioning.

Testing steps:

  1. Run /give @s minecraft:birch_planks[minecraft:item_model="diamond_sword"]
  2. Place an item acceptor set to birch_planks
  3. Place an item acceptor set to minecraft:birch_planks[minecraft:item_model="diamond_sword"]
  4. Try inserting regular birch planks in both acceptors. Only one will function.
  5. Try inserting the custom birch planks in both acceptors. Both will function, as one accepts any birch planks, and one accepts this exact match.

Fixes #89

@Ampflower Ampflower left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/clear-esk predicates aren't strictly required, but I noticed one issue that namespace:invalid_item[component="b"] would not be treated the same as namespace:invalid_item.

Ideally, if Minecraft can reasonably parse it normally, it is valid, even if the item or requested components does not currently exist.

Comment thread src/main/java/dev/hephaestus/glowcase/block/entity/ItemAcceptorBlockEntity.java Outdated
Comment thread src/main/java/dev/hephaestus/glowcase/block/entity/ItemAcceptorBlockEntity.java Outdated
Comment on lines +107 to +115
if (!Identifier.isValidPath(item)) {
return ItemStack.isSameItemSameComponents(stack, getDisplayItemStack()) && stack.getCount() >= count;
} else {
Identifier parse = Identifier.parse(item);
boolean isEqual = isItemTag
? stack.is(TagKey.create(Registries.ITEM, parse))
: stack.is(BuiltInRegistries.ITEM.getValue(parse));
return isEqual && stack.getCount() >= count;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This, might be better as a hotswapped cached Predicate?

@Ampflower
Ampflower merged commit edf8bad into ModFest:26.3 Oct 17, 2026
1 check passed
@cassiancc
cassiancc deleted the exact-component-match branch October 17, 2026 21:17
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.

Ability for Item Acceptors also read component data of items

2 participants