Package org.spout.vanilla.component.entity.misc

Examples of org.spout.vanilla.component.entity.misc.Hunger


  public void hunger(Player player, CommandArguments args) throws CommandException {
    final int amount = args.popInteger("amount");
    final boolean hungry = args.popBoolean("hungry");
    args.assertCompletelyParsed();

    Hunger hunger = player.get(Hunger.class);
    hunger.setHunger(amount);
    hunger.setPoisoned(hungry);
  }
View Full Code Here


    event.getMessages().add(new EntityStatusMessage(event.getEntity().getId(), event.getStatus()));
  }

  @EventHandler
  public void onPlayerUpdateStats(PlayerHealthEvent event) {
    Hunger hunger = getOwner().get(Hunger.class);
    event.getMessages().add(new PlayerHealthMessage(getOwner().get(Human.class).getHealth().getHealth(), (short) hunger.getHunger(), hunger.getFoodSaturation()));
  }
View Full Code Here

    Player player = session.getPlayer();

    Health health = player.get(Health.class);
    health.setHealth(message.getHealth(), HealthChangeCause.UNKNOWN);

    Hunger hunger = player.get(Hunger.class);
    hunger.setHunger(message.getFood());
    hunger.setFoodSaturation(message.getFoodSaturation());
  }
View Full Code Here

     * The notch client's packet sending is weird. Here's how it works: If the client is clicking a block not in range, sends a packet with x=-1,y=255,z=-1 If the client is clicking a block in
     * range with an item in hand (id > 255) Sends both the normal block placement packet and a (-1,255,-1) one If the client is placing a block in range with a block in hand, only one normal
     * packet is sent That is how it usually happens. Sometimes it doesn't happen like that. Therefore, a hacky workaround.
     */
    final BlockFace clickedFace = message.getDirection();
    Hunger hunger = player.add(Hunger.class);
    if ((holdingMat instanceof Food && hunger.getHunger() != VanillaData.HUNGER.getDefaultValue()) || holdingMat instanceof Sword || (holdingMat instanceof PotionItem && !((PotionItem) holdingMat).isSplash())) {
      player.get(Living.class).setEatingBlocking(true);
      hunger.setEating(true, currentSlot);
      return;
    }
    if (clickedFace == BlockFace.THIS) {
      // Right clicked air with an item.
      PlayerInteractBlockEvent event = Spout.getEventManager().callEvent(new PlayerInteractBlockEvent(player, null, null, clickedFace, Action.RIGHT_CLICK));
View Full Code Here

  }

  public void onEat(Entity entity, Slot slot) {
    entity.get(Living.class).setEatingBlocking(false);
    if (entity.getData().get(VanillaData.GAMEMODE).equals(GameMode.SURVIVAL)) {
      Hunger hunger = entity.get(Hunger.class);
      for (FoodEffect effect : getEffectType()) {
        switch (effect.getEffect()) {
          case HEALTH_REGENERATION:
            entity.add(Effects.class).add(new EntityEffect(EntityEffectType.REGENERATION, effect.getChange()));
            break;
          case HUNGER:
            hunger.setHunger((int) (hunger.getHunger() + effect.getChange()));
            break;
          case POISON:
            if (GenericMath.getRandom().nextInt(101) < effect.getChange()) {
              entity.add(Effects.class).add(new EntityEffect(EntityEffectType.HUNGER, 30));
            }
            break;
          case SATURATION:
            hunger.setFoodSaturation(hunger.getFoodSaturation() + effect.getChange());
            break;
        }
      }
      slot.addAmount(-1);
      if (slot.get().getMaterial().equals(VanillaMaterials.MUSHROOM_STEW)) {
View Full Code Here

    attach();
  }

  @Override
  public void animate() {
    Hunger hunger = hud.getOwner().get(Hunger.class);
    if (hunger == null) {
      return;
    }

    float x;
    float y;
    float dx = 0.06f * SCALE;

    // Animate hunger bar
    float saturation = hunger.getFoodSaturation();

    if (saturation <= 0) {
      List<RenderPart> parts = hungerPack.getRenderParts();
      if (hungerTicks == 98) {
        x = 0.09f * SCALE;
 
View Full Code Here

    throw new UnsupportedOperationException("Not supported yet.");
  }

  @Override
  public void update() {
    Hunger hungerComp = hud.getOwner().get(Hunger.class);
    int hunger = hungerComp.getHunger();

    float fx = hungerComp.getFx();
    float bx = hungerComp.getBx();
    //Widget testWidget = getOwner().get(HUD.class).getHungerMeter().getWidget();

    if (hunger == 0) {

      for (int i = 0; i < 10; i++) {
View Full Code Here

TOP

Related Classes of org.spout.vanilla.component.entity.misc.Hunger

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.