1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
package binnie.extrabees.gui.database;
import binnie.Binnie;
import binnie.core.genetics.ManagerGenetics;
import binnie.craftgui.controls.core.Control;
import binnie.craftgui.core.Attribute;
import binnie.craftgui.core.CraftGUI;
import binnie.craftgui.core.ITooltip;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.core.Tooltip;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.core.geometry.IPoint;
import binnie.craftgui.core.renderer.Renderer;
import binnie.craftgui.resource.minecraft.CraftGUITexture;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeRoot;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.genetics.EnumTolerance;
import java.util.ArrayList;
import java.util.List;
public class ControlClimateBar
extends Control
implements ITooltip
{
public ControlClimateBar(IWidget parent, int x, int y, int width, int height)
{
super(parent, x, y, width, height);
addAttribute(Attribute.MouseOver);
}
public ControlClimateBar(IWidget parent, int x, int y, int width, int height, boolean humidity)
{
super(parent, x, y, width, height);
addAttribute(Attribute.MouseOver);
this.isHumidity = true;
}
boolean isHumidity = false;
List<Integer> tolerated = new ArrayList();
public void getTooltip(Tooltip list)
{
if (this.tolerated.isEmpty()) {
return;
}
int types = this.isHumidity ? 3 : 6;
int type = (int)((int)(getRelativeMousePosition().x() - 1.0F) / ((getSize().x() - 2.0F) / types));
if (!this.tolerated.contains(Integer.valueOf(type))) {
return;
}
if (type < types) {
if (this.isHumidity) {
list.add(EnumHumidity.values()[type].name);
} else {
list.add(EnumTemperature.values()[(type + 1)].name);
}
}
}
int[] tempColours = { 65531, 7912447, 5242672, 16776960, 16753152, 16711680 };
int[] humidColours = { 16770979, 1769216, 3177727 };
public void onRenderBackground()
{
CraftGUI.Render.texture(CraftGUITexture.EnergyBarBack, getArea());
int types = this.isHumidity ? 3 : 6;
int w = (int)((getSize().x() - 2.0F) / types);
for (int i = 0; i < types; i++)
{
int x = i * w;
if (this.tolerated.contains(Integer.valueOf(i)))
{
int colour = 0;
if (this.isHumidity) {
colour = this.humidColours[i];
} else {
colour = this.tempColours[i];
}
CraftGUI.Render.solid(new IArea(x + 1, 1.0F, w, getSize().y() - 2.0F), colour);
}
}
CraftGUI.Render.texture(CraftGUITexture.EnergyBarGlass, getArea());
}
public void setSpecies(IAlleleBeeSpecies species)
{
this.tolerated.clear();
if (species == null) {
return;
}
EnumTolerance tolerance;
int main;
EnumTolerance tolerance;
if (!this.isHumidity)
{
int main = species.getTemperature().ordinal() - 1;
IBeeGenome genome = Binnie.Genetics.getBeeRoot().templateAsGenome(Binnie.Genetics.getBeeRoot().getTemplate(species.getUID()));
tolerance = genome.getToleranceTemp();
}
else
{
main = species.getHumidity().ordinal();
IBeeGenome genome = Binnie.Genetics.getBeeRoot().templateAsGenome(Binnie.Genetics.getBeeRoot().getTemplate(species.getUID()));
tolerance = genome.getToleranceHumid();
}
this.tolerated.add(Integer.valueOf(main));
switch (1.$SwitchMap$forestry$api$genetics$EnumTolerance[tolerance.ordinal()])
{
case 1:
case 2:
this.tolerated.add(Integer.valueOf(main + 5));
case 3:
case 4:
this.tolerated.add(Integer.valueOf(main + 4));
case 5:
case 6:
this.tolerated.add(Integer.valueOf(main + 3));
case 7:
case 8:
this.tolerated.add(Integer.valueOf(main + 2));
case 9:
case 10:
this.tolerated.add(Integer.valueOf(main + 1));
}
switch (1.$SwitchMap$forestry$api$genetics$EnumTolerance[tolerance.ordinal()])
{
case 1:
case 11:
this.tolerated.add(Integer.valueOf(main - 5));
case 3:
case 12:
this.tolerated.add(Integer.valueOf(main - 4));
case 5:
case 13:
this.tolerated.add(Integer.valueOf(main - 3));
case 7:
case 14:
this.tolerated.add(Integer.valueOf(main - 2));
case 9:
case 15:
this.tolerated.add(Integer.valueOf(main - 1));
}
}
}
|