Package com.minecolonies.api.colony.jobs
Interface IJob<AI extends ITickingStateAI>
- All Superinterfaces:
net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
- All Known Implementing Classes:
AbstractJob,AbstractJobCrafter,AbstractJobGuard,AbstractJobStructure,JobAlchemist,JobArcherTraining,JobBaker,JobBeekeeper,JobBlacksmith,JobBuilder,JobCavalry,JobChef,JobChickenHerder,JobCombatTraining,JobComposter,JobConcreteMixer,JobCook,JobCowboy,JobCrusher,JobDeliveryman,JobDruid,JobDyer,JobEnchanter,JobFarmer,JobFisherman,JobFletcher,JobFlorist,JobGlassblower,JobHealer,JobHuscarl,JobKnight,JobLumberjack,JobMarksman,JobMechanic,JobMiner,JobNetherWorker,JobPlaceholder,JobPlanter,JobPupil,JobQuarrier,JobRabbitHerder,JobRanger,JobResearch,JobSawmill,JobShepherd,JobSifter,JobSmelter,JobStablemaster,JobStonemason,JobStoneSmeltery,JobStudent,JobSwineHerder,JobTeacher,JobUndertaker
public interface IJob<AI extends ITickingStateAI>
extends net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
-
Method Summary
Modifier and TypeMethodDescriptionbooleanMethod to check if the colony job allows avoidance.booleanassignTo(IAssignsJob module) Assigns the job to its specific work modulebooleanCheck if it is okay to eatvoidClear the actions done counter.voidcreateAI()Creates the work AIGenerate your AI class to register.intGetter for the amount of actions done.Get a set of async requests connected to this job.net.minecraft.core.BlockPosGets the position of the building the job is assigned toGet the CitizenData that this Job belongs to.Get the Colony that this Job is associated with (shortcut for getAssignedCitizen().getColonyByPosFromWorld()).doubleDisease modifier of the job.default intgetIdleSeverity(boolean isDemand) Get the days before complaining or demanding solution for being idledefault intGet the time limit in seconds after which the job considers itself inactive.TheJobEntryfor this job.net.minecraft.resources.ResourceLocationgetModel()Get the RenderBipedCitizen.Model to use when the Citizen performs this job role.This method can be used to display the current status.default doubleJob saturation factor.Gets the work buildingGet the worker AI associated to this jobGets the module this job is assigned tobooleanCheck if the citizen already checked for food in his chest today.booleanignoresDamage(@NotNull net.minecraft.world.damagesource.DamageSource damageSource) Check if the particular job ignores a particular damage type.voidIncrease the actions done since the last reset by 1 Used for example to detect if and when the inventory has to be dumped.voidincrementActionsDone(int numberOfActions) Increase the actions done since the last reset by numberOfActions Used for example to detect if and when the inventory has to be dumped.default voidinitEntityValues(AbstractEntityCitizen citizen) Initizalizes values for an entity when the entity is spawned/assigned to the jobdefault booleanisGuard()Whether the job is a guardbooleanisIdling()Check if the citizen is in an idle state.voidmarkRequestSync(IToken<?> id) Mark a request as a synchronous (blocking request).default voidLevelup actions on citizen levelup, allows custom actions based on JobsvoidWhen job removed (death of citizen or job change).booleanonStackPickUp(@NotNull net.minecraft.world.item.ItemStack pickedUpStack) Method called when a stack is pickup by the entity.voidonWakeUp()Executed every time the colony woke up.booleanpickupSuccess(@NotNull net.minecraft.world.item.ItemStack pickedUpStack) If the worker can pick up the stack.voidprocessOfflineTime(long time) Process time the colony was offline.voidresetAI()Reset the AI.voidserializeToView(net.minecraft.network.FriendlyByteBuf buffer) Serialize the job to a buffer.voidSets that the citizen on this day already searched for food in his chest.voidsetNameTag(String nameTag) Used by the AI skeleton to change a citizens name.voidsetRegistryEntry(JobEntry jobEntry) Set the registry entry of the job.default voidtriggerActivityChangeAction(boolean newState) Trigger a job based action on activity change (active to inactive, or inactive to active).voidtriggerDeathAchievement(net.minecraft.world.damagesource.DamageSource source, AbstractEntityCitizen citizen) Override this to implement Job specific death achievements.Methods inherited from interface net.minecraftforge.common.util.INBTSerializable
deserializeNBT, serializeNBT
-
Method Details
-
getJobRegistryEntry
JobEntry getJobRegistryEntry()TheJobEntryfor this job.- Returns:
- The
JobEntry.
-
getModel
net.minecraft.resources.ResourceLocation getModel()Get the RenderBipedCitizen.Model to use when the Citizen performs this job role.- Returns:
- Model of the citizen.
-
getColony
IColony getColony()Get the Colony that this Job is associated with (shortcut for getAssignedCitizen().getColonyByPosFromWorld()).- Returns:
IColonyof the citizen.
-
getAsyncRequests
Get a set of async requests connected to this job.- Returns:
- a set of ITokens.
-
createAI
void createAI()Creates the work AI -
generateAI
AI generateAI()Generate your AI class to register.Suppressing Sonar Rule squid:S1452 This rule does "Generic wildcard types should not be used in return parameters" But in this case the rule does not apply because We are fine with all AbstractJob implementations and need generics only for java
- Returns:
- your personal AI instance.
-
hasCheckedForFoodToday
boolean hasCheckedForFoodToday()Check if the citizen already checked for food in his chest today.- Returns:
- true if so.
-
setCheckedForFood
void setCheckedForFood()Sets that the citizen on this day already searched for food in his chest. -
getNameTagDescription
String getNameTagDescription()This method can be used to display the current status. That a citizen is having.- Returns:
- Small string to display info in name tag
-
setNameTag
Used by the AI skeleton to change a citizens name. Mostly used to update debugging information.- Parameters:
nameTag- The name tag to display.
-
triggerDeathAchievement
void triggerDeathAchievement(net.minecraft.world.damagesource.DamageSource source, AbstractEntityCitizen citizen) Override this to implement Job specific death achievements.- Parameters:
source- of the deathcitizen- which just died
-
onStackPickUp
boolean onStackPickUp(@NotNull @NotNull net.minecraft.world.item.ItemStack pickedUpStack) Method called when a stack is pickup by the entity.- Parameters:
pickedUpStack- The stack that is being picked up.- Returns:
- true when the stack has been used to resolve a request, false when not.
-
onLevelUp
default void onLevelUp()Levelup actions on citizen levelup, allows custom actions based on Jobs -
initEntityValues
Initizalizes values for an entity when the entity is spawned/assigned to the job- Parameters:
citizen-
-
getCitizen
ICitizenData getCitizen()Get the CitizenData that this Job belongs to.- Returns:
- CitizenData that owns this Job.
-
onWakeUp
void onWakeUp()Executed every time the colony woke up. -
canAIBeInterrupted
boolean canAIBeInterrupted()Check if it is okay to eat- Returns:
- true if so.
-
getActionsDone
int getActionsDone()Getter for the amount of actions done.- Returns:
- the quantity.
-
incrementActionsDone
void incrementActionsDone()Increase the actions done since the last reset by 1 Used for example to detect if and when the inventory has to be dumped. -
incrementActionsDone
void incrementActionsDone(int numberOfActions) Increase the actions done since the last reset by numberOfActions Used for example to detect if and when the inventory has to be dumped. -
clearActionsDone
void clearActionsDone()Clear the actions done counter. Call this when dumping into the chest. -
getWorkerAI
AI getWorkerAI()Get the worker AI associated to this job- Returns:
- worker AI
-
isIdling
boolean isIdling()Check if the citizen is in an idle state.- Returns:
- true if so.
-
resetAI
void resetAI()Reset the AI. -
allowsAvoidance
boolean allowsAvoidance()Method to check if the colony job allows avoidance.- Returns:
- true if so.
-
getDiseaseModifier
double getDiseaseModifier()Disease modifier of the job.- Returns:
- the modifier of the job.
-
onRemoval
void onRemoval()When job removed (death of citizen or job change). -
ignoresDamage
boolean ignoresDamage(@NotNull @NotNull net.minecraft.world.damagesource.DamageSource damageSource) Check if the particular job ignores a particular damage type.- Parameters:
damageSource- the damage source to check.- Returns:
- true if so.
-
markRequestSync
Mark a request as a synchronous (blocking request).- Parameters:
id- the id.
-
pickupSuccess
boolean pickupSuccess(@NotNull @NotNull net.minecraft.world.item.ItemStack pickedUpStack) If the worker can pick up the stack.- Parameters:
pickedUpStack- the stack to check.- Returns:
- true if so.
-
processOfflineTime
void processOfflineTime(long time) Process time the colony was offline.- Parameters:
time- the time in seconds.
-
serializeToView
void serializeToView(net.minecraft.network.FriendlyByteBuf buffer) Serialize the job to a buffer.- Parameters:
buffer- the buffer to serialize it to.
-
getInactivityLimit
default int getInactivityLimit()Get the time limit in seconds after which the job considers itself inactive.- Returns:
- the limit, or -1 if not applicable.
-
getIdleSeverity
default int getIdleSeverity(boolean isDemand) Get the days before complaining or demanding solution for being idle- Parameters:
isDemand- true if looking for the demand time- Returns:
- number of days
-
triggerActivityChangeAction
default void triggerActivityChangeAction(boolean newState) Trigger a job based action on activity change (active to inactive, or inactive to active).- Parameters:
newState- the new state (true for active, false for inactive).
-
setRegistryEntry
Set the registry entry of the job.- Parameters:
jobEntry- the job entry belonging to it.
-
isGuard
default boolean isGuard()Whether the job is a guard- Returns:
-
getBuildingPos
net.minecraft.core.BlockPos getBuildingPos()Gets the position of the building the job is assigned to- Returns:
-
getWorkBuilding
IBuilding getWorkBuilding()Gets the work building- Returns:
-
getWorkModule
IAssignsJob getWorkModule()Gets the module this job is assigned to -
assignTo
Assigns the job to its specific work module- Parameters:
module-- Returns:
-
getSaturationFactor
default double getSaturationFactor()Job saturation factor.- Returns:
- increase in saturation consumption based on job.
-