Class AbstractJob<AI extends AbstractAISkeleton<J> & ITickingStateAI,J extends AbstractJob<AI,J>>
java.lang.Object
com.minecolonies.core.colony.jobs.AbstractJob<AI,J>
- All Implemented Interfaces:
IJob<AI>,net.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
- Direct Known Subclasses:
AbstractJobCrafter,AbstractJobGuard,AbstractJobStructure,JobArcherTraining,JobBeekeeper,JobChickenHerder,JobCombatTraining,JobComposter,JobCook,JobCowboy,JobDeliveryman,JobFisherman,JobFlorist,JobHealer,JobPlaceholder,JobPupil,JobRabbitHerder,JobResearch,JobShepherd,JobSmelter,JobStablemaster,JobStudent,JobSwineHerder,JobTeacher
public abstract class AbstractJob<AI extends AbstractAISkeleton<J> & ITickingStateAI,J extends AbstractJob<AI,J>>
extends Object
implements IJob<AI>
Basic job information.
Suppressing Sonar Rule squid:S2390 This rule does "Classes should not access static members of their own subclasses during initialization" But in this case the rule does not apply because We are only mapping classes and that is reasonable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IBuildingThe work buildingprotected net.minecraft.core.BlockPosPosition of the work buildingprotected IAssignsJobThe work module we're assigned to -
Constructor Summary
Constructors -
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 AIvoiddeserializeNBT(net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compound) final booleanintGetter 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.final JobEntryTheJobEntryfor 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.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.final inthashCode()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.booleanisIdling()Check if the citizen is in an idle state.voidmarkRequestSync(IToken<?> id) Mark a request as a synchronous (blocking request).voidWhen 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.net.minecraft.nbt.CompoundTagserializeNBT(net.minecraft.core.HolderLookup.Provider provider) voidserializeToView(net.minecraft.network.RegistryFriendlyByteBuf buffer) Serialize the job to a buffer.voidSets that the citizen on this day already searched for food in his chest.final voidsetNameTag(String nameTag) Used by the AI skeleton to change a citizens name.voidsetRegistryEntry(JobEntry jobEntry) Set the registry entry of the job.voidtriggerDeathAchievement(net.minecraft.world.damagesource.DamageSource source, AbstractEntityCitizen citizen) Override this to implement Job specific death achievements.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.minecolonies.api.colony.jobs.IJob
generateAI, getIdleSeverity, getInactivityLimit, getSaturationFactor, initEntityValues, isGuard, onLevelUp, triggerActivityChangeAction
-
Field Details
-
workBuildingPos
protected net.minecraft.core.BlockPos workBuildingPosPosition of the work building -
workBuilding
The work building -
workModule
The work module we're assigned to
-
-
Constructor Details
-
AbstractJob
Initialize citizen data.- Parameters:
entity- the citizen data.
-
-
Method Details
-
pickupSuccess
public boolean pickupSuccess(@NotNull @NotNull net.minecraft.world.item.ItemStack pickedUpStack) Description copied from interface:IJobIf the worker can pick up the stack.- Specified by:
pickupSuccessin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Parameters:
pickedUpStack- the stack to check.- Returns:
- true if so.
-
getModel
public net.minecraft.resources.ResourceLocation getModel()Description copied from interface:IJobGet the RenderBipedCitizen.Model to use when the Citizen performs this job role.- Specified by:
getModelin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Returns:
- Model of the citizen.
-
getColony
Description copied from interface:IJobGet the Colony that this Job is associated with (shortcut for getAssignedCitizen().getColonyByPosFromWorld()).- Specified by:
getColonyin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Returns:
IColonyof the citizen.
-
setRegistryEntry
Description copied from interface:IJobSet the registry entry of the job.- Specified by:
setRegistryEntryin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Parameters:
jobEntry- the job entry belonging to it.
-
getBuildingPos
public net.minecraft.core.BlockPos getBuildingPos()Description copied from interface:IJobGets the position of the building the job is assigned to- Specified by:
getBuildingPosin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Returns:
-
getWorkBuilding
Description copied from interface:IJobGets the work building- Specified by:
getWorkBuildingin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Returns:
-
getWorkModule
Description copied from interface:IJobGets the module this job is assigned to- Specified by:
getWorkModulein interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>
-
assignTo
Description copied from interface:IJobAssigns the job to its specific work module- Specified by:
assignToin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Parameters:
module-- Returns:
-
getJobRegistryEntry
Description copied from interface:IJobTheJobEntryfor this job.- Specified by:
getJobRegistryEntryin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Returns:
- The
JobEntry.
-
serializeNBT
public net.minecraft.nbt.CompoundTag serializeNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider) - Specified by:
serializeNBTin interfacenet.neoforged.neoforge.common.util.INBTSerializable<AI extends AbstractAISkeleton<J> & ITickingStateAI>
-
deserializeNBT
public void deserializeNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compound) - Specified by:
deserializeNBTin interfacenet.neoforged.neoforge.common.util.INBTSerializable<AI extends AbstractAISkeleton<J> & ITickingStateAI>
-
serializeToView
public void serializeToView(net.minecraft.network.RegistryFriendlyByteBuf buffer) Description copied from interface:IJobSerialize the job to a buffer.- Specified by:
serializeToViewin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Parameters:
buffer- the buffer to serialize it to.
-
getAsyncRequests
Get a set of async requests connected to this job.- Specified by:
getAsyncRequestsin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Returns:
- a set of ITokens.
-
markRequestSync
Description copied from interface:IJobMark a request as a synchronous (blocking request).- Specified by:
markRequestSyncin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Parameters:
id- the id.
-
createAI
public void createAI()Description copied from interface:IJobCreates the work AI- Specified by:
createAIin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>
-
hasCheckedForFoodToday
public boolean hasCheckedForFoodToday()Description copied from interface:IJobCheck if the citizen already checked for food in his chest today.- Specified by:
hasCheckedForFoodTodayin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Returns:
- true if so.
-
setCheckedForFood
public void setCheckedForFood()Description copied from interface:IJobSets that the citizen on this day already searched for food in his chest.- Specified by:
setCheckedForFoodin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>
-
getNameTagDescription
Description copied from interface:IJobThis method can be used to display the current status. That a citizen is having.- Specified by:
getNameTagDescriptionin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Returns:
- Small string to display info in name tag
-
setNameTag
Description copied from interface:IJobUsed by the AI skeleton to change a citizens name. Mostly used to update debugging information.- Specified by:
setNameTagin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Parameters:
nameTag- The name tag to display.
-
triggerDeathAchievement
public void triggerDeathAchievement(net.minecraft.world.damagesource.DamageSource source, AbstractEntityCitizen citizen) Description copied from interface:IJobOverride this to implement Job specific death achievements.- Specified by:
triggerDeathAchievementin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Parameters:
source- of the deathcitizen- which just died
-
onStackPickUp
public boolean onStackPickUp(@NotNull @NotNull net.minecraft.world.item.ItemStack pickedUpStack) Description copied from interface:IJobMethod called when a stack is pickup by the entity.- Specified by:
onStackPickUpin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Parameters:
pickedUpStack- The stack that is being picked up.- Returns:
- true when the stack has been used to resolve a request, false when not.
-
getCitizen
Description copied from interface:IJobGet the CitizenData that this Job belongs to.- Specified by:
getCitizenin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Returns:
- CitizenData that owns this Job.
-
onWakeUp
public void onWakeUp()Description copied from interface:IJobExecuted every time the colony woke up.- Specified by:
onWakeUpin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>
-
canAIBeInterrupted
public boolean canAIBeInterrupted()Description copied from interface:IJobCheck if it is okay to eat- Specified by:
canAIBeInterruptedin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Returns:
- true if so.
-
getActionsDone
public int getActionsDone()Description copied from interface:IJobGetter for the amount of actions done.- Specified by:
getActionsDonein interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Returns:
- the quantity.
-
incrementActionsDone
public void incrementActionsDone()Description copied from interface:IJobIncrease the actions done since the last reset by 1 Used for example to detect if and when the inventory has to be dumped.- Specified by:
incrementActionsDonein interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>
-
incrementActionsDone
public void incrementActionsDone(int numberOfActions) Description copied from interface:IJobIncrease the actions done since the last reset by numberOfActions Used for example to detect if and when the inventory has to be dumped.- Specified by:
incrementActionsDonein interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>
-
clearActionsDone
public void clearActionsDone()Description copied from interface:IJobClear the actions done counter. Call this when dumping into the chest.- Specified by:
clearActionsDonein interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>
-
getWorkerAI
Description copied from interface:IJobGet the worker AI associated to this job- Specified by:
getWorkerAIin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Returns:
- worker AI
-
isIdling
public boolean isIdling()Description copied from interface:IJobCheck if the citizen is in an idle state.- Specified by:
isIdlingin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Returns:
- true if so.
-
resetAI
public void resetAI()Description copied from interface:IJobReset the AI.- Specified by:
resetAIin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>
-
allowsAvoidance
public boolean allowsAvoidance()Description copied from interface:IJobMethod to check if the colony job allows avoidance.- Specified by:
allowsAvoidancein interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Returns:
- true if so.
-
getDiseaseModifier
public double getDiseaseModifier()Description copied from interface:IJobDisease modifier of the job.- Specified by:
getDiseaseModifierin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Returns:
- the modifier of the job.
-
onRemoval
public void onRemoval()Description copied from interface:IJobWhen job removed (death of citizen or job change).- Specified by:
onRemovalin interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>
-
ignoresDamage
public boolean ignoresDamage(@NotNull @NotNull net.minecraft.world.damagesource.DamageSource damageSource) Description copied from interface:IJobCheck if the particular job ignores a particular damage type.- Specified by:
ignoresDamagein interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Parameters:
damageSource- the damage source to check.- Returns:
- true if so.
-
processOfflineTime
public void processOfflineTime(long time) Description copied from interface:IJobProcess time the colony was offline.- Specified by:
processOfflineTimein interfaceIJob<AI extends AbstractAISkeleton<J> & ITickingStateAI>- Parameters:
time- the time in seconds.
-
equals
-
hashCode
public final int hashCode()
-