use of binnie.botany.api.gardening.EnumSoilType in project Binnie by ForestryMC.
the class GardeningManager method addWeedKiller.
@Override
public boolean addWeedKiller(World world, BlockPos pos) {
IBlockState oldState = world.getBlockState(pos);
if (!(oldState.getBlock() instanceof IBlockSoil)) {
return false;
}
EnumSoilType type = getSoilType(world, pos);
IBlockState newState = getSoil(type, true, oldState.getValue(BlockSoil.MOISTURE), oldState.getValue(BlockSoil.ACIDITY));
boolean done = world.setBlockState(pos, newState, 2);
if (done && BlockPlant.isWeed(world, pos.up())) {
world.setBlockToAir(pos.up());
}
return done;
}
use of binnie.botany.api.gardening.EnumSoilType in project Binnie by ForestryMC.
the class GardeningManager method onFertiliseSoil.
@Override
public boolean onFertiliseSoil(ItemStack heldItem, IBlockSoil soil, World world, BlockPos pos, EntityPlayer player) {
int fertiliserStrength = getFertiliserStrength(heldItem);
if (isFertiliser(EnumFertiliserType.NUTRIENT, heldItem) && soil.getType(world, pos) != EnumSoilType.FLOWERBED) {
EnumSoilType type = soil.getType(world, pos);
int next = Math.min(type.ordinal() + fertiliserStrength, 2);
if (soil.fertilise(world, pos, EnumSoilType.values()[next])) {
if (!player.capabilities.isCreativeMode) {
heldItem.shrink(1);
}
return true;
}
}
if (isFertiliser(EnumFertiliserType.ACID, heldItem) && soil.getPH(world, pos) != EnumAcidity.ACID) {
EnumAcidity pH = soil.getPH(world, pos);
int next = Math.max(pH.ordinal() - fertiliserStrength, 0);
if (soil.setPH(world, pos, EnumAcidity.values()[next])) {
if (!player.capabilities.isCreativeMode) {
heldItem.shrink(1);
}
return true;
}
}
if (isFertiliser(EnumFertiliserType.ALKALINE, heldItem) && soil.getPH(world, pos) != EnumAcidity.ALKALINE) {
EnumAcidity pH = soil.getPH(world, pos);
int next = Math.min(pH.ordinal() + fertiliserStrength, 2);
if (soil.setPH(world, pos, EnumAcidity.values()[next])) {
if (!player.capabilities.isCreativeMode) {
heldItem.shrink(1);
}
return true;
}
}
return false;
}
use of binnie.botany.api.gardening.EnumSoilType in project Binnie by ForestryMC.
the class TileEntityFlower method randomUpdate.
public void randomUpdate(Random rand) {
if (world.getBlockState(pos).getBlock() != ModuleFlowers.flower) {
invalidate();
return;
}
if (getSection() > 0) {
return;
}
if (flower == null) {
return;
}
if (!isBreeding()) {
return;
}
if (updateState(rand)) {
return;
}
IGardeningManager gardening = BotanyCore.getGardening();
EnumSoilType soil = gardening.getSoilType(world, pos.down());
float chanceDispersal = 0.8f;
chanceDispersal += 0.2f * flower.getGenome().getFertility();
chanceDispersal *= 1.0f + soil.ordinal() * 0.5f;
float chancePollinate = 1.0f;
chancePollinate += 0.25f * flower.getGenome().getFertility();
chancePollinate *= 1.0f + soil.ordinal() * 0.5f;
float chanceSelfPollinate = 0.2f * chancePollinate;
plantOffspring(rand, chanceDispersal);
mateFlower(rand, chancePollinate, chanceSelfPollinate);
spawnButterflies();
matureCaterpillar();
checkIfDead(false);
updateRender(true);
}
use of binnie.botany.api.gardening.EnumSoilType 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.EnumSoilType in project Binnie by ForestryMC.
the class BlockSoil method fertilise.
@Override
public boolean fertilise(World world, BlockPos pos, EnumSoilType maxLevel) {
EnumSoilType type = getType(world, pos);
if (type.ordinal() >= maxLevel.ordinal()) {
return false;
}
IBlockState old = world.getBlockState(pos);
IBlockState newState = BotanyCore.getGardening().getSoil(maxLevel, weedKilled, old.getValue(MOISTURE), old.getValue(ACIDITY));
return world.setBlockState(pos, newState, 2);
}
Aggregations