Class IngredientComponentStorageWrapperHandlerEnergyStorage.ComponentStorageWrapper
java.lang.Object
org.cyclops.commoncapabilities.ingredient.storage.IngredientComponentStorageWrapperHandlerEnergyStorage.ComponentStorageWrapper
- All Implemented Interfaces:
Iterable<Long>
,IIngredientComponentStorage<Long,
Boolean>
- Enclosing class:
IngredientComponentStorageWrapperHandlerEnergyStorage<C>
public static class IngredientComponentStorageWrapperHandlerEnergyStorage.ComponentStorageWrapper
extends Object
implements IIngredientComponentStorage<Long,Boolean>
-
Constructor Summary
ConstructorDescriptionComponentStorageWrapper
(IngredientComponent<Long, Boolean> ingredientComponent, net.neoforged.neoforge.energy.IEnergyStorage storage) -
Method Summary
Modifier and TypeMethodDescriptionextract
(long maxQuantity, boolean simulate) Extract any ingredient, but the given maximum amount from the storage.Extract an ingredient matching the given prototype from the storage.long
Inserts an ingredient into the storage and return the remainder.iterator()
Get all ingredients in this storage.Find all ingredients matching the given prototype from the storage.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ComponentStorageWrapper
public ComponentStorageWrapper(IngredientComponent<Long, Boolean> ingredientComponent, net.neoforged.neoforge.energy.IEnergyStorage storage)
-
-
Method Details
-
getComponent
- Specified by:
getComponent
in interfaceIIngredientComponentStorage<Long,
Boolean> - Returns:
- The ingredient component type this storage applies to.
-
iterator
Description copied from interface:IIngredientComponentStorage
Get all ingredients in this storage. -
iterator
Description copied from interface:IIngredientComponentStorage
Find all ingredients matching the given prototype from the storage. Calling this method will not modify the storage in any way. Results from this method MUST NOT be modified.- Specified by:
iterator
in interfaceIIngredientComponentStorage<Long,
Boolean> - Parameters:
prototype
- The ingredient to search for.matchFlags
- The flags to compare the given prototype by according toIngredientComponent.getMatcher()
.- Returns:
- An iterator over ingredients that match the given prototype, which may potentially be empty.
-
getMaxQuantity
public long getMaxQuantity()- Specified by:
getMaxQuantity
in interfaceIIngredientComponentStorage<Long,
Boolean> - Returns:
- The maximum allowed quantity over all instances.
-
insert
Description copied from interface:IIngredientComponentStorage
Inserts an ingredient into the storage and return the remainder. The ingredient should not be modified in this function!- Specified by:
insert
in interfaceIIngredientComponentStorage<Long,
Boolean> - Parameters:
ingredient
- Ingredient to insert.simulate
- If true, the insertion is only simulated.- Returns:
- The remaining ingredient that was not inserted (if the entire ingredient is accepted,
then return
IIngredientMatcher.getEmptyInstance()
). May be the same as the input ingredient if unchanged, otherwise a new ingredient.
-
extract
Description copied from interface:IIngredientComponentStorage
Extract an ingredient matching the given prototype from the storage. Note that only the extracted ingredient must match the prototype under the given condition. Internally, ingredients can be combined and matched in any way. For example, an exact match could be produced by combining several ingredients. If the primary quantifier (as identified byIngredientComponent.getPrimaryQuantifier()
) IS NOT part of the match condition, then the quantity of the given prototype MUST be interpreted as the maximum quantity that must be extracted. If the primary quantifier (as identified byIngredientComponent.getPrimaryQuantifier()
) IS part of the match condition, then the quantity of the given prototype MUST be interpreted as the exact quantity that must be extracted. If the storage has a HIGHER OR EQUAL available quantity, then the storage MUST allow the given quantity to be extracted. If the storage on the other hand has a LOWER available quantity, then extraction is not allowed.- Specified by:
extract
in interfaceIIngredientComponentStorage<Long,
Boolean> - Parameters:
prototype
- The ingredient to search for.matchFlags
- The flags to compare the given prototype by according toIngredientComponent.getMatcher()
.simulate
- If true, the insertion is only simulated- Returns:
- Ingredient extracted from the slot, must be
IIngredientMatcher.getEmptyInstance()
, if nothing can be extracted
-
extract
Description copied from interface:IIngredientComponentStorage
Extract any ingredient, but the given maximum amount from the storage.- Specified by:
extract
in interfaceIIngredientComponentStorage<Long,
Boolean> - Parameters:
maxQuantity
- The maximum amount to extract.simulate
- If true, the insertion is only simulated- Returns:
- Ingredient extracted from the slot, must be
IIngredientMatcher.getEmptyInstance()
, if nothing can be extracted
-