Search in sources :

Example 1 with IAgriSoil

use of com.infinityraider.agricraft.api.v1.requirement.IAgriSoil in project AgriCraft by AgriCraft.

the class MagnifyingGlassSoilInspector method doInspectionRender.

@Override
public void doInspectionRender(MatrixStack transforms, float partialTick, @Nullable Entity entity) {
    // Check if soil is still valid
    IAgriSoil soil = this.cachedSoil;
    if (soil == null || !soil.isSoil()) {
        return;
    }
    // Push matrix for render, flip y, and apply y offset
    transforms.push();
    transforms.rotate(FLIP_Y);
    transforms.translate(0, DELTA_Y, 0);
    // Draw the soil property icons
    this.drawSoilPropertyIcons(transforms, soil);
    // Draw the text
    this.drawSoilPropertyText(transforms, soil);
    // Pop the matrix
    transforms.pop();
}
Also used : IAgriSoil(com.infinityraider.agricraft.api.v1.requirement.IAgriSoil)

Example 2 with IAgriSoil

use of com.infinityraider.agricraft.api.v1.requirement.IAgriSoil in project AgriCraft by AgriCraft.

the class AgriRecipeCategoryGrowthRequirements method setIngredients.

@Override
public void setIngredients(@Nonnull IAgriPlant plant, IIngredients ingredients) {
    // Get current strength and stage
    PlantRenderState state = this.getState(plant);
    int strength = state.getStrength();
    IAgriGrowthStage stage = state.getStage();
    // Determine inputs
    List<ItemStack> seeds = new ImmutableList.Builder<ItemStack>().add(plant.toItemStack()).addAll(plant.getSeedItems()).build();
    List<ItemStack> soils = AgriApi.getSoilRegistry().stream().filter(soil -> {
        IAgriGrowthRequirement req = plant.getGrowthRequirement(stage);
        boolean humidity = req.getSoilHumidityResponse(soil.getHumidity(), strength).isFertile();
        boolean acidity = req.getSoilAcidityResponse(soil.getAcidity(), strength).isFertile();
        boolean nutrients = req.getSoilNutrientsResponse(soil.getNutrients(), strength).isFertile();
        return humidity && acidity && nutrients;
    }).map(IAgriSoil::getVariants).flatMap(Collection::stream).map(AbstractBlock.AbstractBlockState::getBlock).distinct().map(ItemStack::new).collect(Collectors.toList());
    ingredients.setInputLists(VanillaTypes.ITEM, ImmutableList.of(seeds, soils));
    // Determine output
    ingredients.setOutputLists(AgriIngredientPlant.TYPE, ImmutableList.of(ImmutableList.of(plant)));
}
Also used : IAgriGrowthRequirement(com.infinityraider.agricraft.api.v1.requirement.IAgriGrowthRequirement) ImmutableList(com.google.common.collect.ImmutableList) ItemStack(net.minecraft.item.ItemStack) IAgriGrowthStage(com.infinityraider.agricraft.api.v1.crop.IAgriGrowthStage) AbstractBlock(net.minecraft.block.AbstractBlock)

Example 3 with IAgriSoil

use of com.infinityraider.agricraft.api.v1.requirement.IAgriSoil in project AgriCraft by AgriCraft.

the class CoreHandler method initSoils.

public static void initSoils() {
    // Announce Progress
    AgriCore.getLogger("agricraft").info("Registering Soils!");
    // See if soils are valid...
    final int raw = AgriCore.getSoils().getAll().size();
    AgriCore.getSoils().validate();
    final int count = AgriCore.getSoils().getAll().size();
    // Transfer
    AgriCore.getSoils().getAll().stream().filter(AgriSoil::isEnabled).map(JsonSoil::new).forEach(AgriApi.getSoilRegistry()::add);
    // Display Soils
    AgriCore.getLogger("agricraft").info("Registered Soils ({0}/{1}):", count, raw);
    for (IAgriSoil soil : AgriApi.getSoilRegistry().all()) {
        AgriCore.getLogger("agricraft").info(" - {0}", soil.getName());
    }
}
Also used : AgriSoil(com.agricraft.agricore.plant.AgriSoil) IAgriSoil(com.infinityraider.agricraft.api.v1.soil.IAgriSoil) IAgriSoil(com.infinityraider.agricraft.api.v1.soil.IAgriSoil)

Example 4 with IAgriSoil

use of com.infinityraider.agricraft.api.v1.requirement.IAgriSoil in project AgriCraft by AgriCraft.

the class TileEntityCrop method addDisplayInfo.

@Override
public void addDisplayInfo(@Nonnull Consumer<String> information) {
    // Validate
    Preconditions.checkNotNull(information);
    // Add Soil Information
    information.accept("Soil: " + this.getSoil().map(IAgriSoil::getName).orElse("Unknown"));
    if (this.hasSeed()) {
        // Fetch the plant.
        final IAgriPlant plant = this.getSeed().getPlant();
        // Fetch the stat.
        final IAgriStat stat = this.getSeed().getStat();
        // Add the SEED name.
        information.accept(AgriCore.getTranslator().translate("agricraft_tooltip.seed") + ": " + plant.getSeedName());
        // Add the GROWTH.
        if (this.isMature()) {
            information.accept(AgriCore.getTranslator().translate("agricraft_tooltip.growth") + ": " + AgriCore.getTranslator().translate("agricraft_tooltip.mature"));
        } else {
            information.accept(AgriCore.getTranslator().translate("agricraft_tooltip.growth") + ": " + (int) (100.0 * (this.getGrowthStage() + 1) / plant.getGrowthStages()) + "%");
        }
        // Add the ANALYZED data.
        if (stat.isAnalyzed()) {
            stat.addStats(information);
        } else {
            information.accept(AgriCore.getTranslator().translate("agricraft_tooltip.analyzed"));
        }
        // Add the fertility information.
        information.accept(AgriCore.getTranslator().translate(this.isFertile() ? "agricraft_tooltip.fertile" : "agricraft_tooltip.notFertile"));
    } else {
        information.accept(AgriCore.getTranslator().translate("agricraft_tooltip.empty"));
    }
}
Also used : IAgriPlant(com.infinityraider.agricraft.api.v1.plant.IAgriPlant) IAgriStat(com.infinityraider.agricraft.api.v1.stat.IAgriStat)

Example 5 with IAgriSoil

use of com.infinityraider.agricraft.api.v1.requirement.IAgriSoil in project AgriCraft by AgriCraft.

the class CoreHandler method initSoils.

private static void initSoils() {
    // Announce Progress
    AgriCore.getLogger("agricraft").info("Registering Soils!");
    // See if soils are valid...
    final int raw = AgriCore.getSoils().getAll().size();
    AgriCore.getSoils().validate();
    final int count = AgriCore.getSoils().getAll().size();
    // Transfer
    AgriCore.getSoils().getAll().stream().filter(AgriSoil::isEnabled).map(JsonSoil::new).forEach(AgriApi.getSoilRegistry()::add);
    // Display Soils
    AgriCore.getLogger("agricraft").info("Registered Soils ({0}/{1}):", count, raw);
    for (IAgriSoil soil : AgriApi.getSoilRegistry().all()) {
        AgriCore.getLogger("agricraft").info(" - {0}", soil.getId());
    }
}
Also used : IAgriSoil(com.infinityraider.agricraft.api.v1.requirement.IAgriSoil) 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