Eating is actually doable (no raymarching)
Now you can regenerate Health! :partying_face:
This follows https://github.com/PixelGuys/Cubyz/issues/965 :
- every 5 seconds you gain one heart for the price of 0.25 energy.
- You spawn with an empty stomach.
- You can eat food to regenerate energy.
Things I also implemented:
- onUse Event that gets triggered when an item is used (right clicked)
- Eat Callback for onUse, that lets you define how much food should be restored. Like this:
.{
.texture = "apple.png",
.onUse = .{
.type = .eat,
.food = 0.5,
},
}
Sped up gif:
Request for label
As I said in #1939 (comment):
That PR isnt mine. I dont read review of other peoples PR. And especially not closed ones. Can't expect me to read all review comments of closed PRs of other people.
That PR isnt mine. I dont read review of other peoples PR.
When implementing a feature it's always a good idea to check if someone else already made a PR, to prevent repeating the same mistakes.
That PR isnt mine. I dont read review of other peoples PR.
When implementing a feature it's always a good idea to check if someone else already made a PR, to prevent repeating the same mistakes.
The PR was also not named after food/eating or something similar
A shame that the regeneration has to be removed, cause it felt really good. Slow steady healing that doesnt benefits you during a fight.
for anyone who wants to add it yourself locally: this was the code in User being executed from User.update
pub fn regenerateHealth(self: *User) void {
const healthRegenTime = main.timestamp();
if(self.lastHealthRegenTime.durationTo(healthRegenTime).toSeconds() > 5 and self.player.energy > 0 and self.player.health < self.player.maxHealth) {
// give 1 Health every 5 seconds
main.items.Inventory.Sync.addHealth(1, .heal, .server, self.id);
// but take only 1/4 food for it.
main.items.Inventory.Sync.addEnergy(-0.25, .server, self.id);
self.lastHealthRegenTime = healthRegenTime;
}
}
Request for Review
Request for Review
Request for patience, you are already in my email queue, writing this doesn't make it go any faster.
Ah ok, just thought you might have forgotten that this exist
Ah ok, just thought you might have forgotten that this exists
You can make that assumption if you don't hear from me for a week and I did review newer PRs in that time and it isn't the week before the release.
skipping id 12 and using id 13 instead in sync, because i saw your new PR using 12 now https://github.com/PixelGuys/Cubyz/pull/2415
useItem = 13
also please rebase after the recent merge of sweet stuff #2417