Search in sources :

Example 31 with RecipeData

use of com.mrcrayfish.furniture.api.RecipeData in project MrCrayfishFurnitureMod by MrCrayfish.

the class ContainerOven method transferStackInSlot.

@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotNum) {
    ItemStack itemCopy = ItemStack.EMPTY;
    Slot slot = this.inventorySlots.get(slotNum);
    if (slot != null && slot.getHasStack()) {
        ItemStack item = slot.getStack();
        itemCopy = item.copy();
        RecipeData data = RecipeAPI.getOvenRecipeFromInput(item);
        if (slotNum < 18) {
            if (!this.mergeItemStack(item, 18, this.inventorySlots.size(), true)) {
                return ItemStack.EMPTY;
            }
        } else if (data != null) {
            if (!this.mergeItemStack(item, 0, 9, false)) {
                return ItemStack.EMPTY;
            }
        } else if (slotNum >= 18 && slotNum < this.inventorySlots.size() - 9) {
            if (!this.mergeItemStack(item, this.inventorySlots.size() - 9, this.inventorySlots.size(), false)) {
                return ItemStack.EMPTY;
            }
        } else if (slotNum >= this.inventorySlots.size() - 9 && slotNum < this.inventorySlots.size()) {
            if (!this.mergeItemStack(item, 18, this.inventorySlots.size() - 9, false)) {
                return ItemStack.EMPTY;
            }
        }
        if (item.getCount() == 0) {
            slot.putStack(ItemStack.EMPTY);
        } else {
            slot.onSlotChanged();
        }
    }
    return itemCopy;
}
Also used : Slot(net.minecraft.inventory.Slot) ItemStack(net.minecraft.item.ItemStack) RecipeData(com.mrcrayfish.furniture.api.RecipeData)

Example 32 with RecipeData

use of com.mrcrayfish.furniture.api.RecipeData in project MrCrayfishFurnitureMod by MrCrayfish.

the class ContainerPrinter method transferStackInSlot.

@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotNum) {
    ItemStack itemCopy = ItemStack.EMPTY;
    Slot slot = this.inventorySlots.get(slotNum);
    if (slot != null && slot.getHasStack()) {
        ItemStack item = slot.getStack();
        itemCopy = item.copy();
        if (slotNum == 2) {
            if (!this.mergeItemStack(item, 3, 39, true)) {
                return ItemStack.EMPTY;
            }
            slot.onSlotChange(item, itemCopy);
        } else if (slotNum != 1 && slotNum != 0) {
            RecipeData data = RecipeAPI.getPrinterRecipeFromInput(new ItemStack(itemCopy.getItem()));
            if (data != null) {
                if (!this.mergeItemStack(item, 0, 1, false)) {
                    return ItemStack.EMPTY;
                }
            } else if (TileEntityPrinter.isItemFuel(item)) {
                if (!this.mergeItemStack(item, 1, 2, false)) {
                    return ItemStack.EMPTY;
                }
            } else if (slotNum >= 3 && slotNum < 30) {
                if (!this.mergeItemStack(item, 30, 39, false)) {
                    return ItemStack.EMPTY;
                }
            } else if (slotNum >= 30 && slotNum < 39 && !this.mergeItemStack(item, 3, 30, false)) {
                return ItemStack.EMPTY;
            }
        } else if (!this.mergeItemStack(item, 3, 39, false)) {
            return ItemStack.EMPTY;
        }
        if (item.getCount() == 0) {
            slot.putStack(ItemStack.EMPTY);
        } else {
            slot.onSlotChanged();
        }
        if (item.getCount() == itemCopy.getCount()) {
            return null;
        }
        slot.onTake(player, item);
    }
    return itemCopy;
}
Also used : Slot(net.minecraft.inventory.Slot) ItemStack(net.minecraft.item.ItemStack) RecipeData(com.mrcrayfish.furniture.api.RecipeData)

Example 33 with RecipeData

use of com.mrcrayfish.furniture.api.RecipeData in project MrCrayfishFurnitureMod by MrCrayfish.

the class ContainerDishwasher method transferStackInSlot.

@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotNum) {
    ItemStack itemCopy = ItemStack.EMPTY;
    Slot slot = this.inventorySlots.get(slotNum);
    if (slot != null && slot.getHasStack()) {
        ItemStack item = slot.getStack();
        itemCopy = item.copy();
        if (slotNum <= 6) {
            if (!this.mergeItemStack(item, 7, this.inventorySlots.size(), false)) {
                return ItemStack.EMPTY;
            }
        } else if (slotNum > 6) {
            RecipeData data = RecipeAPI.getDishwasherRecipeFromInput(item);
            if (data != null) {
                int corroSlot = toolToSlot(item);
                if (!this.mergeItemStack(item, corroSlot, corroSlot + 1, true)) {
                    return ItemStack.EMPTY;
                }
            } else if (item.getItem() == FurnitureItems.SOAPY_WATER | item.getItem() == FurnitureItems.SUPER_SOAPY_WATER) {
                if (!this.mergeItemStack(item, 6, 7, false)) {
                    return ItemStack.EMPTY;
                }
            } else if (slotNum > 6 && slotNum < this.inventorySlots.size() - 9) {
                if (!this.mergeItemStack(item, this.inventorySlots.size() - 9, this.inventorySlots.size(), false)) {
                    return ItemStack.EMPTY;
                }
            } else if (slotNum >= this.inventorySlots.size() - 9 && slotNum < this.inventorySlots.size()) {
                if (!this.mergeItemStack(item, 7, this.inventorySlots.size() - 9, false)) {
                    return ItemStack.EMPTY;
                }
            }
        }
        if (item.getCount() == 0) {
            slot.putStack(ItemStack.EMPTY);
        } else {
            slot.onSlotChanged();
        }
    }
    return itemCopy;
}
Also used : Slot(net.minecraft.inventory.Slot) RecipeData(com.mrcrayfish.furniture.api.RecipeData)

Aggregations

RecipeData (com.mrcrayfish.furniture.api.RecipeData)33 ItemStack (net.minecraft.item.ItemStack)8 Slot (net.minecraft.inventory.Slot)6 ZenDoc (crafttweaker.annotations.ZenDoc)3 EntityItem (net.minecraft.entity.item.EntityItem)3 ZenMethod (stanhebben.zenscript.annotations.ZenMethod)3 IItemStack (crafttweaker.api.item.IItemStack)2 TileEntity (net.minecraft.tileentity.TileEntity)2 Recipes (com.mrcrayfish.furniture.api.Recipes)1 TileEntityComputer (com.mrcrayfish.furniture.tileentity.TileEntityComputer)1 TileEntityToaster (com.mrcrayfish.furniture.tileentity.TileEntityToaster)1 CraftTweakerAPI (crafttweaker.CraftTweakerAPI)1 ZenRegister (crafttweaker.annotations.ZenRegister)1 CraftTweakerMC (crafttweaker.api.minecraft.CraftTweakerMC)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 Predicate (java.util.function.Predicate)1 Nonnull (javax.annotation.Nonnull)1