@Override public int getFoodLevel(ItemStack itemStack, EntityPlayer entityPlayer) { ItemFood item = (ItemFood) itemStack.getItem(); return item.getHealAmount(itemStack); } }
private static int foodHealCompare(ItemStack stack1, ItemStack stack2) { return ((ItemFood) stack2.getItem()).getHealAmount(stack2) - ((ItemFood) stack1.getItem()).getHealAmount(stack1); }
public static float calculateNutrition(ItemStack itemStack, List<Nutrient> nutrients) { // Get item/block Item item = itemStack.getItem(); // Base food value int foodValue = 0; if (item instanceof ItemFood) foodValue = ((ItemFood) item).getHealAmount(itemStack); // Number of half-drumsticks food heals else if (item instanceof ItemBlock || item instanceof ItemBlockSpecial) // Cake, most likely foodValue = 2; // Hardcoded value from vanilla else if (item instanceof ItemBucketMilk) foodValue = 4; // Hardcoded milk value // Apply multipliers float adjustedFoodValue = (float) (foodValue * 0.5); // Halve to start at reasonable starting point adjustedFoodValue = adjustedFoodValue * Config.nutritionMultiplier; // Multiply by config value float lossPercentage = (float) Config.lossPerNutrient / 100; // Loss percentage from config file float foodLoss = (adjustedFoodValue * lossPercentage * (nutrients.size() - 1)); // Lose 15% (configurable) for each nutrient added after the first nutrient float nutritionValue = Math.max(0, adjustedFoodValue - foodLoss); // Subtract from true value, with a floor of 0 return nutritionValue; }
/** * The base constructor for more complicated ItemSteamedFoods. Use this for cases where the * output item has metadata (other than 0). For example: Steamed Salmon * @param food The input item * @param foodStack The input item as an ItemStack */ public ItemSteamedFood(ItemFood food, ItemStack foodStack) { super(food.getHealAmount(foodStack) + 2, food.getSaturationModifier(foodStack) + 0.2F, food.isWolfsFavoriteMeat()); baseFood = food; baseFoodStack = foodStack; }
int val = Math.min(12, ((ItemFood) stack.getItem()).getHealAmount(stack)); digestingMana = val * val * 70; digestingMana *= 1F / lastFoodCount;
public static void registerFoodAuto(ItemFood food, FoodType foodType, FoodEffect... effects) { registerFood(new FoodKey(food), foodType, food.getHealAmount(new ItemStack(food)) * 650, effects); }
public int getFoodValue(ItemStack stack) { if (stack.isEmpty()) { return 0; } String name = stack.getItem().getRegistryName().toString(); if (foodValues.containsKey(name)) { return foodValues.get(name); } else if (stack.getItem() instanceof ItemFood) { return ((ItemFood) stack.getItem()).getHealAmount(stack) * foodMultiplier; } return 0; }
@SubscribeEvent public void makeTooltip(ItemTooltipEvent event) { if(!event.getItemStack().isEmpty() && event.getItemStack().getItem() instanceof ItemFood) { int pips = ((ItemFood) event.getItemStack().getItem()).getHealAmount(event.getItemStack()); int len = (int) Math.ceil((double) pips / divisor); String s = " "; for(int i = 0; i < len; i++) s += " "; List<String> tooltip = event.getToolTip(); if(tooltip.isEmpty()) tooltip.add(s); else tooltip.add(1, s); } }
/** Set the item for this crop * @param item the item to set this as**/ public Crop setItem(ItemStack item) { this.item = item; if (this.item != null && this.item.getItem() instanceof ItemFood) { ItemFood food = (ItemFood)this.item.getItem(); setIngredient(food.getHealAmount(item), food.getSaturationModifier(item)); } return this; }
public static boolean isValid(ItemStack stack) { return stack.getItem() == HFCooking.MEAL || HFApi.cooking.isIngredient(stack) || (stack.getItem() instanceof ItemFood && ((ItemFood)stack.getItem()).getHealAmount(stack) > 0); }
@Override public int getScore(QuestContestCooking quest, World world) { int hunger = ((ItemFood) stack.getItem()).getHealAmount(stack); float saturation = ((ItemFood) stack.getItem()).getSaturationModifier(stack); long gold = HFApi.shipping.getSellValue(stack); return (int) (hunger * saturation + gold) - (category == quest.getCategory() ? 0 : 1000); }
public static int getFoodPoints(ItemStack item, boolean meatOnly, boolean includeFish){ if(item != null && item != ItemStack.EMPTY && item.getItem() != null && item.getItem() instanceof ItemFood){ int food = (int)(((ItemFood)item.getItem()).getHealAmount(item) * 10); if(!meatOnly){ return food; }else if(((ItemFood)item.getItem()).isWolfsFavoriteMeat()){ return food; }else if(includeFish && item.getItem() == Items.FISH){ return food; } } return 0; }
public void detectAndRegisterLiqueur(RegistryEvent.Register<Item> event) { event.getRegistry().getKeys().stream().filter(s -> s.getPath().contains("liqueur")).map(ForgeRegistries.ITEMS::getValue).collect(Collectors.toList()).forEach(liqueur -> { for (LiqueurType liqueurType : LiqueurTypes.values()) { if (liqueurType == LiqueurTypes.NORMAL) continue; ItemGeneratedLiqueur typedLiqueur = new ItemGeneratedLiqueur(MathHelper.floor(liqueurType.getHealModifier() * ((ItemFood) liqueur).getHealAmount(new ItemStack(liqueur)))); typedLiqueur.setLiqueurType(liqueurType); typedLiqueur.setItemStackDisplayNameCallback(liqueur::getItemStackDisplayName); typedLiqueur.setRegistryName(liqueur.getRegistryName().getNamespace(), liqueurType.getUnlocalizedName() + "_" + liqueur.getRegistryName().getPath()); typedLiqueur.setTranslationKey(liqueur.getTranslationKey()); event.getRegistry().register(typedLiqueur); OreDictionary.registerOre("listAll" + StringUtils.capitalize(liqueurType.getUnlocalizedName()) + "liqueur", typedLiqueur); OreDictionary.registerOre("listAllliqueur", typedLiqueur); OreDictionary.registerOre("listAllfoods", typedLiqueur); if (liqueur instanceof CustomModelMasking) FoodCraftReloadedMod.getLoader(LiqueurLoader.class).get().getLiqueurCustomModelMap().put(typedLiqueur, (CustomModelMasking) liqueur); } }); }
public static int getFuelEnergy(ItemStack stack) { if (stack.isEmpty()) { return 0; } if (stack.getItem().hasContainerItem(stack)) { return 0; } int energy = fuelMap.get(new ComparableItemStack(stack)); if (energy > 0) { return energy; } if (stack.getItem() instanceof ItemFood) { ItemFood food = (ItemFood) stack.getItem(); int foodEnergy = food.getHealAmount(stack) * DEFAULT_ENERGY; int satEnergy = (int) (food.getSaturationModifier(stack) * foodEnergy * 2); return foodEnergy + satEnergy; } return 0; }
@Override public boolean interact(EntityPlayer player, ItemStack item) { // eat only if hurt if (dragon.isServer() && dragon.getHealthRelative() < 1) { ItemFood food = (ItemFood) ItemUtils.consumeEquipped(player, dragon.getBreed().getFoodItems()); // heal only if the food was actually consumed if (food != null) { dragon.heal(food.getHealAmount(item)); dragon.playSound(dragon.getSoundManager().getEatSound(), 0.7f, 1); return true; } } return false; }
@SideOnly(Side.CLIENT) @SubscribeEvent public void onItemTooltipEvent(ItemTooltipEvent event) { if (Keyboard.isCreated() && (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))) { // https://www.reddit.com/r/minecraftsuggestions/comments/3brh7v/when_hovering_over_a_food_it_shows_how_many_food/ ItemStack itemStack = event.getItemStack(); if (itemStack.getItem() == null) { return; } if (foodDetails && itemStack.getItem() instanceof ItemFood) { ItemFood food = (ItemFood) itemStack.getItem(); int hunger = food.getHealAmount(itemStack); float satur = food.getSaturationModifier(itemStack); if (hunger > 0 || satur > 0) { event.getToolTip().add(hunger + " (" + satur + ")"); } } if (fuelDetails) { int burnTime = TileEntityFurnace.getItemBurnTime(itemStack); if (burnTime > 0) { event.getToolTip().add(UtilChat.lang("tooltip.burntime") + burnTime); } } } }
private void food(ItemStack stack) { if (!stack.isEmpty()) { if (stack.getItem() instanceof ItemFood) { ItemFood food = (ItemFood) stack.getItem(); storedpoints.increaseBy(food.getHealAmount(stack)); this.slots().get(0).shrink(1); } if (stack.getItem() instanceof IHungerStore) { IHungerStore module = (IHungerStore) stack.getItem(); int hunger = module.getHungerPoints(stack); if (hunger != 0) { if (hunger >= speed) { module.transferHunger(speed, stack, ProcessType.REMOVE); storedpoints.increaseBy(speed); } else { module.transferHunger(hunger, stack, ProcessType.REMOVE); storedpoints.increaseBy(hunger); } } } } }
@Override public ItemStack getCraftingResult(InventoryCrafting inv){ int amount = 0; for(int i = 0; i < inv.getSizeInventory(); i++){ ItemStack stack = inv.getStackInSlot(i); if(StackUtil.isValid(stack)){ if(stack.getItem() instanceof ItemFood){ ItemFood food = (ItemFood)stack.getItem(); float heal = food.getHealAmount(stack); float sat = food.getSaturationModifier(stack); amount += MathHelper.ceil(heal*sat); } } } if(amount > 0 && amount <= 64){ return new ItemStack(InitItems.itemMisc, amount, TheMiscItems.MASHED_FOOD.ordinal()); } else{ return StackUtil.getEmpty(); } }
citizenData.increaseSaturation(itemFood.getHealAmount(stack) / 2.0); citizenData.getInventory().decrStackSize(foodSlot, 1); citizenData.markDirty();
mc.getTextureManager().bindTexture(GuiIngameForge.ICONS); ItemFood food = ((ItemFood) event.getStack().getItem()); int pips = food.getHealAmount(event.getStack());