Skip to content

PiglinAi 5.46.0 ​

final class · pocketmine\entity\monster\PiglinAi · source

Piglin knowledge shared by piglins, hoglins and the world hooks: the gold they love, the blocks they guard, the blocks piglins and hoglins are afraid of, and the anger at players who open containers or mine gold near them.

Constants ​

GUARD_RANGE ​

php
public const GUARD_RANGE = 16.0

Piglins within this distance of a player who opens a container or mines a guarded block get angry.

Methods ​

angerNearbyPiglins() ​

php
public static function angerNearbyPiglins(\pocketmine\player\Player $player, bool $requireLineOfSight) : int

Makes the piglins within 16 blocks of the player angry at it (gold armor doesn't help). Piglins busy admiring gold, babies and, if asked, those which can't see the player are left alone. Returns how many got angry.

findNearestBlock() ​

php
public static function findNearestBlock(\pocketmine\world\World $world, \pocketmine\math\Vector3 $center, int $range, int $height, array $types, ?\Closure $filter = null) : ?\pocketmine\math\Vector3

Returns the nearest block of the given types within $range blocks horizontally and $height vertically.

getHoglinRepellents() ​

php
public static function getHoglinRepellents() : array

Blocks hoglins avoid (hoglin.json avoid_block, Java tag hoglin_repellents): warped fungus (also potted), nether portals and respawn anchors.

getPiglinRepellents() ​

php
public static function getPiglinRepellents() : array

Blocks piglins avoid (Java tag piglin_repellents): soul fire, soul torches, soul lanterns and lit soul campfires.

isActiveHoglinRepellent() ​

php
public static function isActiveHoglinRepellent(\pocketmine\block\Block $block) : bool

Whether the block really repels hoglins: flower pots only with a warped fungus in them.

isActivePiglinRepellent() ​

php
public static function isActivePiglinRepellent(\pocketmine\block\Block $block) : bool

Whether the block really repels piglins: soul campfires only when lit.

isFood() ​

php
public static function isFood(\pocketmine\item\Item $item) : bool

Food piglins pick up and eat (vanilla piglin_food).

isGuardedBlock() ​

php
public static function isGuardedBlock(\pocketmine\block\Block $block) : bool

Blocks piglins guard (Java tag guarded_by_piglins): breaking one angers the piglins around.

isLovedItem() ​

php
public static function isLovedItem(\pocketmine\item\Item $item) : bool

Gold items piglins pick up and admire (Java tag piglin_loved). Gold ingots are bartered, the rest kept.

onBlockBroken() ​

php
public static function onBlockBroken(\pocketmine\player\Player $player, \pocketmine\block\Block $block) : int

Called when a player broke a block: breaking a guarded block angers the piglins around (Bedrock block_sensor, no line of sight needed).

onContainerOpened() ​

php
public static function onContainerOpened(\pocketmine\player\Player $player) : int

Called when a player opened a chest, trapped chest, ender chest, barrel or shulker box: the piglins around that see the player get angry.

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