Search in sources :

Example 1 with EnumFertiliserType

use of binnie.botany.api.gardening.EnumFertiliserType in project Binnie by ForestryMC.

the class ModuleGardening method addFertiliserRecipes.

private void addFertiliserRecipes(RecipeUtil recipeUtil) {
    IGardeningManager gardening = BotanyCore.getGardening();
    for (EnumMoisture moisture : EnumMoisture.values()) {
        for (EnumAcidity acidity : EnumAcidity.values()) {
            int pH = acidity.ordinal();
            for (EnumSoilType type : EnumSoilType.values()) {
                Map<EnumFertiliserType, Map<ItemStack, Integer>> fertilisers = gardening.getFertilisers();
                for (EnumFertiliserType fertiliserType : EnumFertiliserType.values()) {
                    for (Map.Entry<ItemStack, Integer> entry : fertilisers.get(fertiliserType).entrySet()) {
                        ItemStack stack = entry.getKey();
                        int strengthMax = entry.getValue();
                        for (boolean weedkiller : new boolean[] { false, true }) {
                            int numOfBlocks = strengthMax * strengthMax;
                            for (int strength = 1; strength < strengthMax; ++strength) {
                                int endPh;
                                if (fertiliserType == EnumFertiliserType.ACID) {
                                    endPh = pH - strength;
                                } else if (fertiliserType == EnumFertiliserType.ALKALINE) {
                                    endPh = pH + strength;
                                } else {
                                    endPh = type.ordinal() + strength;
                                }
                                if (endPh < 0 || endPh > 2 || pH == endPh) {
                                    continue;
                                }
                                ItemStack start = getStack(type, acidity, moisture, weedkiller);
                                ItemStack end = getStack(type, EnumAcidity.values()[endPh], moisture, weedkiller);
                                if (!start.isEmpty() && !end.isEmpty()) {
                                    end.setCount(numOfBlocks);
                                    Object[] stacks = new Object[numOfBlocks + 1];
                                    for (int i = 0; i < numOfBlocks; ++i) {
                                        stacks[i] = start;
                                    }
                                    stacks[numOfBlocks] = stack.copy();
                                    String recipeName = fertiliserType.name().toLowerCase(Locale.ENGLISH) + "_fertiliser_moisture" + moisture + "_ph" + pH + "_type" + type + "_strength" + strength;
                                    recipeUtil.addShapelessRecipe(recipeName, end, stacks);
                                }
                                numOfBlocks /= 2;
                            }
                        }
                    }
                }
                ItemStack start = getStack(type, acidity, moisture, false);
                ItemStack end = getStack(type, acidity, moisture, true);
                String recipeName = "weedkiller_moisture" + moisture + "_ph" + pH + "_type" + type;
                recipeUtil.addShapelessRecipe(recipeName, end, start, start, start, start, "weedkiller");
            }
        }
    }
}
Also used : EnumMoisture(binnie.botany.api.gardening.EnumMoisture) EnumAcidity(binnie.botany.api.gardening.EnumAcidity) EnumSoilType(binnie.botany.api.gardening.EnumSoilType) EnumFertiliserType(binnie.botany.api.gardening.EnumFertiliserType) ItemStack(net.minecraft.item.ItemStack) Map(java.util.Map) IGardeningManager(binnie.botany.api.gardening.IGardeningManager)

Aggregations

EnumAcidity (binnie.botany.api.gardening.EnumAcidity)1 EnumFertiliserType (binnie.botany.api.gardening.EnumFertiliserType)1 EnumMoisture (binnie.botany.api.gardening.EnumMoisture)1 EnumSoilType (binnie.botany.api.gardening.EnumSoilType)1 IGardeningManager (binnie.botany.api.gardening.IGardeningManager)1 Map (java.util.Map)1 ItemStack (net.minecraft.item.ItemStack)1