Class AbstractCraftingProductionResolver<C extends AbstractCrafting>

java.lang.Object
com.minecolonies.core.colony.requestsystem.resolvers.core.AbstractRequestResolver<C>
com.minecolonies.core.colony.requestsystem.resolvers.core.AbstractCraftingProductionResolver<C>
All Implemented Interfaces:
IRequester, IRequestResolver<C>, IBuildingBasedRequester
Direct Known Subclasses:
PrivateWorkerCraftingProductionResolver, PublicWorkerCraftingProductionResolver

public abstract class AbstractCraftingProductionResolver<C extends AbstractCrafting> extends AbstractRequestResolver<C> implements IBuildingBasedRequester
Abstract crafting resolver for all crafting tasks.
  • Constructor Details

    • AbstractCraftingProductionResolver

      public AbstractCraftingProductionResolver(@NotNull @NotNull ILocation location, @NotNull @NotNull IToken<?> token, @NotNull @NotNull JobEntry jobEntry, Class<C> cClass)
      Constructor to initialize.
      Parameters:
      location - the location.
      token - the id.
      cClass - the class.
  • Method Details

    • getRequestType

      public com.google.common.reflect.TypeToken<? extends C> getRequestType()
      Description copied from interface: IRequestResolver
      Used to determine which type of requests can be resolved by this Resolver.
      Specified by:
      getRequestType in interface IRequestResolver<C extends AbstractCrafting>
      Returns:
      The class that represents this Type of Request this resolver can resolve.
    • getJobEntry

      public JobEntry getJobEntry()
      Get the job entry for the production resolver.
      Returns:
      the entry.
    • getBuilding

      public Optional<IRequester> getBuilding(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IToken<?> token)
      Description copied from interface: IBuildingBasedRequester
      Get the building.
      Specified by:
      getBuilding in interface IBuildingBasedRequester
      Parameters:
      manager - the manager.
      token - the token.
      Returns:
      the IRequester or empty.
    • canResolveRequest

      public boolean canResolveRequest(@NotNull @NotNull IRequestManager manager, IRequest<? extends C> requestToCheck)
      Description copied from interface: IRequestResolver
      A PreCheck used to determine if this request resolver is able to resolve a given request. Should quickly and cheaply check if this resolver COULD resolve this request.
      Specified by:
      canResolveRequest in interface IRequestResolver<C extends AbstractCrafting>
      Parameters:
      manager - The manager that is checking if this resolver could resolve that request.
      requestToCheck - The request to check.
      Returns:
      True when this resolver COULD resolve the given request, false when not.
    • attemptResolveRequest

      @Nullable public @Nullable List<IToken<?>> attemptResolveRequest(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<? extends C> request)
      Description copied from interface: IRequestResolver
      Method used to attempt a resolving operation.

      When this attempt was successful a List with tokens of required requests is returned. This list maybe empty. The list should indicate all sub requests that should be fullfilled before the @code{resolve(IRequest request)} method is called.

      When this attempt was not successful, eg. this resolver could not schedule a crafting operation, a Null object should be returned. In that case the next resolver will be tried by the manager.

      IT IS VITAL THAT THE REQUEST RETURNED ARE NOT YET ASSIGNED. SIMULATION AND OTHER STRATEGIES WILL FAIL ELSE! THE MANAGER GIVEN WILL HANDLE ASSIGNING HIMSELF!

      Specified by:
      attemptResolveRequest in interface IRequestResolver<C extends AbstractCrafting>
      Parameters:
      manager - The manager that is attempting to resolve using this resolver.
      request - The request to resolve.
      Returns:
      The tokens of required requests if the attempt was successful (an empty list is allowed to indicate no requirements), null if the attempt failed.
    • attemptResolveForBuilding

      @Nullable public @Nullable List<IToken<?>> attemptResolveForBuilding(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<? extends C> request, @NotNull @NotNull AbstractBuilding building)
    • attemptResolveForBuildingAndStack

      @Nullable protected @Nullable List<IToken<?>> attemptResolveForBuildingAndStack(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull AbstractBuilding building, net.minecraft.world.item.ItemStack stack, int count, int minCount, IToken<?> recipeId)
    • canBuildingCraftStack

      protected boolean canBuildingCraftStack(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull AbstractBuilding building, @NotNull @NotNull net.minecraft.world.item.ItemStack stack)
    • createRequestsForRecipe

      @Nullable protected @Nullable List<IToken<?>> createRequestsForRecipe(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull AbstractBuilding building, int count, int minCount, @NotNull @NotNull IRecipeStorage storage)
    • createNewRequestForStack

      @Nullable protected @Nullable IToken<?> createNewRequestForStack(@NotNull @NotNull IRequestManager manager, net.minecraft.world.item.ItemStack stack, int count, int minCount, boolean matchMeta)
    • resolveRequest

      public void resolveRequest(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<? extends C> request)
      Description copied from interface: IRequestResolver
      Method used to resolve a given request. Is called the moment all Child requests are resolved.

      The resolver should update the state through the given manager.

      When this method is called all requirements need be fullfilled for this resolver. If this is not the case it will throw a RunTimeException

      Specified by:
      resolveRequest in interface IRequestResolver<C extends AbstractCrafting>
      Parameters:
      manager - The manager that is resolving this request, under normal conditions this is the colony manager.
      request - The request to resolve.
    • onAssignedToThisResolverForBuilding

      protected void onAssignedToThisResolverForBuilding(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<? extends C> request, boolean simulation, @NotNull @NotNull AbstractBuilding building)
    • onRequestAssigned

      public void onRequestAssigned(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<? extends C> request, boolean simulation)
      Called by the manager given to indicate that this request has been assigned to you.
      Specified by:
      onRequestAssigned in interface IRequestResolver<C extends AbstractCrafting>
      Parameters:
      manager - The systems manager.
      request - The request assigned.
      simulation - True when simulating.
    • resolveForBuilding

      public void resolveForBuilding(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<? extends C> request, @NotNull @NotNull AbstractBuilding building)
      Resolve the request in a building.
      Parameters:
      manager - the request manager.
      request - the request.
      building - the building.
    • isValid

      public boolean isValid()
      Description copied from interface: IRequestResolver
      If this resolver has valid data in it.
      Specified by:
      isValid in interface IRequestResolver<C extends AbstractCrafting>
      Returns:
      true if so.