Search in sources :

Example 1 with CompoundingRecipe

use of net.silentchaos512.gear.crafting.recipe.compounder.CompoundingRecipe in project Silent-Gear by SilentChaos512.

the class CompounderTileEntity method tick.

public static <R extends CompoundingRecipe> void tick(Level level, BlockPos pos, BlockState state, CompounderTileEntity<R> blockEntity) {
    if (blockEntity.areInputsEmpty()) {
        // No point in doing anything when input slots are empty
        blockEntity.updateOutputHint(ItemStack.EMPTY);
        return;
    }
    R recipe = blockEntity.getRecipe();
    if (recipe != null) {
        // Inputs match a custom recipe
        blockEntity.doWork(recipe, MaterialList.empty());
    } else {
        // No recipe, but we might be able to make a generic compound
        MaterialList materials = blockEntity.getInputs();
        if (!hasMultipleMaterials(materials) || !blockEntity.canCompoundMaterials(materials)) {
            // Not a valid combination
            blockEntity.stopWork(true);
            return;
        }
        blockEntity.doWork(null, materials);
    }
}
Also used : MaterialList(net.silentchaos512.gear.api.material.MaterialList)

Example 2 with CompoundingRecipe

use of net.silentchaos512.gear.crafting.recipe.compounder.CompoundingRecipe in project Silent-Gear by SilentChaos512.

the class CompoundingRecipe method makeExample.

public static CompoundingRecipe makeExample(CompounderInfo<?> info, int count, CompoundingRecipe recipe) {
    IMaterialCategory[] cats = info.getCategories().toArray(new IMaterialCategory[0]);
    for (int i = 0; i < count; ++i) {
        recipe.ingredients.add(PartMaterialIngredient.of(PartType.MAIN, GearType.ALL, cats));
    }
    recipe.result = new ItemStack(info.getOutputItem(), count);
    return recipe;
}
Also used : IMaterialCategory(net.silentchaos512.gear.api.material.IMaterialCategory) ItemStack(net.minecraft.world.item.ItemStack)

Aggregations

ItemStack (net.minecraft.world.item.ItemStack)1 IMaterialCategory (net.silentchaos512.gear.api.material.IMaterialCategory)1 MaterialList (net.silentchaos512.gear.api.material.MaterialList)1