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;
}
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());
}
}
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);
}
}
Aggregations