Skip to content

Commit

Permalink
Intial work on biome config
Browse files Browse the repository at this point in the history
  • Loading branch information
GirafiStudios committed Apr 12, 2018
1 parent 919bb14 commit 4d1e8b2
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/main/java/com/girafi/waddles/init/PenguinRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,16 @@ public class PenguinRegistry {

private static EntityEntry createEntity(Class<? extends Entity> entityClass, int eggPrimary, int eggSecondary, int weight, int min, int max, BiomeDictionary.Type[] typesInclude, BiomeDictionary.Type[] typesExclude) {
List<Biome> spawnable_biomes = Lists.newArrayList();

String subCategoryNames = ConfigurationHandler.CATEGORY_PENGUIN_SPAWNS + Configuration.CATEGORY_SPLITTER + "adelie_penguin" + Configuration.CATEGORY_SPLITTER + "Spawnable Biomes";
String[] include = ConfigurationHandler.config.getStringList("Include", subCategoryNames, toStringArray(typesInclude), "BiomeDictionary types to include");
String[] exclude = ConfigurationHandler.config.getStringList("Exclude", subCategoryNames, toStringArray(typesExclude), "BiomeDictionary types to exclude");

ConfigurationHandler.config.save();

for (Biome biome : Biome.REGISTRY) {
Set<BiomeDictionary.Type> types = BiomeDictionary.getTypes(biome);
if (types.containsAll(Arrays.asList(typesInclude)) && !types.containsAll(Arrays.asList(typesExclude)) && !types.contains(NETHER) && !biome.getSpawnableList(EnumCreatureType.CREATURE).isEmpty()) {
if (types.containsAll(Arrays.asList(include)) && !types.containsAll(Arrays.asList(exclude)) && !types.contains(NETHER) && !biome.getSpawnableList(EnumCreatureType.CREATURE).isEmpty()) {
spawnable_biomes.add(biome);
}
}
Expand Down Expand Up @@ -67,6 +74,15 @@ private static EntityEntry createEntity(Class<? extends Entity> entityClass, int
return entry;
}

private static String[] toStringArray(BiomeDictionary.Type[] types) {
String[] def = new String[types.length];
for (int i = 0; i < types.length; i++) {
BiomeDictionary.Type type = types[i];
def[i] = type.getName();
}
return def;
}

@SubscribeEvent
public static void registerPenguins(RegistryEvent.Register<EntityEntry> event) {
int networkId = 0;
Expand Down

0 comments on commit 4d1e8b2

Please sign in to comment.