use of net.minecraft.world.level.levelgen.WorldgenRandom in project Tropicraft by Tropicraft.
the class VolcanoGenerator method generate.
public ChunkAccess generate(int chunkX, int chunkZ, ChunkAccess chunk, WorldgenRandom random) {
BlockPos volcanoCoords = VolcanoGenerator.getVolcanoNear(this.biomeSource, this.worldSeed, chunkX, chunkZ, 0);
if (volcanoCoords == null) {
return chunk;
}
int HEIGHT_OFFSET = VolcanoGenerator.getHeightOffsetForBiome(volcanoCoords.getY());
int calderaCutoff = CALDERA_CUTOFF + HEIGHT_OFFSET;
int lavaLevel = LAVA_LEVEL + HEIGHT_OFFSET;
int volcanoTop = VOLCANO_TOP + HEIGHT_OFFSET;
int volcanoCrust = VOLCANO_CRUST + HEIGHT_OFFSET;
chunkX *= CHUNK_SIZE_X;
chunkZ *= CHUNK_SIZE_Z;
int volcCenterX = volcanoCoords.getX();
int volcCenterZ = volcanoCoords.getZ();
long seed = getPositionSeed(volcCenterX, volcCenterZ);
Random rand = new Random(seed);
int radiusX = rand.nextInt(MAX_RADIUS - MIN_RADIUS) + MIN_RADIUS;
int radiusZ = rand.nextInt(MAX_RADIUS - MIN_RADIUS) + MIN_RADIUS;
NoiseModule volcNoise = getNoise(seed);
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos();
// if this chunk contains the volcano center
if (volcanoCoords.getX() <= chunkX + 15 && volcanoCoords.getX() >= chunkX && volcanoCoords.getZ() <= chunkZ + 15 && volcanoCoords.getZ() >= chunkZ) {
BlockPos volcanoBlockPos = new BlockPos(volcanoCoords.getX() & 15, 1, volcanoCoords.getZ() & 15);
chunk.setBlockState(volcanoBlockPos, TropicraftBlocks.VOLCANO.get().defaultBlockState(), false);
}
for (int x = 0; x < CHUNK_SIZE_X; x++) {
for (int z = 0; z < CHUNK_SIZE_Z; z++) {
int relativeX = ((x + chunkX) - volcCenterX);
int relativeZ = ((z + chunkZ) - volcCenterZ);
double volcanoHeight = getVolcanoHeight(relativeX, relativeZ, radiusX, radiusZ, volcNoise);
float distanceSquared = getDistanceSq(relativeX, relativeZ, radiusX, radiusZ);
int groundHeight = chunk.getHeight(Heightmap.Types.OCEAN_FLOOR_WG, x, z);
groundHeight = Math.min(groundHeight, lavaLevel - 3);
if (distanceSquared < 1) {
for (int y = CHUNK_SIZE_Y; y > 0; y--) {
pos.set(x, y, z);
if (volcanoHeight + groundHeight < calderaCutoff) {
if (volcanoHeight + groundHeight <= volcanoTop) {
if (y <= volcanoHeight + groundHeight) {
if (y > groundHeight) {
this.placeBlock(pos, VOLCANO_BLOCK, chunk);
} else if (y > groundHeight - 2) {
this.placeBlock(pos, SAND_BLOCK, chunk);
}
}
} else if (y == volcanoCrust - 1) {
if (random.nextInt(3) != 0) {
this.placeBlock(pos, VOLCANO_BLOCK, chunk);
}
} else if (y <= volcanoTop) {
placeBlock(pos, VOLCANO_BLOCK, chunk);
}
} else {
// Flat area on top of the volcano
if (y == volcanoCrust && rand.nextInt(CRUST_HOLE_CHANCE) != 0) {
placeBlock(pos, VOLCANO_BLOCK, chunk);
} else if (y <= lavaLevel) {
placeBlock(pos, LAVA_BLOCK, chunk);
} else {
placeBlock(pos, Blocks.AIR::defaultBlockState, chunk);
}
}
}
}
}
}
return chunk;
}
use of net.minecraft.world.level.levelgen.WorldgenRandom in project Tropicraft by Tropicraft.
the class MangroveSurfaceBuilder method initNoise.
@Override
public void initNoise(long seed) {
if (this.seed != seed || this.mudNoise == null) {
WorldgenRandom random = new WorldgenRandom(seed);
this.mudNoise = new PerlinSimplexNoise(random, IntStream.rangeClosed(0, 2));
this.streamNoise = new PerlinSimplexNoise(random, IntStream.rangeClosed(0, 2));
}
this.seed = seed;
}
use of net.minecraft.world.level.levelgen.WorldgenRandom in project Tropicraft by Tropicraft.
the class TropicraftChunkGenerator method fillFromNoise.
@Override
public CompletableFuture<ChunkAccess> fillFromNoise(Executor executor, StructureFeatureManager structures, ChunkAccess chunk) {
CompletableFuture<ChunkAccess> future = super.fillFromNoise(executor, structures, chunk);
return future.thenApply(chunkAccess -> {
ChunkPos chunkPos = chunk.getPos();
WorldgenRandom random = new WorldgenRandom(this.seed);
volcano.generate(chunkPos.x, chunkPos.z, chunk, random);
return chunkAccess;
});
}
use of net.minecraft.world.level.levelgen.WorldgenRandom in project Tropicraft by Tropicraft.
the class HomeTreeBranchPiece method place.
@Override
public boolean place(StructureManager templates, WorldGenLevel world, StructureFeatureManager structures, ChunkGenerator generator, BlockPos origin, BlockPos p_230378_6_, Rotation rotation, BoundingBox chunkBounds, Random random, boolean p_230378_10_) {
WorldgenRandom rand = new WorldgenRandom();
rand.setDecorationSeed(world.getSeed(), origin.getX(), origin.getZ());
final int branchLength = rand.nextInt(10) + 15;
// TODO make configurable
int branchX1 = origin.getX();
int branchZ1 = origin.getZ();
final double minAngle = Math.toRadians(this.minAngle);
final double maxAngle = Math.toRadians(this.maxAngle);
final double angle = minAngle + rand.nextFloat() * (maxAngle - minAngle);
int branchX2 = (int) ((branchLength * Math.sin(angle)) + branchX1);
int branchZ2 = (int) ((branchLength * Math.cos(angle)) + branchZ1);
int branchY2 = rand.nextInt(4) + 4;
BlockState wood = TropicraftBlocks.MAHOGANY_LOG.get().defaultBlockState();
final BlockState leaf = TropicraftBlocks.MAHOGANY_LEAVES.get().defaultBlockState();
final int leafCircleSizeConstant = 3;
final int y2 = origin.getY() + branchY2;
placeBlockLine(world, new BlockPos(branchX1, origin.getY(), branchZ1), new BlockPos(branchX2, y2, branchZ2), wood, chunkBounds);
placeBlockLine(world, new BlockPos(branchX1 + 1, origin.getY(), branchZ1), new BlockPos(branchX2 + 1, y2, branchZ2), wood, chunkBounds);
placeBlockLine(world, new BlockPos(branchX1 - 1, origin.getY(), branchZ1), new BlockPos(branchX2 - 1, y2, branchZ2), wood, chunkBounds);
placeBlockLine(world, new BlockPos(branchX1, origin.getY(), branchZ1 + 1), new BlockPos(branchX2, y2, branchZ2 + 1), wood, chunkBounds);
placeBlockLine(world, new BlockPos(branchX1, origin.getY(), branchZ1 - 1), new BlockPos(branchX2, y2, branchZ2 - 1), wood, chunkBounds);
placeBlockLine(world, new BlockPos(branchX1, origin.getY() - 1, branchZ1), new BlockPos(branchX2, y2 - 1, branchZ2), wood, chunkBounds);
placeBlockLine(world, new BlockPos(branchX1, origin.getY() + 1, branchZ1), new BlockPos(branchX2, y2 + 1, branchZ2), wood, chunkBounds);
genLeafCircle(world, branchX2, y2 - 1, branchZ2, leafCircleSizeConstant + 5, leafCircleSizeConstant + 3, leaf, chunkBounds);
genLeafCircle(world, branchX2, y2, branchZ2, leafCircleSizeConstant + 6, 0, leaf, chunkBounds);
genLeafCircle(world, branchX2, y2 + 1, branchZ2, leafCircleSizeConstant + 10, 0, leaf, chunkBounds);
genLeafCircle(world, branchX2, y2 + 2, branchZ2, leafCircleSizeConstant + 9, 0, leaf, chunkBounds);
return true;
}
Aggregations