mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-16 10:44:53 +00:00
Improve code readability in binnie.extrabees package and other packages
* Improve code readability in binnie.extrabees package and other packages * Fix compile error after refactoring
This commit is contained in:
1 parent
b609d6688f
commit
c09ad04284
95 files changed
+3916
-3900
No files matched your search
@@ -1,156 +1,157 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.extrabees.gui.database;
|
||||
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import binnie.Binnie;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import binnie.core.craftgui.geometry.IArea;
|
||||
import binnie.core.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import binnie.core.craftgui.CraftGUI;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import binnie.core.craftgui.ITooltip;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.Tooltip;
|
||||
import binnie.core.craftgui.WidgetAttribute;
|
||||
import java.util.ArrayList;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import java.util.List;
|
||||
import binnie.core.craftgui.ITooltip;
|
||||
import binnie.core.craftgui.controls.core.Control;
|
||||
import binnie.core.craftgui.geometry.IArea;
|
||||
import binnie.core.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
|
||||
public class ControlClimateBar extends Control implements ITooltip
|
||||
{
|
||||
boolean isHumidity;
|
||||
List<Integer> tolerated;
|
||||
int[] tempColours;
|
||||
int[] humidColours;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public ControlClimateBar(final IWidget parent, final int x, final int y, final int width, final int height) {
|
||||
public class ControlClimateBar extends Control implements ITooltip {
|
||||
protected boolean isHumidity;
|
||||
protected List<Integer> tolerated;
|
||||
protected int[] tempColours;
|
||||
protected int[] humidColours;
|
||||
|
||||
public ControlClimateBar(IWidget parent, int x, int y, int width, int height) {
|
||||
super(parent, x, y, width, height);
|
||||
this.isHumidity = false;
|
||||
this.tolerated = new ArrayList<Integer>();
|
||||
this.tempColours = new int[] { 65531, 7912447, 5242672, 16776960, 16753152, 16711680 };
|
||||
this.humidColours = new int[] { 16770979, 1769216, 3177727 };
|
||||
this.addAttribute(WidgetAttribute.MouseOver);
|
||||
isHumidity = false;
|
||||
tolerated = new ArrayList<>();
|
||||
tempColours = new int[]{0x00fffb, 0x78bbff, 0x4fff30, 0xffff00, 0xffa200, 0xff0000};
|
||||
humidColours = new int[]{0xffe7a3, 0x1aff00, 0x307cff};
|
||||
addAttribute(WidgetAttribute.MouseOver);
|
||||
}
|
||||
|
||||
public ControlClimateBar(final IWidget parent, final int x, final int y, final int width, final int height, final boolean humidity) {
|
||||
public ControlClimateBar(IWidget parent, int x, int y, int width, int height, boolean humidity) {
|
||||
super(parent, x, y, width, height);
|
||||
this.isHumidity = false;
|
||||
this.tolerated = new ArrayList<Integer>();
|
||||
this.tempColours = new int[] { 65531, 7912447, 5242672, 16776960, 16753152, 16711680 };
|
||||
this.humidColours = new int[] { 16770979, 1769216, 3177727 };
|
||||
this.addAttribute(WidgetAttribute.MouseOver);
|
||||
this.isHumidity = true;
|
||||
tolerated = new ArrayList<>();
|
||||
tempColours = new int[]{0x00fffb, 0x78bbff, 0x4fff30, 0xffff00, 0xffa200, 0xff0000};
|
||||
humidColours = new int[]{0xffe7a3, 0x1aff00, 0x307cff};
|
||||
addAttribute(WidgetAttribute.MouseOver);
|
||||
isHumidity = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
if (this.tolerated.isEmpty()) {
|
||||
public void getTooltip(Tooltip tooltip) {
|
||||
if (tolerated.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final int types = this.isHumidity ? 3 : 6;
|
||||
final int type = (int) ((int) (this.getRelativeMousePosition().x() - 1.0f) / ((this.getSize().x() - 2.0f) / types));
|
||||
if (!this.tolerated.contains(type)) {
|
||||
|
||||
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 (type < types) {
|
||||
if (this.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, this.getArea());
|
||||
final int types = this.isHumidity ? 3 : 6;
|
||||
final int w = (int) ((this.getSize().x() - 2.0f) / types);
|
||||
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) {
|
||||
final int x = i * w;
|
||||
if (this.tolerated.contains(i)) {
|
||||
int colour = 0;
|
||||
if (this.isHumidity) {
|
||||
colour = this.humidColours[i];
|
||||
int x = i * w;
|
||||
if (tolerated.contains(i)) {
|
||||
int colour;
|
||||
if (isHumidity) {
|
||||
colour = humidColours[i];
|
||||
} else {
|
||||
colour = tempColours[i];
|
||||
}
|
||||
else {
|
||||
colour = this.tempColours[i];
|
||||
}
|
||||
CraftGUI.Render.solid(new IArea(x + 1, 1.0f, w, this.getSize().y() - 2.0f), colour);
|
||||
CraftGUI.Render.solid(new IArea(x + 1, 1.0f, w, getSize().y() - 2.0f), colour);
|
||||
}
|
||||
}
|
||||
CraftGUI.Render.texture(CraftGUITexture.EnergyBarGlass, this.getArea());
|
||||
CraftGUI.Render.texture(CraftGUITexture.EnergyBarGlass, getArea());
|
||||
}
|
||||
|
||||
public void setSpecies(final IAlleleBeeSpecies species) {
|
||||
this.tolerated.clear();
|
||||
public void setSpecies(IAlleleBeeSpecies species) {
|
||||
tolerated.clear();
|
||||
if (species == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int main;
|
||||
EnumTolerance tolerance;
|
||||
if (!this.isHumidity) {
|
||||
if (!isHumidity) {
|
||||
main = species.getTemperature().ordinal() - 1;
|
||||
final IBeeGenome genome = Binnie.Genetics.getBeeRoot().templateAsGenome(Binnie.Genetics.getBeeRoot().getTemplate(species.getUID()));
|
||||
IBeeGenome genome = Binnie.Genetics.getBeeRoot().templateAsGenome(Binnie.Genetics.getBeeRoot().getTemplate(species.getUID()));
|
||||
tolerance = genome.getToleranceTemp();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
main = species.getHumidity().ordinal();
|
||||
final IBeeGenome genome = Binnie.Genetics.getBeeRoot().templateAsGenome(Binnie.Genetics.getBeeRoot().getTemplate(species.getUID()));
|
||||
IBeeGenome genome = Binnie.Genetics.getBeeRoot().templateAsGenome(Binnie.Genetics.getBeeRoot().getTemplate(species.getUID()));
|
||||
tolerance = genome.getToleranceHumid();
|
||||
}
|
||||
this.tolerated.add(main);
|
||||
|
||||
tolerated.add(main);
|
||||
switch (tolerance) {
|
||||
case BOTH_5:
|
||||
case UP_5: {
|
||||
this.tolerated.add(main + 5);
|
||||
}
|
||||
case BOTH_4:
|
||||
case UP_4: {
|
||||
this.tolerated.add(main + 4);
|
||||
}
|
||||
case BOTH_3:
|
||||
case UP_3: {
|
||||
this.tolerated.add(main + 3);
|
||||
}
|
||||
case BOTH_2:
|
||||
case UP_2: {
|
||||
this.tolerated.add(main + 2);
|
||||
}
|
||||
case BOTH_1:
|
||||
case UP_1: {
|
||||
this.tolerated.add(main + 1);
|
||||
break;
|
||||
}
|
||||
case BOTH_5:
|
||||
case UP_5:
|
||||
tolerated.add(main + 5);
|
||||
break;
|
||||
|
||||
case BOTH_4:
|
||||
case UP_4:
|
||||
tolerated.add(main + 4);
|
||||
break;
|
||||
|
||||
case BOTH_3:
|
||||
case UP_3:
|
||||
tolerated.add(main + 3);
|
||||
break;
|
||||
|
||||
case BOTH_2:
|
||||
case UP_2:
|
||||
tolerated.add(main + 2);
|
||||
break;
|
||||
|
||||
case BOTH_1:
|
||||
case UP_1:
|
||||
tolerated.add(main + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (tolerance) {
|
||||
case BOTH_5:
|
||||
case DOWN_5: {
|
||||
this.tolerated.add(main - 5);
|
||||
}
|
||||
case BOTH_4:
|
||||
case DOWN_4: {
|
||||
this.tolerated.add(main - 4);
|
||||
}
|
||||
case BOTH_3:
|
||||
case DOWN_3: {
|
||||
this.tolerated.add(main - 3);
|
||||
}
|
||||
case BOTH_2:
|
||||
case DOWN_2: {
|
||||
this.tolerated.add(main - 2);
|
||||
}
|
||||
case BOTH_1:
|
||||
case DOWN_1: {
|
||||
this.tolerated.add(main - 1);
|
||||
break;
|
||||
}
|
||||
case BOTH_5:
|
||||
case DOWN_5:
|
||||
tolerated.add(main - 5);
|
||||
break;
|
||||
|
||||
case BOTH_4:
|
||||
case DOWN_4:
|
||||
tolerated.add(main - 4);
|
||||
break;
|
||||
|
||||
case BOTH_3:
|
||||
case DOWN_3:
|
||||
tolerated.add(main - 3);
|
||||
break;
|
||||
|
||||
case BOTH_2:
|
||||
case DOWN_2:
|
||||
tolerated.add(main - 2);
|
||||
break;
|
||||
|
||||
case BOTH_1:
|
||||
case DOWN_1:
|
||||
tolerated.add(main - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user