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");
}
}
}
}
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);
}
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);
}
}
}
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);
}
Aggregations