Search in sources :

Example 1 with IConfigObj

use of biomesoplenty.api.config.IConfigObj in project BiomesOPlenty by Glitchfiend.

the class BOPBiome method configure.

@Override
public void configure(IConfigObj conf) {
    this.topBlock = conf.getBlockState("topBlock", this.topBlock);
    this.fillerBlock = conf.getBlockState("fillerBlock", this.fillerBlock);
    this.skyColor = conf.getInt("skyColor", this.skyColor);
    this.fogColor = conf.getInt("fogColor", this.fogColor);
    this.fogDensity = conf.getFloat("fogDensity", this.fogDensity);
    this.hasBiomeEssence = conf.getBool("hasBiomeEssence", this.hasBiomeEssence);
    // Allow weights to be overridden
    IConfigObj confWeights = conf.getObject("weights");
    for (BOPClimates climate : BOPClimates.values()) {
        Integer weight = confWeights.getInt(climate.name().toLowerCase(), this.weightMap.get(climate));
        if (weight == null) {
            continue;
        }
        if (weight.intValue() < 1) {
            this.weightMap.remove(climate);
        } else {
            this.weightMap.put(climate, weight);
        }
    }
    // Allow generators to be configured
    IConfigObj confGenerators = conf.getObject("generators");
    this.generationManager.configure(confGenerators);
    // Allow spawnable entites to be configured
    ArrayList<IConfigObj> confEntities = conf.getObjectArray("entities");
    if (confEntities != null) {
        for (IConfigObj confEntity : confEntities) {
            String entityName = confEntity.getString("name");
            EnumCreatureType creatureType = confEntity.getEnum("creatureType", EnumCreatureType.class);
            if (entityName == null || creatureType == null) {
                continue;
            }
            // Look for an entity class matching this name
            // case insensitive, dot used as mod delimiter, no spaces or underscores
            // eg  'villager', 'Zombie', 'SQUID', 'enderdragon', 'biomesoplenty.wasp' all ok
            Class<? extends Entity> entityClazz = ForgeRegistries.ENTITIES.getValue(new ResourceLocation(entityName)).getEntityClass();
            Class<? extends EntityLiving> livingClazz = null;
            if (!(entityClazz.isAssignableFrom(EntityLiving.class))) {
                confEntity.addMessage("Entity " + entityName + " is not of type EntityLiving");
                continue;
            } else {
                livingClazz = (Class<? extends EntityLiving>) entityClazz;
            }
            if (livingClazz == null) {
                confEntity.addMessage("No entity registered called " + entityName);
                continue;
            }
            if (!creatureType.getCreatureClass().isAssignableFrom(livingClazz)) {
                confEntity.addMessage("Entity " + entityName + " is not of type " + creatureType);
                continue;
            }
            List<SpawnListEntry> spawns = this.getSpawnableList(creatureType);
            Integer weight = confEntity.getInt("weight");
            if (weight != null && weight < 1) {
                // weight was set to zero (or negative) so find and remove this spawn
                Iterator<SpawnListEntry> spawnIterator = spawns.iterator();
                while (spawnIterator.hasNext()) {
                    SpawnListEntry entry = spawnIterator.next();
                    if (entry.entityClass == livingClazz) {
                        spawnIterator.remove();
                    }
                }
            } else {
                // weight was positive, or omitted, so update an existing spawn or add a new spawn
                boolean foundIt = false;
                for (SpawnListEntry entry : spawns) {
                    if (entry.entityClass == entityClazz) {
                        // the entry already exists - adjust the params
                        entry.itemWeight = confEntity.getInt("weight", entry.itemWeight);
                        entry.minGroupCount = confEntity.getInt("minGroupCount", entry.minGroupCount);
                        entry.maxGroupCount = confEntity.getInt("maxGroupCount", entry.maxGroupCount);
                        foundIt = true;
                    }
                }
                if (!foundIt) {
                    // the entry does not exist - add it
                    SpawnListEntry entry = new SpawnListEntry(livingClazz, confEntity.getInt("weight", 10), confEntity.getInt("minGroupCount", 4), confEntity.getInt("maxGroupCount", 4));
                    spawns.add(entry);
                }
            }
        }
    }
}
Also used : EnumCreatureType(net.minecraft.entity.EnumCreatureType) ResourceLocation(net.minecraft.util.ResourceLocation) IConfigObj(biomesoplenty.api.config.IConfigObj) BOPClimates(biomesoplenty.api.enums.BOPClimates)

Example 2 with IConfigObj

use of biomesoplenty.api.config.IConfigObj in project BiomesOPlenty by Glitchfiend.

the class BOPWorldSettings method setDefault.

public void setDefault() {
    // BOP default values
    this.landScheme = LandMassScheme.VANILLA;
    this.tempScheme = TemperatureVariationScheme.MEDIUM_ZONES;
    this.rainScheme = RainfallVariationScheme.MEDIUM_ZONES;
    this.biomeSize = BiomeSize.MEDIUM;
    this.amplitude = 1.0F;
    this.generateBopGems = true;
    this.generateBopSoils = true;
    this.generateBopTrees = true;
    this.generateBopGrasses = true;
    this.generateBopFoliage = true;
    this.generateBopFlowers = true;
    this.generateBopPlants = true;
    this.generateBopWaterPlants = true;
    this.generateBopMushrooms = true;
    this.generateRockFormations = true;
    this.generatePoisonIvy = false;
    this.generateBerryBushes = true;
    this.generateThorns = true;
    this.generateQuicksand = true;
    this.generateLiquidPoison = true;
    this.generateHotSprings = true;
    this.generateNetherHives = true;
    this.generateEndFeatures = true;
    // Vanilla default values
    this.seaLevel = 63;
    this.useCaves = true;
    this.useDungeons = true;
    this.dungeonChance = 8;
    this.useStrongholds = true;
    this.useVillages = true;
    this.useMineShafts = true;
    this.useTemples = true;
    this.useMonuments = true;
    this.useMansions = true;
    this.useRavines = true;
    this.useWaterLakes = true;
    this.waterLakeChance = 4;
    this.useLavaLakes = true;
    this.lavaLakeChance = 80;
    this.useLavaOceans = false;
    this.mainNoiseScaleX = 80.0F;
    this.mainNoiseScaleY = 160.0F;
    this.mainNoiseScaleZ = 80.0F;
    this.coordinateScale = 684.412F;
    this.heightScale = 684.412F;
    this.upperLimitScale = 512.0F;
    this.lowerLimitScale = 512.0F;
    // Allow defaults to be overridden from file
    IConfigObj worldConfig = new BOPConfig.ConfigFileObj(new File(BiomesOPlenty.configDirectory, "world.json"));
    this.fromConfigObj(worldConfig);
}
Also used : IConfigObj(biomesoplenty.api.config.IConfigObj) File(java.io.File)

Example 3 with IConfigObj

use of biomesoplenty.api.config.IConfigObj in project BiomesOPlenty by Glitchfiend.

the class GenerationManager method configure.

public void configure(IConfigObj generatorsObj) {
    Iterator<String> genKeysItr = generators.keySet().iterator();
    // iterate over all registered generators
    while (genKeysItr.hasNext()) {
        String name = genKeysItr.next();
        IConfigObj currentObj = generatorsObj.getObject(name);
        // there was previously no generator of this name - attempt to add it
        if (generatorsObj.has(name)) {
            IGenerator generator = GeneratorRegistry.createGenerator(currentObj);
            if (generator != null) {
                this.generators.put(name, generator);
            }
        }
        // always attempt to do this so defaults are generated
        if (currentObj.getBool("enable", true)) {
            this.generators.get(name).configure(currentObj);
        } else {
            // remove this generator
            genKeysItr.remove();
        }
    }
}
Also used : IGenerator(biomesoplenty.api.generation.IGenerator) IConfigObj(biomesoplenty.api.config.IConfigObj)

Example 4 with IConfigObj

use of biomesoplenty.api.config.IConfigObj in project BiomesOPlenty by Glitchfiend.

the class ExtendedBiomeWrapper method configure.

@Override
public void configure(IConfigObj conf) {
    this.beachBiomeLocation = conf.getResourceLocation("beachBiomeLocation", this.beachBiomeLocation);
    // Allow generators to be configured
    IConfigObj confGenerators = conf.getObject("generators");
    this.generationManager.configure(confGenerators);
    // log any warnings from parsing the config file
    for (String msg : conf.flushMessages()) BiomesOPlenty.logger.info(msg);
    // write default values to a file
    ModBiomes.writeDefaultConfigFile(ModBiomes.VANILLA_DEFAULTS_DIR, this.getResourceLocation().getResourcePath(), conf);
}
Also used : IConfigObj(biomesoplenty.api.config.IConfigObj)

Example 5 with IConfigObj

use of biomesoplenty.api.config.IConfigObj in project BiomesOPlenty by Glitchfiend.

the class ModBiomes method readConfigFile.

public static IConfigObj readConfigFile(String idName) {
    File configFile = new File(new File(BiomesOPlenty.configDirectory, "biomes"), idName + ".json");
    IConfigObj conf = new BOPConfig.ConfigFileObj(configFile, false, true);
    return conf;
}
Also used : IConfigObj(biomesoplenty.api.config.IConfigObj) File(java.io.File)

Aggregations

IConfigObj (biomesoplenty.api.config.IConfigObj)6 IGenerator (biomesoplenty.api.generation.IGenerator)2 File (java.io.File)2 BOPClimates (biomesoplenty.api.enums.BOPClimates)1 EnumCreatureType (net.minecraft.entity.EnumCreatureType)1 ResourceLocation (net.minecraft.util.ResourceLocation)1