Class AbstractEntityAIInteract<J extends AbstractJob<?,J>,B extends AbstractBuilding>

Type Parameters:
J - the job type this AI has to do.
All Implemented Interfaces:
ITickingStateAI
Direct Known Subclasses:
AbstractEntityAICrafting, AbstractEntityAIFight, AbstractEntityAIHerder, AbstractEntityAIStructure, AbstractEntityAITraining, EntityAIWorkBeekeeper, EntityAIWorkComposter, EntityAIWorkDeliveryman, EntityAIWorkFlorist, EntityAIWorkHealer, EntityAIWorkPupil, EntityAIWorkResearcher, EntityAIWorkTeacher, EntityAIWorkUndertaker

public abstract class AbstractEntityAIInteract<J extends AbstractJob<?,J>,B extends AbstractBuilding> extends AbstractEntityAISkill<J,B>
This is the base class of all worker AIs. Every AI implements this class with it's job type. There are some utilities within the class: - The AI will clear a full inventory at the building chest. - The AI will animate mining a block (with delay) - The AI will request items and tools automatically (and collect them from the building chest)
  • Field Details

    • RENDER_META_WORKING

      public static final String RENDER_META_WORKING
      Working render meta.
      See Also:
    • XP_PER_BLOCK

      public static final double XP_PER_BLOCK
      The amount of xp the entity gains per block mined.
      See Also:
    • RANGE_HORIZONTAL_PICKUP

      public static final float RANGE_HORIZONTAL_PICKUP
      Horizontal range in which the worker picks up items.
      See Also:
    • RANGE_VERTICAL_PICKUP

      public static final float RANGE_VERTICAL_PICKUP
      Vertical range in which the worker picks up items.
      See Also:
    • BLOCK_MINING_DELAY

      public static final int BLOCK_MINING_DELAY
      Block mining delay base
      See Also:
  • Constructor Details

    • AbstractEntityAIInteract

      public AbstractEntityAIInteract(@NotNull J job)
      Creates the abstract part of the AI. Always use this constructor!
      Parameters:
      job - the job to fulfill
  • Method Details

    • mineBlock

      protected final boolean mineBlock(@NotNull @NotNull net.minecraft.core.BlockPos blockToMine)
      Will simulate mining a block with particles ItemDrop etc. Attention: Because it simulates delay, it has to be called 2 times. So make sure the code path up to this function is reachable a second time. And make sure to immediately exit the update function when this returns false.
      Parameters:
      blockToMine - the block that should be mined
      Returns:
      true once we're done
    • mineBlock

      protected boolean mineBlock(@NotNull @NotNull net.minecraft.core.BlockPos blockToMine, @NotNull @NotNull net.minecraft.core.BlockPos safeStand)
      Will simulate mining a block with particles ItemDrop etc. Attention: Because it simulates delay, it has to be called 2 times. So make sure the code path up to this function is reachable a second time. And make sure to immediately exit the update function when this returns false.
      Parameters:
      blockToMine - the block that should be mined
      safeStand - the block we want to stand on to do that
      Returns:
      true once we're done
    • mineBlock

      protected final boolean mineBlock(@NotNull @NotNull net.minecraft.core.BlockPos blockToMine, @NotNull @NotNull net.minecraft.core.BlockPos safeStand, boolean damageTool, boolean getDrops, Runnable blockBreakAction)
      Will simulate mining a block with particles ItemDrop etc. Attention: Because it simulates delay, it has to be called 2 times. So make sure the code path up to this function is reachable a second time. And make sure to immediately exit the update function when this returns false.
      Parameters:
      blockToMine - the block that should be mined
      safeStand - the block we want to stand on to do that
      damageTool - boolean wether we want to damage the tool used
      getDrops - boolean wether we want to get Drops
      blockBreakAction - Runnable that is used instead of the default block break action, can be null
      Returns:
      true once we're done
    • onBlockDropReception

      public void onBlockDropReception(List<net.minecraft.world.item.ItemStack> blockDrops)
      Event triggered after receiving a list of block drops.
      Parameters:
      blockDrops - the received items from the block.
    • shouldSilkTouchBlock

      public boolean shouldSilkTouchBlock(net.minecraft.world.level.block.state.BlockState curBlockState)
      Check if this specific block should be picked up via silk touch.
      Parameters:
      curBlockState - the state to check.
      Returns:
      true if so.
    • increaseBlockDrops

      protected List<net.minecraft.world.item.ItemStack> increaseBlockDrops(List<net.minecraft.world.item.ItemStack> drops)
      Potentially increase the blockdrops. To be overriden by the worker.
      Parameters:
      drops - the drops.
      Returns:
      the list of additional drops.
    • triggerMinedBlock

      protected void triggerMinedBlock(@NotNull @NotNull net.minecraft.core.BlockPos position, @NotNull @NotNull net.minecraft.world.level.block.state.BlockState blockToMine)
      Trigger for miners if they want to do something specific per mined block.
      Parameters:
      position - the position of the block.
      blockToMine - the mined block.
    • getBlockMiningTime

      public int getBlockMiningTime(@NotNull @NotNull net.minecraft.world.level.block.state.BlockState state, @NotNull @NotNull net.minecraft.core.BlockPos pos)
      Calculate how long it takes to mine this block.
      Parameters:
      state - the blockstate
      pos - coordinate
      Returns:
      the delay in ticks
    • getBreakSpeedLevel

      public int getBreakSpeedLevel()
      Get the level that affects the break speed.
      Returns:
      the level.
    • fillItemsList

      public void fillItemsList()
      Fill the list of the item positions to gather.
    • searchForItems

      public void searchForItems(net.minecraft.world.phys.AABB boundingBox)
      Search for all items around the worker. and store them in the items list.
      Parameters:
      boundingBox - the area to search.
    • isItemWorthPickingUp

      protected boolean isItemWorthPickingUp(net.minecraft.world.item.ItemStack stack)
      Check if an item is sufficiently interesting to want to go pick it up. (This won't stop a worker picking up something else as they pass by, but it makes them not want to go over to it.)
      Parameters:
      stack - the stack to check.
      Returns:
      true if the worker wants to go over to it.
    • gatherItems

      public void gatherItems()
      Collect one item by walking to it.
    • resetGatheringItems

      public void resetGatheringItems()
      Reset the gathering items to null.
    • getItemsForPickUp

      @Nullable public @Nullable List<net.minecraft.core.BlockPos> getItemsForPickUp()
      Get the items to gather list.
      Returns:
      a copy of it.