Search in sources :

Example 6 with PlantStats

use of com.infinityraider.agricraft.farming.PlantStats 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 7 with PlantStats

use of com.infinityraider.agricraft.farming.PlantStats 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

PlantStats (com.infinityraider.agricraft.farming.PlantStats)7 IAgriPlant (com.infinityraider.agricraft.api.v1.plant.IAgriPlant)4 AgriSeed (com.infinityraider.agricraft.api.v1.seed.AgriSeed)4 ItemStack (net.minecraft.item.ItemStack)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 IAgriCrop (com.infinityraider.agricraft.api.v1.crop.IAgriCrop)2 AgriApi (com.infinityraider.agricraft.api.v1.AgriApi)1 IAgriAdapter (com.infinityraider.agricraft.api.v1.adapter.IAgriAdapter)1 IAgriStat (com.infinityraider.agricraft.api.v1.stat.IAgriStat)1 FuzzyStack (com.infinityraider.agricraft.api.v1.util.FuzzyStack)1 StackHelper (com.infinityraider.agricraft.utility.StackHelper)1 Optional (java.util.Optional)1