use of net.minecraft.util.FoodStats in project MinecraftForge by MinecraftForge.
the class GuiIngameForge method renderFood.
public void renderFood(int width, int height) {
if (pre(FOOD))
return;
mc.mcProfiler.startSection("food");
EntityPlayer player = (EntityPlayer) this.mc.getRenderViewEntity();
GlStateManager.enableBlend();
int left = width / 2 + 91;
int top = height - right_height;
right_height += 10;
// Unused flag in vanilla, seems to be part of a 'fade out' mechanic
boolean unused = false;
FoodStats stats = mc.player.getFoodStats();
int level = stats.getFoodLevel();
for (int i = 0; i < 10; ++i) {
int idx = i * 2 + 1;
int x = left - i * 8 - 9;
int y = top;
int icon = 16;
byte background = 0;
if (mc.player.isPotionActive(MobEffects.HUNGER)) {
icon += 36;
background = 13;
}
//Probably should be a += 1 but vanilla never uses this
if (unused)
background = 1;
if (player.getFoodStats().getSaturationLevel() <= 0.0F && updateCounter % (level * 3 + 1) == 0) {
y = top + (rand.nextInt(3) - 1);
}
drawTexturedModalRect(x, y, 16 + background * 9, 27, 9, 9);
if (idx < level)
drawTexturedModalRect(x, y, icon + 36, 27, 9, 9);
else if (idx == level)
drawTexturedModalRect(x, y, icon + 45, 27, 9, 9);
}
GlStateManager.disableBlend();
mc.mcProfiler.endSection();
post(FOOD);
}
use of net.minecraft.util.FoodStats in project SilentGems by SilentChaos512.
the class ItemDebug method clOnItemRightClick.
@Override
protected ActionResult<ItemStack> clOnItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
// playerIn.attackEntityFrom(DamageSource.inWall, 1.0f);
FoodStats food = playerIn.getFoodStats();
food.setFoodLevel(food.getFoodLevel() - 2);
food.setFoodSaturationLevel(food.getSaturationLevel() - 0.2f);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, playerIn.getHeldItem(hand));
}
use of net.minecraft.util.FoodStats in project VoodooCraft by Mod-DevCafeTeam.
the class HexHandler method attackEvent.
/**
* Fire Aura Hex
* Water Breathing Hex
*/
@SubscribeEvent
public static void attackEvent(LivingAttackEvent event) {
EntityLivingBase entity = event.getEntityLiving();
ItemStack stack = null;
//Fire Aura - Sets attacking entity on fire
if (event.getSource().getSourceOfDamage() != null && (stack = getDollWithHex(entity, "fireAura")) != null)
event.getSource().getSourceOfDamage().setFire(2);
//Water Breathing - Uses player's hunger if possible when they're drowning
if (event.getSource().equals(DamageSource.drown) && (stack = getDollWithHex(entity, "waterBreathing")) != null) {
FoodStats food = ((EntityPlayer) entity).getFoodStats();
if (food.getFoodLevel() > 0) {
food.addStats(-1, 0);
event.setCanceled(true);
}
}
//Damage the doll
if (stack != null)
stack.damageItem(1, entity);
}
use of net.minecraft.util.FoodStats in project ConvenientAdditions by Necr0.
the class ItemSaturationRing method onWornTick.
@Override
public void onWornTick(ItemStack itemstack, EntityLivingBase player) {
if (player.getEntityWorld().isRemote)
return;
EntityPlayer p = (EntityPlayer) player;
FoodStats s = p.getFoodStats();
if (s.needFood() && p.ticksExisted % 1100 == 0) {
int foodLevel = Math.min((20 - s.getFoodLevel()), (1 + (p.world.rand.nextInt(8) == 0 ? 1 : 0)));
s.addStats(foodLevel, 2f + (p.world.rand.nextFloat() * 2));
p.world.playSound(null, p.posX, p.posY, p.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, .05f, .95f);
}
}
use of net.minecraft.util.FoodStats in project Bewitchment by Um-Mitternacht.
the class ItemFilledBowl method onFoodEaten.
@Override
public void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) {
if (stack.getTagCompound() == null) {
// not really supposed to happen ingame since you only get the stews with NBT values assigned but it prevents crashing
stack.setTagCompound(new NBTTagCompound());
}
final FoodStats foodStats = player.getFoodStats();
foodStats.setFoodLevel(foodStats.getFoodLevel() + stack.getTagCompound().getInteger("hunger"));
foodStats.setFoodSaturationLevel(foodStats.getFoodLevel() + stack.getTagCompound().getFloat("saturation"));
player.addItemStackToInventory(new ItemStack(Items.BOWL, 1));
}
Aggregations