/**
   * Turn one item from the furnace source stack into the appropriate smelted item in the furnace
   * result stack
   */
  public void smeltItem() {
    if (this.canSmelt()) {
      ItemStack var1 =
          FreezerRecipes.smelting()
              .getSmeltingResult(this.freezerItemStacks[0].getItem().shiftedIndex);
      ItemStack var2 = new ItemStack(Item.bucketEmpty);

      if (this.freezerItemStacks[2] == null) {
        this.freezerItemStacks[2] = var1.copy();
        if (this.freezerItemStacks[2].getItem().shiftedIndex
            == new ItemStack(Item.iceCube).getItem().shiftedIndex) {
          for (int x = 0; x < 3; x++) ++this.freezerItemStacks[2].stackSize;
        }

        if (this.freezerItemStacks[3] == null) {
          this.freezerItemStacks[3] = var2.copy();
        } else if (this.freezerItemStacks[3].itemID == var2.itemID) {
          ++this.freezerItemStacks[3].stackSize;
        }
      } else if (this.freezerItemStacks[2].itemID == var1.itemID) {
        ++this.freezerItemStacks[2].stackSize;
        if (this.freezerItemStacks[2].getItem().shiftedIndex
            == new ItemStack(Item.iceCube).getItem().shiftedIndex) {
          for (int x = 0; x < 3; x++) ++this.freezerItemStacks[2].stackSize;
        }
        if (this.freezerItemStacks[3] == null) {
          this.freezerItemStacks[3] = var2.copy();
        } else if (this.freezerItemStacks[3].itemID == var2.itemID) {
          ++this.freezerItemStacks[3].stackSize;
        }
      }

      --this.freezerItemStacks[0].stackSize;

      if (this.freezerItemStacks[0].stackSize <= 0) {
        this.freezerItemStacks[0] = null;
      }
    }
  }
Example #2
0
 public boolean wantsItem(ItemStack itemstack1) {
   if (fooditems.contains(itemstack1.itemID) && hunger < 200000 && pickUp == 0) {
     if (item != null) {
       dropItem(item.itemID, 1);
     }
     item = itemstack1.copy();
     if (item.stackSize > 1) {
       dropItem(item.itemID, item.stackSize - 1);
     }
     pickUp = 600;
     return true;
   }
   return false;
 }
Example #3
0
 public void operate() {
   if (!canOperate()) {
     return;
   }
   ItemStack itemstack = getResultFor(inventory[0]);
   if (inventory[2] == null) {
     inventory[2] = itemstack.copy();
   } else {
     inventory[2].stackSize += itemstack.stackSize;
   }
   if (inventory[0].getItem().hasContainerItem()) {
     inventory[0] = new ItemStack(inventory[0].getItem().getContainerItem());
   } else {
     inventory[0].stackSize--;
   }
   if (inventory[0].stackSize <= 0) {
     inventory[0] = null;
   }
 }
  /** Called to transfer a stack from one inventory to the other eg. when shift clicking. */
  @Override
  public ItemStack transferStackInSlot(int par1) {
    ItemStack var2 = null;
    Slot var3 = (Slot) this.inventorySlots.get(par1);

    if (var3 != null && var3.getHasStack()) {
      ItemStack var4 = var3.getStack();
      var2 = var4.copy();

      if (par1 != 0 && par1 != 1) {
        if (var4.getItem() instanceof ItemElectric) {
          if (((ItemElectric) var4.getItem()).canProduceElectricity()) {
            if (!this.mergeItemStack(var4, 1, 2, false)) {
              return null;
            }
          } else {
            if (!this.mergeItemStack(var4, 0, 1, false)) {
              return null;
            }
          }
        } else if (par1 >= 30 && par1 < 38 && !this.mergeItemStack(var4, 3, 30, false)) {
          return null;
        }
      } else if (!this.mergeItemStack(var4, 3, 38, false)) {
        return null;
      }

      if (var4.stackSize == 0) {
        var3.putStack((ItemStack) null);
      } else {
        var3.onSlotChanged();
      }

      if (var4.stackSize == var2.stackSize) {
        return null;
      }

      var3.onPickupFromSlot(var4);
    }

    return var2;
  }
Example #5
0
  public ItemStack checkExtractGeneric(
      IInventory inventory, boolean doRemove, Orientations from, int start, int stop) {
    for (int k = start; k <= stop; ++k)
      if (inventory.getStackInSlot(k) != null && inventory.getStackInSlot(k).stackSize > 0) {

        ItemStack slot = inventory.getStackInSlot(k);

        if (slot != null)
          if (slot.stackSize > 0 && doRemove)
            return inventory.decrStackSize(
                k, (int) powerProvider.useEnergy(1, slot.stackSize, true));
          else if (slot.stackSize < 0) {
            ItemStack k = slot.copy();
            k.stackSize = 1;
            return k;
          } else if (!doRemove) return slot;
      }

    return null;
  }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slotId) {
    ItemStack stack = null;
    Slot slot = (Slot) inventorySlots.get(slotId);

    // If slot isn't empty and item can be stacked.
    if (slot != null && slot.getHasStack()) {
      ItemStack slotStack = slot.getStack();
      stack = slotStack.copy();
      // If slot is in the container inventory, try to transfer the item to the player.
      if (slotId < inventory.getSizeInventory()) {
        if (!mergeItemStack(slotStack, inventory.getSizeInventory(), inventorySlots.size(), true))
          return null;
        // If slot is in the player inventory, try to transfer the item to the container.
      } else if (!mergeItemStack(slotStack, 0, inventory.getSizeInventory(), false)) return null;
      if (slotStack.stackSize != 0) slot.onSlotChanged();
      else slot.putStack(null);
    }

    return stack;
  }
Example #7
0
  @Override
  protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
    int i = 0;
    int j = (width - xSize) / 2;
    int k = (height - ySize) / 2;
    int realXSize = 0;

    if (builder.isBuildingBlueprint()) {
      i = mc.renderEngine.getTexture(DefaultProps.TEXTURE_PATH_GUI + "/builder_blueprint.png");
      realXSize = 256;
    } else {
      i = mc.renderEngine.getTexture(DefaultProps.TEXTURE_PATH_GUI + "/builder.png");
      realXSize = 176;
    }

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.bindTexture(i);

    drawTexturedModalRect(j, k, 0, 0, realXSize, ySize);

    for (int s = 0; s < slots.length; ++s) ((ItemSlot) slots[s]).stack = null;

    Collection<ItemStack> needs = builder.getNeededItems();

    if (needs != null) {
      int s = 0;

      for (ItemStack stack : needs) {
        if (s >= slots.length) break;

        ((ItemSlot) slots[s]).stack = stack.copy();
        s++;
      }
    }

    drawBackgroundSlots();
  }