reformatted project
This commit is contained in:
@@ -7,13 +7,13 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public enum BlockPallet {
|
||||
GROUND(new Block[] {Block.GRAVEL, Block.STONE, Block.DIRT, Block.GRASS_BLOCK, Block.COARSE_DIRT, Block.ROOTED_DIRT}),
|
||||
WOOD(new Block[] {Block.ACACIA_WOOD, Block.BIRCH_WOOD, Block.JUNGLE_WOOD, Block.OAK_WOOD, Block.DARK_OAK_WOOD, Block.SPRUCE_WOOD}),
|
||||
STONE(new Block[] {Block.CHISELED_STONE_BRICKS, Block.STONE_BRICKS, Block.POLISHED_ANDESITE, Block.POLISHED_BLACKSTONE, Block.POLISHED_DIORITE}),
|
||||
WINTER(new Block[] {Block.SNOW_BLOCK, Block.ICE, Block.PACKED_ICE, Block.BLUE_CONCRETE, Block.SEA_LANTERN}),
|
||||
STREET(new Block[] {Block.BLACK_CONCRETE_POWDER, Block.GRAY_CONCRETE_POWDER, Block.GRAVEL, Block.BLACK_CONCRETE, Block.GRAY_CONCRETE}),
|
||||
FLOWER(new Block[] {Block.ORANGE_TULIP, Block.PINK_TULIP, Block.RED_TULIP, Block.WHITE_TULIP, Block.DANDELION, Block.POPPY, Block.CORNFLOWER}),
|
||||
PRESSURE_PLATES(new Block[] {Block.ACACIA_PRESSURE_PLATE, Block.BIRCH_PRESSURE_PLATE, Block.CRIMSON_PRESSURE_PLATE, Block.JUNGLE_PRESSURE_PLATE, Block.OAK_PRESSURE_PLATE, Block.DARK_OAK_PRESSURE_PLATE, Block.HEAVY_WEIGHTED_PRESSURE_PLATE, Block.HEAVY_WEIGHTED_PRESSURE_PLATE, Block.POLISHED_BLACKSTONE_PRESSURE_PLATE, Block.SPRUCE_PRESSURE_PLATE, Block.STONE_PRESSURE_PLATE, Block.WARPED_PRESSURE_PLATE});
|
||||
GROUND(new Block[]{Block.GRAVEL, Block.STONE, Block.DIRT, Block.GRASS_BLOCK, Block.COARSE_DIRT, Block.ROOTED_DIRT}),
|
||||
WOOD(new Block[]{Block.ACACIA_WOOD, Block.BIRCH_WOOD, Block.JUNGLE_WOOD, Block.OAK_WOOD, Block.DARK_OAK_WOOD, Block.SPRUCE_WOOD}),
|
||||
STONE(new Block[]{Block.CHISELED_STONE_BRICKS, Block.STONE_BRICKS, Block.POLISHED_ANDESITE, Block.POLISHED_BLACKSTONE, Block.POLISHED_DIORITE}),
|
||||
WINTER(new Block[]{Block.SNOW_BLOCK, Block.ICE, Block.PACKED_ICE, Block.BLUE_CONCRETE, Block.SEA_LANTERN}),
|
||||
STREET(new Block[]{Block.BLACK_CONCRETE_POWDER, Block.GRAY_CONCRETE_POWDER, Block.GRAVEL, Block.BLACK_CONCRETE, Block.GRAY_CONCRETE}),
|
||||
FLOWER(new Block[]{Block.ORANGE_TULIP, Block.PINK_TULIP, Block.RED_TULIP, Block.WHITE_TULIP, Block.DANDELION, Block.POPPY, Block.CORNFLOWER}),
|
||||
PRESSURE_PLATES(new Block[]{Block.ACACIA_PRESSURE_PLATE, Block.BIRCH_PRESSURE_PLATE, Block.CRIMSON_PRESSURE_PLATE, Block.JUNGLE_PRESSURE_PLATE, Block.OAK_PRESSURE_PLATE, Block.DARK_OAK_PRESSURE_PLATE, Block.HEAVY_WEIGHTED_PRESSURE_PLATE, Block.HEAVY_WEIGHTED_PRESSURE_PLATE, Block.POLISHED_BLACKSTONE_PRESSURE_PLATE, Block.SPRUCE_PRESSURE_PLATE, Block.STONE_PRESSURE_PLATE, Block.WARPED_PRESSURE_PLATE});
|
||||
|
||||
final List<Block> list;
|
||||
final Random rnd = new Random();
|
||||
@@ -23,11 +23,11 @@ public enum BlockPallet {
|
||||
}
|
||||
|
||||
public Block rnd() {
|
||||
return list.get(rnd.nextInt(list.size()));
|
||||
return this.list.get(this.rnd.nextInt(this.list.size()));
|
||||
}
|
||||
|
||||
public boolean contains(Block b) {
|
||||
return list.contains(b);
|
||||
return this.list.contains(b);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,6 @@ public abstract class PlateTerrainGenerator implements Generator {
|
||||
}
|
||||
|
||||
public boolean generatePlate() {
|
||||
return plateHeight > 0;
|
||||
return this.plateHeight > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,15 +13,13 @@ public class CircularPlateGenerator extends HeightTerrainGenerator {
|
||||
private final SingleExecution execution = SingleExecution.make();
|
||||
private final int radius;
|
||||
private final int height;
|
||||
private final boolean generated = false;
|
||||
private BlockPallet blockPallet = BlockPallet.GROUND;
|
||||
|
||||
private int centerX = 0;
|
||||
private int centerZ = 0;
|
||||
|
||||
private boolean generated = false;
|
||||
|
||||
public CircularPlateGenerator(int radius, int height) {
|
||||
setCalculateHeight(point -> (int) ((point.distance(new Pos(0, point.y(), 0)) / 2) - radius));
|
||||
this.setCalculateHeight(point -> (int) ((point.distance(new Pos(0, point.y(), 0)) / 2) - radius));
|
||||
this.radius = radius;
|
||||
this.height = height;
|
||||
}
|
||||
@@ -39,19 +37,19 @@ public class CircularPlateGenerator extends HeightTerrainGenerator {
|
||||
|
||||
@Override
|
||||
public void generate(@NotNull GenerationUnit unit) {
|
||||
execution.singleRun(() -> unit.fork(setter -> {
|
||||
System.out.println(new Pos(-(radius + centerX), unit.absoluteStart().y(), -(radius + centerZ)));
|
||||
System.out.println(new Pos(radius + centerX, height, radius + centerZ));
|
||||
this.execution.singleRun(() -> unit.fork(setter -> {
|
||||
System.out.println(new Pos(-(this.radius + this.centerX), unit.absoluteStart().y(), -(this.radius + this.centerZ)));
|
||||
System.out.println(new Pos(this.radius + this.centerX, this.height, this.radius + this.centerZ));
|
||||
GeneratorUtils.foreachXZ(
|
||||
new Pos(-(radius + centerX), unit.absoluteStart().y(), -(radius + centerZ)),
|
||||
new Pos(radius + centerX, height, radius + centerZ),
|
||||
point -> {
|
||||
double distance = point.distance(new Pos(centerX, point.y(), centerZ));
|
||||
new Pos(-(this.radius + this.centerX), unit.absoluteStart().y(), -(this.radius + this.centerZ)),
|
||||
new Pos(this.radius + this.centerX, this.height, this.radius + this.centerZ),
|
||||
point -> {
|
||||
double distance = point.distance(new Pos(this.centerX, point.y(), this.centerZ));
|
||||
|
||||
if(distance <= this.radius) {
|
||||
setter.setBlock(point.add(1, height, 1), Block.GOLD_BLOCK);
|
||||
}
|
||||
if(distance <= this.radius) {
|
||||
setter.setBlock(point.add(1, this.height, 1), Block.GOLD_BLOCK);
|
||||
}
|
||||
}
|
||||
);
|
||||
}));
|
||||
|
||||
|
||||
@@ -9,31 +9,31 @@ import java.util.function.Function;
|
||||
|
||||
public class ValeGenerator extends HeightTerrainGenerator {
|
||||
private final JNoise curves = JNoise.newBuilder()
|
||||
.fastSimplex()
|
||||
.setSeed(rnd.nextLong())
|
||||
.setFrequency(0.01)
|
||||
.build();
|
||||
.fastSimplex()
|
||||
.setSeed(this.rnd.nextLong())
|
||||
.setFrequency(0.01)
|
||||
.build();
|
||||
|
||||
private final JNoise largeCurves = JNoise.newBuilder()
|
||||
.fastSimplex()
|
||||
.setSeed(rnd.nextLong())
|
||||
.setFrequency(0.001)
|
||||
.build();
|
||||
.fastSimplex()
|
||||
.setSeed(this.rnd.nextLong())
|
||||
.setFrequency(0.001)
|
||||
.build();
|
||||
|
||||
private Function<Integer, Double> xShiftMultiplier = multiplier -> 1d;
|
||||
private Function<Integer, Double> xShiftOffset = z -> 0d;
|
||||
|
||||
public ValeGenerator() {
|
||||
setCalculateHeight(this::calculateY);
|
||||
setHeightNoiseMultiplier(point -> (int) NumberUtil.map(calculateY(point), -64, 100, 0, 16));
|
||||
this.setCalculateHeight(this::calculateY);
|
||||
this.setHeightNoiseMultiplier(point -> (int) NumberUtil.map(this.calculateY(point), -64, 100, 0, 16));
|
||||
}
|
||||
|
||||
private int calculateY(Point point) {
|
||||
return (int) (Math.abs(point.blockX() - getXShiftAtZ(point.blockZ())) / 1.5);
|
||||
return (int) (Math.abs(point.blockX() - this.getXShiftAtZ(point.blockZ())) / 1.5);
|
||||
}
|
||||
|
||||
public int getXShiftAtZ(int z) {
|
||||
return (int) ((curves.getNoise(z) * 32 + largeCurves.getNoise(z) * 64) * xShiftMultiplier.apply(z) + xShiftOffset.apply(z));
|
||||
return (int) ((this.curves.getNoise(z) * 32 + this.largeCurves.getNoise(z) * 64) * this.xShiftMultiplier.apply(z) + this.xShiftOffset.apply(z));
|
||||
}
|
||||
|
||||
public void setXShiftMultiplier(Function<Integer, Double> xShiftMultiplier) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minestom.server.instance.block.Block;
|
||||
public class PeakRock extends Structure {
|
||||
private final Point position;
|
||||
private final BlockPallet blockPallet;
|
||||
|
||||
public PeakRock(Point position, BlockPallet blockPallet) {
|
||||
this.position = position;
|
||||
this.blockPallet = blockPallet;
|
||||
@@ -15,14 +16,14 @@ public class PeakRock extends Structure {
|
||||
|
||||
@Override
|
||||
public void generateStructure(Block.Setter setter) {
|
||||
for (int stoneX = -4; stoneX < 4; stoneX++) {
|
||||
for (int stoneZ = -4; stoneZ < 4; stoneZ++) {
|
||||
for(int stoneX = -4; stoneX < 4; stoneX++) {
|
||||
for(int stoneZ = -4; stoneZ < 4; stoneZ++) {
|
||||
|
||||
double distanceToCenter = position.add(stoneX, 0, stoneZ).distance(position);
|
||||
double distanceToCenter = this.position.add(stoneX, 0, stoneZ).distance(this.position);
|
||||
if(distanceToCenter > 3) continue;
|
||||
|
||||
for (int stoneY = 0; stoneY < 10-(int) distanceToCenter * rnd.nextDouble(2, 5); stoneY++) {
|
||||
Point blockPos = position.add(stoneX, stoneY, stoneZ);
|
||||
for(int stoneY = 0; stoneY < 10 - (int) distanceToCenter * this.rnd.nextDouble(2, 5); stoneY++) {
|
||||
Point blockPos = this.position.add(stoneX, stoneY, stoneZ);
|
||||
setter.setBlock(blockPos, this.blockPallet.rnd());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,18 +13,18 @@ public class Tree extends Structure {
|
||||
|
||||
@Override
|
||||
public void generateStructure(Block.Setter setter) {
|
||||
int trunkX = position.blockX();
|
||||
int trunkBottomY = position.blockY();
|
||||
int trunkZ = position.blockZ();
|
||||
int trunkX = this.position.blockX();
|
||||
int trunkBottomY = this.position.blockY();
|
||||
int trunkZ = this.position.blockZ();
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for(int i = 0; i < 2; i++) {
|
||||
setter.setBlock(trunkX + 1, trunkBottomY + 3 + i, trunkZ, Block.OAK_LEAVES);
|
||||
setter.setBlock(trunkX - 1, trunkBottomY + 3 + i, trunkZ, Block.OAK_LEAVES);
|
||||
setter.setBlock(trunkX, trunkBottomY + 3 + i, trunkZ + 1, Block.OAK_LEAVES);
|
||||
setter.setBlock(trunkX, trunkBottomY + 3 + i, trunkZ - 1, Block.OAK_LEAVES);
|
||||
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
for(int x = -1; x <= 1; x++) {
|
||||
for(int z = -1; z <= 1; z++) {
|
||||
setter.setBlock(trunkX + x, trunkBottomY + 2 + i, trunkZ - z, Block.OAK_LEAVES);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,12 +21,12 @@ public abstract class BaseGenerator implements Generator {
|
||||
}
|
||||
|
||||
protected void applyStructures(GenerationUnit unit) {
|
||||
structures.forEach(structure -> unit.fork(structure::generateStructure));
|
||||
this.structures.forEach(structure -> unit.fork(structure::generateStructure));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void generate(@NotNull GenerationUnit unit) {
|
||||
mixIns.forEach(generator -> generator.generate(unit));
|
||||
this.mixIns.forEach(generator -> generator.generate(unit));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,29 +16,30 @@ import java.util.Random;
|
||||
public class CircularPlateTerrainGenerator extends PlateTerrainGenerator {
|
||||
protected final Random rnd = new Random();
|
||||
private final int size;
|
||||
private final JNoise base = JNoise.newBuilder()
|
||||
.fastSimplex()
|
||||
.setSeed(this.rnd.nextLong())
|
||||
.setFrequency(0.01)
|
||||
.build();
|
||||
private final JNoise batches = JNoise.newBuilder()
|
||||
.fastSimplex()
|
||||
.setSeed(this.rnd.nextLong())
|
||||
.setFrequency(0.05)
|
||||
.build();
|
||||
private final JNoise peaks = JNoise.newBuilder()
|
||||
.fastSimplex()
|
||||
.setSeed(this.rnd.nextLong())
|
||||
.setFrequency(0.1)
|
||||
.build();
|
||||
|
||||
public CircularPlateTerrainGenerator(int size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
private final JNoise base = JNoise.newBuilder()
|
||||
.fastSimplex()
|
||||
.setSeed(rnd.nextLong())
|
||||
.setFrequency(0.01)
|
||||
.build();
|
||||
|
||||
private final JNoise batches = JNoise.newBuilder()
|
||||
.fastSimplex()
|
||||
.setSeed(rnd.nextLong())
|
||||
.setFrequency(0.05)
|
||||
.build();
|
||||
|
||||
private final JNoise peaks = JNoise.newBuilder()
|
||||
.fastSimplex()
|
||||
.setSeed(rnd.nextLong())
|
||||
.setFrequency(0.1)
|
||||
.build();
|
||||
|
||||
private static double minTwo(double input) {
|
||||
if(input < 2) return 2;
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(@NotNull GenerationUnit unit) {
|
||||
@@ -46,40 +47,40 @@ public class CircularPlateTerrainGenerator extends PlateTerrainGenerator {
|
||||
|
||||
if(unit.absoluteStart().distance(new Pos(0, 0, 0)) > 500 + this.size) return;
|
||||
|
||||
for (int x = 0; x < unit.size().x(); x++) {
|
||||
for (int z = 0; z < unit.size().z(); z++) {
|
||||
for(int x = 0; x < unit.size().x(); x++) {
|
||||
for(int z = 0; z < unit.size().z(); z++) {
|
||||
Point bottom = start.add(x, 0, z);
|
||||
|
||||
double distance = bottom.distance(new Pos(0, 0, 0));
|
||||
|
||||
if(distance <= this.size && generatePlate()) {
|
||||
unit.modifier().fill(bottom, bottom.add(1, plateHeight, 1), platePallet.rnd());
|
||||
if(distance <= this.size && this.generatePlate()) {
|
||||
unit.modifier().fill(bottom, bottom.add(1, this.plateHeight, 1), this.platePallet.rnd());
|
||||
continue;
|
||||
}
|
||||
|
||||
unit.modifier().setBlock(bottom, Block.GRASS_BLOCK);
|
||||
|
||||
synchronized (base) {
|
||||
double baseNoise = base.getNoise(bottom.x(), bottom.z());
|
||||
synchronized(this.base) {
|
||||
double baseNoise = this.base.getNoise(bottom.x(), bottom.z());
|
||||
double currentHeight = minTwo(NumberUtil.map(distance, 0, 400, -((double) this.size / 5), 200)) + baseNoise * 8;
|
||||
|
||||
synchronized (batches) {
|
||||
double elementNoise = batches.getNoise(bottom.x(), bottom.z());
|
||||
synchronized(this.batches) {
|
||||
double elementNoise = this.batches.getNoise(bottom.x(), bottom.z());
|
||||
|
||||
unit.modifier().fill(
|
||||
bottom,
|
||||
bottom.add(1, 1, 1)
|
||||
.withY(currentHeight),
|
||||
elementNoise < 0.9 ? elementNoise > 0 ? Block.GRASS_BLOCK : Block.SOUL_SAND : Block.STONE
|
||||
bottom,
|
||||
bottom.add(1, 1, 1)
|
||||
.withY(currentHeight),
|
||||
elementNoise < 0.9 ? elementNoise > 0 ? Block.GRASS_BLOCK : Block.SOUL_SAND : Block.STONE
|
||||
);
|
||||
}
|
||||
|
||||
synchronized (peaks) {
|
||||
double peakNoise = peaks.getNoise(bottom.x(), bottom.z());
|
||||
synchronized(this.peaks) {
|
||||
double peakNoise = this.peaks.getNoise(bottom.x(), bottom.z());
|
||||
|
||||
if(peakNoise > 0.97 && bottom.distance(new Pos(0, 0, 0)) > (this.size + 20)) {
|
||||
|
||||
Point center = bottom.add(1, currentHeight-3, 1);
|
||||
Point center = bottom.add(1, currentHeight - 3, 1);
|
||||
unit.fork(setter -> new PeakRock(center, BlockPallet.STONE).generateStructure(setter));
|
||||
}
|
||||
}
|
||||
@@ -90,9 +91,4 @@ public class CircularPlateTerrainGenerator extends PlateTerrainGenerator {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static double minTwo(double input) {
|
||||
if(input < 2) return 2;
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package eu.mhsl.minenet.minigames.world.generator.terrain;
|
||||
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.instance.generator.GenerationUnit;
|
||||
import net.minestom.server.instance.generator.Generator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class FlatTerrainGenerator implements Generator {
|
||||
private final int height;
|
||||
private final Block block;
|
||||
|
||||
public FlatTerrainGenerator(int height, Block block) {
|
||||
this.height = height;
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
FlatTerrainGenerator() {
|
||||
this.height = 5;
|
||||
this.block = Block.GRASS_BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(@NotNull GenerationUnit unit) {
|
||||
unit.modifier().fillHeight(0, height, block);
|
||||
}
|
||||
}
|
||||
@@ -16,72 +16,68 @@ import java.util.function.Function;
|
||||
|
||||
public class HeightTerrainGenerator extends BaseGenerator {
|
||||
protected final Random rnd = new Random();
|
||||
private Function<Point, Integer> calculateHeight = (Point) -> 0;
|
||||
private final JNoise base = JNoise.newBuilder()
|
||||
.fastSimplex()
|
||||
.setSeed(this.rnd.nextLong())
|
||||
.setFrequency(0.01)
|
||||
.build();
|
||||
private final JNoise batches = JNoise.newBuilder()
|
||||
.fastSimplex()
|
||||
.setSeed(this.rnd.nextLong())
|
||||
.setFrequency(0.05)
|
||||
.build();
|
||||
private final JNoise peaks = JNoise.newBuilder()
|
||||
.fastSimplex()
|
||||
.setSeed(this.rnd.nextLong())
|
||||
.setFrequency(0.1)
|
||||
.build();
|
||||
private final BlockPallet blockPallet = BlockPallet.STONE;
|
||||
protected Function<Point, Integer> heightNoiseMultiplier = (Point) -> 16;
|
||||
protected Function<Point, Integer> calculateSeaLevel = null;
|
||||
|
||||
private final JNoise base = JNoise.newBuilder()
|
||||
.fastSimplex()
|
||||
.setSeed(rnd.nextLong())
|
||||
.setFrequency(0.01)
|
||||
.build();
|
||||
|
||||
private final JNoise batches = JNoise.newBuilder()
|
||||
.fastSimplex()
|
||||
.setSeed(rnd.nextLong())
|
||||
.setFrequency(0.05)
|
||||
.build();
|
||||
|
||||
private final JNoise peaks = JNoise.newBuilder()
|
||||
.fastSimplex()
|
||||
.setSeed(rnd.nextLong())
|
||||
.setFrequency(0.1)
|
||||
.build();
|
||||
|
||||
private final BlockPallet blockPallet = BlockPallet.STONE;
|
||||
private Function<Point, Integer> calculateHeight = (Point) -> 0;
|
||||
|
||||
@Override
|
||||
public void generate(@NotNull GenerationUnit unit) {
|
||||
super.generate(unit);
|
||||
GeneratorUtils.foreachXZ(unit, bottomPoint -> {
|
||||
unit.modifier().setBlock(bottomPoint, blockPallet.rnd());
|
||||
unit.modifier().setBlock(bottomPoint, this.blockPallet.rnd());
|
||||
|
||||
synchronized (base) {
|
||||
double heightNoise = base.getNoise(bottomPoint.x(), bottomPoint.z());
|
||||
double noiseModifier = heightNoise * heightNoiseMultiplier.apply(bottomPoint);
|
||||
double heightModifier = NumberUtil.clamp(calculateHeight.apply(bottomPoint) + noiseModifier, 1d, unit.size().y());
|
||||
synchronized(this.base) {
|
||||
double heightNoise = this.base.getNoise(bottomPoint.x(), bottomPoint.z());
|
||||
double noiseModifier = heightNoise * this.heightNoiseMultiplier.apply(bottomPoint);
|
||||
double heightModifier = NumberUtil.clamp(this.calculateHeight.apply(bottomPoint) + noiseModifier, 1d, unit.size().y());
|
||||
if(heightModifier < 1) System.out.println("HEIGHT MODIFIER ILLEGAL");
|
||||
|
||||
synchronized (batches) {
|
||||
double batchNoise = batches.getNoise(bottomPoint.x(), bottomPoint.z());
|
||||
synchronized(this.batches) {
|
||||
double batchNoise = this.batches.getNoise(bottomPoint.x(), bottomPoint.z());
|
||||
|
||||
Block block = batchNoise < 0.9 ? batchNoise > -0.2 ? Block.GRASS_BLOCK : Block.SOUL_SAND : Block.STONE;
|
||||
unit.modifier().fill(bottomPoint, bottomPoint.add(1, heightModifier, 1), block);
|
||||
if(rnd.nextInt(0, 5) < 1 && block == Block.GRASS_BLOCK) {
|
||||
int randomInt = rnd.nextInt(0, 6);
|
||||
if(this.rnd.nextInt(0, 5) < 1 && block == Block.GRASS_BLOCK) {
|
||||
int randomInt = this.rnd.nextInt(0, 6);
|
||||
if(randomInt > 1) {
|
||||
unit.modifier().setBlock(bottomPoint.add(0, heightModifier, 0), Block.SHORT_GRASS);
|
||||
} else if(randomInt > 0) {
|
||||
unit.modifier().setBlock(bottomPoint.add(0, heightModifier, 0), BlockPallet.FLOWER.rnd());
|
||||
} else {
|
||||
unit.modifier().setBlock(bottomPoint.add(0, heightModifier, 0), Block.TALL_GRASS);
|
||||
unit.modifier().setBlock(bottomPoint.add(0, heightModifier+1, 0), Block.TALL_GRASS.withProperty("half", "upper"));
|
||||
unit.modifier().setBlock(bottomPoint.add(0, heightModifier + 1, 0), Block.TALL_GRASS.withProperty("half", "upper"));
|
||||
}
|
||||
}
|
||||
|
||||
if(calculateSeaLevel != null) {
|
||||
if(this.calculateSeaLevel != null) {
|
||||
Point absoluteHeight = bottomPoint.add(0, heightModifier, 0);
|
||||
int seaLevel = calculateSeaLevel.apply(bottomPoint);
|
||||
int seaLevel = this.calculateSeaLevel.apply(bottomPoint);
|
||||
if(absoluteHeight.y() < seaLevel) {
|
||||
// System.out.println("HM:" + absoluteHeight.y() + " SL:" + seaLevel);
|
||||
// System.out.println("Filling from " + bottomPoint.y() + " to " + absoluteHeight.withY(seaLevel).y());
|
||||
unit.modifier().fill(bottomPoint.withY(v -> v+heightModifier), absoluteHeight.add(1, 0, 1).withY(seaLevel), Block.WATER);
|
||||
unit.modifier().fill(bottomPoint.withY(v -> v + heightModifier), absoluteHeight.add(1, 0, 1).withY(seaLevel), Block.WATER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
synchronized (peaks) {
|
||||
double peakNoise = peaks.getNoise(bottomPoint.x(), bottomPoint.z());
|
||||
synchronized(this.peaks) {
|
||||
double peakNoise = this.peaks.getNoise(bottomPoint.x(), bottomPoint.z());
|
||||
|
||||
if(peakNoise > 0.97 && bottomPoint.distance(new Pos(0, 0, 0)) > (50 + 20)) {
|
||||
|
||||
|
||||
@@ -14,13 +14,8 @@ public class PlaneTerrainGenerator implements Generator {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
PlaneTerrainGenerator() {
|
||||
this.height = 5;
|
||||
this.block = Block.GRASS_BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(@NotNull GenerationUnit unit) {
|
||||
unit.modifier().fillHeight(height-1, height, block);
|
||||
unit.modifier().fillHeight(this.height - 1, this.height, this.block);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,31 +20,31 @@ public class SquarePlateTerrainGenerator extends PlateTerrainGenerator {
|
||||
|
||||
private final int width;
|
||||
private final int length;
|
||||
|
||||
private final JNoise base = JNoise.newBuilder()
|
||||
.fastSimplex()
|
||||
.setSeed(this.rnd.nextLong())
|
||||
.setFrequency(0.01)
|
||||
.build();
|
||||
private final JNoise batches = JNoise.newBuilder()
|
||||
.fastSimplex()
|
||||
.setSeed(this.rnd.nextLong())
|
||||
.setFrequency(0.05)
|
||||
.build();
|
||||
private final JNoise peaks = JNoise.newBuilder()
|
||||
.fastSimplex()
|
||||
.setSeed(this.rnd.nextLong())
|
||||
.setFrequency(0.1)
|
||||
.build();
|
||||
|
||||
public SquarePlateTerrainGenerator(int width, int length) {
|
||||
this.width = width;
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
private final JNoise base = JNoise.newBuilder()
|
||||
.fastSimplex()
|
||||
.setSeed(rnd.nextLong())
|
||||
.setFrequency(0.01)
|
||||
.build();
|
||||
|
||||
private final JNoise batches = JNoise.newBuilder()
|
||||
.fastSimplex()
|
||||
.setSeed(rnd.nextLong())
|
||||
.setFrequency(0.05)
|
||||
.build();
|
||||
|
||||
private final JNoise peaks = JNoise.newBuilder()
|
||||
.fastSimplex()
|
||||
.setSeed(rnd.nextLong())
|
||||
.setFrequency(0.1)
|
||||
.build();
|
||||
|
||||
private static double minTwo(double input) {
|
||||
if(input < 2) return 2;
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(@NotNull GenerationUnit unit) {
|
||||
@@ -52,28 +52,28 @@ public class SquarePlateTerrainGenerator extends PlateTerrainGenerator {
|
||||
|
||||
// don't generate more than 500 blocks outwards
|
||||
Point chunkStart = unit.absoluteStart();
|
||||
if(chunkStart.z() > length + 500 || chunkStart.z() < -500) return;
|
||||
if(chunkStart.x() < -500 || chunkStart.x() > width + 500) return;
|
||||
if(chunkStart.z() > this.length + 500 || chunkStart.z() < -500) return;
|
||||
if(chunkStart.x() < -500 || chunkStart.x() > this.width + 500) return;
|
||||
|
||||
for (int x = 0; x < unit.size().x(); x++) {
|
||||
for (int z = 0; z < unit.size().z(); z++) {
|
||||
for(int x = 0; x < unit.size().x(); x++) {
|
||||
for(int z = 0; z < unit.size().z(); z++) {
|
||||
Point bottom = start.add(x, 0, z);
|
||||
|
||||
if(generatePlate()) {
|
||||
if(bottom.x() <= width && bottom.x() >= 0 && bottom.z() <= length && bottom.z() >= 0) {
|
||||
unit.modifier().fill(bottom, bottom.add(1, plateHeight, 1), platePallet.rnd());
|
||||
if(this.generatePlate()) {
|
||||
if(bottom.x() <= this.width && bottom.x() >= 0 && bottom.z() <= this.length && bottom.z() >= 0) {
|
||||
unit.modifier().fill(bottom, bottom.add(1, this.plateHeight, 1), this.platePallet.rnd());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(generateBorders) {
|
||||
if(this.generateBorders) {
|
||||
Runnable generateBorder = () -> unit.modifier().fill(bottom, bottom.add(1, DimensionType.VANILLA_MAX_Y, 1), Block.BARRIER);
|
||||
|
||||
if(bottom.z() <= length+1 && bottom.z() >= -1 && bottom.x() >= -1 && bottom.x() <= width+1) {
|
||||
if(bottom.x() == -1 || bottom.x() == width+1) {
|
||||
if(bottom.z() <= this.length + 1 && bottom.z() >= -1 && bottom.x() >= -1 && bottom.x() <= this.width + 1) {
|
||||
if(bottom.x() == -1 || bottom.x() == this.width + 1) {
|
||||
generateBorder.run();
|
||||
}
|
||||
if(bottom.z() == -1 || bottom.z() == length + 1) {
|
||||
if(bottom.z() == -1 || bottom.z() == this.length + 1) {
|
||||
generateBorder.run();
|
||||
}
|
||||
}
|
||||
@@ -81,34 +81,34 @@ public class SquarePlateTerrainGenerator extends PlateTerrainGenerator {
|
||||
|
||||
unit.modifier().setBlock(bottom, Block.GRASS_BLOCK);
|
||||
|
||||
synchronized (base) {
|
||||
double baseNoise = base.getNoise(bottom.x(), bottom.z());
|
||||
synchronized(this.base) {
|
||||
double baseNoise = this.base.getNoise(bottom.x(), bottom.z());
|
||||
double[] possibleHeights = {
|
||||
minTwo(NumberUtil.map(bottom.distance(new Pos(0, 0, 0)), 0, 400, -((double) this.width / 5), 200)) + baseNoise * 8,
|
||||
minTwo(NumberUtil.map(bottom.distance(new Pos(width, 0, 0)), 0, 400, -((double) this.width / 5), 200)) + baseNoise * 8,
|
||||
minTwo(NumberUtil.map(bottom.distance(new Pos(0, 0, length)), 0, 400, -((double) this.width / 5), 200)) + baseNoise * 8,
|
||||
minTwo(NumberUtil.map(bottom.distance(new Pos(width, 0, length)), 0, 400, -((double) this.width / 5), 200)) + baseNoise * 8
|
||||
minTwo(NumberUtil.map(bottom.distance(new Pos(this.width, 0, 0)), 0, 400, -((double) this.width / 5), 200)) + baseNoise * 8,
|
||||
minTwo(NumberUtil.map(bottom.distance(new Pos(0, 0, this.length)), 0, 400, -((double) this.width / 5), 200)) + baseNoise * 8,
|
||||
minTwo(NumberUtil.map(bottom.distance(new Pos(this.width, 0, this.length)), 0, 400, -((double) this.width / 5), 200)) + baseNoise * 8
|
||||
};
|
||||
|
||||
double currentHeight = Arrays.stream(possibleHeights).min().getAsDouble();
|
||||
|
||||
synchronized (batches) {
|
||||
double elementNoise = batches.getNoise(bottom.x(), bottom.z());
|
||||
synchronized(this.batches) {
|
||||
double elementNoise = this.batches.getNoise(bottom.x(), bottom.z());
|
||||
|
||||
unit.modifier().fill(
|
||||
bottom,
|
||||
bottom.add(1, 1, 1)
|
||||
.withY(currentHeight),
|
||||
elementNoise < 0.9 ? elementNoise > 0 ? Block.GRASS_BLOCK : Block.SOUL_SAND : Block.STONE
|
||||
bottom,
|
||||
bottom.add(1, 1, 1)
|
||||
.withY(currentHeight),
|
||||
elementNoise < 0.9 ? elementNoise > 0 ? Block.GRASS_BLOCK : Block.SOUL_SAND : Block.STONE
|
||||
);
|
||||
}
|
||||
|
||||
synchronized (peaks) {
|
||||
double peakNoise = peaks.getNoise(bottom.x(), bottom.z());
|
||||
synchronized(this.peaks) {
|
||||
double peakNoise = this.peaks.getNoise(bottom.x(), bottom.z());
|
||||
|
||||
if(peakNoise > 0.97 && bottom.distance(new Pos(0, 0, 0)) > (this.width + 20)) {
|
||||
|
||||
Point center = bottom.add(1, currentHeight-3, 1);
|
||||
Point center = bottom.add(1, currentHeight - 3, 1);
|
||||
unit.fork(setter -> new PeakRock(center, BlockPallet.STONE).generateStructure(setter));
|
||||
}
|
||||
}
|
||||
@@ -119,9 +119,4 @@ public class SquarePlateTerrainGenerator extends PlateTerrainGenerator {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static double minTwo(double input) {
|
||||
if(input < 2) return 2;
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user