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 biomes = new ArrayList(); Set allBiomes = new HashSet(); 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; 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 allBiomes = new HashSet(); 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(); } } }