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