本文整理汇总了Java中net.minecraft.util.FoodStats.getFoodLevel方法的典型用法代码示例。如果您正苦于以下问题:Java FoodStats.getFoodLevel方法的具体用法?Java FoodStats.getFoodLevel怎么用?Java FoodStats.getFoodLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.util.FoodStats
的用法示例。
在下文中一共展示了FoodStats.getFoodLevel方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onUpdate
import net.minecraft.util.FoodStats; //导入方法依赖的package包/类
@Override
public void onUpdate(EntityPlayerSP player) {
ItemStack curStack = player.inventory.getCurrentItem();
if(isEnabled()) {
if(!shouldEat()) {
Wrapper.getMinecraft().gameSettings.keyBindUseItem.pressed = false;
return;
}
FoodStats foodStats = player.getFoodStats();
if (foodStats.getFoodLevel() <= hungerFactor.getValue() && shouldEat())
{
eatFood();
}
}
}
示例2: handleHunger
import net.minecraft.util.FoodStats; //导入方法依赖的package包/类
/** Handles the hunger setting, returns if hunger is enabled. */
private boolean handleHunger(EntityPlayer player, FoodStats foodStats) {
EnumHunger hunger = AdvHealthOptions.config.<EnumHunger>get(AHOWorldConfig.miscHunger);
if (hunger == EnumHunger.ENABLE) return true;
// Make direct changes to the food meter affect health directly.
if ((hunger == EnumHunger.HEALTH) && foodLevelSet) {
int change = (foodStats.getFoodLevel() - 8);
if (change > 0) player.heal(change);
else if (change < 0) player.attackEntityFrom(DamageSource.starve, -change);
}
// Reset the food level and saturation.
setFoodLevel(player, 0);
foodStats.addStats(8, 20.0F);
foodLevelSet = true;
return false;
}
示例3: onUpdate
import net.minecraft.util.FoodStats; //导入方法依赖的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);
}
}
示例4: resetFoodTimer
import net.minecraft.util.FoodStats; //导入方法依赖的package包/类
/** Reset the "food timer" to disable Vanilla natural regeneration. */
private void resetFoodTimer(FoodStats foodStats) {
if (foodTimerField == null)
foodTimerField = ReflectionHelper.findField(FoodStats.class, "field_75123_d", "foodTimer");
if (foodStats.getFoodLevel() > 0) {
try { foodTimerField.set(foodStats, 0); }
catch (Exception ex) { throw new RuntimeException(ex); }
}
}
示例5: onItemRightClick
import net.minecraft.util.FoodStats; //导入方法依赖的package包/类
@Override
public ItemStack onItemRightClick(ItemStack stack, World w, EntityPlayer player){
int lunchCarried=MAX_FOOD_CARRIED-stack.getItemDamage();
FoodStats stats=player.getFoodStats();
int playerHunger=20-stats.getFoodLevel();
//feed the player until either they are full or the luncher is out of food
int toFeedToPlayer=Math.min(lunchCarried, playerHunger);
if(toFeedToPlayer>0){ //if player is hungry and luncher isn't empty
w.playSoundAtEntity(player, "random.burp", 0.5F, w.rand.nextFloat() * 0.1F + 0.9F);
stats.addStats(toFeedToPlayer, 0);
stack.setItemDamage(stack.getItemDamage()+toFeedToPlayer);
//Debug.dbg("Luncher omnomnomnom! Ate "+toFeedToPlayer);
}else{
int foodGathered=0;
boolean full=false;
for(int i=0; i<player.inventory.mainInventory.length; i++){
ItemStack stk=player.inventory.mainInventory[i];
if(stk!=null && stk.getItem() instanceof ItemFood){ //check if food
ItemFood item=(ItemFood) stk.getItem();
int foodPerItem=item.func_150905_g(stk);
int numberCanConsume=(int) Math.floor( (double)stack.getItemDamage() /foodPerItem );
int eating=stack.getItemDamage()-foodPerItem*Math.min(numberCanConsume, stk.stackSize);
//Debug.dbg("Can eat "+numberCanConsume + " of " + stk.stackSize +". Eating "+eating );
stack.setItemDamage(Math.max(eating,0));
if(numberCanConsume>=stk.stackSize){
player.inventory.mainInventory[i]=null;
}else{
stk.stackSize-=numberCanConsume;
}
}
if(full)break;
}
}
return stack;
}
示例6: render
import net.minecraft.util.FoodStats; //导入方法依赖的package包/类
@Override
public void render(Minecraft mc, ScaledResolution res, float partialTicks, HPHud hud) {
super.render(mc, res, partialTicks, hud);
hud.bindTexture(ICONS);
int left = halfWidth + hudHalfWidth;
int top = height - hudBaseline;
FoodStats stats = mc.thePlayer.getFoodStats();
int level = stats.getFoodLevel();
for (int i = 0; i < maxFood/2; i++) {
int x = left - (i * 8) - iconSize;
int y = top;
int icon = 16;
byte backgound = 0;
//determines how the current icon will be displayed (full, partial, empty)
int wholeFood = (i * 2) + 1;
if (stats.getSaturationLevel() <= 0.0F && hud.getUpdateCounter() % (level * 3 + 1) == 0) {
y = top + (hud.getRand().nextInt(3) - 1);
}
if (mc.thePlayer.isPotionActive(Potion.hunger)) {
icon += 36;
backgound = 13;
}
//draws the haunch outline (background)
hud.drawTexturedModalRect(x, y, 16 + (backgound * iconSize), 27, iconSize, iconSize);
//draws the actual food haunch
if (wholeFood < level)
hud.drawTexturedModalRect(x, y, icon + (iconSize * 4), 27, iconSize, iconSize);
else if (wholeFood == level)
hud.drawTexturedModalRect(x, y, icon + (iconSize * 5), 27, iconSize, iconSize);
//else; draw nothing. no haunch is drawn but the background is.
}
}
示例7: renderFood
import net.minecraft.util.FoodStats; //导入方法依赖的package包/类
public void renderFood(int width, int height)
{
if (pre(FOOD)) return;
mc.mcProfiler.startSection("food");
EntityPlayer player = (EntityPlayer)this.mc.getRenderViewEntity();
GlStateManager.enableBlend();
int left = width / 2 + 91;
int top = height - right_height;
right_height += 10;
boolean unused = false;// Unused flag in vanilla, seems to be part of a 'fade out' mechanic
FoodStats stats = mc.thePlayer.getFoodStats();
int level = stats.getFoodLevel();
for (int i = 0; i < 10; ++i)
{
int idx = i * 2 + 1;
int x = left - i * 8 - 9;
int y = top;
int icon = 16;
byte background = 0;
if (mc.thePlayer.isPotionActive(MobEffects.HUNGER))
{
icon += 36;
background = 13;
}
if (unused) background = 1; //Probably should be a += 1 but vanilla never uses this
if (player.getFoodStats().getSaturationLevel() <= 0.0F && updateCounter % (level * 3 + 1) == 0)
{
y = top + (rand.nextInt(3) - 1);
}
drawTexturedModalRect(x, y, 16 + background * 9, 27, 9, 9);
if (idx < level)
drawTexturedModalRect(x, y, icon + 36, 27, 9, 9);
else if (idx == level)
drawTexturedModalRect(x, y, icon + 45, 27, 9, 9);
}
GlStateManager.disableBlend();
mc.mcProfiler.endSection();
post(FOOD);
}
示例8: renderFood
import net.minecraft.util.FoodStats; //导入方法依赖的package包/类
public void renderFood(int width, int height)
{
if (pre(FOOD)) return;
mc.mcProfiler.startSection("food");
GL11.glEnable(GL11.GL_BLEND);
int left = width / 2 + 91;
int top = height - right_height;
right_height += 10;
boolean unused = false;// Unused flag in vanilla, seems to be part of a 'fade out' mechanic
FoodStats stats = mc.thePlayer.getFoodStats();
int level = stats.getFoodLevel();
int levelLast = stats.getPrevFoodLevel();
for (int i = 0; i < 10; ++i)
{
int idx = i * 2 + 1;
int x = left - i * 8 - 9;
int y = top;
int icon = 16;
byte backgound = 0;
if (mc.thePlayer.isPotionActive(Potion.hunger))
{
icon += 36;
backgound = 13;
}
if (unused) backgound = 1; //Probably should be a += 1 but vanilla never uses this
if (mc.thePlayer.getFoodStats().getSaturationLevel() <= 0.0F && updateCounter % (level * 3 + 1) == 0)
{
y = top + (rand.nextInt(3) - 1);
}
drawTexturedModalRect(x, y, 16 + backgound * 9, 27, 9, 9);
if (unused)
{
if (idx < levelLast)
drawTexturedModalRect(x, y, icon + 54, 27, 9, 9);
else if (idx == levelLast)
drawTexturedModalRect(x, y, icon + 63, 27, 9, 9);
}
if (idx < level)
drawTexturedModalRect(x, y, icon + 36, 27, 9, 9);
else if (idx == level)
drawTexturedModalRect(x, y, icon + 45, 27, 9, 9);
}
GL11.glDisable(GL11.GL_BLEND);
mc.mcProfiler.endSection();
post(FOOD);
}
示例9: renderFood
import net.minecraft.util.FoodStats; //导入方法依赖的package包/类
public void renderFood(int width, int height)
{
if (pre(FOOD)) return;
mc.mcProfiler.startSection("food");
int left = width / 2 + 91;
int top = height - right_height;
right_height += 10;
boolean unused = false;// Unused flag in vanilla, seems to be part of a 'fade out' mechanic
FoodStats stats = mc.thePlayer.getFoodStats();
int level = stats.getFoodLevel();
int levelLast = stats.getPrevFoodLevel();
for (int i = 0; i < 10; ++i)
{
int idx = i * 2 + 1;
int x = left - i * 8 - 9;
int y = top;
int icon = 16;
byte backgound = 0;
if (mc.thePlayer.isPotionActive(Potion.hunger))
{
icon += 36;
backgound = 13;
}
if (unused) backgound = 1; //Probably should be a += 1 but vanilla never uses this
if (mc.thePlayer.getFoodStats().getSaturationLevel() <= 0.0F && updateCounter % (level * 3 + 1) == 0)
{
y = top + (rand.nextInt(3) - 1);
}
drawTexturedModalRect(x, y, 16 + backgound * 9, 27, 9, 9);
if (unused)
{
if (idx < levelLast)
drawTexturedModalRect(x, y, icon + 54, 27, 9, 9);
else if (idx == levelLast)
drawTexturedModalRect(x, y, icon + 63, 27, 9, 9);
}
if (idx < level)
drawTexturedModalRect(x, y, icon + 36, 27, 9, 9);
else if (idx == level)
drawTexturedModalRect(x, y, icon + 45, 27, 9, 9);
}
mc.mcProfiler.endSection();
post(FOOD);
}
示例10: renderFood
import net.minecraft.util.FoodStats; //导入方法依赖的package包/类
@Override
public void renderFood(int width, int height) {
if (pre(FOOD)) return;
mc.mcProfiler.startSection("food");
int left = width / 2 + 91;
int top = height - right_height;
right_height += 10;
boolean unused = false;// Unused flag in vanilla, seems to be part of a 'fade out' mechanic
FoodStats stats = mc.thePlayer.getFoodStats();
int level = stats.getFoodLevel();
int levelLast = stats.getPrevFoodLevel();
for (int i = 0; i < 10; ++i) {
int idx = i * 2 + 1;
int x = left - i * 8 - 9;
int y = top;
int icon = 16;
byte backgound = 0;
if (mc.thePlayer.isPotionActive(Potion.hunger)) {
icon += 36;
backgound = 13;
}
if (unused) backgound = 1; //Probably should be a += 1 but vanilla never uses this
if (mc.thePlayer.getFoodStats().getSaturationLevel() <= 0.0F && updateCounter % (level * 3 + 1) == 0) {
y = top + (rand.nextInt(3) - 1);
}
drawTexturedModalRect(x, y, 16 + backgound * 9, 27, 9, 9);
if (unused) {
if (idx < levelLast)
drawTexturedModalRect(x, y, icon + 54, 27, 9, 9);
else if (idx == levelLast)
drawTexturedModalRect(x, y, icon + 63, 27, 9, 9);
}
if (idx < level)
drawTexturedModalRect(x, y, icon + 36, 27, 9, 9);
else if (idx == level)
drawTexturedModalRect(x, y, icon + 45, 27, 9, 9);
}
mc.mcProfiler.endSection();
post(FOOD);
}
示例11: renderFood
import net.minecraft.util.FoodStats; //导入方法依赖的package包/类
@Override
public void renderFood(int width, int height) {
mc.mcProfiler.startSection("food");
int left = width / 2 + 91;
int top = height - right_height + offsetY;
right_height += 10;
boolean unused = false;
FoodStats stats = mc.thePlayer.getFoodStats();
int level = stats.getFoodLevel();
int levelLast = stats.getPrevFoodLevel();
for(int i = 0; i < 10; ++i) {
int idx = i * 2 + 1;
int x = left - i * 8 - 9;
int y = top;
int icon = 16;
byte backgound = 0;
if(mc.thePlayer.isPotionActive(Potion.hunger)) {
icon += 36;
backgound = 13;
}
if(unused) {
backgound = 1;
}
if(mc.thePlayer.getFoodStats().getSaturationLevel() <= 0.0F && updateCounter % (level * 3 + 1) == 0) {
y = top + (rand.nextInt(3) - 1);
}
drawTexturedModalRect(x, y, 16 + backgound * 9, 27, 9, 9);
if(unused) {
if(idx < levelLast) {
drawTexturedModalRect(x, y, icon + 54, 27, 9, 9);
} else if(idx == levelLast) {
drawTexturedModalRect(x, y, icon + 63, 27, 9, 9);
}
}
if(idx < level) {
drawTexturedModalRect(x, y, icon + 36, 27, 9, 9);
} else if(idx == level) {
drawTexturedModalRect(x, y, icon + 45, 27, 9, 9);
}
}
mc.mcProfiler.endSection();
}
示例12: render
import net.minecraft.util.FoodStats; //导入方法依赖的package包/类
@Override
public void render(float paramFloat) {
Minecraft mc = Minecraft.getMinecraft();
RenderAssist.bindTexture(Gui.icons);
GL11.glColor4f(1.0f, 1.0f, 1.0f, this.getOpacity());
int left = posX + 81;
int top = posY;
FoodStats stats = mc.thePlayer.getFoodStats();
int level = stats.getFoodLevel();
for (int i = 0; i < 10; ++i) {
int idx = i * 2 + 1;
int x = left - i * 8 - 9;
int y = top;
if (rotated){
x = left - 81;
y = top + 82 - i*8 -9;
}
int icon = 16;
byte backgound = 0;
if (mc.thePlayer.isPotionActive(Potion.hunger)) {
icon += 36;
backgound = 13;
}
if (mc.thePlayer.getFoodStats().getSaturationLevel() <= 0.0F && mc.ingameGUI.getUpdateCounter() % (level * 3 + 1) == 0) {
y = top + rand.nextInt(3) - 1;
if (rotated) {
x = left-81+rand.nextInt(3)-1;
y = top + 82 - i*8 -9;
}
}
RenderAssist.drawTexturedModalRect(x, y, 16 + backgound * 9, 27, 9, 9);
if (idx < level) {
RenderAssist.drawTexturedModalRect(x, y, icon + 36, 27, 9, 9);
} else if (idx == level) {
RenderAssist.drawTexturedModalRect(x, y, icon + 45, 27, 9, 9);
}
}
}