Update buildscript & spotlessApply

This commit is contained in:
DianeXD committed 2022-07-03 12:17:51 +08:00
1 parent e4329e2b8f
commit 8683a345c3
818 files changed
+51123 -49403

No files matched your search

@@ -15,163 +15,160 @@ import forestry.api.apiculture.IBeeRoot;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.genetics.EnumTolerance;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
public class ControlClimateBar extends Control implements ITooltip {
protected boolean isHumidity;
protected List<Integer> tolerated;
protected boolean isHumidity;
protected List<Integer> tolerated;
private static final Color[] TEMP_COLORS = new Color[]{
new Color(0x00fffb),
new Color(0x78bbff),
new Color(0x4fff30),
new Color(0xffff00),
new Color(0xffa200),
new Color(0xff0000)
};
private static final Color[] HUMID_COLORS = new Color[]{
new Color(0xffe7a3),
new Color(0x1aff00),
new Color(0x307cff)
};
private static final Color[] TEMP_COLORS = new Color[] {
new Color(0x00fffb),
new Color(0x78bbff),
new Color(0x4fff30),
new Color(0xffff00),
new Color(0xffa200),
new Color(0xff0000)
};
private static final Color[] HUMID_COLORS =
new Color[] {new Color(0xffe7a3), new Color(0x1aff00), new Color(0x307cff)};
public ControlClimateBar(IWidget parent, int x, int y, int width, int height) {
this(parent, x, y, width, height, false);
}
public ControlClimateBar(IWidget parent, int x, int y, int width, int height) {
this(parent, x, y, width, height, false);
}
public ControlClimateBar(IWidget parent, int x, int y, int width, int height, boolean humidity) {
super(parent, x, y, width, height);
tolerated = new ArrayList<>();
addAttribute(WidgetAttribute.MOUSE_OVER);
isHumidity = humidity;
}
public ControlClimateBar(IWidget parent, int x, int y, int width, int height, boolean humidity) {
super(parent, x, y, width, height);
tolerated = new ArrayList<>();
addAttribute(WidgetAttribute.MOUSE_OVER);
isHumidity = humidity;
}
@Override
public void getTooltip(Tooltip tooltip) {
if (tolerated.isEmpty()) {
return;
}
@Override
public void getTooltip(Tooltip tooltip) {
if (tolerated.isEmpty()) {
return;
}
int types = isHumidity ? 3 : 6;
int type = (int) ((int) (getRelativeMousePosition().x() - 1.0f) / ((getSize().x() - 2.0f) / types));
if (!tolerated.contains(type) || type >= types) {
return;
}
int types = isHumidity ? 3 : 6;
int type = (int)
((int) (getRelativeMousePosition().x() - 1.0f) / ((getSize().x() - 2.0f) / types));
if (!tolerated.contains(type) || type >= types) {
return;
}
if (isHumidity) {
tooltip.add(EnumHumidity.values()[type].name);
} else {
tooltip.add(EnumTemperature.values()[type + 1].name);
}
}
if (isHumidity) {
tooltip.add(EnumHumidity.values()[type].name);
} else {
tooltip.add(EnumTemperature.values()[type + 1].name);
}
}
@Override
public void onRenderBackground() {
CraftGUI.render.texture(CraftGUITexture.EnergyBarBack, getArea());
int types = isHumidity ? 3 : 6;
int w = (int) ((getSize().x() - 2.0f) / types);
for (int i = 0; i < types; ++i) {
int x = i * w;
if (tolerated.contains(i)) {
Color color;
if (isHumidity) {
color = HUMID_COLORS[i];
} else {
color = TEMP_COLORS[i];
}
CraftGUI.render.solid(new IArea(x + 1, 1.0f, w, getSize().y() - 2.0f), color.getRGB());
}
}
CraftGUI.render.texture(CraftGUITexture.EnergyBarGlass, getArea());
}
@Override
public void onRenderBackground() {
CraftGUI.render.texture(CraftGUITexture.EnergyBarBack, getArea());
int types = isHumidity ? 3 : 6;
int w = (int) ((getSize().x() - 2.0f) / types);
for (int i = 0; i < types; ++i) {
int x = i * w;
if (tolerated.contains(i)) {
Color color;
if (isHumidity) {
color = HUMID_COLORS[i];
} else {
color = TEMP_COLORS[i];
}
CraftGUI.render.solid(new IArea(x + 1, 1.0f, w, getSize().y() - 2.0f), color.getRGB());
}
}
CraftGUI.render.texture(CraftGUITexture.EnergyBarGlass, getArea());
}
public void setSpecies(IAlleleBeeSpecies species) {
tolerated.clear();
if (species == null) {
return;
}
public void setSpecies(IAlleleBeeSpecies species) {
tolerated.clear();
if (species == null) {
return;
}
int main;
EnumTolerance tolerance;
IBeeRoot beeRoot = Binnie.Genetics.getBeeRoot();
IBeeGenome genome = beeRoot.templateAsGenome(beeRoot.getTemplate(species.getUID()));
if (!isHumidity) {
main = species.getTemperature().ordinal() - 1;
tolerance = genome.getToleranceTemp();
} else {
main = species.getHumidity().ordinal();
tolerance = genome.getToleranceHumid();
}
int main;
EnumTolerance tolerance;
IBeeRoot beeRoot = Binnie.Genetics.getBeeRoot();
IBeeGenome genome = beeRoot.templateAsGenome(beeRoot.getTemplate(species.getUID()));
if (!isHumidity) {
main = species.getTemperature().ordinal() - 1;
tolerance = genome.getToleranceTemp();
} else {
main = species.getHumidity().ordinal();
tolerance = genome.getToleranceHumid();
}
tolerated.add(main);
switch (tolerance) {
case BOTH_5:
case UP_5:
addTolerance(main, 5);
break;
tolerated.add(main);
switch (tolerance) {
case BOTH_5:
case UP_5:
addTolerance(main, 5);
break;
case BOTH_4:
case UP_4:
addTolerance(main, 4);
break;
case BOTH_4:
case UP_4:
addTolerance(main, 4);
break;
case BOTH_3:
case UP_3:
addTolerance(main, 3);
break;
case BOTH_3:
case UP_3:
addTolerance(main, 3);
break;
case BOTH_2:
case UP_2:
addTolerance(main, 2);
break;
case BOTH_2:
case UP_2:
addTolerance(main, 2);
break;
case BOTH_1:
case UP_1:
addTolerance(main, 1);
break;
}
case BOTH_1:
case UP_1:
addTolerance(main, 1);
break;
}
switch (tolerance) {
case BOTH_5:
case DOWN_5:
addTolerance(main, -5);
break;
switch (tolerance) {
case BOTH_5:
case DOWN_5:
addTolerance(main, -5);
break;
case BOTH_4:
case DOWN_4:
addTolerance(main, -4);
break;
case BOTH_4:
case DOWN_4:
addTolerance(main, -4);
break;
case BOTH_3:
case DOWN_3:
addTolerance(main, -3);
break;
case BOTH_3:
case DOWN_3:
addTolerance(main, -3);
break;
case BOTH_2:
case DOWN_2:
addTolerance(main, -2);
break;
case BOTH_2:
case DOWN_2:
addTolerance(main, -2);
break;
case BOTH_1:
case DOWN_1:
addTolerance(main, -1);
break;
}
}
case BOTH_1:
case DOWN_1:
addTolerance(main, -1);
break;
}
}
private void addTolerance(int main, int offset) {
offset += main;
if (main > offset) {
for (int i = offset; i < main; i++) {
tolerated.add(i);
}
} else {
for (int i = offset; i > main; i--) {
tolerated.add(i);
}
}
}
private void addTolerance(int main, int offset) {
offset += main;
if (main > offset) {
for (int i = offset; i < main; i++) {
tolerated.add(i);
}
} else {
for (int i = offset; i > main; i--) {
tolerated.add(i);
}
}
}
}
@@ -9,19 +9,19 @@ import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.genetics.IAlleleSpecies;
public class PageSpeciesClimate extends PageSpecies {
protected ControlClimateBar tempBar;
protected ControlClimateBar humidBar;
protected ControlClimateBar tempBar;
protected ControlClimateBar humidBar;
public PageSpeciesClimate(IWidget parent, DatabaseTab tab) {
super(parent, tab);
new ControlTextCentered(this, 8.0f, I18N.localise("extrabees.gui.database.tab.species.climate"));
tempBar = new ControlClimateBar(this, 8, 24, 128, 12);
humidBar = new ControlClimateBar(this, 8, 42, 128, 12, true);
}
public PageSpeciesClimate(IWidget parent, DatabaseTab tab) {
super(parent, tab);
new ControlTextCentered(this, 8.0f, I18N.localise("extrabees.gui.database.tab.species.climate"));
tempBar = new ControlClimateBar(this, 8, 24, 128, 12);
humidBar = new ControlClimateBar(this, 8, 42, 128, 12, true);
}
@Override
public void onValueChanged(IAlleleSpecies species) {
tempBar.setSpecies((IAlleleBeeSpecies) species);
humidBar.setSpecies((IAlleleBeeSpecies) species);
}
@Override
public void onValueChanged(IAlleleSpecies species) {
tempBar.setSpecies((IAlleleBeeSpecies) species);
humidBar.setSpecies((IAlleleBeeSpecies) species);
}
}
@@ -17,164 +17,205 @@ import forestry.api.genetics.IAlleleSpecies;
import forestry.core.genetics.alleles.EnumAllele;
public class PageSpeciesGenome extends PageSpecies {
protected ControlText title;
protected ControlText speedText;
protected ControlText lifespanText;
protected ControlText fertilityText;
protected ControlText floweringText;
protected ControlText territoryText;
protected ControlText nocturnalText;
protected ControlText caveDwellingText;
protected ControlText tolerantFlyerText;
protected ControlText flowerText;
protected ControlText effectText;
protected ControlText title;
protected ControlText speedText;
protected ControlText lifespanText;
protected ControlText fertilityText;
protected ControlText floweringText;
protected ControlText territoryText;
protected ControlText nocturnalText;
protected ControlText caveDwellingText;
protected ControlText tolerantFlyerText;
protected ControlText flowerText;
protected ControlText effectText;
public PageSpeciesGenome(IWidget parent, DatabaseTab tab) {
super(parent, tab);
title = new ControlTextCentered(this, 8.0f, I18N.localise("extrabees.gui.database.tab.species.genome"));
new ControlText(this, new IArea(0.0f, 32.0f, 68.0f, 30.0f), I18N.localise("extrabees.gui.database.tab.species.genome.speed"), TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 44.0f, 68.0f, 30.0f), I18N.localise("extrabees.gui.database.tab.species.genome.lifespan"), TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 56.0f, 68.0f, 30.0f), I18N.localise("extrabees.gui.database.tab.species.genome.fertility"), TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 68.0f, 68.0f, 30.0f), I18N.localise("extrabees.gui.database.tab.species.genome.flowering"), TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 80.0f, 68.0f, 30.0f), I18N.localise("extrabees.gui.database.tab.species.genome.territory"), TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 97.0f, 68.0f, 30.0f), I18N.localise("extrabees.gui.database.tab.species.genome.behavior"), TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 109.0f, 68.0f, 30.0f), I18N.localise("extrabees.gui.database.tab.species.genome.sunlight"), TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 121.0f, 68.0f, 30.0f), I18N.localise("extrabees.gui.database.tab.species.genome.rain"), TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 138.0f, 68.0f, 30.0f), I18N.localise("extrabees.gui.database.tab.species.genome.flower"), TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 155.0f, 68.0f, 30.0f), I18N.localise("extrabees.gui.database.tab.species.genome.effect"), TextJustification.TOP_RIGHT);
int x = 72;
public PageSpeciesGenome(IWidget parent, DatabaseTab tab) {
super(parent, tab);
title = new ControlTextCentered(this, 8.0f, I18N.localise("extrabees.gui.database.tab.species.genome"));
new ControlText(
this,
new IArea(0.0f, 32.0f, 68.0f, 30.0f),
I18N.localise("extrabees.gui.database.tab.species.genome.speed"),
TextJustification.TOP_RIGHT);
new ControlText(
this,
new IArea(0.0f, 44.0f, 68.0f, 30.0f),
I18N.localise("extrabees.gui.database.tab.species.genome.lifespan"),
TextJustification.TOP_RIGHT);
new ControlText(
this,
new IArea(0.0f, 56.0f, 68.0f, 30.0f),
I18N.localise("extrabees.gui.database.tab.species.genome.fertility"),
TextJustification.TOP_RIGHT);
new ControlText(
this,
new IArea(0.0f, 68.0f, 68.0f, 30.0f),
I18N.localise("extrabees.gui.database.tab.species.genome.flowering"),
TextJustification.TOP_RIGHT);
new ControlText(
this,
new IArea(0.0f, 80.0f, 68.0f, 30.0f),
I18N.localise("extrabees.gui.database.tab.species.genome.territory"),
TextJustification.TOP_RIGHT);
new ControlText(
this,
new IArea(0.0f, 97.0f, 68.0f, 30.0f),
I18N.localise("extrabees.gui.database.tab.species.genome.behavior"),
TextJustification.TOP_RIGHT);
new ControlText(
this,
new IArea(0.0f, 109.0f, 68.0f, 30.0f),
I18N.localise("extrabees.gui.database.tab.species.genome.sunlight"),
TextJustification.TOP_RIGHT);
new ControlText(
this,
new IArea(0.0f, 121.0f, 68.0f, 30.0f),
I18N.localise("extrabees.gui.database.tab.species.genome.rain"),
TextJustification.TOP_RIGHT);
new ControlText(
this,
new IArea(0.0f, 138.0f, 68.0f, 30.0f),
I18N.localise("extrabees.gui.database.tab.species.genome.flower"),
TextJustification.TOP_RIGHT);
new ControlText(
this,
new IArea(0.0f, 155.0f, 68.0f, 30.0f),
I18N.localise("extrabees.gui.database.tab.species.genome.effect"),
TextJustification.TOP_RIGHT);
int x = 72;
speedText = new ControlText(this, new IArea(x, 32.0f, 72.0f, 30.0f), "", TextJustification.TOP_LEFT);
lifespanText = new ControlText(this, new IArea(x, 44.0f, 72.0f, 30.0f), "", TextJustification.TOP_LEFT);
fertilityText = new ControlText(this, new IArea(x, 56.0f, 72.0f, 30.0f), "", TextJustification.TOP_LEFT);
floweringText = new ControlText(this, new IArea(x, 68.0f, 72.0f, 30.0f), "", TextJustification.TOP_LEFT);
territoryText = new ControlText(this, new IArea(x, 80.0f, 72.0f, 30.0f), "", TextJustification.TOP_LEFT);
nocturnalText = new ControlText(this, new IArea(x, 97.0f, 72.0f, 30.0f), "", TextJustification.TOP_LEFT);
caveDwellingText = new ControlText(this, new IArea(x, 109.0f, 72.0f, 30.0f), "", TextJustification.TOP_LEFT);
tolerantFlyerText = new ControlText(this, new IArea(x, 121.0f, 72.0f, 30.0f), "", TextJustification.TOP_LEFT);
flowerText = new ControlText(this, new IArea(x, 138.0f, 72.0f, 30.0f), "", TextJustification.TOP_LEFT);
effectText = new ControlText(this, new IArea(x, 155.0f, 72.0f, 30.0f), "", TextJustification.TOP_LEFT);
}
speedText = new ControlText(this, new IArea(x, 32.0f, 72.0f, 30.0f), "", TextJustification.TOP_LEFT);
lifespanText = new ControlText(this, new IArea(x, 44.0f, 72.0f, 30.0f), "", TextJustification.TOP_LEFT);
fertilityText = new ControlText(this, new IArea(x, 56.0f, 72.0f, 30.0f), "", TextJustification.TOP_LEFT);
floweringText = new ControlText(this, new IArea(x, 68.0f, 72.0f, 30.0f), "", TextJustification.TOP_LEFT);
territoryText = new ControlText(this, new IArea(x, 80.0f, 72.0f, 30.0f), "", TextJustification.TOP_LEFT);
nocturnalText = new ControlText(this, new IArea(x, 97.0f, 72.0f, 30.0f), "", TextJustification.TOP_LEFT);
caveDwellingText = new ControlText(this, new IArea(x, 109.0f, 72.0f, 30.0f), "", TextJustification.TOP_LEFT);
tolerantFlyerText = new ControlText(this, new IArea(x, 121.0f, 72.0f, 30.0f), "", TextJustification.TOP_LEFT);
flowerText = new ControlText(this, new IArea(x, 138.0f, 72.0f, 30.0f), "", TextJustification.TOP_LEFT);
effectText = new ControlText(this, new IArea(x, 155.0f, 72.0f, 30.0f), "", TextJustification.TOP_LEFT);
}
public static String rateFlowering(int flowering) {
if (flowering >= 99) {
return AlleleHelper.toDisplay(EnumAllele.Flowering.MAXIMUM);
}
if (flowering >= 35) {
return AlleleHelper.toDisplay(EnumAllele.Flowering.FASTEST);
}
if (flowering >= 30) {
return AlleleHelper.toDisplay(EnumAllele.Flowering.FASTER);
}
if (flowering >= 25) {
return AlleleHelper.toDisplay(EnumAllele.Flowering.FAST);
}
if (flowering >= 20) {
return AlleleHelper.toDisplay(EnumAllele.Flowering.AVERAGE);
}
if (flowering >= 15) {
return AlleleHelper.toDisplay(EnumAllele.Flowering.SLOW);
}
if (flowering >= 10) {
return AlleleHelper.toDisplay(EnumAllele.Flowering.SLOWER);
}
return AlleleHelper.toDisplay(EnumAllele.Flowering.SLOWEST);
}
public static String rateFlowering(int flowering) {
if (flowering >= 99) {
return AlleleHelper.toDisplay(EnumAllele.Flowering.MAXIMUM);
}
if (flowering >= 35) {
return AlleleHelper.toDisplay(EnumAllele.Flowering.FASTEST);
}
if (flowering >= 30) {
return AlleleHelper.toDisplay(EnumAllele.Flowering.FASTER);
}
if (flowering >= 25) {
return AlleleHelper.toDisplay(EnumAllele.Flowering.FAST);
}
if (flowering >= 20) {
return AlleleHelper.toDisplay(EnumAllele.Flowering.AVERAGE);
}
if (flowering >= 15) {
return AlleleHelper.toDisplay(EnumAllele.Flowering.SLOW);
}
if (flowering >= 10) {
return AlleleHelper.toDisplay(EnumAllele.Flowering.SLOWER);
}
return AlleleHelper.toDisplay(EnumAllele.Flowering.SLOWEST);
}
public static String rateSpeed(float speed) {
if (speed >= 1.7f) {
return AlleleHelper.toDisplay(EnumAllele.Speed.FASTEST);
}
if (speed >= 1.4f) {
return AlleleHelper.toDisplay(EnumAllele.Speed.FASTER);
}
if (speed >= 1.2f) {
return AlleleHelper.toDisplay(EnumAllele.Speed.FAST);
}
if (speed >= 1.0f) {
return AlleleHelper.toDisplay(EnumAllele.Speed.NORMAL);
}
if (speed >= 0.8f) {
return AlleleHelper.toDisplay(EnumAllele.Speed.SLOW);
}
if (speed >= 0.6f) {
return AlleleHelper.toDisplay(EnumAllele.Speed.SLOWER);
}
return AlleleHelper.toDisplay(EnumAllele.Speed.SLOWEST);
}
public static String rateSpeed(float speed) {
if (speed >= 1.7f) {
return AlleleHelper.toDisplay(EnumAllele.Speed.FASTEST);
}
if (speed >= 1.4f) {
return AlleleHelper.toDisplay(EnumAllele.Speed.FASTER);
}
if (speed >= 1.2f) {
return AlleleHelper.toDisplay(EnumAllele.Speed.FAST);
}
if (speed >= 1.0f) {
return AlleleHelper.toDisplay(EnumAllele.Speed.NORMAL);
}
if (speed >= 0.8f) {
return AlleleHelper.toDisplay(EnumAllele.Speed.SLOW);
}
if (speed >= 0.6f) {
return AlleleHelper.toDisplay(EnumAllele.Speed.SLOWER);
}
return AlleleHelper.toDisplay(EnumAllele.Speed.SLOWEST);
}
public static String rateLifespan(int life) {
if (life >= 70) {
return AlleleHelper.toDisplay(EnumAllele.Lifespan.LONGEST);
}
if (life >= 60) {
return AlleleHelper.toDisplay(EnumAllele.Lifespan.LONGER);
}
if (life >= 50) {
return AlleleHelper.toDisplay(EnumAllele.Lifespan.LONG);
}
if (life >= 45) {
return AlleleHelper.toDisplay(EnumAllele.Lifespan.ELONGATED);
}
if (life >= 40) {
return AlleleHelper.toDisplay(EnumAllele.Lifespan.NORMAL);
}
if (life >= 35) {
return AlleleHelper.toDisplay(EnumAllele.Lifespan.SHORTENED);
}
if (life >= 30) {
return AlleleHelper.toDisplay(EnumAllele.Lifespan.SHORT);
}
if (life >= 20) {
return AlleleHelper.toDisplay(EnumAllele.Lifespan.SHORTER);
}
return AlleleHelper.toDisplay(EnumAllele.Lifespan.SHORTEST);
}
public static String rateLifespan(int life) {
if (life >= 70) {
return AlleleHelper.toDisplay(EnumAllele.Lifespan.LONGEST);
}
if (life >= 60) {
return AlleleHelper.toDisplay(EnumAllele.Lifespan.LONGER);
}
if (life >= 50) {
return AlleleHelper.toDisplay(EnumAllele.Lifespan.LONG);
}
if (life >= 45) {
return AlleleHelper.toDisplay(EnumAllele.Lifespan.ELONGATED);
}
if (life >= 40) {
return AlleleHelper.toDisplay(EnumAllele.Lifespan.NORMAL);
}
if (life >= 35) {
return AlleleHelper.toDisplay(EnumAllele.Lifespan.SHORTENED);
}
if (life >= 30) {
return AlleleHelper.toDisplay(EnumAllele.Lifespan.SHORT);
}
if (life >= 20) {
return AlleleHelper.toDisplay(EnumAllele.Lifespan.SHORTER);
}
return AlleleHelper.toDisplay(EnumAllele.Lifespan.SHORTEST);
}
public static String tolerated(boolean t) {
if (t) {
return I18N.localise("extrabees.gui.database.tab.species.genome.tolerated");
}
return AlleleHelper.toDisplay(EnumTolerance.NONE);
}
public static String tolerated(boolean t) {
if (t) {
return I18N.localise("extrabees.gui.database.tab.species.genome.tolerated");
}
return AlleleHelper.toDisplay(EnumTolerance.NONE);
}
@Override
public void onValueChanged(IAlleleSpecies species) {
IAllele[] template = Binnie.Genetics.getBeeRoot().getTemplate(species.getUID());
if (template == null) {
return;
}
@Override
public void onValueChanged(IAlleleSpecies species) {
IAllele[] template = Binnie.Genetics.getBeeRoot().getTemplate(species.getUID());
if (template == null) {
return;
}
IBeeGenome genome = Binnie.Genetics.getBeeRoot().templateAsGenome(template);
speedText.setValue(rateSpeed(genome.getSpeed()));
lifespanText.setValue(rateLifespan(genome.getLifespan()));
fertilityText.setValue(I18N.localise("extrabees.gui.database.tab.species.genome.children", genome.getFertility()));
floweringText.setValue(rateFlowering(genome.getFlowering()));
int[] area = genome.getTerritory();
territoryText.setValue(area[0] + "x" + area[1] + "x" + area[2]);
IBeeGenome genome = Binnie.Genetics.getBeeRoot().templateAsGenome(template);
speedText.setValue(rateSpeed(genome.getSpeed()));
lifespanText.setValue(rateLifespan(genome.getLifespan()));
fertilityText.setValue(
I18N.localise("extrabees.gui.database.tab.species.genome.children", genome.getFertility()));
floweringText.setValue(rateFlowering(genome.getFlowering()));
int[] area = genome.getTerritory();
territoryText.setValue(area[0] + "x" + area[1] + "x" + area[2]);
String behavior;
if (genome.getNocturnal()) {
behavior = I18N.localise("extrabees.gui.database.tab.species.genome.allDay");
} else if (genome.getPrimary().isNocturnal()) {
behavior = I18N.localise("extrabees.gui.database.tab.species.genome.nighttime");
} else {
behavior = I18N.localise("extrabees.gui.database.tab.species.genome.daytime");
}
nocturnalText.setValue(behavior);
if (genome.getCaveDwelling()) {
caveDwellingText.setValue(I18N.localise("extrabees.gui.database.tab.species.genome.notNeeded"));
} else {
caveDwellingText.setValue(I18N.localise("extrabees.gui.database.tab.species.genome.required"));
}
String behavior;
if (genome.getNocturnal()) {
behavior = I18N.localise("extrabees.gui.database.tab.species.genome.allDay");
} else if (genome.getPrimary().isNocturnal()) {
behavior = I18N.localise("extrabees.gui.database.tab.species.genome.nighttime");
} else {
behavior = I18N.localise("extrabees.gui.database.tab.species.genome.daytime");
}
tolerantFlyerText.setValue(tolerated(genome.getTolerantFlyer()));
if (genome.getFlowerProvider() != null) {
flowerText.setValue(genome.getFlowerProvider().getDescription());
} else {
flowerText.setValue(AlleleHelper.toDisplay(EnumTolerance.NONE));
}
effectText.setValue(genome.getEffect().getName());
}
nocturnalText.setValue(behavior);
if (genome.getCaveDwelling()) {
caveDwellingText.setValue(I18N.localise("extrabees.gui.database.tab.species.genome.notNeeded"));
} else {
caveDwellingText.setValue(I18N.localise("extrabees.gui.database.tab.species.genome.required"));
}
tolerantFlyerText.setValue(tolerated(genome.getTolerantFlyer()));
if (genome.getFlowerProvider() != null) {
flowerText.setValue(genome.getFlowerProvider().getDescription());
} else {
flowerText.setValue(AlleleHelper.toDisplay(EnumTolerance.NONE));
}
effectText.setValue(genome.getEffect().getName());
}
}
@@ -19,35 +19,36 @@ import cpw.mods.fml.relauncher.Side;
import net.minecraft.entity.player.EntityPlayer;
public class WindowApiaristDatabase extends WindowAbstractDatabase {
public WindowApiaristDatabase(EntityPlayer player, Side side, boolean nei) {
super(player, side, nei, Binnie.Genetics.beeBreedingSystem, 110.0f);
}
public WindowApiaristDatabase(EntityPlayer player, Side side, boolean nei) {
super(player, side, nei, Binnie.Genetics.beeBreedingSystem, 110.0f);
}
public static Window create(EntityPlayer player, Side side, boolean nei) {
return new WindowApiaristDatabase(player, side, nei);
}
public static Window create(EntityPlayer player, Side side, boolean nei) {
return new WindowApiaristDatabase(player, side, nei);
}
@Override
protected void addTabs() {
new PageSpeciesOverview(getInfoPages(Mode.Species), new DatabaseTab(ExtraBees.instance, "species.overview"));
new PageSpeciesClassification(getInfoPages(Mode.Species), new DatabaseTab(ExtraBees.instance, "species.classification"));
new PageSpeciesGenome(getInfoPages(Mode.Species), new DatabaseTab(ExtraBees.instance, "species.genome"));
new PageSpeciesProducts(getInfoPages(Mode.Species), new DatabaseTab(ExtraBees.instance, "species.products"));
new PageSpeciesClimate(getInfoPages(Mode.Species), new DatabaseTab(ExtraBees.instance, "species.climate"));
new PageSpeciesResultant(getInfoPages(Mode.Species), new DatabaseTab(ExtraBees.instance, "species.resultant"));
new PageSpeciesMutations(getInfoPages(Mode.Species), new DatabaseTab(ExtraBees.instance, "species.further"));
new PageBranchOverview(getInfoPages(Mode.Branches), new DatabaseTab(ExtraBees.instance, "branches.overview"));
new PageBranchSpecies(getInfoPages(Mode.Branches), new DatabaseTab(ExtraBees.instance, "branches.species"));
new PageBreeder(getInfoPages(Mode.Breeder), getUsername(), new DatabaseTab(ExtraBees.instance, "breeder"));
}
@Override
protected void addTabs() {
new PageSpeciesOverview(getInfoPages(Mode.Species), new DatabaseTab(ExtraBees.instance, "species.overview"));
new PageSpeciesClassification(
getInfoPages(Mode.Species), new DatabaseTab(ExtraBees.instance, "species.classification"));
new PageSpeciesGenome(getInfoPages(Mode.Species), new DatabaseTab(ExtraBees.instance, "species.genome"));
new PageSpeciesProducts(getInfoPages(Mode.Species), new DatabaseTab(ExtraBees.instance, "species.products"));
new PageSpeciesClimate(getInfoPages(Mode.Species), new DatabaseTab(ExtraBees.instance, "species.climate"));
new PageSpeciesResultant(getInfoPages(Mode.Species), new DatabaseTab(ExtraBees.instance, "species.resultant"));
new PageSpeciesMutations(getInfoPages(Mode.Species), new DatabaseTab(ExtraBees.instance, "species.further"));
new PageBranchOverview(getInfoPages(Mode.Branches), new DatabaseTab(ExtraBees.instance, "branches.overview"));
new PageBranchSpecies(getInfoPages(Mode.Branches), new DatabaseTab(ExtraBees.instance, "branches.species"));
new PageBreeder(getInfoPages(Mode.Breeder), getUsername(), new DatabaseTab(ExtraBees.instance, "breeder"));
}
@Override
public AbstractMod getMod() {
return ExtraBees.instance;
}
@Override
public AbstractMod getMod() {
return ExtraBees.instance;
}
@Override
public String getName() {
return I18N.localise("extrabees.gui.database");
}
@Override
public String getName() {
return I18N.localise("extrabees.gui.database");
}
}
@@ -7,55 +7,54 @@ import binnie.core.craftgui.controls.listbox.ControlListBox;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.genetics.IAllele;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.minecraft.item.ItemStack;
public class ControlProductsBox extends ControlListBox<Product> {
protected IAlleleBeeSpecies species;
protected IAlleleBeeSpecies species;
private ProductType type;
private ProductType type;
public ControlProductsBox(IWidget parent, int x, int y, int width, int height, ProductType type) {
super(parent, x, y, width, height, 12.0f);
this.type = type;
species = null;
}
public ControlProductsBox(IWidget parent, int x, int y, int width, int height, ProductType type) {
super(parent, x, y, width, height, 12.0f);
this.type = type;
species = null;
}
@Override
public IWidget createOption(Product value, int y) {
return new ControlProductsItem(getContent(), value, y);
}
@Override
public IWidget createOption(Product value, int y) {
return new ControlProductsItem(getContent(), value, y);
}
public void setSpecies(IAlleleBeeSpecies species) {
if (species != this.species && (this.species = species) != null) {
IAllele[] template = Binnie.Genetics.getBeeRoot().getTemplate(species.getUID());
if (template == null) {
return;
}
public void setSpecies(IAlleleBeeSpecies species) {
if (species != this.species && (this.species = species) != null) {
IAllele[] template = Binnie.Genetics.getBeeRoot().getTemplate(species.getUID());
if (template == null) {
return;
}
IBeeGenome genome = Binnie.Genetics.getBeeRoot().templateAsGenome(template);
float speed = genome.getSpeed();
float modeSpeed = Binnie.Genetics.getBeeRoot()
.getBeekeepingMode(BinnieCore.proxy.getWorld())
.getBeeModifier()
.getProductionModifier(genome, 1.0f);
IBeeGenome genome = Binnie.Genetics.getBeeRoot().templateAsGenome(template);
float speed = genome.getSpeed();
float modeSpeed = Binnie.Genetics.getBeeRoot()
.getBeekeepingMode(BinnieCore.proxy.getWorld())
.getBeeModifier()
.getProductionModifier(genome, 1.0f);
List<Product> strings = new ArrayList<>();
Set<Map.Entry<ItemStack, Float>> chances;
if (type == ProductType.PRODUCTS) {
chances = species.getProductChances().entrySet();
} else {
chances = species.getSpecialtyChances().entrySet();
}
List<Product> strings = new ArrayList<>();
Set<Map.Entry<ItemStack, Float>> chances;
if (type == ProductType.PRODUCTS) {
chances = species.getProductChances().entrySet();
} else {
chances = species.getSpecialtyChances().entrySet();
}
for (Map.Entry<ItemStack, Float> entry : chances) {
strings.add(new Product(entry.getKey(), speed * modeSpeed * entry.getValue()));
}
setOptions(strings);
}
}
for (Map.Entry<ItemStack, Float> entry : chances) {
strings.add(new Product(entry.getKey(), speed * modeSpeed * entry.getValue()));
}
setOptions(strings);
}
}
}
@@ -8,35 +8,37 @@ import binnie.core.craftgui.geometry.CraftGUIUtil;
import binnie.core.craftgui.geometry.IPoint;
import binnie.core.craftgui.minecraft.control.ControlItemDisplay;
import binnie.core.util.I18N;
import java.text.DecimalFormat;
public class ControlProductsItem extends ControlOption<Product> {
protected ControlItemDisplay item;
protected ControlItemDisplay item;
public ControlProductsItem(ControlList<Product> controlList, Product value, int y) {
super(controlList, value, y);
(item = new ControlItemDisplay(this, 4.0f, 4.0f)).setTooltip();
ControlText textWidget = new ControlTextCentered(this, 2.0f, "");
CraftGUIUtil.moveWidget(textWidget, new IPoint(12.0f, 0.0f));
public ControlProductsItem(ControlList<Product> controlList, Product value, int y) {
super(controlList, value, y);
(item = new ControlItemDisplay(this, 4.0f, 4.0f)).setTooltip();
ControlText textWidget = new ControlTextCentered(this, 2.0f, "");
CraftGUIUtil.moveWidget(textWidget, new IPoint(12.0f, 0.0f));
if (value == null) {
return;
}
if (value == null) {
return;
}
item.setItemStack(value.item);
float time = (int) (550.0 / value.chance);
float seconds = time / 20.0f;
float minutes = seconds / 60.0f;
float hours = minutes / 60.0f;
DecimalFormat df = new DecimalFormat("#.0");
item.setItemStack(value.item);
float time = (int) (550.0 / value.chance);
float seconds = time / 20.0f;
float minutes = seconds / 60.0f;
float hours = minutes / 60.0f;
DecimalFormat df = new DecimalFormat("#.0");
if (hours > 1.0f) {
textWidget.setValue(I18N.localise("extrabees.gui.database.tab.species.products.everyHours", df.format(hours)));
} else if (minutes > 1.0f) {
textWidget.setValue(I18N.localise("extrabees.gui.database.tab.species.products.everyMins", df.format(minutes)));
} else {
textWidget.setValue(I18N.localise("extrabees.gui.database.tab.species.products.everySecs", df.format(seconds)));
}
}
if (hours > 1.0f) {
textWidget.setValue(
I18N.localise("extrabees.gui.database.tab.species.products.everyHours", df.format(hours)));
} else if (minutes > 1.0f) {
textWidget.setValue(
I18N.localise("extrabees.gui.database.tab.species.products.everyMins", df.format(minutes)));
} else {
textWidget.setValue(
I18N.localise("extrabees.gui.database.tab.species.products.everySecs", df.format(seconds)));
}
}
}
@@ -9,21 +9,21 @@ import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.genetics.IAlleleSpecies;
public class PageSpeciesProducts extends PageSpecies {
protected ControlProductsBox products;
protected ControlProductsBox specialties;
protected ControlProductsBox products;
protected ControlProductsBox specialties;
public PageSpeciesProducts(IWidget parent, DatabaseTab tab) {
super(parent, tab);
new ControlTextCentered(this, 8.0f, I18N.localise("extrabees.gui.database.tab.species.products"));
products = new ControlProductsBox(this, 4, 20, 136, 48, ProductType.PRODUCTS);
public PageSpeciesProducts(IWidget parent, DatabaseTab tab) {
super(parent, tab);
new ControlTextCentered(this, 8.0f, I18N.localise("extrabees.gui.database.tab.species.products"));
products = new ControlProductsBox(this, 4, 20, 136, 48, ProductType.PRODUCTS);
new ControlTextCentered(this, 68.0f, I18N.localise("extrabees.gui.database.tab.species.specialties"));
specialties = new ControlProductsBox(this, 4, 80, 136, 48, ProductType.SPECIALTIES);
}
new ControlTextCentered(this, 68.0f, I18N.localise("extrabees.gui.database.tab.species.specialties"));
specialties = new ControlProductsBox(this, 4, 80, 136, 48, ProductType.SPECIALTIES);
}
@Override
public void onValueChanged(IAlleleSpecies species) {
products.setSpecies((IAlleleBeeSpecies) species);
specialties.setSpecies((IAlleleBeeSpecies) species);
}
@Override
public void onValueChanged(IAlleleSpecies species) {
products.setSpecies((IAlleleBeeSpecies) species);
specialties.setSpecies((IAlleleBeeSpecies) species);
}
}
@@ -3,11 +3,11 @@ package binnie.extrabees.gui.database.product;
import net.minecraft.item.ItemStack;
public class Product {
protected ItemStack item;
protected float chance;
protected ItemStack item;
protected float chance;
public Product(ItemStack item, float chance) {
this.item = item;
this.chance = chance;
}
public Product(ItemStack item, float chance) {
this.item = item;
this.chance = chance;
}
}
@@ -1,6 +1,6 @@
package binnie.extrabees.gui.database.product;
public enum ProductType {
PRODUCTS,
SPECIALTIES
PRODUCTS,
SPECIALTIES
}