Class HarvestHandler
java.lang.Object
me.desht.pneumaticcraft.api.harvesting.HarvestHandler
- Direct Known Subclasses:
HarvestHandler.SimpleHarvestHandler,HarvestHandlerAbstractCrop,HarvestHandlerCactusLike,HarvestHandlerLeaves,HarvestHandlerTree
Defines a generic harvest handler. Register new harvest handlers via the standard Forge deferred register system.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA simple harvest handler which just compares against a list of blocks, without checking any blockstate properties. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList<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 booleancanHarvest(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.voidharvest(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.booleanharvestAndReplant(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.
-
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 worldchunkCache- 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 positionstate- the blockstate at the positiondrone- 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 worldchunkCache- 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 positionstate- the blockstate at the positiondrone- 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 worldchunkCache- 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 checkedstate- the blockstatedrone- 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 aftercanHarvest(Level, BlockGetter, BlockPos, BlockState, IDrone), when that method returns true- Parameters:
world- the worldchunkCache- 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 blockposstate- the blockstatedrone- the drone
-