EffectiveThrowable

Behaviour that lets an EffectiveItem be thrown as a snowball-backed projectile.

Registration adds a right-click handler that launches the projectile carrying the item; a shared module listens for ProjectileHitEvent and dispatches to the matching item's onHit. Register via EffectiveItem.makeThrowable.

Notes:

  • The projectile is always a Snowball; the thrown item is stored inside it and used to identify it on landing, so EffectiveItem.createItemStack must yield the item's namespaced key (the default does).

  • onHit is already filtered: it fires only for this item's projectiles, never for vanilla snowballs or other throwables.

fun init() {
makeThrowable(velocity = 1.5) { event ->
val target = event.hitEntity as? LivingEntity ?: return@makeThrowable
target.addPotionEffect(PotionEffect(PotionEffectType.POISON, 40, 0))
}
}

Types

Link copied to clipboard
object Companion
Link copied to clipboard
data class Data(val item: EffectiveItem, val velocity: Double = 1.5, val consumeOnThrow: Boolean = true, val throwSound: Sound? = Sound.ENTITY_SNOWBALL_THROW, val onHit: (ProjectileHitEvent) -> Unit)

Throw configuration for one item.