Search in sources :

Example 1 with IGrowthReqBuilder

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

the class JsonPlant method initGrowthRequirementJSON.

public static final IGrowthRequirement initGrowthRequirementJSON(AgriPlant plant) {
    IGrowthReqBuilder builder = new GrowthReqBuilder();
    if (plant == null) {
        return builder.build();
    }
    if (plant.getRequirement().getSoils().isEmpty()) {
        AgriCore.getLogger("agricraft").warn("Plant: \"{0}\" has no valid soils to plant on!", plant.getPlantName());
    }
    plant.getRequirement().getSoils().stream().map(JsonSoil::new).forEach(builder::addSoil);
    plant.getRequirement().getConditions().forEach(obj -> {
        final Object stack = obj.toStack();
        if (stack instanceof FuzzyStack) {
            builder.addCondition(new BlockCondition((FuzzyStack) stack, new BlockRange(obj.getMinX(), obj.getMinY(), obj.getMinZ(), obj.getMaxX(), obj.getMaxY(), obj.getMaxZ())));
        }
    });
    builder.setMinLight(plant.getRequirement().getMinLight());
    builder.setMaxLight(plant.getRequirement().getMaxLight());
    return builder.build();
}
Also used : BlockRange(com.infinityraider.agricraft.api.v1.util.BlockRange) BlockCondition(com.infinityraider.agricraft.api.v1.requirement.BlockCondition) IGrowthReqBuilder(com.infinityraider.agricraft.api.v1.requirement.IGrowthReqBuilder) FuzzyStack(com.infinityraider.agricraft.api.v1.util.FuzzyStack) IGrowthReqBuilder(com.infinityraider.agricraft.api.v1.requirement.IGrowthReqBuilder) GrowthReqBuilder(com.infinityraider.agricraft.farming.growthrequirement.GrowthReqBuilder)

Aggregations

BlockCondition (com.infinityraider.agricraft.api.v1.requirement.BlockCondition)1 IGrowthReqBuilder (com.infinityraider.agricraft.api.v1.requirement.IGrowthReqBuilder)1 BlockRange (com.infinityraider.agricraft.api.v1.util.BlockRange)1 FuzzyStack (com.infinityraider.agricraft.api.v1.util.FuzzyStack)1 GrowthReqBuilder (com.infinityraider.agricraft.farming.growthrequirement.GrowthReqBuilder)1