use of com.infinityraider.agricraft.api.v1.util.FuzzyStack in project AgriCraft by AgriCraft.
the class CustomWoodShapedRecipe method matches.
@Override
public boolean matches(InventoryCrafting ic, World world) {
final Optional<CustomWoodType> material = inferMaterial(ic);
if (!material.isPresent()) {
return false;
}
for (int r = 0; r < 3; r++) {
for (int c = 0; c < 3; c++) {
final FuzzyStack expected = layout.get(r, c);
final ItemStack input = ic.getStackInRowAndColumn(r, c);
final Optional<CustomWoodType> inputMaterial = CustomWoodTypeRegistry.getFromStack(input);
if (inputMaterial.isPresent() && !material.equals(inputMaterial)) {
return false;
} else if (!Objects.equals(input, expected)) {
return false;
}
}
}
return true;
}
use of com.infinityraider.agricraft.api.v1.util.FuzzyStack in project AgriCraft by AgriCraft.
the class JsonPlant method initSeedItemsListJSON.
public static final List<FuzzyStack> initSeedItemsListJSON(AgriPlant plant) {
final List<FuzzyStack> seeds = new ArrayList<>(plant.getSeedItems().size());
plant.getSeedItems().stream().map(i -> i.toStack(FuzzyStack.class)).filter(Optional::isPresent).map(Optional::get).forEach(seeds::add);
if (seeds.isEmpty()) {
seeds.add(new FuzzyStack(new ItemStack(AgriItems.getInstance().AGRI_SEED)));
}
return seeds;
}
use of com.infinityraider.agricraft.api.v1.util.FuzzyStack in project AgriCraft by AgriCraft.
the class DebugModeCheckSoil method debugActionBlockClicked.
@Override
public void debugActionBlockClicked(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
FuzzyStack soil = FuzzyStack.from(world.getBlockState(pos)).orElse(null);
String type = AgriApi.getSoilRegistry().all().stream().filter(s -> s.isVarient(soil)).map(s -> s.getName()).findFirst().orElse("Unknown Soil");
MessageUtil.messagePlayer(player, "{0} Soil Info:", FMLCommonHandler.instance().getSide());
MessageUtil.messagePlayer(player, " - Soil Type: \"{0}\"", type);
}
use of com.infinityraider.agricraft.api.v1.util.FuzzyStack in project AgriCraft by AgriCraft.
the class SeedWrapper method resolve.
private AgriSeed resolve(ItemStack stack) {
if (!StackHelper.isValid(stack)) {
return null;
}
final FuzzyStack toResolve = new FuzzyStack(stack);
Optional<IAgriPlant> plant = AgriApi.getPlantRegistry().all().stream().filter(p -> p.getSeedItems().contains(toResolve)).findFirst();
if (plant.isPresent()) {
Optional<IAgriStat> stats = AgriApi.getStatRegistry().valueOf(stack.getTagCompound());
return new AgriSeed(plant.get(), stats.orElseGet(PlantStats::new));
} else {
return null;
}
}
use of com.infinityraider.agricraft.api.v1.util.FuzzyStack 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 Optional<FuzzyStack> stack = obj.toStack(FuzzyStack.class);
if (stack.isPresent()) {
builder.addCondition(new BlockCondition(stack.get(), 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();
}
Aggregations