Package forestry.api.genetics

Examples of forestry.api.genetics.IAllele


    @Override
    public void convert(final Object value, final Map<Object, Object> output) {
        if (value instanceof IMutation) {
            IMutation mutation = (IMutation) value;

            IAllele allele1 = mutation.getAllele0();
            if (allele1 instanceof IAlleleSpecies) {
                Map<Object, Object> allelMap1 = Maps.newHashMap();
                convert(allele1, allelMap1);
                output.put("allele1", allelMap1);
            }
            IAllele allele2 = mutation.getAllele1();
            if (allele2 instanceof IAlleleSpecies) {
                Map<Object, Object> allelMap2 = Maps.newHashMap();
                convert(allele2, allelMap2);
                output.put("allele2", allelMap2);
            }
View Full Code Here


    super(chromosomes);
  }

  // NBT RETRIEVAL
  public static IAlleleButterflySpecies getSpecies(ItemStack itemStack) {
    IAllele speciesAllele = Genome.getPrimaryAllele(itemStack, EnumButterflyChromosome.SPECIES);
    if (speciesAllele instanceof IAlleleButterflySpecies)
      return (IAlleleButterflySpecies)speciesAllele;
    else
      return null;
  }
View Full Code Here

    if(!Proxies.common.isSimulating(worldObj)) {
      if (species == null || dataWatcher.hasChanges()) {
        scale = (float)dataWatcher.getWatchableObjectInt(DATAWATCHER_ID_SCALE) / 100;
        String uid = dataWatcher.getWatchableObjectString(DATAWATCHER_ID_SPECIES);
        if(species == null || !species.getUID().equals(uid)) {
          IAllele allele = AlleleManager.alleleRegistry.getAllele(uid);
          if(allele instanceof IAlleleButterflySpecies) {
            setSpecies((IAlleleButterflySpecies)allele);
          }
        }
      }
View Full Code Here

    IChromosome[] parent1 = genomeOne.getChromosomes();
    IChromosome[] parent2 = genomeTwo.getChromosomes();

    IGenome genome0;
    IGenome genome1;
    IAllele allele0;
    IAllele allele1;

    if (world.rand.nextBoolean()) {
      allele0 = parent1[EnumButterflyChromosome.SPECIES.ordinal()].getPrimaryAllele();
      allele1 = parent2[EnumButterflyChromosome.SPECIES.ordinal()].getSecondaryAllele();
View Full Code Here

    drawLine(StringUtil.localize("gui.sappiness"), COLUMN_0);
    drawLine(tree.getGenome().getActiveAllele(EnumTreeChromosome.SAPPINESS.ordinal()).getName(), COLUMN_1, tree, EnumTreeChromosome.SAPPINESS, false);

    // FIXME: Legacy handling
    IAllele sappiness = tree.getGenome().getInactiveAllele(EnumTreeChromosome.SAPPINESS.ordinal());
    String sap;
    if (sappiness instanceof IAlleleFloat)
      sap = sappiness.getName();
    else
      sap = Allele.saplingsLowest.getName();

    drawLine(sap, COLUMN_2, tree, EnumTreeChromosome.SAPPINESS, true);
View Full Code Here

    drawLine(StringUtil.localize("gui.tolerated"), COLUMN_0);

    EnumPlantType[] tolerated0 = tree.getGenome().getPlantTypes().toArray(new EnumPlantType[0]);
    EnumPlantType[] tolerated1 = new EnumPlantType[0];
    IAllele allele1 = tree.getGenome().getInactiveAllele(EnumTreeChromosome.PLANT.ordinal());
    if (allele1 instanceof AllelePlantType)
      tolerated1 = ((AllelePlantType) allele1).getPlantTypes().toArray(new EnumPlantType[0]);

    int max = tolerated0.length > tolerated1.length ? tolerated0.length : tolerated1.length;
    for (int i = 0; i < max; i++) {
      if (i > 0)
        newLine();
      if(tolerated0.length > i)
        drawLine(StringUtil.localize("gui." + tolerated0[i].toString().toLowerCase(Locale.ENGLISH)), COLUMN_1, tree, EnumTreeChromosome.PLANT, false);
      if(tolerated1.length > i)
        drawLine(StringUtil.localize("gui." + tolerated1[i].toString().toLowerCase(Locale.ENGLISH)), COLUMN_2, tree, EnumTreeChromosome.PLANT, true);
    }
    newLine();

    // FRUITS
    drawLine(StringUtil.localize("gui.supports"), COLUMN_0);
    IFruitFamily[] families0 = tree.getGenome().getPrimary().getSuitableFruit().toArray(new IFruitFamily[0]);
    IFruitFamily[] families1 = tree.getGenome().getPrimary().getSuitableFruit().toArray(new IFruitFamily[0]);

    max = families0.length > families1.length ? families0.length : families1.length;
    for (int i = 0; i < max; i++) {
      if (i > 0)
        newLine();

      if (families0.length > i)
        drawLine(families0[i].getName(), COLUMN_1, speciesDominance0);
      if (families1.length > i)
        drawLine(families1[i].getName(), COLUMN_2, speciesDominance1);

    }

    newLine();
    newLine();

    int fruitDominance0 = getColorCoding(tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS.ordinal()).isDominant());
    int fruitDominance1 = getColorCoding(tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS.ordinal()).isDominant());

    drawLine(StringUtil.localize("gui.fruits"), COLUMN_0);
    String strike = "";
    IAllele fruit0 = tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS.ordinal());
    if (!tree.canBearFruit() && fruit0 != Allele.fruitNone)
      strike = "\u00A7m";
    drawLine(strike + StringUtil.localize(tree.getGenome().getFruitProvider().getDescription()), COLUMN_1, fruitDominance0);

    strike = "";
    IAllele fruit1 = tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS.ordinal());
    if (!tree.getGenome().getSecondary().getSuitableFruit().contains(((IAlleleFruit) fruit1).getProvider().getFamily()) && fruit1 != Allele.fruitNone)
      strike = "\u00A7m";
    drawLine(strike + StringUtil.localize(((IAlleleFruit) fruit1).getProvider().getDescription()), COLUMN_2, fruitDominance1);

    newLine();
View Full Code Here

  /* SAVING & LOADING */
  @Override
  public void readFromNBT(NBTTagCompound nbttagcompound) {
    super.readFromNBT(nbttagcompound);

    IAllele stored = AlleleManager.alleleRegistry.getAllele(nbttagcompound.getString("UID"));
    if (stored != null && stored instanceof IAlleleFruit)
      allele = (IAlleleFruit)stored;
    else
      allele = (IAlleleFruit) AlleleManager.alleleRegistry.getAllele("fruitCocoa");

View Full Code Here

    ItemStack partnerBee = iconStacks.get(combination.getPartner(species).getUID());
    widgetManager.add(new ItemStackWidget(x, getLineY(), partnerBee));

    drawProbabilityArrow(combination.getBaseChance(), adjustToFactor(guiLeft) + x + 18, adjustToFactor(guiTop) + getLineY() + 4);

    IAllele result = combination.getTemplate()[EnumBeeChromosome.SPECIES.ordinal()];
    ItemStack resultBee = iconStacks.get(result.getUID());
    widgetManager.add(new ItemStackWidget(x + 33, getLineY(), resultBee));
  }
View Full Code Here

    super(nbttagcompound);
  }

  // NBT RETRIEVAL
  public static IAlleleTreeSpecies getSpecies(ItemStack itemStack) {
    IAllele speciesAllele = Genome.getPrimaryAllele(itemStack, EnumTreeChromosome.SPECIES);
    if (speciesAllele instanceof IAlleleTreeSpecies)
      return (IAlleleTreeSpecies)speciesAllele;
    else
      return null;
  }
View Full Code Here

  public float getSappiness() {
    // FIXME: Legacy handling.
    if (getChromosomes()[EnumTreeChromosome.SAPPINESS.ordinal()] == null)
      getChromosomes()[EnumTreeChromosome.SAPPINESS.ordinal()] = new Chromosome(Allele.sappinessLowest);

    IAllele allele = getActiveAllele(EnumTreeChromosome.SAPPINESS.ordinal());
    // FIXME: More legacy handling
    if (allele instanceof IAlleleFloat)
      return ((IAlleleFloat) allele).getValue();
    else {
      getChromosomes()[EnumTreeChromosome.SAPPINESS.ordinal()] = new Chromosome(Allele.sappinessLowest);
View Full Code Here

TOP

Related Classes of forestry.api.genetics.IAllele

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.