#Is it possible to make eternal food
10 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
Cooldown? And then is the food consumed or not?
the food is not consumed
It would need some coding then
StartupEvents.registry("item", event => {
event.create("test_food")
// Use duration in ticks, 32 is normal eating duration
.useDuration(() => 32)
// Animation to play, use eating animation
.useAnimation("eat")
.use((stack, player, hand) => {
// So it can only be used when the player is hungry
// (having less than 20 food level)
return player.foodData.foodLevel < 20
})
.finishUsing((stack, level, player) => {
// Add 5 food level
player.foodData.foodLevel += 5
// Add 0.5 saturation
// actual value is 0.5 * 5 (50% of 5 food level)
player.foodData.setSaturation(player.foodData.getSaturationLevel() + 0.5 * 5)
// Add cooldown to the player of 20 ticks (1 second)
player.addItemCooldown(stack, 20)
// Return the stack so the item is not consumed
return stack
})
})
See if it works
its works perfectly, thanks
??closeticket
Please close your ticket (with </ticket close:1054771505520717835> or the button atop this thread) once you resolved your issue! This also helps others that would like to help out, as they don't have to look into this thread to check if it has been resolved by now.
Do you have any other questions regarding your issue? Feel free to ask!
Note: You generally should create a new post for unrelated issues.