Skip to content

HarvestCropsGoal 5.46.0 ​

class · pocketmine\entity\ai\villager\HarvestCropsGoal · source

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 ​

php
public const SEARCH_INTERVAL = 100

SEARCH_RANGE ​

php
public const SEARCH_RANGE = 8

SPEED ​

php
public const SPEED = 0.5

Methods ​

__construct() ​

php
public function __construct(\pocketmine\entity\npc\VillagerV2 $villager)

canContinue() ​

php
public function canContinue() : bool

canStart() ​

php
public function canStart() : bool

findTarget() ​

php
public function findTarget() : ?\pocketmine\math\Vector3

Returns the nearest grown crop, or empty farmland if the farmer has something to plant.

getFlags() ​

php
public function getFlags() : int

getSeedFor() ​

php
public static function getSeedFor(\pocketmine\block\Block $crop) : ?\pocketmine\item\Item

Seed item that plants the crop, keyed by crop block type ID.

start() ​

php
public function start() : void

stop() ​

php
public function stop() : void

tick() ​

php
public function tick() : void

work() ​

php
public function work(\pocketmine\math\Vector3 $pos) : void

Harvests the grown crop at the position and replants it, or plants on the empty farmland below it.

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.