-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathSubGuiNpcBiomes.java
More file actions
124 lines (111 loc) · 4.2 KB
/
Copy pathSubGuiNpcBiomes.java
File metadata and controls
124 lines (111 loc) · 4.2 KB
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
package noppes.npcs.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.BiomeDictionary;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.controllers.data.SpawnData;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class SubGuiNpcBiomes extends SubGuiInterface {
private SpawnData data;
private GuiCustomScroll scroll1;
private GuiCustomScroll scroll2;
public SubGuiNpcBiomes(SpawnData data) {
this.data = data;
setBackground("menubg.png");
xSize = 346;
ySize = 216;
closeOnEsc = true;
}
public void initGui() {
super.initGui();
if (scroll1 == null) {
scroll1 = new GuiCustomScroll(this, 0);
scroll1.setSize(140, 180);
}
scroll1.guiLeft = guiLeft + 4;
scroll1.guiTop = guiTop + 14;
this.addScroll(scroll1);
addLabel(new GuiNpcLabel(1, "spawning.availableBiomes", guiLeft + 4, guiTop + 4));
if (scroll2 == null) {
scroll2 = new GuiCustomScroll(this, 1);
scroll2.setSize(140, 180);
}
scroll2.guiLeft = guiLeft + 200;
scroll2.guiTop = guiTop + 14;
this.addScroll(scroll2);
addLabel(new GuiNpcLabel(2, "spawning.spawningBiomes", guiLeft + 200, guiTop + 4));
List<String> biomes = new ArrayList<String>();
Set<BiomeGenBase> allBiomes = new HashSet<BiomeGenBase>();
for (BiomeDictionary.Type type : BiomeDictionary.Type.values()) {
Collections.addAll(allBiomes, BiomeDictionary.getBiomesForType(type));
}
for (BiomeGenBase base : BiomeGenBase.getBiomeGenArray()) {
if (base != null)
allBiomes.add(base);
}
for (BiomeGenBase base : allBiomes) {
if (base != null && base.biomeName != null && !data.biomes.contains(base.biomeName)) {
biomes.add(base.biomeName);
}
}
scroll1.setList(biomes);
scroll2.setList(data.biomes);
addButton(new GuiNpcButton(1, guiLeft + 145, guiTop + 40, 55, 20, ">"));
addButton(new GuiNpcButton(2, guiLeft + 145, guiTop + 62, 55, 20, "<"));
addButton(new GuiNpcButton(3, guiLeft + 145, guiTop + 90, 55, 20, ">>"));
addButton(new GuiNpcButton(4, guiLeft + 145, guiTop + 112, 55, 20, "<<"));
addButton(new GuiNpcButton(66, guiLeft + 260, guiTop + 194, 60, 20, "gui.done"));
}
protected void actionPerformed(GuiButton guibutton) {
GuiNpcButton button = (GuiNpcButton) guibutton;
if (button.id == 1) {
if (scroll1.hasSelected()) {
data.biomes.add(scroll1.getSelected());
scroll1.selected = -1;
initGui();
}
}
if (button.id == 2) {
if (scroll2.hasSelected()) {
data.biomes.remove(scroll2.getSelected());
scroll2.selected = -1;
initGui();
}
}
if (button.id == 3) {
data.biomes.clear();
Set<BiomeGenBase> allBiomes = new HashSet<BiomeGenBase>();
for (BiomeDictionary.Type type : BiomeDictionary.Type.values()) {
Collections.addAll(allBiomes, BiomeDictionary.getBiomesForType(type));
}
for (BiomeGenBase base : BiomeGenBase.getBiomeGenArray()) {
if (base != null)
allBiomes.add(base);
}
for (BiomeGenBase base : allBiomes) {
if (base != null) {
data.biomes.add(base.biomeName);
}
}
scroll1.selected = -1;
scroll2.selected = -1;
initGui();
}
if (button.id == 4) {
data.biomes.clear();
scroll1.selected = -1;
scroll2.selected = -1;
initGui();
}
if (button.id == 66) {
close();
}
}
}