use of com.infinityraider.agricraft.api.v1.soil.IAgriSoil in project AgriCraft by AgriCraft.
the class AgriClocheRecipe method getTime.
@Override
public int getTime(ItemStack seed, ItemStack soilStack) {
IAgriPlant plant = this.getPlant(seed);
IAgriSoil soil = this.getSoil(soilStack);
Optional<IAgriStatsMap> statsOptional = this.getStats(seed);
if (plant.isPlant() && soil.isSoil() && statsOptional.isPresent()) {
IAgriStatsMap stats = statsOptional.get();
IAgriGrowthRequirement req = plant.getGrowthRequirement(plant.getInitialGrowthStage());
int strength = stats.getStrength();
if (!req.getSoilHumidityResponse(soil.getHumidity(), strength).isFertile()) {
return Integer.MAX_VALUE;
}
if (!req.getSoilAcidityResponse(soil.getAcidity(), strength).isFertile()) {
return Integer.MAX_VALUE;
}
if (!req.getSoilNutrientsResponse(soil.getNutrients(), strength).isFertile()) {
return Integer.MAX_VALUE;
}
double growthFactor = 1 - stats.getGrowth() * this.getGrowthStatFactor();
double soilFactor = 2 - soil.getGrowthModifier();
return Math.max((int) (this.getGrowthTicks() * growthFactor * soilFactor), 1);
}
return Integer.MAX_VALUE;
}
use of com.infinityraider.agricraft.api.v1.soil.IAgriSoil in project AgriCraft by AgriCraft.
the class DebugModeCheckSoil method debugActionBlockClicked.
@Override
public void debugActionBlockClicked(ItemStack stack, ItemUseContext context) {
IAgriSoil soil = AgriApi.getSoilRegistry().stream().filter(s -> s.isVariant(context.getWorld().getBlockState(context.getPos()))).findFirst().orElse(null);
MessageUtil.messagePlayer(context.getPlayer(), "{0} Soil Info:", AgriCraft.instance.proxy().getLogicalSide());
if (soil == null) {
MessageUtil.messagePlayer(context.getPlayer(), " - Type: \"{0}\"", "Unknown Soil");
} else {
MessageUtil.messagePlayer(context.getPlayer(), " - Type: \"{0}\"", soil.getId());
MessageUtil.messagePlayer(context.getPlayer(), " - Humidity: \"{0}\"", soil.getHumidity());
MessageUtil.messagePlayer(context.getPlayer(), " - Acidity: \"{0}\"", soil.getAcidity());
MessageUtil.messagePlayer(context.getPlayer(), " - Nutrients: \"{0}\"", soil.getNutrients());
}
}
Aggregations