當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。