public interface IHarvestRegistry
CropsBlock is
supported automatically.
Harvest handlers are Forge registry entries, and should be registered via the Forge registration system:
net.minecraftforge.event.RegistryEvent.Register<HarvestHandler>
| Modifier and Type | Method and Description |
|---|---|
void |
registerHarvestHandler(HarvestHandler harvestHandler)
Registers a generic harvest handler.
|
void |
registerHarvestHandlerCactuslike(java.util.function.Predicate<net.minecraft.block.BlockState> blockChecker)
Registers a harvest handler for block states that need to be farmed like cactus or sugar cane,
in that the top blocks can be harvested as long as there is a plant block left at the bottom.
|
void |
registerHarvestHandlerCroplike(java.util.function.Predicate<net.minecraft.block.BlockState> blockChecker,
net.minecraft.state.IntegerProperty ageProperty,
java.util.function.Predicate<net.minecraft.item.ItemStack> isSeed)
Registers a harvest handler for block states that need to farmed like wheat/carrots/beetroot,
in that the block can be harvested when 'ageProperty' gets to its max growth value.
|
void |
registerHarvestHandlerTreelike(java.util.function.Predicate<net.minecraft.block.BlockState> blockChecker,
java.util.function.Predicate<net.minecraft.item.ItemStack> isSapling,
net.minecraft.block.BlockState saplingState)
Registers a harvest handler for trees.
|
void |
registerHoe(java.util.function.Predicate<net.minecraft.item.ItemStack> isHoeWithDurability,
java.util.function.BiConsumer<net.minecraft.item.ItemStack,net.minecraft.entity.player.PlayerEntity> useDurability)
Registers a custom hoe to be used by drones, by default any subclass of ItemHoe should work already.
|
void registerHarvestHandler(HarvestHandler harvestHandler)
harvestHandler - the harvest handler to registervoid registerHarvestHandlerCactuslike(java.util.function.Predicate<net.minecraft.block.BlockState> blockChecker)
blockChecker - return true if the given block state is a state you target.void registerHarvestHandlerCroplike(java.util.function.Predicate<net.minecraft.block.BlockState> blockChecker,
net.minecraft.state.IntegerProperty ageProperty,
java.util.function.Predicate<net.minecraft.item.ItemStack> isSeed)
blockChecker - return true if the given block state is of a block you target. Checking for the right age is not necessary, this is done automatically.ageProperty - the block state property that keeps track of age. When the current age is equal to the max age, the crop will be harvested.
When requiring to replant, the min value of this property is used. The allowed block state by 'blockChecker' should include this property otherwise the game will crash!isSeed - return true if the given stack is the seed you target. Be aware that this can be called for item stacks that are not dropped from this crop.void registerHarvestHandlerTreelike(java.util.function.Predicate<net.minecraft.block.BlockState> blockChecker,
java.util.function.Predicate<net.minecraft.item.ItemStack> isSapling,
net.minecraft.block.BlockState saplingState)
blockChecker - should return for the logs of this tree.isSapling - should return if the given item stack is a sapling item (which can be used to replant)saplingState - the state of the sapling to be planted.void registerHoe(java.util.function.Predicate<net.minecraft.item.ItemStack> isHoeWithDurability,
java.util.function.BiConsumer<net.minecraft.item.ItemStack,net.minecraft.entity.player.PlayerEntity> useDurability)
isHoeWithDurability - return true if the given item stack is a hoe, with durability left.useDurability - Called when isHoeWithDurability returns true, durability should be used in this implementation.