Search in sources :

Example 6 with EnumAcidity

use of binnie.botany.api.gardening.EnumAcidity 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)

Example 7 with EnumAcidity

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

the class GardeningManager method canTolerate.

@Override
public boolean canTolerate(@Nullable IFlower flower, World world, BlockPos pos) {
    if (flower == null) {
        return false;
    }
    IBlockState soil = world.getBlockState(pos.down());
    Biome biome = world.getBiome(pos);
    EnumAcidity acidity = soil.getValue(BlockSoil.ACIDITY);
    EnumMoisture moisture = soil.getValue(BlockSoil.MOISTURE);
    EnumTemperature temperature = EnumTemperature.getFromValue(biome.getTemperature());
    return canTolerate(flower, acidity, moisture, temperature);
}
Also used : EnumMoisture(binnie.botany.api.gardening.EnumMoisture) IBlockState(net.minecraft.block.state.IBlockState) Biome(net.minecraft.world.biome.Biome) EnumAcidity(binnie.botany.api.gardening.EnumAcidity) EnumTemperature(forestry.api.core.EnumTemperature)

Example 8 with EnumAcidity

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

the class BlockSoil method registerModel.

@Override
@SideOnly(Side.CLIENT)
public void registerModel(Item item, IModelManager manager) {
    for (EnumAcidity acidity : EnumAcidity.values()) {
        for (EnumMoisture moisture : EnumMoisture.values()) {
            String modelName = "";
            if (acidity != EnumAcidity.NEUTRAL) {
                modelName += acidity.getName();
            }
            if (moisture != EnumMoisture.NORMAL) {
                if (!modelName.isEmpty()) {
                    modelName += "_";
                }
                modelName += moisture.getName();
            }
            if (modelName.isEmpty()) {
                modelName = "normal";
            }
            String identifier;
            if (weedKilled) {
                identifier = type.getName() + "_no_weed/" + modelName;
            } else {
                identifier = type.getName() + '/' + modelName;
            }
            manager.registerItemModel(item, moisture.ordinal() + acidity.ordinal() * 3, identifier);
        }
    }
}
Also used : EnumMoisture(binnie.botany.api.gardening.EnumMoisture) EnumAcidity(binnie.botany.api.gardening.EnumAcidity) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 9 with EnumAcidity

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

the class BlockSoil method getPH.

public static String getPH(ItemStack stack, boolean withColor, boolean byNeutralNone) {
    int index = stack.getItemDamage() / 3;
    index = (index < EnumAcidity.values().length) ? index : EnumAcidity.values().length - 1;
    EnumAcidity ph = EnumAcidity.values()[index];
    if (byNeutralNone) {
        if (ph == EnumAcidity.NEUTRAL) {
            return "";
        }
    }
    return TextFormatting.GRAY + I18N.localise("botany.ph") + ": " + EnumHelper.getLocalisedName(ph, withColor);
}
Also used : EnumAcidity(binnie.botany.api.gardening.EnumAcidity)

Aggregations

EnumAcidity (binnie.botany.api.gardening.EnumAcidity)9 EnumMoisture (binnie.botany.api.gardening.EnumMoisture)6 ItemStack (net.minecraft.item.ItemStack)4 IGardeningManager (binnie.botany.api.gardening.IGardeningManager)3 EnumSoilType (binnie.botany.api.gardening.EnumSoilType)2 Block (net.minecraft.block.Block)2 IBlockState (net.minecraft.block.state.IBlockState)2 EnumFertiliserType (binnie.botany.api.gardening.EnumFertiliserType)1 IBlockSoil (binnie.botany.api.gardening.IBlockSoil)1 EnumTemperature (forestry.api.core.EnumTemperature)1 FarmDirection (forestry.api.farming.FarmDirection)1 Map (java.util.Map)1 ItemBlock (net.minecraft.item.ItemBlock)1 BlockPos (net.minecraft.util.math.BlockPos)1 Biome (net.minecraft.world.biome.Biome)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1