use of net.minecraft.util.math.ChunkPos in project Realistic-Terrain-Generation by Team-RTG.
the class MapGenStrongholdRTG method canSpawnStructureAtCoords.
protected boolean canSpawnStructureAtCoords(int chunkX, int chunkZ) {
if (!this.ranBiomeCheck) {
this.generatePositions();
this.ranBiomeCheck = true;
}
for (ChunkPos chunkpos : this.structureCoords) {
if (chunkX == chunkpos.chunkXPos && chunkZ == chunkpos.chunkZPos) {
return true;
}
}
return false;
}
use of net.minecraft.util.math.ChunkPos in project Realistic-Terrain-Generation by Team-RTG.
the class MapGenStrongholdRTG method generatePositions.
private void generatePositions() {
this.initializeStructureData(this.world);
int i = 0;
for (StructureStart structurestart : this.structureMap.values()) {
if (i < this.structureCoords.length) {
this.structureCoords[i++] = new ChunkPos(structurestart.getChunkPosX(), structurestart.getChunkPosZ());
}
}
Random random = new Random();
random.setSeed(this.world.getSeed());
double d1 = random.nextDouble() * Math.PI * 2.0D;
int j = 0;
int k = 0;
int l = this.structureMap.size();
if (l < this.structureCoords.length) {
for (int i1 = 0; i1 < this.structureCoords.length; ++i1) {
double d0 = 4.0D * this.distance + this.distance * (double) j * 6.0D + (random.nextDouble() - 0.5D) * this.distance * 2.5D;
int j1 = (int) Math.round(Math.cos(d1) * d0);
int k1 = (int) Math.round(Math.sin(d1) * d0);
BlockPos blockpos = this.world.getBiomeProvider().findBiomePosition((j1 << 4) + 8, (k1 << 4) + 8, 112, this.allowedBiomes, random);
if (blockpos != null) {
j1 = blockpos.getX() >> 4;
k1 = blockpos.getZ() >> 4;
}
if (i1 >= l) {
this.structureCoords[i1] = new ChunkPos(j1, k1);
}
d1 += (Math.PI * 2D) / (double) this.spread;
++k;
if (k == this.spread) {
++j;
k = 0;
this.spread += 2 * this.spread / (j + 1);
this.spread = Math.min(this.spread, this.structureCoords.length - i1);
d1 += random.nextDouble() * Math.PI * 2.0D;
}
}
}
}
use of net.minecraft.util.math.ChunkPos in project Realistic-Terrain-Generation by Team-RTG.
the class LandscapeGenerator method landscape.
/*
* All of the 'cx' and 'cz' parameters have been flipped when passing them.
* Prior to flipping, the terrain was being XZ-chunk-flipped. - WhichOnesPink
*/
synchronized ChunkLandscape landscape(IBiomeProviderRTG cmr, int cx, int cz) {
ChunkPos chunkPos = new ChunkPos(cx, cz);
ChunkLandscape preExisting = this.storage.get(chunkPos);
if (preExisting != null)
return preExisting;
ChunkLandscape result = new ChunkLandscape();
getNewerNoise(cmr, cx, cz, result);
int[] biomeIndices = cmr.getBiomesGens(cx, cz, 16, 16);
analyzer.newRepair(biomeIndices, result.biome, this.biomeData, this.sampleSize, result.noise, result.river);
//-cmr.getRiverStrength(cx * 16 + 7, cy * 16 + 7));
storage.put(chunkPos, result);
return result;
}
use of net.minecraft.util.math.ChunkPos in project Realistic-Terrain-Generation by Team-RTG.
the class DecoSingleBiomeDecorations method generate.
@Override
public void generate(IRealisticBiome biome, RTGWorld rtgWorld, Random rand, int worldX, int worldZ, float strength, float river, boolean hasPlacedVillageBlocks) {
if (this.allowed) {
// skip if already decorated
ChunkPos position = new ChunkPos(worldX, worldZ);
if (rtgWorld.decoratedChunks.contains(position))
return;
rtgWorld.decoratedChunks.add(position);
super.generate(biome, rtgWorld, rand, worldX, worldZ, strength, river, hasPlacedVillageBlocks);
}
}
use of net.minecraft.util.math.ChunkPos in project RecurrentComplex by Ivorforce.
the class WorldGenStructures method planStructuresInChunk.
public static void planStructuresInChunk(Random random, ChunkPos chunkPos, WorldServer world, Biome biomeGen, @Nullable Predicate<Structure> structurePredicate) {
MixingStructureSelector<NaturalGeneration, NaturalStructureSelector.Category> structureSelector = StructureRegistry.INSTANCE.naturalStructureSelectors().get(biomeGen, world.provider);
float distanceToSpawn = distance(new ChunkPos(world.getSpawnPoint()), chunkPos);
// TODO Use STRUCTURE_TRIES
List<Pair<Structure<?>, NaturalGeneration>> generated = structureSelector.generatedStructures(random, world.getBiome(chunkPos.getBlock(0, 0, 0)), world.provider, distanceToSpawn);
generated.stream().filter(pair -> structurePredicate == null || structurePredicate.test(pair.getLeft())).forEach(pair -> planStructureInChunk(chunkPos, world, pair.getLeft(), pair.getRight(), random.nextLong()));
}
Aggregations