Skip to content

FindTreasureGoal 5.47.0 ​

class · pocketmine\entity\ai\goal\FindTreasureGoal · source

Extends Goal

A dolphin that was fed fish leads the way to the nearest treasure (Bedrock behavior.find_underwater_treasure, Java DolphinSwimToTreasureGoal): the nearest ocean ruin, shipwreck or buried treasure within FindTreasureGoal::SEARCH_RADIUS_CHUNKS chunks (Java DOLPHIN_LOCATED structures, the /locate structure locator of the world). It swims there in hops of up to 16 blocks through the water, shows its treasure hunt particles now and then, and stops within 4 blocks of it (horizontally), when no hop through the water is found (stuck) or when it runs low on air; then the fish is used up.

The structure search runs once per feeding, off the main thread when the locator supports it, and its results are cached per world and 128-block area: the goal never searches on its own ticks.

Constants ​

ARRIVE_DISTANCE ​

php
public const ARRIVE_DISTANCE = 4.0

Horizontal distance from the treasure at which the dolphin stops.

MIN_AIR_TICKS ​

php
public const MIN_AIR_TICKS = 100

Air ticks the dolphin needs to lead (Java).

SEARCH_RADIUS_CHUNKS ​

php
public const SEARCH_RADIUS_CHUNKS = 50

Search radius (Java findNearestMapStructure(DOLPHIN_LOCATED, pos, 50, false)).

STRUCTURES ​

php
public const STRUCTURES = ["ocean_ruin", "shipwreck", "buried_treasure"]

Structures dolphins lead to (Java structure tag dolphin_located), as /locate structure names.

Properties ​

$dolphin ​

php
public \pocketmine\entity\aquatic\Dolphin $dolphin

$speedMultiplier ​

php
public float $speedMultiplier

Methods ​

__construct() ​

php
public function __construct(\pocketmine\entity\aquatic\Dolphin $dolphin, float $speedMultiplier = 2.0)

canContinue() ​

php
public function canContinue() : bool

canStart() ​

php
public function canStart() : bool

getFlags() ​

php
public function getFlags() : int

getTreasure() ​

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

Returns the treasure the dolphin swims to, null while it isn't known (yet).

isInterruptible() ​

php
public function isInterruptible() : bool

locateTreasure() ​

php
public static function locateTreasure(\pocketmine\world\World $world, \pocketmine\math\Vector3 $from, \Closure $onResult) : void

Finds the nearest treasure structure (FindTreasureGoal::STRUCTURES) around the position with the world's structure locator and passes it to $onResult (null if there is none, or the world has no locator). The result comes later, on the main thread, when the locator searches off it (AsyncStructureLocator); results are cached per 128-block area, and searches of the same area are shared.

start() ​

php
public function start() : void

stop() ​

php
public function stop() : void

tick() ​

php
public function tick() : void

VanillaMine is a fork of PocketMine-MP. Not affiliated with the PMMP team or Mojang.