Search in sources :

Example 6 with MachineRecipeInput

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

the class VatMachineRecipe method getQuantitiesConsumed.

@Override
@Nonnull
public NNList<MachineRecipeInput> getQuantitiesConsumed(@Nonnull NNList<MachineRecipeInput> inputs) {
    NNList<MachineRecipeInput> result = new NNList<MachineRecipeInput>();
    VatRecipe rec = (VatRecipe) getRecipeForInputs(inputs);
    FluidStack inputFluidStack = rec.getRequiredFluidInput(inputs);
    result.add(new MachineRecipeInput(0, inputFluidStack));
    for (MachineRecipeInput ri : inputs) {
        if (!ri.isFluid() && Prep.isValid(ri.item)) {
            ItemStack st = ri.item.copy();
            st.setCount(rec.getNumConsumed(ri.item));
            result.add(new MachineRecipeInput(ri.slotNumber, st));
        }
    }
    return result;
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) NNList(com.enderio.core.common.util.NNList) MachineRecipeInput(crazypants.enderio.base.recipe.MachineRecipeInput) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Example 7 with MachineRecipeInput

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

the class AbstractSoulBinderRecipe method getCompletedResult.

@Override
@Nonnull
public ResultStack[] getCompletedResult(long nextSeed, float chanceMultiplier, @Nonnull NNList<MachineRecipeInput> inputs) {
    CapturedMob mobType = null;
    ItemStack inputItem = null;
    for (MachineRecipeInput input : inputs) {
        if (input != null && input.slotNumber == 0 && CapturedMob.containsSoul(input.item)) {
            mobType = CapturedMob.create(input.item);
        } else if (input != null && input.slotNumber == 1 && isValidInputItem(input.item)) {
            inputItem = input.item;
        }
    }
    if (mobType == null || !isValidInputSoul(mobType) || inputItem == null) {
        return new ResultStack[0];
    }
    ItemStack resultStack = getOutputStack(inputItem, mobType);
    ItemStack soulVessel = new ItemStack(itemSoulVial.getItemNN());
    return new ResultStack[] { new ResultStack(soulVessel), new ResultStack(resultStack) };
}
Also used : CapturedMob(crazypants.enderio.util.CapturedMob) MachineRecipeInput(crazypants.enderio.base.recipe.MachineRecipeInput) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Example 8 with MachineRecipeInput

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

the class AbstractSoulBinderRecipe method getQuantitiesConsumed.

@Override
@Nonnull
public List<MachineRecipeInput> getQuantitiesConsumed(@Nonnull NNList<MachineRecipeInput> inputs) {
    List<MachineRecipeInput> result = new ArrayList<MachineRecipeInput>(inputs.size());
    for (MachineRecipeInput input : inputs) {
        if (input != null && Prep.isValid(input.item)) {
            ItemStack resStack = input.item.copy();
            resStack.setCount(1);
            MachineRecipeInput mri = new MachineRecipeInput(input.slotNumber, resStack);
            result.add(mri);
        }
    }
    return result;
}
Also used : MachineRecipeInput(crazypants.enderio.base.recipe.MachineRecipeInput) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Example 9 with MachineRecipeInput

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

the class TileSoulBinder method isMachineItemValidForSlot.

@Override
public boolean isMachineItemValidForSlot(int slot, @Nonnull ItemStack item) {
    if (!slotDefinition.isInputSlot(slot)) {
        return false;
    }
    MachineRecipeInput newInput = new MachineRecipeInput(slot, item);
    int otherSlot = slot == 0 ? 1 : 0;
    if (Prep.isInvalid(getStackInSlot(otherSlot))) {
        List<IMachineRecipe> recipes = MachineRecipeRegistry.instance.getRecipesForInput(getMachineName(), newInput);
        if (recipes.isEmpty()) {
            return false;
        }
        for (IMachineRecipe rec : recipes) {
            if (rec != null && rec.isValidInput(newInput)) {
                return true;
            }
        }
    } else {
        NNList<MachineRecipeInput> inputs = new NNList<>(newInput, new MachineRecipeInput(otherSlot, getStackInSlot(otherSlot)));
        return MachineRecipeRegistry.instance.getRecipeForInputs(getMachineName(), inputs) != null;
    }
    return false;
}
Also used : NNList(com.enderio.core.common.util.NNList) MachineRecipeInput(crazypants.enderio.base.recipe.MachineRecipeInput) IMachineRecipe(crazypants.enderio.base.recipe.IMachineRecipe)

Example 10 with MachineRecipeInput

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

the class ContainerEnchanter method addSlots.

@Override
protected void addSlots(@Nonnull InventoryPlayer playerInv) {
    final TileEnchanter te = getInv();
    addSlotToContainer(new Slot(te, 0, 16, 35) {

        @Override
        public int getSlotStackLimit() {
            return 1;
        }

        @Override
        public boolean isItemValid(@Nonnull ItemStack itemStack) {
            return te.isItemValidForSlot(0, itemStack);
        }

        @Override
        public void onSlotChanged() {
            updateOutput();
        }
    });
    addSlotToContainer(new Slot(te, 1, 65, 35) {

        @Override
        public boolean isItemValid(@Nonnull ItemStack itemStack) {
            return te.isItemValidForSlot(1, itemStack);
        }

        @Override
        public void onSlotChanged() {
            updateOutput();
        }
    });
    addSlotToContainer(new Slot(te, 2, 85, 35) {

        @Override
        public boolean isItemValid(@Nonnull ItemStack itemStack) {
            return te.isItemValidForSlot(2, itemStack);
        }

        @Override
        public void onSlotChanged() {
            updateOutput();
        }
    });
    addSlotToContainer(new Slot(te, 3, 144, 35) {

        @Override
        public int getSlotStackLimit() {
            return 1;
        }

        @Override
        public boolean isItemValid(@Nullable ItemStack itemStack) {
            return false;
        }

        @Override
        @Nonnull
        public ItemStack onTake(@Nonnull EntityPlayer player, @Nonnull ItemStack stack) {
            EnchanterRecipe currentEnchantmentRecipe = getInv().getCurrentEnchantmentRecipe();
            if (currentEnchantmentRecipe != null) {
                final int xpCost = currentEnchantmentRecipe.getXPCost(getInv().getInvAsMachineRecipeInput());
                List<MachineRecipeInput> quantitiesConsumed = currentEnchantmentRecipe.getQuantitiesConsumed(getInv().getInvAsMachineRecipeInput());
                for (MachineRecipeInput machineRecipeInput : quantitiesConsumed) {
                    te.decrStackSize(machineRecipeInput.slotNumber, machineRecipeInput.item.getCount());
                }
                if (!player.capabilities.isCreativeMode) {
                    player.addExperienceLevel(-xpCost);
                }
            } else {
                Log.error("Enchanting yielded result without resources");
            }
            if (!te.getWorld().isRemote) {
                te.getWorld().playEvent(1030, te.getPos(), 0);
                te.getWorld().playEvent(2005, te.getPos().up(), 0);
            }
            return stack;
        }

        @Override
        public boolean canTakeStack(@Nonnull EntityPlayer player) {
            return playerHasEnoughLevels(player);
        }
    });
}
Also used : EnchanterRecipe(crazypants.enderio.base.recipe.enchanter.EnchanterRecipe) Nonnull(javax.annotation.Nonnull) MachineRecipeInput(crazypants.enderio.base.recipe.MachineRecipeInput) GhostSlot(com.enderio.core.client.gui.widget.GhostSlot) GhostBackgroundItemSlot(com.enderio.core.client.gui.widget.GhostBackgroundItemSlot) Slot(net.minecraft.inventory.Slot) EntityPlayer(net.minecraft.entity.player.EntityPlayer) List(java.util.List) ItemStack(net.minecraft.item.ItemStack)

Aggregations

MachineRecipeInput (crazypants.enderio.base.recipe.MachineRecipeInput)14 ItemStack (net.minecraft.item.ItemStack)9 Nonnull (javax.annotation.Nonnull)8 NNList (com.enderio.core.common.util.NNList)5 IMachineRecipe (crazypants.enderio.base.recipe.IMachineRecipe)2 ArrayList (java.util.ArrayList)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 NBTTagList (net.minecraft.nbt.NBTTagList)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 GhostBackgroundItemSlot (com.enderio.core.client.gui.widget.GhostBackgroundItemSlot)1 GhostSlot (com.enderio.core.client.gui.widget.GhostSlot)1 IPoweredTask (crazypants.enderio.base.machine.interfaces.IPoweredTask)1 EnchanterRecipe (crazypants.enderio.base.recipe.enchanter.EnchanterRecipe)1 CapturedMob (crazypants.enderio.util.CapturedMob)1 List (java.util.List)1 Nullable (javax.annotation.Nullable)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 Slot (net.minecraft.inventory.Slot)1