Class AbstractWorkOrder

java.lang.Object
com.minecolonies.core.colony.workorders.AbstractWorkOrder
All Implemented Interfaces:
IBuilderWorkOrder, IServerWorkOrder, IWorkOrder
Direct Known Subclasses:
WorkOrderBuilding, WorkOrderDecoration, WorkOrderMiner, WorkOrderPlantationField

public abstract class AbstractWorkOrder extends Object implements IBuilderWorkOrder
General information between WorkOrders.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected com.ldtteam.structurize.blueprints.v1.Blueprint
    The blueprint of this workorders schematic
    protected net.minecraft.world.phys.AABB
    The workorder area
    protected boolean
    Internal flag to see if anything has been changed.
    protected IColony
    Colony this workorder is in
    protected CompletableFuture<com.ldtteam.structurize.blueprints.v1.Blueprint>
    The loading future of the blueprint
    protected String
    The structurize schematic name.

    Fields inherited from interface com.minecolonies.api.colony.workorders.IWorkOrder

    WORK_ORDER_COMPARATOR
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    Default constructor; we also start with a new id and replace it during loading; this greatly simplifies creating subclasses.
    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 Summary

    Modifier and Type
    Method
    Description
    boolean
    canBeResolved(IColony colony, int level)
    Check if this workOrder can be resolved by an existing builder.
    abstract boolean
    Whether the work order can be built or not.
    void
    Clears the stored blueprint
    createFromNBT(@NotNull net.minecraft.nbt.CompoundTag compound, WorkManager manager)
    Create a Work Order from a saved CompoundTag.
    static @Nullable IWorkOrderView
    createWorkOrderView(net.minecraft.network.RegistryFriendlyByteBuf buf)
    Create a WorkOrder View from a buffer.
    final int
    Get the amount of resources this work order still requires.
    com.ldtteam.structurize.blueprints.v1.Blueprint
    Get the stored blueprint
    net.minecraft.world.phys.AABB
    Get the blueprints Boundingbox
    final net.minecraft.core.BlockPos
    Get the position of the Citizen that the Work Order is claimed by.
    Get the related colony or view
    final int
    Get the current level of the structure of the work order.
    net.minecraft.network.chat.Component
    Get the name of the work order, provides the custom name or the work order name when no custom name is given
    final int
    Get the ID of the work order.
    final String
    Get the iterator type (method of construction) of the work order.
    final net.minecraft.core.BlockPos
    Get the current location of the building
    final int
    Getter for the priority.
    final com.ldtteam.structurize.api.RotationMirror
    Get the current rotation and mirror of the building
    The buildings stage
    Get the structure this work order should be using, if any.
    final String
    Get the structure this work order should be using, if any.
    final int
    Get the target level of the structure of the work order.
    final String
    The name of the work order.
    The type of the work order.
    final boolean
    Is the Work Order claimed?
    final boolean
    Whether the area of the work order has been cleared out or not.
    final boolean
    Checks if the workOrder has changed.
    final boolean
    Set whether the resources for this work order have been requested.
    boolean
    isValid(IColony colony)
    Is this WorkOrder still valid? If not, it will be deleted.
    void
    loadBlueprint(net.minecraft.world.level.Level world, Consumer<com.ldtteam.structurize.blueprints.v1.Blueprint> afterLoad)
    Loads the blueprint if necessary
    void
    onAdded(IColony colony, boolean readingFromNbt)
    Executed when a work order is added.
    void
    onCompleted(IColony colony, ICitizenData citizen)
    Executed when a work order is completed.
    void
    Executed when a work order is removed.
    void
    read(@NotNull net.minecraft.nbt.CompoundTag compound, IWorkManager manager)
    Read the WorkOrder data from the CompoundTag.
    final void
    Resets the changed variable.
    void
    serializeViewNetworkData(@NotNull net.minecraft.network.RegistryFriendlyByteBuf buf)
    Writes the workOrders data to a byte buf for transition.
    final void
    setAmountOfResources(int newQuantity)
    Set the amount of resources this work order still requires.
    void
    setBlueprint(com.ldtteam.structurize.blueprints.v1.Blueprint blueprint, net.minecraft.world.level.Level world)
    Store a blueprint reference
    final void
    setClaimedBy(net.minecraft.core.BlockPos claimedBy)
    Set the Work order as claimed by a given building.
    final void
    setCleared(boolean cleared)
    Set whether the area of the work order has been cleared out or not.
    void
    Set the related colony or view
    final void
    setID(int id)
    Set the ID of the work order.
    final void
    setIteratorType(String iteratorType)
    Set the iterator type (method of construction) of the work order.
    final void
    setPriority(int priority)
    Setter for the priority.
    final void
    setRequested(boolean requested)
    Set whether the building has been cleared.
    void
    Sets the building stage of the workorder
    boolean
    tooFarFromAnyBuilder(IColony colony, int level)
    Check if this workOrder can be resolved by an existing builder by distance.
    void
    write(@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, wait

    Methods inherited from interface com.minecolonies.api.colony.workorders.IBuilderWorkOrder

    canBuildIgnoringDistance

    Methods inherited from interface com.minecolonies.api.colony.workorders.IWorkOrder

    getFileName
  • Field Details

    • packName

      protected String packName
      The structurize schematic name.
    • changed

      protected boolean changed
      Internal flag to see if anything has been changed.
    • box

      protected net.minecraft.world.phys.AABB box
      The workorder area
    • blueprint

      protected com.ldtteam.structurize.blueprints.v1.Blueprint blueprint
      The blueprint of this workorders schematic
    • future

      protected CompletableFuture<com.ldtteam.structurize.blueprints.v1.Blueprint> future
      The loading future of the blueprint
    • colony

      protected IColony 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 Order
      manager - the work manager.
      Returns:
      IWorkOrder from 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: IWorkOrder
      Get the ID of the work order.
      Specified by:
      getID in interface IWorkOrder
      Returns:
      ID of the work order
    • setID

      public final void setID(int id)
      Description copied from interface: IWorkOrder
      Set the ID of the work order.
      Specified by:
      setID in interface IWorkOrder
      Parameters:
      id - the new ID for the work order
    • getPriority

      public final int getPriority()
      Description copied from interface: IWorkOrder
      Getter for the priority.
      Specified by:
      getPriority in interface IWorkOrder
      Returns:
      the priority of the work order.
    • setPriority

      public final void setPriority(int priority)
      Description copied from interface: IWorkOrder
      Setter for the priority.
      Specified by:
      setPriority in interface IWorkOrder
      Parameters:
      priority - the new priority.
    • getClaimedBy

      public final net.minecraft.core.BlockPos getClaimedBy()
      Description copied from interface: IWorkOrder
      Get the position of the Citizen that the Work Order is claimed by.
      Specified by:
      getClaimedBy in interface IWorkOrder
      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: IWorkOrder
      Set the Work order as claimed by a given building.
      Specified by:
      setClaimedBy in interface IWorkOrder
      Parameters:
      claimedBy - the building position.
    • isClaimed

      public final boolean isClaimed()
      Description copied from interface: IWorkOrder
      Is the Work Order claimed?
      Specified by:
      isClaimed in interface IWorkOrder
      Returns:
      true if the Work Order has been claimed
    • getStructurePath

      public final String getStructurePath()
      Description copied from interface: IWorkOrder
      Get the structure this work order should be using, if any.
      Specified by:
      getStructurePath in interface IWorkOrder
      Returns:
      the schematic path.
    • getStructurePack

      public String getStructurePack()
      Description copied from interface: IWorkOrder
      Get the structure this work order should be using, if any.
      Specified by:
      getStructurePack in interface IWorkOrder
      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: IWorkOrder
      Loads the blueprint if necessary
      Specified by:
      loadBlueprint in interface IWorkOrder
      Parameters:
      world - world to use
      afterLoad - consumes the loaded blueprint or null
    • getTranslationKey

      public final String getTranslationKey()
      Description copied from interface: IWorkOrder
      The name of the work order.
      Specified by:
      getTranslationKey in interface IWorkOrder
      Returns:
      the work order name.
    • getWorkOrderType

      public final WorkOrderType getWorkOrderType()
      Description copied from interface: IWorkOrder
      The type of the work order.
      Specified by:
      getWorkOrderType in interface IWorkOrder
      Returns:
      the work order type.
    • getLocation

      public final net.minecraft.core.BlockPos getLocation()
      Description copied from interface: IWorkOrder
      Get the current location of the building
      Specified by:
      getLocation in interface IWorkOrder
      Returns:
      the location
    • getRotationMirror

      public final com.ldtteam.structurize.api.RotationMirror getRotationMirror()
      Description copied from interface: IWorkOrder
      Get the current rotation and mirror of the building
      Specified by:
      getRotationMirror in interface IWorkOrder
      Returns:
      the location
    • getCurrentLevel

      public final int getCurrentLevel()
      Description copied from interface: IWorkOrder
      Get the current level of the structure of the work order.
      Specified by:
      getCurrentLevel in interface IWorkOrder
      Returns:
      the current level.
    • getTargetLevel

      public final int getTargetLevel()
      Description copied from interface: IWorkOrder
      Get the target level of the structure of the work order.
      Specified by:
      getTargetLevel in interface IWorkOrder
      Returns:
      the target level.
    • getAmountOfResources

      public final int getAmountOfResources()
      Description copied from interface: IBuilderWorkOrder
      Get the amount of resources this work order still requires.
      Specified by:
      getAmountOfResources in interface IBuilderWorkOrder
      Returns:
      the amount of resources.
    • setAmountOfResources

      public final void setAmountOfResources(int newQuantity)
      Description copied from interface: IBuilderWorkOrder
      Set the amount of resources this work order still requires.
      Specified by:
      setAmountOfResources in interface IBuilderWorkOrder
      Parameters:
      newQuantity - the new amount of resources.
    • getIteratorType

      public final String getIteratorType()
      Description copied from interface: IBuilderWorkOrder
      Get the iterator type (method of construction) of the work order.
      Specified by:
      getIteratorType in interface IBuilderWorkOrder
      Returns:
      the iterator type.
    • setIteratorType

      public final void setIteratorType(String iteratorType)
      Description copied from interface: IBuilderWorkOrder
      Set the iterator type (method of construction) of the work order.
      Specified by:
      setIteratorType in interface IBuilderWorkOrder
      Parameters:
      iteratorType - the new iterator type.
    • isCleared

      public final boolean isCleared()
      Description copied from interface: IBuilderWorkOrder
      Whether the area of the work order has been cleared out or not.
      Specified by:
      isCleared in interface IBuilderWorkOrder
      Returns:
      true if the area is cleared.
    • setCleared

      public final void setCleared(boolean cleared)
      Description copied from interface: IBuilderWorkOrder
      Set whether the area of the work order has been cleared out or not.
      Specified by:
      setCleared in interface IBuilderWorkOrder
      Parameters:
      cleared - the new cleared state.
    • isRequested

      public final boolean isRequested()
      Description copied from interface: IBuilderWorkOrder
      Set whether the resources for this work order have been requested.
      Specified by:
      isRequested in interface IBuilderWorkOrder
      Returns:
      true when the resources are requested.
    • setRequested

      public final void setRequested(boolean requested)
      Description copied from interface: IBuilderWorkOrder
      Set whether the building has been cleared.
      Specified by:
      setRequested in interface IBuilderWorkOrder
      Parameters:
      requested - true if the building has been cleared.
    • isDirty

      public final boolean isDirty()
      Description copied from interface: IServerWorkOrder
      Checks if the workOrder has changed.
      Specified by:
      isDirty in interface IServerWorkOrder
      Returns:
      true if so.
    • resetChange

      public final void resetChange()
      Description copied from interface: IServerWorkOrder
      Resets the changed variable.
      Specified by:
      resetChange in interface IServerWorkOrder
    • 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:
      getDisplayName in interface IWorkOrder
      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: IWorkOrder
      Store a blueprint reference
      Specified by:
      setBlueprint in interface IWorkOrder
      Parameters:
      blueprint -
    • getBlueprint

      public com.ldtteam.structurize.blueprints.v1.Blueprint getBlueprint()
      Description copied from interface: IWorkOrder
      Get the stored blueprint
      Specified by:
      getBlueprint in interface IWorkOrder
      Returns:
    • clearBlueprint

      public void clearBlueprint()
      Description copied from interface: IWorkOrder
      Clears the stored blueprint
      Specified by:
      clearBlueprint in interface IWorkOrder
    • getBoundingBox

      public net.minecraft.world.phys.AABB getBoundingBox()
      Description copied from interface: IWorkOrder
      Get the blueprints Boundingbox
      Specified by:
      getBoundingBox in interface IWorkOrder
    • getColony

      public IColony getColony()
      Description copied from interface: IWorkOrder
      Get the related colony or view
      Specified by:
      getColony in interface IWorkOrder
      Returns:
    • setColony

      public void setColony(IColony colony)
      Description copied from interface: IWorkOrder
      Set the related colony or view
      Specified by:
      setColony in interface IWorkOrder
    • canBuild

      public abstract boolean canBuild(IBuilding citizen)
      Whether the work order can be built or not.
      Specified by:
      canBuild in interface IServerWorkOrder
      Parameters:
      citizen - the citizen attempting to perform the work order
      Returns:
      true if it can be built
    • isValid

      public boolean isValid(IColony colony)
      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:
      isValid in interface IServerWorkOrder
      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

      public void read(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound, IWorkManager manager)
      Read the WorkOrder data from the CompoundTag.
      Specified by:
      read in interface IServerWorkOrder
      Parameters:
      compound - NBT Tag compound
      manager - 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:
      write in interface IServerWorkOrder
      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:
      serializeViewNetworkData in interface IServerWorkOrder
      Parameters:
      buf - Buffer to write to
    • onAdded

      public void onAdded(IColony colony, boolean readingFromNbt)
      Executed when a work order is added.

      Override this when something need to be done when the work order is added

      Specified by:
      onAdded in interface IServerWorkOrder
      Parameters:
      colony - in which the work order exist
      readingFromNbt - if being read from NBT.
    • onCompleted

      public void onCompleted(IColony colony, ICitizenData citizen)
      Executed when a work order is completed.

      Override this when something need to be done when the work order is completed

      Specified by:
      onCompleted in interface IBuilderWorkOrder
      Parameters:
      colony - in which the work order exist
      citizen - citizen that completed the work order
    • onRemoved

      public void onRemoved(IColony colony)
      Executed when a work order is removed.

      Override this when something need to be done when the work order is removed

      Specified by:
      onRemoved in interface IBuilderWorkOrder
      Parameters:
      colony - in which the work order exist
    • canBeResolved

      public boolean canBeResolved(IColony colony, int level)
      Check if this workOrder can be resolved by an existing builder.
      Specified by:
      canBeResolved in interface IBuilderWorkOrder
      Parameters:
      colony - the colony to check in.
      level - the new level of the building.
      Returns:
      true if so.
    • tooFarFromAnyBuilder

      public boolean tooFarFromAnyBuilder(IColony colony, int level)
      Check if this workOrder can be resolved by an existing builder by distance.
      Specified by:
      tooFarFromAnyBuilder in interface IBuilderWorkOrder
      Parameters:
      colony - the colony to check in.
      level - the new level of the building.
      Returns:
      true if so.
    • getStage

      public BuildingProgressStage getStage()
      Description copied from interface: IWorkOrder
      The buildings stage
      Specified by:
      getStage in interface IWorkOrder
      Returns:
      stage index
    • setStage

      public void setStage(BuildingProgressStage stage)
      Description copied from interface: IBuilderWorkOrder
      Sets the building stage of the workorder
      Specified by:
      setStage in interface IBuilderWorkOrder
      Parameters:
      stage -