getFoodLevel();

Discussion in 'Plugin Development' started by ThatBox, Jul 11, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    ThatBox

    What is the max number this can return ? I tried to check the apidocs but it seems they are down atm.
     
  2. Offline

    chaseoes

    I assume 20, just like health?
     
  3. Offline

    ThatBox

    That was I was thinking, but it doesn't seem to work that way.
    PHP:
    if(player.getFoodLevel() != 20) {
    player.setFoodLevel(player.getFoodLevel() + 3);
    ItemStack hand player.getItemInHand();
    hand.setAmount(hand.getAmount() - 1);
    }
     
  4. Offline

    EnvisionRed

    I think that it returns a max of 10 because that's how many show on the food bar. I'm not sure and it doesn't show on the apidocs either. Maybe make a test plugin and spawn yourself a lot of food, eat it and then do a command for it to broadcast your food level?
     
  5. Offline

    ThatBox

    I have been trying exactly that. This method i have above is always called.

    So i tried setFoodLevel(20); and it fills the hunger bar. It may be a bug with getFoodLevel() :/

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  6. Offline

    Vinceguy1

    does 10 fill the hunger bar? if not try if(player.getFoodLevel() < 20)
     
  7. Offline

    ThatBox

    It seems it may be a bug with getFoodLevel() :/
     
  8. Offline

    Vinceguy1

    couldn't hurt to try, if you did then contact bukkit.
     
  9. Offline

    MrTwiggy

    Why not just run some debug tests, and have it send a message to the player telling them what their hunger is, so you can log in and see what 'getFoodLevel()' returns when you're at full ,etc.
     
  10. Offline

    LucasEmanuel

    Nothing wrong with the getFoodLevel() method its working fine for me.

    The max amount of food a player can have is 20.
     
  11. Offline

    keelar

    I highly doubt something as simple as getFoodLevel() would ever be buggy.

    Like someone else said, just run some debug tests by sending yourself a message which contains what getFoodLevel() returns.
     
Thread Status:
Not open for further replies.

Share This Page