Creaking 5.46.0
Extends Monster
Creaking (Bedrock values, creaking.json): 1 health, 0.9x2.7, movement 0.4, attack 3 every 2 seconds.
- Neutral: strolls slowly until a player within 12 blocks looks at it (120 degree field of view), who becomes its target (minecraft:looked_at, set_target "once_and_keep_scanning").
- Hostile: frozen in place while any player within 24 blocks (not wearing a carved pumpkin) looks at it; when nobody looks it walks to its target and attacks it.
- Calms down when its target is gone or more than 24 blocks away.
- Its state ("minecraft:creaking_state") and the sway after a hit ("minecraft:creaking_swaying_ticks", 1 to 6 then reset) are synced to the client as actor properties.
A creaking summoned by a creaking heart ("spawned_by_creaking_heart") remembers the heart's position (NBT "home_pos", like Java) and the heart remembers it (TileCreakingHeart):
- It takes no damage except from the void and /kill-style suicide damage; a hit only makes it sway, and a hit by a player makes the heart react (
CreakingHeart::onCreakingHurt()). It is fire proof and never despawns. - It crumbles (bark particles and death sound, despawns without drops or experience) by day or when more than 34 blocks from its heart, unless it has a name tag; the heart then summons another one when it can. It also crumbles when its heart no longer knows it (heart replaced, or it forgot a creaking that wasn't loaded in time).
- When the heart is broken it twitches for 2.25 seconds, then crumbles. A creaking spawned by a player (spawn egg, summon) has none of this and dies from its single health point.
Not implemented: the heart's 32 block home restriction on movement (a creaking going farther than 34 blocks just crumbles and is replaced), crumbling after sharing a block with a player for 5 seconds, player-spawned creakings avoiding damage blocks and taking lava damage.
Constants
ACTIVATION_RANGE
public const ACTIVATION_RANGE = 12.0ATTACK_COOLDOWN
public const ATTACK_COOLDOWN = 40ATTACK_DAMAGE
public const ATTACK_DAMAGE = 3.0FIELD_OF_VIEW
public const FIELD_OF_VIEW = 120.0HEART_DESPAWN_DISTANCE
public const HEART_DESPAWN_DISTANCE = 34.0home_distance above which a heart-bound creaking crumbles
MAX_SWAYING_TICKS
public const MAX_SWAYING_TICKS = 6creaking_swaying_ticks goes from 1 to this, then back to 0 (it sways for exactly 5 ticks)
OBSERVATION_RANGE
public const OBSERVATION_RANGE = 24.0STATE_CRUMBLING
public const STATE_CRUMBLING = 4STATE_HOSTILE_OBSERVED
public const STATE_HOSTILE_OBSERVED = 1STATE_HOSTILE_UNOBSERVED
public const STATE_HOSTILE_UNOBSERVED = 2STATE_NEUTRAL
public const STATE_NEUTRAL = 0STATE_TWITCHING
public const STATE_TWITCHING = 3TAG_HOME_POS
public const TAG_HOME_POS = "home_pos"TWITCH_TICKS
public const TWITCH_TICKS = 45minecraft:twitching timer: 2.25 seconds
Methods
attack()
public function attack(\pocketmine\event\entity\EntityDamageEvent $source) : voidattackMelee()
public function attackMelee(\pocketmine\entity\Living $target, float $baseDamage) : boolcanDespawn()
public function canDespawn() : boolcrumble()
public function crumble() : voidMakes the creaking crumble: bark particles and death sound, then it despawns without drops (minecraft:crumble).
entityBaseTick() protected
protected function entityBaseTick(int $tickDiff = 1) : boolgetHeartPosition()
public function getHeartPosition() : ?\pocketmine\math\Vector3Returns the position of the creaking heart that summoned this creaking, or null if it wasn't summoned by one.
getHeartTile()
public function getHeartTile() : ?\pocketmine\block\tile\CreakingHeartReturns the heart's block entity if its chunk is loaded and it still has this creaking.
getInitialSizeInfo() protected
protected function getInitialSizeInfo() : \pocketmine\entity\EntitySizeInfogetName()
public function getName() : stringgetNetworkTypeId()
public static function getNetworkTypeId() : stringgetPickedItem()
public function getPickedItem() : ?\pocketmine\item\ItemgetState()
public function getState() : intgetSwayingTicks()
public function getSwayingTicks() : intgetXpDropAmount()
public function getXpDropAmount() : intinitEntity() protected
protected function initEntity(\pocketmine\nbt\tag\CompoundTag $nbt) : voidisFireProof()
public function isFireProof() : boolisFrozen()
public function isFrozen() : boolReturns whether the creaking can't move or attack (minecraft:immobile: watched, twitching or crumbling).
isHeartBound()
public function isHeartBound() : boolReturns whether the creaking was summoned by a creaking heart (and is protected by it).
registerGoals() protected
protected function registerGoals() : voidsaveNBT()
public function saveNBT() : \pocketmine\nbt\tag\CompoundTagsetHeartPosition()
public function setHeartPosition(?\pocketmine\math\Vector3 $pos) : voidTies the creaking to the creaking heart at the given position. Use TileCreakingHeart::setCreaking() to bind both sides.
startTwitching()
public function startTwitching() : voidMakes the creaking twitch for Creaking::TWITCH_TICKS ticks, then crumble (its heart was broken).
syncNetworkData() protected
protected function syncNetworkData(\pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection $properties) : voidtryChangeMovement() protected
protected function tryChangeMovement() : voidupdateLookedAt()
public function updateLookedAt() : voidUpdates the creaking's state from who is looking at it (looked_at_cooldown 0.1 s: called every 2 ticks).
