All Implemented Interfaces:
IBuildingExtensionModule, IPlantationModule
Direct Known Subclasses:
CocoaPlantModule

public abstract class TreeSidePlantModule extends AbstractPlantationModule
Plantation module for plants that grow attached to any horizontal side of a tree log. Similar to plants like cocoa beans.
Requirements:
  1. Must grow on the side of a vertically standing log.
  2. Must be harvested by chopping and re-planting the plant of the tree.
  3. Every harvestable must be within CitizenConstants.DEFAULT_RANGE_FOR_DELAY blocks range of any available walking position, if not the entity will not be able path to the position.
  • Constructor Details

    • TreeSidePlantModule

      protected TreeSidePlantModule(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

    • decideFieldWork

      public IPlantationModule.PlantationModuleResult.Builder decideFieldWork(net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos workingPosition)
      Description copied from interface: IPlantationModule
      Core function for the planter module, is responsible for telling the AI what to do on the specific field.
      Parameters:
      world - the world reference that can be used for block state lookups.
      workingPosition - the position that has been chosen for work.
      Returns:
      a basic enum state telling the planter AI what the AI should be doing next.
    • isValidPlantingBlock

      protected boolean isValidPlantingBlock(net.minecraft.world.level.block.state.BlockState blockState)
      Check if the block is a correct block for planting. Defaults to being any air block.
      Parameters:
      blockState - the block state.
      Returns:
      whether the block can be planted.
    • isValidClearingBlock

      protected boolean isValidClearingBlock(net.minecraft.world.level.block.state.BlockState blockState)
      Check if the block is a correct block for clearing.
      Parameters:
      blockState - the block state.
      Returns:
      whether the block can be cleared.
    • isValidHarvestBlock

      protected abstract boolean isValidHarvestBlock(net.minecraft.world.level.block.state.BlockState blockState)
      Check if the block is a correct block for harvesting.
      Parameters:
      blockState - the block state.
      Returns:
      whether the block can be harvested.
    • getNextWorkingPosition

      @Nullable public @Nullable net.minecraft.core.BlockPos getNextWorkingPosition(net.minecraft.world.level.Level world)
      Description copied from interface: IPlantationModule
      Obtains the next working position for the given field, if any.
      Parameters:
      world - the world reference that can be used for block state lookups.
      Returns:
      the next position to work on, or null.
    • getActionLimit

      public int getActionLimit()
      Description copied from interface: IPlantationModule
      Returns the maximum amount of actions that can be performed on a field, before the planter must forcefully switch to a new field.
      Returns:
      the maximum of actions the planter can perform on the field per cycle.
    • getRequiredItemsForOperation

      public List<net.minecraft.world.item.ItemStack> getRequiredItemsForOperation()
      Description copied from interface: IPlantationModule
      Returns a list of items that are mandatory for this module to function.
      Returns:
      a list of items.
    • 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
      Overrides:
      getValidWorkingPositions in class AbstractPlantationModule
      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.
    • 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
      Overrides:
      getPositionToWalkTo in class AbstractPlantationModule
      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.