Class AbstractAssignedCitizenModule

java.lang.Object
com.minecolonies.api.colony.buildings.modules.AbstractBuildingModule
com.minecolonies.core.colony.buildings.modules.AbstractAssignedCitizenModule
All Implemented Interfaces:
IAssignsCitizen, IBuildingEventsModule, IBuildingModule, IPersistentModule, IHasDirty
Direct Known Subclasses:
CourierAssignmentModule, LivingBuildingModule, QuarryModule, WorkerBuildingModule

public abstract class AbstractAssignedCitizenModule extends AbstractBuildingModule implements IAssignsCitizen, IPersistentModule, IBuildingEventsModule
Abstract assignment module.
  • Field Details

    • assignedCitizen

      protected final List<ICitizenData> assignedCitizen
      List of worker assosiated to the building.
  • Constructor Details

    • AbstractAssignedCitizenModule

      public AbstractAssignedCitizenModule()
  • Method Details

    • removeCitizen

      public boolean removeCitizen(@NotNull @NotNull ICitizenData citizen)
      Description copied from interface: IAssignsCitizen
      Specific citizen removal hook for modules.
      Specified by:
      removeCitizen in interface IAssignsCitizen
      Parameters:
      citizen - the removed citizen.
      Returns:
      true if one was removed.
    • assignCitizen

      public boolean assignCitizen(ICitizenData citizen)
      Description copied from interface: IAssignsCitizen
      Specific citizen assignment hook for modules.
      Specified by:
      assignCitizen in interface IAssignsCitizen
      Parameters:
      citizen - the added citizen.
      Returns:
      true if one was added.
    • onDestroyed

      public void onDestroyed()
      Description copied from interface: IBuildingEventsModule
      On destruction hook of the building, calling into the modules.
      Specified by:
      onDestroyed in interface IBuildingEventsModule
    • getAssignedCitizen

      public List<ICitizenData> getAssignedCitizen()
      Description copied from interface: IAssignsCitizen
      Get all assigned citizens to this module.
      Specified by:
      getAssignedCitizen in interface IAssignsCitizen
      Returns:
      the list.
    • getFirstCitizen

      @Nullable public @Nullable ICitizenData getFirstCitizen()
      Get the first citizen assigned to this module.
      Returns:
      this citizen or null.
    • isFull

      public boolean isFull()
      Description copied from interface: IAssignsCitizen
      Check if we can fit additional citizens into the module.
      Specified by:
      isFull in interface IAssignsCitizen
      Returns:
      true if so.
    • hasAssignedCitizen

      public boolean hasAssignedCitizen(ICitizenData citizen)
      Description copied from interface: IAssignsCitizen
      Check if a given citizen is assigned to this module.
      Specified by:
      hasAssignedCitizen in interface IAssignsCitizen
      Parameters:
      citizen - the citizen to check.
      Returns:
      true if so.
    • getAssignedEntities

      @Nullable public @Nullable List<Optional<AbstractEntityCitizen>> getAssignedEntities()
      Description copied from interface: IAssignsCitizen
      Get a list of entities from the assigned citizens.
      Specified by:
      getAssignedEntities in interface IAssignsCitizen
      Returns:
      optional list of entities.
    • hasAssignedCitizen

      public final boolean hasAssignedCitizen()
      Description copied from interface: IAssignsCitizen
      Check if there are any assigned citizens in the module.
      Specified by:
      hasAssignedCitizen in interface IAssignsCitizen
      Returns:
      true if so.
    • serializeNBT

      public void serializeNBT(net.minecraft.nbt.CompoundTag compound)
      Description copied from interface: IPersistentModule
      Serialize the module from a compound.
      Specified by:
      serializeNBT in interface IPersistentModule
      Parameters:
      compound - the compound.
    • deserializeNBT

      public void deserializeNBT(net.minecraft.nbt.CompoundTag compound)
      Description copied from interface: IPersistentModule
      Deserialize the module.
      Specified by:
      deserializeNBT in interface IPersistentModule
      Parameters:
      compound - the nbt compound.
    • serializeToView

      public void serializeToView(@NotNull @NotNull net.minecraft.network.FriendlyByteBuf buf)
      Description copied from interface: IBuildingModule
      Serialization method to send the module data to the client side.
      Specified by:
      serializeToView in interface IBuildingModule
      Parameters:
      buf - the buffer to write it to.
    • setHiringMode

      public void setHiringMode(HiringMode hiringMode)
      Description copied from interface: IAssignsCitizen
      Set the hiring mode (automatic or manual or colony default).
      Specified by:
      setHiringMode in interface IAssignsCitizen
      Parameters:
      hiringMode - the mode to set.
    • getHiringMode

      public HiringMode getHiringMode()
      Description copied from interface: IAssignsCitizen
      Get the hiring mode of the module.
      Specified by:
      getHiringMode in interface IAssignsCitizen
      Returns:
      the mode.
    • getModuleSerializationIdentifier

      @Deprecated protected String getModuleSerializationIdentifier()
      Deprecated.
      Get the identifier for unique serialization. Use for deserialize/serialize only!
      Returns:
      a string identifier.