Search in sources :

Example 1 with RecipeBuilder

use of gregtech.api.recipes.RecipeBuilder in project GregTech by GregTechCE.

the class ProcessingDecomposition method registerOre.

// @Override
public void registerOre(UnificationEntry entry, String modName, SimpleItemStack itemStack) {
    if (entry.material instanceof FluidMaterial) {
        FluidMaterial material = (FluidMaterial) entry.material;
        if (!material.materialComponents.isEmpty() && (material.hasFlag(Material.MatFlags.DECOMPOSITION_BY_ELECTROLYZING) || material.hasFlag(Material.MatFlags.DECOMPOSITION_BY_CENTRIFUGING))) {
            // compute outputs
            ArrayList<ItemStack> outputs = new ArrayList<>();
            ArrayList<FluidStack> fluidOutputs = new ArrayList<>();
            int totalInputAmount = 0;
            for (MaterialStack component : material.materialComponents) {
                totalInputAmount += component.amount;
                if (component.material instanceof DustMaterial) {
                    outputs.add(OreDictUnifier.get(OrePrefix.dust, component.material, (int) component.amount));
                } else if (component.material instanceof FluidMaterial) {
                    FluidMaterial componentMaterial = (FluidMaterial) component.material;
                    fluidOutputs.add(componentMaterial.getFluid((int) (GTValues.L * component.amount)));
                }
            }
            // generate builder
            RecipeBuilder builder;
            if (material.hasFlag(Material.MatFlags.DECOMPOSITION_BY_ELECTROLYZING)) {
                builder = RecipeMap.ELECTROLYZER_RECIPES.recipeBuilder().duration((int) material.getProtons() * totalInputAmount * 8).EUt(Math.min(4, material.materialComponents.size()) * 30);
            } else {
                builder = RecipeMap.CENTRIFUGE_RECIPES.recipeBuilder().duration((int) material.getMass() * totalInputAmount * 2).EUt(30);
            }
            builder.outputs(outputs);
            builder.fluidOutputs(fluidOutputs);
            // finish builder
            if (entry.orePrefix == OrePrefix.dust) {
                builder.inputs(itemStack.asItemStack(totalInputAmount));
            } else {
                builder.fluidInputs(material.getFluid(GTValues.L * totalInputAmount));
            }
            // register recipe
            builder.buildAndRegister();
        }
    }
}
Also used : FluidMaterial(gregtech.api.unification.material.type.FluidMaterial) FluidStack(net.minecraftforge.fluids.FluidStack) MaterialStack(gregtech.api.unification.stack.MaterialStack) ArrayList(java.util.ArrayList) DustMaterial(gregtech.api.unification.material.type.DustMaterial) SimpleItemStack(gregtech.api.unification.stack.SimpleItemStack) ItemStack(net.minecraft.item.ItemStack) RecipeBuilder(gregtech.api.recipes.RecipeBuilder)

Example 2 with RecipeBuilder

use of gregtech.api.recipes.RecipeBuilder in project GregTech by GregTechCE.

the class ProcessingDirtyDust method registerOre.

// @Override
public void registerOre(UnificationEntry entry, String modName, SimpleItemStack itemStack) {
    if (entry.material instanceof DustMaterial) {
        DustMaterial material = (DustMaterial) entry.material;
        ItemStack stack = itemStack.asItemStack();
        ItemStack dustStack = OreDictUnifier.get(OrePrefix.dust, material);
        if (entry.orePrefix == OrePrefix.dustPure && material.separatedOnto != null) {
            ItemStack separatedStack = OreDictUnifier.get(OrePrefix.dustSmall, material.separatedOnto);
            RecipeMap.ELECTROMAGNETIC_SEPARATOR_RECIPES.recipeBuilder().inputs(stack).outputs(dustStack).chancedOutput(separatedStack, 4000).duration((int) material.separatedOnto.getMass()).EUt(24).buildAndRegister();
        }
        int byProductIndex;
        if (entry.orePrefix == OrePrefix.dustRefined) {
            byProductIndex = 2;
        } else if (entry.orePrefix == OrePrefix.dustPure) {
            byProductIndex = 1;
        } else
            byProductIndex = 0;
        FluidMaterial byproduct = GTUtility.selectItemInList(byProductIndex, material, material.oreByProducts, FluidMaterial.class);
        RecipeBuilder builder = RecipeMap.CENTRIFUGE_RECIPES.recipeBuilder().inputs(stack).outputs(dustStack).duration((int) (material.getMass() * 4)).EUt(24);
        if (byproduct instanceof DustMaterial) {
            builder.outputs(OreDictUnifier.get(OrePrefix.dustTiny, byproduct));
        } else {
            builder.fluidOutputs(byproduct.getFluid(GTValues.L / 9));
        }
        builder.buildAndRegister();
    }
}
Also used : FluidMaterial(gregtech.api.unification.material.type.FluidMaterial) DustMaterial(gregtech.api.unification.material.type.DustMaterial) SimpleItemStack(gregtech.api.unification.stack.SimpleItemStack) ItemStack(net.minecraft.item.ItemStack) RecipeBuilder(gregtech.api.recipes.RecipeBuilder)

Aggregations

RecipeBuilder (gregtech.api.recipes.RecipeBuilder)2 DustMaterial (gregtech.api.unification.material.type.DustMaterial)2 FluidMaterial (gregtech.api.unification.material.type.FluidMaterial)2 SimpleItemStack (gregtech.api.unification.stack.SimpleItemStack)2 ItemStack (net.minecraft.item.ItemStack)2 MaterialStack (gregtech.api.unification.stack.MaterialStack)1 ArrayList (java.util.ArrayList)1 FluidStack (net.minecraftforge.fluids.FluidStack)1