Class AbstractPlantationModule
java.lang.Object
com.minecolonies.core.colony.buildingextensions.modules.AbstractBuildingExtensionModule
com.minecolonies.core.colony.buildings.workerbuildings.plantation.AbstractPlantationModule
- All Implemented Interfaces:
IBuildingExtensionModule,IPlantationModule
- Direct Known Subclasses:
BoneMealedPlantModule,DownwardsGrowingPlantModule,PercentageHarvestPlantModule,TreeSidePlantModule,UpwardsGrowingPlantModule
public abstract class AbstractPlantationModule
extends AbstractBuildingExtensionModule
implements IPlantationModule
Base class for planter modules that determines how the AI should work specific fields.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.minecolonies.api.colony.buildingextensions.plantation.IPlantationModule
IPlantationModule.ActionToPerform, IPlantationModule.PlantationModuleResult, IPlantationModule.PlanterAIModuleResultResetState -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intThe default maximum amount of plants the field can have.Fields inherited from class com.minecolonies.core.colony.buildingextensions.modules.AbstractBuildingExtensionModule
extension -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractPlantationModule(IBuildingExtension field, String fieldTag, String workTag, net.minecraft.world.item.Item item) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyBonemeal(AbstractEntityCitizen worker, net.minecraft.core.BlockPos workPosition, net.minecraft.world.item.ItemStack stackInSlot, net.minecraft.world.entity.player.Player fakePlayer) Logic for applying bonemeal to the working position.booleanEquals implementation for this field.final StringGet the field tag property.final net.minecraft.world.item.ItemgetItem()Get the item the module uses.protected intGet the maximum amount of working positions this field is allowed to handle.net.minecraft.world.level.block.state.BlockStategetPlantingBlockState(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos workPosition, net.minecraft.world.level.block.state.BlockState blockState) Generate a block state for a new plant.intGet the amount of plants to request when the planter no longer has any left.net.minecraft.core.BlockPosgetPositionToWalkTo(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos workingPosition) Determines where the planter should walk to, in order to most effectively work on the given working position.net.minecraft.resources.ResourceLocationGet the required research effect for this module.List<net.minecraft.world.item.Item> Returns which items are considered valid bonemeal items.List<net.minecraft.core.BlockPos> getValidWorkingPositions(@NotNull net.minecraft.world.level.Level world, List<net.minecraft.core.BlockPos> workingPositions) Get a list of actual valid working positions, based on the tags read from the plantation field.protected final List<net.minecraft.core.BlockPos> Get the working positions on the field.final StringGet the work tag property.inthashCode()Hashcode implementation for this field.Methods inherited from class com.minecolonies.core.colony.buildingextensions.modules.AbstractBuildingExtensionModule
getExtensionMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.minecolonies.api.colony.buildingextensions.modules.IBuildingExtensionModule
getExtensionMethods inherited from interface com.minecolonies.api.colony.buildingextensions.plantation.IPlantationModule
decideFieldWork, getActionLimit, getNextWorkingPosition, getRequiredItemsForOperation, getRequiredTool
-
Field Details
-
DEFAULT_MAX_PLANTS
protected static final int DEFAULT_MAX_PLANTSThe default maximum amount of plants the field can have.- See Also:
-
-
Constructor Details
-
AbstractPlantationModule
protected AbstractPlantationModule(IBuildingExtension field, String fieldTag, String workTag, net.minecraft.world.item.Item item) Default constructor.- Parameters:
field- the field instance this module is working on.fieldTag- the tag of the field anchor block.workTag- the tag of the working positions.item- the item which is harvested.
-
-
Method Details
-
getFieldTag
Description copied from interface:IPlantationModuleGet the field tag property.- Specified by:
getFieldTagin interfaceIPlantationModule- Returns:
- the field tag.
-
getWorkTag
Description copied from interface:IPlantationModuleGet the work tag property.- Specified by:
getWorkTagin interfaceIPlantationModule- Returns:
- the work tag.
-
getItem
public final net.minecraft.world.item.Item getItem()Description copied from interface:IPlantationModuleGet the item the module uses.- Specified by:
getItemin interfaceIPlantationModule- Returns:
- the item.
-
getPlantsToRequest
public int getPlantsToRequest()Description copied from interface:IPlantationModuleGet the amount of plants to request when the planter no longer has any left. Defaults to quarter stack size of the block.- Specified by:
getPlantsToRequestin interfaceIPlantationModule- Returns:
- the amount of plants to request.
-
getRequiredResearchEffect
public net.minecraft.resources.ResourceLocation getRequiredResearchEffect()Description copied from interface:IPlantationModuleGet the required research effect for this module. Null if there is no research required for this field.- Specified by:
getRequiredResearchEffectin interfaceIPlantationModule- Returns:
- the key of where to find the effect.
-
getValidWorkingPositions
public List<net.minecraft.core.BlockPos> getValidWorkingPositions(@NotNull @NotNull net.minecraft.world.level.Level world, List<net.minecraft.core.BlockPos> workingPositions) Description copied from interface:IPlantationModuleGet a list of actual valid working positions, based on the tags read from the plantation field.- Specified by:
getValidWorkingPositionsin interfaceIPlantationModule- Parameters:
world- the level the tags were read from.workingPositions- the list of initially parsed working positions, based on work tag.- Returns:
- the list of actually valid parsed working positions.
-
getMaxWorkingPositions
protected int getMaxWorkingPositions()Get the maximum amount of working positions this field is allowed to handle. Defaults toDEFAULT_MAX_PLANTS.- Returns:
- the maximum amount of plants.
-
getValidBonemeal
Description copied from interface:IPlantationModuleReturns which items are considered valid bonemeal items. Defaults to an empty list. (Most modules should not need any bonemeal).- Specified by:
getValidBonemealin interfaceIPlantationModule
-
getPositionToWalkTo
public net.minecraft.core.BlockPos getPositionToWalkTo(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos workingPosition) Description copied from interface:IPlantationModuleDetermines where the planter should walk to, in order to most effectively work on the given working position. Defaults to the same block.- Specified by:
getPositionToWalkToin interfaceIPlantationModule- Parameters:
world- the world reference that can be used for block state lookups.workingPosition- the original working position.- Returns:
- the position for the planter to walk to.
-
getPlantingBlockState
public net.minecraft.world.level.block.state.BlockState getPlantingBlockState(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos workPosition, net.minecraft.world.level.block.state.BlockState blockState) Description copied from interface:IPlantationModuleGenerate a block state for a new plant.- Specified by:
getPlantingBlockStatein interfaceIPlantationModule- Parameters:
world- the world reference that can be used for block state lookups.workPosition- the position that has been chosen for work.blockState- the default block state for the block.
-
applyBonemeal
public void applyBonemeal(AbstractEntityCitizen worker, net.minecraft.core.BlockPos workPosition, net.minecraft.world.item.ItemStack stackInSlot, net.minecraft.world.entity.player.Player fakePlayer) Description copied from interface:IPlantationModuleLogic for applying bonemeal to the working position.- Specified by:
applyBonemealin interfaceIPlantationModule- Parameters:
worker- the worker entity working on the plantation.workPosition- the position that has been chosen for work.stackInSlot- the item stack to use for the planting.fakePlayer- a fake player class to use.
-
getWorkingPositions
Get the working positions on the field.- Returns:
- a list of working positions.
-
hashCode
public int hashCode()Description copied from interface:IPlantationModuleHashcode implementation for this field.- Specified by:
hashCodein interfaceIPlantationModule- Overrides:
hashCodein classObject
-
equals
Description copied from interface:IPlantationModuleEquals implementation for this field.- Specified by:
equalsin interfaceIPlantationModule- Overrides:
equalsin classObject
-