Search in sources :

Example 21 with IAgriPlant

use of com.infinityraider.agricraft.api.v1.plant.IAgriPlant in project AgriCraft by AgriCraft.

the class Mutation method toString.

@Override
public String toString() {
    final StringBuilder sb = new StringBuilder();
    sb.append(this.id).append(": ");
    for (IAgriPlant p : this.parents) {
        sb.append(p.getPlantName()).append(" + ");
    }
    sb.replace(sb.length() - 3, sb.length(), " = ");
    sb.append(this.child.getPlantName());
    return sb.toString();
}
Also used : IAgriPlant(com.infinityraider.agricraft.api.v1.plant.IAgriPlant)

Example 22 with IAgriPlant

use of com.infinityraider.agricraft.api.v1.plant.IAgriPlant in project AgriCraft by AgriCraft.

the class ItemAgriSeed method getSubItems.

@Override
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> list) {
    final PlantStats baseStat = new PlantStats();
    for (IAgriPlant plant : AgriApi.getPlantRegistry().all()) {
        if (plant.getSeedItems().stream().anyMatch(s -> s.isItemEqual(this))) {
            ItemStack stack = new ItemStack(item);
            NBTTagCompound tag = new NBTTagCompound();
            tag.setString(AgriNBT.SEED, plant.getId());
            baseStat.writeToNBT(tag);
            stack.setTagCompound(tag);
            list.add(stack);
        }
    }
}
Also used : IAgriPlant(com.infinityraider.agricraft.api.v1.plant.IAgriPlant) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) PlantStats(com.infinityraider.agricraft.farming.PlantStats)

Example 23 with IAgriPlant

use of com.infinityraider.agricraft.api.v1.plant.IAgriPlant in project AgriCraft by AgriCraft.

the class ItemAgriSeed method getSubItems.

@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> list) {
    if (tab == this.getCreativeTab() || tab == CreativeTabs.SEARCH) {
        final PlantStats baseStat = new PlantStats();
        for (IAgriPlant plant : AgriApi.getPlantRegistry().all()) {
            if (plant.getSeedItems().stream().anyMatch(s -> s.isItemEqual(this))) {
                ItemStack stack = new ItemStack(this);
                NBTTagCompound tag = new NBTTagCompound();
                tag.setString(AgriNBT.SEED, plant.getId());
                baseStat.writeToNBT(tag);
                stack.setTagCompound(tag);
                list.add(stack);
            }
        }
    }
}
Also used : IAgriPlant(com.infinityraider.agricraft.api.v1.plant.IAgriPlant) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) PlantStats(com.infinityraider.agricraft.farming.PlantStats)

Example 24 with IAgriPlant

use of com.infinityraider.agricraft.api.v1.plant.IAgriPlant 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 25 with IAgriPlant

use of com.infinityraider.agricraft.api.v1.plant.IAgriPlant in project AgriCraft by AgriCraft.

the class TileEntityCrop method spawn.

// =========================================================================
// IWeedable Methods
// =========================================================================
public boolean spawn() {
    // If in remote world, abort!
    if (this.isRemote()) {
        return false;
    }
    // If already have plant, abort!
    if (this.hasSeed()) {
        return false;
    }
    // Attempt to spawn plant.
    for (IAgriPlant p : AgriApi.getPlantRegistry().all()) {
        if (p.getSpawnChance() > this.getRandom().nextDouble() && this.isFertile(p)) {
            this.setCrossCrop(false);
            this.setSeed(new AgriSeed(p, new PlantStats()));
            return true;
        }
    }
    // The operation was a failure.
    return false;
}
Also used : IAgriPlant(com.infinityraider.agricraft.api.v1.plant.IAgriPlant) AgriSeed(com.infinityraider.agricraft.api.v1.seed.AgriSeed) PlantStats(com.infinityraider.agricraft.farming.PlantStats)

Aggregations

IAgriPlant (com.infinityraider.agricraft.api.v1.plant.IAgriPlant)32 ItemStack (net.minecraft.item.ItemStack)8 AgriSeed (com.infinityraider.agricraft.api.v1.seed.AgriSeed)7 Nonnull (javax.annotation.Nonnull)6 IAgriStat (com.infinityraider.agricraft.api.v1.stat.IAgriStat)5 PlantStats (com.infinityraider.agricraft.farming.PlantStats)5 IAgriCrop (com.infinityraider.agricraft.api.v1.crop.IAgriCrop)4 AgriApi (com.infinityraider.agricraft.api.v1.AgriApi)3 IAgriMutation (com.infinityraider.agricraft.api.v1.mutation.IAgriMutation)3 IAgriGrowthRequirement (com.infinityraider.agricraft.api.v1.requirement.IAgriGrowthRequirement)3 AgriMutation (com.agricraft.agricore.plant.AgriMutation)2 ImmutableList (com.google.common.collect.ImmutableList)2 IAgriJournalItem (com.infinityraider.agricraft.api.v1.content.items.IAgriJournalItem)2 IAgriGrowthStage (com.infinityraider.agricraft.api.v1.crop.IAgriGrowthStage)2 IAgriMutation (com.infinityraider.agricraft.api.v1.genetics.IAgriMutation)2 AgriPlantIngredient (com.infinityraider.agricraft.api.v1.plant.AgriPlantIngredient)2 IAgriWeed (com.infinityraider.agricraft.api.v1.plant.IAgriWeed)2 IAgriSoil (com.infinityraider.agricraft.api.v1.requirement.IAgriSoil)2 IAgriStatsMap (com.infinityraider.agricraft.api.v1.stat.IAgriStatsMap)2 BlockCropPlant (com.infinityraider.agricraft.content.core.BlockCropPlant)2