feat: eat to heal

This commit is contained in:
str1k3r committed 2026-09-27 10:26:56 -04:00
1 parent 7d592c43ca
commit 9bcb6f8a3d
7 files changed
+36 -21

No files matched your search

+1 -1
View File
@@ -353,7 +353,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse)
if (minecraft->player->invulnerableTime < 10) blink = false;
int iHealth = minecraft->player->getHealth();
int iLastHealth = minecraft->player->lastHealth;
random->setSeed(tickCount * 312871);
//random->setSeed(tickCount * 312871);
if (EnderDragonRenderer::bossInstance != NULL)
{
+1 -14
View File
@@ -98,20 +98,7 @@ void CakeTile::attack(Level *level, int x, int y, int z, shared_ptr<Player> play
void CakeTile::eat(Level *level, int x, int y, int z, shared_ptr<Player> player)
{
if (player->canEat(false))
{
player->getFoodData()->eat(2, FoodConstants::FOOD_SATURATION_POOR);
int d = level->getData(x, y, z) + 1;
if (d >= 6)
{
level->setTile(x, y, z, 0);
} else
{
level->setData(x, y, z, d);
level->setTileDirty(x, y, z);
}
}
player->heal(1.5);
}
bool CakeTile::mayPlace(Level *level, int x, int y, int z)
+29 -2
View File
@@ -24,9 +24,36 @@ void FoodData::eat(int food, float saturationModifier)
saturationLevel = min(saturationLevel + (float) food * saturationModifier * 2.0f, (float)foodLevel);
}
void FoodData::eat(FoodItem *item)
void FoodData::eat(FoodItem *item, shared_ptr<Player> player)
{
eat(item->getNutrition(), item->getSaturationModifier());
if(item->apple_gold)
{
player->heal(10);
}
else if(item->mushroomStew)
{
player->heal(5);
}
else if (item->porkChop_cooked)
{
player->heal(4);
}
else if(item->bread || item->fish_cooked)
{
player->heal(2.5);
}
else if(item->porkChop_raw)
{
player->heal(1.5);
}
else if(item->fish_raw)
{
player->heal(1);
}
else if(item->cookie)
{
player->heal(0.5);
}
}
void FoodData::tick(shared_ptr<Player> player)
+1 -1
View File
@@ -18,7 +18,7 @@ public:
FoodData();
void eat(int food, float saturationModifier);
void eat(FoodItem *item);
void eat(FoodItem *item, shared_ptr<Player> player);
void tick(shared_ptr<Player> player);
void readAdditionalSaveData(CompoundTag *entityTag);
void addAdditonalSaveData(CompoundTag *entityTag);
+1 -1
View File
@@ -36,7 +36,7 @@ FoodItem::FoodItem(int id, int nutrition, bool isMeat)
shared_ptr<ItemInstance> FoodItem::useTimeDepleted(shared_ptr<ItemInstance> instance, Level *level, shared_ptr<Player> player)
{
instance->count--;
player->getFoodData()->eat(this);
player->getFoodData()->eat(this, player);
// 4J - new sound brought forward from 1.2.3
level->playSound(player, eSoundType_RANDOM_BURP, 0.5f, level->random->nextFloat() * 0.1f + 0.9f);
+2 -1
View File
@@ -2345,7 +2345,8 @@ FoodData *Player::getFoodData()
bool Player::canEat(bool magicalItem)
{
return (magicalItem || foodData.needsFood()) && !abilities.invulnerable && !hasInvulnerablePrivilege();
//return (magicalItem || foodData.needsFood()) && !abilities.invulnerable && !hasInvulnerablePrivilege();
return true;
}
bool Player::isHurt()
+1 -1
View File
@@ -22,7 +22,7 @@ Bringing the October 10th 2014 Source Leak back down to TU0
- [ ] Trading
## Added Features
- [ ] Eat to Instantly Heal
- [x] Eat to Heal
- [x] Punching Sheep for wool
## Removed Structures