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