use of com.infinityraider.agricraft.api.v1.soil.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();
}
use of com.infinityraider.agricraft.api.v1.soil.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)));
}
use of com.infinityraider.agricraft.api.v1.soil.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());
}
}
use of com.infinityraider.agricraft.api.v1.soil.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"));
}
}
use of com.infinityraider.agricraft.api.v1.soil.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());
}
}
Aggregations