本文整理匯總了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);
}
示例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);
}
}
}
}
示例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())));
}
}
示例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 + ")");
}
}
示例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()));
}