Class AbstractEntityAICrafting<J extends AbstractJobCrafter<?,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>
com.minecolonies.core.entity.ai.workers.crafting.AbstractEntityAICrafting<J,B>
- 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 Summary
FieldsModifier and TypeFieldDescriptionprotected IRecipeStorageThe current recipe that is being crafted.IRequest<? extends PublicCrafting> The current request that is being crafted;protected static final intTime the worker delays until the next hit.net.minecraft.core.BlockPosIdle pos.protected static final intMax level which should have an effect on the speed of the worker.static IAIStateAllow transitioning to any other state, otherwise stay in current.static final intIncrease this value to make the product creation progress way slower.Fields inherited from class com.minecolonies.core.entity.ai.workers.AbstractEntityAIInteract
BLOCK_MINING_DELAY, RANGE_HORIZONTAL_PICKUP, RANGE_VERTICAL_PICKUP, RENDER_META_WORKING, XP_PER_BLOCKFields 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
ConstructorsConstructorDescriptionInitialize the crafter job and add all his tasks. -
Method Summary
Modifier and TypeMethodDescriptionState to go to after dumping.protected IAIStatecheckForItems(@NotNull IRecipeStorage storage) Check for all items of the required recipe.protected IAIStatecraft()The actual crafting logic.protected IAIStatedecide()Main method to decide on what to do.executeCraftingAction(int toolSlot) Execute the actual crafting action.protected intThe number of actions a crafting "success" is worth.protected intCalculates after how many actions the ai should dump it's inventory.protected StringReturns the name of the crafting stat that is used in the building's statistics.protected intgetExtendedCount(net.minecraft.world.item.ItemStack stack) Get an extended count that can be overriden.protected net.minecraft.world.level.storage.loot.LootParamsget the LootContextBuilder forprotected net.minecraft.world.level.storage.loot.LootParamsgetLootContext(boolean includeKiller) get the LootContextBuilder forprotected IAIStateGets the next crafting state required, if a task exists.protected IAIStateQuery the IRecipeStorage of the first request in the queue.The state to transform to after picking up things.booleanIf the crafter should go in idle mode or not.voidhitBlockWithToolInHand(@Nullable net.minecraft.core.BlockPos blockPos) protected IAIStateidle()booleanChecks whether automatic pickups after dumps are allowed.protected voidrecordCraftingBuildingStats(IRequest<?> request, IRecipeStorage recipe) Records the crafting request in the building's statistics.voidReset all the values.protected voidCan be overridden in implementations.Methods inherited from class com.minecolonies.core.entity.ai.workers.AbstractEntityAIInteract
fillItemsList, gatherItems, getBlockMiningTime, getBreakSpeedLevel, getItemsForPickUp, increaseBlockDrops, isItemWorthPickingUp, mineBlock, mineBlock, mineBlock, onBlockDropReception, resetGatheringItems, searchForItems, shouldSilkTouchBlock, triggerMinedBlockMethods inherited from class com.minecolonies.core.entity.ai.workers.AbstractEntityAIBasic
afterRequestPickUp, cancelAsynchRequestForArmor, canGoIdle, checkAndTransferFromHut, checkForToolOrWeapon, checkForToolOrWeapon, checkForToolOrWeaponAsync, checkIfNeedsItem, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreate, checkIfRequestForItemExistOrCreateAsync, checkIfRequestForItemExistOrCreateAsync, checkIfRequestForItemExistOrCreateAsync, checkIfRequestForItemExistOrCreateAsync, checkIfRequestForItemExistOrCreateAsync, checkIfRequestForTagExistOrCreateAsync, getBuildingToDump, getEffectiveSkillLevel, getExceptionTimer, getExpectedBuildingClass, getFakePlayer, getInventory, getInvertedEffectiveSkillLevel, getModuleForJob, getMostEfficientTool, getPrimarySkillLevel, getSecondarySkillLevel, getTotalRequiredAmount, getWorkingPosition, getWorkingPosition, hasNotDelayed, holdEfficientTool, incrementActionsDone, incrementActionsDone, incrementActionsDoneAndDecSaturation, inventoryNeedsDump, itemsNiceToHave, onException, resetActionsDone, retrieveToolInHut, retrieveToolInTileEntity, setDelay, takeItemStackFromProvider, 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
-
NO_CHANGE
Allow transitioning to any other state, otherwise stay in current. -
HIT_DELAY
protected static final int HIT_DELAYTime the worker delays until the next hit.- See Also:
-
PROGRESS_MULTIPLIER
public static final int PROGRESS_MULTIPLIERIncrease this value to make the product creation progress way slower.- See Also:
-
MAX_LEVEL
protected static final int MAX_LEVELMax level which should have an effect on the speed of the worker.- See Also:
-
currentRequest
The current request that is being crafted; -
currentRecipeStorage
The current recipe that is being crafted. -
idlePos
public net.minecraft.core.BlockPos idlePosIdle pos.
-
-
Constructor Details
-
AbstractEntityAICrafting
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
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
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:AbstractEntityAIBasicCan be overridden in implementations.Here the AI can check if the chestBelt has to be re rendered and do it.
- Overrides:
updateRenderMetaDatain classAbstractEntityAIBasic<J extends AbstractJobCrafter<?,J>, B extends AbstractBuilding>
-
idle
-
hasWorkToDo
public boolean hasWorkToDo()If the crafter should go in idle mode or not.- Returns:
- true if so.
-
decide
Main method to decide on what to do.- Returns:
- the next state to go to.
-
getNextCraftingState
Gets the next crafting state required, if a task exists.- Returns:
- next state
-
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
Description copied from class:AbstractEntityAIBasicThe state to transform to after picking up things.- Overrides:
getStateAfterPickUpin classAbstractEntityAIBasic<J extends AbstractJobCrafter<?,J>, B extends AbstractBuilding> - Returns:
- the next state to go to.
-
checkForItems
Check for all items of the required recipe.- Parameters:
storage- the recipe storage.- Returns:
- the next state to go to.
-
craft
The actual crafting logic.- Returns:
- the next state to go to.
-
executeCraftingAction
Execute the actual crafting action.- Parameters:
toolSlot- the tool slot to consider.- Returns:
- the next state to go to.
-
finalizeCraftingTask
-
hitBlockWithToolInHand
public void hitBlockWithToolInHand(@Nullable @Nullable net.minecraft.core.BlockPos blockPos) -
resetValues
public void resetValues()Reset all the values. -
afterDump
Description copied from class:AbstractEntityAIBasicState to go to after dumping.- Overrides:
afterDumpin classAbstractEntityAIBasic<J extends AbstractJobCrafter<?,J>, B extends AbstractBuilding> - Returns:
- the next state.
-
getActionsDoneUntilDumping
protected int getActionsDoneUntilDumping()Description copied from class:AbstractEntityAIBasicCalculates after how many actions the ai should dump it's inventory.Override this to change the value.
- Overrides:
getActionsDoneUntilDumpingin classAbstractEntityAIBasic<J extends AbstractJobCrafter<?,J>, B extends AbstractBuilding> - Returns:
- the number of actions done before item dump.
-
isAfterDumpPickupAllowed
public boolean isAfterDumpPickupAllowed()Description copied from class:AbstractEntityAIBasicChecks 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:
isAfterDumpPickupAllowedin classAbstractEntityAIBasic<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
-