CreakingHeart 5.46.0
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
public const COMPARATOR_RANGE = 32.0HURT_REACTION_COOLDOWN
public const HURT_REACTION_COOLDOWN = 100NIGHT_END
public const NIGHT_END = 23400NIGHT_START
public const NIGHT_START = 12600Moon visible (creaking.json "hourly_clock_time" filters, Dimension::isMoonVisible)
RESIN_SPREAD_DEPTH
public const RESIN_SPREAD_DEPTH = 2RESIN_SPREAD_MAX_BLOCKS
public const RESIN_SPREAD_MAX_BLOCKS = 64SPAWN_ATTEMPTS
public const SPAWN_ATTEMPTS = 5SPAWN_PLAYER_RANGE
public const SPAWN_PLAYER_RANGE = 32SPAWN_RANGE_XZ
public const SPAWN_RANGE_XZ = 16SPAWN_RANGE_Y
public const SPAWN_RANGE_Y = 8UPDATE_INTERVAL
public const UPDATE_INTERVAL = 20UPDATE_VARIANCE
public const UPDATE_VARIANCE = 5Properties
$heartState protected
protected \pocketmine\block\utils\CreakingHeartState $heartState$natural protected
protected bool $naturalMethods
computeHeartState()
public function computeHeartState() : \pocketmine\block\utils\CreakingHeartStateReturns the state the heart should have, given the blocks around it, its creaking and the time of day.
describeBlockOnlyState() protected
protected function describeBlockOnlyState(\pocketmine\data\runtime\RuntimeDataDescriber $w) : voidgetComparatorOutput()
public function getComparatorOutput() : intgetCreaking()
public function getCreaking() : ?\pocketmine\entity\monster\CreakingReturns the creaking this heart summoned, if it is loaded.
getDropsForCompatibleTool()
public function getDropsForCompatibleTool(\pocketmine\item\Item $item) : arraygetHeartState()
public function getHeartState() : \pocketmine\block\utils\CreakingHeartStategetXpDropAmount() protected
protected function getXpDropAmount() : inthasRequiredLogs()
public function hasRequiredLogs() : boolReturns whether the heart is between two pale oak logs along its axis.
isAffectedBySilkTouch()
public function isAffectedBySilkTouch() : boolisNatural()
public function isNatural() : boolReturns whether the heart was generated with a pale oak tree (only natural hearts drop experience).
isNaturalNight()
public static function isNaturalNight(\pocketmine\world\World $world) : boolReturns whether it is night for creaking hearts in the world (moon visible, Overworld only).
onCreakingHurt()
public function onCreakingHurt(\pocketmine\entity\monster\Creaking $creaking) : voidCalled 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()
public function onNearbyBlockChange() : voidonPostPlace()
public function onPostPlace() : voidonRandomTick()
public function onRandomTick() : voidonScheduledUpdate()
public function onScheduledUpdate() : voidThe 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()
public function setHeartState(\pocketmine\block\utils\CreakingHeartState $state) : selfsetNatural()
public function setNatural(bool $natural) : selfspreadResin()
public function spreadResin() : ?\pocketmine\math\Vector3Grows 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()
public function summonCreaking(?\pocketmine\block\tile\CreakingHeart $tile = null) : ?\pocketmine\entity\monster\CreakingSummons 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()
public function ticksRandomly() : bool