Skip to content

CreakingHeart 5.46.0 ​

class · pocketmine\block\CreakingHeart · source

Extends Opaque
Implements PillarRotation, ComparatorReadable

Creaking heart (https://minecraft.wiki/w/Creaking_Heart, vanilla Bedrock 1.26 behaviour).

  • Between two pale oak logs (or wood, stripped or not) along its axis it is dormant by day and awake at night (moon visible: time of day 12600-23400, Overworld only); otherwise uprooted. While it has a creaking it stays rooted even if a log is removed.
  • An awake heart without a creaking summons one every ~20 ticks if a player is within 32 blocks and the difficulty isn't peaceful: 5 attempts at a random column within 16 blocks horizontally and 8 vertically, standing on a full top face that isn't leaves, in a 2 block tall space without collisions, entities or liquid. Hearts placed by players summon creakings too (vanilla); "natural" only decides whether breaking it drops experience.
  • The heart and its creaking remember each other (TileCreakingHeart, Creaking::getHeartPosition()). The creaking is invulnerable; when a player hits it the heart shows a particle trail and, at night, grows 2-3 resin clumps on the pale oak logs around it (at most once every 5 seconds).
  • Breaking the heart makes its creaking twitch and crumble. A comparator reads 15 - floor(distance / 32 * 15) from the creaking's distance (0 without creaking).
  • Drops 1-3 resin clumps (itself with silk touch); natural hearts drop 20-24 experience.

Constants ​

COMPARATOR_RANGE ​

php
public const COMPARATOR_RANGE = 32.0

HURT_REACTION_COOLDOWN ​

php
public const HURT_REACTION_COOLDOWN = 100

NIGHT_END ​

php
public const NIGHT_END = 23400

NIGHT_START ​

php
public const NIGHT_START = 12600

Moon visible (creaking.json "hourly_clock_time" filters, Dimension::isMoonVisible)

RESIN_SPREAD_DEPTH ​

php
public const RESIN_SPREAD_DEPTH = 2

RESIN_SPREAD_MAX_BLOCKS ​

php
public const RESIN_SPREAD_MAX_BLOCKS = 64

SPAWN_ATTEMPTS ​

php
public const SPAWN_ATTEMPTS = 5

SPAWN_PLAYER_RANGE ​

php
public const SPAWN_PLAYER_RANGE = 32

SPAWN_RANGE_XZ ​

php
public const SPAWN_RANGE_XZ = 16

SPAWN_RANGE_Y ​

php
public const SPAWN_RANGE_Y = 8

UPDATE_INTERVAL ​

php
public const UPDATE_INTERVAL = 20

UPDATE_VARIANCE ​

php
public const UPDATE_VARIANCE = 5

Properties ​

$heartState protected ​

php
protected \pocketmine\block\utils\CreakingHeartState $heartState

$natural protected ​

php
protected bool $natural

Methods ​

computeHeartState() ​

php
public function computeHeartState() : \pocketmine\block\utils\CreakingHeartState

Returns the state the heart should have, given the blocks around it, its creaking and the time of day.

describeBlockOnlyState() protected ​

php
protected function describeBlockOnlyState(\pocketmine\data\runtime\RuntimeDataDescriber $w) : void

getComparatorOutput() ​

php
public function getComparatorOutput() : int

getCreaking() ​

php
public function getCreaking() : ?\pocketmine\entity\monster\Creaking

Returns the creaking this heart summoned, if it is loaded.

getDropsForCompatibleTool() ​

php
public function getDropsForCompatibleTool(\pocketmine\item\Item $item) : array

getHeartState() ​

php
public function getHeartState() : \pocketmine\block\utils\CreakingHeartState

getXpDropAmount() protected ​

php
protected function getXpDropAmount() : int

hasRequiredLogs() ​

php
public function hasRequiredLogs() : bool

Returns whether the heart is between two pale oak logs along its axis.

isAffectedBySilkTouch() ​

php
public function isAffectedBySilkTouch() : bool

isNatural() ​

php
public function isNatural() : bool

Returns whether the heart was generated with a pale oak tree (only natural hearts drop experience).

isNaturalNight() ​

php
public static function isNaturalNight(\pocketmine\world\World $world) : bool

Returns whether it is night for creaking hearts in the world (moon visible, Overworld only).

onCreakingHurt() ​

php
public function onCreakingHurt(\pocketmine\entity\monster\Creaking $creaking) : void

Called when the heart's creaking is hit by a player: particle trail and sound, and resin clumps on the pale oak logs around the heart if it is awake (at most once every CreakingHeart::HURT_REACTION_COOLDOWN ticks).

onNearbyBlockChange() ​

php
public function onNearbyBlockChange() : void

onPostPlace() ​

php
public function onPostPlace() : void

onRandomTick() ​

php
public function onRandomTick() : void

onScheduledUpdate() ​

php
public function onScheduledUpdate() : void

The heart's tick (vanilla block entity tick, every 20-24 ticks): updates its state and comparator output and summons a creaking when awake without one.

setHeartState() ​

php
public function setHeartState(\pocketmine\block\utils\CreakingHeartState $state) : self

setNatural() ​

php
public function setNatural(bool $natural) : self

spreadResin() ​

php
public function spreadResin() : ?\pocketmine\math\Vector3

Grows a resin clump face on a pale oak log near the heart (breadth-first through the logs touching it, at most CreakingHeart::RESIN_SPREAD_DEPTH logs away) and returns where, or null if there was no room.

summonCreaking() ​

php
public function summonCreaking(?\pocketmine\block\tile\CreakingHeart $tile = null) : ?\pocketmine\entity\monster\Creaking

Summons the heart's creaking if a spawn position is found (vanilla SpawnUtil.trySpawnMob with the ON_TOP_OF_COLLIDER_NO_LEAVES strategy) and returns it. Doesn't check the time, difficulty or nearby players.

ticksRandomly() ​

php
public function ticksRandomly() : bool

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