Skip to content

Instantly share code, notes, and snippets.

@OMAR-3OOV
Last active February 26, 2023 21:12
Show Gist options
  • Save OMAR-3OOV/d1bb55eb4f6d36611099fb707009370e to your computer and use it in GitHub Desktop.
Save OMAR-3OOV/d1bb55eb4f6d36611099fb707009370e to your computer and use it in GitHub Desktop.
Draw heart under player and make it rotate depends on player direction
fun drawHeart(player: Player) {
val loc = player.location.add(0.0 , 0.5, 0.0)
val radius = 0.1
val particleType = Particle.REDSTONE
val step = Math.PI / 32
for (i in 0..63) {
val theta = i * step
val x = radius * (16 * sin(theta).pow(3))
val z = radius * (13 * cos(theta) - 5 * cos(2 * theta) - 2 * cos(3 * theta) - cos(4 * theta))
// Rotate the heart particles around the player location based on their rotation
val rotatedX = x * cos(Math.toRadians(loc.yaw.toDouble())) - z * sin(Math.toRadians(loc.yaw.toDouble()))
val rotatedZ = z * cos(Math.toRadians(loc.yaw.toDouble())) + x * sin(Math.toRadians(loc.yaw.toDouble()))
// Add the rotated heart particles to the player's location
loc.add(rotatedX, 0.0, rotatedZ)
player.spawnParticle(particleType, loc, 0, Particle.DustOptions(Color.RED, 1f))
loc.subtract(rotatedX, 0.0, rotatedZ)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment