Search in sources :

Example 16 with IBreedingSystem

use of binnie.core.api.genetics.IBreedingSystem in project Binnie by ForestryMC.

the class PageSpeciesTreeGenome method onValueChanged.

// TODO: unused ?
/*public static String tolerated(final boolean t) {
		if (t) {
			return I18N.localise("binniecore.gui.tolerated");
		}
		return I18N.localise("binniecore.gui.nottolerated");
	}*/
@Override
public void onValueChanged(final IAlleleSpecies species) {
    this.deleteAllChildren();
    final IAllele[] template = TreeManager.treeRoot.getTemplate(species.getUID());
    if (template == null) {
        return;
    }
    final ITree tree = TreeManager.treeRoot.templateAsIndividual(template);
    final ITreeGenome genome = tree.getGenome();
    final IAlleleTreeSpecies treeSpecies = genome.getPrimary();
    final int w = 144;
    final int h = 176;
    new ControlText(this, new Area(0, 4, w, 16), this.getValue().toString(), TextJustification.MIDDLE_CENTER);
    final ControlScrollableContent scrollable = new ControlScrollableContent(this, 4, 20, w - 8, h - 8 - 16, 12);
    final Control contents = new Control(scrollable, 0, 0, w - 8 - 12, h - 8 - 16);
    final int tw = w - 8 - 12;
    final int w2 = 65;
    final int w3 = tw - 50;
    int y = 0;
    final int th = 14;
    final int th2 = 18;
    final IBreedingSystem syst = Binnie.GENETICS.getSystem(TreeManager.treeRoot);
    new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getPlantType().toString(), TextJustification.MIDDLE_LEFT);
    y += th;
    new ControlText(contents, new Area(0, y, w2, th), I18N.localise("binniecore.gui.temperature.short") + " : ", TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getTemperature().getName(), TextJustification.MIDDLE_LEFT);
    y += th;
    Minecraft minecraft = Minecraft.getMinecraft();
    World world = minecraft.world;
    TextureMap map = minecraft.getTextureMapBlocks();
    ILeafSpriteProvider spriteProvider = treeSpecies.getLeafSpriteProvider();
    TextureAtlasSprite leaf = map.getAtlasSprite(spriteProvider.getSprite(false, false).toString());
    int leafColour = spriteProvider.getColor(false);
    new ControlText(contents, new Area(0, y, w2, th2), I18N.localise("extratrees.gui.database.leaves") + " : ", TextJustification.MIDDLE_RIGHT);
    new ControlBlockIconDisplay(contents, w2, y, leaf).setColor(leafColour);
    IFruitProvider fruitProvider = genome.getFruitProvider();
    ResourceLocation fruitSprite = fruitProvider.getSprite(genome, world, BlockPos.ORIGIN, 100);
    if (fruitSprite != null && !treeSpecies.getUID().equals("forestry.treeOak")) {
        TextureAtlasSprite fruit = map.getAtlasSprite(fruitSprite.toString());
        int fruitColour = fruitProvider.getColour(genome, world, BlockPos.ORIGIN, 100);
        new ControlBlockIconDisplay(contents, w2, y, fruit).setColor(fruitColour);
    }
    y += th2;
    Map<ItemStack, Float> products = fruitProvider.getProducts();
    ItemStack log = treeSpecies.getWoodProvider().getWoodStack();
    if (log.isEmpty()) {
        new ControlText(contents, new Area(0, y, w2, th2), I18N.localise("extratrees.gui.database.log") + " : ", TextJustification.MIDDLE_RIGHT);
        final ControlItemDisplay display = new ControlItemDisplay(contents, w2, y);
        display.setItemStack(log);
        display.setTooltip();
        y += th2;
    }
    new ControlText(contents, new Area(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.HEIGHT) + " : ", TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), genome.getHeight() + "x", TextJustification.MIDDLE_LEFT);
    y += th;
    new ControlText(contents, new Area(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.FERTILITY) + " : ", TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), genome.getFertility() + "x", TextJustification.MIDDLE_LEFT);
    y += th;
    List<ItemStack> fruits = new ArrayList<>(products.keySet());
    if (!fruits.isEmpty()) {
        new ControlText(contents, new Area(0, y, w2, th2), syst.getChromosomeShortName(EnumTreeChromosome.FRUITS) + " : ", TextJustification.MIDDLE_RIGHT);
        for (ItemStack fruitw : fruits) {
            final ControlItemDisplay display2 = new ControlItemDisplay(contents, w2, y);
            display2.setItemStack(fruitw);
            display2.setTooltip();
            y += th2;
        }
    }
    new ControlText(contents, new Area(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.YIELD) + " : ", TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), genome.getYield() + "x", TextJustification.MIDDLE_LEFT);
    y += th;
    new ControlText(contents, new Area(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.SAPPINESS) + " : ", TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), genome.getSappiness() + "x", TextJustification.MIDDLE_LEFT);
    y += th;
    new ControlText(contents, new Area(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.MATURATION) + " : ", TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), genome.getMaturationTime() + "x", TextJustification.MIDDLE_LEFT);
    y += th;
    new ControlText(contents, new Area(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.GIRTH) + " : ", TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), genome.getGirth() + "x" + genome.getGirth(), TextJustification.MIDDLE_LEFT);
    y += th;
    contents.setSize(new Point(contents.getSize().xPos(), y));
    scrollable.setScrollableContent(contents);
}
Also used : ControlItemDisplay(binnie.core.gui.minecraft.control.ControlItemDisplay) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ArrayList(java.util.ArrayList) World(net.minecraft.world.World) IFruitProvider(forestry.api.arboriculture.IFruitProvider) IAlleleTreeSpecies(forestry.api.arboriculture.IAlleleTreeSpecies) Control(binnie.core.gui.controls.core.Control) ResourceLocation(net.minecraft.util.ResourceLocation) ControlText(binnie.core.gui.controls.ControlText) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem) ITree(forestry.api.arboriculture.ITree) Point(binnie.core.gui.geometry.Point) Minecraft(net.minecraft.client.Minecraft) Point(binnie.core.gui.geometry.Point) IAllele(forestry.api.genetics.IAllele) Area(binnie.core.gui.geometry.Area) TextureMap(net.minecraft.client.renderer.texture.TextureMap) ILeafSpriteProvider(forestry.api.arboriculture.ILeafSpriteProvider) ItemStack(net.minecraft.item.ItemStack) ITreeGenome(forestry.api.arboriculture.ITreeGenome) ControlScrollableContent(binnie.core.gui.controls.scroll.ControlScrollableContent)

Example 17 with IBreedingSystem

use of binnie.core.api.genetics.IBreedingSystem in project Binnie by ForestryMC.

the class ControlGene method getTooltip.

@Override
public void getTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) {
    IBreedingSystem system = Binnie.GENETICS.getSystem(this.gene.getSpeciesRoot());
    final String cName = system.getChromosomeName(this.gene.getChromosome());
    tooltip.add(cName + ": " + this.gene.getName());
    if (this.isMouseOver() && this.canFill(Window.get(this).getHeldItemStack())) {
        tooltip.add("Left click to assign gene");
        final IGene existingGene = Engineering.getGene(Window.get(this).getHeldItemStack(), this.gene.getChromosome().ordinal());
        if (existingGene == null) {
            return;
        }
        final String dName = system.getChromosomeName(this.gene.getChromosome());
        tooltip.add("Will replace " + dName + ": " + existingGene.getName());
    }
}
Also used : IGene(binnie.core.api.genetics.IGene) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem)

Example 18 with IBreedingSystem

use of binnie.core.api.genetics.IBreedingSystem in project Binnie by ForestryMC.

the class ControlIndividualDisplay method setSpecies.

public void setSpecies(final IAlleleSpecies species, EnumDiscoveryState state) {
    final ISpeciesRoot speciesRoot = Binnie.GENETICS.getSpeciesRoot(species);
    final IBreedingSystem system = Binnie.GENETICS.getSystem(speciesRoot);
    final IAllele[] template = system.getSpeciesRoot().getTemplate(species);
    final IIndividual ind = system.getSpeciesRoot().templateAsIndividual(template);
    super.setItemStack(system.getSpeciesRoot().getMemberStack(ind, system.getDefaultType()));
    this.species = species;
    final GameProfile username = Window.get(this).getUsername();
    if (state == EnumDiscoveryState.UNDETERMINED) {
        state = (system.isSpeciesDiscovered(species, Window.get(this).getWorld(), username) ? EnumDiscoveryState.DISCOVERED : EnumDiscoveryState.UNDISCOVERED);
    }
    if (Window.get(this) instanceof WindowAbstractDatabase && ((WindowAbstractDatabase) Window.get(this)).isMaster()) {
        state = EnumDiscoveryState.SHOW;
    }
    this.discovered = state;
    this.addAttribute(Attribute.MOUSE_OVER);
}
Also used : IAllele(forestry.api.genetics.IAllele) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual) GameProfile(com.mojang.authlib.GameProfile) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem)

Example 19 with IBreedingSystem

use of binnie.core.api.genetics.IBreedingSystem 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);
        }
    }
}
Also used : IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem)

Example 20 with IBreedingSystem

use of binnie.core.api.genetics.IBreedingSystem 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);
    }
}
Also used : GameProfile(com.mojang.authlib.GameProfile) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) ArrayList(java.util.ArrayList) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem)

Aggregations

IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)22 ArrayList (java.util.ArrayList)8 IAllele (forestry.api.genetics.IAllele)7 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)6 IChromosomeType (forestry.api.genetics.IChromosomeType)5 IIndividual (forestry.api.genetics.IIndividual)5 ItemStack (net.minecraft.item.ItemStack)5 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)5 IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)4 Gene (binnie.core.genetics.Gene)3 Point (binnie.core.gui.geometry.Point)3 ControlPlayerInventory (binnie.core.gui.minecraft.control.ControlPlayerInventory)3 List (java.util.List)3 IGene (binnie.core.api.genetics.IGene)2 BreedingSystem (binnie.core.genetics.BreedingSystem)2 ControlText (binnie.core.gui.controls.ControlText)2 Control (binnie.core.gui.controls.core.Control)2 ControlScrollableContent (binnie.core.gui.controls.scroll.ControlScrollableContent)2 Area (binnie.core.gui.geometry.Area)2 ControlItemDisplay (binnie.core.gui.minecraft.control.ControlItemDisplay)2