Package org.spoutcraft.api.inventory

Examples of org.spoutcraft.api.inventory.ItemStack


  public ItemStack readItemStack(ItemStack item) {
    int id = readInt();
    short dura = readShort();
    short amt = readShort();
    return new ItemStack(id, amt, dura);
  }
View Full Code Here


    Spoutcraft.getRenderDelegate().render(this);
  }

  public ItemStack getItem() {
    if (stack == null) {
      stack = new ItemStack(0);
    }
    return stack.clone();
  }
View Full Code Here

    return stack.clone();
  }

  public Slot setItem(ItemStack item) {
    if (item == null) {
      stack = new ItemStack(0);
      setTooltip("");
      return this;
    }
    stack = item.clone();
    setTooltip(Spoutcraft.getMaterialManager().getToolTip(stack));
View Full Code Here

  @Override
  public void readData(SpoutInputStream input) throws IOException {
    super.readData(input);

    setItem(new ItemStack(input.readInt(), (int) input.readShort(), input.readShort()));
    depth = input.readInt();

        renderAmount = input.readBoolean();
    boolean hasDisplayName = input.readBoolean();
    if (hasDisplayName) {
View Full Code Here

  protected short data = -1;
  protected int depth = 8;
  protected ItemStack toRender = null;

  public GenericItemWidget() {
    this(new ItemStack(0));
  }
View Full Code Here

    this.item = item;
    this.name = item.getName();
    this.fullName = item.getFullName();
    this.customId = item.getCustomId();
    MaterialData.addCustomBlock(this);
    this.setItemDrop(new ItemStack(this, 1));
  }
View Full Code Here

    setFriction(input.readFloat());
    setHardness(input.readFloat());
    setLightLevel(input.readInt());
    item = new GenericCustomItem(addon, name, customId);
    MaterialData.addCustomBlock(this);
    this.setItemDrop(new ItemStack(this, 1));
    this.blockId = isOpaque() ? 1 :20;
  }
View Full Code Here

  public void render(GenericSlot genericSlot) {
    if (!genericSlot.isVisible()) {
      return;
    }
    ItemStack item = genericSlot.getItem();

    GL11.glDepthFunc(515);
    RenderHelper.enableGUIStandardItemLighting();
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_COLOR_MATERIAL);
    GL11.glPushMatrix();
    GL11.glTranslatef((float) genericSlot.getScreenX(), (float) genericSlot.getScreenY(), 0);
    if (genericSlot.getAnchor() == WidgetAnchor.SCALE) {
      GL11.glScalef((float) (genericSlot.getScreen().getWidth() / 427f), (float) (genericSlot.getScreen().getHeight() / 240f), 1);
    }
    GL11.glScaled(genericSlot.getWidth() / 16D, genericSlot.getHeight() / 16D, 1);

    if (item.getTypeId() != 0) {
      GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
      int id = item.getTypeId();
      int data = item.getDurability();
      if (MaterialData.getCustomItem(id) != null) {
        int temp = id;
        id = 318;
        data = temp;
      }
      renderer.renderItemIntoGUI(SpoutClient.getHandle().fontRenderer, SpoutClient.getHandle().renderEngine, new net.minecraft.src.ItemStack(id, !genericSlot.doesRenderAmount() ? 0 : item.getAmount(), data), 0, 0);
      renderer.renderItemOverlayIntoGUI(SpoutClient.getHandle().fontRenderer, SpoutClient.getHandle().renderEngine, new net.minecraft.src.ItemStack(id, !genericSlot.doesRenderAmount() ? 0 : item.getAmount(), data), 0, 0);
    }
    GL11.glEnable(GL11.GL_LIGHTING);
    RenderHelper.disableStandardItemLighting();
    if (isHovering(genericSlot)) RenderUtil.drawRectangle(0, 0, 16, 16, 0x88ffffff);
    GL11.glPopMatrix();
View Full Code Here

    if (mcItems.length != items.length) {
      throw new IllegalArgumentException("Invalid inventory size; expected " + mcItems.length);
    }

    for (int i = 0; i < items.length; i++) {
      ItemStack item = items[i];
      if (item == null || item.getTypeId() <= 0) {
        getInventory().setInventorySlotContents(i, null);
      } else {
        getInventory().setInventorySlotContents(i, new net.minecraft.src.ItemStack(item.getTypeId(), item.getAmount(), item.getDurability()));
      }
    }
  }
View Full Code Here

  public HashMap<Integer, ItemStack> all(int materialId) {
    HashMap<Integer, ItemStack> slots = new HashMap<Integer, ItemStack>();

    ItemStack[] inventory = getContents();
    for (int i = 0; i < inventory.length; i++) {
      ItemStack item = inventory[i];
      if (item != null && item.getTypeId() == materialId) {
        slots.put(i, item);
      }
    }
    return slots;
  }
View Full Code Here

TOP

Related Classes of org.spoutcraft.api.inventory.ItemStack

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.