Separate central island from others

This commit is contained in:
paulevsGitch 2021-03-18 04:49:18 +03:00
parent c4d290f949
commit 47ddc3a07c
5 changed files with 26 additions and 12 deletions

View file

@ -71,7 +71,7 @@ public class DataFixerUtil {
});
}
private static void addFix(String result, String... names) {
protected static void addFix(String result, String... names) {
for (String name: names) {
REPLACEMENT.put(name, result);
}

View file

@ -35,9 +35,9 @@ public class GeneratorOptions {
generateCentralIsland = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "generateCentralIsland", false);
endCityFailChance = Configs.GENERATOR_CONFIG.getInt("customGenerator", "endCityFailChance", 5);
generateObsidianPlatform = Configs.GENERATOR_CONFIG.getBooleanRoot("generateObsidianPlatform", true);
bigOptions = new LayerOptions("customGenerator.layers.bigIslands", Configs.GENERATOR_CONFIG, 300, 200, 70, 10);
mediumOptions = new LayerOptions("customGenerator.layers.mediumIslands", Configs.GENERATOR_CONFIG, 150, 100, 70, 20);
smallOptions = new LayerOptions("customGenerator.layers.smallIslands", Configs.GENERATOR_CONFIG, 60, 50, 70, 30);
bigOptions = new LayerOptions("customGenerator.layers.bigIslands", Configs.GENERATOR_CONFIG, 300, 200, 70, 10, false);
mediumOptions = new LayerOptions("customGenerator.layers.mediumIslands", Configs.GENERATOR_CONFIG, 150, 100, 70, 20, true);
smallOptions = new LayerOptions("customGenerator.layers.smallIslands", Configs.GENERATOR_CONFIG, 60, 50, 70, 30, false);
}
public static int getBiomeSizeLand() {

View file

@ -5,6 +5,7 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.minecraft.util.math.BlockPos;
@ -24,13 +25,11 @@ public class IslandLayer {
private final Map<BlockPos, SDF> islands = Maps.newHashMap();
private final OpenSimplexNoise density;
private final int seed;
private final boolean hasCentralIsland;
private int lastX = Integer.MIN_VALUE;
private int lastZ = Integer.MIN_VALUE;
private final LayerOptions options;
public IslandLayer(int seed, LayerOptions options, boolean hasCentralIsland) {
this.hasCentralIsland = hasCentralIsland;
public IslandLayer(int seed, LayerOptions options) {
this.density = new OpenSimplexNoise(seed);
this.options = options;
this.seed = seed;
@ -43,8 +42,10 @@ public class IslandLayer {
}
public void updatePositions(double x, double z) {
int ix = MHelper.floor(x / options.distance);
int iz = MHelper.floor(z / options.distance);
if (lastX != ix || lastZ != iz) {
lastX = ix;
lastZ = iz;
@ -64,7 +65,18 @@ public class IslandLayer {
}
}
}
if (hasCentralIsland && GeneratorOptions.hasCentralIsland() && ix < 2 && iz < 2 && ix > -2 && iz > -2) {
}
if (GeneratorOptions.hasCentralIsland() && ix < 4 && iz < 4 && ix > -4 && iz > -4) {
List<BlockPos> remove = Lists.newArrayList();
positions.forEach((pos) -> {
int d = pos.getX() * pos.getX() + pos.getZ() * pos.getZ();
if (d < 12544) {
remove.add(pos);
}
});
positions.removeAll(remove);
if (options.hasCentralIsland) {
positions.add(new BlockPos(0, 64, 0));
}
}

View file

@ -12,8 +12,9 @@ public class LayerOptions {
public final int minY;
public final int maxY;
public final long centerDist;
public final boolean hasCentralIsland;
public LayerOptions(String name, PathConfig config, float distance, float scale, int center, int heightVariation) {
public LayerOptions(String name, PathConfig config, float distance, float scale, int center, int heightVariation, boolean hasCentral) {
this.distance = clampDistance(config.getFloat(name, "distance[1-8192]", distance));
this.scale = clampScale(config.getFloat(name, "scale[0.1-1024]", scale));
this.center = clampCenter(config.getInt(name, "averageHeight[0-255]", center));
@ -22,6 +23,7 @@ public class LayerOptions {
this.minY = this.center - this.heightVariation;
this.maxY = this.center + this.heightVariation;
this.centerDist = MathHelper.floor(1000 / this.distance);
this.hasCentralIsland = config.getBoolean(name, "hasCentralIsland", hasCentral);
}
private float clampDistance(float value) {

View file

@ -25,9 +25,9 @@ public class TerrainGenerator {
public static void initNoise(long seed) {
Random random = new Random(seed);
largeIslands = new IslandLayer(random.nextInt(), GeneratorOptions.bigOptions, false);
mediumIslands = new IslandLayer(random.nextInt(), GeneratorOptions.mediumOptions, true);
smallIslands = new IslandLayer(random.nextInt(), GeneratorOptions.smallOptions, false);
largeIslands = new IslandLayer(random.nextInt(), GeneratorOptions.bigOptions);
mediumIslands = new IslandLayer(random.nextInt(), GeneratorOptions.mediumOptions);
smallIslands = new IslandLayer(random.nextInt(), GeneratorOptions.smallOptions);
noise1 = new OpenSimplexNoise(random.nextInt());
noise2 = new OpenSimplexNoise(random.nextInt());
}