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 building extensions (assigned) to a building.
-
Field Summary
Fields inherited from class com.minecolonies.api.colony.buildings.modules.AbstractBuildingModule
building, isDirty -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanassignExtension(IBuildingExtension extension) Method called to assign a building extension to the building.final booleanGetter for the assign manually.final booleancanAssignExtension(IBuildingExtension extension) Check to see if a new building extension can be assigned to the worker.protected abstract booleancanAssignExtensionOverride(IBuildingExtension extension) Additional checks to see if this building extension can be assigned to the building.voidAttempt to automatically claim free building extensions, if possible and if any building extensions are available.voiddeserializeNBT(net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compound) Deserialize the module.voidfreeExtension(IBuildingExtension extension) Method called to free a building extension.@Nullable IBuildingExtensionRetrieves 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.@Nullable IBuildingExtensionGetter of the current building extension.abstract Class<?> Get the class type which is expected for the building extensions to have.final List<IBuildingExtension> Returns list of free building extensions.abstract @NotNull List<IBuildingExtension> getMatchingExtension(Predicate<IBuildingExtension> predicateToMatch) Returns list of building extensions.protected abstract intGetter to obtain the maximum building extension count.final @NotNull List<IBuildingExtension> Returns list of owned building extensions.final booleanChecks if the building has any building extensions.voidSpecific dirty marking of modules (separate from building dirty).voidonColonyTick(@NotNull IColony colony) Colony tick hook.voidResets the current building extension if the worker indicates this building extension should no longer be worked on.voidserializeNBT(net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compound) Serialize the module from a compound.voidserializeToView(@NotNull net.minecraft.network.RegistryFriendlyByteBuf buf) Serialization method to send the module data to the client side.final voidsetAssignManually(boolean assignManually) Switches the assign manually of the building.Methods inherited from class com.minecolonies.api.colony.buildings.modules.AbstractBuildingModule
checkDirty, clearDirty, getBuilding, getProducer, setBuilding, setProducerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.minecolonies.api.colony.buildings.modules.IBuildingModule
getBuilding, getProducer, serializeToView, setBuilding, setProducerMethods inherited from interface com.minecolonies.api.util.IHasDirty
checkDirty, clearDirty
-
Constructor Details
-
BuildingExtensionsModule
public BuildingExtensionsModule()
-
-
Method Details
-
onColonyTick
Description copied from interface:ITickingModuleColony tick hook.- Specified by:
onColonyTickin interfaceITickingModule- Parameters:
colony- the colony the tick is invoked from.
-
deserializeNBT
public void deserializeNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compound) Description copied from interface:IPersistentModuleDeserialize the module.- Specified by:
deserializeNBTin interfaceIPersistentModule- Parameters:
compound- the nbt compound.
-
serializeNBT
public void serializeNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compound) Description copied from interface:IPersistentModuleSerialize the module from a compound.- Specified by:
serializeNBTin interfaceIPersistentModule- Parameters:
compound- the compound.
-
serializeToView
public void serializeToView(@NotNull @NotNull net.minecraft.network.RegistryFriendlyByteBuf buf) Description copied from interface:IBuildingModuleSerialization method to send the module data to the client side.- Specified by:
serializeToViewin interfaceIBuildingModule- 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
Get the class type which is expected for the building extensions to have.- Returns:
- the class type.
-
getCurrentExtension
Getter of the current building extension.- Returns:
- a building extension object.
-
getBuildingExtensionToWorkOn
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
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
Returns list of free building extensions.- Returns:
- a list of building extension objects.
-
assignExtension
Method called to assign a building extension to the building.- Parameters:
extension- the building extension to add.
-
canAssignExtension
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:IHasDirtySpecific dirty marking of modules (separate from building dirty).- Specified by:
markDirtyin interfaceIHasDirty- Overrides:
markDirtyin classAbstractBuildingModule
-
canAssignExtensionOverride
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
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.
-