Search in sources :

Example 6 with Slot

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

the class ContainerDeployer 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 < 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()) {
            return ItemStack.EMPTY;
        }
        slot.onQuickCraft(itemstack, itemstack1);
    }
    return itemstack;
}
Also used : Slot(net.minecraft.inventory.container.Slot) ItemStack(net.minecraft.item.ItemStack)

Example 7 with Slot

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

the class ContainerBlulectricFurnace method quickMoveStack.

@Override
public ItemStack quickMoveStack(PlayerEntity playerIn, int index) {
    ItemStack stack1 = ItemStack.EMPTY;
    Slot slot = slots.get(index);
    if (slot != null && slot.hasItem()) {
        ItemStack stack = slot.getItem();
        stack1 = stack.copy();
        if (index < 2) {
            if (!moveItemStackTo(stack, 2, 37, false))
                return ItemStack.EMPTY;
            slot.onQuickCraft(stack, stack1);
        } else {
            if (!moveItemStackTo(stack, 0, 1, false))
                return ItemStack.EMPTY;
            slot.onQuickCraft(stack, stack1);
        }
        if (stack.isEmpty()) {
            slot.set(ItemStack.EMPTY);
        } else {
            slot.setChanged();
        }
        if (stack.getCount() == stack1.getCount())
            return ItemStack.EMPTY;
        slot.onTake(playerIn, stack);
    }
    return stack1;
}
Also used : Slot(net.minecraft.inventory.container.Slot) ItemStack(net.minecraft.item.ItemStack)

Example 8 with Slot

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

the class ContainerCircuitDatabaseMain 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, 55, false))
                return ItemStack.EMPTY;
        } else {
            if (!moveItemStackTo(itemstack1, 2, 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 9 with Slot

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

the class ContainerCircuitTable method quickMoveStack.

@Override
public ItemStack quickMoveStack(PlayerEntity player, int par2) {
    if (!isRetrying)
        itemsCrafted = 0;
    ItemStack itemstack = ItemStack.EMPTY;
    Slot slot = (Slot) slots.get(par2);
    if (slot != null && slot.hasItem()) {
        ItemStack itemstack1 = slot.getItem();
        itemstack = itemstack1.copy();
        if (par2 < 42) {
            if (!moveItemStackTo(itemstack1, 42, 77, false))
                return ItemStack.EMPTY;
        } else {
            if (!moveItemStackTo(itemstack1, 24, 42, 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 10 with Slot

use of net.minecraft.inventory.container.Slot in project AgriCraft by AgriCraft.

the class SeedAnalyzerContainer method transferStackInSlot.

@Nonnull
@Override
public ItemStack transferStackInSlot(@Nonnull PlayerEntity playerIn, int index) {
    ItemStack itemStack = ItemStack.EMPTY;
    Slot slot = this.inventorySlots.get(index);
    if (slot != null && slot.getHasStack()) {
        ItemStack slotStack = slot.getStack();
        itemStack = slotStack.copy();
        if (index <= 1) {
            // shift-click in seed/journal slot
            if (!this.mergeItemStack(slotStack, 2, 38, true)) {
                return ItemStack.EMPTY;
            }
        } else if (index <= 38) {
            // shift-click in inventory slots
            if (slotStack.getItem() instanceof IAgriSeedItem) {
                if (!this.mergeItemStack(slotStack, 0, 1, false)) {
                    return ItemStack.EMPTY;
                }
            } else if (slotStack.getItem() instanceof IAgriJournalItem) {
                if (!this.mergeItemStack(slotStack, 1, 2, false)) {
                    return ItemStack.EMPTY;
                }
            }
        }
        if (slotStack.isEmpty()) {
            slot.putStack(ItemStack.EMPTY);
        } else {
            slot.onSlotChanged();
        }
        if (slotStack.getCount() == itemStack.getCount()) {
            return ItemStack.EMPTY;
        }
        slot.onTake(playerIn, slotStack);
    }
    return itemStack;
}
Also used : Slot(net.minecraft.inventory.container.Slot) ItemStack(net.minecraft.item.ItemStack) IAgriSeedItem(com.infinityraider.agricraft.api.v1.content.items.IAgriSeedItem) IAgriJournalItem(com.infinityraider.agricraft.api.v1.content.items.IAgriJournalItem) Nonnull(javax.annotation.Nonnull)

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