Piglin 5.46.0
Extends Monster
Implements Ageable, Angerable
Bedrock values (piglin.json): 16 health, movement 0.35 (baby 0.42), 0.6x1.9. Adults hold a golden sword (attack 5) or a crossbow (shoots within 8 blocks, backing off within 4), 50/50 (5% of the swords are golden spears), and wear each piece of golden armor with a 10% chance; 5% spawn as babies, which panic when hurt.
- Neutral to players wearing a piece of golden armor; attacks the others within 16 blocks, and wither skeletons.
- Hurting one angers the piglins within 16 blocks for 30 seconds. So does opening a chest, trapped chest, ender chest, barrel or shulker box in their sight, or breaking a gold block, gold ore, raw gold block, gilded blackstone or one of those containers within 16 blocks (see
PiglinAi), gold armor or not. - Bartering: give an adult a gold ingot (interact) or let it pick one up; it holds it in its off hand and admires it for 8 seconds (admire_item), then throws an item of the bartering table (
PiglinBarter) towards the player. Other gold items it picks up (Java tag piglin_loved) are admired too and kept: golden armor is worn when the slot is free, the rest goes into its 8-slot inventory, dropped on death. Being hurt stops the admiring and keeps it from picking gold up for 20 seconds. Babies don't barter. - Picks up porkchops and eats them (one every 10 seconds).
- Hunts hoglins: an adult which hasn't hunted for 30-120 seconds attacks the nearest adult hoglin within 16 blocks unless the hoglins outnumber the piglins, and calls the piglins around to join; when the hoglin dies, the piglins within 16 blocks celebrate (dance) for 10 seconds. Outnumbered piglins walk away from hoglins instead.
- Flees zombified piglins and zoglins within 6 blocks, and soul fire, soul torches, soul lanterns and lit soul campfires within 8 blocks.
- Turns into a zombified piglin after 15 seconds outside the Nether. Loot: its spawn equipment (8.5%), the gold it picked up and its inventory. Experience 5 (+1-3 per equipped item), baby 1 (+1-2). Not implemented: babies admiring gold, piglins staring at players holding gold, jealousy when a player takes the gold they wanted, riding hoglins as baby piglins, minecart chests (no minecarts).
Constants
ADMIRE_COOLDOWN_TICKS
public const ADMIRE_COOLDOWN_TICKS = 400admire_item cooldown_after_being_attacked
ADMIRE_TICKS
public const ADMIRE_TICKS = 160ANGER_TICKS
public const ANGER_TICKS = 600ARMOR_CHANCE
public const ARMOR_CHANCE = 10ATE_RECENTLY_TICKS
public const ATE_RECENTLY_TICKS = 200ATTACK_DAMAGE
public const ATTACK_DAMAGE = 5.0CELEBRATE_TICKS
public const CELEBRATE_TICKS = 200HUNT_RANGE
public const HUNT_RANGE = 16.0INVENTORY_SIZE
public const INVENTORY_SIZE = 8TAG_ARMOR
public const TAG_ARMOR = "Armor"TAG_ARMOR_KEPT
public const TAG_ARMOR_KEPT = "ArmorKept"TAG_INVENTORY
public const TAG_INVENTORY = "Inventory"TAG_IS_BABY
public const TAG_IS_BABY = "IsBaby"WANTED_ITEM_RANGE
public const WANTED_ITEM_RANGE = 10.0Methods
attack()
public function attack(\pocketmine\event\entity\EntityDamageEvent $source) : voidcountAdultsAround()
public function countAdultsAround() : arrayCounts the adult piglins (this one included) and adult hoglins within 16 blocks.
entityBaseTick() protected
protected function entityBaseTick(int $tickDiff = 1) : boolfindRepellent()
public function findRepellent() : ?\pocketmine\math\Vector3Nearest soul fire, soul torch, soul lantern or lit soul campfire within 8 blocks (4 up or down), looked for once a second.
findWantedItem()
public function findWantedItem() : ?\pocketmine\entity\object\ItemEntityNearest wanted item lying within 10 blocks, looked for once a second while the piglin has no target.
getBarterLoot()
public static function getBarterLoot() : \pocketmine\item\ItemReturns a random item of the bartering table.
getDrops()
public function getDrops() : arraygetHuntCooldown()
public function getHuntCooldown() : intgetInitialSizeInfo() protected
protected function getInitialSizeInfo() : \pocketmine\entity\EntitySizeInfogetInventoryContents()
public function getInventoryContents() : arraygetItemInteractButtonText() protected
protected function getItemInteractButtonText(\pocketmine\player\Player $player, \pocketmine\item\Item $item) : ?stringgetName()
public function getName() : stringgetNetworkTypeId()
public static function getNetworkTypeId() : stringgetPickedItem()
public function getPickedItem() : ?\pocketmine\item\ItemgetXpDropAmount()
public function getXpDropAmount() : inthasCrossbow()
public function hasCrossbow() : boolinitEntity() protected
protected function initEntity(\pocketmine\nbt\tag\CompoundTag $nbt) : voidisAdmiring()
public function isAdmiring() : boolisBaby()
public function isBaby() : boolisCelebrating()
public function isCelebrating() : boolonAngerChange() protected
protected function onAngerChange(bool $angry) : voidonInteractWithItem() protected
protected function onInteractWithItem(\pocketmine\player\Player $player, \pocketmine\item\Item $item) : boolpickUp()
public function pickUp(\pocketmine\entity\object\ItemEntity $entity) : boolPicks one item of the stack up: porkchops are eaten, gold is admired.
registerGoals() protected
protected function registerGoals() : voidsaveNBT()
public function saveNBT() : \pocketmine\nbt\tag\CompoundTagsetBaby()
public function setBaby(bool $baby) : voidsetCharging()
public function setCharging(bool $charging) : voidsetHuntCooldown()
public function setHuntCooldown(int $ticks) : voidshootCrossbow()
public function shootCrossbow(\pocketmine\entity\Living $target, float $distance) : voidstartAdmiring()
public function startAdmiring(?\pocketmine\item\Item $item = null, ?\pocketmine\player\Player $from = null) : voidHolds the item (default: a gold ingot) in its off hand and admires it; afterwards it barters it (gold ingots) or keeps it. $from is the player who gave or threw it, who gets the bartered item.
startCelebrating()
public function startCelebrating() : voidDances for 10 seconds (celebrate_hunt), after a hoglin hunt.
syncNetworkData() protected
protected function syncNetworkData(\pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection $properties) : voidtryHunting()
public function tryHunting() : boolStarts a hunt when possible: an adult not on hunt cooldown, not busy, which sees an adult hoglin and isn't outnumbered. The adult piglins around join the hunt, and none of them hunts again for 30-120 seconds.
wantsItem()
public function wantsItem(\pocketmine\item\Item $item) : boolWhether the piglin would pick up the item now: gold it loves when it's free to admire it, and porkchops when it hasn't eaten recently.
wearsGold()
public static function wearsGold(\pocketmine\entity\Living $entity) : boolPiglins leave alone players wearing at least one piece of golden armor.
wouldAttack()
public function wouldAttack(\pocketmine\entity\Living $entity) : boolWhether the piglin attacks the entity on sight: adults not busy admiring attack wither skeletons and players without golden armor.
zombify() protected
protected function zombify() : void