Search in sources :

Example 1 with DynamicCell

use of techreborn.items.DynamicCell in project TechReborn by TechReborn.

the class DistillationTowerRecipes method register.

static void register(ItemStack input, int ticks, int euPerTick, boolean oreDict, ItemStack... outputs) {
    ItemStack output1;
    ItemStack output2 = null;
    ItemStack output3 = null;
    ItemStack output4 = null;
    if (outputs.length == 3) {
        output1 = outputs[0];
        output2 = outputs[1];
        output3 = outputs[2];
    } else if (outputs.length == 2) {
        output1 = outputs[0];
        output2 = outputs[1];
    } else if (outputs.length == 1) {
        output1 = outputs[0];
    } else if (outputs.length == 4) {
        output1 = outputs[0];
        output2 = outputs[1];
        output3 = outputs[2];
        output4 = outputs[3];
    } else {
        throw new InvalidParameterException("Invalid number of distillation tower outputs: " + outputs);
    }
    int cellCount = 0;
    for (ItemStack stack : outputs) {
        if (stack.getItem() instanceof DynamicCell) {
            cellCount += stack.getCount();
        }
    }
    if (input.getItem() instanceof DynamicCell) {
        int inputCount = input.getCount();
        if (cellCount < inputCount) {
            if (output2 == null) {
                output2 = DynamicCell.getEmptyCell(inputCount - cellCount);
            } else if (output3 == null) {
                output3 = DynamicCell.getEmptyCell(inputCount - cellCount);
            } else if (output4 == null) {
                output4 = DynamicCell.getEmptyCell(inputCount - cellCount);
            }
        }
        cellCount -= inputCount;
    }
    if (cellCount < 0) {
        cellCount = 0;
    }
    ItemStack cells = null;
    if (cellCount > 0) {
        if (cellCount > 64) {
            throw new InvalidParameterException("Invalid distillation tower outputs: " + outputs + "(Recipe requires > 64 cells)");
        }
        cells = DynamicCell.getEmptyCell(cellCount);
    }
    RecipeHandler.addRecipe(new DistillationTowerRecipe(input, cells, output1, output2, output3, output4, ticks, euPerTick, oreDict));
}
Also used : InvalidParameterException(java.security.InvalidParameterException) DistillationTowerRecipe(techreborn.api.recipe.machines.DistillationTowerRecipe) DynamicCell(techreborn.items.DynamicCell) ItemStack(net.minecraft.item.ItemStack)

Example 2 with DynamicCell

use of techreborn.items.DynamicCell in project TechReborn by TechReborn.

the class IndustrialCentrifugeRecipes method register.

static void register(Object input, int ticks, boolean oreDict, ItemStack... outputs) {
    ItemStack output1;
    ItemStack output2 = null;
    ItemStack output3 = null;
    ItemStack output4 = null;
    if (outputs.length == 3) {
        output1 = outputs[0];
        output2 = outputs[1];
        output3 = outputs[2];
    } else if (outputs.length == 2) {
        output1 = outputs[0];
        output2 = outputs[1];
    } else if (outputs.length == 1) {
        output1 = outputs[0];
    } else if (outputs.length == 4) {
        output1 = outputs[0];
        output2 = outputs[1];
        output3 = outputs[2];
        output4 = outputs[3];
    } else {
        throw new InvalidParameterException("Invalid industrial centrifuge outputs: " + outputs);
    }
    int cellCount = 0;
    for (ItemStack stack : outputs) {
        if (stack.getItem() instanceof DynamicCell) {
            cellCount += stack.getCount();
        }
    }
    if (input instanceof ItemStack) {
        if (((ItemStack) input).getItem() instanceof DynamicCell) {
            int inputCount = ((ItemStack) input).getCount();
            if (cellCount < inputCount) {
                if (output2 == null) {
                    output2 = DynamicCell.getEmptyCell(inputCount - cellCount);
                } else if (output3 == null) {
                    output3 = DynamicCell.getEmptyCell(inputCount - cellCount);
                } else if (output4 == null) {
                    output4 = DynamicCell.getEmptyCell(inputCount - cellCount);
                }
            }
            cellCount -= inputCount;
        }
    }
    if (cellCount < 0) {
        cellCount = 0;
    }
    ItemStack cells = null;
    if (cellCount > 0) {
        if (cellCount > 64) {
            throw new InvalidParameterException("Invalid industrial centrifuge outputs: " + outputs + "(Recipe requires > 64 cells)");
        }
        cells = DynamicCell.getEmptyCell(cellCount);
    }
    RecipeHandler.addRecipe(new CentrifugeRecipe(input, cells, output1, output2, output3, output4, ticks, 5, oreDict));
}
Also used : InvalidParameterException(java.security.InvalidParameterException) DynamicCell(techreborn.items.DynamicCell) ItemStack(net.minecraft.item.ItemStack) CentrifugeRecipe(techreborn.api.recipe.machines.CentrifugeRecipe)

Example 3 with DynamicCell

use of techreborn.items.DynamicCell in project TechReborn by TechReborn.

the class IndustrialElectrolyzerRecipes method register.

static void register(ItemStack input, int ticks, int euPerTick, boolean oreDict, ItemStack... outputs) {
    ItemStack output1;
    ItemStack output2 = null;
    ItemStack output3 = null;
    ItemStack output4 = null;
    if (outputs.length == 3) {
        output1 = outputs[0];
        output2 = outputs[1];
        output3 = outputs[2];
    } else if (outputs.length == 2) {
        output1 = outputs[0];
        output2 = outputs[1];
    } else if (outputs.length == 1) {
        output1 = outputs[0];
    } else if (outputs.length == 4) {
        output1 = outputs[0];
        output2 = outputs[1];
        output3 = outputs[2];
        output4 = outputs[3];
    } else {
        throw new InvalidParameterException("Invalid industrial electrolyzer outputs: " + outputs);
    }
    int cellCount = 0;
    for (ItemStack stack : outputs) {
        if (stack.getItem() instanceof DynamicCell) {
            cellCount += stack.getCount();
        }
    }
    if (input.getItem() instanceof DynamicCell) {
        int inputCount = input.getCount();
        if (cellCount < inputCount) {
            if (output2 == null) {
                output2 = DynamicCell.getEmptyCell(inputCount - cellCount);
            } else if (output3 == null) {
                output3 = DynamicCell.getEmptyCell(inputCount - cellCount);
            } else if (output4 == null) {
                output4 = DynamicCell.getEmptyCell(inputCount - cellCount);
            }
        }
        cellCount -= inputCount;
    }
    if (cellCount < 0) {
        cellCount = 0;
    }
    ItemStack cells = null;
    if (cellCount > 0) {
        if (cellCount > 64) {
            throw new InvalidParameterException("Invalid industrial electrolyzer outputs: " + outputs + "(Recipe requires > 64 cells)");
        }
        cells = DynamicCell.getEmptyCell(cellCount);
    }
    RecipeHandler.addRecipe(new IndustrialElectrolyzerRecipe(input, cells, output1, output2, output3, output4, ticks, euPerTick, oreDict));
}
Also used : InvalidParameterException(java.security.InvalidParameterException) DynamicCell(techreborn.items.DynamicCell) ItemStack(net.minecraft.item.ItemStack) IndustrialElectrolyzerRecipe(techreborn.api.recipe.machines.IndustrialElectrolyzerRecipe)

Aggregations

InvalidParameterException (java.security.InvalidParameterException)3 ItemStack (net.minecraft.item.ItemStack)3 DynamicCell (techreborn.items.DynamicCell)3 CentrifugeRecipe (techreborn.api.recipe.machines.CentrifugeRecipe)1 DistillationTowerRecipe (techreborn.api.recipe.machines.DistillationTowerRecipe)1 IndustrialElectrolyzerRecipe (techreborn.api.recipe.machines.IndustrialElectrolyzerRecipe)1