Class AbstractWorkOrder
java.lang.Object
com.minecolonies.core.colony.workorders.AbstractWorkOrder
- All Implemented Interfaces:
IBuilderWorkOrder,IServerWorkOrder,IWorkOrder
- Direct Known Subclasses:
WorkOrderBuilding,WorkOrderDecoration,WorkOrderMiner,WorkOrderPlantationField
General information between WorkOrders.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.ldtteam.structurize.blueprints.v1.BlueprintThe blueprint of this workorders schematicprotected net.minecraft.world.phys.AABBThe workorder areaprotected booleanInternal flag to see if anything has been changed.protected IColonyColony this workorder is inprotected CompletableFuture<com.ldtteam.structurize.blueprints.v1.Blueprint> The loading future of the blueprintprotected StringThe structurize schematic name.Fields inherited from interface com.minecolonies.api.colony.workorders.IWorkOrder
WORK_ORDER_COMPARATOR -
Constructor Summary
ConstructorsModifierConstructorDescriptionDefault constructor; we also start with a new id and replace it during loading; this greatly simplifies creating subclasses.protectedAbstractWorkOrder(String packName, String path, String translationKey, WorkOrderType workOrderType, net.minecraft.core.BlockPos location, com.ldtteam.structurize.api.RotationMirror rotationMirror, int currentLevel, int targetLevel) -
Method Summary
Modifier and TypeMethodDescriptionbooleancanBeResolved(IColony colony, int level) Check if this workOrder can be resolved by an existing builder.abstract booleanWhether the work order can be built or not.voidClears the stored blueprintstatic IServerWorkOrdercreateFromNBT(@NotNull net.minecraft.nbt.CompoundTag compound, WorkManager manager) Create a Work Order from a saved CompoundTag.static @Nullable IWorkOrderViewcreateWorkOrderView(net.minecraft.network.RegistryFriendlyByteBuf buf) Create a WorkOrder View from a buffer.final intGet the amount of resources this work order still requires.com.ldtteam.structurize.blueprints.v1.BlueprintGet the stored blueprintnet.minecraft.world.phys.AABBGet the blueprints Boundingboxfinal net.minecraft.core.BlockPosGet the position of the Citizen that the Work Order is claimed by.Get the related colony or viewfinal intGet the current level of the structure of the work order.net.minecraft.network.chat.ComponentGet the name of the work order, provides the custom name or the work order name when no custom name is givenfinal intgetID()Get the ID of the work order.final StringGet the iterator type (method of construction) of the work order.final net.minecraft.core.BlockPosGet the current location of the buildingfinal intGetter for the priority.final com.ldtteam.structurize.api.RotationMirrorGet the current rotation and mirror of the buildinggetStage()The buildings stageGet the structure this work order should be using, if any.final StringGet the structure this work order should be using, if any.final intGet the target level of the structure of the work order.final StringThe name of the work order.final WorkOrderTypeThe type of the work order.final booleanIs the Work Order claimed?final booleanWhether the area of the work order has been cleared out or not.final booleanisDirty()Checks if the workOrder has changed.final booleanSet whether the resources for this work order have been requested.booleanIs this WorkOrder still valid? If not, it will be deleted.voidloadBlueprint(net.minecraft.world.level.Level world, Consumer<com.ldtteam.structurize.blueprints.v1.Blueprint> afterLoad) Loads the blueprint if necessaryvoidExecuted when a work order is added.voidonCompleted(IColony colony, ICitizenData citizen) Executed when a work order is completed.voidExecuted when a work order is removed.voidread(@NotNull net.minecraft.nbt.CompoundTag compound, IWorkManager manager) Read the WorkOrder data from the CompoundTag.final voidResets the changed variable.voidserializeViewNetworkData(@NotNull net.minecraft.network.RegistryFriendlyByteBuf buf) Writes the workOrders data to a byte buf for transition.final voidsetAmountOfResources(int newQuantity) Set the amount of resources this work order still requires.voidsetBlueprint(com.ldtteam.structurize.blueprints.v1.Blueprint blueprint, net.minecraft.world.level.Level world) Store a blueprint referencefinal voidsetClaimedBy(net.minecraft.core.BlockPos claimedBy) Set the Work order as claimed by a given building.final voidsetCleared(boolean cleared) Set whether the area of the work order has been cleared out or not.voidSet the related colony or viewfinal voidsetID(int id) Set the ID of the work order.final voidsetIteratorType(String iteratorType) Set the iterator type (method of construction) of the work order.final voidsetPriority(int priority) Setter for the priority.final voidsetRequested(boolean requested) Set whether the building has been cleared.voidsetStage(BuildingProgressStage stage) Sets the building stage of the workorderbooleantooFarFromAnyBuilder(IColony colony, int level) Check if this workOrder can be resolved by an existing builder by distance.voidwrite(@NotNull net.minecraft.nbt.CompoundTag compound) Save the Work Order to an CompoundTag.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.minecolonies.api.colony.workorders.IBuilderWorkOrder
canBuildIgnoringDistanceMethods inherited from interface com.minecolonies.api.colony.workorders.IWorkOrder
getFileName
-
Field Details
-
packName
The structurize schematic name. -
changed
protected boolean changedInternal flag to see if anything has been changed. -
box
protected net.minecraft.world.phys.AABB boxThe workorder area -
blueprint
protected com.ldtteam.structurize.blueprints.v1.Blueprint blueprintThe blueprint of this workorders schematic -
future
The loading future of the blueprint -
colony
Colony this workorder is in
-
-
Constructor Details
-
AbstractWorkOrder
public AbstractWorkOrder()Default constructor; we also start with a new id and replace it during loading; this greatly simplifies creating subclasses. -
AbstractWorkOrder
protected AbstractWorkOrder(String packName, String path, String translationKey, WorkOrderType workOrderType, net.minecraft.core.BlockPos location, com.ldtteam.structurize.api.RotationMirror rotationMirror, int currentLevel, int targetLevel)
-
-
Method Details
-
createFromNBT
public static IServerWorkOrder createFromNBT(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound, WorkManager manager) Create a Work Order from a saved CompoundTag.- Parameters:
compound- the compound that contains the data for the Work Ordermanager- the work manager.- Returns:
IWorkOrderfrom the NBT
-
createWorkOrderView
@Nullable public static @Nullable IWorkOrderView createWorkOrderView(net.minecraft.network.RegistryFriendlyByteBuf buf) Create a WorkOrder View from a buffer.- Parameters:
buf- The network data- Returns:
- View object of the workOrder
-
getID
public final int getID()Description copied from interface:IWorkOrderGet the ID of the work order.- Specified by:
getIDin interfaceIWorkOrder- Returns:
- ID of the work order
-
setID
public final void setID(int id) Description copied from interface:IWorkOrderSet the ID of the work order.- Specified by:
setIDin interfaceIWorkOrder- Parameters:
id- the new ID for the work order
-
getPriority
public final int getPriority()Description copied from interface:IWorkOrderGetter for the priority.- Specified by:
getPriorityin interfaceIWorkOrder- Returns:
- the priority of the work order.
-
setPriority
public final void setPriority(int priority) Description copied from interface:IWorkOrderSetter for the priority.- Specified by:
setPriorityin interfaceIWorkOrder- Parameters:
priority- the new priority.
-
getClaimedBy
public final net.minecraft.core.BlockPos getClaimedBy()Description copied from interface:IWorkOrderGet the position of the Citizen that the Work Order is claimed by.- Specified by:
getClaimedByin interfaceIWorkOrder- Returns:
- ID of citizen the Work Order has been claimed by, BLockpos.ZERO
-
setClaimedBy
public final void setClaimedBy(net.minecraft.core.BlockPos claimedBy) Description copied from interface:IWorkOrderSet the Work order as claimed by a given building.- Specified by:
setClaimedByin interfaceIWorkOrder- Parameters:
claimedBy- the building position.
-
isClaimed
public final boolean isClaimed()Description copied from interface:IWorkOrderIs the Work Order claimed?- Specified by:
isClaimedin interfaceIWorkOrder- Returns:
- true if the Work Order has been claimed
-
getStructurePath
Description copied from interface:IWorkOrderGet the structure this work order should be using, if any.- Specified by:
getStructurePathin interfaceIWorkOrder- Returns:
- the schematic path.
-
getStructurePack
Description copied from interface:IWorkOrderGet the structure this work order should be using, if any.- Specified by:
getStructurePackin interfaceIWorkOrder- Returns:
- the pack name.
-
loadBlueprint
public void loadBlueprint(net.minecraft.world.level.Level world, Consumer<com.ldtteam.structurize.blueprints.v1.Blueprint> afterLoad) Description copied from interface:IWorkOrderLoads the blueprint if necessary- Specified by:
loadBlueprintin interfaceIWorkOrder- Parameters:
world- world to useafterLoad- consumes the loaded blueprint or null
-
getTranslationKey
Description copied from interface:IWorkOrderThe name of the work order.- Specified by:
getTranslationKeyin interfaceIWorkOrder- Returns:
- the work order name.
-
getWorkOrderType
Description copied from interface:IWorkOrderThe type of the work order.- Specified by:
getWorkOrderTypein interfaceIWorkOrder- Returns:
- the work order type.
-
getLocation
public final net.minecraft.core.BlockPos getLocation()Description copied from interface:IWorkOrderGet the current location of the building- Specified by:
getLocationin interfaceIWorkOrder- Returns:
- the location
-
getRotationMirror
public final com.ldtteam.structurize.api.RotationMirror getRotationMirror()Description copied from interface:IWorkOrderGet the current rotation and mirror of the building- Specified by:
getRotationMirrorin interfaceIWorkOrder- Returns:
- the location
-
getCurrentLevel
public final int getCurrentLevel()Description copied from interface:IWorkOrderGet the current level of the structure of the work order.- Specified by:
getCurrentLevelin interfaceIWorkOrder- Returns:
- the current level.
-
getTargetLevel
public final int getTargetLevel()Description copied from interface:IWorkOrderGet the target level of the structure of the work order.- Specified by:
getTargetLevelin interfaceIWorkOrder- Returns:
- the target level.
-
getAmountOfResources
public final int getAmountOfResources()Description copied from interface:IBuilderWorkOrderGet the amount of resources this work order still requires.- Specified by:
getAmountOfResourcesin interfaceIBuilderWorkOrder- Returns:
- the amount of resources.
-
setAmountOfResources
public final void setAmountOfResources(int newQuantity) Description copied from interface:IBuilderWorkOrderSet the amount of resources this work order still requires.- Specified by:
setAmountOfResourcesin interfaceIBuilderWorkOrder- Parameters:
newQuantity- the new amount of resources.
-
getIteratorType
Description copied from interface:IBuilderWorkOrderGet the iterator type (method of construction) of the work order.- Specified by:
getIteratorTypein interfaceIBuilderWorkOrder- Returns:
- the iterator type.
-
setIteratorType
Description copied from interface:IBuilderWorkOrderSet the iterator type (method of construction) of the work order.- Specified by:
setIteratorTypein interfaceIBuilderWorkOrder- Parameters:
iteratorType- the new iterator type.
-
isCleared
public final boolean isCleared()Description copied from interface:IBuilderWorkOrderWhether the area of the work order has been cleared out or not.- Specified by:
isClearedin interfaceIBuilderWorkOrder- Returns:
- true if the area is cleared.
-
setCleared
public final void setCleared(boolean cleared) Description copied from interface:IBuilderWorkOrderSet whether the area of the work order has been cleared out or not.- Specified by:
setClearedin interfaceIBuilderWorkOrder- Parameters:
cleared- the new cleared state.
-
isRequested
public final boolean isRequested()Description copied from interface:IBuilderWorkOrderSet whether the resources for this work order have been requested.- Specified by:
isRequestedin interfaceIBuilderWorkOrder- Returns:
- true when the resources are requested.
-
setRequested
public final void setRequested(boolean requested) Description copied from interface:IBuilderWorkOrderSet whether the building has been cleared.- Specified by:
setRequestedin interfaceIBuilderWorkOrder- Parameters:
requested- true if the building has been cleared.
-
isDirty
public final boolean isDirty()Description copied from interface:IServerWorkOrderChecks if the workOrder has changed.- Specified by:
isDirtyin interfaceIServerWorkOrder- Returns:
- true if so.
-
resetChange
public final void resetChange()Description copied from interface:IServerWorkOrderResets the changed variable.- Specified by:
resetChangein interfaceIServerWorkOrder
-
getDisplayName
public net.minecraft.network.chat.Component getDisplayName()Get the name of the work order, provides the custom name or the work order name when no custom name is given- Specified by:
getDisplayNamein interfaceIWorkOrder- Returns:
- the display name for the work order
-
setBlueprint
public void setBlueprint(com.ldtteam.structurize.blueprints.v1.Blueprint blueprint, net.minecraft.world.level.Level world) Description copied from interface:IWorkOrderStore a blueprint reference- Specified by:
setBlueprintin interfaceIWorkOrder- Parameters:
blueprint-
-
getBlueprint
public com.ldtteam.structurize.blueprints.v1.Blueprint getBlueprint()Description copied from interface:IWorkOrderGet the stored blueprint- Specified by:
getBlueprintin interfaceIWorkOrder- Returns:
-
clearBlueprint
public void clearBlueprint()Description copied from interface:IWorkOrderClears the stored blueprint- Specified by:
clearBlueprintin interfaceIWorkOrder
-
getBoundingBox
public net.minecraft.world.phys.AABB getBoundingBox()Description copied from interface:IWorkOrderGet the blueprints Boundingbox- Specified by:
getBoundingBoxin interfaceIWorkOrder
-
getColony
Description copied from interface:IWorkOrderGet the related colony or view- Specified by:
getColonyin interfaceIWorkOrder- Returns:
-
setColony
Description copied from interface:IWorkOrderSet the related colony or view- Specified by:
setColonyin interfaceIWorkOrder
-
canBuild
Whether the work order can be built or not.- Specified by:
canBuildin interfaceIServerWorkOrder- Parameters:
citizen- the citizen attempting to perform the work order- Returns:
- true if it can be built
-
isValid
Is this WorkOrder still valid? If not, it will be deleted.Suppressing Sonar Rule squid:S1172 This rule does " Unused method parameters should be removed" But in this case extending class may need to use the colony parameter
- Specified by:
isValidin interfaceIServerWorkOrder- Parameters:
colony- The colony that owns the Work Order- Returns:
- True if the WorkOrder is still valid, or False if it should be deleted
-
read
Read the WorkOrder data from the CompoundTag.- Specified by:
readin interfaceIServerWorkOrder- Parameters:
compound- NBT Tag compoundmanager- the workManager calling this method.
-
write
public void write(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound) Save the Work Order to an CompoundTag.- Specified by:
writein interfaceIServerWorkOrder- Parameters:
compound- NBT tag compount
-
serializeViewNetworkData
public void serializeViewNetworkData(@NotNull @NotNull net.minecraft.network.RegistryFriendlyByteBuf buf) Writes the workOrders data to a byte buf for transition.- Specified by:
serializeViewNetworkDatain interfaceIServerWorkOrder- Parameters:
buf- Buffer to write to
-
onAdded
Executed when a work order is added.Override this when something need to be done when the work order is added
- Specified by:
onAddedin interfaceIServerWorkOrder- Parameters:
colony- in which the work order existreadingFromNbt- if being read from NBT.
-
onCompleted
Executed when a work order is completed.Override this when something need to be done when the work order is completed
- Specified by:
onCompletedin interfaceIBuilderWorkOrder- Parameters:
colony- in which the work order existcitizen- citizen that completed the work order
-
onRemoved
Executed when a work order is removed.Override this when something need to be done when the work order is removed
- Specified by:
onRemovedin interfaceIBuilderWorkOrder- Parameters:
colony- in which the work order exist
-
canBeResolved
Check if this workOrder can be resolved by an existing builder.- Specified by:
canBeResolvedin interfaceIBuilderWorkOrder- Parameters:
colony- the colony to check in.level- the new level of the building.- Returns:
- true if so.
-
tooFarFromAnyBuilder
Check if this workOrder can be resolved by an existing builder by distance.- Specified by:
tooFarFromAnyBuilderin interfaceIBuilderWorkOrder- Parameters:
colony- the colony to check in.level- the new level of the building.- Returns:
- true if so.
-
getStage
Description copied from interface:IWorkOrderThe buildings stage- Specified by:
getStagein interfaceIWorkOrder- Returns:
- stage index
-
setStage
Description copied from interface:IBuilderWorkOrderSets the building stage of the workorder- Specified by:
setStagein interfaceIBuilderWorkOrder- Parameters:
stage-
-