Search in sources :

Example 1 with RecipeWrapper

use of net.minecraftforge.items.wrapper.RecipeWrapper in project createaddition by mrh0.

the class RollingMillTileEntity method process.

private void process() {
    RecipeWrapper inventoryIn = new RecipeWrapper(inputInv);
    if (lastRecipe == null || !lastRecipe.matches(inventoryIn, level)) {
        Optional<RollingRecipe> recipe = find(inventoryIn, level);
        if (!recipe.isPresent())
            return;
        lastRecipe = recipe.get();
    }
    ItemStack result = lastRecipe.assemble(inventoryIn).copy();
    ItemHandlerHelper.insertItemStacked(outputInv, result, false);
    ItemStack stackInSlot = inputInv.getStackInSlot(0);
    stackInSlot.shrink(1);
    inputInv.setStackInSlot(0, stackInSlot);
    sendData();
    setChanged();
}
Also used : RollingRecipe(com.mrh0.createaddition.recipe.rolling.RollingRecipe) ItemStack(net.minecraft.world.item.ItemStack) RecipeWrapper(net.minecraftforge.items.wrapper.RecipeWrapper)

Example 2 with RecipeWrapper

use of net.minecraftforge.items.wrapper.RecipeWrapper in project createaddition by mrh0.

the class RollingMillTileEntity method tick.

@Override
public void tick() {
    super.tick();
    if (getSpeed() == 0)
        return;
    for (int i = 0; i < outputInv.getSlots(); i++) if (outputInv.getStackInSlot(i).getCount() == outputInv.getSlotLimit(i))
        return;
    if (timer > 0) {
        timer -= getProcessingSpeed();
        if (level.isClientSide) {
            spawnParticles();
            return;
        }
        if (timer <= 0)
            process();
        return;
    }
    if (inputInv.getStackInSlot(0).isEmpty())
        return;
    RecipeWrapper inventoryIn = new RecipeWrapper(inputInv);
    if (lastRecipe == null || !lastRecipe.matches(inventoryIn, level)) {
        Optional<RollingRecipe> recipe = find(inventoryIn, level);
        if (!recipe.isPresent()) {
            timer = 100;
            sendData();
        } else {
            lastRecipe = recipe.get();
            timer = getProcessingDuration();
            sendData();
        }
        return;
    }
    timer = getProcessingDuration();
    sendData();
}
Also used : RollingRecipe(com.mrh0.createaddition.recipe.rolling.RollingRecipe) RecipeWrapper(net.minecraftforge.items.wrapper.RecipeWrapper)

Example 3 with RecipeWrapper

use of net.minecraftforge.items.wrapper.RecipeWrapper in project Create by Creators-of-Create.

the class MillstoneTileEntity method canProcess.

private boolean canProcess(ItemStack stack) {
    ItemStackHandler tester = new ItemStackHandler(1);
    tester.setStackInSlot(0, stack);
    RecipeWrapper inventoryIn = new RecipeWrapper(tester);
    if (lastRecipe != null && lastRecipe.matches(inventoryIn, level))
        return true;
    return AllRecipeTypes.MILLING.find(inventoryIn, level).isPresent();
}
Also used : ItemStackHandler(net.minecraftforge.items.ItemStackHandler) RecipeWrapper(net.minecraftforge.items.wrapper.RecipeWrapper)

Example 4 with RecipeWrapper

use of net.minecraftforge.items.wrapper.RecipeWrapper in project createaddition by mrh0.

the class RollingMillTileEntity method canProcess.

private boolean canProcess(ItemStack stack) {
    ItemStackHandler tester = new ItemStackHandler(1);
    tester.setStackInSlot(0, stack);
    RecipeWrapper inventoryIn = new RecipeWrapper(tester);
    if (lastRecipe != null && lastRecipe.matches(inventoryIn, level))
        return true;
    return find(inventoryIn, level).isPresent();
}
Also used : ItemStackHandler(net.minecraftforge.items.ItemStackHandler) RecipeWrapper(net.minecraftforge.items.wrapper.RecipeWrapper)

Example 5 with RecipeWrapper

use of net.minecraftforge.items.wrapper.RecipeWrapper in project Create by Creators-of-Create.

the class MillstoneTileEntity method tick.

@Override
public void tick() {
    super.tick();
    if (getSpeed() == 0)
        return;
    for (int i = 0; i < outputInv.getSlots(); i++) if (outputInv.getStackInSlot(i).getCount() == outputInv.getSlotLimit(i))
        return;
    if (timer > 0) {
        timer -= getProcessingSpeed();
        if (level.isClientSide) {
            spawnParticles();
            return;
        }
        if (timer <= 0)
            process();
        return;
    }
    if (inputInv.getStackInSlot(0).isEmpty())
        return;
    RecipeWrapper inventoryIn = new RecipeWrapper(inputInv);
    if (lastRecipe == null || !lastRecipe.matches(inventoryIn, level)) {
        Optional<MillingRecipe> recipe = AllRecipeTypes.MILLING.find(inventoryIn, level);
        if (!recipe.isPresent()) {
            timer = 100;
            sendData();
        } else {
            lastRecipe = recipe.get();
            timer = lastRecipe.getProcessingDuration();
            sendData();
        }
        return;
    }
    timer = lastRecipe.getProcessingDuration();
    sendData();
}
Also used : RecipeWrapper(net.minecraftforge.items.wrapper.RecipeWrapper)

Aggregations

RecipeWrapper (net.minecraftforge.items.wrapper.RecipeWrapper)8 ItemStack (net.minecraft.world.item.ItemStack)3 ItemStackHandler (net.minecraftforge.items.ItemStackHandler)3 RollingRecipe (com.mrh0.createaddition.recipe.rolling.RollingRecipe)2 FluidIngredient (com.simibubi.create.foundation.fluid.FluidIngredient)2 AllRecipeTypes (com.simibubi.create.AllRecipeTypes)1 SequencedAssemblyRecipe (com.simibubi.create.content.contraptions.itemAssembly.SequencedAssemblyRecipe)1 List (java.util.List)1 Optional (java.util.Optional)1 Recipe (net.minecraft.world.item.crafting.Recipe)1 Level (net.minecraft.world.level.Level)1 FluidStack (net.minecraftforge.fluids.FluidStack)1