Search in sources :

Example 11 with Slot

use of net.minecraft.inventory.container.Slot in project BluePower by Qmunity.

the class ContainerBlulectricAlloyFurnace method quickMoveStack.

@Override
public ItemStack quickMoveStack(PlayerEntity par1EntityPlayer, int par2) {
    ItemStack var3 = ItemStack.EMPTY;
    Slot var4 = slots.get(par2);
    if (var4 != null && var4.hasItem()) {
        ItemStack var5 = var4.getItem();
        var3 = var5.copy();
        if (par2 < 10) {
            if (!moveItemStackTo(var5, 11, 46, false))
                return ItemStack.EMPTY;
            var4.onQuickCraft(var5, var3);
        } else {
            if (FurnaceTileEntity.isFuel(var5) && moveItemStackTo(var5, 0, 1, false)) {
            } else if (!moveItemStackTo(var5, 1, 10, false))
                return ItemStack.EMPTY;
            var4.onQuickCraft(var5, var3);
        }
        if (var5.getCount() == 0) {
            var4.set(ItemStack.EMPTY);
        } else {
            var4.setChanged();
        }
        if (var5.getCount() == var3.getCount())
            return ItemStack.EMPTY;
        var4.onQuickCraft(var3, var5);
    }
    return var3;
}
Also used : Slot(net.minecraft.inventory.container.Slot) ItemStack(net.minecraft.item.ItemStack)

Example 12 with Slot

use of net.minecraft.inventory.container.Slot in project BluePower by Qmunity.

the class ContainerBuffer method quickMoveStack.

@Override
public ItemStack quickMoveStack(PlayerEntity player, int par2) {
    ItemStack itemstack = ItemStack.EMPTY;
    Slot slot = (Slot) slots.get(par2);
    if (slot != null && slot.hasItem()) {
        ItemStack itemstack1 = slot.getItem();
        itemstack = itemstack1.copy();
        if (par2 < 20) {
            if (!moveItemStackTo(itemstack1, 20, 56, true))
                return ItemStack.EMPTY;
        } else if (!moveItemStackTo(itemstack1, 0, 20, false)) {
            return ItemStack.EMPTY;
        }
        if (itemstack1.getCount() == 0) {
            slot.set(ItemStack.EMPTY);
        } else {
            slot.setChanged();
        }
        if (itemstack1.getCount() != itemstack.getCount()) {
            slot.onQuickCraft(itemstack, itemstack1);
        } else {
            return ItemStack.EMPTY;
        }
    }
    return itemstack;
}
Also used : Slot(net.minecraft.inventory.container.Slot) ItemStack(net.minecraft.item.ItemStack)

Example 13 with Slot

use of net.minecraft.inventory.container.Slot in project BluePower by Qmunity.

the class ContainerCanvasBag method quickMoveStack.

@Override
public ItemStack quickMoveStack(PlayerEntity par1EntityPlayer, int par2) {
    ItemStack itemstack = ItemStack.EMPTY;
    Slot slot = (Slot) slots.get(par2);
    if (slot != null && slot.hasItem()) {
        ItemStack itemstack1 = slot.getItem();
        itemstack = itemstack1.copy();
        if (par2 < 27) {
            if (!moveItemStackTo(itemstack1, 27, 63, true)) {
                return ItemStack.EMPTY;
            }
        } else if (!moveItemStackTo(itemstack1, 0, 27, false)) {
            return ItemStack.EMPTY;
        }
        if (itemstack1.getCount() == 0) {
            slot.set(ItemStack.EMPTY);
        } else {
            slot.setChanged();
        }
        if (itemstack1.getCount() == itemstack.getCount()) {
            return ItemStack.EMPTY;
        }
        slot.onQuickCraft(itemstack, itemstack1);
    }
    return itemstack;
}
Also used : Slot(net.minecraft.inventory.container.Slot) ItemStack(net.minecraft.item.ItemStack)

Example 14 with Slot

use of net.minecraft.inventory.container.Slot in project BluePower by Qmunity.

the class ContainerDeployer method moveItemStackTo.

@Override
public boolean moveItemStackTo(ItemStack par1ItemStack, int par2, int par3, boolean par4) {
    boolean flag1 = false;
    int k = par2;
    if (par4) {
        k = par3 - 1;
    }
    Slot slot;
    ItemStack itemstack1;
    if (par1ItemStack.isStackable()) {
        while (par1ItemStack.getCount() > 0 && (!par4 && k < par3 || par4 && k >= par2)) {
            slot = (Slot) slots.get(k);
            itemstack1 = slot.getItem();
            if (!itemstack1.isEmpty() && itemstack1.getItem() == par1ItemStack.getItem() && (!par1ItemStack.hasContainerItem() || par1ItemStack.getDamageValue() == itemstack1.getDamageValue()) && ItemStack.tagMatches(par1ItemStack, itemstack1) && slot.mayPlace(par1ItemStack)) {
                int l = itemstack1.getCount() + par1ItemStack.getCount();
                if (l <= par1ItemStack.getMaxStackSize()) {
                    par1ItemStack.setCount(0);
                    itemstack1.setCount(l);
                    slot.setChanged();
                    flag1 = true;
                } else if (itemstack1.getCount() < par1ItemStack.getMaxStackSize()) {
                    par1ItemStack.setCount(par1ItemStack.getCount() - par1ItemStack.getMaxStackSize() - itemstack1.getCount());
                    itemstack1.setCount(par1ItemStack.getMaxStackSize());
                    slot.setChanged();
                    flag1 = true;
                }
            }
            if (par4) {
                --k;
            } else {
                ++k;
            }
        }
    }
    if (par1ItemStack.getCount() > 0) {
        if (par4) {
            k = par3 - 1;
        } else {
            k = par2;
        }
        while (!par4 && k < par3 || par4 && k >= par2) {
            slot = (Slot) slots.get(k);
            itemstack1 = slot.getItem();
            if (itemstack1.isEmpty() && slot.mayPlace(par1ItemStack)) {
                if (1 < par1ItemStack.getCount()) {
                    ItemStack copy = par1ItemStack.copy();
                    copy.setCount(1);
                    slot.set(copy);
                    par1ItemStack.setCount(par1ItemStack.getCount() - 1);
                    flag1 = true;
                    break;
                } else {
                    slot.set(par1ItemStack.copy());
                    slot.setChanged();
                    par1ItemStack.setCount(0);
                    flag1 = true;
                    break;
                }
            }
            if (par4) {
                --k;
            } else {
                ++k;
            }
        }
    }
    return flag1;
}
Also used : Slot(net.minecraft.inventory.container.Slot) ItemStack(net.minecraft.item.ItemStack)

Example 15 with Slot

use of net.minecraft.inventory.container.Slot in project BluePower by Qmunity.

the class ContainerEjector method quickMoveStack.

@Override
public ItemStack quickMoveStack(PlayerEntity player, int par2) {
    ItemStack itemstack = ItemStack.EMPTY;
    Slot slot = (Slot) slots.get(par2);
    if (slot != null && slot.hasItem()) {
        ItemStack itemstack1 = slot.getItem();
        itemstack = itemstack1.copy();
        if (par2 < 9) {
            if (!moveItemStackTo(itemstack1, 9, 45, true))
                return ItemStack.EMPTY;
        } else if (!moveItemStackTo(itemstack1, 0, 9, false)) {
            return ItemStack.EMPTY;
        }
        if (itemstack1.getCount() == 0) {
            slot.set(ItemStack.EMPTY);
        } else {
            slot.setChanged();
        }
        if (itemstack1.getCount() != itemstack.getCount()) {
            slot.onQuickCraft(itemstack, itemstack1);
        } else {
            return ItemStack.EMPTY;
        }
    }
    return itemstack;
}
Also used : Slot(net.minecraft.inventory.container.Slot) ItemStack(net.minecraft.item.ItemStack)

Aggregations

Slot (net.minecraft.inventory.container.Slot)21 ItemStack (net.minecraft.item.ItemStack)21 Nonnull (javax.annotation.Nonnull)2 IAgriJournalItem (com.infinityraider.agricraft.api.v1.content.items.IAgriJournalItem)1 IAgriSeedItem (com.infinityraider.agricraft.api.v1.content.items.IAgriSeedItem)1