Class CraftingJobHandler
java.lang.Object
org.cyclops.integratedcrafting.core.CraftingJobHandler
A CraftingJobHandler maintains a list of processing and pending crafting job.
Each time that
update(INetwork, int, PartPos) is called,
the handler will observe the target position for changes in the processing job.
Also, it will try initiating pending jobs into the target if none was running.
If blockingJobsMode is true, then a multi-amount job will only be crafted one-by-one.
If false, then as much as possible of that job will be crafted at once.-
Constructor Summary
ConstructorsConstructorDescriptionCraftingJobHandler(int maxProcessingJobs, boolean blockingJobsMode, Collection<ICraftingProcessOverride> craftingProcessOverrides, ICraftingResultsSink resultsSink) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCraftingJobProcessingPendingIngredientsEntry(CraftingJob craftingJob, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, List<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient<?, ?>>> pendingIngredients) <T,M> org.cyclops.integrateddynamics.core.network.IIngredientChannelInsertPreConsumer.Result<T> beforeFlushIngredientToNetwork(org.cyclops.commoncapabilities.api.ingredient.IngredientInstanceWrapper<T, M> instanceWrapper, int channel) This method is called right before a crafting interface's result buffer is flushed to the network.booleanprotected booleanconsumeAndInsertCrafting(boolean blockingMode, org.cyclops.integrateddynamics.api.network.INetwork network, int channel, org.cyclops.integrateddynamics.api.part.PartPos targetPos, CraftingJob startingCraftingJob) voidfillCraftingJobBufferFromStorage(CraftingJob craftingJob, Function<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage> storageGetter) it.unimi.dsi.fastutil.ints.Int2ObjectMap<CraftingJob>getCraftingJobStatus(ICraftingNetwork network, int channel, int craftingJobId) net.minecraft.core.DirectiongetIngredientComponentTarget(org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?> ingredientComponent) List<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?,?>> it.unimi.dsi.fastutil.ints.Int2ObjectMap<List<Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?,?>, List<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient<?, ?>>>>> it.unimi.dsi.fastutil.ints.Int2ObjectMap<CraftingJob>Function<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?,?>, org.cyclops.integrateddynamics.api.part.PartPos> getTargetGetter(org.cyclops.integrateddynamics.api.part.PartPos defaultPosition) protected booleaninsertCrafting(org.cyclops.integrateddynamics.api.part.PartPos target, org.cyclops.commoncapabilities.api.ingredient.IMixedIngredients ingredients, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe, CraftingJob craftingJob, org.cyclops.integrateddynamics.api.network.INetwork network, int channel, boolean simulate) protected voidinsertLoopNonBlocking(org.cyclops.integrateddynamics.api.network.INetwork network, int channel, org.cyclops.integrateddynamics.api.part.PartPos targetPos, CraftingJob craftingJob) booleanvoidmarkCraftingJobFinished(int craftingJobId) voidonCraftingJobEntryFinished(ICraftingNetwork craftingNetwork, int craftingJobId) voidonCraftingJobFinished(CraftingJob craftingJob) voidreadFromNBT(net.minecraft.nbt.CompoundTag tag) protected <T,M> void registerIngredientObserver(org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, org.cyclops.integrateddynamics.api.network.INetwork network) protected booleanremoveCraftingJobProcessingPendingIngredientsEntry(CraftingJob craftingJob, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, List<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient<?, ?>>> pendingIngredients) Undo a single crafting operation that was added viaaddCraftingJobProcessingPendingIngredientsEntry(org.cyclops.integratedcrafting.api.crafting.CraftingJob, java.util.Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, java.util.List<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient<?, ?>>>).voidscheduleCraftingJob(CraftingJob craftingJob) booleansetBlockingJobsMode(boolean blockingJobsMode) voidsetIngredientComponentTarget(org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?> ingredientComponent, net.minecraft.core.Direction side) voidunmarkCraftingJobProcessing(CraftingJob craftingJob) protected <T,M> void unregisterIngredientObserver(org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, org.cyclops.integrateddynamics.api.network.INetwork network) voidupdate(org.cyclops.integrateddynamics.api.network.INetwork network, int channel, org.cyclops.integrateddynamics.api.part.PartPos targetPos) voidwriteToNBT(net.minecraft.nbt.CompoundTag tag)
-
Constructor Details
-
CraftingJobHandler
public CraftingJobHandler(int maxProcessingJobs, boolean blockingJobsMode, Collection<ICraftingProcessOverride> craftingProcessOverrides, ICraftingResultsSink resultsSink)
-
-
Method Details
-
writeToNBT
public void writeToNBT(net.minecraft.nbt.CompoundTag tag) -
readFromNBT
public void readFromNBT(net.minecraft.nbt.CompoundTag tag) -
setBlockingJobsMode
public boolean setBlockingJobsMode(boolean blockingJobsMode) -
isBlockingJobsMode
public boolean isBlockingJobsMode() -
canScheduleCraftingJobs
public boolean canScheduleCraftingJobs() -
scheduleCraftingJob
-
fillCraftingJobBufferFromStorage
public void fillCraftingJobBufferFromStorage(CraftingJob craftingJob, Function<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage> storageGetter) -
getProcessingCraftingJobsPendingIngredients
-
getProcessingCraftingJobsRaw
-
getProcessingCraftingJobs
-
getPendingCraftingJobs
-
unmarkCraftingJobProcessing
-
removeCraftingJobProcessingPendingIngredientsEntry
protected boolean removeCraftingJobProcessingPendingIngredientsEntry(CraftingJob craftingJob, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, List<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient<?, ?>>> pendingIngredients) Undo a single crafting operation that was added viaaddCraftingJobProcessingPendingIngredientsEntry(org.cyclops.integratedcrafting.api.crafting.CraftingJob, java.util.Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, java.util.List<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient<?, ?>>>). Other operations of the same job, which may still be running in non-blocking mode, are kept. If no operations remain, the job is moved back to the pending jobs.- Parameters:
craftingJob- The crafting job.pendingIngredients- The exact pending ingredients entry that was added for the operation.- Returns:
- If the operation was still running.
-
addCraftingJobProcessingPendingIngredientsEntry
public void addCraftingJobProcessingPendingIngredientsEntry(CraftingJob craftingJob, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, List<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient<?, ?>>> pendingIngredients) -
getObserversPendingDeletion
public List<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?,?>> getObserversPendingDeletion() -
registerIngredientObserver
protected <T,M> void registerIngredientObserver(org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, org.cyclops.integrateddynamics.api.network.INetwork network) -
unregisterIngredientObserver
protected <T,M> void unregisterIngredientObserver(org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, org.cyclops.integrateddynamics.api.network.INetwork network) -
onCraftingJobFinished
-
markCraftingJobFinished
public void markCraftingJobFinished(int craftingJobId) -
onCraftingJobEntryFinished
-
update
public void update(org.cyclops.integrateddynamics.api.network.INetwork network, int channel, org.cyclops.integrateddynamics.api.part.PartPos targetPos) -
insertCrafting
protected boolean insertCrafting(org.cyclops.integrateddynamics.api.part.PartPos target, org.cyclops.commoncapabilities.api.ingredient.IMixedIngredients ingredients, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe, CraftingJob craftingJob, org.cyclops.integrateddynamics.api.network.INetwork network, int channel, boolean simulate) -
insertLoopNonBlocking
protected void insertLoopNonBlocking(org.cyclops.integrateddynamics.api.network.INetwork network, int channel, org.cyclops.integrateddynamics.api.part.PartPos targetPos, CraftingJob craftingJob) -
consumeAndInsertCrafting
protected boolean consumeAndInsertCrafting(boolean blockingMode, org.cyclops.integrateddynamics.api.network.INetwork network, int channel, org.cyclops.integrateddynamics.api.part.PartPos targetPos, CraftingJob startingCraftingJob) -
getCraftingJobStatus
public CraftingJobStatus getCraftingJobStatus(ICraftingNetwork network, int channel, int craftingJobId) -
getAllCraftingJobs
-
setIngredientComponentTarget
public void setIngredientComponentTarget(org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?> ingredientComponent, @Nullable net.minecraft.core.Direction side) -
getIngredientComponentTarget
@Nullable public net.minecraft.core.Direction getIngredientComponentTarget(org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?> ingredientComponent) -
getTargetGetter
public Function<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?,?>, getTargetGetterorg.cyclops.integrateddynamics.api.part.PartPos> (org.cyclops.integrateddynamics.api.part.PartPos defaultPosition) -
beforeFlushIngredientToNetwork
public <T,M> org.cyclops.integrateddynamics.core.network.IIngredientChannelInsertPreConsumer.Result<T> beforeFlushIngredientToNetwork(org.cyclops.commoncapabilities.api.ingredient.IngredientInstanceWrapper<T, M> instanceWrapper, int channel) This method is called right before a crafting interface's result buffer is flushed to the network. This will first try to pass the instance along to crafting jobs that have pending ingredients. The remaining instance that could not be inserted into any of those crafting jobs is returned.- Type Parameters:
T- The ingredient type.M- The match condition.- Parameters:
instanceWrapper- The instance that would be inserted into the network.channel- The channel.- Returns:
- The remaining instance that was not consumed by observers, and the part of it that no crafting interface has claimed.
-