forked from Kolyah35/minecraft-pe-0.6.1
the whole game
This commit is contained in:
16
src/world/food/FoodConstants.h
Executable file
16
src/world/food/FoodConstants.h
Executable file
@@ -0,0 +1,16 @@
|
||||
#ifndef NET_MINECRAFT_WORLD_FOOD__FoodConstants_H__
|
||||
#define NET_MINECRAFT_WORLD_FOOD__FoodConstants_H__
|
||||
|
||||
//package net.minecraft.world.food;
|
||||
|
||||
class FoodConstants
|
||||
{
|
||||
public:
|
||||
static const int MAX_FOOD = 20;
|
||||
// number of game ticks to change health because of food
|
||||
static const int HEALTH_TICK_COUNT = 80;
|
||||
static const int HEALTH_TICK_COUNT_SIMPLE = 5;
|
||||
static const int HEAL_LEVEL = 18;
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_WORLD_FOOD__FoodConstants_H__*/
|
||||
33
src/world/food/SimpleFoodData.cpp
Executable file
33
src/world/food/SimpleFoodData.cpp
Executable file
@@ -0,0 +1,33 @@
|
||||
#include "SimpleFoodData.h"
|
||||
#include "FoodConstants.h"
|
||||
#include "../item/FoodItem.h"
|
||||
#include "../entity/player/Player.h"
|
||||
|
||||
SimpleFoodData::SimpleFoodData()
|
||||
: foodLevel(0)
|
||||
{
|
||||
}
|
||||
|
||||
void SimpleFoodData::eat( int food ) {
|
||||
foodLevel = Mth::Min(food + foodLevel, FoodConstants::MAX_FOOD);
|
||||
}
|
||||
|
||||
void SimpleFoodData::eat( FoodItem* item ) {
|
||||
eat(item->getNutrition());
|
||||
}
|
||||
|
||||
void SimpleFoodData::tick( Player* player ) {
|
||||
if (foodLevel > 0 && player->isHurt()) {
|
||||
const int healAmount = foodLevel;// / 2;
|
||||
player->heal(healAmount);
|
||||
foodLevel = 0;
|
||||
/*
|
||||
if (!level->isClientSide) {
|
||||
player->heal(healAmount);
|
||||
} else {
|
||||
SetHealthPacket packet(SetHealthPacket::HEALTH_MODIFY_OFFSET - healAmount);
|
||||
level->raknetInstance->send(packet);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
22
src/world/food/SimpleFoodData.h
Executable file
22
src/world/food/SimpleFoodData.h
Executable file
@@ -0,0 +1,22 @@
|
||||
#ifndef NET_MINECRAFT_WORLD_FOOD__SimpleFoodData_H__
|
||||
#define NET_MINECRAFT_WORLD_FOOD__SimpleFoodData_H__
|
||||
|
||||
//package net.minecraft.world.food;
|
||||
|
||||
class FoodItem;
|
||||
class Player;
|
||||
|
||||
class SimpleFoodData
|
||||
{
|
||||
public:
|
||||
SimpleFoodData();
|
||||
|
||||
void eat(int food);
|
||||
void eat(FoodItem* item);
|
||||
|
||||
void tick(Player* player);
|
||||
private:
|
||||
int foodLevel;
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_WORLD_FOOD__SimpleFoodData_H__*/
|
||||
Reference in New Issue
Block a user