IronGolem 5.46.0
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
public const DEFEND_VILLAGE_CHANCE = 0.05Chance that a golem near a villager hurt by a player turns on that player (Bedrock defend_village_target).
HOSTILE_REPUTATION
public const HOSTILE_REPUTATION = -100Golems not built by players attack players this disliked by a villager nearby (vanilla: -100).
TAG_PLAYER_CREATED
public const TAG_PLAYER_CREATED = "PlayerCreated"Methods
attack()
public function attack(\pocketmine\event\entity\EntityDamageEvent $source) : voidattackMelee()
public function attackMelee(\pocketmine\entity\Living $target, float $baseDamage) : boolcanBeLeashed()
public function canBeLeashed() : boolgetDrops()
public function getDrops() : arraygetInitialSizeInfo() protected
protected function getInitialSizeInfo() : \pocketmine\entity\EntitySizeInfogetName()
public function getName() : stringgetNetworkTypeId()
public static function getNetworkTypeId() : stringinitEntity() protected
protected function initEntity(\pocketmine\nbt\tag\CompoundTag $nbt) : voidisDislikedByVillagers()
public function isDislikedByVillagers(\pocketmine\player\Player $player) : boolWhether a villager near the golem has a reputation of IronGolem::HOSTILE_REPUTATION or less for the player.
isOfferingFlower()
public function isOfferingFlower() : boolisPlayerCreated()
public function isPlayerCreated() : boolonInteractWithItem() protected
protected function onInteractWithItem(\pocketmine\player\Player $player, \pocketmine\item\Item $item) : boolonVillagerAttacked()
public function onVillagerAttacked(\pocketmine\entity\Living $attacker) : voidCalled 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
protected function registerGoals() : voidsaveNBT()
public function saveNBT() : \pocketmine\nbt\tag\CompoundTagsendSpawnPacket() protected
protected function sendSpawnPacket(\pocketmine\player\Player $player) : voidsetAttackTarget()
public function setAttackTarget(?\pocketmine\entity\Living $target) : voidsetOfferingFlower()
public function setOfferingFlower(bool $offering) : voidHolds out or withdraws a poppy (IRON_GOLEM_OFFER_FLOWER / IRON_GOLEM_WITHDRAW_FLOWER actor events).
setPlayerCreated()
public function setPlayerCreated(bool $playerCreated) : void