コード例 #1
0
 /**
  * Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't
  * full, etc.
  */
 private boolean canSmelt() {
   if (this.furnaceItemStacks[0] == null) {
     return false;
   } else {
     ItemStack itemstack =
         ConcreteMixerRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]);
     if (itemstack == null) return false;
     if (this.furnaceItemStacks[2] == null) return true;
     if (!this.furnaceItemStacks[2].isItemEqual(itemstack)) return false;
     int result = furnaceItemStacks[2].stackSize + itemstack.stackSize;
     return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize());
   }
 }
コード例 #2
0
  /**
   * Called when a player shift-clicks on a slot. You must override this or you will crash when
   * someone does that.
   */
  public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
    ItemStack itemstack = null;
    Slot slot = (Slot) this.inventorySlots.get(par2);

    if (slot != null && slot.getHasStack()) {
      ItemStack itemstack1 = slot.getStack();
      itemstack = itemstack1.copy();

      if (par2 == 2) {
        if (!this.mergeItemStack(itemstack1, 3, 39, true)) {
          return null;
        }

        slot.onSlotChange(itemstack1, itemstack);
      } else if (par2 != 1 && par2 != 0) {
        if (ConcreteMixerRecipes.smelting().getSmeltingResult(itemstack1) != null) {
          if (!this.mergeItemStack(itemstack1, 0, 1, false)) {
            return null;
          }
        } else if (TileEntityConcreteMixer.isItemFuel(itemstack1)) {
          if (!this.mergeItemStack(itemstack1, 1, 2, false)) {
            return null;
          }
        } else if (par2 >= 3 && par2 < 30) {
          if (!this.mergeItemStack(itemstack1, 30, 39, false)) {
            return null;
          }
        } else if (par2 >= 30 && par2 < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) {
          return null;
        }
      } else if (!this.mergeItemStack(itemstack1, 3, 39, false)) {
        return null;
      }

      if (itemstack1.stackSize == 0) {
        slot.putStack((ItemStack) null);
      } else {
        slot.onSlotChanged();
      }

      if (itemstack1.stackSize == itemstack.stackSize) {
        return null;
      }

      slot.onPickupFromSlot(par1EntityPlayer, itemstack1);
    }

    return itemstack;
  }
コード例 #3
0
  /**
   * 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 itemstack =
          ConcreteMixerRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]);

      if (this.furnaceItemStacks[2] == null) {
        this.furnaceItemStacks[2] = itemstack.copy();
      } else if (this.furnaceItemStacks[2].isItemEqual(itemstack)) {
        furnaceItemStacks[2].stackSize += itemstack.stackSize;
      }

      --this.furnaceItemStacks[0].stackSize;

      if (this.furnaceItemStacks[0].stackSize <= 0) {
        this.furnaceItemStacks[0] = null;
      }
    }
  }