aboutsummaryrefslogtreecommitdiff
path: root/src/Java/binnie/craftgui/mod/database/ControlSpeciesBox.java
blob: 4f184b00646336a59edafd323643f9992137fb64 (plain)
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
package binnie.craftgui.mod.database;

import binnie.core.genetics.BreedingSystem;
import binnie.craftgui.controls.listbox.ControlList;
import binnie.craftgui.controls.listbox.ControlListBox;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.minecraft.Window;
import com.mojang.authlib.GameProfile;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IClassification;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;

public class ControlSpeciesBox
  extends ControlListBox<IAlleleSpecies>
{
  public IWidget createOption(IAlleleSpecies value, int y)
  {
    return new ControlSpeciexBoxOption((ControlList)getContent(), value, y);
  }
  
  public ControlSpeciesBox(IWidget parent, float x, float y, float width, float height)
  {
    super(parent, x, y, width, height, 12.0F);
  }
  
  private IClassification branch = null;
  
  public void setBranch(IClassification branch)
  {
    if (branch != this.branch)
    {
      this.branch = branch;
      List<IAlleleSpecies> speciesList2 = new ArrayList();
      movePercentage(-100.0F);
      setOptions(speciesList2);
      
      EntityPlayer player = Window.get(this).getPlayer();
      GameProfile playerName = Window.get(this).getUsername();
      WindowAbstractDatabase db = (WindowAbstractDatabase)Window.get(this);
      
      Collection<IAlleleSpecies> speciesList = !db.isNEI ? db.getBreedingSystem().getDiscoveredSpecies(db.getWorld(), playerName) : db.getBreedingSystem().getAllSpecies();
      if (branch != null) {
        for (IAlleleSpecies species : branch.getMemberSpecies()) {
          if (speciesList.contains(species)) {
            speciesList2.add(species);
          }
        }
      }
      setOptions(speciesList2);
    }
  }
}