Search in sources :

Example 1 with BOPClimates

use of biomesoplenty.api.enums.BOPClimates in project BiomeTweaker by superckl.

the class BOPIntegrationModule method addBiomeInfo.

@Override
public void addBiomeInfo(Biome biome, final JsonObject obj) {
    final IExtendedBiome eBiome = BOPIntegrationModule.getExtendedBiome(biome);
    biome = eBiome.getBaseBiome();
    final IGenerationManager gManager = eBiome.getGenerationManager();
    final JsonObject genNames = new JsonObject();
    for (final GeneratorStage stage : GeneratorStage.values()) {
        final Collection<IGenerator> gens = gManager.getGeneratorsForStage(stage);
        if (gens.isEmpty())
            continue;
        final JsonArray subArray = new JsonArray();
        final Iterator<IGenerator> it = gens.iterator();
        while (it.hasNext()) {
            final JsonObject subSubObj = new JsonObject();
            final IGenerator gen = it.next();
            subSubObj.addProperty("ID", gen.getIdentifier());
            subSubObj.addProperty("Name", gen.getName());
            subArray.add(subSubObj);
        }
        genNames.add(stage.name() + " Generators", subArray);
    }
    obj.add("BOP Generators", genNames);
    obj.addProperty("BOP Owner", eBiome.getBiomeOwner().name());
    final Gson gson = new Gson();
    obj.add("BOP Weight Map", gson.toJsonTree(eBiome.getWeightMap()));
    try {
        final JsonObject weights = new JsonObject();
        for (final BOPClimates climate : BOPClimates.values()) {
            final List<WeightedBiomeEntry> entries = WarningHelper.uncheckedCast(BOPBiomeProperties.LAND_BIOMES.get(climate));
            final JsonArray subArray = new JsonArray();
            for (final WeightedBiomeEntry entry : entries) if (Biome.getIdForBiome(entry.biome) == Biome.getIdForBiome(biome))
                subArray.add(new JsonPrimitive(entry.weight));
            if (subArray.size() > 0)
                weights.add(climate.name(), subArray);
        }
        obj.add("BOP Climate Weights", weights);
        if (ModBiomes.islandBiomesMap.containsKey(Biome.getIdForBiome(biome)))
            obj.add("BOP Island Weight", new JsonPrimitive(ModBiomes.islandBiomesMap.get(Biome.getIdForBiome(biome))));
        else
            obj.add("BOP Island Weight", new JsonPrimitive(0));
    } catch (final Exception e) {
        LogHelper.error("Failed to retrieve all BOP biome info!");
        e.printStackTrace();
    }
}
Also used : IExtendedBiome(biomesoplenty.api.biome.IExtendedBiome) JsonPrimitive(com.google.gson.JsonPrimitive) JsonObject(com.google.gson.JsonObject) Gson(com.google.gson.Gson) IGenerationManager(biomesoplenty.api.generation.IGenerationManager) JsonArray(com.google.gson.JsonArray) WeightedBiomeEntry(biomesoplenty.api.enums.BOPClimates.WeightedBiomeEntry) IGenerator(biomesoplenty.api.generation.IGenerator) GeneratorStage(biomesoplenty.api.generation.GeneratorStage) BOPClimates(biomesoplenty.api.enums.BOPClimates)

Example 2 with BOPClimates

use of biomesoplenty.api.enums.BOPClimates in project BiomeTweaker by superckl.

the class ScriptCommandAddToGenerationBOP method perform.

@Override
public void perform() throws Exception {
    final BOPClimates climate = BOPClimates.valueOf(this.type);
    final Iterator<Biome> it = this.pack.getIterator();
    while (it.hasNext()) {
        final Biome biome = it.next();
        final IExtendedBiome eBiome = BOPIntegrationModule.getExtendedBiome(biome);
        climate.addBiome(this.weight, eBiome.getBaseBiome());
    }
}
Also used : IExtendedBiome(biomesoplenty.api.biome.IExtendedBiome) Biome(net.minecraft.world.biome.Biome) IExtendedBiome(biomesoplenty.api.biome.IExtendedBiome) BOPClimates(biomesoplenty.api.enums.BOPClimates)

Example 3 with BOPClimates

use of biomesoplenty.api.enums.BOPClimates 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 4 with BOPClimates

use of biomesoplenty.api.enums.BOPClimates in project BiomesOPlenty by Glitchfiend.

the class GenLayerBiomeBOP method getInts.

// Get array of biome IDs covering the requested area
@Override
public int[] getInts(int areaX, int areaY, int areaWidth, int areaHeight) {
    int[] landSeaValues = this.landMassLayer.getInts(areaX, areaY, areaWidth, areaHeight);
    int[] climateValues = this.climateLayer.getInts(areaX, areaY, areaWidth, areaHeight);
    int[] out = IntCache.getIntCache(areaWidth * areaHeight);
    for (int x = 0; x < areaHeight; ++x) {
        for (int z = 0; z < areaWidth; ++z) {
            int index = z + x * areaWidth;
            this.initChunkSeed((long) (z + areaX), (long) (x + areaY));
            int landSeaVal = landSeaValues[index];
            int climateOrdinal = climateValues[index];
            BOPClimates climate;
            try {
                climate = BOPClimates.lookup(climateOrdinal);
            } catch (java.lang.ArrayIndexOutOfBoundsException e) {
                // This shouldn't happen - but apparently it (rarely) does (https://github.com/Glitchfiend/BiomesOPlenty/issues/983)
                // If it does it means that something weird happened with the climate layer / lookup
                // Rethrow with hopefully a more useful message
                String msg = "Climate lookup failed climateOrdinal: " + climateOrdinal + " climate layer mapping: " + climateLayer.debugClimateMappingInts();
                throw new java.lang.RuntimeException(msg, e);
            }
            // At this point, oceans and land have been assigned, and so have mushroom islands
            if (landSeaVal == Biome.getIdForBiome(Biomes.DEEP_OCEAN)) {
                out[index] = Biome.getIdForBiome(climate.getRandomOceanBiome(this, true));
            } else if ((landSeaVal == Biome.getIdForBiome(Biomes.MUSHROOM_ISLAND) || ModBiomes.islandBiomesMap.containsKey(landSeaVal)) && climate.biomeType != BiomeType.ICY) {
                // keep islands, unless it's in an icy climate in which case, replace
                out[index] = landSeaVal;
            } else if (landSeaVal == 0) {
                out[index] = Biome.getIdForBiome(climate.getRandomOceanBiome(this, false));
            } else {
                out[index] = Biome.getIdForBiome(climate.getRandomBiome(this));
            }
        }
    }
    return out;
}
Also used : BOPClimates(biomesoplenty.api.enums.BOPClimates)

Example 5 with BOPClimates

use of biomesoplenty.api.enums.BOPClimates in project BiomeTweaker by superckl.

the class ScriptCommandRemoveBOP method perform.

@Override
public void perform() throws Exception {
    final Iterator<Biome> it = this.pack.getIterator();
    while (it.hasNext()) {
        Biome biome = it.next();
        final IExtendedBiome eBiome = BOPIntegrationModule.getExtendedBiome(biome);
        biome = eBiome.getBaseBiome();
        if (this.types == null)
            for (final BOPClimates climate : BOPClimates.values()) {
                final Iterator<WeightedBiomeEntry> bit = WarningHelper.<List<WeightedBiomeEntry>>uncheckedCast(BOPBiomeProperties.LAND_BIOMES.get(climate)).iterator();
                while (bit.hasNext()) {
                    final WeightedBiomeEntry entry = bit.next();
                    if (Biome.getIdForBiome(entry.biome) == Biome.getIdForBiome(biome)) {
                        bit.remove();
                        BOPBiomeProperties.TOTAL_BIOMES_WEIGHT.set(climate, BOPBiomeProperties.TOTAL_BIOMES_WEIGHT.get(climate) - entry.weight);
                    }
                }
            }
        else
            for (final String type : this.types) {
                final BOPClimates climate = BOPClimates.valueOf(type);
                if (climate == null)
                    throw new IllegalArgumentException("No climate type found for: " + type);
                final Iterator<WeightedBiomeEntry> bit = WarningHelper.<List<WeightedBiomeEntry>>uncheckedCast(BOPBiomeProperties.LAND_BIOMES.get(climate)).iterator();
                while (bit.hasNext()) {
                    final WeightedBiomeEntry entry = bit.next();
                    if (Biome.getIdForBiome(entry.biome) == Biome.getIdForBiome(biome)) {
                        bit.remove();
                        BOPBiomeProperties.TOTAL_BIOMES_WEIGHT.set(climate, BOPBiomeProperties.TOTAL_BIOMES_WEIGHT.get(climate) - entry.weight);
                    }
                }
            }
        BiomeTweaker.getInstance().onTweak(Biome.getIdForBiome(biome));
    }
}
Also used : IExtendedBiome(biomesoplenty.api.biome.IExtendedBiome) Biome(net.minecraft.world.biome.Biome) IExtendedBiome(biomesoplenty.api.biome.IExtendedBiome) WeightedBiomeEntry(biomesoplenty.api.enums.BOPClimates.WeightedBiomeEntry) Iterator(java.util.Iterator) List(java.util.List) BOPClimates(biomesoplenty.api.enums.BOPClimates)

Aggregations

BOPClimates (biomesoplenty.api.enums.BOPClimates)6 IExtendedBiome (biomesoplenty.api.biome.IExtendedBiome)4 Biome (net.minecraft.world.biome.Biome)3 WeightedBiomeEntry (biomesoplenty.api.enums.BOPClimates.WeightedBiomeEntry)2 IConfigObj (biomesoplenty.api.config.IConfigObj)1 GeneratorStage (biomesoplenty.api.generation.GeneratorStage)1 IGenerationManager (biomesoplenty.api.generation.IGenerationManager)1 IGenerator (biomesoplenty.api.generation.IGenerator)1 BOPHellBiome (biomesoplenty.common.biome.nether.BOPHellBiome)1 BOPOverworldBiome (biomesoplenty.common.biome.overworld.BOPOverworldBiome)1 Gson (com.google.gson.Gson)1 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 Iterator (java.util.Iterator)1 List (java.util.List)1 EnumCreatureType (net.minecraft.entity.EnumCreatureType)1 ResourceLocation (net.minecraft.util.ResourceLocation)1