Spackenmobs/src/main/java/mod/acgaming/spackenmobs/misc/BiomeHelper.java

39 lines
1.3 KiB
Java
Raw Normal View History

2020-08-14 19:24:29 +02:00
package mod.acgaming.spackenmobs.misc;
2020-08-23 10:30:02 +02:00
import net.minecraft.entity.Entity;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biome.SpawnListEntry;
import java.util.ArrayList;
import java.util.List;
// Thanks to Vazkii!
public class BiomeHelper {
public static Biome[] getBiomesWithMonster(Class<? extends Entity> clazz) {
List<Biome> biomes = new ArrayList<>();
for(Biome b : Biome.REGISTRY) {
List<SpawnListEntry> spawnList = b.getSpawnableList(EnumCreatureType.MONSTER);
for(SpawnListEntry e : spawnList)
if(e.entityClass == clazz) {
biomes.add(b);
break;
}
}
return biomes.toArray(new Biome[0]);
}
2020-08-23 10:30:02 +02:00
public static Biome[] getBiomesWithCreature(Class<? extends Entity> clazz) {
List<Biome> biomes = new ArrayList<>();
for(Biome b : Biome.REGISTRY) {
List<SpawnListEntry> spawnList = b.getSpawnableList(EnumCreatureType.CREATURE);
for(SpawnListEntry e : spawnList)
if(e.entityClass == clazz) {
biomes.add(b);
break;
}
}
return biomes.toArray(new Biome[0]);
}
}