PiglinAi 5.46.0
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
public const GUARD_RANGE = 16.0Piglins within this distance of a player who opens a container or mines a guarded block get angry.
Methods
angerNearbyPiglins()
public static function angerNearbyPiglins(\pocketmine\player\Player $player, bool $requireLineOfSight) : intMakes 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()
public static function findNearestBlock(\pocketmine\world\World $world, \pocketmine\math\Vector3 $center, int $range, int $height, array $types, ?\Closure $filter = null) : ?\pocketmine\math\Vector3Returns the nearest block of the given types within $range blocks horizontally and $height vertically.
getHoglinRepellents()
public static function getHoglinRepellents() : arrayBlocks hoglins avoid (hoglin.json avoid_block, Java tag hoglin_repellents): warped fungus (also potted), nether portals and respawn anchors.
getPiglinRepellents()
public static function getPiglinRepellents() : arrayBlocks piglins avoid (Java tag piglin_repellents): soul fire, soul torches, soul lanterns and lit soul campfires.
isActiveHoglinRepellent()
public static function isActiveHoglinRepellent(\pocketmine\block\Block $block) : boolWhether the block really repels hoglins: flower pots only with a warped fungus in them.
isActivePiglinRepellent()
public static function isActivePiglinRepellent(\pocketmine\block\Block $block) : boolWhether the block really repels piglins: soul campfires only when lit.
isFood()
public static function isFood(\pocketmine\item\Item $item) : boolFood piglins pick up and eat (vanilla piglin_food).
isGuardedBlock()
public static function isGuardedBlock(\pocketmine\block\Block $block) : boolBlocks piglins guard (Java tag guarded_by_piglins): breaking one angers the piglins around.
isLovedItem()
public static function isLovedItem(\pocketmine\item\Item $item) : boolGold items piglins pick up and admire (Java tag piglin_loved). Gold ingots are bartered, the rest kept.
onBlockBroken()
public static function onBlockBroken(\pocketmine\player\Player $player, \pocketmine\block\Block $block) : intCalled when a player broke a block: breaking a guarded block angers the piglins around (Bedrock block_sensor, no line of sight needed).
onContainerOpened()
public static function onContainerOpened(\pocketmine\player\Player $player) : intCalled when a player opened a chest, trapped chest, ender chest, barrel or shulker box: the piglins around that see the player get angry.
