HarvestCropsGoal 5.46.0
Extends VillagerGoal
Farmers harvest grown wheat, carrots, potatoes and beetroots around them during working hours and replant the farmland with seeds from their inventory (vanilla behavior.harvest_farm_block, priority 7, speed 0.5). The harvest goes into the farmer's inventory (what doesn't fit is dropped). Fertilizing with bone meal is not implemented.
Crops are looked for every HarvestCropsGoal::SEARCH_INTERVAL ticks in a box of HarvestCropsGoal::SEARCH_RANGE blocks around, reading only the sub-chunks that have crops or farmland.
Constants
SEARCH_INTERVAL
public const SEARCH_INTERVAL = 100SEARCH_RANGE
public const SEARCH_RANGE = 8SPEED
public const SPEED = 0.5Methods
__construct()
public function __construct(\pocketmine\entity\npc\VillagerV2 $villager)canContinue()
public function canContinue() : boolcanStart()
public function canStart() : boolfindTarget()
public function findTarget() : ?\pocketmine\math\Vector3Returns the nearest grown crop, or empty farmland if the farmer has something to plant.
getFlags()
public function getFlags() : intgetSeedFor()
public static function getSeedFor(\pocketmine\block\Block $crop) : ?\pocketmine\item\ItemSeed item that plants the crop, keyed by crop block type ID.
start()
public function start() : voidstop()
public function stop() : voidtick()
public function tick() : voidwork()
public function work(\pocketmine\math\Vector3 $pos) : voidHarvests the grown crop at the position and replants it, or plants on the empty farmland below it.
