Class AbstractEntityAICrafting<J extends AbstractJobCrafter<?,J>,B extends AbstractBuilding>

All Implemented Interfaces:
ITickingStateAI
Direct Known Subclasses:
AbstractEntityAIRequestSmelter, EntityAIConcreteMixer, EntityAIWorkAlchemist, EntityAIWorkBlacksmith, EntityAIWorkCrusher, EntityAIWorkEnchanter, EntityAIWorkFarmer, EntityAIWorkFletcher, EntityAIWorkLumberjack, EntityAIWorkMechanic, EntityAIWorkNether, EntityAIWorkPlanter, EntityAIWorkSawmill, EntityAIWorkSifter, EntityAIWorkStonemason

public abstract class AbstractEntityAICrafting<J extends AbstractJobCrafter<?,J>,B extends AbstractBuilding> extends AbstractEntityAIInteract<J,B>
Abstract class for the principal crafting AIs.
  • Field Details

    • NO_CHANGE

      public static IAIState NO_CHANGE
      Allow transitioning to any other state, otherwise stay in current.
    • HIT_DELAY

      protected static final int HIT_DELAY
      Time the worker delays until the next hit.
      See Also:
    • PROGRESS_MULTIPLIER

      public static final int PROGRESS_MULTIPLIER
      Increase this value to make the product creation progress way slower.
      See Also:
    • MAX_LEVEL

      protected static final int MAX_LEVEL
      Max level which should have an effect on the speed of the worker.
      See Also:
    • currentRequest

      public IRequest<? extends PublicCrafting> currentRequest
      The current request that is being crafted;
    • currentRecipeStorage

      protected IRecipeStorage currentRecipeStorage
      The current recipe that is being crafted.
    • idlePos

      public net.minecraft.core.BlockPos idlePos
      Idle pos.
  • Constructor Details

    • AbstractEntityAICrafting

      public AbstractEntityAICrafting(@NotNull J job)
      Initialize the crafter job and add all his tasks.
      Parameters:
      job - the job he has.
  • Method Details

    • getActionRewardForCraftingSuccess

      protected int getActionRewardForCraftingSuccess()
      The number of actions a crafting "success" is worth. By default, that's 1 action for 1 crafting success. Override this in your subclass to make crafting recipes worth more actions :-)
      Returns:
      The number of actions a crafting "success" is worth.
    • getCraftingStatName

      protected String getCraftingStatName()
      Returns the name of the crafting stat that is used in the building's statistics. Override this in your subclass to change the description of the smelting stat.
      Returns:
      The name of the crafting statistic.
    • recordCraftingBuildingStats

      protected void recordCraftingBuildingStats(IRequest<?> request, IRecipeStorage recipe)
      Records the crafting request in the building's statistics. Override this in your subclass to change the description of the crafting stat.
      Parameters:
      request - the request to record.
    • updateRenderMetaData

      protected void updateRenderMetaData()
      Description copied from class: AbstractEntityAIBasic
      Can be overridden in implementations.

      Here the AI can check if the chestBelt has to be re rendered and do it.

      Overrides:
      updateRenderMetaData in class AbstractEntityAIBasic<J extends AbstractJobCrafter<?,J>,B extends AbstractBuilding>
    • idle

      protected IAIState idle()
    • hasWorkToDo

      public boolean hasWorkToDo()
      If the crafter should go in idle mode or not.
      Returns:
      true if so.
    • decide

      protected IAIState decide()
      Main method to decide on what to do.
      Returns:
      the next state to go to.
    • getNextCraftingState

      protected IAIState getNextCraftingState()
      Gets the next crafting state required, if a task exists.
      Returns:
      next state
    • getRecipe

      protected IAIState getRecipe()
      Query the IRecipeStorage of the first request in the queue.
      Returns:
      the next state to go to.
    • getExtendedCount

      protected int getExtendedCount(net.minecraft.world.item.ItemStack stack)
      Get an extended count that can be overriden.
      Parameters:
      stack - the stack to add.
      Returns:
      the additional quantities (for example in a furnace).
    • getStateAfterPickUp

      public IAIState getStateAfterPickUp()
      Description copied from class: AbstractEntityAIBasic
      The state to transform to after picking up things.
      Overrides:
      getStateAfterPickUp in class AbstractEntityAIBasic<J extends AbstractJobCrafter<?,J>,B extends AbstractBuilding>
      Returns:
      the next state to go to.
    • checkForItems

      protected IAIState checkForItems(@NotNull @NotNull IRecipeStorage storage)
      Check for all items of the required recipe.
      Parameters:
      storage - the recipe storage.
      Returns:
      the next state to go to.
    • craft

      protected IAIState craft()
      The actual crafting logic.
      Returns:
      the next state to go to.
    • executeCraftingAction

      public IAIState executeCraftingAction(int toolSlot)
      Execute the actual crafting action.
      Parameters:
      toolSlot - the tool slot to consider.
      Returns:
      the next state to go to.
    • finalizeCraftingTask

      public IAIState finalizeCraftingTask()
    • hitBlockWithToolInHand

      public void hitBlockWithToolInHand(@Nullable @Nullable net.minecraft.core.BlockPos blockPos)
    • resetValues

      public void resetValues()
      Reset all the values.
    • afterDump

      public IAIState afterDump()
      Description copied from class: AbstractEntityAIBasic
      State to go to after dumping.
      Overrides:
      afterDump in class AbstractEntityAIBasic<J extends AbstractJobCrafter<?,J>,B extends AbstractBuilding>
      Returns:
      the next state.
    • getActionsDoneUntilDumping

      protected int getActionsDoneUntilDumping()
      Description copied from class: AbstractEntityAIBasic
      Calculates after how many actions the ai should dump it's inventory.

      Override this to change the value.

      Overrides:
      getActionsDoneUntilDumping in class AbstractEntityAIBasic<J extends AbstractJobCrafter<?,J>,B extends AbstractBuilding>
      Returns:
      the number of actions done before item dump.
    • isAfterDumpPickupAllowed

      public boolean isAfterDumpPickupAllowed()
      Description copied from class: AbstractEntityAIBasic
      Checks whether automatic pickups after dumps are allowed. Usually we want this, but if the worker is currently crafting/building, he will handle deliveries/afterdumps in their resolvers, so we can disable automatic pickups in that time. Note that this is just a efficiency-thing. It doesn't hurt when the dman does a pickup during crafting, it's just a wasted run. Therefore, this flag is only considered for *automatic* pickups after dump. It is *ignored* for player-triggered forcePickups, and when the inventory is full.
      Overrides:
      isAfterDumpPickupAllowed in class AbstractEntityAIBasic<J extends AbstractJobCrafter<?,J>,B extends AbstractBuilding>
      Returns:
      true if after-dump pickups are allowed currently.
    • getLootContext

      protected net.minecraft.world.level.storage.loot.LootParams getLootContext()
      get the LootContextBuilder for
      Returns:
      the LootContext to use for crafting
    • getLootContext

      protected net.minecraft.world.level.storage.loot.LootParams getLootContext(boolean includeKiller)
      get the LootContextBuilder for
      Parameters:
      includeKiller - true for killer-based parameters
      Returns:
      the LootContext to use for crafting