Class ShapelessGroupRecipe
-
- All Implemented Interfaces:
-
io.github.sakaki_aruka.customcrafter.recipe.CRecipe,io.github.sakaki_aruka.customcrafter.recipe.UnPartialSearchableRecipe
public class ShapelessGroupRecipe implements CRecipe, UnPartialSearchableRecipe
Implementation of CRecipe.
This recipe only provides CRecipe.Type.SHAPELESS.
This is the SHAPELESS counterpart of GroupRecipe: groups states, for each set of recipe slots, how many of them must actually be matched to an input item (MatchGroup.min to MatchGroup.max). Unlike GroupRecipe, no
Material.AIRplaceholder candidate is needed to express "this slot may stay unmatched" — SHAPELESS matching has no concept of position, so an unmatched slot is simply absent from the resulting relation. The min/max bounds are enforced structurally by the matching itself (see io.github.sakaki_aruka.customcrafter.search.Search), so — again unlike GroupRecipe — no extra CRecipePredicate safety net is auto-appended here.- Since:
5.3.0
-
-
Field Summary
Fields Modifier and Type Field Description private final Stringnameprivate final Map<CoordinateComponent, CMatter>itemsprivate final Set<MatchGroup>groupsprivate final List<CRecipePredicate>predicatesprivate final List<ResultSupplier>resultsprivate final CRecipe.Typetype
-
Constructor Summary
Constructors Constructor Description ShapelessGroupRecipe(String name, Map<CoordinateComponent, CMatter> items, Set<MatchGroup> groups, List<CRecipePredicate> predicates, List<ResultSupplier> results)ShapelessGroupRecipe(String name, Map<CoordinateComponent, CMatter> items, Set<MatchGroup> groups, List<CRecipePredicate> predicates)ShapelessGroupRecipe(String name, Map<CoordinateComponent, CMatter> items, Set<MatchGroup> groups)
-
Method Summary
Modifier and Type Method Description StringgetName()Map<CoordinateComponent, CMatter>getItems()final Set<MatchGroup>getGroups()List<CRecipePredicate>getPredicates()List<ResultSupplier>getResults()CRecipe.TypegetType()Type of this recipe. List<MatchGroup>matchGroups()Groups of recipe slots used by CRecipe.Type.SHAPELESS matching. UnitisValidRecipe()Validates this CRecipe. final static Set<MatchGroup>createGroups(Map<CoordinateComponent, CMatter> items, Set<MatchGroup> missingGroups)Creates a collection of MatchGroups, which are grouping settings that can be set in ShapelessGroupRecipe.groups. final static UnitisValidGroups(Set<MatchGroup> groups, Map<CoordinateComponent, CMatter> items)Validates the specified group set against the items mapping. -
Methods inherited from class io.github.sakaki_aruka.customcrafter.recipe.CRecipe
asyncGetRecipePredicateResults, asyncGetResults, firstFailedRecipePredicate, getRecipePredicateResults, getResults, getTimes, requiresInputItemAmountMax, requiresInputItemAmountMin -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
ShapelessGroupRecipe
ShapelessGroupRecipe(String name, Map<CoordinateComponent, CMatter> items, Set<MatchGroup> groups, List<CRecipePredicate> predicates, List<ResultSupplier> results)
- Parameters:
name- Name of this recipeitems- Item mapping.groups- Groups covering every coordinate in items.predicates- Additional predicates.results- ResultSupplier list
-
ShapelessGroupRecipe
ShapelessGroupRecipe(String name, Map<CoordinateComponent, CMatter> items, Set<MatchGroup> groups, List<CRecipePredicate> predicates)
- Parameters:
name- Name of this recipeitems- Item mapping.groups- Groups covering every coordinate in items.predicates- Additional predicates.
-
ShapelessGroupRecipe
ShapelessGroupRecipe(String name, Map<CoordinateComponent, CMatter> items, Set<MatchGroup> groups)
- Parameters:
name- Name of this recipeitems- Item mapping.groups- Groups covering every coordinate in items.
-
-
Method Detail
-
getItems
Map<CoordinateComponent, CMatter> getItems()
-
getGroups
final Set<MatchGroup> getGroups()
-
getPredicates
List<CRecipePredicate> getPredicates()
-
getResults
List<ResultSupplier> getResults()
-
getType
CRecipe.Type getType()
Type of this recipe. See CRecipe.Type.
-
matchGroups
List<MatchGroup> matchGroups()
Groups of recipe slots used by CRecipe.Type.SHAPELESS matching.
Each MatchGroup states how many of its members must actually be filled by an input item; a slot whose coordinate is not covered is simply never assigned an input, no
Material.AIRplaceholder candidate required (contrast GroupRecipe).The default implementation treats every entry of items as its own mandatory group (
min == max == 1), which reproduces plain full-matching SHAPELESS behaviour and keeps requiresInputItemAmountMin / requiresInputItemAmountMax correct without any extra overrides. Implementations that override this to express optional/aggregate slots (e.g. ShapelessGroupRecipe) do not need to separately override those two methods.Ignored by CRecipe.Type.SHAPED matching, which stays purely coordinate-based.
Contract: every MatchGroup.members coordinate returned here must be a key of items; violating this causes an exception during search.
- Returns:
List Match groups covering (all or part of) items.
- Since:
5.3.0
-
isValidRecipe
Unit isValidRecipe()
Validates this CRecipe.
CRecipe's default implementation checks below conditions.
CRecipe.items size is in range 1 to 36
All contained CMatter pass CMatter.isValidMatter
// (Usage) val recipe: CRecipe = ~~~ recipe.isValidRecipe()- Since:
5.0.15
-
createGroups
final static Set<MatchGroup> createGroups(Map<CoordinateComponent, CMatter> items, Set<MatchGroup> missingGroups)
Creates a collection of MatchGroups, which are grouping settings that can be set in ShapelessGroupRecipe.groups.
missingGroups is a collection of already created MatchGroups; any coordinates of items not covered by them are each turned into their own mandatory group (MatchGroup.mandatory).
If the resulting set is invalid, throws an exception.
- Parameters:
items- Coordinate and CMatter mappingmissingGroups- Set of MatchGroups already created- Returns:
Set A MatchGroup set usable for ShapelessGroupRecipe.groups
- Since:
5.3.0
-
isValidGroups
final static Unit isValidGroups(Set<MatchGroup> groups, Map<CoordinateComponent, CMatter> items)
Validates the specified group set against the items mapping.
If those are invalid, throws an exception that includes error messages.
Every MatchGroup.members coordinate must exist as a key in items.
No coordinate may belong to more than one group.
Every coordinate in items must belong to exactly one group (no gaps).
- Parameters:
groups- Set of MatchGroupitems- Item mapping on ShapelessGroupRecipe- Since:
5.3.0
-
-
-
-