Class BuildingExtensionsModule

java.lang.Object
com.minecolonies.api.colony.buildings.modules.AbstractBuildingModule
com.minecolonies.core.colony.buildings.modules.BuildingExtensionsModule
All Implemented Interfaces:
IBuildingModule, IPersistentModule, ITickingModule, IHasDirty
Direct Known Subclasses:
BuildingFarmer.FarmerFieldsModule, BuildingPlantation.PlantationFieldsModule

public abstract class BuildingExtensionsModule extends AbstractBuildingModule implements IPersistentModule, IBuildingModule, ITickingModule
Abstract class to list all extensions (assigned) to a building.
  • Constructor Details

    • BuildingExtensionsModule

      public BuildingExtensionsModule()
  • Method Details

    • onColonyTick

      public void onColonyTick(@NotNull @NotNull IColony colony)
      Description copied from interface: ITickingModule
      Colony tick hook.
      Specified by:
      onColonyTick in interface ITickingModule
      Parameters:
      colony - the colony the tick is invoked from.
    • 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.
    • 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.
    • 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.
    • getMaxExtensionCount

      protected abstract int getMaxExtensionCount()
      Getter to obtain the maximum building extension count.
      Returns:
      an integer stating the maximum building extension count.
    • getExpectedExtensionType

      public abstract Class<?> getExpectedExtensionType()
      Get the class type which is expected for the building extension to have.
      Returns:
      the class type.
    • getCurrentExtension

      @Nullable public @Nullable IBuildingExtension getCurrentExtension()
      Getter of the current building extension.
      Returns:
      a building extension object.
    • getExtensionToWorkOn

      @Nullable public @Nullable IBuildingExtension getExtensionToWorkOn()
      Retrieves the building extension to work on for the citizen, as long as the current building extension has work, it will keep returning that building extension. Else it will retrieve a random building extension to work on for the citizen. This method will also automatically claim any building extensions that are not in use if the building is on automatic assignment mode.
      Returns:
      a building extension to work on.
    • getOwnedExtensions

      @NotNull public final @NotNull List<IBuildingExtension> getOwnedExtensions()
      Returns list of owned building extensions.
      Returns:
      a list of building extension objects.
    • getMatchingExtension

      @NotNull public abstract @NotNull List<IBuildingExtension> getMatchingExtension(Predicate<IBuildingExtension> predicateToMatch)
      Returns list of building extensions.
      Returns:
      a list of building extension objects.
    • claimExtensions

      public void claimExtensions()
      Attempt to automatically claim free building extensions, if possible and if any building extensions are available.
    • getFreeExtensions

      public final List<IBuildingExtension> getFreeExtensions()
      Returns list of free building extensions.
      Returns:
      a list of building extension objects.
    • assignExtension

      public boolean assignExtension(IBuildingExtension extension)
      Method called to assign a building extension to the building.
      Parameters:
      extension - the building extension to add.
    • canAssignExtension

      public final boolean canAssignExtension(IBuildingExtension extension)
      Check to see if a new building extension can be assigned to the worker.
      Parameters:
      extension - the building extension which is being added.
      Returns:
      true if so.
    • markDirty

      public void markDirty()
      Description copied from interface: IHasDirty
      Specific dirty marking of modules (separate from building dirty).
      Specified by:
      markDirty in interface IHasDirty
      Overrides:
      markDirty in class AbstractBuildingModule
    • canAssignExtensionOverride

      protected abstract boolean canAssignExtensionOverride(IBuildingExtension extension)
      Additional checks to see if this building extension can be assigned to the building.
      Parameters:
      extension - the building extension which is being added.
      Returns:
      true if so.
    • assignManually

      public final boolean assignManually()
      Getter for the assign manually.
      Returns:
      true if he should.
    • hasNoExtensions

      public final boolean hasNoExtensions()
      Checks if the building has any building extensions.
      Returns:
      true if he has none.
    • setAssignManually

      public final void setAssignManually(boolean assignManually)
      Switches the assign manually of the building.
      Parameters:
      assignManually - true if assignment should be manual.
    • freeExtension

      public void freeExtension(IBuildingExtension extension)
      Method called to free a building extension.
      Parameters:
      extension - the building extension to be freed.
    • resetCurrentExtension

      public void resetCurrentExtension()
      Resets the current building extension if the worker indicates this building extension should no longer be worked on.