Search in sources :

Example 6 with IAgriSoil

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;
}
Also used : IAgriPlant(com.infinityraider.agricraft.api.v1.plant.IAgriPlant) IAgriGrowthRequirement(com.infinityraider.agricraft.api.v1.requirement.IAgriGrowthRequirement) IAgriStatsMap(com.infinityraider.agricraft.api.v1.stat.IAgriStatsMap) IAgriSoil(com.infinityraider.agricraft.api.v1.requirement.IAgriSoil)

Example 7 with IAgriSoil

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());
    }
}
Also used : IAgriSoil(com.infinityraider.agricraft.api.v1.requirement.IAgriSoil)

Aggregations

IAgriSoil (com.infinityraider.agricraft.api.v1.requirement.IAgriSoil)4 IAgriPlant (com.infinityraider.agricraft.api.v1.plant.IAgriPlant)2 IAgriGrowthRequirement (com.infinityraider.agricraft.api.v1.requirement.IAgriGrowthRequirement)2 AgriSoil (com.agricraft.agricore.plant.AgriSoil)1 ImmutableList (com.google.common.collect.ImmutableList)1 IAgriGrowthStage (com.infinityraider.agricraft.api.v1.crop.IAgriGrowthStage)1 IAgriSoil (com.infinityraider.agricraft.api.v1.soil.IAgriSoil)1 IAgriStat (com.infinityraider.agricraft.api.v1.stat.IAgriStat)1 IAgriStatsMap (com.infinityraider.agricraft.api.v1.stat.IAgriStatsMap)1 AbstractBlock (net.minecraft.block.AbstractBlock)1 ItemStack (net.minecraft.item.ItemStack)1