Interface Ingredient
What one grid slot of a recipe accepts, and how many of it the craft takes from that slot.
Vanilla always takes one item per slot. Here the count can be raised:
Ingredient.of(DIAMOND).withCount(16) only matches a slot holding at least sixteen
diamonds, and crafting takes sixteen of them.
Instances are immutable and safe to share between threads.
- Since:
- 0.1.0
-
Method Summary
Modifier and TypeMethodDescriptionbooleanaccepts(ItemStack stack, ItemTagLookup tags) intcount()static IngredientAccepts only stacks of the same item carrying the same components, which is how a plugin recognises its own custom items.static IngredientAccepts whateverpredicateaccepts.static Ingredientstatic Ingredientof(Collection<TypedKey<Item>> items) static Ingredientbooleantest(ItemStack stack, ItemTagLookup tags) Whether the item ofstackis accepted, regardless of how many there are.withCount(int newCount)
-
Method Details
-
of
- Parameters:
items- the items accepted, any of them will do- Returns:
- an ingredient taking one of any of
items - Throws:
IllegalArgumentException- ifitemsis empty- Since:
- 0.1.0
-
of
- Parameters:
items- the items accepted, any of them will do- Returns:
- an ingredient taking one of any of
items - Throws:
IllegalArgumentException- ifitemsis empty- Since:
- 0.1.0
-
tag
- Parameters:
tag- an item tag, e.g.minecraft:planks, without the leading#- Returns:
- an ingredient taking one of any item of the tag
- Since:
- 0.1.0
-
exact
Accepts only stacks of the same item carrying the same components, which is how a plugin recognises its own custom items. The count ofstackbecomes the count of the ingredient:Ingredient.exact(ruby.withCount(4))takes four rubies.- Parameters:
stack- the stack to compare against- Returns:
- an ingredient taking
stack.count()items similar tostack - Throws:
IllegalArgumentException- ifstackis empty- Since:
- 0.1.0
-
matching
Accepts whateverpredicateaccepts. The predicate sees the whole stack but must not look at its count: the count of the ingredient takes care of that.- Parameters:
predicate- tells whether a stack is accepted, never called with an empty stack- Returns:
- an ingredient taking one item accepted by
predicate - Since:
- 0.1.0
-
count
int count()- Returns:
- how many items one craft takes from the slot, at least
1 - Since:
- 0.1.0
-
withCount
- Parameters:
newCount- how many items one craft takes from the slot- Returns:
- an ingredient accepting the same items, in that quantity
- Throws:
IllegalArgumentException- ifnewCountis lower than1- Since:
- 0.1.0
-
test
Whether the item ofstackis accepted, regardless of how many there are.- Parameters:
stack- the stack to testtags- resolves tag ingredients- Returns:
truewhenstackis not empty and its item is accepted- Since:
- 0.1.0
-
accepts
- Parameters:
stack- the stack to testtags- resolves tag ingredients- Returns:
truewhen one craft can take its share fromstack- Since:
- 0.1.0
-