Search in sources :

Example 1 with FuzzyStack

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;
}
Also used : FuzzyStack(com.infinityraider.agricraft.api.v1.util.FuzzyStack) CustomWoodType(com.infinityraider.agricraft.utility.CustomWoodType) ItemStack(net.minecraft.item.ItemStack)

Example 2 with FuzzyStack

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;
}
Also used : AgriNBT(com.infinityraider.agricraft.reference.AgriNBT) IAgriCrop(com.infinityraider.agricraft.api.v1.crop.IAgriCrop) IGrowthReqBuilder(com.infinityraider.agricraft.api.v1.requirement.IGrowthReqBuilder) IGrowthRequirement(com.infinityraider.agricraft.api.v1.requirement.IGrowthRequirement) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) BlockCondition(com.infinityraider.agricraft.api.v1.requirement.BlockCondition) PlantStats(com.infinityraider.agricraft.farming.PlantStats) Random(java.util.Random) Function(java.util.function.Function) ArrayList(java.util.ArrayList) AgriCore(com.agricraft.agricore.core.AgriCore) RenderMethod(com.infinityraider.agricraft.api.v1.render.RenderMethod) ItemStack(net.minecraft.item.ItemStack) AgriItems(com.infinityraider.agricraft.init.AgriItems) Side(net.minecraftforge.fml.relauncher.Side) GrowthReqBuilder(com.infinityraider.agricraft.farming.growthrequirement.GrowthReqBuilder) FuzzyStack(com.infinityraider.agricraft.api.v1.util.FuzzyStack) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) IAgriStat(com.infinityraider.agricraft.api.v1.stat.IAgriStat) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IAgriPlant(com.infinityraider.agricraft.api.v1.plant.IAgriPlant) Collection(java.util.Collection) EnumFacing(net.minecraft.util.EnumFacing) BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) PlantRenderer(com.infinityraider.agricraft.renderers.PlantRenderer) Objects(java.util.Objects) Consumer(java.util.function.Consumer) Constants(com.infinityraider.agricraft.reference.Constants) List(java.util.List) BlockRange(com.infinityraider.agricraft.api.v1.util.BlockRange) ITessellator(com.infinityraider.infinitylib.render.tessellation.ITessellator) AgriPlant(com.agricraft.agricore.plant.AgriPlant) ResourceLocation(net.minecraft.util.ResourceLocation) Optional(java.util.Optional) Collections(java.util.Collections) Optional(java.util.Optional) ArrayList(java.util.ArrayList) FuzzyStack(com.infinityraider.agricraft.api.v1.util.FuzzyStack) ItemStack(net.minecraft.item.ItemStack)

Example 3 with FuzzyStack

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);
}
Also used : ItemStack(net.minecraft.item.ItemStack) DebugMode(com.infinityraider.infinitylib.utility.debug.DebugMode) AgriApi(com.infinityraider.agricraft.api.v1.AgriApi) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) World(net.minecraft.world.World) EnumHand(net.minecraft.util.EnumHand) EnumFacing(net.minecraft.util.EnumFacing) FMLCommonHandler(net.minecraftforge.fml.common.FMLCommonHandler) BlockPos(net.minecraft.util.math.BlockPos) FuzzyStack(com.infinityraider.agricraft.api.v1.util.FuzzyStack) MessageUtil(com.infinityraider.infinitylib.utility.MessageUtil) FuzzyStack(com.infinityraider.agricraft.api.v1.util.FuzzyStack)

Example 4 with FuzzyStack

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;
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) IAgriPlant(com.infinityraider.agricraft.api.v1.plant.IAgriPlant) AgriApi(com.infinityraider.agricraft.api.v1.AgriApi) IAgriAdapter(com.infinityraider.agricraft.api.v1.adapter.IAgriAdapter) AgriSeed(com.infinityraider.agricraft.api.v1.seed.AgriSeed) PlantStats(com.infinityraider.agricraft.farming.PlantStats) Optional(java.util.Optional) FuzzyStack(com.infinityraider.agricraft.api.v1.util.FuzzyStack) StackHelper(com.infinityraider.agricraft.utility.StackHelper) IAgriStat(com.infinityraider.agricraft.api.v1.stat.IAgriStat) IAgriPlant(com.infinityraider.agricraft.api.v1.plant.IAgriPlant) IAgriStat(com.infinityraider.agricraft.api.v1.stat.IAgriStat) FuzzyStack(com.infinityraider.agricraft.api.v1.util.FuzzyStack) AgriSeed(com.infinityraider.agricraft.api.v1.seed.AgriSeed)

Example 5 with FuzzyStack

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();
}
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

FuzzyStack (com.infinityraider.agricraft.api.v1.util.FuzzyStack)5 ItemStack (net.minecraft.item.ItemStack)4 AgriApi (com.infinityraider.agricraft.api.v1.AgriApi)2 IAgriPlant (com.infinityraider.agricraft.api.v1.plant.IAgriPlant)2 BlockCondition (com.infinityraider.agricraft.api.v1.requirement.BlockCondition)2 IGrowthReqBuilder (com.infinityraider.agricraft.api.v1.requirement.IGrowthReqBuilder)2 IAgriStat (com.infinityraider.agricraft.api.v1.stat.IAgriStat)2 BlockRange (com.infinityraider.agricraft.api.v1.util.BlockRange)2 PlantStats (com.infinityraider.agricraft.farming.PlantStats)2 GrowthReqBuilder (com.infinityraider.agricraft.farming.growthrequirement.GrowthReqBuilder)2 Optional (java.util.Optional)2 EnumFacing (net.minecraft.util.EnumFacing)2 AgriCore (com.agricraft.agricore.core.AgriCore)1 AgriPlant (com.agricraft.agricore.plant.AgriPlant)1 IAgriAdapter (com.infinityraider.agricraft.api.v1.adapter.IAgriAdapter)1 IAgriCrop (com.infinityraider.agricraft.api.v1.crop.IAgriCrop)1 RenderMethod (com.infinityraider.agricraft.api.v1.render.RenderMethod)1 IGrowthRequirement (com.infinityraider.agricraft.api.v1.requirement.IGrowthRequirement)1 AgriSeed (com.infinityraider.agricraft.api.v1.seed.AgriSeed)1 AgriItems (com.infinityraider.agricraft.init.AgriItems)1