context(Adepts) fun Toggled.ItemFood( material: Short, meta: Short = 0, max: Byte = 64, tags: TagCompound = emptyMap(), onConsume: (Adept) -> (Unit) = {} ) = Item(adepts, material, meta, max, tags, onUse = { adept, _ -> adept.onRelease { disable() } val selected = adept.selected.last val current = adept.inventory[selected]!! scheduler.every(4.ticks)() { if (it > 2) current().apply { val volume = 0.5f + 0.5f * nextInt(2) val pitch = (nextFloat() - nextFloat()) * 0.2f + 1f adepts.send("random.eat", adept.location.last, volume, pitch) } if (it >= 7) { adept.status(adept.id, 9) val pitch = current().nextFloat() * 0.1f + 0.9f adepts.send("random.burp", adept.location.last, 0.5f, pitch) if (adept.inventory[selected] == current) { adept.inventory[selected] = current.add(-1) onConsume(adept); } disable() } } enable(); CONSUME })