Package org.spout.vanilla.component.entity.inventory

Examples of org.spout.vanilla.component.entity.inventory.WindowHolder


      updateProgressArrow(player);
    }
  }

  private void updateProgressArrow(Player player) {
    WindowHolder window = player.get(WindowHolder.class);
    if (window != null) {
      float increment = 0.0f;
      if (canSmelt()) {
        float maxSmeltTime = getMaxSmeltTime();
        increment = (MAX_SMELT_TIME_INCREMENT * 20) - ((MAX_SMELT_TIME_INCREMENT / maxSmeltTime) * (getSmeltTime() * 20));
      }
      window.getActiveWindow().setProperty(FurnaceProperty.PROGRESS_ARROW, (int) increment);
    }
  }
View Full Code Here


      updateFireIcon(player);
    }
  }

  private void updateFireIcon(Player player) {
    WindowHolder window = player.get(WindowHolder.class);
    if (window != null) {
      // (12.5 / maximum time from fuel source) * (fuel seconds left * 20) = increment to send to client
      float maxFuel = getMaxFuel();
      float increment = MAX_FUEL_INCREMENT / maxFuel * (getFuel() * 20);
      window.getActiveWindow().setProperty(FurnaceProperty.FIRE_ICON, (int) increment);
    }
  }
View Full Code Here

  @Override
  public boolean open(Player player) {
    FurnaceOpenEvent event = player.getEngine().getEventManager().callEvent(new FurnaceOpenEvent(this, player));
    if (!event.isCancelled()) {
      WindowHolder window = player.get(WindowHolder.class);
      if (window != null) {
        window.openWindow(new FurnaceWindow(player, this, getInventory()));
        updateProgressArrow(player);
        updateFireIcon(player);
      }
      return true;
    }
View Full Code Here

    if (!isPressed(args)) {
      return;
    }
    args.assertCompletelyParsed();

    WindowHolder holder = ((Player) source).get(WindowHolder.class);
    Window window = holder.getActiveWindow();
    if (window.isOpened()) {
      holder.closeWindow();
    } else {
      holder.openWindow(holder.getDefaultWindow());
    }
  }
View Full Code Here

import org.spout.vanilla.protocol.msg.window.WindowCloseMessage;

public final class WindowCloseHandler extends MessageHandler<WindowCloseMessage> {
  @Override
  public void handleServer(ServerSession session, WindowCloseMessage message) {
    WindowHolder window = session.getPlayer().get(WindowHolder.class);
    if (window != null) {
      if (window.getActiveWindow() instanceof ChestWindow) {
        SoundEffects.RANDOM_CHESTCLOSED.playGlobal(session.getPlayer().getPhysics().getPosition());
      }
      window.closeWindow();
    }
  }
View Full Code Here

public class WindowPropertyHandler extends MessageHandler<WindowPropertyMessage> {
  @Override
  public void handleClient(ClientSession session, WindowPropertyMessage msg) {
    Player player = session.getPlayer();
    WindowHolder holder = player.get(WindowHolder.class);
    if (holder != null) {
      holder.getActiveWindow().setProperty(msg.getProgressBar(), msg.getValue());
    }
  }
View Full Code Here

public class WindowItemsHandler extends MessageHandler<WindowItemsMessage> {
  @Override
  public void handleClient(ClientSession session, WindowItemsMessage msg) {
    Player player = session.getPlayer();
    WindowHolder holder = player.get(WindowHolder.class);
    if (holder == null) {
      return;
    }
    Window window = holder.getActiveWindow();
    ItemStack[] slots = msg.getItems();
    for (int i = 0; i < slots.length; i++) {
      Slot entry = window.getSlot(i);
      if (entry == null) {
        return;
View Full Code Here

public class WindowSlotHandler extends MessageHandler<WindowSlotMessage> {
  @Override
  public void handleClient(ClientSession session, WindowSlotMessage msg) {
    Player player = session.getPlayer();
    WindowHolder holder = player.get(WindowHolder.class);
    if (holder != null) {
      Slot entry = holder.getActiveWindow().getSlot(msg.getSlot());
      if (entry == null) {
        return;
      }

      entry.getInventory().set(entry.getIndex(), msg.get());
View Full Code Here

TOP

Related Classes of org.spout.vanilla.component.entity.inventory.WindowHolder

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.