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

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


  /**
   * Drops the player's current item.
   */
  public void dropItem() {
    PlayerInventory inventory = getOwner().get(PlayerInventory.class);
    if (inventory != null) {
      Slot selected = inventory.getQuickbar().getSelectedSlot();
      ItemStack drop = selected.get();
      if (drop == null) {
        return;
      } else {
        drop = drop.clone().setAmount(1);
View Full Code Here


public class DefaultWindow extends Window {
  private boolean opened = false;

  public DefaultWindow(Player owner) {
    super(owner, WindowType.DEFAULT, "Inventory", 9);
    PlayerInventory inventory = getPlayerInventory();

    addInventoryConverter(new InventoryConverter(inventory.getArmor(), "8, 7, 6, 5", new Vector2f[] {
        Vector2f.ZERO, Vector2f.ZERO, Vector2f.ZERO, Vector2f.ZERO
    }));

    addInventoryConverter(new InventoryConverter(inventory.getCraftingGrid(), "3-4, 1-2, 0", new Vector2f[] {
        Vector2f.ZERO, Vector2f.ZERO, Vector2f.ZERO, Vector2f.ZERO, Vector2f.ZERO
    }));
  }
View Full Code Here

    }));
  }

  @Override
  public void close() {
    PlayerInventory pInv = getPlayerInventory();
    //Disconnecting
    if (pInv == null) {
      return;
    }
View Full Code Here

  @ServerOnly
  public boolean onShiftClick(ItemStack stack, int slot, Inventory from) {
    if (getPlayer().getEngine().getPlatform() == Platform.CLIENT) {
      throw new IllegalStateException("Shift click handling is handled server side.");
    }
    final PlayerInventory inventory = getPlayerInventory();

    // Transferring to the armor slots
    if (!(from instanceof EntityArmorInventory)) {
      // Transferring to the armor slots
      final ArmorInventory armor = inventory.getArmor();
      for (int i = 0; i < armor.size(); i++) {
        if (armor.get(i) == null && canSet(armor, i, stack)) {
          armor.set(i, ItemStack.cloneSpecial(stack));
          from.set(slot, stack.setAmount(0));
          return true;
View Full Code Here

  @CommandDescription (aliases = "mapdraw", usage = "<bx> <by> <tx> <ty> <col>", desc = "Draws a rectangle on the current map.  The top nibble for col is the colour and the bottom nibble is the brightness")
  @Permissible ("vanilla.command.debug")
  @Filter (PlayerFilter.class)
  public void mapDraw(Player player, CommandArguments args) throws CommandException {
    args.assertCompletelyParsed();
    PlayerInventory inventory = player.get(PlayerInventory.class);
    if (inventory == null) {
      throw new CommandException("Player has no inventory.");
    }
    ItemStack i = inventory.getQuickbar().getSelectedSlot().get();
    if (i == null || !(i.getMaterial() instanceof Map)) {
      throw new CommandException("Held item is not a map");
    }
    Map m = (Map) i.getMaterial();
    int bx = args.popInteger("bx");
View Full Code Here

  @CommandDescription (aliases = "mapflood", usage = "<col>", desc = "Floods the current map with the given color")
  @Permissible ("vanilla.command.debug")
  @Filter (PlayerFilter.class)
  public void mapFlood(Player player, CommandArguments args) throws CommandException {
    args.assertCompletelyParsed();
    PlayerInventory inventory = player.get(PlayerInventory.class);
    if (inventory == null) {
      throw new CommandException("Player has no inventory.");
    }
    ItemStack i = inventory.getQuickbar().getSelectedSlot().get();
    if (i == null || !(i.getMaterial() instanceof Map)) {
      throw new CommandException("Held item is not a map");
    }
    Map m = (Map) i.getMaterial();
    int col = args.popInteger("col");
View Full Code Here

  private static final float SCALE = 0.75f;

  public Window(Player owner, WindowType type, String title, int offset) {
    super(owner, type, title, offset);

    PlayerInventory inventory = getPlayerInventory();
    GridInventoryConverter main = new GridInventoryConverter(inventory.getMain(), 9, offset, MAIN_POSITION);
    addInventoryConverter(main);
    addInventoryConverter(new GridInventoryConverter(inventory.getQuickbar(), 9, offset + main.getGrid().getSize(), QUICKBAR_POSITION));

    switch (VanillaPlugin.getInstance().getEngine().getPlatform()) {
      case PROXY:
      case SERVER:
        background = label = null;
View Full Code Here

    }
  }

  @Override
  public boolean onShiftClick(ItemStack stack, int slot, Inventory from) {
    final PlayerInventory inventory = getPlayerInventory();
    if (from instanceof CraftingInventory) {
      if (((CraftingInventory) from).onShiftClick(slot, inventory)) {
        return true;
      }
    }

    // Transferring to the main inventory, top to bottom
    if (!(from instanceof PlayerMainInventory)) {
      final Inventory main = inventory.getMain();
      for (int row = PlayerMainInventory.HEIGHT - 1; row >= 0; row--) {
        int startSlot = PlayerMainInventory.LENGTH * row;
        int endSlot = startSlot + PlayerMainInventory.LENGTH - 1;
        main.add(startSlot, endSlot, stack);
        from.set(slot, stack);
        if (stack.isEmpty()) {
          return true;
        }
      }
    }

    // Transferring to the quickbar inventory
    if (!(from instanceof QuickbarInventory)) {
      inventory.getQuickbar().add(stack);
      from.set(slot, stack);
      if (stack.isEmpty()) {
        return true;
      }
    }
View Full Code Here

   *
   * @param entity to get the quickbar of
   * @return The quickbar, or null
   */
  public static QuickbarInventory getQuickbar(Entity entity) {
    PlayerInventory inventory = entity.get(PlayerInventory.class);
    if (entity instanceof Player && inventory != null) {
      return inventory.getQuickbar();
    } else {
      return null;
    }
  }
View Full Code Here

    }

    getSession().send(new PlayerHeldItemChangeMessage(getOwner().add(PlayerInventory.class).getQuickbar().getSelectedSlot().getIndex()));

    // Vanilla Only, MC does not send full inventory update on world change, nor on first connect
    PlayerInventory inv = getOwner().get(PlayerInventory.class);
    if (inv != null) {
      inv.updateAll();
    }

    // TODO: Send scoreboard data here
    world.get(Sky.class).updatePlayer((Player) getOwner());
    // TODO: notify all connected players of login PacketChat 'using: server'
View Full Code Here

TOP

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

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.