Search in sources :

Example 1 with OrichalcumBlasterRecipe

use of net.kaupenjoe.mccourse.recipe.OrichalcumBlasterRecipe in project Fabric-Course-118 by Kaupenjoe.

the class OrichalcumBlasterEntity method hasRecipe.

private static boolean hasRecipe(OrichalcumBlasterEntity entity) {
    World world = entity.world;
    SimpleInventory inventory = new SimpleInventory(entity.inventory.size());
    for (int i = 0; i < entity.inventory.size(); i++) {
        inventory.setStack(i, entity.getStack(i));
    }
    Optional<OrichalcumBlasterRecipe> match = world.getRecipeManager().getFirstMatch(OrichalcumBlasterRecipe.Type.INSTANCE, inventory, world);
    return match.isPresent() && canInsertAmountIntoOutputSlot(inventory) && canInsertItemIntoOutputSlot(inventory, match.get().getOutput());
}
Also used : OrichalcumBlasterRecipe(net.kaupenjoe.mccourse.recipe.OrichalcumBlasterRecipe) World(net.minecraft.world.World) SimpleInventory(net.minecraft.inventory.SimpleInventory)

Example 2 with OrichalcumBlasterRecipe

use of net.kaupenjoe.mccourse.recipe.OrichalcumBlasterRecipe in project Fabric-Course-118 by Kaupenjoe.

the class OrichalcumBlasterEntity method craftItem.

private static void craftItem(OrichalcumBlasterEntity entity) {
    World world = entity.world;
    SimpleInventory inventory = new SimpleInventory(entity.inventory.size());
    for (int i = 0; i < entity.inventory.size(); i++) {
        inventory.setStack(i, entity.getStack(i));
    }
    Optional<OrichalcumBlasterRecipe> match = world.getRecipeManager().getFirstMatch(OrichalcumBlasterRecipe.Type.INSTANCE, inventory, world);
    if (match.isPresent()) {
        entity.removeStack(1, 1);
        entity.removeStack(2, 1);
        entity.setStack(3, new ItemStack(match.get().getOutput().getItem(), entity.getStack(3).getCount() + 1));
        entity.resetProgress();
    }
}
Also used : OrichalcumBlasterRecipe(net.kaupenjoe.mccourse.recipe.OrichalcumBlasterRecipe) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) SimpleInventory(net.minecraft.inventory.SimpleInventory)

Aggregations

OrichalcumBlasterRecipe (net.kaupenjoe.mccourse.recipe.OrichalcumBlasterRecipe)2 SimpleInventory (net.minecraft.inventory.SimpleInventory)2 World (net.minecraft.world.World)2 ItemStack (net.minecraft.item.ItemStack)1