Skip to content

IronGolem 5.46.0 ​

class · pocketmine\entity\golem\IronGolem · source

Extends Mob

Bedrock values (entities/iron_golem.json): 100 health, 1.4x2.9, movement 0.25, knockback resistance 1, attack 7-21 (random) that throws the target up. Attacks monsters except creepers within 16 blocks, and whoever hurts it except creepers (players too, unless it was built by a player: "PlayerCreated"). Repaired by 25 health with iron ingots. No fall damage. Loot (loot_tables/entities/iron_golem.json): 0-2 poppies, 3-5 iron ingots. Golems not built by players also attack players with a reputation of -100 or less with a villager nearby (see VillagerV2::getPlayerReputation()); villages summon them (see VillagerV2::trySummonGolem()). Offering flowers: see IronGolemOfferFlowerGoal. Golems also step in when a villager within 16 blocks is hurt (see IronGolem::onVillagerAttacked()).

Constants ​

DEFEND_VILLAGE_CHANCE ​

php
public const DEFEND_VILLAGE_CHANCE = 0.05

Chance that a golem near a villager hurt by a player turns on that player (Bedrock defend_village_target).

HOSTILE_REPUTATION ​

php
public const HOSTILE_REPUTATION = -100

Golems not built by players attack players this disliked by a villager nearby (vanilla: -100).

TAG_PLAYER_CREATED ​

php
public const TAG_PLAYER_CREATED = "PlayerCreated"

Methods ​

attack() ​

php
public function attack(\pocketmine\event\entity\EntityDamageEvent $source) : void

attackMelee() ​

php
public function attackMelee(\pocketmine\entity\Living $target, float $baseDamage) : bool

canBeLeashed() ​

php
public function canBeLeashed() : bool

getDrops() ​

php
public function getDrops() : array

getInitialSizeInfo() protected ​

php
protected function getInitialSizeInfo() : \pocketmine\entity\EntitySizeInfo

getName() ​

php
public function getName() : string

getNetworkTypeId() ​

php
public static function getNetworkTypeId() : string

initEntity() protected ​

php
protected function initEntity(\pocketmine\nbt\tag\CompoundTag $nbt) : void

isDislikedByVillagers() ​

php
public function isDislikedByVillagers(\pocketmine\player\Player $player) : bool

Whether a villager near the golem has a reputation of IronGolem::HOSTILE_REPUTATION or less for the player.

isOfferingFlower() ​

php
public function isOfferingFlower() : bool

isPlayerCreated() ​

php
public function isPlayerCreated() : bool

onInteractWithItem() protected ​

php
protected function onInteractWithItem(\pocketmine\player\Player $player, \pocketmine\item\Item $item) : bool

onVillagerAttacked() ​

php
public function onVillagerAttacked(\pocketmine\entity\Living $attacker) : void

Called when a villager within 16 blocks is hurt by an entity. Golems without a target go after monsters and other mobs that hurt villagers; players only make golems that were not built by players hostile, with a 5% chance per hit (Bedrock defend_village_target attack_chance). Players that villagers dislike are attacked anyway (see IronGolem::isDislikedByVillagers()).

registerGoals() protected ​

php
protected function registerGoals() : void

saveNBT() ​

php
public function saveNBT() : \pocketmine\nbt\tag\CompoundTag

sendSpawnPacket() protected ​

php
protected function sendSpawnPacket(\pocketmine\player\Player $player) : void

setAttackTarget() ​

php
public function setAttackTarget(?\pocketmine\entity\Living $target) : void

setOfferingFlower() ​

php
public function setOfferingFlower(bool $offering) : void

Holds out or withdraws a poppy (IRON_GOLEM_OFFER_FLOWER / IRON_GOLEM_WITHDRAW_FLOWER actor events).

setPlayerCreated() ​

php
public function setPlayerCreated(bool $playerCreated) : void

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