Whats going on!! Flight food.

Discussion in 'Plugin Development' started by ChrisStarr32, Aug 7, 2014.

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

    ChrisStarr32

    So my friends and I have a whitelisted server that we all play on frequintly.
    We all decided that we wanted to fly but not have to be cheaty. I started to make this
    plugin that would take away food every 10 blocks you flown. For some odd reason our hunger
    will drop from time to time out of no where. Im not certain what Im doing wrong.
    Code:java
    1. @EventHandler
    2. public void Move(PlayerMoveEvent event)
    3. {
    4. Player player = event.getPlayer();
    5. if (player.isFlying() == true)
    6. {
    7. if (startfly.distance(player.getLocation()) >= 10)
    8. {
    9. startfly = player.getLocation();
    10. int food = player.getFoodLevel();
    11. int subfood = food - 1;
    12. player.setFoodLevel(subfood);
    13. if (player.getFoodLevel() == 0)
    14. {
    15. player.sendMessage(ChatColor.DARK_AQUA + " • " + ChatColor.GRAY + "You have ran out of food");
    16. player.setFlying(false);
    17. player.setAllowFlight(false);
    18. }
    19. }
    20. }
    21. }


    Location startfly is recorded when they click a feather to enable there flying.

    Thanks, Chris :)
     
  2. Offline

    _Filip

    This is the third time I have seen a post like this

    Also you naturally lose hunger from moving in minecraft
     
  3. Offline

    Joseph3262

    basically just counteract the natural hunger effect while flying
     
  4. Offline

    Forseth11

    You lose food naturally when moving. You could cancel the food change event unless player is flying and the amount going down equals a certain amount. Also I would set the saturation or exhaustion to another value not the hunger.
    Maybe this will help: http://minecraft.gamepedia.com/Hunger
     
Thread Status:
Not open for further replies.

Share This Page