Package appeng.api.networking.crafting
Interface ICraftingService
- All Superinterfaces:
IGridService
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdds aICraftingProviderthat is not associated with a specificIGridNode.beginCraftingCalculation(net.minecraft.world.level.Level level, ICraftingSimulationRequester simRequester, AEKey craftWhat, long amount, CalculationStrategy strategy) Begin calculating a crafting job.booleancanEmitFor(AEKey what) com.google.common.collect.ImmutableSet<ICraftingCPU> getCpus()getCraftables(AEKeyFilter filter) Get the set of things that can be crafted for a given storage channel.getCraftingFor(AEKey whatToCraft) @Nullable AEKeygetFuzzyCraftable(AEKey whatToCraft, AEKeyFilter filter) Important: Never mutate the passed or returned stacks.longgetRequestedAmount(AEKey what) Gets the total amount being requested across all crafting cpus of a grid.default booleanisCraftable(AEKey whatToCraft) booleanisRequesting(AEKey what) Returns true ifwhatis currently being requested for a crafting job in this grid.booleanReturns true if anything is currently being requested as part of a crafting job in this grid.voidRefreshes the storage mounts provided by a global storage provider.voidRefreshes the crafting mounts provided by anodethrough itsICraftingProvider.voidRemoves a provider added withaddGlobalCraftingProvider(ICraftingProvider).submitJob(ICraftingPlan job, @Nullable ICraftingRequester requestingMachine, @Nullable ICraftingCPU target, boolean prioritizePower, IActionSource src) Submit the job to the Crafting system for processing.
-
Method Details
-
getCraftingFor
- Parameters:
whatToCraft- requested craft- Returns:
- an unmodifiable collection of crafting patterns for the item in question.
-
isCraftable
- Returns:
- true if the grid knows how to craft the given key
-
refreshNodeCraftingProvider
Refreshes the crafting mounts provided by anodethrough itsICraftingProvider.- Throws:
IllegalArgumentException- If the given node is not part of this grid, or did not provideICraftingProvider.
-
addGlobalCraftingProvider
Adds aICraftingProviderthat is not associated with a specificIGridNode. This is for providing crafting patterns and auto-crafting withIGridServices, for example. THIS IS NOT FOR USE BYNODESTHAT PROVIDE THEICraftingProviderSERVICE. Those are automatically handled by the crafting system.- Parameters:
cc- to-be-added crafting pattern provider
-
removeGlobalCraftingProvider
Removes a provider added withaddGlobalCraftingProvider(ICraftingProvider). -
refreshGlobalCraftingProvider
Refreshes the storage mounts provided by a global storage provider.- Throws:
IllegalArgumentException- If the given provider has not beenregistered.
-
getFuzzyCraftable
Important: Never mutate the passed or returned stacks.- Returns:
- another fuzzy equals stack that can be crafted and matches the filter, or null if none exists
-
beginCraftingCalculation
Future<ICraftingPlan> beginCraftingCalculation(net.minecraft.world.level.Level level, ICraftingSimulationRequester simRequester, AEKey craftWhat, long amount, CalculationStrategy strategy) Begin calculating a crafting job.- Parameters:
level- crafting levelsimRequester- sourcecraftWhat- resultstrategy- usuallyCalculationStrategy.REPORT_MISSING_ITEMSfor player requests- Returns:
- a future which will at an undetermined point in the future get you the
ICraftingPlando not wait on this, your be waiting forever.
-
submitJob
ICraftingSubmitResult submitJob(ICraftingPlan job, @Nullable @Nullable ICraftingRequester requestingMachine, @Nullable @Nullable ICraftingCPU target, boolean prioritizePower, IActionSource src) Submit the job to the Crafting system for processing.If you send a requestingMachine you need to keep track of the resulting
ICraftingLink, persist it to nbt, and expose it inICraftingRequester.getRequestedJobs()so that the requester can be linked back to the CPU after a chunk unload / grid change.- Parameters:
job- - the crafting job from beginCraftingJobrequestingMachine- - a machine if its being requested via automation, may be null.target- - can be nullprioritizePower- - if cpu is null, this determine if the system should prioritize power, or if it should find the lower end cpus.src- - the action source to use when starting the job, this will be used for extracting items, should usually be the same as the one provided to beginCraftingJob.- Returns:
- the success/failure state, and a crafting link in case if successful and there was a requestingMachine.
-
getCpus
com.google.common.collect.ImmutableSet<ICraftingCPU> getCpus()- Returns:
- list of all the crafting cpus on the grid
-
canEmitFor
- Parameters:
what- to be requested item- Returns:
- true if the item can be requested via a crafting emitter.
-
getCraftables
Get the set of things that can be crafted for a given storage channel. -
isRequesting
Returns true ifwhatis currently being requested for a crafting job in this grid. This means that its pattern was pushed to a provider and the result is now being awaited, or that more of the item is expected to be emitted. The final output of a job does not count as being requested.- Parameters:
what- item being crafted- Returns:
- true if it is being crafting
-
getRequestedAmount
Gets the total amount being requested across all crafting cpus of a grid.- Parameters:
what- the key for which the requested amount should be returned- Returns:
- The total amount being requested.
-
isRequestingAny
boolean isRequestingAny()Returns true if anything is currently being requested as part of a crafting job in this grid.- See Also:
-