Class HarvestHandler

java.lang.Object
net.minecraftforge.registries.ForgeRegistryEntry<HarvestHandler>
me.desht.pneumaticcraft.api.harvesting.HarvestHandler
All Implemented Interfaces:
net.minecraftforge.registries.IForgeRegistryEntry<HarvestHandler>
Direct Known Subclasses:
HarvestHandler.SimpleHarvestHandler, HarvestHandlerAbstractCrop, HarvestHandlerCactusLike, HarvestHandlerLeaves, HarvestHandlerTree

public abstract class HarvestHandler extends net.minecraftforge.registries.ForgeRegistryEntry<HarvestHandler>
Defines a generic harvest handler. Register new harvest handlers via Forge registry events: RegistryEvent.Register
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    A simple harvest handler which just compares against a list of blocks, without checking any blockstate properties.

    Nested classes/interfaces inherited from class net.minecraftforge.registries.ForgeRegistryEntry

    net.minecraftforge.registries.ForgeRegistryEntry.UncheckedRegistryEntry<V extends net.minecraftforge.registries.IForgeRegistryEntry<V>>
  • Field Summary

    Fields inherited from class net.minecraftforge.registries.ForgeRegistryEntry

    delegate
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    List<net.minecraft.world.item.ItemStack>
    addFilterItems(net.minecraft.world.level.Level world, net.minecraft.world.level.BlockGetter chunkCache, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, IDrone drone)
    Should add the items the connected item filters in the Harvest puzzle piece in the Programmer can use to determine if a block should be harvested.
    abstract boolean
    canHarvest(net.minecraft.world.level.Level world, net.minecraft.world.level.BlockGetter chunkCache, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, IDrone drone)
    Determines if the currently checked block can be harvested.
    void
    harvest(net.minecraft.world.level.Level world, net.minecraft.world.level.BlockGetter chunkCache, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, IDrone drone)
    Should actually harvest the block.
    boolean
    harvestAndReplant(net.minecraft.world.level.Level world, net.minecraft.world.level.BlockGetter chunkCache, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, IDrone drone)
    Should harvest the block (drop items), and replant the plant if applicable.

    Methods inherited from class net.minecraftforge.registries.ForgeRegistryEntry

    getRegistryName, getRegistryType, setRegistryName, setRegistryName, setRegistryName

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • HarvestHandler

      public HarvestHandler()
  • Method Details

    • harvest

      public void harvest(net.minecraft.world.level.Level world, net.minecraft.world.level.BlockGetter chunkCache, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, IDrone drone)
      Should actually harvest the block. Usually this is just a matter of breaking the block, but you can override this for custom behavior.
      Parameters:
      world - the world
      chunkCache - Use preferably methods from this cache as it's generally quicker than accessing via 'world'. The cache has access to the chunks that are accessed by the Drone current program, so as long as only the y pos is varied of the supplied pos, you are good. If not, use 'world'.
      pos - the block's position
      state - the blockstate at the position
      drone - the drone doing the harvesting
    • harvestAndReplant

      public boolean harvestAndReplant(net.minecraft.world.level.Level world, net.minecraft.world.level.BlockGetter chunkCache, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, IDrone drone)
      Should harvest the block (drop items), and replant the plant if applicable. For example, for crops it should reset the growth stage to 0.
      Parameters:
      world - the world
      chunkCache - Use preferably methods from this cache as it's generally quicker than accessing via 'world'. The cache has access to the chunks that are accessed by the Drone current program, so as long as only the y pos is varied of the supplied pos, you are good. If not, use 'world'.
      pos - the block's position
      state - the blockstate at the position
      drone - the drone doing the harvesting
      Returns:
      true if the replanting succeeded (and the hoe the Drone carries needs to be damaged). If nothing needed to be replanted return false.
    • canHarvest

      public abstract boolean canHarvest(net.minecraft.world.level.Level world, net.minecraft.world.level.BlockGetter chunkCache, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, IDrone drone)
      Determines if the currently checked block can be harvested.
      Parameters:
      world - the world
      chunkCache - Use preferably methods from this cache as it's generally quicker than accessing via 'world'. The cache has access to the chunks that are accessed by the Drone current program, so as long as only the y pos is varied of the supplied pos, you are good. If not, use 'world'.
      pos - the blockpos to be checked
      state - the blockstate
      drone - the drone
      Returns:
      true if the block can be harvested, false if not.
    • addFilterItems

      public List<net.minecraft.world.item.ItemStack> addFilterItems(net.minecraft.world.level.Level world, net.minecraft.world.level.BlockGetter chunkCache, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, IDrone drone)
      Should add the items the connected item filters in the Harvest puzzle piece in the Programmer can use to determine if a block should be harvested. Called after canHarvest(World, IBlockReader, BlockPos, BlockState, IDrone), when that method returns true
      Parameters:
      world - the world
      chunkCache - Use preferably methods from this cache as it's generally quicker than accessing via 'world'. The cache has access to the chunks that are accessed by the Drone current program, so as long as only the y pos is varied of the supplied pos, you are good. If not, use 'world'.
      pos - the blockpos
      state - the blockstate
      drone - the drone