use of forestry.api.genetics.ISpeciesRoot in project Binnie by ForestryMC.
the class WindowGenesis method initialiseClient.
@Override
@SideOnly(Side.CLIENT)
public void initialiseClient() {
new ControlPlayerInventory(this);
this.setTitle(I18N.localise("binniecore.gui.genesis.title"));
final ControlTabBar<IBreedingSystem> tabSystems = new GenesisTabSystems(this);
this.root = Binnie.GENETICS.getActiveSystems().iterator().next().getSpeciesRoot();
this.template = this.root.getDefaultTemplate();
final Area one = new Area(32, 28, 170, 100);
final Area two = new Area(214, 28, 100, 100);
new Panel(this, one.outset(1), MinecraftGUI.PanelType.BLACK);
new Panel(this, two.outset(1), MinecraftGUI.PanelType.BLACK);
this.geneList = new GeneList(this, one);
this.geneOptions = new GeneOptions(this, two);
tabSystems.addEventHandler(EventValueChanged.class, EventHandlerOrigin.SELF, tabSystems, event -> {
Object value = event.getValue();
if (!(value instanceof BreedingSystem)) {
return;
}
IBreedingSystem breedingSystem = (IBreedingSystem) value;
root = breedingSystem.getSpeciesRoot();
template = root.getDefaultTemplate();
refreshTemplate(null);
});
this.geneList.addEventHandler(EventValueChanged.class, EventHandlerOrigin.SELF, this.geneList, event -> {
Object value = event.getValue();
if (!(value instanceof Gene)) {
return;
}
Gene gene = (Gene) value;
Map<IChromosomeType, List<IAllele>> map = Binnie.GENETICS.getChromosomeMap(root);
List<Gene> options = new ArrayList<>();
IChromosomeType chromosomeType = gene.getChromosome();
List<IAllele> alleles = map.get(chromosomeType);
for (IAllele allele : alleles) {
options.add(new Gene(allele, chromosomeType, root));
}
geneOptions.setOptions(options);
});
this.geneOptions.addEventHandler(EventValueChanged.class, EventHandlerOrigin.SELF, this.geneOptions, event -> {
Object value = event.getValue();
if (!(value instanceof Gene)) {
return;
}
Gene gene = (Gene) value;
IChromosomeType chromosomeType = gene.getChromosome();
ISpeciesRoot speciesRoot = gene.getSpeciesRoot();
IAllele allele = gene.getAllele();
if (chromosomeType == speciesRoot.getSpeciesChromosomeType()) {
template = speciesRoot.getTemplate(allele.getUID());
} else {
template[chromosomeType.ordinal()] = allele;
}
refreshTemplate(chromosomeType);
});
this.panelPickup = new Panel(this, 16, 140, 60, 42, MinecraftGUI.PanelType.BLACK);
this.refreshTemplate(null);
}
use of forestry.api.genetics.ISpeciesRoot in project Binnie by ForestryMC.
the class WindowFieldKit method refreshSpecies.
private void refreshSpecies() {
final ItemStack item = this.getWindowInventory().getStackInSlot(INDIVIDUAL_SLOT);
if (item.isEmpty() || !AlleleManager.alleleRegistry.isIndividual(item)) {
return;
}
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(item);
if (ind == null) {
return;
}
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(item);
if (root == null) {
return;
}
IBreedingSystem system = Binnie.GENETICS.getSystem(root);
this.chromo.setSystem(system);
final Random rand = new Random();
this.info.clear();
for (final IChromosomeType type : root.getKaryotype()) {
if (!Binnie.GENETICS.isInvalidChromosome(type)) {
final IAllele allele = ind.getGenome().getActiveAllele(type);
final List<String> infos = new ArrayList<>();
int i = 0;
for (String pref = root.getUID() + ".fieldkit." + type.getName().toLowerCase() + '.'; I18N.canLocalise(pref + i); ++i) {
infos.add(I18N.localise(pref + i));
}
String text = system.getAlleleName(type, allele);
if (!infos.isEmpty()) {
text = infos.get(rand.nextInt(infos.size()));
}
this.info.put(type, text);
this.chromo.setSystem(system);
}
}
}
use of forestry.api.genetics.ISpeciesRoot in project Binnie by ForestryMC.
the class TreeBreedingSystem method getChance.
@Override
public float getChance(final IMutation mutation, final EntityPlayer player, final IAlleleSpecies firstSpecies, final IAlleleSpecies secondSpecies) {
ISpeciesRoot speciesRoot = this.getSpeciesRoot();
final ITreeGenome genome0 = (ITreeGenome) speciesRoot.templateAsGenome(speciesRoot.getTemplate(firstSpecies));
final ITreeGenome genome2 = (ITreeGenome) speciesRoot.templateAsGenome(speciesRoot.getTemplate(secondSpecies));
return ((ITreeMutation) mutation).getChance(player.world, player.getPosition(), (IAlleleTreeSpecies) firstSpecies, (IAlleleTreeSpecies) secondSpecies, genome0, genome2);
}
use of forestry.api.genetics.ISpeciesRoot in project Binnie by ForestryMC.
the class GenepoolRecipeMaker method create.
public static List<GenepoolRecipeWrapper> create() {
List<GenepoolRecipeWrapper> recipes = new ArrayList<>();
Collection<ISpeciesRoot> roots = AlleleManager.alleleRegistry.getSpeciesRoot().values();
for (ISpeciesRoot root : roots) {
ISpeciesType[] speciesTypes = root.getIconType().getClass().getEnumConstants();
IAllele[] defaultTemplate = root.getDefaultTemplate();
IIndividual individual = root.templateAsIndividual(defaultTemplate);
for (ISpeciesType speciesType : speciesTypes) {
ItemStack memberStack = root.getMemberStack(individual, speciesType);
memberStack.setItemDamage(OreDictionary.WILDCARD_VALUE);
GenepoolRecipeWrapper recipeWrapper = new GenepoolRecipeWrapper(memberStack);
recipes.add(recipeWrapper);
}
}
return recipes;
}
use of forestry.api.genetics.ISpeciesRoot in project Binnie by ForestryMC.
the class WindowAnalyst method initialiseServer.
@Override
public void initialiseServer() {
for (IBreedingSystem system : Binnie.GENETICS.getActiveSystems()) {
ISpeciesRoot root = system.getSpeciesRoot();
if (root != null) {
IBreedingTracker tracker = root.getBreedingTracker(getWorld(), getUsername());
if (tracker != null) {
tracker.synchToPlayer(getPlayer());
}
}
}
// create slots
getWindowInventory().createSlot(0);
getWindowInventory().createSlot(1);
setupValidators();
}
Aggregations