Interface CMatter
-
-
Method Summary
Modifier and Type Method Description UnitisValidMatter()Validates this CMatter. BooleanhasPredicates()returns this CMatter has some predicates or not. BooleanpredicatesResult(CMatterPredicate.Context ctx)Returns a merged result of all predicates run. Pair<Integer, CMatterPredicate>firstFailedPredicate(CMatterPredicate.Context ctx)Returns the first CMatterPredicate that rejects ctx, or nullwhen all of them pass.abstract StringgetName()Name of this matter. abstract Set<Material>getCandidate()Set of acceptable Material types for this slot. abstract IntegergetAmount()Required item count. abstract BooleangetAnyAmount()If true, any input amount ≥ 1 is accepted regardless of amount.abstract List<CMatterPredicate>getPredicates()List of additional CMatterPredicate checks that run during slot matching. -
-
Method Detail
-
isValidMatter
Unit isValidMatter()
Validates this CMatter.
CMatter's default implementation checks below conditions.
CMatter.candidate is not empty
CMatter.candidate does not contain Material.isAir and !Material.isItem
CMatter.amount is 1 or more
// (Usage) val matter: CMatter = ~~~ matter.isValidMatter()This is called from CRecipe.isValidRecipe.
- Since:
5.0.15
-
hasPredicates
Boolean hasPredicates()
returns this CMatter has some predicates or not.
- Returns:
Boolean ==
!predicates.isNullOrEmpty()
-
predicatesResult
Boolean predicatesResult(CMatterPredicate.Context ctx)
Returns a merged result of all predicates run.
// Default implementation on `CMatter#predicatesResult` fun predicatesResult(ctx: CMatterPredicate.Context): Boolean { return predicates?.all { p -> p.test(ctx) } ?: true }- Parameters:
ctx- Context of CMatterPredicate execution- Returns:
Boolean all or nothing.
-
firstFailedPredicate
Pair<Integer, CMatterPredicate> firstFailedPredicate(CMatterPredicate.Context ctx)
Returns the first CMatterPredicate that rejects ctx, or
nullwhen all of them pass.Evaluates predicates in order and stops at the first failure, exactly as predicatesResult does, so this can be used in its place when the caller needs to report which predicate failed rather than only whether one did. The returned index is the position within predicates and identifies a predicate that did not override CMatterPredicate.name.
- Parameters:
ctx- Context of CMatterPredicate execution- Returns:
Pair The failing predicate's index paired with the predicate itself, or
nullwhen nothing failed- Since:
5.3.0
-
getCandidate
abstract Set<Material> getCandidate()
Set of acceptable Material types for this slot.
-
getAmount
abstract Integer getAmount()
Required item count. Ignored when anyAmount is
true. Must be 1 or greater.
-
getAnyAmount
abstract Boolean getAnyAmount()
If
true, any input amount ≥ 1 is accepted regardless of amount. Iffalse, input must have at least amount items.
-
getPredicates
abstract List<CMatterPredicate> getPredicates()
List of additional CMatterPredicate checks that run during slot matching.
nullor empty means no additional conditions.Ordered, so an unnamed predicate can be reported by its index in diagnostic logs.
-
-
-
-