port to forestry 4.2

This commit is contained in:
marcin212 committed 2016-10-20 02:56:31 +02:00
1 parent dbc5c1a564
commit f969f63b66
3697 files changed
+78372

No files matched your search

@@ -0,0 +1,71 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import forestry.api.genetics.IAlleleSpecies;
import binnie.botany.api.EnumFlowerStage;
import binnie.craftgui.core.geometry.IPoint;
import binnie.craftgui.core.CraftGUI;
import org.lwjgl.opengl.GL11;
import binnie.craftgui.minecraft.control.ControlIconDisplay;
import binnie.craftgui.botany.ControlColourDisplay;
import binnie.craftgui.controls.ControlTextCentered;
import binnie.botany.api.IFlower;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.core.IWidget;
public class AnalystPageAppearance extends ControlAnalystPage
{
public AnalystPageAppearance(final IWidget parent, final IArea area, final IFlower ind) {
super(parent, area);
this.setColour(3355443);
int y = 4;
final IAlleleSpecies species = ind.getGenome().getPrimary();
new ControlTextCentered(this, y, "§nAppearance").setColour(this.getColour());
y += 12;
final ControlColourDisplay a = new ControlColourDisplay(this, this.w() / 2.0f - 28.0f, y);
a.setValue(ind.getGenome().getPrimaryColor());
a.addTooltip("Primary Petal Colour");
final ControlColourDisplay b = new ControlColourDisplay(this, this.w() / 2.0f - 8.0f, y);
b.setValue(ind.getGenome().getSecondaryColor());
b.addTooltip("Secondary Petal Colour");
final ControlColourDisplay c = new ControlColourDisplay(this, this.w() / 2.0f + 12.0f, y);
c.setValue(ind.getGenome().getStemColor());
c.addTooltip("Stem Colour");
y += 26;
final int sections = ind.getGenome().getType().getSections();
final int w = (sections > 1) ? 50 : 100;
new ControlIconDisplay(this, (this.w() - w) / 2.0f, y - ((sections == 1) ? 0 : 0), null) {
@Override
public void onRenderForeground() {
GL11.glPushMatrix();
final float scale = w / 16.0f;
final float dy = (sections > 1) ? 16.0f : 0.0f;
GL11.glScalef(scale, scale, 1.0f);
CraftGUI.Render.colour(ind.getGenome().getStemColor().getColor(false));
if (sections > 1) {
CraftGUI.Render.iconBlock(new IPoint(0.0f, 0.0f), ind.getGenome().getType().getStem(EnumFlowerStage.FLOWER, true, 1));
}
CraftGUI.Render.iconBlock(new IPoint(0.0f, dy), ind.getGenome().getType().getStem(EnumFlowerStage.FLOWER, true, 0));
CraftGUI.Render.colour(ind.getGenome().getPrimaryColor().getColor(false));
if (sections > 1) {
CraftGUI.Render.iconBlock(new IPoint(0.0f, 0.0f), ind.getGenome().getType().getPetalIcon(EnumFlowerStage.FLOWER, true, 1));
}
CraftGUI.Render.iconBlock(new IPoint(0.0f, dy), ind.getGenome().getType().getPetalIcon(EnumFlowerStage.FLOWER, true, 0));
CraftGUI.Render.colour(ind.getGenome().getSecondaryColor().getColor(false));
if (sections > 1) {
CraftGUI.Render.iconBlock(new IPoint(0.0f, 0.0f), ind.getGenome().getType().getVariantIcon(EnumFlowerStage.FLOWER, true, 1));
}
CraftGUI.Render.iconBlock(new IPoint(0.0f, dy), ind.getGenome().getType().getVariantIcon(EnumFlowerStage.FLOWER, true, 0));
GL11.glPopMatrix();
}
};
}
@Override
public String getTitle() {
return "Appearance";
}
}
@@ -0,0 +1,76 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import forestry.api.lepidopterology.IAlleleButterflyEffect;
import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.genetics.IChromosomeType;
import forestry.api.lepidopterology.EnumButterflyChromosome;
import binnie.Binnie;
import forestry.api.lepidopterology.IButterfly;
import binnie.craftgui.core.CraftGUI;
import binnie.craftgui.controls.ControlText;
import binnie.craftgui.core.geometry.TextJustification;
import binnie.core.BinnieCore;
import forestry.plugins.PluginApiculture;
import forestry.api.apiculture.IBee;
import binnie.craftgui.controls.ControlTextCentered;
import forestry.api.genetics.IIndividual;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.core.IWidget;
public class AnalystPageBehaviour extends ControlAnalystPage
{
public AnalystPageBehaviour(final IWidget parent, final IArea area, final IIndividual ind) {
super(parent, area);
this.setColour(6684723);
int y = 4;
new ControlTextCentered(this, y, "§nBehaviour").setColour(this.getColour());
y += 12;
if (ind instanceof IBee) {
final IBee bee = (IBee) ind;
y += 8;
final int fertility = bee.getGenome().getFlowering();
new ControlTextCentered(this, y, "Pollinates nearby\n" + bee.getGenome().getFlowerProvider().getDescription()).setColour(this.getColour());
y += 20;
new ControlTextCentered(this, y, "§oEvery " + this.getTimeString(PluginApiculture.ticksPerBeeWorkCycle * 100.0f / fertility)).setColour(this.getColour());
y += 22;
final IAlleleBeeEffect effect = bee.getGenome().getEffect();
final int[] t = bee.getGenome().getTerritory();
if (!effect.getUID().contains("None")) {
final String effectDesc = BinnieCore.proxy.localiseOrBlank("allele." + effect.getUID() + ".desc");
final String loc = effectDesc.equals("") ? ("Effect: " + effect.getName()) : effectDesc;
new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 0.0f), loc, TextJustification.TopCenter).setColour(this.getColour());
y += (int) (CraftGUI.Render.textHeight(loc, this.w() - 8.0f) + 1.0f);
new ControlTextCentered(this, y, "§oWithin " + (int) (t[0] / 2.0f) + " blocks").setColour(this.getColour());
y += 22;
}
new ControlTextCentered(this, y, "Territory: §o" + t[0] + "x" + t[1] + "x" + t[2]).setColour(this.getColour());
y += 22;
}
if (ind instanceof IButterfly) {
final IButterfly bee2 = (IButterfly) ind;
new ControlTextCentered(this, y, "§oMetabolism: " + Binnie.Genetics.mothBreedingSystem.getAlleleName(EnumButterflyChromosome.METABOLISM, ind.getGenome().getActiveAllele(EnumButterflyChromosome.METABOLISM))).setColour(this.getColour());
y += 20;
new ControlTextCentered(this, y, "Pollinates nearby\n" + bee2.getGenome().getFlowerProvider().getDescription()).setColour(this.getColour());
y += 20;
new ControlTextCentered(this, y, "§oEvery " + this.getTimeString(1500.0f)).setColour(this.getColour());
y += 22;
final IAlleleButterflyEffect effect2 = bee2.getGenome().getEffect();
if (!effect2.getUID().contains("None")) {
final String effectDesc2 = BinnieCore.proxy.localiseOrBlank("allele." + effect2.getUID() + ".desc");
final String loc2 = effectDesc2.equals("") ? ("Effect: " + effect2.getName()) : effectDesc2;
new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 0.0f), loc2, TextJustification.TopCenter).setColour(this.getColour());
y += (int) (CraftGUI.Render.textHeight(loc2, this.w() - 8.0f) + 1.0f);
y += 22;
}
}
}
@Override
public String getTitle() {
return "Behaviour";
}
}
@@ -0,0 +1,181 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import java.text.DecimalFormat;
import binnie.craftgui.core.geometry.IPoint;
import binnie.botany.api.IFlower;
import net.minecraftforge.common.EnumPlantType;
import forestry.plugins.PluginApiculture;
import forestry.api.genetics.IChromosomeType;
import forestry.api.arboriculture.EnumTreeChromosome;
import binnie.Binnie;
import forestry.api.arboriculture.ITree;
import forestry.api.lepidopterology.IButterfly;
import binnie.craftgui.minecraft.control.ControlIconDisplay;
import binnie.genetics.item.ModuleItem;
import forestry.api.apiculture.IBee;
import binnie.craftgui.controls.ControlTextCentered;
import forestry.api.genetics.IIndividual;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.core.IWidget;
public class AnalystPageBiology extends ControlAnalystPage
{
public AnalystPageBiology(final IWidget parent, final IArea area, final IIndividual ind) {
super(parent, area);
this.setColour(26214);
int y = 4;
new ControlTextCentered(this, y, "§nBiology").setColour(this.getColour());
y += 12;
if (ind instanceof IBee) {
final IBee bee = (IBee) ind;
if (bee.getGenome().getNocturnal()) {
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f, y, ModuleItem.iconAllDay.getIcon()).addTooltip("Active all day and night");
}
else if (bee.getGenome().getPrimary().isNocturnal()) {
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f, y, ModuleItem.iconNight.getIcon()).addTooltip("Active at night");
}
else {
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f, y, ModuleItem.iconDaytime.getIcon()).addTooltip("Active during the day");
}
if (!bee.getGenome().getTolerantFlyer()) {
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f + 24.0f, y, ModuleItem.iconNoRain.getIcon()).addTooltip("Cannot work during rain");
}
else {
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f + 24.0f, y, ModuleItem.iconRain.getIcon()).addTooltip("Can work during rain");
}
if (bee.getGenome().getCaveDwelling()) {
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f + 48.0f, y, ModuleItem.iconNoSky.getIcon()).addTooltip("Can work underground");
}
else {
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f + 48.0f, y, ModuleItem.iconSky.getIcon()).addTooltip("Cannot work underground");
}
y += 30;
}
else if (ind instanceof IButterfly) {
final IButterfly moth = (IButterfly) ind;
if (moth.getGenome().getNocturnal()) {
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f, y, ModuleItem.iconAllDay.getIcon()).addTooltip("Active all day and night");
}
else if (moth.getGenome().getPrimary().isNocturnal()) {
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f, y, ModuleItem.iconNight.getIcon()).addTooltip("Active at night");
}
else {
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f, y, ModuleItem.iconDaytime.getIcon()).addTooltip("Active during the day");
}
if (!moth.getGenome().getTolerantFlyer()) {
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f + 24.0f, y, ModuleItem.iconNoRain.getIcon()).addTooltip("Cannot work during rain");
}
else {
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f + 24.0f, y, ModuleItem.iconRain.getIcon()).addTooltip("Can work during rain");
}
if (moth.getGenome().getFireResist()) {
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f + 48.0f, y, ModuleItem.iconNoFire.getIcon()).addTooltip("Nonflammable");
}
else {
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f + 48.0f, y, ModuleItem.iconFire.getIcon()).addTooltip("Flammable");
}
y += 30;
}
else if (ind instanceof ITree) {
new ControlTextCentered(this, y, "§oSappiness: " + Binnie.Genetics.treeBreedingSystem.getAlleleName(EnumTreeChromosome.SAPPINESS, ind.getGenome().getActiveAllele(EnumTreeChromosome.SAPPINESS))).setColour(this.getColour());
y += 20;
}
else {
y += 10;
}
if (ind instanceof IBee) {
final IBee bee = (IBee) ind;
final int fertility = bee.getGenome().getFertility();
new ControlTextCentered(this, y, "§l" + fertility + "§r drone" + ((fertility > 1) ? "s" : "") + " per hive").setColour(this.getColour());
y += 22;
final int lifespan = bee.getGenome().getLifespan() * PluginApiculture.ticksPerBeeWorkCycle;
new ControlTextCentered(this, y, "Average Lifespan").setColour(this.getColour());
y += 12;
new ControlTextCentered(this, y, "§l" + this.getMCDayString(lifespan * (bee.getGenome().getNocturnal() ? 1.0f : 2.0f))).setColour(this.getColour());
y += 22;
}
if (ind instanceof IButterfly) {
final IButterfly bee2 = (IButterfly) ind;
final int fertility = bee2.getGenome().getFertility();
new ControlTextCentered(this, y, "Lays §l" + fertility + "§r caterpillar" + ((fertility > 1) ? "s" : "") + " before dying").setColour(this.getColour());
y += 32;
final float caterpillarMatureTime = 1365.3999f * Math.round(bee2.getGenome().getLifespan() / (bee2.getGenome().getFertility() * 2));
new ControlTextCentered(this, y, "Caterpillar Gestation").setColour(this.getColour());
y += 12;
new ControlTextCentered(this, y, "§l" + this.getMCDayString(caterpillarMatureTime)).setColour(this.getColour());
y += 22;
final int speed = (int) (20.0f * bee2.getGenome().getSpeed());
new ControlTextCentered(this, y, "Flight Speed").setColour(this.getColour());
y += 12;
new ControlTextCentered(this, y, "§l" + speed + "§r blocks per second").setColour(this.getColour());
y += 22;
}
if (ind instanceof ITree) {
final ITree tree = (ITree) ind;
final int fertility = (int) (1.0f / tree.getGenome().getFertility());
new ControlTextCentered(this, y, "1 Sapling per §l" + fertility + "§r leave" + ((fertility > 1) ? "s" : "")).setColour(this.getColour());
y += 22;
final float butterflySpawn = 1365.3999f / (tree.getGenome().getSappiness() * tree.getGenome().getYield() * 0.5f);
new ControlTextCentered(this, y, "Butterfies spawn every\n" + this.getTimeString(butterflySpawn) + " per leaf").setColour(this.getColour());
y += 34;
new ControlTextCentered(this, y, "Plant Types").setColour(this.getColour());
y += 12;
for (final EnumPlantType type : tree.getGenome().getPlantTypes()) {
new ControlTextCentered(this, y, "§o" + type.name()).setColour(this.getColour());
y += 12;
}
}
if (ind instanceof IFlower) {
final IFlower flower = (IFlower) ind;
final float butterflySpawn2 = 1365.3999f / (flower.getGenome().getSappiness() * 0.2f);
new ControlTextCentered(this, y, "Butterfies spawn every\n" + this.getTimeString(butterflySpawn2)).setColour(this.getColour());
y += 30;
float CHANCE_DISPERSAL = 0.8f;
CHANCE_DISPERSAL += 0.2f * flower.getGenome().getFertility();
float CHANCE_POLLINATE = 0.6f;
CHANCE_POLLINATE += 0.25f * flower.getGenome().getFertility();
final float CHANCE_SELFPOLLINATE = 0.2f * CHANCE_POLLINATE;
if (CHANCE_DISPERSAL > 1.0f) {
CHANCE_DISPERSAL = 1.0f;
}
if (CHANCE_POLLINATE > 1.0f) {
CHANCE_POLLINATE = 1.0f;
}
final float dispersalTime = 1365.3999f / CHANCE_DISPERSAL;
final float pollinateTime = 1365.3999f / CHANCE_POLLINATE;
final float lifespan2 = flower.getMaxAge() * 20.0f * 68.27f / flower.getGenome().getAgeChance();
float floweringLifespan = (flower.getMaxAge() - 1) * 20.0f * 68.27f / flower.getGenome().getAgeChance();
floweringLifespan -= 1365.3999f;
new ControlTextCentered(this, y, "Average Lifespan").setColour(this.getColour());
y += 12;
new ControlTextCentered(this, y, "§l" + this.getMCDayString(lifespan2)).setColour(this.getColour());
y += 22;
new ControlTextCentered(this, y, "Seed Dispersal").setColour(this.getColour());
y += 12;
new ControlTextCentered(this, y, "§o" + (int) (floweringLifespan / dispersalTime) + " per lifetime").setColour(this.getColour());
y += 22;
new ControlTextCentered(this, y, "Pollination").setColour(this.getColour());
y += 12;
new ControlTextCentered(this, y, "§o" + (int) (floweringLifespan / pollinateTime) + " per lifetime").setColour(this.getColour());
y += 22;
}
this.setSize(new IPoint(this.w(), y));
}
private String getMCDayString(final float time) {
final float seconds = time / 20.0f;
final float minutes = seconds / 60.0f;
final float days = minutes / 20.0f;
final DecimalFormat df = new DecimalFormat("#.0");
return df.format(days) + " MC days";
}
@Override
public String getTitle() {
return "Biology";
}
}
@@ -0,0 +1,136 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import java.util.List;
import binnie.craftgui.core.geometry.IPoint;
import forestry.api.core.EnumHumidity;
import binnie.core.genetics.Tolerance;
import forestry.api.core.EnumTemperature;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraft.world.biome.BiomeGenBase;
import java.util.ArrayList;
import binnie.craftgui.controls.ControlText;
import binnie.craftgui.core.geometry.TextJustification;
import binnie.craftgui.controls.ControlTextCentered;
import forestry.api.lepidopterology.EnumButterflyChromosome;
import forestry.api.lepidopterology.IButterfly;
import binnie.botany.api.EnumFlowerChromosome;
import binnie.botany.api.IFlower;
import forestry.api.genetics.IChromosomeType;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.genetics.IAlleleTolerance;
import forestry.api.apiculture.IBee;
import forestry.api.genetics.EnumTolerance;
import forestry.api.genetics.IIndividual;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.core.IWidget;
public class AnalystPageClimate extends ControlAnalystPage
{
public AnalystPageClimate(final IWidget parent, final IArea area, final IIndividual ind) {
super(parent, area);
this.setColour(26163);
final EnumTemperature temp = ind.getGenome().getPrimary().getTemperature();
EnumTolerance tempTol = EnumTolerance.NONE;
final EnumHumidity humid = ind.getGenome().getPrimary().getHumidity();
EnumTolerance humidTol = EnumTolerance.NONE;
if (ind instanceof IBee) {
tempTol = ((IAlleleTolerance) ind.getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE)).getValue();
humidTol = ((IAlleleTolerance) ind.getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE)).getValue();
}
if (ind instanceof IFlower) {
tempTol = ((IAlleleTolerance) ind.getGenome().getActiveAllele(EnumFlowerChromosome.TEMPERATURE_TOLERANCE)).getValue();
humidTol = EnumTolerance.BOTH_5;
}
if (ind instanceof IButterfly) {
tempTol = ((IAlleleTolerance) ind.getGenome().getActiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE)).getValue();
humidTol = ((IAlleleTolerance) ind.getGenome().getActiveAllele(EnumButterflyChromosome.HUMIDITY_TOLERANCE)).getValue();
}
int y = 4;
new ControlTextCentered(this, y, "§nClimate").setColour(this.getColour());
y += 16;
new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 14.0f), "Temp. Tolerance", TextJustification.MiddleCenter).setColour(this.getColour());
y += 12;
this.createTemperatureBar(this, (this.w() - 100.0f) / 2.0f, y, 100.0f, 10.0f, temp, tempTol);
y += 16;
if (!(ind instanceof IFlower)) {
new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 14.0f), "Humidity Tolerance", TextJustification.MiddleCenter).setColour(this.getColour());
y += 12;
this.createHumidity(this, (this.w() - 100.0f) / 2.0f, y, 100.0f, 10.0f, humid, humidTol);
y += 16;
}
new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 14.0f), "Biomes", TextJustification.MiddleCenter).setColour(this.getColour());
y += 12;
final List<BiomeGenBase> biomes = new ArrayList<BiomeGenBase>();
for (final BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) {
if (biome != null) {
if (BiomeDictionary.isBiomeRegistered(biome)) {
if (biome != BiomeGenBase.frozenOcean) {
if (Tolerance.canTolerate(temp, EnumTemperature.getFromBiome(biome), tempTol)) {
if (Tolerance.canTolerate(humid, EnumHumidity.getFromValue(biome.rainfall), humidTol)) {
boolean match = false;
for (final BiomeGenBase eBiome : biomes) {
if (biome.biomeName.contains(eBiome.biomeName) && EnumHumidity.getFromValue(eBiome.rainfall) == EnumHumidity.getFromValue(biome.rainfall) && EnumTemperature.getFromBiome(eBiome) == EnumTemperature.getFromBiome(biome)) {
match = true;
}
}
if (!match) {
biomes.add(biome);
}
}
}
}
}
}
}
final int maxBiomePerLine = (int) ((this.w() + 2.0f - 16.0f) / 18.0f);
final float biomeListX = (this.w() - (Math.min(maxBiomePerLine, biomes.size()) * 18 - 2)) / 2.0f;
int dx = 0;
int dy = 0;
for (final BiomeGenBase biome2 : biomes) {
new ControlBiome(this, biomeListX + dx, y + dy, 16.0f, 16.0f, biome2);
dx += 18;
if (dx >= 18 * maxBiomePerLine) {
dx = 0;
dy += 18;
}
}
this.setSize(new IPoint(this.w(), y + dy + 18 + 8));
}
protected void createTemperatureBar(final IWidget parent, final float x, final float y, final float w, final float h, final EnumTemperature value, final EnumTolerance tol) {
new ControlToleranceBar<EnumTemperature>(parent, x, y, w, h, EnumTemperature.class) {
@Override
protected String getName(final EnumTemperature value) {
return value.name;
}
@Override
protected int getColour(final EnumTemperature value) {
return (new int[] { 65531, 7912447, 5242672, 16776960, 16753152, 16711680 })[value.ordinal() - 1];
}
}.setValues(value, tol);
}
protected void createHumidity(final IWidget parent, final float x, final float y, final float w, final float h, final EnumHumidity value, final EnumTolerance tol) {
new ControlToleranceBar<EnumHumidity>(parent, x, y, w, h, EnumHumidity.class) {
@Override
protected String getName(final EnumHumidity value) {
return value.name;
}
@Override
protected int getColour(final EnumHumidity value) {
return (new int[] { 16770979, 1769216, 3177727 })[value.ordinal()];
}
}.setValues(value, tol);
}
@Override
public String getTitle() {
return "Climate";
}
}
@@ -0,0 +1,187 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import binnie.craftgui.core.geometry.IPoint;
import binnie.craftgui.events.EventMouse;
import forestry.api.genetics.IIndividual;
import binnie.craftgui.controls.scroll.ControlScrollBar;
import binnie.craftgui.core.geometry.TextJustification;
import binnie.craftgui.controls.core.Control;
import binnie.craftgui.controls.listbox.ControlListBox;
import forestry.api.genetics.IChromosomeType;
import forestry.api.arboriculture.EnumTreeChromosome;
import binnie.craftgui.window.Panel;
import binnie.craftgui.minecraft.MinecraftGUI;
import binnie.craftgui.resource.minecraft.CraftGUITexture;
import binnie.craftgui.core.CraftGUI;
import java.util.Collection;
import forestry.api.genetics.IAlleleSpecies;
import java.util.ArrayList;
import binnie.craftgui.controls.ControlTextEdit;
import binnie.craftgui.controls.ControlTextCentered;
import binnie.core.genetics.BreedingSystem;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.controls.scroll.ControlScrollableContent;
public class AnalystPageDatabase extends ControlAnalystPage
{
ControlScrollableContent scroll;
boolean isMaster;
public AnalystPageDatabase(final IWidget parent, final IArea area, final BreedingSystem system, final boolean isMaster) {
super(parent, area);
this.scroll = null;
this.isMaster = isMaster;
final int cOfSystem = system.getColour();
final int cr = (0xFF0000 & cOfSystem) >> 16;
final int cg = (0xFF00 & cOfSystem) >> 8;
final int cb = 0xFF & cOfSystem;
float brightness = 0.1f * cb / 255.0f + 0.35f * cr / 255.0f + 0.55f * cg / 255.0f;
brightness = 0.3f / brightness;
if (brightness > 1.0f) {
brightness = 1.0f;
}
final int newColour = (int) (cr * brightness) * 65536 + (int) (cg * brightness) * 256 + (int) (cb * brightness);
this.setColour(newColour);
int y = 4;
new ControlTextCentered(this, y, "§nRegistry").setColour(this.getColour());
y += 16;
new ControlTextEdit(this, 20.0f, y, this.w() - 40.0f, 16.0f) {
@Override
public void onTextEdit(final String value) {
final Collection<IAlleleSpecies> options = new ArrayList<IAlleleSpecies>();
AnalystPageDatabase.this.getSpecies(system);
for (final IAlleleSpecies species : AnalystPageDatabase.this.getSpecies(system)) {
if (value != null) {
if (value != "") {
if (!species.getName().toLowerCase().contains(value.toLowerCase())) {
continue;
}
}
}
options.add(species);
}
AnalystPageDatabase.this.scroll.deleteAllChildren();
AnalystPageDatabase.this.scroll.setScrollableContent(AnalystPageDatabase.this.getItemScrollList(system, options));
}
@Override
public void onRenderBackground() {
CraftGUI.Render.colour(5592405);
CraftGUI.Render.texture(CraftGUITexture.TabSolid, this.getArea().inset(1));
CraftGUI.Render.colour(AnalystPageDatabase.this.getColour());
CraftGUI.Render.texture(CraftGUITexture.TabOutline, this.getArea());
super.renderTextField();
}
};
y += 22;
new Panel(this, 3.0f, y - 1, this.w() - 6.0f, this.h() - y - 8.0f + 2.0f, MinecraftGUI.PanelType.TabOutline).setColour(this.getColour());
final boolean textView = false;
final Collection<IAlleleSpecies> options = this.getSpecies(system);
for (final IAlleleSpecies species : options) {
final String height = system.getAlleleName(EnumTreeChromosome.HEIGHT, system.getIndividual(species.getUID()).getGenome().getActiveAllele(EnumTreeChromosome.HEIGHT));
final String fertility = system.getAlleleName(EnumTreeChromosome.FERTILITY, system.getIndividual(species.getUID()).getGenome().getActiveAllele(EnumTreeChromosome.FERTILITY));
final String yield = system.getAlleleName(EnumTreeChromosome.YIELD, system.getIndividual(species.getUID()).getGenome().getActiveAllele(EnumTreeChromosome.YIELD));
final String sappiness = system.getAlleleName(EnumTreeChromosome.SAPPINESS, system.getIndividual(species.getUID()).getGenome().getActiveAllele(EnumTreeChromosome.SAPPINESS));
final String maturation = system.getAlleleName(EnumTreeChromosome.MATURATION, system.getIndividual(species.getUID()).getGenome().getActiveAllele(EnumTreeChromosome.MATURATION));
}
if (textView) {
this.scroll = new ControlListBox<IAlleleSpecies>(this, 4.0f, y, this.w() - 8.0f, this.h() - y - 8.0f - 20.0f, 0.0f) {
@Override
public void initialise() {
super.initialise();
this.setOptions(options);
}
@Override
public IWidget createOption(final IAlleleSpecies v, final int y) {
return new Control(this.getContent(), 0.0f, y, this.w(), 12.0f) {
IAlleleSpecies value = v;
@Override
public void onRenderBackground() {
CraftGUI.Render.text(this.getArea(), TextJustification.MiddleCenter, this.value.getName(), 16777215);
}
};
}
};
}
else {
(this.scroll = new ControlScrollableContent(this, 4.0f, y, this.w() - 8.0f, this.h() - y - 8.0f, 0.0f)).setScrollableContent(this.getItemScrollList(system, options));
}
new ControlScrollBar(this, this.scroll.x() + this.scroll.w() - 6.0f, this.scroll.y() + 3.0f, 3.0f, this.scroll.h() - 6.0f, this.scroll) {
@Override
public void onRenderBackground() {
if (!this.isEnabled()) {
return;
}
CraftGUI.Render.gradientRect(this.getArea(), 1140850688 + AnalystPageDatabase.this.getColour(), 1140850688 + AnalystPageDatabase.this.getColour());
CraftGUI.Render.solid(this.getRenderArea(), AnalystPageDatabase.this.getColour());
}
};
}
private IWidget getItemScrollList(final BreedingSystem system, final Collection<IAlleleSpecies> options) {
return new Control(this.scroll, 0.0f, 0.0f, this.scroll.w(), this.scroll.h()) {
@Override
public void initialise() {
final int maxBiomePerLine = (int) ((this.w() - 4.0f + 2.0f) / 18.0f);
final float biomeListX = -6.0f + (this.w() - (maxBiomePerLine * 18 - 2)) / 2.0f;
int dx = 0;
int dy = 0;
for (final IAlleleSpecies species : options) {
final IIndividual ind = system.getSpeciesRoot().templateAsIndividual(system.getSpeciesRoot().getTemplate(species.getUID()));
new ControlIndividualDisplay(this, biomeListX + dx, 2 + dy, ind) {
@Override
public void initialise() {
this.addSelfEventHandler(new EventMouse.Down.Handler() {
@Override
public void onEvent(final EventMouse.Down event) {
final WindowAnalyst window = (WindowAnalyst) AnalystPageDatabase.this.getSuperParent();
window.setIndividual(ind);
}
});
}
@Override
public void onRenderBackground() {
final WindowAnalyst window = (WindowAnalyst) AnalystPageDatabase.this.getSuperParent();
if (window.getIndividual() != null && window.getIndividual().getGenome().getPrimary() == species) {
CraftGUI.Render.colour(15658734);
CraftGUI.Render.texture(CraftGUITexture.TabSolid, this.getArea().outset(1));
CraftGUI.Render.colour(AnalystPageDatabase.this.getColour());
CraftGUI.Render.texture(CraftGUITexture.TabOutline, this.getArea().outset(1));
}
else if (this.calculateIsMouseOver()) {
CraftGUI.Render.colour(15658734);
CraftGUI.Render.texture(CraftGUITexture.TabSolid, this.getArea().outset(1));
}
super.onRenderBackground();
}
};
dx += 18;
if (dx >= 18 * maxBiomePerLine) {
dx = 0;
dy += 18;
}
}
this.setSize(new IPoint(this.w(), 4 + dy + 18));
}
};
}
@Override
public String getTitle() {
return "Registry";
}
private Collection<IAlleleSpecies> getSpecies(final BreedingSystem system) {
final Collection<IAlleleSpecies> species = new ArrayList<IAlleleSpecies>();
species.addAll(this.isMaster ? system.getAllSpecies() : system.getDiscoveredSpecies(this.getWindow().getWorld(), this.getWindow().getPlayer().getGameProfile()));
return species;
}
}
@@ -0,0 +1,75 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import forestry.api.genetics.IAlleleSpecies;
import binnie.craftgui.core.geometry.IPoint;
import binnie.craftgui.controls.ControlText;
import binnie.craftgui.core.geometry.TextJustification;
import binnie.craftgui.core.CraftGUI;
import binnie.craftgui.controls.ControlTextCentered;
import forestry.api.genetics.IIndividual;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.core.IWidget;
public class AnalystPageDescription extends ControlAnalystPage
{
public AnalystPageDescription(final IWidget parent, final IArea area, final IIndividual ind) {
super(parent, area);
this.setColour(3355443);
int y = 4;
final IAlleleSpecies species = ind.getGenome().getPrimary();
final String branchBinomial = (species.getBranch() != null) ? species.getBranch().getScientific() : "<Unknown>";
final String branchName = (species.getBranch() != null) ? species.getBranch().getName() : "Unknown";
final String desc = species.getDescription();
String descBody = "§o";
String descSig = "";
if (desc == null || desc == "" || desc.contains("for.description")) {
descBody += "";
}
else {
final String[] descStrings = desc.split("\\|");
descBody += descStrings[0];
for (int i = 1; i < descStrings.length - 1; ++i) {
descBody = descBody + " " + descStrings[i];
}
if (descStrings.length > 1) {
descSig += descStrings[descStrings.length - 1];
}
}
String authority = species.getAuthority();
if (authority.contains("Binnie")) {
authority = "§1§l" + authority;
}
if (authority.contains("Sengir")) {
authority = "§2§l" + authority;
}
if (authority.contains("MysteriousAges")) {
authority = "§5§l" + authority;
}
new ControlTextCentered(this, y, "§nDescription").setColour(this.getColour());
y += 16;
new ControlTextCentered(this, y, species.getName() + "§r").setColour(this.getColour());
y += 10;
new ControlTextCentered(this, y, "§o" + branchBinomial + " " + species.getBinomial() + "§r").setColour(this.getColour());
y += 20;
new ControlTextCentered(this, y, "Discovered by §l" + authority + "§r").setColour(this.getColour());
y += (int) (3.0f + CraftGUI.Render.textHeight("Discovered by §l" + authority + "§r", this.w()));
new ControlTextCentered(this, y, "Genetic Complexity: " + species.getComplexity()).setColour(this.getColour());
y += 26;
final ControlText descText = new ControlText(this, new IArea(8.0f, y, this.w() - 16.0f, 0.0f), descBody + "§r", TextJustification.TopCenter);
final IWidget signatureText = new ControlText(this, new IArea(8.0f, y, this.w() - 16.0f, 0.0f), descSig + "§r", TextJustification.BottomRight);
descText.setColour(this.getColour());
signatureText.setColour(this.getColour());
final float descHeight = CraftGUI.Render.textHeight(descText.getValue(), descText.getSize().x());
signatureText.setPosition(new IPoint(signatureText.pos().x(), descText.getPosition().y() + descHeight + 10.0f));
this.setSize(new IPoint(this.w(), 20.0f + signatureText.y()));
}
@Override
public String getTitle() {
return "Description";
}
}
@@ -0,0 +1,143 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import java.lang.reflect.Field;
import forestry.api.arboriculture.ITreeGenome;
import binnie.craftgui.core.geometry.IPoint;
import net.minecraft.init.Items;
import forestry.api.arboriculture.IAlleleFruit;
import forestry.api.genetics.IFruitFamily;
import forestry.api.genetics.ISpeciesRoot;
import forestry.api.genetics.IAllele;
import java.util.Collection;
import binnie.craftgui.minecraft.control.ControlItemDisplay;
import net.minecraft.item.ItemStack;
import forestry.arboriculture.FruitProviderPod;
import binnie.core.util.UniqueItemStackSet;
import forestry.api.genetics.IChromosomeType;
import forestry.api.arboriculture.EnumTreeChromosome;
import binnie.Binnie;
import binnie.craftgui.controls.ControlTextCentered;
import forestry.api.arboriculture.ITree;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.core.IWidget;
public class AnalystPageFruit extends AnalystPageProduce
{
public AnalystPageFruit(final IWidget parent, final IArea area, final ITree ind) {
super(parent, area);
this.setColour(13382400);
final ITreeGenome genome = ind.getGenome();
int y = 4;
new ControlTextCentered(this, y, "§nFruit").setColour(this.getColour());
y += 12;
new ControlTextCentered(this, y, "§oYield: " + Binnie.Genetics.treeBreedingSystem.getAlleleName(EnumTreeChromosome.YIELD, ind.getGenome().getActiveAllele(EnumTreeChromosome.YIELD))).setColour(this.getColour());
y += 20;
final Collection<ItemStack> products = new UniqueItemStackSet();
final Collection<ItemStack> specialties = new UniqueItemStackSet();
final Collection<ItemStack> wiid = new UniqueItemStackSet();
for (final ItemStack stack : ind.getProduceList()) {
products.add(stack);
}
for (final ItemStack stack : ind.getSpecialtyList()) {
specialties.add(stack);
}
try {
if (ind.getGenome().getFruitProvider() instanceof FruitProviderPod) {
final FruitProviderPod pod = (FruitProviderPod) ind.getGenome().getFruitProvider();
final Field f = FruitProviderPod.class.getDeclaredField("drop");
f.setAccessible(true);
for (final ItemStack stack2 : (ItemStack[]) f.get(pod)) {
products.add(stack2);
}
}
} catch (Exception e) {
e.printStackTrace();
}
if (products.size() > 0) {
new ControlTextCentered(this, y, "Natural Fruit").setColour(this.getColour());
y += 10;
final int w = products.size() * 18 - 2;
final int i = 0;
for (final ItemStack stack : products) {
final ControlItemDisplay d = new ControlItemDisplay(this, (this.w() - w) / 2.0f + 18 * i, y);
d.setTooltip();
d.setItemStack(stack);
}
y += 26;
}
if (specialties.size() > 0) {
new ControlTextCentered(this, y, "Specialty Fruit").setColour(this.getColour());
y += 10;
final int w = products.size() * 18 - 2;
final int i = 0;
for (final ItemStack stack : specialties) {
final ControlItemDisplay d = new ControlItemDisplay(this, (this.w() - w) / 2.0f + 18 * i, y);
d.setTooltip();
d.setItemStack(stack);
}
y += 26;
}
final Collection<ItemStack> allProducts = new UniqueItemStackSet();
for (final ItemStack stack3 : products) {
allProducts.add(stack3);
}
for (final ItemStack stack3 : specialties) {
allProducts.add(stack3);
}
final Collection<ItemStack> refinedProducts = new UniqueItemStackSet();
refinedProducts.addAll(this.getAllProductsAndFluids(allProducts));
if (refinedProducts.size() > 0) {
y = this.getRefined("Refined Products", y, refinedProducts);
y += 8;
}
if (products.size() == 0 && specialties.size() == 0) {
new ControlTextCentered(this, y, "This tree has no \nfruits or nuts").setColour(this.getColour());
y += 28;
}
new ControlTextCentered(this, y, "Possible Fruits").setColour(this.getColour());
y += 12;
final Collection<IAllele> fruitAlleles = Binnie.Genetics.getChromosomeMap(Binnie.Genetics.getTreeRoot()).get(EnumTreeChromosome.FRUITS);
for (final IFruitFamily fam : ind.getGenome().getPrimary().getSuitableFruit()) {
final Collection<ItemStack> stacks = new UniqueItemStackSet();
for (final IAllele a : fruitAlleles) {
if (((IAlleleFruit) a).getProvider().getFamily() == fam) {
for (final ItemStack p : ((IAlleleFruit) a).getProvider().getProducts()) {
stacks.add(p);
}
for (final ItemStack p : ((IAlleleFruit) a).getProvider().getSpecialty()) {
stacks.add(p);
}
try {
if (a.getUID().contains("fruitCocoa")) {
stacks.add(new ItemStack(Items.dye, 1, 3));
}
else {
if (!(((IAlleleFruit) a).getProvider() instanceof FruitProviderPod)) {
continue;
}
final FruitProviderPod pod2 = (FruitProviderPod) ((IAlleleFruit) a).getProvider();
final Field field = FruitProviderPod.class.getDeclaredField("drop");
field.setAccessible(true);
for (final ItemStack stack4 : (ItemStack[]) field.get(pod2)) {
stacks.add(stack4);
}
}
} catch (Exception ex) {
}
}
}
y = this.getRefined("§o" + fam.getName(), y, stacks);
y += 2;
}
this.setSize(new IPoint(this.w(), y + 8));
}
@Override
public String getTitle() {
return "Fruit";
}
}
@@ -0,0 +1,65 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import forestry.api.genetics.IAllele;
import binnie.core.genetics.BreedingSystem;
import forestry.api.genetics.ISpeciesRoot;
import binnie.craftgui.core.geometry.IPoint;
import binnie.craftgui.controls.ControlText;
import binnie.craftgui.core.geometry.TextJustification;
import binnie.craftgui.core.CraftGUI;
import forestry.api.genetics.IChromosomeType;
import org.lwjgl.opengl.GL11;
import binnie.craftgui.controls.core.Control;
import binnie.Binnie;
import forestry.api.genetics.AlleleManager;
import binnie.craftgui.controls.ControlTextCentered;
import forestry.api.genetics.IIndividual;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.core.IWidget;
public class AnalystPageGenome extends ControlAnalystPage
{
boolean active;
public AnalystPageGenome(final IWidget parent, final IArea area, final boolean active, final IIndividual ind) {
super(parent, area);
this.active = active;
this.setColour(26265);
int y = 4;
new ControlTextCentered(this, y, "§n" + this.getTitle()).setColour(this.getColour());
y += 16;
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(ind.getClass());
final BreedingSystem system = Binnie.Genetics.getSystem(root);
final Control scaled = new Control(this, 0.0f, y, 0.0f, 0.0f) {
@Override
public void onRenderBackground() {
GL11.glPushMatrix();
GL11.glTranslatef(10.0f, -15.0f, 0.0f);
GL11.glScalef(0.9f, 0.95f, 1.0f);
}
@Override
public void onRenderForeground() {
GL11.glPopMatrix();
}
};
for (final IChromosomeType chromo : system.getActiveKaryotype()) {
final IAllele allele = active ? ind.getGenome().getActiveAllele(chromo) : ind.getGenome().getInactiveAllele(chromo);
final String alleleName = system.getAlleleName(chromo, allele);
final float height = CraftGUI.Render.textHeight(alleleName, this.w() / 2.0f - 2.0f);
new ControlText(scaled, new IArea(0.0f, y + (height - 9.0f) / 2.0f, this.w() / 2.0f - 2.0f, 0.0f), system.getChromosomeShortName(chromo) + " :", TextJustification.TopRight).setColour(this.getColour());
new ControlText(scaled, new IArea(this.w() / 2.0f + 2.0f, y, this.w() / 2.0f - 2.0f, 0.0f), alleleName, TextJustification.TopLeft).setColour(this.getColour());
y += (int) (3.0f + height);
}
this.setSize(new IPoint(this.w(), y + 8));
}
@Override
public String getTitle() {
return (this.active ? "Active" : "Inactive") + " Genome";
}
}
@@ -0,0 +1,52 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IChromosomeType;
import forestry.api.arboriculture.EnumTreeChromosome;
import binnie.Binnie;
import forestry.api.arboriculture.ITree;
import binnie.craftgui.controls.ControlTextCentered;
import forestry.api.genetics.IIndividual;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.core.IWidget;
public class AnalystPageGrowth extends ControlAnalystPage
{
public AnalystPageGrowth(final IWidget parent, final IArea area, final IIndividual ind) {
super(parent, area);
this.setColour(3355443);
int y = 4;
final IAlleleSpecies species = ind.getGenome().getPrimary();
new ControlTextCentered(this, y, "§nGrowth").setColour(this.getColour());
y += 12;
if (ind instanceof ITree) {
final ITree tree = (ITree) ind;
final int mat = tree.getGenome().getMaturationTime();
new ControlTextCentered(this, y, "Saplings mature in").setColour(this.getColour());
y += 12;
new ControlTextCentered(this, y, "§l" + this.getTimeString(1373.3999f * mat)).setColour(this.getColour());
y += 22;
new ControlTextCentered(this, y, "§oHeight: " + Binnie.Genetics.treeBreedingSystem.getAlleleName(EnumTreeChromosome.HEIGHT, ind.getGenome().getActiveAllele(EnumTreeChromosome.HEIGHT))).setColour(this.getColour());
y += 12;
new ControlTextCentered(this, y, "§oGirth: " + Binnie.Genetics.treeBreedingSystem.getAlleleName(EnumTreeChromosome.GIRTH, ind.getGenome().getActiveAllele(EnumTreeChromosome.GIRTH))).setColour(this.getColour());
y += 20;
new ControlTextCentered(this, y, "Growth Conditions").setColour(this.getColour());
y += 12;
new ControlTextCentered(this, y, "§o" + tree.getGenome().getGrowthProvider().getDescription()).setColour(this.getColour());
y += 12;
for (final String s : tree.getGenome().getGrowthProvider().getInfo()) {
new ControlTextCentered(this, y, "§o" + s).setColour(this.getColour());
y += 12;
}
}
}
@Override
public String getTitle() {
return "Growth";
}
}
@@ -0,0 +1,51 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import binnie.core.genetics.BreedingSystem;
import forestry.api.genetics.ISpeciesRoot;
import forestry.api.genetics.IChromosomeType;
import binnie.Binnie;
import forestry.api.genetics.AlleleManager;
import binnie.craftgui.controls.ControlTextCentered;
import forestry.api.genetics.IIndividual;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.core.IWidget;
public class AnalystPageKaryogram extends ControlAnalystPage
{
public AnalystPageKaryogram(final IWidget parent, final IArea area, final IIndividual ind) {
super(parent, area);
this.setColour(10040319);
int y = 4;
new ControlTextCentered(this, y, "§nKaryogram").setColour(this.getColour());
y += 16;
y += 8;
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(ind.getClass());
final BreedingSystem system = Binnie.Genetics.getSystem(root);
final int maxBiomePerLine = (int) ((this.w() + 4.0f - 16.0f) / 22.0f);
float karygramX = (this.w() - (Math.min(maxBiomePerLine, system.getActiveKaryotype().size()) * 18 - 4)) / 2.0f;
int dx = 0;
int dy = 0;
int rem = system.getActiveKaryotype().size();
for (final IChromosomeType type : system.getActiveKaryotype()) {
new ControlAnalystChromosome(this, karygramX + dx, y + dy, root, type, ind.getGenome().getActiveAllele(type), ind.getGenome().getInactiveAllele(type));
dx += 22;
if (dx >= 22 * maxBiomePerLine - 22) {
rem -= maxBiomePerLine - 1;
if (rem < maxBiomePerLine) {
karygramX += (maxBiomePerLine - 1 - rem) * 22 / 2.0f;
}
dx = 0;
dy += 28;
}
}
}
@Override
public String getTitle() {
return "Karyogram";
}
}
@@ -0,0 +1,277 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import binnie.craftgui.core.geometry.TextJustification;
import binnie.craftgui.core.Attribute;
import binnie.craftgui.minecraft.EnumColor;
import java.util.Collection;
import java.util.List;
import forestry.api.genetics.IAllele;
import binnie.genetics.item.ModuleItem;
import binnie.craftgui.core.geometry.IPoint;
import binnie.craftgui.core.CraftGUI;
import forestry.api.genetics.IAlleleSpecies;
import binnie.core.genetics.BreedingSystem;
import binnie.craftgui.controls.core.Control;
import forestry.api.genetics.IMutation;
import binnie.craftgui.minecraft.control.ControlItemDisplay;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import binnie.core.Mods;
import binnie.core.genetics.ForestryAllele;
import net.minecraft.item.ItemStack;
import binnie.extrabees.ExtraBees;
import binnie.extrabees.genetics.ExtraBeesSpecies;
import forestry.api.apiculture.IBee;
import binnie.craftgui.minecraft.Window;
import binnie.Binnie;
import binnie.craftgui.controls.ControlTextCentered;
import forestry.api.genetics.IIndividual;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.core.IWidget;
public class AnalystPageMutations extends ControlAnalystPage
{
public AnalystPageMutations(final IWidget parent, final IArea area, final IIndividual ind, final boolean isMaster) {
super(parent, area);
this.setColour(3355392);
int y = 4;
new ControlTextCentered(this, y, "§nMutations").setColour(this.getColour());
y += 18;
final BreedingSystem system = Binnie.Genetics.getSystem(ind.getGenome().getSpeciesRoot());
final List<IMutation> discovered = system.getDiscoveredMutations(Window.get(this).getWorld(), Window.get(this).getUsername());
final IAlleleSpecies speciesCurrent = ind.getGenome().getPrimary();
final Collection<IMutation> resultant = system.getResultantMutations(speciesCurrent);
final Collection<IMutation> further = system.getFurtherMutations(speciesCurrent);
if (ind instanceof IBee) {
ItemStack hive = null;
if (ind.getGenome().getPrimary() == ExtraBeesSpecies.WATER) {
hive = new ItemStack(ExtraBees.hive, 1, 0);
}
if (ind.getGenome().getPrimary() == ExtraBeesSpecies.ROCK) {
hive = new ItemStack(ExtraBees.hive, 1, 1);
}
if (ind.getGenome().getPrimary() == ExtraBeesSpecies.BASALT) {
hive = new ItemStack(ExtraBees.hive, 1, 2);
}
if (ind.getGenome().getPrimary() == ForestryAllele.BeeSpecies.Forest.getAllele()) {
hive = new ItemStack(Mods.Forestry.block("beehives"), 1, 1);
}
if (ind.getGenome().getPrimary() == ForestryAllele.BeeSpecies.Meadows.getAllele()) {
hive = new ItemStack(Mods.Forestry.block("beehives"), 1, 2);
}
if (ind.getGenome().getPrimary() == ForestryAllele.BeeSpecies.Modest.getAllele()) {
hive = new ItemStack(Mods.Forestry.block("beehives"), 1, 3);
}
if (ind.getGenome().getPrimary() == ForestryAllele.BeeSpecies.Tropical.getAllele()) {
hive = new ItemStack(Mods.Forestry.block("beehives"), 1, 4);
}
if (ind.getGenome().getPrimary() == ForestryAllele.BeeSpecies.Ended.getAllele()) {
hive = new ItemStack(Mods.Forestry.block("beehives"), 1, 5);
}
if (ind.getGenome().getPrimary() == ForestryAllele.BeeSpecies.Wintry.getAllele()) {
hive = new ItemStack(Mods.Forestry.block("beehives"), 1, 6);
}
if (ind.getGenome().getPrimary() == ForestryAllele.BeeSpecies.Marshy.getAllele()) {
hive = new ItemStack(Mods.Forestry.block("beehives"), 1, 7);
}
if (ind.getGenome().getPrimary() == ForestryAllele.BeeSpecies.Steadfast.getAllele()) {
hive = new ItemStack(Blocks.chest);
}
if (ind.getGenome().getPrimary() == ForestryAllele.BeeSpecies.Valiant.getAllele()) {
new ControlTextCentered(this, y, "Natural Habitat").setColour(this.getColour());
y += 10;
new ControlTextCentered(this, y, "§oFound in any Hive").setColour(this.getColour());
y += 22;
}
else if (ind.getGenome().getPrimary() == ForestryAllele.BeeSpecies.Monastic.getAllele()) {
new ControlTextCentered(this, y, "Natural Habitat").setColour(this.getColour());
y += 10;
new ControlTextCentered(this, y, "§oBought from Villagers").setColour(this.getColour());
y += 22;
}
else if (hive != null) {
new ControlTextCentered(this, y, "Natural Habitat").setColour(this.getColour());
y += 10;
final ControlItemDisplay display = new ControlItemDisplay(this, (this.w() - 16.0f) / 2.0f, y);
if (ind.getGenome().getPrimary() == ForestryAllele.BeeSpecies.Steadfast.getAllele()) {
display.addTooltip("Dungeon Chests");
}
else {
display.setTooltip();
}
display.setItemStack(hive);
y += 24;
}
}
float ox = (this.w() - 88.0f - 8.0f) / 2.0f;
float dx = 0.0f;
if (!resultant.isEmpty()) {
if (resultant.size() == 1) {
ox = (this.w() - 44.0f) / 2.0f;
}
new ControlTextCentered(this, y, "Resultant Mutations").setColour(this.getColour());
y += 10;
for (final IMutation mutation : resultant) {
final float specificChance = this.getSpecificChance(ind, mutation, system);
if (!isMaster && !this.isKnown(system, mutation)) {
new ControlUnknownMutation(this, ox + dx, y, 44.0f, 16.0f);
}
else {
new Control(this, ox + dx, y, 44.0f, 16.0f) {
@Override
public void initialise() {
final IAlleleSpecies species0 = mutation.getAllele0();
final IAlleleSpecies species2 = mutation.getAllele1();
final String comb = species0.getName() + " + " + species2.getName();
this.addTooltip(comb);
String chance = AnalystPageMutations.this.getMutationColour(mutation.getBaseChance()).getCode() + (int) mutation.getBaseChance() + "% Chance";
if (specificChance != mutation.getBaseChance()) {
chance = chance + AnalystPageMutations.this.getMutationColour(specificChance).getCode() + " (" + (int) specificChance + "% currently)";
}
this.addTooltip(chance);
for (final String s : mutation.getSpecialConditions()) {
this.addTooltip(s);
}
}
@Override
public void onRenderBackground() {
CraftGUI.Render.item(new IPoint(0.0f, 0.0f), system.getDefaultMember(mutation.getAllele0().getUID()));
CraftGUI.Render.item(new IPoint(28.0f, 0.0f), system.getDefaultMember(mutation.getAllele1().getUID()));
if (specificChance != mutation.getBaseChance()) {
CraftGUI.Render.colour(AnalystPageMutations.this.getMutationColour(mutation.getBaseChance()).getColour());
CraftGUI.Render.iconItem(new IPoint(14.0f, 0.0f), ModuleItem.iconAdd0.getIcon());
CraftGUI.Render.colour(AnalystPageMutations.this.getMutationColour(specificChance).getColour());
CraftGUI.Render.iconItem(new IPoint(14.0f, 0.0f), ModuleItem.iconAdd1.getIcon());
}
else {
CraftGUI.Render.colour(AnalystPageMutations.this.getMutationColour(mutation.getBaseChance()).getColour());
CraftGUI.Render.iconItem(new IPoint(14.0f, 0.0f), ModuleItem.iconAdd.getIcon());
}
}
};
}
dx = 52.0f - dx;
if (dx == 0.0f || resultant.size() == 1) {
y += 18;
}
}
if (dx != 0.0f && resultant.size() != 1) {
y += 18;
}
y += 10;
}
ox = (this.w() - 88.0f - 8.0f) / 2.0f;
dx = 0.0f;
if (!further.isEmpty()) {
if (further.size() == 1) {
ox = (this.w() - 44.0f) / 2.0f;
}
new ControlTextCentered(this, y, "Further Mutations").setColour(this.getColour());
y += 10;
for (final IMutation mutation : further) {
final IAllele speciesComb = mutation.getPartner(speciesCurrent);
final float specificChance2 = this.getSpecificChance(ind, mutation, system);
if (!isMaster && !this.isKnown(system, mutation)) {
new ControlUnknownMutation(this, ox + dx, y, 44.0f, 16.0f);
}
else {
new Control(this, ox + dx, y, 44.0f, 16.0f) {
@Override
public void initialise() {
final IAlleleSpecies species0 = (IAlleleSpecies) speciesComb;
final IAlleleSpecies species2 = (IAlleleSpecies) mutation.getTemplate()[0];
this.addTooltip(species2.getName());
final String comb = speciesCurrent.getName() + " + " + species0.getName();
this.addTooltip(comb);
String chance = AnalystPageMutations.this.getMutationColour(mutation.getBaseChance()).getCode() + (int) mutation.getBaseChance() + "% Chance";
if (specificChance2 != mutation.getBaseChance()) {
chance = chance + AnalystPageMutations.this.getMutationColour(specificChance2).getCode() + " (" + (int) specificChance2 + "% currently)";
}
this.addTooltip(chance);
for (final String s : mutation.getSpecialConditions()) {
this.addTooltip(s);
}
}
@Override
public void onRenderBackground() {
CraftGUI.Render.item(new IPoint(0.0f, 0.0f), system.getDefaultMember(speciesComb.getUID()));
CraftGUI.Render.item(new IPoint(28.0f, 0.0f), system.getDefaultMember(mutation.getTemplate()[0].getUID()));
CraftGUI.Render.colour(AnalystPageMutations.this.getMutationColour(mutation.getBaseChance()).getColour());
if (specificChance2 != mutation.getBaseChance()) {
CraftGUI.Render.colour(AnalystPageMutations.this.getMutationColour(mutation.getBaseChance()).getColour());
CraftGUI.Render.iconItem(new IPoint(14.0f, 0.0f), ModuleItem.iconArrow0.getIcon());
CraftGUI.Render.colour(AnalystPageMutations.this.getMutationColour(specificChance2).getColour());
CraftGUI.Render.iconItem(new IPoint(14.0f, 0.0f), ModuleItem.iconArrow1.getIcon());
}
else {
CraftGUI.Render.colour(AnalystPageMutations.this.getMutationColour(mutation.getBaseChance()).getColour());
CraftGUI.Render.iconItem(new IPoint(14.0f, 0.0f), ModuleItem.iconArrow.getIcon());
}
}
};
}
dx = 52.0f - dx;
if (dx == 0.0f || further.size() == 1) {
y += 18;
}
}
if (dx != 0.0f && further.size() != 1) {
y += 18;
}
}
y += 8;
this.setSize(new IPoint(this.w(), y));
}
private boolean isKnown(final BreedingSystem system, final IMutation mutation) {
return system.getDiscoveredMutations(this.getWindow().getWorld(), this.getWindow().getPlayer().getGameProfile()).contains(mutation);
}
private float getSpecificChance(final IIndividual ind, final IMutation mutation, final BreedingSystem system) {
return system.getChance(mutation, this.getWindow().getPlayer(), mutation.getAllele0(), mutation.getAllele1());
}
@Override
public String getTitle() {
return "Mutations";
}
protected EnumColor getMutationColour(final float percent) {
if (percent >= 20.0f) {
return EnumColor.DarkGreen;
}
if (percent >= 15.0f) {
return EnumColor.Green;
}
if (percent >= 10.0f) {
return EnumColor.Yellow;
}
if (percent >= 5.0f) {
return EnumColor.Gold;
}
if (percent > 0.0f) {
return EnumColor.Red;
}
return EnumColor.DarkRed;
}
static class ControlUnknownMutation extends Control
{
public ControlUnknownMutation(final IWidget parent, final float x, final float y, final float w, final float h) {
super(parent, x, y, w, h);
this.addAttribute(Attribute.MouseOver);
this.addTooltip("Unknown Mutation");
}
@Override
public void onRenderBackground() {
CraftGUI.Render.text(this.getArea(), TextJustification.MiddleCenter, "UNKNOWN", 11184810);
}
}
}
@@ -0,0 +1,246 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import binnie.craftgui.minecraft.control.ControlItemDisplay;
import binnie.craftgui.controls.ControlTextCentered;
import net.minecraft.init.Items;
import net.minecraftforge.fluids.FluidContainerRegistry;
import binnie.extratrees.machines.Distillery;
import binnie.extratrees.machines.Brewery;
import binnie.core.util.UniqueFluidStackSet;
import binnie.extratrees.machines.Press;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraft.item.crafting.CraftingManager;
import java.util.List;
import java.util.Map;
import forestry.api.recipes.RecipeManagers;
import java.util.ArrayList;
import net.minecraft.item.crafting.FurnaceRecipes;
import binnie.core.util.UniqueItemStackSet;
import java.util.Collection;
import net.minecraft.item.ItemStack;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.core.IWidget;
public abstract class AnalystPageProduce extends ControlAnalystPage
{
public AnalystPageProduce(final IWidget parent, final IArea area) {
super(parent, area);
}
protected Collection<? extends ItemStack> getAllProducts(final ItemStack key) {
final Collection<ItemStack> products = new UniqueItemStackSet();
products.addAll(this.getCentrifuge(key));
products.addAll(this.getSqueezer(key));
products.add(FurnaceRecipes.smelting().getSmeltingResult(key));
products.addAll(this.getCrafting(key));
return products;
}
public Collection<ItemStack> getCentrifuge(final ItemStack stack) {
final List<ItemStack> products = new ArrayList<ItemStack>();
for (final Map.Entry<Object[], Object[]> recipe : RecipeManagers.centrifugeManager.getRecipes().entrySet()) {
boolean isRecipe = false;
for (final Object obj : recipe.getKey()) {
if (obj instanceof ItemStack && stack.isItemEqual((ItemStack) obj)) {
isRecipe = true;
}
}
if (isRecipe) {
for (final Object obj : recipe.getValue()) {
if (obj instanceof ItemStack) {
products.add((ItemStack) obj);
}
}
}
}
return products;
}
public Collection<ItemStack> getSqueezer(final ItemStack stack) {
final List<ItemStack> products = new ArrayList<ItemStack>();
for (final Map.Entry<Object[], Object[]> recipe : RecipeManagers.squeezerManager.getRecipes().entrySet()) {
boolean isRecipe = false;
for (final Object obj : recipe.getKey()) {
if (obj instanceof ItemStack && stack.isItemEqual((ItemStack) obj)) {
isRecipe = true;
}
}
if (isRecipe) {
for (final Object obj : recipe.getValue()) {
if (obj instanceof ItemStack) {
products.add((ItemStack) obj);
}
}
}
}
return products;
}
public Collection<ItemStack> getCrafting(final ItemStack stack) {
final List<ItemStack> products = new ArrayList<ItemStack>();
for (final Object recipeO : CraftingManager.getInstance().getRecipeList()) {
if (recipeO instanceof ShapelessRecipes) {
final ShapelessRecipes recipe = (ShapelessRecipes) recipeO;
boolean match = true;
for (final Object rec : recipe.recipeItems) {
if (rec != null && (!(rec instanceof ItemStack) || !stack.isItemEqual((ItemStack) rec))) {
match = false;
}
}
if (match) {
products.add(recipe.getRecipeOutput());
}
}
if (recipeO instanceof ShapedRecipes) {
final ShapedRecipes recipe2 = (ShapedRecipes) recipeO;
boolean match = true;
for (final Object rec2 : recipe2.recipeItems) {
if (rec2 != null && (!(rec2 instanceof ItemStack) || !stack.isItemEqual((ItemStack) rec2))) {
match = false;
}
}
if (match) {
products.add(recipe2.getRecipeOutput());
}
}
if (recipeO instanceof ShapelessOreRecipe) {
final ShapelessOreRecipe recipe3 = (ShapelessOreRecipe) recipeO;
boolean match = true;
for (final Object rec : recipe3.getInput()) {
if (rec != null && (!(rec instanceof ItemStack) || !stack.isItemEqual((ItemStack) rec))) {
match = false;
}
}
if (!match) {
continue;
}
products.add(recipe3.getRecipeOutput());
}
}
return products;
}
public Collection<FluidStack> getAllFluids(final ItemStack stack) {
final List<FluidStack> products = new ArrayList<FluidStack>();
products.addAll(this.getSqueezerFluid(stack));
if (Press.getOutput(stack) != null) {
products.add(Press.getOutput(stack));
}
return products;
}
public Collection<FluidStack> getSqueezerFluid(final ItemStack stack) {
final List<FluidStack> products = new ArrayList<FluidStack>();
for (final Map.Entry<Object[], Object[]> recipe : RecipeManagers.squeezerManager.getRecipes().entrySet()) {
boolean isRecipe = false;
for (final Object obj : recipe.getKey()) {
if (obj instanceof ItemStack && stack.isItemEqual((ItemStack) obj)) {
isRecipe = true;
}
}
if (isRecipe) {
for (final Object obj : recipe.getValue()) {
if (obj instanceof FluidStack) {
products.add((FluidStack) obj);
}
}
}
}
return products;
}
protected Collection<? extends FluidStack> getAllProducts(final FluidStack stack) {
final Collection<FluidStack> fluids = new UniqueFluidStackSet();
fluids.add(Brewery.getOutput(stack));
fluids.add(Distillery.getOutput(stack, 0));
fluids.add(Distillery.getOutput(stack, 1));
fluids.add(Distillery.getOutput(stack, 2));
return fluids;
}
protected Collection<ItemStack> getAllProductsAndFluids(final Collection<ItemStack> collection) {
final Collection<ItemStack> products = new UniqueItemStackSet();
for (final ItemStack stack : collection) {
products.addAll(this.getAllProducts(stack));
}
final Collection<ItemStack> products2 = new UniqueItemStackSet();
for (final ItemStack stack2 : products) {
products2.addAll(this.getAllProducts(stack2));
}
final Collection<ItemStack> products3 = new UniqueItemStackSet();
for (final ItemStack stack3 : products2) {
products3.addAll(this.getAllProducts(stack3));
}
products.addAll(products2);
products.addAll(products3);
final Collection<FluidStack> allFluids = new UniqueFluidStackSet();
for (final ItemStack stack4 : collection) {
allFluids.addAll(this.getAllFluids(stack4));
}
final Collection<FluidStack> fluids2 = new UniqueFluidStackSet();
for (final FluidStack stack5 : allFluids) {
fluids2.addAll(this.getAllProducts(stack5));
}
final Collection<FluidStack> fluids3 = new UniqueFluidStackSet();
for (final FluidStack stack6 : fluids2) {
fluids3.addAll(this.getAllProducts(stack6));
}
allFluids.addAll(fluids2);
allFluids.addAll(fluids3);
for (final FluidStack fluid : allFluids) {
ItemStack container = null;
for (final FluidContainerRegistry.FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) {
if (data.emptyContainer.isItemEqual(new ItemStack(Items.glass_bottle)) && data.fluid.isFluidEqual(fluid)) {
container = data.filledContainer;
break;
}
if (data.emptyContainer.isItemEqual(new ItemStack(Items.bucket)) && data.fluid.isFluidEqual(fluid)) {
container = data.filledContainer;
break;
}
if (data.fluid.isFluidEqual(fluid)) {
container = data.filledContainer;
break;
}
}
if (container != null) {
products.add(container);
}
}
return products;
}
protected int getRefined(final String string, int y, final Collection<ItemStack> products) {
new ControlTextCentered(this, y, string).setColour(this.getColour());
y += 10;
final int maxBiomePerLine = (int) ((this.w() + 2.0f - 16.0f) / 18.0f);
final float biomeListX = (this.w() - (Math.min(maxBiomePerLine, products.size()) * 18 - 2)) / 2.0f;
int dx = 0;
int dy = 0;
for (final ItemStack soilStack : products) {
if (dx >= 18 * maxBiomePerLine) {
dx = 0;
dy += 18;
}
final FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(soilStack);
soilStack.stackSize = 1;
final ControlItemDisplay display = new ControlItemDisplay(this, biomeListX + dx, y + dy, soilStack, fluid == null);
if (fluid != null) {
display.addTooltip(fluid.getLocalizedName());
}
dx += 18;
}
if (dx != 0) {
dy += 18;
}
y += dy;
return y;
}
}
@@ -0,0 +1,190 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import binnie.craftgui.controls.ControlText;
import forestry.plugins.PluginApiculture;
import binnie.craftgui.core.geometry.CraftGUIUtil;
import net.minecraft.nbt.NBTTagCompound;
import binnie.craftgui.core.Tooltip;
import forestry.api.apiculture.IBeeGenome;
import binnie.craftgui.core.geometry.IPoint;
import binnie.craftgui.extratrees.kitchen.ControlFluidDisplay;
import net.minecraft.init.Items;
import net.minecraftforge.fluids.FluidContainerRegistry;
import binnie.craftgui.minecraft.control.ControlItemDisplay;
import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import net.minecraft.item.ItemStack;
import java.util.HashMap;
import binnie.core.util.UniqueItemStackSet;
import forestry.api.genetics.IChromosomeType;
import forestry.api.apiculture.EnumBeeChromosome;
import binnie.craftgui.controls.ControlTextCentered;
import binnie.core.BinnieCore;
import binnie.Binnie;
import forestry.api.apiculture.IBee;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.core.IWidget;
public class AnalystPageProducts extends AnalystPageProduce
{
public AnalystPageProducts(final IWidget parent, final IArea area, final IBee ind) {
super(parent, area);
this.setColour(13382400);
final IBeeGenome genome = ind.getGenome();
final float speed = genome.getSpeed();
final float modeSpeed = Binnie.Genetics.getBeeRoot().getBeekeepingMode(BinnieCore.proxy.getWorld()).getBeeModifier().getProductionModifier(genome, 1.0f);
int y = 4;
new ControlTextCentered(this, y, "§nProduce").setColour(this.getColour());
y += 12;
new ControlTextCentered(this, y, "§oRate: " + Binnie.Genetics.beeBreedingSystem.getAlleleName(EnumBeeChromosome.SPEED, ind.getGenome().getActiveAllele(EnumBeeChromosome.SPEED))).setColour(this.getColour());
y += 20;
final Collection<ItemStack> refinedProducts = new UniqueItemStackSet();
final Collection<ItemStack> productList = new UniqueItemStackSet();
final Collection<ItemStack> specialtyList = new UniqueItemStackSet();
Map<ItemStack, Float> products = new HashMap<ItemStack, Float>();
products.putAll(genome.getPrimary().getProductChances());
products.putAll(genome.getSecondary().getProductChances());
if (!products.isEmpty()) {
new ControlTextCentered(this, y, "Natural Products").setColour(this.getColour());
y += 12;
for (final Map.Entry<ItemStack, Float> entry : products.entrySet()) {
if (!productList.add(entry.getKey())) {
continue;
}
refinedProducts.addAll(this.getAllProducts(entry.getKey()));
this.createProductEntry(entry.getKey(), entry.getValue(), y, speed * modeSpeed);
y += 18;
}
y += 12;
}
products = genome.getPrimary().getSpecialtyChances();
if (!products.isEmpty()) {
new ControlTextCentered(this, y, "Specialty Products").setColour(this.getColour());
y += 12;
for (final Map.Entry<ItemStack, Float> entry : products.entrySet()) {
refinedProducts.addAll(this.getAllProducts(entry.getKey()));
this.createProductEntry(entry.getKey(), entry.getValue(), y, speed * modeSpeed);
y += 18;
}
y += 12;
}
new ControlTextCentered(this, y, "Refined Products").setColour(this.getColour());
y += 12;
Collection<ItemStack> level2Products = new UniqueItemStackSet();
for (final ItemStack stack : refinedProducts) {
level2Products.addAll(this.getAllProducts(stack));
}
refinedProducts.addAll(level2Products);
level2Products = new UniqueItemStackSet();
for (final ItemStack stack : refinedProducts) {
level2Products.addAll(this.getAllProducts(stack));
}
refinedProducts.addAll(level2Products);
final Collection<FluidStack> allFluids = new ArrayList<FluidStack>();
for (final ItemStack stack2 : refinedProducts) {
for (final FluidStack addition : this.getAllFluids(stack2)) {
boolean alreadyIn = false;
for (final FluidStack existing : allFluids) {
if (existing.isFluidEqual(addition)) {
alreadyIn = true;
}
}
if (!alreadyIn) {
allFluids.add(addition);
}
}
}
final int maxBiomePerLine = (int) ((this.w() + 2.0f - 16.0f) / 18.0f);
final float biomeListX = (this.w() - (Math.min(maxBiomePerLine, allFluids.size() + refinedProducts.size()) * 18 - 2)) / 2.0f;
int dx = 0;
int dy = 0;
for (final ItemStack soilStack : refinedProducts) {
if (dx >= 18 * maxBiomePerLine) {
dx = 0;
dy += 18;
}
final ControlItemDisplay display = new ControlItemDisplay(this, biomeListX + dx, y + dy);
display.setItemStack(soilStack);
display.setTooltip();
dx += 18;
}
for (final FluidStack soilStack2 : allFluids) {
if (dx >= 18 * maxBiomePerLine) {
dx = 0;
dy += 18;
}
ItemStack container = null;
for (final FluidContainerRegistry.FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) {
if (data.emptyContainer.isItemEqual(new ItemStack(Items.glass_bottle)) && data.fluid.isFluidEqual(soilStack2)) {
container = data.filledContainer;
break;
}
if (data.emptyContainer.isItemEqual(new ItemStack(Items.bucket)) && data.fluid.isFluidEqual(soilStack2)) {
container = data.filledContainer;
break;
}
if (data.fluid.isFluidEqual(soilStack2)) {
container = data.filledContainer;
break;
}
}
if (container == null) {
final ControlFluidDisplay display2 = new ControlFluidDisplay(this, biomeListX + dx, y + dy);
display2.setItemStack(soilStack2);
display2.setTooltip();
}
else {
final ControlItemDisplay display3 = new ControlItemDisplay(this, biomeListX + dx, y + dy);
display3.setItemStack(container);
display3.setTooltip();
}
dx += 18;
}
this.setSize(new IPoint(this.w(), y + dy + 18 + 8));
}
private void createProductEntry(final ItemStack key, final Float value, final int y, final float speed) {
final ControlItemDisplay item = new ControlItemDisplay(this, 16.0f, y) {
@Override
public void getTooltip(final Tooltip tooltip) {
super.getTooltip(tooltip);
final Collection<ItemStack> products = AnalystPageProducts.this.getCentrifuge(key);
if (!products.isEmpty()) {
tooltip.add("Centrifuges to give: ");
for (final ItemStack prod : products) {
final NBTTagCompound nbt = new NBTTagCompound();
prod.writeToNBT(nbt);
tooltip.add(prod, prod.getDisplayName());
}
}
final Collection<ItemStack> liquids = AnalystPageProducts.this.getSqueezer(key);
if (!liquids.isEmpty()) {
tooltip.add("Squeezes to give: ");
for (final ItemStack prod2 : liquids) {
final NBTTagCompound nbt2 = new NBTTagCompound();
prod2.writeToNBT(nbt2);
tooltip.add(prod2, prod2.getDisplayName());
}
}
}
};
item.setTooltip();
final ControlText textWidget = new ControlTextCentered(this, y + 4, "");
textWidget.setColour(this.getColour());
CraftGUIUtil.moveWidget(textWidget, new IPoint(12.0f, 0.0f));
item.setItemStack(key);
final float time = (int) (PluginApiculture.ticksPerBeeWorkCycle * 100.0 / (speed * value));
textWidget.setValue("Every " + this.getTimeString(time));
}
@Override
public String getTitle() {
return "Produce";
}
}
@@ -0,0 +1,146 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import binnie.Binnie;
import java.util.List;
import forestry.api.genetics.EnumTolerance;
import java.util.EnumSet;
import java.util.ArrayList;
import binnie.craftgui.minecraft.control.ControlItemDisplay;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import binnie.botany.gardening.BlockSoil;
import binnie.botany.Botany;
import binnie.botany.api.EnumAcidity;
import binnie.core.genetics.Tolerance;
import binnie.botany.api.EnumMoisture;
import binnie.craftgui.controls.ControlText;
import binnie.craftgui.core.geometry.TextJustification;
import binnie.craftgui.controls.ControlTextCentered;
import binnie.botany.api.IFlower;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.core.IWidget;
public class AnalystPageSoil extends ControlAnalystPage
{
public AnalystPageSoil(final IWidget parent, final IArea area, final IFlower flower) {
super(parent, area);
this.setColour(6697728);
final EnumMoisture moisture = flower.getGenome().getPrimary().getMoisture();
final EnumTolerance moistureTol = flower.getGenome().getToleranceMoisture();
final EnumAcidity pH = flower.getGenome().getPrimary().getPH();
final EnumTolerance pHTol = flower.getGenome().getTolerancePH();
int y = 4;
new ControlTextCentered(this, y, "§nSoil").setColour(this.getColour());
y += 16;
new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 14.0f), "Moisture Tolerance", TextJustification.MiddleCenter).setColour(this.getColour());
y += 12;
this.createMoisture(this, (this.w() - 100.0f) / 2.0f, y, 100.0f, 10.0f, moisture, moistureTol);
y += 16;
new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 14.0f), "pH Tolerance", TextJustification.MiddleCenter).setColour(this.getColour());
y += 12;
this.createAcidity(this, (this.w() - 100.0f) / 2.0f, y, 100.0f, 10.0f, pH, pHTol);
y += 16;
new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 14.0f), "Recommended Soil", TextJustification.MiddleCenter).setColour(this.getColour());
y += 12;
EnumMoisture recomMoisture = EnumMoisture.Normal;
final boolean canTolNormal = Tolerance.canTolerate(moisture, EnumMoisture.Normal, moistureTol);
final boolean canTolDamp = Tolerance.canTolerate(moisture, EnumMoisture.Damp, moistureTol);
final boolean canTolDry = Tolerance.canTolerate(moisture, EnumMoisture.Dry, moistureTol);
if (canTolNormal) {
if (canTolDamp && !canTolDry) {
recomMoisture = EnumMoisture.Damp;
}
else if (canTolDry && !canTolDamp) {
recomMoisture = EnumMoisture.Dry;
}
}
else {
if (canTolDamp) {
recomMoisture = EnumMoisture.Damp;
}
if (canTolDry) {
recomMoisture = EnumMoisture.Dry;
}
}
EnumAcidity recomPH = EnumAcidity.Neutral;
final boolean canTolNeutral = Tolerance.canTolerate(pH, EnumAcidity.Neutral, pHTol);
final boolean canTolAcid = Tolerance.canTolerate(pH, EnumAcidity.Acid, pHTol);
final boolean canTolAlkaline = Tolerance.canTolerate(pH, EnumAcidity.Alkaline, pHTol);
if (canTolNeutral) {
if (canTolAcid && !canTolAlkaline) {
recomPH = EnumAcidity.Acid;
}
else if (canTolAlkaline && !canTolAcid) {
recomPH = EnumAcidity.Alkaline;
}
}
else {
if (canTolAcid) {
recomPH = EnumAcidity.Acid;
}
if (canTolAlkaline) {
recomPH = EnumAcidity.Alkaline;
}
}
final ItemStack stack = new ItemStack(Botany.soil, 1, BlockSoil.getMeta(recomPH, recomMoisture));
final ControlItemDisplay recomSoil = new ControlItemDisplay(this, (this.w() - 24.0f) / 2.0f, y, 24.0f);
recomSoil.setItemStack(stack);
recomSoil.setTooltip();
y += 32;
new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 14.0f), "Other Soils", TextJustification.MiddleCenter).setColour(this.getColour());
y += 12;
final List<ItemStack> stacks = new ArrayList<ItemStack>();
for (final EnumAcidity a : EnumSet.range(EnumAcidity.Acid, EnumAcidity.Alkaline)) {
for (final EnumMoisture b : EnumSet.range(EnumMoisture.Dry, EnumMoisture.Damp)) {
if (Tolerance.canTolerate(pH, a, pHTol) && Tolerance.canTolerate(moisture, b, moistureTol) && (a != recomPH || b != recomMoisture)) {
stacks.add(new ItemStack(Botany.soil, 1, BlockSoil.getMeta(a, b)));
}
}
}
final float soilListWidth = 17 * stacks.size() - 1;
final float soilListX = (this.w() - soilListWidth) / 2.0f;
int t = 0;
for (final ItemStack soilStack : stacks) {
final ControlItemDisplay display = new ControlItemDisplay(this, soilListX + 17 * t++, y);
display.setItemStack(soilStack);
display.setTooltip();
}
}
protected void createMoisture(final IWidget parent, final float x, final float y, final float w, final float h, final EnumMoisture value, final EnumTolerance tol) {
new ControlToleranceBar<EnumMoisture>(parent, x, y, w, h, EnumMoisture.class) {
@Override
protected String getName(final EnumMoisture value) {
return Binnie.Language.localise(value);
}
@Override
protected int getColour(final EnumMoisture value) {
return (new int[] { 13434828, 6737151, 3368703 })[value.ordinal()];
}
}.setValues(value, tol);
}
protected void createAcidity(final IWidget parent, final float x, final float y, final float w, final float h, final EnumAcidity value, final EnumTolerance tol) {
new ControlToleranceBar<EnumAcidity>(parent, x, y, w, h, EnumAcidity.class) {
@Override
protected String getName(final EnumAcidity value) {
return Binnie.Language.localise(value);
}
@Override
protected int getColour(final EnumAcidity value) {
return (new int[] { 16711782, 65280, 26367 })[value.ordinal()];
}
}.setValues(value, tol);
}
@Override
public String getTitle() {
return "Soil";
}
}
@@ -0,0 +1,29 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import forestry.api.genetics.IIndividual;
import binnie.craftgui.controls.ControlTextCentered;
import forestry.api.lepidopterology.IButterfly;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.core.IWidget;
public class AnalystPageSpecimen extends ControlAnalystPage
{
public AnalystPageSpecimen(final IWidget parent, final IArea area, final IButterfly ind) {
super(parent, area);
this.setColour(3355443);
int y = 4;
new ControlTextCentered(this, y, "§nSpecimen").setColour(this.getColour());
y += 12;
final float w = (this.w() - 16.0f) * ind.getSize();
new ControlIndividualDisplay(this, (this.w() - w) / 2.0f, y + (this.w() - w) / 2.0f, w, ind);
}
@Override
public String getTitle() {
return "Specimen";
}
}
@@ -0,0 +1,90 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import forestry.api.arboriculture.ITreeGenome;
import binnie.craftgui.core.geometry.IPoint;
import java.util.Collection;
import binnie.craftgui.minecraft.control.ControlItemDisplay;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import binnie.core.util.UniqueItemStackSet;
import binnie.craftgui.minecraft.control.ControlIconDisplay;
import binnie.genetics.item.ModuleItem;
import forestry.api.genetics.IChromosomeType;
import forestry.api.arboriculture.EnumTreeChromosome;
import forestry.api.genetics.IAlleleBoolean;
import binnie.craftgui.controls.ControlTextCentered;
import forestry.api.arboriculture.ITree;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.core.IWidget;
import binnie.extratrees.FakeWorld;
public class AnalystPageWood extends AnalystPageProduce
{
public AnalystPageWood(final IWidget parent, final IArea area, final ITree ind) {
super(parent, area);
this.setColour(6697728);
final ITreeGenome genome = ind.getGenome();
int y = 4;
new ControlTextCentered(this, y, "§nWood").setColour(this.getColour());
y += 12;
if (((IAlleleBoolean) ind.getGenome().getActiveAllele(EnumTreeChromosome.FIREPROOF)).getValue()) {
new ControlIconDisplay(this, (this.w() - 16.0f) / 2.0f, y, ModuleItem.iconNoFire.getIcon()).addTooltip("Fireproof");
}
else {
new ControlIconDisplay(this, (this.w() - 16.0f) / 2.0f, y, ModuleItem.iconFire.getIcon()).addTooltip("Flammable");
}
y += 30;
final Collection<ItemStack> products = new UniqueItemStackSet();
genome.getPrimary().getGenerator().setLogBlock(genome, FakeWorld.instance, 0, 0, 0, ForgeDirection.UP);
ItemStack stackWood = FakeWorld.instance.getWooLog();
if (stackWood != null) {
products.add(stackWood);
}
// for (final ItemStack stack :
// ind.getGenome().getFruitProvider().getProducts()) {
// products.add(stack);
// }
if (products.size() > 0) {
new ControlTextCentered(this, y, "Logs").setColour(this.getColour());
y += 10;
final int w = products.size() * 18 - 2;
final int i = 0;
for (final ItemStack stack : products) {
final ControlItemDisplay d = new ControlItemDisplay(this, (this.w() - w) / 2.0f + 18 * i, y);
d.setTooltip();
d.setItemStack(stack);
}
y += 26;
}
final Collection<ItemStack> allProducts = new UniqueItemStackSet();
for (final ItemStack stack2 : products) {
allProducts.add(stack2);
}
final Collection<ItemStack> refinedProducts = new UniqueItemStackSet();
refinedProducts.addAll(this.getAllProductsAndFluids(allProducts));
if (refinedProducts.size() > 0) {
y = this.getRefined("Refined Products", y, refinedProducts);
y += 8;
}
if (products.size() == 0) {
new ControlTextCentered(this, y, "This tree has no \nfruits or nuts").setColour(this.getColour());
y += 28;
}
this.setSize(new IPoint(this.w(), y + 8));
}
@Override
public String getTitle() {
return "Wood";
}
}
@@ -0,0 +1,65 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import binnie.core.genetics.BreedingSystem;
import binnie.Binnie;
import binnie.craftgui.core.Tooltip;
import binnie.craftgui.core.geometry.IPoint;
import binnie.craftgui.core.CraftGUI;
import binnie.craftgui.core.Attribute;
import binnie.craftgui.resource.minecraft.StandardTexture;
import binnie.core.texture.BinnieCoreTexture;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.resource.Texture;
import forestry.api.genetics.ISpeciesRoot;
import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.IAllele;
import binnie.craftgui.core.ITooltip;
import binnie.craftgui.controls.core.Control;
public class ControlAnalystChromosome extends Control implements ITooltip
{
IAllele allele0;
IAllele allele1;
IChromosomeType chromosomeType;
ISpeciesRoot root;
Texture Homozygous;
Texture Heterozygous;
public ControlAnalystChromosome(final IWidget parent, final float x, final float y, final ISpeciesRoot root, final IChromosomeType type, final IAllele allele0, final IAllele allele1) {
super(parent, x, y, 16.0f, 22.0f);
this.Homozygous = new StandardTexture(0, 0, 16, 22, BinnieCoreTexture.GUIAnalyst);
this.Heterozygous = new StandardTexture(16, 0, 16, 22, BinnieCoreTexture.GUIAnalyst);
this.addAttribute(Attribute.MouseOver);
this.root = root;
this.chromosomeType = type;
this.allele0 = allele0;
this.allele1 = allele1;
}
public boolean isHomozygous() {
return this.allele0.getUID().equals(this.allele1.getUID());
}
@Override
public void onRenderBackground() {
super.onRenderBackground();
CraftGUI.Render.texture(this.isHomozygous() ? this.Homozygous : this.Heterozygous, IPoint.ZERO);
}
@Override
public void getTooltip(final Tooltip tooltip) {
final BreedingSystem system = Binnie.Genetics.getSystem(this.root);
tooltip.add(system.getChromosomeName(this.chromosomeType));
if (this.isHomozygous()) {
tooltip.add(system.getAlleleName(this.chromosomeType, this.allele0));
}
else {
tooltip.add("Active: " + system.getAlleleName(this.chromosomeType, this.allele0));
tooltip.add("Inactive: " + system.getAlleleName(this.chromosomeType, this.allele1));
}
}
}
@@ -0,0 +1,38 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import java.text.DecimalFormat;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.controls.core.Control;
public abstract class ControlAnalystPage extends Control
{
public ControlAnalystPage(final IWidget parent, final IArea area) {
super(parent, area);
this.hide();
}
@Override
public void onRenderBackground() {
}
public abstract String getTitle();
protected String getTimeString(final float time) {
final float seconds = time / 20.0f;
final float minutes = seconds / 60.0f;
final float hours = minutes / 60.0f;
final DecimalFormat df = new DecimalFormat("#.0");
if (hours > 1.0f) {
return df.format(hours) + " hours";
}
if (minutes > 1.0f) {
return df.format(minutes) + " min.";
}
return df.format(seconds) + " sec.";
}
}
@@ -0,0 +1,76 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import binnie.craftgui.core.Tooltip;
import net.minecraft.util.IIcon;
import binnie.craftgui.core.geometry.IPoint;
import binnie.craftgui.core.CraftGUI;
import forestry.core.render.TextureManager;
import net.minecraftforge.common.BiomeDictionary;
import binnie.craftgui.core.IWidget;
import net.minecraft.world.biome.BiomeGenBase;
import binnie.craftgui.core.ITooltip;
import binnie.craftgui.controls.core.Control;
public class ControlBiome extends Control implements ITooltip
{
BiomeGenBase biome;
String iconCategory;
public ControlBiome(final IWidget parent, final float x, final float y, final float w, final float h, final BiomeGenBase biome) {
super(parent, x, y, w, h);
this.biome = null;
this.iconCategory = "plains";
this.biome = biome;
}
@Override
public void onRenderBackground() {
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.MOUNTAIN)) {
this.iconCategory = "hills";
}
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.HILLS)) {
this.iconCategory = "hills";
}
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.SANDY)) {
this.iconCategory = "desert";
}
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.SNOWY)) {
this.iconCategory = "snow";
}
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.FOREST)) {
this.iconCategory = "forest";
}
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.SWAMP)) {
this.iconCategory = "swamp";
}
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.JUNGLE)) {
this.iconCategory = "jungle";
}
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.COLD) && BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.FOREST)) {
this.iconCategory = "taiga";
}
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.MUSHROOM)) {
this.iconCategory = "mushroom";
}
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.OCEAN)) {
this.iconCategory = "ocean";
}
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.NETHER)) {
this.iconCategory = "nether";
}
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.END)) {
this.iconCategory = "end";
}
final IIcon icon = TextureManager.getInstance().getDefault("habitats/" + this.iconCategory);
CraftGUI.Render.iconItem(IPoint.ZERO, icon);
}
@Override
public void getTooltip(final Tooltip tooltip) {
tooltip.add(this.biome.biomeName.replaceAll("(\\p{Ll})(\\p{Lu})", "$1 $2"));
}
}
@@ -0,0 +1,61 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import binnie.Binnie;
import binnie.craftgui.core.Tooltip;
import binnie.craftgui.core.geometry.IPoint;
import binnie.craftgui.core.CraftGUI;
import binnie.craftgui.events.EventValueChanged;
import binnie.craftgui.events.EventWidget;
import binnie.craftgui.core.Attribute;
import binnie.craftgui.resource.minecraft.StandardTexture;
import binnie.extrabees.core.ExtraBeeTexture;
import forestry.api.genetics.IChromosomeType;
import binnie.craftgui.resource.Texture;
import binnie.craftgui.core.ITooltip;
import binnie.craftgui.controls.core.Control;
public class ControlChromoPicker extends Control implements ITooltip
{
Texture Selected;
Texture Texture;
IChromosomeType type;
ControlChromosome parent;
public ControlChromoPicker(final ControlChromosome parent, final float x, final float y, final IChromosomeType chromo) {
super(parent, x, y, 16.0f, 16.0f);
this.Selected = new StandardTexture(160, 18, 16, 16, ExtraBeeTexture.GUIPunnett);
this.Texture = new StandardTexture(160, 34, 16, 16, ExtraBeeTexture.GUIPunnett);
this.type = chromo;
this.addAttribute(Attribute.MouseOver);
this.parent = parent;
this.addSelfEventHandler(new EventWidget.StartMouseOver.Handler() {
@Override
public void onEvent(final EventWidget.StartMouseOver event) {
ControlChromoPicker.this.callEvent(new EventValueChanged<Object>(ControlChromoPicker.this.getWidget(), ControlChromoPicker.this.type));
}
});
this.addSelfEventHandler(new EventWidget.EndMouseOver.Handler() {
@Override
public void onEvent(final EventWidget.EndMouseOver event) {
ControlChromoPicker.this.callEvent(new EventValueChanged<Object>(ControlChromoPicker.this.getWidget(), null));
}
});
}
@Override
public void onRenderBackground() {
super.onRenderBackground();
final boolean selected = this.isMouseOver();
final Texture text = selected ? this.Selected : this.Texture;
CraftGUI.Render.texture(text, IPoint.ZERO);
}
@Override
public void getTooltip(final Tooltip tooltip) {
tooltip.add(Binnie.Genetics.getSystem(this.parent.getRoot()).getChromosomeName(this.type));
}
}
@@ -0,0 +1,148 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import binnie.craftgui.core.geometry.IPoint;
import binnie.craftgui.core.CraftGUI;
import forestry.api.lepidopterology.EnumButterflyChromosome;
import binnie.botany.api.EnumFlowerChromosome;
import forestry.api.arboriculture.EnumTreeChromosome;
import forestry.api.apiculture.EnumBeeChromosome;
import binnie.Binnie;
import binnie.craftgui.resource.minecraft.StandardTexture;
import binnie.core.texture.BinnieCoreTexture;
import binnie.craftgui.core.IWidget;
import forestry.api.genetics.ISpeciesRoot;
import binnie.craftgui.resource.Texture;
import forestry.api.genetics.IChromosomeType;
import binnie.craftgui.controls.core.IControlValue;
import binnie.craftgui.controls.core.Control;
public class ControlChromosome extends Control implements IControlValue<IChromosomeType>
{
Texture BeeTexture;
Texture TreeTexture;
Texture MothTexture;
Texture FlowerTexture;
IChromosomeType chromo;
ISpeciesRoot species;
public ControlChromosome(final IWidget parent, final float x, final float y) {
super(parent, x, y, 96.0f, 96.0f);
this.BeeTexture = new StandardTexture(0, 0, 96, 96, BinnieCoreTexture.GUIBreeding);
this.TreeTexture = new StandardTexture(96, 0, 96, 96, BinnieCoreTexture.GUIBreeding);
this.MothTexture = new StandardTexture(96, 96, 96, 96, BinnieCoreTexture.GUIBreeding);
this.FlowerTexture = new StandardTexture(0, 96, 96, 96, BinnieCoreTexture.GUIBreeding);
this.chromo = null;
this.species = null;
}
public ISpeciesRoot getRoot() {
return this.species;
}
public void setRoot(final ISpeciesRoot root) {
if (root != this.species) {
this.species = root;
this.deleteAllChildren();
if (root == Binnie.Genetics.getBeeRoot()) {
new ControlChromoPicker(this, 28.0f, 47.0f, EnumBeeChromosome.SPECIES);
new ControlChromoPicker(this, 28.0f, 72.0f, EnumBeeChromosome.SPEED);
new ControlChromoPicker(this, 19.0f, 20.0f, EnumBeeChromosome.LIFESPAN);
new ControlChromoPicker(this, 55.0f, 65.0f, EnumBeeChromosome.FERTILITY);
new ControlChromoPicker(this, 28.0f, 1.0f, EnumBeeChromosome.TEMPERATURE_TOLERANCE);
new ControlChromoPicker(this, 61.0f, 37.0f, EnumBeeChromosome.NOCTURNAL);
new ControlChromoPicker(this, 81.0f, 76.0f, EnumBeeChromosome.HUMIDITY_TOLERANCE);
new ControlChromoPicker(this, 44.0f, 21.0f, EnumBeeChromosome.TOLERANT_FLYER);
new ControlChromoPicker(this, 3.0f, 37.0f, EnumBeeChromosome.CAVE_DWELLING);
new ControlChromoPicker(this, 4.0f, 65.0f, EnumBeeChromosome.FLOWER_PROVIDER);
new ControlChromoPicker(this, 83.0f, 27.0f, EnumBeeChromosome.FLOWERING);
new ControlChromoPicker(this, 71.0f, 10.0f, EnumBeeChromosome.TERRITORY);
new ControlChromoPicker(this, 84.0f, 54.0f, EnumBeeChromosome.EFFECT);
}
else if (root == Binnie.Genetics.getTreeRoot()) {
new ControlChromoPicker(this, 48.0f, 48.0f, EnumTreeChromosome.SPECIES);
new ControlChromoPicker(this, 43.0f, 12.0f, EnumTreeChromosome.GROWTH);
new ControlChromoPicker(this, 43.0f, 84.0f, EnumTreeChromosome.HEIGHT);
new ControlChromoPicker(this, 25.0f, 63.0f, EnumTreeChromosome.FERTILITY);
new ControlChromoPicker(this, 72.0f, 57.0f, EnumTreeChromosome.FRUITS);
new ControlChromoPicker(this, 21.0f, 43.0f, EnumTreeChromosome.YIELD);
new ControlChromoPicker(this, 38.0f, 32.0f, EnumTreeChromosome.PLANT);
new ControlChromoPicker(this, 15.0f, 17.0f, EnumTreeChromosome.SAPPINESS);
new ControlChromoPicker(this, 75.0f, 78.0f, EnumTreeChromosome.TERRITORY);
new ControlChromoPicker(this, 67.0f, 15.0f, EnumTreeChromosome.EFFECT);
new ControlChromoPicker(this, 70.0f, 34.0f, EnumTreeChromosome.MATURATION);
new ControlChromoPicker(this, 45.0f, 67.0f, EnumTreeChromosome.GIRTH);
new ControlChromoPicker(this, 5.0f, 70.0f, EnumTreeChromosome.FIREPROOF);
}
else if (root == Binnie.Genetics.getFlowerRoot()) {
new ControlChromoPicker(this, 35.0f, 81.0f, EnumFlowerChromosome.SPECIES);
new ControlChromoPicker(this, 36.0f, 28.0f, EnumFlowerChromosome.PRIMARY);
new ControlChromoPicker(this, 27.0f, 13.0f, EnumFlowerChromosome.SECONDARY);
new ControlChromoPicker(this, 47.0f, 15.0f, EnumFlowerChromosome.FERTILITY);
new ControlChromoPicker(this, 54.0f, 31.0f, EnumFlowerChromosome.TERRITORY);
new ControlChromoPicker(this, 15.0f, 55.0f, EnumFlowerChromosome.EFFECT);
new ControlChromoPicker(this, 23.0f, 38.0f, EnumFlowerChromosome.LIFESPAN);
new ControlChromoPicker(this, 17.0f, 77.0f, EnumFlowerChromosome.TEMPERATURE_TOLERANCE);
new ControlChromoPicker(this, 52.0f, 51.0f, EnumFlowerChromosome.HUMIDITY_TOLERANCE);
new ControlChromoPicker(this, 54.0f, 80.0f, EnumFlowerChromosome.PH_TOLERANCE);
new ControlChromoPicker(this, 41.0f, 42.0f, EnumFlowerChromosome.SAPPINESS);
new ControlChromoPicker(this, 37.0f, 63.0f, EnumFlowerChromosome.STEM);
}
else if (root == Binnie.Genetics.getButterflyRoot()) {
new ControlChromoPicker(this, 40.0f, 40.0f, EnumButterflyChromosome.SPECIES);
new ControlChromoPicker(this, 63.0f, 32.0f, EnumButterflyChromosome.SIZE);
new ControlChromoPicker(this, 32.0f, 63.0f, EnumButterflyChromosome.SPEED);
new ControlChromoPicker(this, 11.0f, 27.0f, EnumButterflyChromosome.LIFESPAN);
new ControlChromoPicker(this, 16.0f, 12.0f, EnumButterflyChromosome.METABOLISM);
new ControlChromoPicker(this, 17.0f, 63.0f, EnumButterflyChromosome.FERTILITY);
new ControlChromoPicker(this, 34.0f, 12.0f, EnumButterflyChromosome.TEMPERATURE_TOLERANCE);
new ControlChromoPicker(this, 22.0f, 46.0f, EnumButterflyChromosome.HUMIDITY_TOLERANCE);
new ControlChromoPicker(this, 53.0f, 26.0f, EnumButterflyChromosome.NOCTURNAL);
new ControlChromoPicker(this, 71.0f, 53.0f, EnumButterflyChromosome.TOLERANT_FLYER);
new ControlChromoPicker(this, 78.0f, 12.0f, EnumButterflyChromosome.FIRE_RESIST);
new ControlChromoPicker(this, 55.0f, 55.0f, EnumButterflyChromosome.FLOWER_PROVIDER);
new ControlChromoPicker(this, 27.0f, 31.0f, EnumButterflyChromosome.EFFECT);
new ControlChromoPicker(this, 87.0f, 45.0f, EnumButterflyChromosome.TERRITORY);
}
}
}
@Override
public IChromosomeType getValue() {
return this.chromo;
}
@Override
public void setValue(final IChromosomeType value) {
this.chromo = value;
}
@Override
public void onRenderBackground() {
if (this.species == null) {
return;
}
super.onRenderBackground();
final Texture text = this.getTypeTexture();
CraftGUI.Render.texture(text, IPoint.ZERO);
}
private Texture getTypeTexture() {
if (this.species == Binnie.Genetics.getBeeRoot()) {
return this.BeeTexture;
}
if (this.species == Binnie.Genetics.getTreeRoot()) {
return this.TreeTexture;
}
if (this.species == Binnie.Genetics.getButterflyRoot()) {
return this.MothTexture;
}
if (this.species == Binnie.Genetics.getFlowerRoot()) {
return this.FlowerTexture;
}
return null;
}
}
@@ -0,0 +1,36 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import binnie.craftgui.core.geometry.TextJustification;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.core.CraftGUI;
import binnie.craftgui.controls.listbox.ControlList;
import binnie.core.genetics.Gene;
import binnie.craftgui.controls.listbox.ControlOption;
public class ControlGenesisOption extends ControlOption<Gene>
{
public ControlGenesisOption(final ControlList<Gene> parent, final Gene gene, final int y) {
super(parent, gene, y);
}
String getAlleleName() {
return this.getValue().getAlleleName();
}
String getChromosomeName() {
return this.getValue().getShortChromosomeName();
}
@Override
public void onRenderBackground() {
super.onRenderBackground();
CraftGUI.Render.text(new IArea(0.0f, 0.0f, 70.0f, 22.0f), TextJustification.MiddleCenter, this.getChromosomeName(), this.getColour());
CraftGUI.Render.text(new IArea(75.0f, 0.0f, 80.0f, 22.0f), TextJustification.MiddleCenter, this.getAlleleName(), this.getColour());
CraftGUI.Render.solid(new IArea(70.0f, 2.0f, 1.0f, 16.0f), -16777216 + this.getColour());
}
}
@@ -0,0 +1,42 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import net.minecraft.item.ItemStack;
import forestry.api.genetics.AlleleManager;
import binnie.craftgui.core.Tooltip;
import binnie.core.genetics.BreedingSystem;
import binnie.Binnie;
import forestry.api.genetics.IIndividual;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.core.ITooltip;
import binnie.craftgui.minecraft.control.ControlItemDisplay;
public class ControlIndividualDisplay extends ControlItemDisplay implements ITooltip
{
public ControlIndividualDisplay(final IWidget parent, final float x, final float y, final IIndividual ind) {
this(parent, x, y, 16.0f, ind);
}
public ControlIndividualDisplay(final IWidget parent, final float x, final float y, final float size, final IIndividual ind) {
super(parent, x, y, size);
final BreedingSystem system = Binnie.Genetics.getSystem(ind.getGenome().getSpeciesRoot());
this.setItemStack(system.getSpeciesRoot().getMemberStack(ind, system.getDefaultType()));
this.setTooltip();
}
@Override
public void getTooltip(final Tooltip tooltip) {
final ItemStack stack = this.getItemStack();
if (stack == null) {
return;
}
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(stack);
if (ind == null) {
return;
}
tooltip.add(ind.getGenome().getPrimary().getName());
}
}
@@ -0,0 +1,78 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import binnie.core.genetics.Tolerance;
import forestry.api.genetics.EnumTolerance;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.core.geometry.IBorder;
import binnie.craftgui.core.CraftGUI;
import binnie.craftgui.core.Tooltip;
import forestry.api.core.EnumTemperature;
import binnie.craftgui.core.Attribute;
import binnie.craftgui.core.IWidget;
import java.util.EnumSet;
import binnie.craftgui.core.ITooltip;
import binnie.craftgui.controls.core.Control;
public abstract class ControlToleranceBar<T extends Enum<T>> extends Control implements ITooltip
{
private Class<T> enumClass;
EnumSet<T> tolerated;
EnumSet<T> fullSet;
public ControlToleranceBar(final IWidget parent, final float x, final float y, final float width, final float height, final Class<T> clss) {
super(parent, x, y, width, height);
this.addAttribute(Attribute.MouseOver);
this.enumClass = clss;
this.tolerated = EnumSet.noneOf(this.enumClass);
this.fullSet = EnumSet.allOf(this.enumClass);
if (this.enumClass == EnumTemperature.class) {
this.fullSet.remove(EnumTemperature.NONE);
}
}
@Override
public void getTooltip(final Tooltip list) {
final int types = this.fullSet.size();
final int type = (int) ((int) this.getRelativeMousePosition().x() / (this.getSize().x() / types));
for (final T tol : this.fullSet) {
if (tol.ordinal() - ((this.enumClass == EnumTemperature.class) ? 1 : 0) == type) {
list.add((this.tolerated.contains(tol) ? "" : "§8") + this.getName(tol));
}
}
}
protected abstract String getName(final T p0);
protected abstract int getColour(final T p0);
@Override
public void onRenderBackground() {
CraftGUI.Render.gradientRect(this.getArea(), -1431655766, -1431655766);
final float w = this.getArea().w() / this.fullSet.size();
int t = 0;
for (final T value : this.fullSet) {
final int col = (this.tolerated.contains(value) ? -16777216 : 855638016) + this.getColour(value);
final IBorder inset = new IBorder(this.tolerated.contains(value) ? 1.0f : 3.0f);
CraftGUI.Render.gradientRect(new IArea(w * t, 0.0f, w, this.h()).inset(inset), col, col);
++t;
}
}
public void setValues(final T value, final EnumTolerance enumTol) {
this.tolerated.clear();
final Tolerance tol = Tolerance.get(enumTol);
for (final T full : this.fullSet) {
if (full.ordinal() > value.ordinal() + tol.getBounds()[1]) {
continue;
}
if (full.ordinal() < value.ordinal() + tol.getBounds()[0]) {
continue;
}
this.tolerated.add(full);
}
}
}
@@ -0,0 +1,21 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import binnie.craftgui.core.Tooltip;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.core.ITooltip;
import binnie.craftgui.controls.core.Control;
public class ControlTooltip extends Control implements ITooltip
{
public ControlTooltip(final IWidget parent, final float x, final float y, final float w, final float h) {
super(parent, x, y, w, h);
}
@Override
public void getTooltip(final Tooltip tooltip) {
}
}
@@ -0,0 +1,485 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.genetics.gui;
import forestry.api.genetics.AlleleManager;
import forestry.api.lepidopterology.IButterfly;
import binnie.botany.api.IFlower;
import forestry.api.apiculture.IBee;
import forestry.api.arboriculture.ITree;
import binnie.craftgui.controls.ControlTextCentered;
import binnie.craftgui.events.EventKey;
import binnie.craftgui.minecraft.control.ControlPlayerInventory;
import binnie.craftgui.core.geometry.Position;
import binnie.craftgui.controls.scroll.ControlScrollBar;
import binnie.craftgui.minecraft.MinecraftGUI;
import binnie.craftgui.minecraft.InventoryType;
import binnie.craftgui.minecraft.control.ControlSlot;
import binnie.craftgui.core.geometry.IPoint;
import binnie.craftgui.resource.minecraft.CraftGUITexture;
import binnie.craftgui.core.CraftGUI;
import binnie.craftgui.core.Tooltip;
import binnie.craftgui.events.EventMouse;
import binnie.craftgui.core.Attribute;
import binnie.craftgui.core.Widget;
import forestry.api.genetics.IBreedingTracker;
import binnie.Binnie;
import binnie.genetics.machine.ModuleMachine;
import binnie.genetics.item.GeneticsItems;
import binnie.genetics.machine.Analyser;
import net.minecraft.item.ItemStack;
import binnie.core.machines.inventory.SlotValidator;
import binnie.genetics.Genetics;
import binnie.core.AbstractMod;
import java.util.ArrayList;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.inventory.IInventory;
import net.minecraft.entity.player.EntityPlayer;
import binnie.core.genetics.BreedingSystem;
import forestry.api.genetics.IIndividual;
import binnie.craftgui.minecraft.control.ControlSlide;
import binnie.craftgui.core.geometry.IArea;
import java.util.List;
import binnie.craftgui.window.Panel;
import binnie.craftgui.controls.core.Control;
import binnie.craftgui.controls.scroll.ControlScrollableContent;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.minecraft.Window;
public class WindowAnalyst extends Window
{
IWidget baseWidget;
ControlScrollableContent leftPage;
ControlScrollableContent rightPage;
Control tabBar;
Panel analystPanel;
List<ControlAnalystPage> analystPages;
IArea analystPageSize;
boolean isDatabase;
boolean isMaster;
boolean lockedSearch;
private Control analystNone;
private ControlSlide slideUpInv;
IIndividual current;
BreedingSystem currentSystem;
public WindowAnalyst(final EntityPlayer player, final IInventory inventory, final Side side, final boolean database, final boolean master) {
super(312.0f, 230.0f, player, inventory, side);
this.baseWidget = null;
this.tabBar = null;
this.analystPages = new ArrayList<ControlAnalystPage>();
this.analystPageSize = null;
this.isDatabase = false;
this.isMaster = false;
this.lockedSearch = false;
this.current = null;
this.currentSystem = null;
this.isDatabase = database;
this.isMaster = master;
this.lockedSearch = this.isDatabase;
}
@Override
protected AbstractMod getMod() {
return Genetics.instance;
}
@Override
protected String getName() {
return "Analyst";
}
private void setupValidators() {
if (!this.isDatabase) {
this.getWindowInventory().setValidator(0, new SlotValidator.Individual() {
@Override
public boolean isValid(final ItemStack itemStack) {
return Analyser.isAnalysed(itemStack) || (Analyser.isAnalysable(itemStack) && WindowAnalyst.this.getWindowInventory().getStackInSlot(1) != null);
}
});
this.getWindowInventory().setValidator(1, new SlotValidator.Item(GeneticsItems.DNADye.get(1), ModuleMachine.IconDye));
}
}
@Override
public void initialiseServer() {
for (final BreedingSystem system : Binnie.Genetics.getActiveSystems()) {
final IBreedingTracker tracker = system.getSpeciesRoot().getBreedingTracker(this.getWorld(), this.getUsername());
if (tracker != null) {
tracker.synchToPlayer(this.getPlayer());
}
}
this.setupValidators();
}
@Override
public void initialiseClient() {
this.setTitle(this.isDatabase ? (this.isMaster ? "Master Registry" : "Registry") : "Analyst");
final BreedingSystem system = Binnie.Genetics.beeBreedingSystem;
final IIndividual ind = system.getDefaultIndividual();
final ItemStack stack = system.getSpeciesRoot().getMemberStack(ind, system.getDefaultType());
this.getWindowInventory().createSlot(0);
this.baseWidget = new Widget(this);
int x = 16;
final int y = 28;
if (this.isDatabase) {
for (final BreedingSystem syst : Binnie.Genetics.getActiveSystems()) {
new Control(this, x, y, 20.0f, 20.0f) {
@Override
public void initialise() {
this.addAttribute(Attribute.MouseOver);
this.addSelfEventHandler(new EventMouse.Down.Handler() {
@Override
public void onEvent(final EventMouse.Down event) {
WindowAnalyst.this.setSystem(syst);
}
});
}
@Override
public void getTooltip(final Tooltip tooltip) {
tooltip.add(syst.getName());
}
@Override
public void onRenderBackground() {
CraftGUI.Render.colour(syst.getColour());
final int outset = (WindowAnalyst.this.getSystem() == syst) ? 1 : 0;
CraftGUI.Render.texture(CraftGUITexture.TabOutline, this.getArea().outset(outset));
if (WindowAnalyst.this.getSystem() == syst) {
CraftGUI.Render.colour(1140850688 + syst.getColour());
CraftGUI.Render.texture(CraftGUITexture.TabSolid, this.getArea().outset(outset));
}
CraftGUI.Render.item(new IPoint(2.0f, 2.0f), syst.getItemStackRepresentitive());
}
};
x += 22;
}
}
else {
new ControlSlot(this, x, y + 1).assign(InventoryType.Window, 0);
x += 22;
new ControlSlot(this, x, y + 1).assign(InventoryType.Window, 1);
x += 26;
this.setupValidators();
}
this.tabBar = new Control(this, x, 28.0f, this.w() - 16.0f - x, 20.0f);
this.analystPanel = new Panel(this, 16.0f, 54.0f, 280.0f, 164.0f, MinecraftGUI.PanelType.Outline) {
@Override
public void onRenderBackground() {
CraftGUI.Render.gradientRect(this.getArea(), 1157627903, 1728053247);
super.onRenderBackground();
}
@Override
public void initialise() {
this.setColour(4473924);
final float sectionWidth = (this.w() - 8.0f - 4.0f) / 2.0f;
WindowAnalyst.this.leftPage = new ControlScrollableContent<IWidget>(this, 3.0f, 3.0f, sectionWidth + 2.0f, this.h() - 8.0f + 2.0f, 0.0f) {
@Override
public void onRenderBackground() {
if (this.getContent() == null) {
return;
}
CraftGUI.Render.colour(this.getContent().getColour());
CraftGUI.Render.texture(CraftGUITexture.TabOutline, this.getArea());
}
};
new ControlScrollBar(this, sectionWidth + 2.0f - 3.0f, 6.0f, 3.0f, this.h() - 8.0f + 2.0f - 6.0f, WindowAnalyst.this.leftPage) {
@Override
public void onRenderBackground() {
if (!this.isEnabled()) {
return;
}
if (WindowAnalyst.this.leftPage.getContent() == null) {
return;
}
CraftGUI.Render.gradientRect(this.getArea(), 1140850688 + WindowAnalyst.this.leftPage.getContent().getColour(), 1140850688 + WindowAnalyst.this.leftPage.getContent().getColour());
CraftGUI.Render.solid(this.getRenderArea(), WindowAnalyst.this.leftPage.getContent().getColour());
}
};
WindowAnalyst.this.rightPage = new ControlScrollableContent<IWidget>(this, 3.0f + sectionWidth + 4.0f, 3.0f, sectionWidth + 2.0f, this.h() - 8.0f + 2.0f, 0.0f) {
@Override
public void onRenderBackground() {
if (this.getContent() == null) {
return;
}
CraftGUI.Render.colour(this.getContent().getColour());
CraftGUI.Render.texture(CraftGUITexture.TabOutline, this.getArea());
}
};
new ControlScrollBar(this, sectionWidth + 2.0f - 3.0f + sectionWidth + 4.0f, 6.0f, 3.0f, this.h() - 8.0f + 2.0f - 6.0f, WindowAnalyst.this.rightPage) {
@Override
public void onRenderBackground() {
if (!this.isEnabled()) {
return;
}
if (WindowAnalyst.this.rightPage.getContent() == null) {
return;
}
CraftGUI.Render.gradientRect(this.getArea(), 1140850688 + WindowAnalyst.this.rightPage.getContent().getColour(), 1140850688 + WindowAnalyst.this.rightPage.getContent().getColour());
CraftGUI.Render.solid(this.getRenderArea(), WindowAnalyst.this.rightPage.getContent().getColour());
}
};
WindowAnalyst.this.analystPageSize = new IArea(1.0f, 1.0f, sectionWidth, this.h() - 8.0f);
}
};
if (!this.isDatabase) {
this.slideUpInv = new ControlSlide(this, (this.getSize().x() - 244.0f) / 2.0f, this.getSize().y() - 80.0f + 1.0f, 244.0f, 80.0f, Position.Bottom);
new ControlPlayerInventory(this.slideUpInv, true);
this.slideUpInv.setSlide(false);
}
this.addEventHandler(new EventKey.Down.Handler() {
@Override
public void onEvent(final EventKey.Down event) {
if (event.getKey() == 205) {
WindowAnalyst.this.shiftPages(true);
}
if (event.getKey() == 203) {
WindowAnalyst.this.shiftPages(false);
}
}
});
if (!this.isDatabase) {
this.analystNone = new Control(this.analystPanel, 0.0f, 0.0f, this.analystPanel.w(), this.analystPanel.h()) {
@Override
public void initialise() {
new ControlTextCentered(this, 20.0f, "Add a bee, tree, flower or butterfly to the top left slot. DNA Dye is required if it has not been analysed yet. This dye can also convert vanilla items to breedable individuals.").setColour(4473924);
new ControlPlayerInventory(this);
}
};
}
this.setIndividual(null);
this.setSystem(Binnie.Genetics.beeBreedingSystem);
}
public void setIndividual(final IIndividual ind) {
if (!this.isDatabase) {
if (ind == null) {
this.analystNone.show();
this.slideUpInv.hide();
}
else {
this.analystNone.hide();
this.slideUpInv.show();
}
}
if (ind == this.current || (ind != null && this.current != null && ind.isGeneticEqual(this.current))) {
return;
}
final boolean systemChange = (this.current = ind) != null && ind.getGenome().getSpeciesRoot() != this.getSystem().getSpeciesRoot();
if (systemChange) {
this.currentSystem = Binnie.Genetics.getSystem(ind.getGenome().getSpeciesRoot());
}
this.updatePages(systemChange);
}
public void setSystem(final BreedingSystem system) {
if (system == this.currentSystem) {
return;
}
this.currentSystem = system;
this.current = null;
this.updatePages(true);
}
public void updatePages(final boolean systemChange) {
int oldLeft = -1;
int oldRight = -1;
if (!systemChange) {
oldLeft = this.analystPages.indexOf(this.leftPage.getContent());
oldRight = this.analystPages.indexOf(this.rightPage.getContent());
}
ControlAnalystPage databasePage = null;
if (this.isDatabase && !systemChange) {
databasePage = ((this.analystPages.size() > 0) ? this.analystPages.get(0) : null);
}
this.analystPages.clear();
this.setPage(this.leftPage, null);
this.setPage(this.rightPage, null);
if (this.isDatabase) {
this.analystPages.add((databasePage != null) ? databasePage : new AnalystPageDatabase(this.analystPanel, this.analystPageSize, this.currentSystem, this.isMaster));
}
if (this.current != null) {
this.analystPages.add(new AnalystPageDescription(this.analystPanel, this.analystPageSize, this.current));
this.analystPages.add(new AnalystPageGenome(this.analystPanel, this.analystPageSize, true, this.current));
if (!this.isDatabase) {
this.analystPages.add(new AnalystPageGenome(this.analystPanel, this.analystPageSize, false, this.current));
this.analystPages.add(new AnalystPageKaryogram(this.analystPanel, this.analystPageSize, this.current));
}
if (!(this.current instanceof ITree)) {
this.analystPages.add(new AnalystPageClimate(this.analystPanel, this.analystPageSize, this.current));
}
if (this.current instanceof IBee) {
this.analystPages.add(new AnalystPageProducts(this.analystPanel, this.analystPageSize, (IBee) this.current));
}
else if (this.current instanceof ITree) {
this.analystPages.add(new AnalystPageFruit(this.analystPanel, this.analystPageSize, (ITree) this.current));
this.analystPages.add(new AnalystPageWood(this.analystPanel, this.analystPageSize, (ITree) this.current));
}
else if (this.current instanceof IFlower) {
this.analystPages.add(new AnalystPageSoil(this.analystPanel, this.analystPageSize, (IFlower) this.current));
}
else if (this.current instanceof IButterfly) {
this.analystPages.add(new AnalystPageSpecimen(this.analystPanel, this.analystPageSize, (IButterfly) this.current));
}
this.analystPages.add(new AnalystPageBiology(this.analystPanel, this.analystPageSize, this.current));
if (this.current instanceof IBee || this.current instanceof IButterfly) {
this.analystPages.add(new AnalystPageBehaviour(this.analystPanel, this.analystPageSize, this.current));
}
else if (this.current instanceof ITree) {
this.analystPages.add(new AnalystPageGrowth(this.analystPanel, this.analystPageSize, this.current));
}
else if (this.current instanceof IFlower) {
this.analystPages.add(new AnalystPageAppearance(this.analystPanel, this.analystPageSize, (IFlower) this.current));
}
this.analystPages.add(new AnalystPageMutations(this.analystPanel, this.analystPageSize, this.current, this.isMaster));
}
this.tabBar.deleteAllChildren();
final float width = this.tabBar.w() / this.analystPages.size();
float x = 0.0f;
for (final ControlAnalystPage page : this.analystPages) {
new ControlTooltip(this.tabBar, x, 0.0f, width, this.tabBar.h()) {
ControlAnalystPage value;
@Override
public void getTooltip(final Tooltip tooltip) {
tooltip.add(this.value.getTitle());
}
@Override
protected void initialise() {
super.initialise();
this.addAttribute(Attribute.MouseOver);
this.value = page;
this.addSelfEventHandler(new EventMouse.Down.Handler() {
@Override
public void onEvent(final EventMouse.Down event) {
final int currentIndex = WindowAnalyst.this.analystPages.indexOf(WindowAnalyst.this.rightPage.getContent());
int clickedIndex = WindowAnalyst.this.analystPages.indexOf(value);
if (WindowAnalyst.this.isDatabase) {
if (clickedIndex != 0 && clickedIndex != currentIndex) {
WindowAnalyst.this.setPage(WindowAnalyst.this.rightPage, value);
}
}
else {
if (clickedIndex < 0) {
clickedIndex = 0;
}
if (clickedIndex < currentIndex) {
++clickedIndex;
}
WindowAnalyst.this.setPage(WindowAnalyst.this.rightPage, null);
WindowAnalyst.this.setPage(WindowAnalyst.this.leftPage, null);
WindowAnalyst.this.setPage(WindowAnalyst.this.rightPage, WindowAnalyst.this.analystPages.get(clickedIndex));
WindowAnalyst.this.setPage(WindowAnalyst.this.leftPage, WindowAnalyst.this.analystPages.get(clickedIndex - 1));
}
}
});
}
@Override
public void onRenderBackground() {
final boolean active = this.value == WindowAnalyst.this.leftPage.getContent() || this.value == WindowAnalyst.this.rightPage.getContent();
CraftGUI.Render.colour((active ? -16777216 : 1140850688) + this.value.getColour());
CraftGUI.Render.texture(CraftGUITexture.TabSolid, this.getArea().inset(1));
CraftGUI.Render.colour(this.value.getColour());
CraftGUI.Render.texture(CraftGUITexture.TabOutline, this.getArea().inset(1));
super.onRenderBackground();
}
};
x += width;
}
if (this.analystPages.size() > 0) {
this.setPage(this.leftPage, this.analystPages.get((oldLeft >= 0) ? oldLeft : 0));
}
if (this.analystPages.size() > 1) {
this.setPage(this.rightPage, this.analystPages.get((oldRight >= 0) ? oldRight : 1));
}
}
public void shiftPages(final boolean right) {
if (this.analystPages.size() < 2) {
return;
}
final int leftIndex = this.analystPages.indexOf(this.leftPage.getContent());
final int rightIndex = this.analystPages.indexOf(this.rightPage.getContent());
if (right && rightIndex + 1 >= this.analystPages.size()) {
return;
}
if (!this.lockedSearch && !right && leftIndex <= 0) {
return;
}
if (!this.lockedSearch && !right && rightIndex <= 1) {
return;
}
final int newRightIndex = rightIndex + (right ? 1 : -1);
final int newLeftIndex = this.lockedSearch ? 0 : (newRightIndex - 1);
float oldRightPercent = 0.0f;
float oldLeftPercent = 0.0f;
if (newLeftIndex == rightIndex) {
oldRightPercent = this.rightPage.getPercentageIndex();
}
if (newRightIndex == leftIndex) {
oldLeftPercent = this.leftPage.getPercentageIndex();
}
this.setPage(this.leftPage, null);
this.setPage(this.rightPage, null);
this.setPage(this.leftPage, this.analystPages.get(newLeftIndex));
this.setPage(this.rightPage, this.analystPages.get(newRightIndex));
this.analystPages.get(newLeftIndex).show();
if (oldRightPercent != 0.0f) {
this.leftPage.setPercentageIndex(oldRightPercent);
}
if (oldLeftPercent != 0.0f) {
this.rightPage.setPercentageIndex(oldLeftPercent);
}
}
public void setPage(final ControlScrollableContent side, final ControlAnalystPage page) {
final ControlAnalystPage existingPage = (ControlAnalystPage) side.getContent();
if (existingPage != null) {
existingPage.hide();
side.setScrollableContent(null);
}
if (page != null) {
page.show();
side.setScrollableContent(page);
side.setPercentageIndex(0.0f);
page.setPosition(side.pos().add(1.0f, 1.0f));
}
}
@Override
public void onWindowInventoryChanged() {
super.onWindowInventoryChanged();
if (this.getWindowInventory().getStackInSlot(0) != null && !Analyser.isAnalysed(this.getWindowInventory().getStackInSlot(0))) {
this.getWindowInventory().setInventorySlotContents(0, Analyser.analyse(this.getWindowInventory().getStackInSlot(0)));
this.getWindowInventory().decrStackSize(1, 1);
}
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(this.getWindowInventory().getStackInSlot(0));
if (ind != null) {
ind.getGenome().getSpeciesRoot().getBreedingTracker(this.getWorld(), this.getUsername()).registerBirth(ind);
}
if (this.isClient()) {
this.setStack(this.getWindowInventory().getStackInSlot(0));
}
else if (this.isServer()) {
}
}
public void setStack(final ItemStack stack) {
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(stack);
this.setIndividual(ind);
}
public IIndividual getIndividual() {
return this.current;
}
public BreedingSystem getSystem() {
return this.currentSystem;
}
}