当前位置: 首页>>代码示例>>Java>>正文


Java ItemFood.getHealAmount方法代码示例

本文整理汇总了Java中net.minecraft.item.ItemFood.getHealAmount方法的典型用法代码示例。如果您正苦于以下问题:Java ItemFood.getHealAmount方法的具体用法?Java ItemFood.getHealAmount怎么用?Java ItemFood.getHealAmount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.item.ItemFood的用法示例。


在下文中一共展示了ItemFood.getHealAmount方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFoodValue

import net.minecraft.item.ItemFood; //导入方法依赖的package包/类
int getFoodValue(ItemStack is) {
    if (is == null) {
        return 0;
    }
    Item it = is.getItem();
    int heal = 0;
    double sat = 0;

    FoodInfo fi = lookup(is);
    if (fi != null) {
        heal = fi.heal;
        sat = fi.sat;
    } else if (it instanceof ItemFood) {
        ItemFood nom = (ItemFood) it;
        heal = nom.getHealAmount(is);
        sat = nom.getSaturationModifier(is);
    }
    if (heal < sat) {
        double swapah = heal;
        heal = (int) sat;
        sat = swapah;
    }
    heal += Math.min(0, heal*2*sat);
    int r = (int)(heal*(heal/4F));
    return Math.max(heal, r);
}
 
开发者ID:purpleposeidon,项目名称:Factorization,代码行数:27,代码来源:TileEntityCaliometricBurner.java

示例2: onItemTooltipEvent

import net.minecraft.item.ItemFood; //导入方法依赖的package包/类
@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 == null || 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);
      }
    }
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:27,代码来源:TextInfoModule.java

示例3: onUpdate

import net.minecraft.item.ItemFood; //导入方法依赖的package包/类
@SubscribeEvent
public void onUpdate(LocalPlayerUpdateEvent event) {
    FoodStats foodStats = getLocalPlayer().getFoodStats();
    int foodSlot = -1;
    ItemStack foodStack = null;
    for (int i = 0; i < 9; i++) {
        ItemStack stack = getLocalPlayer().inventory.getStackInSlot(i);
        if (stack != null &&
                stack.getItem() instanceof ItemFood) {
            foodSlot = i;
            foodStack = stack;
            break;
        }
    }
    if (foodStack != null) {
        ItemFood itemFood = (ItemFood) foodStack.getItem();
        if (20 - foodStats.getFoodLevel() >= itemFood.getHealAmount(foodStack)
                && !getLocalPlayer().isHandActive()
                && FastReflection.Fields.Minecraft_rightClickDelayTimer.get(MC) == 0) {
            isEating = true;
            MC.player.inventory.currentItem = foodSlot;
            // need to fake use key to stop code that stops the eating
            Bindings.use.setPressed(true);
            FastReflection.Methods.Minecraft_rightClickMouse.invoke(MC);
            return;
        }
    }
    if(isEating && !getLocalPlayer().isHandActive()) {
        isEating = false;
        Bindings.use.setPressed(false);
    }
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:33,代码来源:AutoEatMod.java

示例4: onFoodHover

import net.minecraft.item.ItemFood; //导入方法依赖的package包/类
@SubscribeEvent
public void onFoodHover(ItemTooltipEvent e)
{
    if (e.getItemStack() != null && e.getItemStack().getItem() instanceof ItemFood) {
        ItemFood food = (ItemFood) e.getItemStack().getItem();
        double healAmount = food.getHealAmount(e.getItemStack());
        double saturationModifier = food.getSaturationModifier(e.getItemStack());
        df.setRoundingMode(RoundingMode.FLOOR);

        if (GuiScreen.isShiftKeyDown())
            e.getToolTip().add("H: " + healAmount + " | S: " + df.format(saturationModifier));
        else
            e.getToolTip().add(I18n.translateToLocalFormatted("tooltip.littlethings.foodrating", String.valueOf(new Double(healAmount * saturationModifier).intValue())));
    }
}
 
开发者ID:GamingsModding,项目名称:LittleThings-old,代码行数:16,代码来源:FoodEvents.java

示例5: matches

import net.minecraft.item.ItemFood; //导入方法依赖的package包/类
@Override
public boolean matches(@Nonnull InventoryCrafting crafting, @Nonnull World world) {
    ItemStack stack = ItemStack.EMPTY;
    List<ItemStack> list = Lists.newArrayList();

    for (int i = 0; i < crafting.getSizeInventory(); ++i) {
        ItemStack craftingStack = crafting.getStackInSlot(i);

        if (!craftingStack.isEmpty()) {
            if (craftingStack.getItem() instanceof ItemFood) {
                ItemFood food = (ItemFood) craftingStack.getItem();

                if (food.getHealAmount(craftingStack) <= 0 || !stack.isEmpty()) {
                    return false;
                }
                stack = craftingStack;
            } else {
                int meta = craftingStack.getMetadata();
                if (craftingStack.getItem() == ModItems.GENERAL) {
                    if (meta == ItemGeneral.Type.PEPPER.getMetadata()) {
                        return !isPeppered(stack);
                    }
                    if (meta == ItemGeneral.Type.SALT.getMetadata()) {
                        return !isSalted(stack);
                    }
                }
                list.add(craftingStack);
            }
        }
    }
    return !stack.isEmpty() && !list.isEmpty();
}
 
开发者ID:GirafiStudios,项目名称:Culinary-Cultivation,代码行数:33,代码来源:RecipesSeasoning.java

示例6: onItemTooltipEvent

import net.minecraft.item.ItemFood; //导入方法依赖的package包/类
@SubscribeEvent
public void onItemTooltipEvent(ItemTooltipEvent event) {
  // https://www.reddit.com/r/minecraftsuggestions/comments/3brh7v/when_hovering_over_a_food_it_shows_how_many_food/
  ItemStack itemStack = event.getItemStack();
  if (itemStack != null && itemStack.getItem() instanceof ItemFood) {
    ItemFood food = (ItemFood) itemStack.getItem();
    int hunger = food.getHealAmount(itemStack);
    float satur = food.getSaturationModifier(itemStack);
    event.getToolTip().add(hunger + " (" + satur + ")");
  }
}
 
开发者ID:LothrazarMinecraftMods,项目名称:FoodDetails,代码行数:12,代码来源:ModFoodDetails.java

示例7: recommendAllFood

import net.minecraft.item.ItemFood; //导入方法依赖的package包/类
public static void recommendAllFood(File file)
{
    if(FMLCommonHandler.instance().getSide().isServer())
    {
        return;
    }
    
    IBlockState dirt = Blocks.DIRT.getDefaultState();
    Color brown = new Color("7F3F0F");
    
    Map<String, Compostable> recommended = Maps.newHashMap();
    
    for(Item item : Item.REGISTRY)
    {
        if(item instanceof ItemFood)
        {
            ItemFood food = (ItemFood) item;
            
            List<ItemStack> stacks = Lists.newArrayList();
            food.getSubItems(food, null, stacks);
            
            for(ItemStack foodStack : stacks)
            {
                ItemInfo foodItemInfo = new ItemInfo(foodStack);
                
                if(!containsItem(foodItemInfo))
                {
   	                int hungerRestored = food.getHealAmount(foodStack);
   	                
   	                recommended.put(foodItemInfo.toString(), new Compostable(hungerRestored * 0.025F, brown, new ItemInfo(dirt)));
   	            }
            }
        }
    }
    
    String json = gson.toJson(recommended, new TypeToken<Map<String, Compostable>>(){}.getType());
    
    try
       {
           Files.write(file.toPath(), json.getBytes(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
       }
       catch (IOException e)
       {
           e.printStackTrace();
       }
}
 
开发者ID:MikeLydeamore,项目名称:ExNihiloAdscensio,代码行数:47,代码来源:CompostRegistry.java

示例8: getCraftingResult

import net.minecraft.item.ItemFood; //导入方法依赖的package包/类
@Override
@Nonnull
public ItemStack getCraftingResult(@Nonnull InventoryCrafting crafting) {
    ItemStack stack = ItemStack.EMPTY;
    boolean peppered = false;
    boolean salted = false;

    for (int k = 0; k < crafting.getSizeInventory(); ++k) {
        ItemStack craftingStack = crafting.getStackInSlot(k);

        if (!craftingStack.isEmpty()) {
            if (craftingStack.getItem() instanceof ItemFood) {
                ItemFood food = (ItemFood) craftingStack.getItem();

                if (food.getHealAmount(craftingStack) <= 0 || !stack.isEmpty()) {
                    return ItemStack.EMPTY;
                }

                stack = craftingStack.copy();
                stack.setCount(1);
            }
        }

        int meta = craftingStack.getMetadata();
        if (craftingStack.getItem() == ModItems.GENERAL) {
            if (meta == ItemGeneral.Type.PEPPER.getMetadata()) {
                peppered = true;
            } else if (meta == ItemGeneral.Type.SALT.getMetadata()) {
                salted = true;
            }
        }
    }

    if (stack.isEmpty()) return ItemStack.EMPTY;

    if (!stack.hasTagCompound()) {
        stack.setTagCompound(new NBTTagCompound());
    }

    NBTTagCompound baseTag = stack.getTagCompound();

    if (baseTag == null) return ItemStack.EMPTY;

    if (!baseTag.hasKey(SEASONING_NBT_KEY)) {
        baseTag.setTag(SEASONING_NBT_KEY, new NBTTagCompound());
    }

    NBTTagCompound seasoningTag = baseTag.getCompoundTag(SEASONING_NBT_KEY);

    if (peppered) {
        seasoningTag.setBoolean(PEPPERED_NBT_KEY, peppered);
    }
    if (salted) {
        seasoningTag.setBoolean(SALTED_NBT_KEY, salted);
    }
    return stack;
}
 
开发者ID:GirafiStudios,项目名称:Culinary-Cultivation,代码行数:58,代码来源:RecipesSeasoning.java

示例9: eatFood

import net.minecraft.item.ItemFood; //导入方法依赖的package包/类
public void eatFood(ItemFood food)
{
	chew(100);
	this.saturationLevel = food.getSaturationModifier()*food.getHealAmount();
	this.setHunger(Math.min(getMaxHunger(), getHunger() + food.getHealAmount()));
}
 
开发者ID:TheAwesomeGem,项目名称:MineFantasy,代码行数:7,代码来源:EntityHound.java


注:本文中的net.minecraft.item.ItemFood.getHealAmount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。