Search in sources :

Example 6 with IMachineRecipe

use of crazypants.enderio.base.recipe.IMachineRecipe in project EnderIO by SleepyTrousers.

the class TileAlloySmelter method isMachineItemValidForSlot.

@Override
public boolean isMachineItemValidForSlot(int slot, @Nonnull ItemStack itemstack) {
    if (!slotDefinition.isInputSlot(slot)) {
        return false;
    }
    // We will assume anything that is in a slot is valid, so just return whether the new input can be stacked with the current one
    ItemStack currentStackInSlot = NullHelper.first(inventory[slot], Prep.getEmpty());
    if (Prep.isValid(currentStackInSlot)) {
        return currentStackInSlot.isItemEqual(itemstack);
    }
    int numSlotsFilled = 0;
    for (int i = slotDefinition.getMinInputSlot(); i <= slotDefinition.getMaxInputSlot(); i++) {
        if (i >= 0 && i < inventory.length) {
            if (inventory[i] != null && inventory[i].getCount() > 0) {
                numSlotsFilled++;
            }
        }
    }
    NNList<IMachineRecipe> recipes = MachineRecipeRegistry.instance.getRecipesForInput(getMachineName(), MachineRecipeInput.create(slot, itemstack));
    if (getMode() == Mode.FURNACE) {
        return isValidInputForFurnaceRecipe(itemstack, numSlotsFilled, recipes);
    } else if (getMode() == Mode.ALLOY) {
        return isValidInputForAlloyRecipe(slot, itemstack, numSlotsFilled, recipes);
    }
    return isValidInputForFurnaceRecipe(itemstack, numSlotsFilled, recipes) || isValidInputForAlloyRecipe(slot, itemstack, numSlotsFilled, recipes);
}
Also used : ItemStack(net.minecraft.item.ItemStack) IMachineRecipe(crazypants.enderio.base.recipe.IMachineRecipe)

Example 7 with IMachineRecipe

use of crazypants.enderio.base.recipe.IMachineRecipe in project EnderIO by SleepyTrousers.

the class TileSoulBinder method canStartNextTask.

@Override
protected IMachineRecipe canStartNextTask(long nextSeed) {
    IMachineRecipe recipe = super.canStartNextTask(nextSeed);
    if (recipe == null) {
        return null;
    }
    int xpRequired = ((ISoulBinderRecipe) recipe).getExperienceRequired();
    if (xpCont.getExperienceTotal() >= xpRequired) {
        return recipe;
    }
    return null;
}
Also used : ISoulBinderRecipe(crazypants.enderio.base.recipe.soul.ISoulBinderRecipe) IMachineRecipe(crazypants.enderio.base.recipe.IMachineRecipe)

Example 8 with IMachineRecipe

use of crazypants.enderio.base.recipe.IMachineRecipe in project EnderIO by SleepyTrousers.

the class TileEntityPainter method isMachineItemValidForSlot.

@Override
public boolean isMachineItemValidForSlot(int i, @Nonnull ItemStack itemStack) {
    if (i > 1) {
        return false;
    }
    ItemStack paint = i == 0 ? getStackInSlot(1) : itemStack;
    ItemStack targt = i == 0 ? itemStack : getStackInSlot(0);
    Map<String, IMachineRecipe> recipes = MachineRecipeRegistry.instance.getRecipesForMachine(getMachineName());
    for (IMachineRecipe rec : recipes.values()) {
        if (rec instanceof AbstractPainterTemplate<?>) {
            AbstractPainterTemplate<?> temp = (AbstractPainterTemplate<?>) rec;
            if (temp.isPartialRecipe(paint, targt)) {
                return true;
            }
        }
    }
    return false;
}
Also used : AbstractPainterTemplate(crazypants.enderio.base.recipe.painter.AbstractPainterTemplate) ItemStack(net.minecraft.item.ItemStack) IMachineRecipe(crazypants.enderio.base.recipe.IMachineRecipe)

Example 9 with IMachineRecipe

use of crazypants.enderio.base.recipe.IMachineRecipe in project EnderIO by SleepyTrousers.

the class TileAlloySmelter method canStartNextTask.

@Override
protected IMachineRecipe canStartNextTask(long nextSeed) {
    if (getMode() == Mode.FURNACE) {
        VanillaSmeltingRecipe vr = AlloyRecipeManager.getInstance().getVanillaRecipe();
        if (vr.isRecipe(getRecipeInputs())) {
            final IPoweredTask task = createTask(vr, nextSeed);
            if (task == null) {
                return null;
            }
            IMachineRecipe.ResultStack[] res = task.getCompletedResult();
            if (res.length == 0) {
                return null;
            }
            return canInsertResult(nextSeed, vr) ? vr : null;
        }
        return null;
    }
    IMachineRecipe nextRecipe = getNextRecipe();
    if (getMode() == Mode.ALLOY && nextRecipe instanceof VanillaSmeltingRecipe) {
        nextRecipe = null;
    }
    if (nextRecipe == null) {
        // no template
        return null;
    }
    // make sure we have room for the next output
    return canInsertResult(nextSeed, nextRecipe) ? nextRecipe : null;
}
Also used : IPoweredTask(crazypants.enderio.base.machine.interfaces.IPoweredTask) VanillaSmeltingRecipe(crazypants.enderio.base.recipe.alloysmelter.VanillaSmeltingRecipe) IMachineRecipe(crazypants.enderio.base.recipe.IMachineRecipe)

Aggregations

IMachineRecipe (crazypants.enderio.base.recipe.IMachineRecipe)9 ItemStack (net.minecraft.item.ItemStack)4 NNList (com.enderio.core.common.util.NNList)2 IPoweredTask (crazypants.enderio.base.machine.interfaces.IPoweredTask)2 MachineRecipeInput (crazypants.enderio.base.recipe.MachineRecipeInput)2 AbstractPainterTemplate (crazypants.enderio.base.recipe.painter.AbstractPainterTemplate)2 ResultStack (crazypants.enderio.base.recipe.IMachineRecipe.ResultStack)1 VanillaSmeltingRecipe (crazypants.enderio.base.recipe.alloysmelter.VanillaSmeltingRecipe)1 ISoulBinderRecipe (crazypants.enderio.base.recipe.soul.ISoulBinderRecipe)1 ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 NBTTagList (net.minecraft.nbt.NBTTagList)1