Cubyz icon indicating copy to clipboard operation
Cubyz copied to clipboard

Eating is actually doable (no raymarching)

Open tillpp opened this issue 1 month ago • 2 comments

Now you can regenerate Health! :partying_face:

This follows https://github.com/PixelGuys/Cubyz/issues/965 :

  1. every 5 seconds you gain one heart for the price of 0.25 energy.
  2. You spawn with an empty stomach.
  3. 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: appleEating2online-video-cutter com-ezgif com-optimize

tillpp avatar Dec 07 '25 00:12 tillpp

Request for label

tillpp avatar Dec 07 '25 12:12 tillpp

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.

tillpp avatar Dec 08 '25 21:12 tillpp

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.

IntegratedQuantum avatar Dec 11 '25 16:12 IntegratedQuantum

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

tillpp avatar Dec 11 '25 16:12 tillpp

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;
		}
	}

tillpp avatar Dec 15 '25 14:12 tillpp

Request for Review

tillpp avatar Dec 17 '25 03:12 tillpp

Request for Review

Request for patience, you are already in my email queue, writing this doesn't make it go any faster.

IntegratedQuantum avatar Dec 18 '25 16:12 IntegratedQuantum

Ah ok, just thought you might have forgotten that this exist

tillpp avatar Dec 18 '25 16:12 tillpp

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.

IntegratedQuantum avatar Dec 18 '25 16:12 IntegratedQuantum

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

tillpp avatar Dec 18 '25 21:12 tillpp

also please rebase after the recent merge of sweet stuff #2417

IntegratedQuantum avatar Dec 20 '25 14:12 IntegratedQuantum