Class AbstractEntityAIInteract<J extends AbstractJob<?,J>,B extends AbstractBuilding>
java.lang.Object
com.minecolonies.core.entity.ai.workers.AbstractAISkeleton<J>
com.minecolonies.core.entity.ai.workers.AbstractEntityAIBasic<J,B>
com.minecolonies.core.entity.ai.workers.AbstractEntityAISkill<J,B>
com.minecolonies.core.entity.ai.workers.AbstractEntityAIInteract<J,B>
- 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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intBlock mining delay basestatic final floatHorizontal range in which the worker picks up items.static final floatVertical range in which the worker picks up items.static final StringWorking render meta.static final doubleThe amount of xp the entity gains per block mined.Fields inherited from class com.minecolonies.core.entity.ai.workers.AbstractEntityAIBasic
building, currentWorkingLocation, needsCurrently, NO_TOOL, REQUEST_DELAY, STANDARD_DELAY, WALK_DELAY, walkTo, workPosIndexFields inherited from class com.minecolonies.core.entity.ai.workers.AbstractAISkeleton
job, worker, world -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidFill the list of the item positions to gather.voidCollect one item by walking to it.intgetBlockMiningTime(@NotNull net.minecraft.world.level.block.state.BlockState state, @NotNull net.minecraft.core.BlockPos pos) Calculate how long it takes to mine this block.intGet the level that affects the break speed.@Nullable List<net.minecraft.core.BlockPos>Get the items to gather list.protected List<net.minecraft.world.item.ItemStack>increaseBlockDrops(List<net.minecraft.world.item.ItemStack> drops) Potentially increase the blockdrops.protected booleanisItemWorthPickingUp(net.minecraft.world.item.ItemStack stack) Check if an item is sufficiently interesting to want to go pick it up.protected final booleanmineBlock(@NotNull net.minecraft.core.BlockPos blockToMine) Will simulate mining a block with particles ItemDrop etc.protected booleanmineBlock(@NotNull net.minecraft.core.BlockPos blockToMine, @Nullable net.minecraft.core.BlockPos safeStand) Will simulate mining a block with particles ItemDrop etc.protected final booleanmineBlock(@NotNull net.minecraft.core.BlockPos blockToMine, @Nullable net.minecraft.core.BlockPos safeStand, boolean damageTool, boolean getDrops, Runnable blockBreakAction) Will simulate mining a block with particles ItemDrop etc.voidonBlockDropReception(List<net.minecraft.world.item.ItemStack> blockDrops) Event triggered after receiving a list of block drops.voidReset the gathering items to null.voidsearchForItems(net.minecraft.world.phys.AABB boundingBox) Search for all items around the worker.booleanshouldSilkTouchBlock(net.minecraft.world.level.block.state.BlockState curBlockState) Check if this specific block should be picked up via silk touch.protected voidtriggerMinedBlock(@NotNull net.minecraft.core.BlockPos position, @NotNull net.minecraft.world.level.block.state.BlockState blockToMine) Trigger for miners if they want to do something specific per mined block.Methods inherited from class com.minecolonies.core.entity.ai.workers.AbstractEntityAIBasic
afterDump, afterRequestPickUp, cancelAsynchRequestForArmor, canGoIdle, checkAndTransferFromHut, checkForToolOrWeapon, checkForToolOrWeapon, checkForToolOrWeaponAsync, checkIfNeedsItem, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreateAsync, checkIfRequestForItemExistOrCreateAsync, checkIfRequestForItemExistOrCreateAsync, checkIfRequestForItemExistOrCreateAsync, checkIfRequestForItemExistOrCreateAsync, checkIfRequestForTagExistOrCreateAsync, getActionsDoneUntilDumping, getBuildingToDump, getEffectiveSkillLevel, getExceptionTimer, getExpectedBuildingClass, getFakePlayer, getInventory, getInvertedEffectiveSkillLevel, getModuleForJob, getMostEfficientTool, getPrimarySkillLevel, getSecondarySkillLevel, getStateAfterPickUp, getTotalRequiredAmount, getWorkingPosition, getWorkingPosition, hasNotDelayed, holdEfficientTool, incrementActionsDone, incrementActionsDone, incrementActionsDoneAndDecSaturation, inventoryNeedsDump, isAfterDumpPickupAllowed, itemsNiceToHave, onException, resetActionsDone, retrieveToolInHut, retrieveToolInTileEntity, setDelay, takeItemStackFromProvider, updateRenderMetaData, waitForRequests, walkToBuilding, walkToBuilding, walkToSafePos, walkToTaggedWorkPos, walkToUnSafePos, walkToUnSafePos, walkToWorkPos, walkWithProxy, walkWithProxy, wantInventoryDumpedMethods inherited from class com.minecolonies.core.entity.ai.workers.AbstractAISkeleton
canBeInterrupted, getState, getStateAI, getTickRate, onRemoval, registerGroupTarget, registerTarget, registerTargets, resetAI, setCurrentDelay, tick
-
Field Details
-
RENDER_META_WORKING
Working render meta.- See Also:
-
XP_PER_BLOCK
public static final double XP_PER_BLOCKThe amount of xp the entity gains per block mined.- See Also:
-
RANGE_HORIZONTAL_PICKUP
public static final float RANGE_HORIZONTAL_PICKUPHorizontal range in which the worker picks up items.- See Also:
-
RANGE_VERTICAL_PICKUP
public static final float RANGE_VERTICAL_PICKUPVertical range in which the worker picks up items.- See Also:
-
BLOCK_MINING_DELAY
public static final int BLOCK_MINING_DELAYBlock mining delay base- See Also:
-
-
Constructor Details
-
AbstractEntityAIInteract
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, @Nullable @Nullable 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 minedsafeStand- 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, @Nullable @Nullable 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 minedsafeStand- the block we want to stand on to do thatdamageTool- boolean wether we want to damage the tool usedgetDrops- boolean wether we want to get DropsblockBreakAction- Runnable that is used instead of the default block break action, can be null- Returns:
- true once we're done
-
onBlockDropReception
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 blockstatepos- 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
Get the items to gather list.- Returns:
- a copy of it.
-