Search in sources :

Example 1 with MobSpawnSettings

use of net.minecraft.world.level.biome.MobSpawnSettings in project Denizen-For-Bukkit by DenizenScript.

the class BiomeNMSImpl method getSpawnableEntities.

private List<EntityType> getSpawnableEntities(MobCategory creatureType) {
    MobSpawnSettings mobs = biomeBase.getMobSettings();
    WeightedRandomList<MobSpawnSettings.SpawnerData> typeSettingList = mobs.getMobs(creatureType);
    List<EntityType> entityTypes = new ArrayList<>();
    if (typeSettingList == null) {
        return entityTypes;
    }
    for (MobSpawnSettings.SpawnerData meta : typeSettingList.unwrap()) {
        try {
            String n = net.minecraft.world.entity.EntityType.getKey(meta.type).getPath();
            EntityType et = EntityType.fromName(n);
            if (et == null) {
                et = EntityType.valueOf(n.toUpperCase(Locale.ENGLISH));
            }
            entityTypes.add(et);
        } catch (Throwable e) {
        // Ignore the error. Likely from invalid entity type name output.
        }
    }
    return entityTypes;
}
Also used : EntityType(org.bukkit.entity.EntityType) MobSpawnSettings(net.minecraft.world.level.biome.MobSpawnSettings) ArrayList(java.util.ArrayList)

Example 2 with MobSpawnSettings

use of net.minecraft.world.level.biome.MobSpawnSettings in project Denizen-For-Bukkit by DenizenScript.

the class BiomeNMSImpl method getSpawnableEntities.

private List<EntityType> getSpawnableEntities(MobCategory creatureType) {
    MobSpawnSettings mobs = biomeBase.getMobSettings();
    WeightedRandomList<MobSpawnSettings.SpawnerData> typeSettingList = mobs.getMobs(creatureType);
    List<EntityType> entityTypes = new ArrayList<>();
    if (typeSettingList == null) {
        return entityTypes;
    }
    for (MobSpawnSettings.SpawnerData meta : typeSettingList.unwrap()) {
        try {
            String n = net.minecraft.world.entity.EntityType.getKey(meta.type).getPath();
            EntityType et = EntityType.fromName(n);
            if (et == null) {
                et = EntityType.valueOf(n.toUpperCase(Locale.ENGLISH));
            }
            entityTypes.add(et);
        } catch (Throwable e) {
        // Ignore the error. Likely from invalid entity type name output.
        }
    }
    return entityTypes;
}
Also used : EntityType(org.bukkit.entity.EntityType) MobSpawnSettings(net.minecraft.world.level.biome.MobSpawnSettings) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)2 MobSpawnSettings (net.minecraft.world.level.biome.MobSpawnSettings)2 EntityType (org.bukkit.entity.EntityType)2