本文整理汇总了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()));
}