Effective Throwable
interface 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).
onHitis 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))
}
}Content copied to clipboard