Search in sources :

Example 1 with IExtendedBiome

use of biomesoplenty.api.biome.IExtendedBiome in project BiomeTweaker by superckl.

the class ScriptCommandRemoveGeneratorBOP method perform.

@Override
public void perform() throws Exception {
    final Iterator<Biome> it = this.pack.getIterator();
    while (it.hasNext()) {
        final Biome biome = it.next();
        final IExtendedBiome eBiome = BOPIntegrationModule.getExtendedBiome(biome);
        for (final String type : this.types) eBiome.getGenerationManager().removeGenerator(type);
    }
}
Also used : IExtendedBiome(biomesoplenty.api.biome.IExtendedBiome) Biome(net.minecraft.world.biome.Biome) IExtendedBiome(biomesoplenty.api.biome.IExtendedBiome)

Example 2 with IExtendedBiome

use of biomesoplenty.api.biome.IExtendedBiome 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 3 with IExtendedBiome

use of biomesoplenty.api.biome.IExtendedBiome 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 4 with IExtendedBiome

use of biomesoplenty.api.biome.IExtendedBiome in project BiomesOPlenty by Glitchfiend.

the class DecorateBiomeEventHandler method runGeneratorStage.

private static boolean runGeneratorStage(World world, Random random, BlockPos pos, GeneratorStage stage) {
    Biome biome = world.getBiome(pos.add(16, 0, 16));
    IExtendedBiome extendedBiome = BOPBiomes.REG_INSTANCE.getExtendedBiome(biome);
    if (extendedBiome != null) {
        IGenerationManager generationManager = extendedBiome.getGenerationManager();
        for (IGenerator generator : generationManager.getGeneratorsForStage(stage)) {
            generator.scatter(world, random, pos);
        }
    }
    return true;
}
Also used : IExtendedBiome(biomesoplenty.api.biome.IExtendedBiome) Biome(net.minecraft.world.biome.Biome) IExtendedBiome(biomesoplenty.api.biome.IExtendedBiome) IGenerator(biomesoplenty.api.generation.IGenerator) IGenerationManager(biomesoplenty.api.generation.IGenerationManager)

Example 5 with IExtendedBiome

use of biomesoplenty.api.biome.IExtendedBiome in project BiomesOPlenty by Glitchfiend.

the class GenLayerShoreBOP method getInts.

@Override
public int[] getInts(int areaX, int areaY, int areaWidth, int areaHeight) {
    int[] biomeIds = this.parent.getInts(areaX - 1, areaY - 1, areaWidth + 2, areaHeight + 2);
    int[] out = IntCache.getIntCache(areaWidth * areaHeight);
    for (int z = 0; z < areaHeight; ++z) {
        for (int x = 0; x < areaWidth; ++x) {
            this.initChunkSeed((long) (x + areaX), (long) (z + areaY));
            // The biome we're going to attempt to put a beach beside
            int biomeId = biomeIds[x + 1 + (z + 1) * (areaWidth + 2)];
            Biome biome = Biome.getBiome(biomeId);
            if (biomeId == Biome.getIdForBiome(Biomes.MUSHROOM_ISLAND)) {
                setBiomeWithAdjacent(biomeIds, out, x, z, areaWidth, biomeId, Biome.getIdForBiome(Biomes.MUSHROOM_ISLAND_SHORE), OCEAN_PREDICATE);
            } else if (biome != null && biome.getBiomeClass() == BiomeJungle.class) {
                int biomeNorth = biomeIds[x + 1 + (z + 1 - 1) * (areaWidth + 2)];
                int biomeEast = biomeIds[x + 1 + 1 + (z + 1) * (areaWidth + 2)];
                int biomeWest = biomeIds[x + 1 - 1 + (z + 1) * (areaWidth + 2)];
                int biomeSouth = biomeIds[x + 1 + (z + 1 + 1) * (areaWidth + 2)];
                // Ensure the biomes surrounding the jungle are all suitable before generating a beach
                if (JUNGLE_BORDER_PREDICATE.apply(biomeNorth) && JUNGLE_BORDER_PREDICATE.apply(biomeEast) && JUNGLE_BORDER_PREDICATE.apply(biomeWest) && JUNGLE_BORDER_PREDICATE.apply(biomeSouth)) {
                    setBiomeWithAdjacent(biomeIds, out, x, z, areaWidth, biomeId, Biome.getIdForBiome(Biomes.BEACH), OCEANIC_PREDICATE);
                } else // There is a non-jungle/ocean/taiga/forest next to the jungle, generate an edge biome
                {
                    out[x + z * areaWidth] = Biome.getIdForBiome(Biomes.JUNGLE_EDGE);
                }
            } else if (biomeId != Biome.getIdForBiome(Biomes.EXTREME_HILLS) && biomeId != Biome.getIdForBiome(Biomes.EXTREME_HILLS_WITH_TREES) && biomeId != Biome.getIdForBiome(Biomes.EXTREME_HILLS_EDGE)) {
                if (// Snowy biomes should have cold beaches
                biome != null && biome.isSnowyBiome()) {
                    // Frozen ocean should not have a beach
                    if (isBiomeOceanic(biomeId)) {
                        out[x + z * areaWidth] = biomeId;
                    } else {
                        Biome beachBiome = null;
                        if (BOPBiomes.REG_INSTANCE.getExtendedBiome(biome) != null) {
                            IExtendedBiome extBiome = BOPBiomes.REG_INSTANCE.getExtendedBiome(biome);
                            beachBiome = BiomeUtils.getBiomeForLoc(extBiome.getBeachLocation());
                        }
                        setBiomeWithAdjacent(biomeIds, out, x, z, areaWidth, biomeId, beachBiome == null ? biomeId : Biome.getIdForBiome(Biomes.COLD_BEACH), OCEANIC_PREDICATE);
                    }
                } else if (biomeId != Biome.getIdForBiome(Biomes.MESA) && biomeId != Biome.getIdForBiome(Biomes.MESA_ROCK)) {
                    if (biomeId != Biome.getIdForBiome(Biomes.OCEAN) && biomeId != Biome.getIdForBiome(Biomes.DEEP_OCEAN) && biomeId != Biome.getIdForBiome(Biomes.RIVER) && biomeId != Biome.getIdForBiome(Biomes.SWAMPLAND)) {
                        // Generate custom beaches for our biomes
                        if (biome != null && BOPBiomes.REG_INSTANCE.getExtendedBiome(biome) != null) {
                            IExtendedBiome extBiome = BOPBiomes.REG_INSTANCE.getExtendedBiome(biome);
                            Biome beachBiome = BiomeUtils.getBiomeForLoc(extBiome.getBeachLocation());
                            setBiomeWithAdjacent(biomeIds, out, x, z, areaWidth, biomeId, beachBiome == null ? biomeId : Biome.getIdForBiome(beachBiome), OCEANIC_PREDICATE);
                        } else {
                            setBiomeWithAdjacent(biomeIds, out, x, z, areaWidth, biomeId, Biome.getIdForBiome(Biomes.BEACH), OCEANIC_PREDICATE);
                        }
                    } else // Biome is watery, don't put any beaches next to it
                    {
                        out[x + z * areaWidth] = biomeId;
                    }
                } else // Biome is a variant of the mesa
                {
                    int biomeNorth = biomeIds[x + 1 + (z + 1 - 1) * (areaWidth + 2)];
                    int biomeEast = biomeIds[x + 1 + 1 + (z + 1) * (areaWidth + 2)];
                    int biomeWest = biomeIds[x + 1 - 1 + (z + 1) * (areaWidth + 2)];
                    int biomeSouth = biomeIds[x + 1 + (z + 1 + 1) * (areaWidth + 2)];
                    // Ensure that none of the surrounding biomes are ocean
                    if (!isBiomeOceanic(biomeNorth) && !isBiomeOceanic(biomeEast) && !isBiomeOceanic(biomeWest) && !isBiomeOceanic(biomeSouth)) {
                        // If at least one of the surrounding biomes is a non-mesa, set it to desert
                        setBiomeWithAdjacent(biomeIds, out, x, z, areaWidth, biomeId, Biome.getIdForBiome(Biomes.DESERT), MESA_PREDICATE);
                    } else {
                        out[x + z * areaWidth] = biomeId;
                    }
                }
            } else // Biome is a variant of the extreme hills
            {
                this.setBiomeWithAdjacent(biomeIds, out, x, z, areaWidth, biomeId, Biome.getIdForBiome(Biomes.STONE_BEACH), OCEANIC_PREDICATE);
            }
        }
    }
    return out;
}
Also used : IExtendedBiome(biomesoplenty.api.biome.IExtendedBiome) Biome(net.minecraft.world.biome.Biome) IExtendedBiome(biomesoplenty.api.biome.IExtendedBiome)

Aggregations

IExtendedBiome (biomesoplenty.api.biome.IExtendedBiome)8 Biome (net.minecraft.world.biome.Biome)6 BOPClimates (biomesoplenty.api.enums.BOPClimates)4 WeightedBiomeEntry (biomesoplenty.api.enums.BOPClimates.WeightedBiomeEntry)2 IGenerationManager (biomesoplenty.api.generation.IGenerationManager)2 IGenerator (biomesoplenty.api.generation.IGenerator)2 GeneratorStage (biomesoplenty.api.generation.GeneratorStage)1 BOPHellBiome (biomesoplenty.common.biome.nether.BOPHellBiome)1 BOPOverworldBiome (biomesoplenty.common.biome.overworld.BOPOverworldBiome)1 ExtendedBiomeWrapper (biomesoplenty.common.biome.vanilla.ExtendedBiomeWrapper)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