Search in sources :

Example 1 with ItemFocusCharge

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

the class ContainerArcaneReconstructor method mergeSpecialItems.

private boolean mergeSpecialItems(ItemStack stack, Slot slot) {
    if (stack.getItem() instanceof ItemFocusCharge) {
        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().isRepairable() && stack.isItemDamaged()) {
        for (int b = 4; b < 10; ++b) {
            Slot repairSlot = (Slot) inventorySlots.get(b);
            if (repairSlot.getHasStack())
                continue;
            ItemStack input = new ItemStack(stack.getItem(), 1, stack.getItemDamage());
            if (stack.stackTagCompound != null) {
                input.setTagCompound((NBTTagCompound) stack.stackTagCompound.copy());
            }
            repairSlot.putStack(input);
            repairSlot.onSlotChanged();
            stack.stackSize--;
            if (stack.stackSize == 0) {
                slot.putStack(null);
                slot.onSlotChanged();
            }
            return true;
        }
    }
    return false;
}
Also used : ItemFocusCharge(am2.items.ItemFocusCharge) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Slot(net.minecraft.inventory.Slot) ItemStack(net.minecraft.item.ItemStack)

Example 2 with ItemFocusCharge

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

the class ContainerArcaneDeconstructor method mergeSpecialItems.

private boolean mergeSpecialItems(ItemStack stack, Slot slot) {
    if (stack.getItem() instanceof ItemFocusCharge) {
        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;
        }
    }
    return false;
}
Also used : ItemFocusCharge(am2.items.ItemFocusCharge) Slot(net.minecraft.inventory.Slot) ItemStack(net.minecraft.item.ItemStack)

Example 3 with ItemFocusCharge

use of am2.items.ItemFocusCharge 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 4 with ItemFocusCharge

use of am2.items.ItemFocusCharge 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)4 Slot (net.minecraft.inventory.Slot)4 ItemStack (net.minecraft.item.ItemStack)4 ItemFocusMana (am2.items.ItemFocusMana)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 ItemSpellBase (am2.api.spell.ItemSpellBase)1 ItemFocus (am2.items.ItemFocus)1