Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. package betterwithaddons.config;
  2.  
  3. import net.minecraft.world.biome.Biome;
  4. import net.minecraftforge.common.config.Configuration;
  5. import net.minecraftforge.common.config.Property;
  6.  
  7. import java.util.ArrayList;
  8. import java.util.List;
  9.  
  10. public class ConfigOptionBiomeList {
  11. String name;
  12. String section;
  13. String description;
  14. int[] defaultValue;
  15. Property property;
  16.  
  17. public ConfigOptionBiomeList(String section, String name, List<Biome> defaultValue, String description) {
  18. this.name = name;
  19. this.section = section;
  20. this.description = description;
  21. this.defaultValue = toArray(defaultValue);
  22. }
  23.  
  24. public ConfigOptionBiomeList(String section, String name, List<Biome> defaultValue) {
  25. this(section,name, defaultValue, null);
  26. }
  27.  
  28. public List<Biome> init(Configuration configuration)
  29. {
  30. property = configuration.get(section, name, defaultValue);
  31. property.setComment(description);
  32. return toList(property.getIntList());
  33. }
  34.  
  35. public List<Biome> getValue()
  36. {
  37. return toList(property.getIntList());
  38. }
  39.  
  40. private List<Biome> toList(int[] array)
  41. {
  42. ArrayList list = new ArrayList(array.length);
  43. for(int i : array)
  44. list.add(Biome.getBiome(i));
  45. return list;
  46. }
  47.  
  48. private int[] toArray(List<Biome> list)
  49. {
  50. int[] array = new int[list.size()];
  51. for (int i = 0;i < array.length; i++)
  52. array[i] = Biome.getIdForBiome(list.get(i));
  53. return array;
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement