Search in sources :

Example 1 with BiomeProviderRTG

use of rtg.world.biome.BiomeProviderRTG in project Realistic-Terrain-Generation by Team-RTG.

the class MapGenVillageRTG method canSpawnStructureAtCoords.

@Override
protected boolean canSpawnStructureAtCoords(int chunkX, int chunkZ) {
    boolean canSpawnVillage = false;
    int i = chunkX;
    int j = chunkZ;
    if (chunkX < 0)
        chunkX -= this.distance - 1;
    if (chunkZ < 0)
        chunkZ -= this.distance - 1;
    int k = chunkX / this.distance;
    int l = chunkZ / this.distance;
    Random random = this.world.setRandomSeed(k, l, 10387312);
    k = k * this.distance;
    l = l * this.distance;
    k = k + random.nextInt(this.distance - 8);
    l = l + random.nextInt(this.distance - 8);
    if (i == k && j == l) {
        boolean booRTGWorld = DimensionManagerRTG.isValidDimension(world.provider.getDimension());
        boolean booRTGChunkManager = world.getBiomeProvider() instanceof BiomeProviderRTG;
        int worldX = i * 16 + 8;
        int worldZ = j * 16 + 8;
        if (booRTGWorld && booRTGChunkManager) {
            BiomeProviderRTG cmr = (BiomeProviderRTG) world.getBiomeProvider();
            //Why are we flipping XZ here? No idea, but it works. - Pink
            RealisticBiomeBase realisticBiome = cmr.getBiomeDataAt(worldX, worldZ);
            if (realisticBiome.getConfig().ALLOW_VILLAGES.get()) {
                canSpawnVillage = true;
                Logger.debug("Potential village in %s at %d %d", realisticBiome.baseBiome.getBiomeName(), worldX, worldZ);
            }
        } else
            canSpawnVillage = this.world.getBiomeProvider().areBiomesViable(worldX, worldZ, 0, VILLAGE_SPAWN_BIOMES);
    }
    return canSpawnVillage;
}
Also used : Random(java.util.Random) RealisticBiomeBase(rtg.world.biome.realistic.RealisticBiomeBase) BiomeProviderRTG(rtg.world.biome.BiomeProviderRTG)

Example 2 with BiomeProviderRTG

use of rtg.world.biome.BiomeProviderRTG in project Realistic-Terrain-Generation by Team-RTG.

the class WorldTypeRTG method getBiomeProvider.

@Override
@Nonnull
public BiomeProvider getBiomeProvider(@Nonnull World world) {
    if (DimensionManagerRTG.isValidDimension(world.provider.getDimension())) {
        if (biomeProvider == null) {
            biomeProvider = new BiomeProviderRTG(world, this);
            RTG.instance.runOnNextServerCloseOnly(clearProvider(biomeProvider));
        }
        Logger.debug("WorldTypeRTG#getBiomeProvider() returning BiomeProviderRTG");
        return biomeProvider;
    } else {
        Logger.debug("WorldTypeRTG#getBiomeProvider() returning vanilla BiomeProvider");
        return new BiomeProvider(world.getWorldInfo());
    }
}
Also used : BiomeProvider(net.minecraft.world.biome.BiomeProvider) BiomeProviderRTG(rtg.world.biome.BiomeProviderRTG) Nonnull(javax.annotation.Nonnull)

Example 3 with BiomeProviderRTG

use of rtg.world.biome.BiomeProviderRTG in project Realistic-Terrain-Generation by Team-RTG.

the class StructureOceanMonumentRTG method areBiomesViable.

public boolean areBiomesViable(int x, int z, int radius, List<Biome> allowed) {
    // Are we in an RTG world?
    if (!DimensionManagerRTG.isValidDimension(this.world.provider.getDimension())) {
        //Logger.debug("Could not generate ocean monument. This is not an RTG world.");
        return false;
    }
    // Do we have RTG's chunk manager?
    if (!(this.world.getBiomeProvider() instanceof BiomeProviderRTG)) {
        //Logger.debug("Could not generate ocean monument. Incompatible chunk manager detected.");
        return false;
    }
    IntCache.resetIntCache();
    int i = x - radius >> 2;
    int j = z - radius >> 2;
    int k = x + radius >> 2;
    int l = z + radius >> 2;
    int i1 = k - i + 1;
    int j1 = l - j + 1;
    BiomeProviderRTG cmr = (BiomeProviderRTG) this.world.getBiomeProvider();
    int[] aint = cmr.getBiomesGens(i, j, i1, j1);
    try {
        for (int k1 = 0; k1 < i1 * j1; ++k1) {
            Biome biome = Biome.getBiome(aint[k1]);
            if (!allowed.contains(biome)) {
                //Logger.debug("Could not generate ocean monument. Biome (%d) nearby.", BiomeUtils.getId(biome));
                return false;
            }
        }
        return true;
    } catch (Throwable throwable) {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Invalid Biome id");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Layer");
        crashreportcategory.addCrashSection("Layer", Arrays.toString(aint));
        crashreportcategory.addCrashSection("x", x);
        crashreportcategory.addCrashSection("z", z);
        crashreportcategory.addCrashSection("radius", radius);
        crashreportcategory.addCrashSection("allowed", allowed);
        throw new ReportedException(crashreport);
    }
}
Also used : Biome(net.minecraft.world.biome.Biome) CrashReport(net.minecraft.crash.CrashReport) BiomeProviderRTG(rtg.world.biome.BiomeProviderRTG) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ReportedException(net.minecraft.util.ReportedException)

Aggregations

BiomeProviderRTG (rtg.world.biome.BiomeProviderRTG)3 Random (java.util.Random)1 Nonnull (javax.annotation.Nonnull)1 CrashReport (net.minecraft.crash.CrashReport)1 CrashReportCategory (net.minecraft.crash.CrashReportCategory)1 ReportedException (net.minecraft.util.ReportedException)1 Biome (net.minecraft.world.biome.Biome)1 BiomeProvider (net.minecraft.world.biome.BiomeProvider)1 RealisticBiomeBase (rtg.world.biome.realistic.RealisticBiomeBase)1