Search in sources :

Example 1 with ItemFocus

use of am2.items.ItemFocus 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

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