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


Java ItemFood.getSaturationModifier方法代码示例

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


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

示例4: 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

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