Пример #1
0
  @Override
  public void setInventorySlotContents(int i, ItemStack itemstack) {

    // TODO: add gregcipies
    if (i == 0) glassPanel = itemstack;
    else {

      ForgeDirection front = RotatableBlock.getFront(this.getBlockMetadata());

      for (ForgeDirection f : VALID_INVENTORY_DIRECTIONS) {
        if (f == front) continue;

        TileEntity e =
            this.worldObj.getTileEntity(
                this.xCoord + f.offsetX, this.yCoord + f.offsetY, this.zCoord + f.offsetZ);

        // TODO: may cause inf loop
        if (e != null && e instanceof IInventory)
          if (i < ((IInventory) e).getSizeInventory()) {
            ((IInventory) e).setInventorySlotContents(i, itemstack);
            break;
          } else i -= ((IInventory) e).getSizeInventory();
      }

      this.checkCanRun();
    }
  }
Пример #2
0
 @Override
 public boolean canConnectEnergy(ForgeDirection from) {
   return from != ForgeDirection.DOWN
       && from
           != RotatableBlock.getFront(
               this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord));
 }
Пример #3
0
  @Override
  public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
    if (from == ForgeDirection.DOWN
        || from
            == RotatableBlock.getFront(
                this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord))) return 0;

    return storage.receiveEnergy(maxReceive, simulate);
  }
Пример #4
0
  /**
   * Gets the first inventory with an empty slot
   *
   * @return first available inventory or null
   */
  private IInventory getAvalibleInv() {
    ForgeDirection front = RotatableBlock.getFront(this.getBlockMetadata());

    for (ForgeDirection f : VALID_INVENTORY_DIRECTIONS) {
      if (f == front) continue;

      TileEntity e =
          this.worldObj.getTileEntity(
              this.xCoord + f.offsetX, this.yCoord + f.offsetY, this.zCoord + f.offsetZ);

      if (e != null && e instanceof IInventory && ZUtils.numEmptySlots((IInventory) e) > 0)
        return (IInventory) e;
    }
    return null;
  }
Пример #5
0
  // InventoryHandling start
  @Override
  public int getSizeInventory() {
    int sizeInv = 0;
    ForgeDirection front = RotatableBlock.getFront(this.getBlockMetadata());

    for (ForgeDirection f : VALID_INVENTORY_DIRECTIONS) {
      if (f == front) continue;

      TileEntity e =
          this.worldObj.getTileEntity(
              this.xCoord + f.offsetX, this.yCoord + f.offsetY, this.zCoord + f.offsetZ);

      // TODO: may cause inf loop
      if (e != null && e instanceof IInventory) sizeInv += ((IInventory) e).getSizeInventory();
    }

    return sizeInv;
  }
Пример #6
0
  @Override
  public ItemStack getStackInSlot(int i) {
    if (i == 0) return glassPanel;
    else {
      ForgeDirection front = RotatableBlock.getFront(this.getBlockMetadata());

      for (ForgeDirection f : VALID_INVENTORY_DIRECTIONS) {
        if (f == front) continue;

        TileEntity e =
            this.worldObj.getTileEntity(
                this.xCoord + f.offsetX, this.yCoord + f.offsetY, this.zCoord + f.offsetZ);

        // TODO: may cause inf loop
        if (e != null && e instanceof IInventory)
          if (i < ((IInventory) e).getSizeInventory()) return ((IInventory) e).getStackInSlot(i);
          else i -= ((IInventory) e).getSizeInventory();
      }
      return null;
    }
  }
Пример #7
0
  @Override
  public boolean isItemValidForSlot(int i, ItemStack itemstack) {
    if (i == 0)
      return CompatibilityMgr.gregtechLoaded
          ? OreDictionary.getOreName(OreDictionary.getOreID(itemstack)).equals("lenseRuby")
          : Item.getItemFromBlock(Blocks.glass_pane) == itemstack.getItem() ? true : false;

    ForgeDirection front = RotatableBlock.getFront(this.getBlockMetadata());

    for (ForgeDirection f : VALID_INVENTORY_DIRECTIONS) {
      if (f == front) continue;

      TileEntity e =
          this.worldObj.getTileEntity(
              this.xCoord + f.offsetX, this.yCoord + f.offsetY, this.zCoord + f.offsetZ);

      // TODO: may cause inf loop
      if (e != null && e instanceof IInventory)
        if (i < ((IInventory) e).getSizeInventory())
          return ((IInventory) e).isItemValidForSlot(i, itemstack);
        else i -= ((IInventory) e).getSizeInventory();
    }
    return false;
  }