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.
  • Field Details

    • DEFAULT_MAX_PLANTS

      protected static final int DEFAULT_MAX_PLANTS
      The 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

      public final String getFieldTag()
      Description copied from interface: IPlantationModule
      Get the field tag property.
      Specified by:
      getFieldTag in interface IPlantationModule
      Returns:
      the field tag.
    • getWorkTag

      public final String getWorkTag()
      Description copied from interface: IPlantationModule
      Get the work tag property.
      Specified by:
      getWorkTag in interface IPlantationModule
      Returns:
      the work tag.
    • getItem

      public final net.minecraft.world.item.Item getItem()
      Description copied from interface: IPlantationModule
      Get the item the module uses.
      Specified by:
      getItem in interface IPlantationModule
      Returns:
      the item.
    • getPlantsToRequest

      public int getPlantsToRequest()
      Description copied from interface: IPlantationModule
      Get the amount of plants to request when the planter no longer has any left. Defaults to quarter stack size of the block.
      Specified by:
      getPlantsToRequest in interface IPlantationModule
      Returns:
      the amount of plants to request.
    • getRequiredResearchEffect

      public net.minecraft.resources.ResourceLocation getRequiredResearchEffect()
      Description copied from interface: IPlantationModule
      Get the required research effect for this module. Null if there is no research required for this field.
      Specified by:
      getRequiredResearchEffect in interface IPlantationModule
      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: IPlantationModule
      Get a list of actual valid working positions, based on the tags read from the plantation field.
      Specified by:
      getValidWorkingPositions in interface IPlantationModule
      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 to DEFAULT_MAX_PLANTS.
      Returns:
      the maximum amount of plants.
    • getValidBonemeal

      public List<net.minecraft.world.item.Item> getValidBonemeal()
      Description copied from interface: IPlantationModule
      Returns which items are considered valid bonemeal items. Defaults to an empty list. (Most modules should not need any bonemeal).
      Specified by:
      getValidBonemeal in interface IPlantationModule
    • getPositionToWalkTo

      public net.minecraft.core.BlockPos getPositionToWalkTo(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos workingPosition)
      Description copied from interface: IPlantationModule
      Determines where the planter should walk to, in order to most effectively work on the given working position. Defaults to the same block.
      Specified by:
      getPositionToWalkTo in interface IPlantationModule
      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: IPlantationModule
      Generate a block state for a new plant.
      Specified by:
      getPlantingBlockState in interface IPlantationModule
      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: IPlantationModule
      Logic for applying bonemeal to the working position.
      Specified by:
      applyBonemeal in interface IPlantationModule
      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

      protected final List<net.minecraft.core.BlockPos> getWorkingPositions()
      Get the working positions on the field.
      Returns:
      a list of working positions.
    • hashCode

      public int hashCode()
      Description copied from interface: IPlantationModule
      Hashcode implementation for this field.
      Specified by:
      hashCode in interface IPlantationModule
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Description copied from interface: IPlantationModule
      Equals implementation for this field.
      Specified by:
      equals in interface IPlantationModule
      Overrides:
      equals in class Object