use of forestry.api.genetics.IAlleleSpecies in project ForestryMC by ForestryMC.
the class SpeciesWidget method draw.
@Override
public void draw(int startX, int startY) {
int x = xPos + startX;
int y = yPos + startY;
IFilterLogic logic = gui.getLogic();
IAlleleSpecies allele = (IAlleleSpecies) logic.getGenomeFilter(facing, index, active);
if (allele != null) {
GuiUtil.drawItemStack(manager.gui, ITEMS.getOrDefault(allele, ItemStack.EMPTY), x, y);
}
TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
if (this.gui.selection.isSame(this)) {
textureManager.bindTexture(SelectionWidget.TEXTURE);
gui.drawTexturedModalRect(x - 1, y - 1, 212, 0, 18, 18);
}
}
use of forestry.api.genetics.IAlleleSpecies in project Binnie by ForestryMC.
the class PagePlanksTrees method getTreesThatMakePlanks.
private static Collection<IAlleleSpecies> getTreesThatMakePlanks(ItemStack fruit, boolean master, World world, GameProfile player) {
if (fruit == null) {
return new ArrayList<>();
}
ITreeRoot treeRoot = TreeManager.treeRoot;
IBreedingSystem system = Binnie.GENETICS.getSystem(treeRoot);
final Collection<IAlleleSpecies> set = master ? system.getAllSpecies() : system.getDiscoveredSpecies(world, player);
final List<IAlleleSpecies> found = new ArrayList<>();
for (final IAlleleSpecies species : set) {
final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
ITreeGenome genome = treeRoot.templateAsGenome(treeRoot.getTemplate(tSpecies));
IAlleleTreeSpecies treeSpecies = genome.getPrimary();
final ItemStack woodStack = treeSpecies.getWoodProvider().getWoodStack();
ItemStack plankProduct = LumbermillRecipeManager.getPlankProduct(woodStack, world);
if (!plankProduct.isEmpty() && fruit.isItemEqual(plankProduct)) {
found.add(species);
}
}
return found;
}
use of forestry.api.genetics.IAlleleSpecies in project Binnie by ForestryMC.
the class ControlMutationSymbol method getTooltip.
@Override
public void getTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) {
if (this.type == 1 && this.discovered) {
final IAlleleSpecies species1 = this.value.getAllele0();
final IAlleleSpecies species2 = this.value.getAllele1();
final IBreedingSystem system = ((WindowAbstractDatabase) this.getTopParent()).getBreedingSystem();
final float chance = system.getChance(this.value, Window.get(this).getPlayer(), species1, species2);
tooltip.add(I18N.localise(DatabaseConstants.CONTROL_KEY + ".chance", chance));
for (final String string : this.value.getSpecialConditions()) {
tooltip.add(string);
}
}
}
use of forestry.api.genetics.IAlleleSpecies in project Binnie by ForestryMC.
the class ControlSpeciesBox method setBranch.
public void setBranch(final IClassification branch) {
if (branch != this.branch) {
this.branch = branch;
final List<IAlleleSpecies> speciesList2 = new ArrayList<>();
this.movePercentage(-100.0f);
this.setOptions(speciesList2);
// final EntityPlayer player = Window.get(this).getPlayer();
final GameProfile playerName = Window.get(this).getUsername();
final WindowAbstractDatabase db = Window.get(this);
IBreedingSystem breedingSystem = db.getBreedingSystem();
final Collection<IAlleleSpecies> speciesList3 = db.isMaster() ? breedingSystem.getAllSpecies() : breedingSystem.getDiscoveredSpecies(db.getWorld(), playerName);
if (branch != null) {
for (final IAlleleSpecies species : branch.getMemberSpecies()) {
if (speciesList3.contains(species)) {
speciesList2.add(species);
}
}
}
this.setOptions(speciesList2);
}
}
use of forestry.api.genetics.IAlleleSpecies in project Binnie by ForestryMC.
the class BreedingSystem method syncTracker.
@Override
public final void syncTracker(final IBreedingTracker tracker) {
if (allActiveSpecies.isEmpty()) {
calculateArrays();
}
this.discoveredSpeciesPercentage = 0.0f;
this.totalSpeciesCount = 0;
this.discoveredSpeciesCount = 0;
this.totalSecretCount = 0;
this.discoveredSecretCount = 0;
final Collection<IAlleleSpecies> discoveredSpecies = this.getDiscoveredSpecies(tracker);
final Collection<IAlleleSpecies> allSpecies = this.getAllSpecies();
for (final IAlleleSpecies species : allSpecies) {
if (!this.isSecret(species)) {
++this.totalSpeciesCount;
if (!this.isSpeciesDiscovered(species, tracker)) {
continue;
}
++this.discoveredSpeciesCount;
} else {
++this.totalSecretCount;
if (!this.isSpeciesDiscovered(species, tracker)) {
continue;
}
++this.discoveredSecretCount;
}
}
this.discoveredBranchPercentage = 0.0f;
this.totalBranchCount = 0;
this.discoveredBranchCount = 0;
final Collection<IClassification> discoveredBranches = this.getDiscoveredBranches(tracker);
final Collection<IClassification> allBranches = this.getAllBranches();
for (final IClassification branch : allBranches) {
if (!this.isSecret(branch)) {
++this.totalBranchCount;
if (!discoveredBranches.contains(branch)) {
continue;
}
++this.discoveredBranchCount;
} else {
++this.totalSecretBranchCount;
if (!discoveredBranches.contains(branch)) {
continue;
}
++this.discoveredSecretBranchCount;
}
}
this.discoveredSpeciesPercentage = this.discoveredSpeciesCount / this.totalSpeciesCount;
this.discoveredBranchPercentage = this.discoveredBranchCount / this.totalBranchCount;
final String epithet = this.getEpitome();
this.onSyncBreedingTracker(tracker);
}
Aggregations