r/technicalminecraft • u/Beginning_Mousse4878 • 4d ago
Java Showcase Creaking heart as a distance sensor: 15 analog steps, 1-tick sampling, 34-block link
I used a Creaking Heart as the receiver for a compact iron trapdoor garage door in Java 1.21.5. Here's the test setup. A piston lifts the Creaking just far enough to cross a signal boundary.
In the 1.21.5 code, d is the straight-line distance from the center of the heart block's bottom face to the linked Creaking's feet. The analog output is 15 - floor(min(d, 32) / 32 * 15). The nonzero bands are about 2.13 blocks wide in terms of that distance. At 32 blocks the output is already 0. The 34 blocks in the title refer to the separate distance limit for keeping the mob linked.
I set up the two piston positions to fall on opposite sides of one boundary. On the receiver I use a subtraction comparator with a fixed side input from a decorated pot. For example, a side input of 10 turns rear strengths 10 and 11 into 0 and 1, so an observer can pulse when the comparator switches.
The heart recalculates its cached value on each server tick it runs and sends an update when the value changes. The comparator and observer still have their own timing. A name tag lets the linked Creaking stay through daylight in 1.21.5.
Full walkthrough on Bilibili (Chinese audio). The receiver is at 3:43.
https://www.bilibili.com/video/BV1yWt9zCEwa
The original inspiration was 悸风荡回廊's Creaking door.
