Class GroupRecipe
-
- All Implemented Interfaces:
-
io.github.sakaki_aruka.customcrafter.recipe.CRecipe,io.github.sakaki_aruka.customcrafter.recipe.UnPartialSearchableRecipe
public class GroupRecipe implements CRecipe, UnPartialSearchableRecipe
Implementation of CRecipe.
This recipe only provides CRecipe.Type.SHAPED.
This recipe has groups what is a list of air-containable matter (GroupRecipe.Matter).
This recipe has the constraint that "all Context#members to which the key that returns the smallest CoordinateComponent#toIndex value in items belongs cannot have an element in candidate that satisfies Material#isAir."
items = { (0, 0): [Material.AIR, Material.STONE], (0, 1): [Material.COBBLESTONE] } // This is invalid groups. Group1 contains the minimum coordinate what keyed with a CMatter that contains Material.AIR. groups = [Group1{ (0, 0) }, Group2{ (0, 1) }]// Other invalid pattern items = { (0, 0): [Material.STONE], (0, 1): [Material.AIR, Material.COBBLESTONE] } // This is invalid group. groups = [Group1{ (0, 0), (0, 1) }]GroupRecipe.recipePredicate is always appended to GroupRecipe.predicates automatically, regardless of whether predicates is specified in the constructor.
- Since:
5.0.15
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classGroupRecipe.ContextContext of GroupRecipe
Configure minimum amount in crafting and relation of item placements.
public final classGroupRecipe.MatterAir-containable CMatter implementation.
Use Matter.of to initialize.
-
Field Summary
Fields Modifier and Type Field Description public final static CRecipePredicaterecipePredicateprivate final Stringnameprivate final Map<CoordinateComponent, CMatter>itemsprivate final Set<GroupRecipe.Context>groupsprivate final List<ResultSupplier>resultsprivate final List<CRecipePredicate>predicatesprivate final CRecipe.Typetype
-
Constructor Summary
Constructors Constructor Description GroupRecipe(String name, Map<CoordinateComponent, CMatter> items, Set<GroupRecipe.Context> groups, List<CRecipePredicate> predicates, List<ResultSupplier> results)GroupRecipe(String name, Map<CoordinateComponent, CMatter> items, Set<GroupRecipe.Context> groups, List<CRecipePredicate> predicates)GroupRecipe(String name, Map<CoordinateComponent, CMatter> items, Set<GroupRecipe.Context> groups)
-
Method Summary
Modifier and Type Method Description StringgetName()Map<CoordinateComponent, CMatter>getItems()final Set<GroupRecipe.Context>getGroups()List<ResultSupplier>getResults()List<CRecipePredicate>getPredicates()List of CRecipePredicate that run during recipe matching. CRecipe.TypegetType()Type of this recipe. IntegerrequiresInputItemAmountMin()Minimal requires input items amountDefault implementation derives this from matchGroups (sum of each group's MatchGroup.min). UnitisValidRecipe()Validates this CRecipe. final static Set<GroupRecipe.Context>createGroups(Map<CoordinateComponent, CMatter> items, Set<GroupRecipe.Context> missingGroups)Creates a collection of GroupRecipe.Context s, which are grouping settings that can be set in GroupRecipe#groups. -
Methods inherited from class io.github.sakaki_aruka.customcrafter.recipe.CRecipe
asyncGetRecipePredicateResults, asyncGetResults, firstFailedRecipePredicate, getRecipePredicateResults, getResults, getTimes, matchGroups, requiresInputItemAmountMax -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
GroupRecipe
GroupRecipe(String name, Map<CoordinateComponent, CMatter> items, Set<GroupRecipe.Context> groups, List<CRecipePredicate> predicates, List<ResultSupplier> results)
- Parameters:
name- Name of this recipeitems- Item mappinggroups- Air-containable context set.predicates- Additional predicates prepended before recipePredicate.results- ResultSupplier list
-
GroupRecipe
GroupRecipe(String name, Map<CoordinateComponent, CMatter> items, Set<GroupRecipe.Context> groups, List<CRecipePredicate> predicates)
- Parameters:
name- Name of this recipeitems- Item mappinggroups- Air-containable context set.predicates- Additional predicates prepended before recipePredicate.
-
GroupRecipe
GroupRecipe(String name, Map<CoordinateComponent, CMatter> items, Set<GroupRecipe.Context> groups)
- Parameters:
name- Name of this recipeitems- Item mappinggroups- Air-containable context set.
-
-
Method Detail
-
getItems
Map<CoordinateComponent, CMatter> getItems()
-
getGroups
final Set<GroupRecipe.Context> getGroups()
-
getResults
List<ResultSupplier> getResults()
-
getPredicates
List<CRecipePredicate> getPredicates()
List of CRecipePredicate that run during recipe matching.
nullor empty means no additional conditions.
-
getType
CRecipe.Type getType()
Type of this recipe. See CRecipe.Type.
-
requiresInputItemAmountMin
Integer requiresInputItemAmountMin()
Minimal requires input items amount
Default implementation derives this from matchGroups (sum of each group's MatchGroup.min).
- Returns:
Int Minimal requires input items amount
- Since:
5.0.15
-
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<GroupRecipe.Context> createGroups(Map<CoordinateComponent, CMatter> items, Set<GroupRecipe.Context> missingGroups)
Creates a collection of GroupRecipe.Context s, which are grouping settings that can be set in GroupRecipe#groups.
missingGroups is a collection of already created Context s; any Contexts for coordinates that are not included will be created with default settings and grouped into a single collection.
If invalid state Context found from a specified set, throws an exception.
- Parameters:
items- Coordinate and CMatter mappingmissingGroups- Set of GroupRecipe.- Returns:
Set A GroupRecipe.Context set what can use for GroupRecipe#groups
- Since:
5.0.15
-
-
-
-