RaidGardenGoal 5.47.0
Extends Goal
Walks to a crop nearby and eats it (vanilla behavior.raid_garden: rabbits and carrots, foxes and sweet berry bushes or cave vines with berries; Java RabbitRaidCarrotGoal and FoxEatBerriesGoal). Once next to the block the mob waits $initialEatDelay ticks, then $eat changes the block (lowers the crop's age, takes the berries). After eating the next search waits $eatDelay ticks, or $fullDelay ticks once the mob ate $maxToEat blocks (0: no limit). Needs mobGriefing.
The search runs at most once every 10-20 seconds while it finds nothing (Java MoveToBlockGoal), and first skips every subchunk of the searched box whose palette has no wanted block state: where there are no crops it costs a few palette checks. A block hanging above air (cave vines) is eaten from the block below it.
Constants
SEARCH_INTERVAL
public const SEARCH_INTERVAL = 200Ticks between two searches which found nothing, plus up to as many at random.
Properties
$condition
public ?\Closure $condition$eat
public \Closure $eat$eatDelay
public int $eatDelay$fullDelay
public int $fullDelay$goalRadius
public float $goalRadius$initialEatDelay
public int $initialEatDelay$isTargetState
public \Closure $isTargetState$maxToEat
public int $maxToEat$mob
public \pocketmine\entity\Mob $mob$searchHeight
public int $searchHeight$searchRange
public int $searchRange$speedMultiplier
public float $speedMultiplierMethods
__construct()
public function __construct(\pocketmine\entity\Mob $mob, \Closure $isTargetState, \Closure $eat, float $speedMultiplier = 1.0, int $searchRange = 16, int $searchHeight = 1, float $goalRadius = 0.5, int $initialEatDelay = 0, int $eatDelay = 40, int $maxToEat = 6, int $fullDelay = 2000, ?\Closure $condition = null)canContinue()
public function canContinue() : boolcanStart()
public function canStart() : boolchangeBlock()
public static function changeBlock(\pocketmine\entity\Mob $mob, \pocketmine\block\Block $from, \pocketmine\block\Block $to) : boolReplaces a block the mob changes (eats), unless a plugin cancels EntityBlockChangeEvent. Returns whether the block was changed.
findNearest()
public function findNearest(\pocketmine\world\World $world, int $x, int $y, int $z) : ?arrayReturns the nearest wanted block within the search range around the mob's feet, with the Y of the mob's feet next to it, or null. The block must be reachable: standing on the ground (a crop, a bush), or hanging with air below it and the ground under that (cave vines at head height).
Like Java MoveToBlockGoal.findNearestBlock, the layers are searched by Y offset (0, +1, -1, +2...) and each layer outwards in square rings, stopping at the first reachable block. Only the subchunks whose palette has a wanted state are read, and a block is checked with a lookup of its state ID in those palettes' wanted states.
getFlags()
public function getFlags() : intgetTarget()
public function getTarget() : ?\pocketmine\math\Vector3Returns the block the mob is going to or eating, null when the goal isn't running.
resetSearchDelay()
public function resetSearchDelay() : voidMakes the next search happen right away (tests, plugins).
start()
public function start() : voidstop()
public function stop() : voidtick()
public function tick() : void