Search in sources :

Example 1 with IGeneItem

use of binnie.genetics.genetics.IGeneItem in project Binnie by ForestryMC.

the class ItemSerum method getSubItems.

@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
    if (this.isInCreativeTab(tab)) {
        for (ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
            Map<IChromosomeType, List<IAllele>> chromosomeMap = Binnie.GENETICS.getChromosomeMap(root);
            if (chromosomeMap != null) {
                for (Map.Entry<IChromosomeType, List<IAllele>> entry : chromosomeMap.entrySet()) {
                    IChromosomeType chromosome = entry.getKey();
                    for (final IAllele allele : entry.getValue()) {
                        Gene gene = Gene.create(allele, chromosome, root);
                        IGeneItem geneItem = new GeneItem(gene);
                        ItemStack stack = new ItemStack(this);
                        geneItem.writeToItem(stack);
                        items.add(stack);
                    }
                }
            }
        }
    }
}
Also used : IAllele(forestry.api.genetics.IAllele) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IGeneItem(binnie.genetics.genetics.IGeneItem) Gene(binnie.core.genetics.Gene) IGene(binnie.core.api.genetics.IGene) GeneItem(binnie.genetics.genetics.GeneItem) IGeneItem(binnie.genetics.genetics.IGeneItem) List(java.util.List) NonNullList(net.minecraft.util.NonNullList) IChromosomeType(forestry.api.genetics.IChromosomeType) ItemStack(net.minecraft.item.ItemStack) Map(java.util.Map)

Example 2 with IGeneItem

use of binnie.genetics.genetics.IGeneItem in project Binnie by ForestryMC.

the class ItemSerum method addGene.

@Override
public ItemStack addGene(ItemStack stack, IGene gene) {
    final IGeneItem geneI = this.getGeneItem(stack);
    Preconditions.checkNotNull(geneI, "Cannot add gene to itemStack that is not a valid serum.");
    geneI.addGene(gene);
    geneI.writeToItem(stack);
    return stack;
}
Also used : IGeneItem(binnie.genetics.genetics.IGeneItem)

Example 3 with IGeneItem

use of binnie.genetics.genetics.IGeneItem in project Binnie by ForestryMC.

the class ItemSerumArray method addGene.

@Override
public ItemStack addGene(final ItemStack stack, final IGene gene) {
    final IGeneItem geneItem = this.getGeneItem(stack);
    Preconditions.checkNotNull(geneItem, "Cannot add gene to itemStack that is not a valid serum array.");
    geneItem.addGene(gene);
    geneItem.writeToItem(stack);
    return stack;
}
Also used : IGeneItem(binnie.genetics.genetics.IGeneItem)

Example 4 with IGeneItem

use of binnie.genetics.genetics.IGeneItem in project Binnie by ForestryMC.

the class ItemSerumArray method getSubItems.

@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
    if (this.isInCreativeTab(tab)) {
        for (ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
            for (IIndividual template : root.getIndividualTemplates()) {
                if (template.getGenome().getPrimary().isSecret()) {
                    continue;
                }
                IGeneItem geneItem = new GeneArrayItem();
                for (IChromosomeType type : root.getKaryotype()) {
                    IChromosome chromosome = template.getGenome().getChromosomes()[type.ordinal()];
                    if (chromosome != null) {
                        IAllele active = chromosome.getActiveAllele();
                        geneItem.addGene(new Gene(active, type, root));
                    }
                }
                ItemStack array = new ItemStack(this);
                geneItem.writeToItem(array);
                items.add(array);
            }
        }
    }
}
Also used : IAllele(forestry.api.genetics.IAllele) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IGeneItem(binnie.genetics.genetics.IGeneItem) IIndividual(forestry.api.genetics.IIndividual) Gene(binnie.core.genetics.Gene) IGene(binnie.core.api.genetics.IGene) IChromosome(forestry.api.genetics.IChromosome) IChromosomeType(forestry.api.genetics.IChromosomeType) ItemStack(net.minecraft.item.ItemStack) GeneArrayItem(binnie.genetics.genetics.GeneArrayItem)

Example 5 with IGeneItem

use of binnie.genetics.genetics.IGeneItem in project Binnie by ForestryMC.

the class ItemGene method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemstack, @Nullable World worldIn, List<String> list, ITooltipFlag flagIn) {
    int damage = itemstack.getMaxDamage() - itemstack.getItemDamage();
    if (damage == 0) {
        list.add(I18N.localise("genetics.item.gene.empty"));
    } else if (damage == 1) {
        list.add("1 " + I18N.localise("genetics.item.gene.charge"));
    } else {
        list.add(damage + " " + I18N.localise("genetics.item.gene.charges"));
    }
    IGeneItem gene = this.getGeneItem(itemstack);
    if (gene != null) {
        gene.getInfo(list);
    }
}
Also used : IGeneItem(binnie.genetics.genetics.IGeneItem) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

IGeneItem (binnie.genetics.genetics.IGeneItem)5 IGene (binnie.core.api.genetics.IGene)2 Gene (binnie.core.genetics.Gene)2 IAllele (forestry.api.genetics.IAllele)2 IChromosomeType (forestry.api.genetics.IChromosomeType)2 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)2 ItemStack (net.minecraft.item.ItemStack)2 GeneArrayItem (binnie.genetics.genetics.GeneArrayItem)1 GeneItem (binnie.genetics.genetics.GeneItem)1 IChromosome (forestry.api.genetics.IChromosome)1 IIndividual (forestry.api.genetics.IIndividual)1 List (java.util.List)1 Map (java.util.Map)1 NonNullList (net.minecraft.util.NonNullList)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1