Search in sources :

Example 1 with ItemFocusMana

use of am2.items.ItemFocusMana in project ArsMagica2 by Mithion.

the class ContainerCalefactor method mergeSpecialItems.

private boolean mergeSpecialItems(ItemStack stack, Slot slot) {
    if (stack.getItem() instanceof ItemFocusCharge || stack.getItem() instanceof ItemFocusMana) {
        for (int b = 2; b < 5; ++b) {
            Slot focusSlot = (Slot) inventorySlots.get(b);
            if (focusSlot.getHasStack())
                continue;
            focusSlot.putStack(new ItemStack(stack.getItem(), 1, stack.getItemDamage()));
            focusSlot.onSlotChanged();
            stack.stackSize--;
            if (stack.stackSize == 0) {
                slot.putStack(null);
                slot.onSlotChanged();
            }
            return true;
        }
    } else if (FurnaceRecipes.smelting().getSmeltingResult(stack) != null) {
        Slot focusSlot = (Slot) inventorySlots.get(0);
        boolean b = mergeItemStack(stack, 0, 1, false);
        if (stack.stackSize == 0) {
            slot.putStack(null);
            slot.onSlotChanged();
        }
        return b;
    }
    return false;
}
Also used : ItemFocusMana(am2.items.ItemFocusMana) ItemFocusCharge(am2.items.ItemFocusCharge) Slot(net.minecraft.inventory.Slot) ItemStack(net.minecraft.item.ItemStack)

Example 2 with ItemFocusMana

use of am2.items.ItemFocusMana in project ArsMagica2 by Mithion.

the class ContainerSummoner method mergeSpecialItems.

private boolean mergeSpecialItems(ItemStack stack, Slot slot) {
    if (stack.getItem() instanceof ItemFocus) {
        if (stack.getItem() instanceof ItemFocusCharge || stack.getItem() instanceof ItemFocusMana) {
            for (int b = 0; b < 3; ++b) {
                Slot focusSlot = (Slot) inventorySlots.get(b);
                if (focusSlot.getHasStack())
                    continue;
                focusSlot.putStack(new ItemStack(stack.getItem(), 1, stack.getItemDamage()));
                focusSlot.onSlotChanged();
                stack.stackSize--;
                if (stack.stackSize == 0) {
                    slot.putStack(null);
                    slot.onSlotChanged();
                }
                return true;
            }
        }
    } else if (stack.getItem() instanceof ItemSpellBase) {
        Slot scrollSlot = (Slot) inventorySlots.get(3);
        if (scrollSlot.getHasStack())
            return false;
        ItemStack castStack = new ItemStack(stack.getItem(), 1, stack.getItemDamage());
        if (stack.hasTagCompound()) {
            castStack.setTagCompound((NBTTagCompound) stack.stackTagCompound.copy());
        }
        scrollSlot.putStack(castStack);
        scrollSlot.onSlotChanged();
        stack.stackSize--;
        if (stack.stackSize == 0) {
            slot.putStack(null);
            slot.onSlotChanged();
        }
        return true;
    }
    return false;
}
Also used : ItemFocusMana(am2.items.ItemFocusMana) ItemFocusCharge(am2.items.ItemFocusCharge) ItemSpellBase(am2.api.spell.ItemSpellBase) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Slot(net.minecraft.inventory.Slot) ItemFocus(am2.items.ItemFocus) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemFocusCharge (am2.items.ItemFocusCharge)2 ItemFocusMana (am2.items.ItemFocusMana)2 Slot (net.minecraft.inventory.Slot)2 ItemStack (net.minecraft.item.ItemStack)2 ItemSpellBase (am2.api.spell.ItemSpellBase)1 ItemFocus (am2.items.ItemFocus)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1