Player spawn in Overworld fix

This commit is contained in:
paulevsGitch 2021-01-13 13:34:43 +03:00
parent e09d1d2235
commit 56591633ec
12 changed files with 370 additions and 41 deletions

View file

@ -70,7 +70,7 @@ public class BetterEndBiomeSource extends BiomeSource {
@Override
public Biome getBiomeForNoiseGen(int biomeX, int biomeY, int biomeZ) {
boolean hasVoid = !TerrainGenerator.useNewGenerator() || !TerrainGenerator.noRingVoid();
boolean hasVoid = !GeneratorOptions.useNewGenerator() || !GeneratorOptions.noRingVoid();
long i = (long) biomeX * (long) biomeX;
long j = (long) biomeZ * (long) biomeZ;
if (hasVoid && i + j <= 65536L) return this.centerBiome;
@ -80,7 +80,7 @@ public class BetterEndBiomeSource extends BiomeSource {
mapVoid.clearCache();
}
if (TerrainGenerator.useNewGenerator()) {
if (GeneratorOptions.useNewGenerator()) {
if (TerrainGenerator.isLand(biomeX, biomeZ)) {
return mapLand.getBiome(biomeX << 2, biomeZ << 2).getActualBiome();
}

View file

@ -11,6 +11,9 @@ public class GeneratorOptions {
private static boolean swapOverworldToEnd;
private static boolean changeChorusPlant;
private static boolean removeChorusFromVanillaBiomes;
private static boolean newGenerator;
private static boolean noRingVoid;
private static boolean generateCentralIsland;
public static void init() {
biomeSizeLand = Configs.GENERATOR_CONFIG.getInt("biomeMap", "biomeSizeLand", 256);
@ -21,6 +24,9 @@ public class GeneratorOptions {
swapOverworldToEnd = Configs.GENERATOR_CONFIG.getBooleanRoot("swapOverworldToEnd", false);
changeChorusPlant = Configs.GENERATOR_CONFIG.getBoolean("chorusPlant", "changeChorusPlant", true);
removeChorusFromVanillaBiomes = Configs.GENERATOR_CONFIG.getBoolean("chorusPlant", "removeChorusFromVanillaBiomes", true);
newGenerator = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "useNewGenerator", false);
noRingVoid = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "noRingVoid", false);
generateCentralIsland = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "generateCentralIsland", false);
}
public static int getBiomeSizeLand() {
@ -54,4 +60,16 @@ public class GeneratorOptions {
public static boolean removeChorusFromVanillaBiomes() {
return removeChorusFromVanillaBiomes;
}
public static boolean noRingVoid() {
return noRingVoid;
}
public static boolean useNewGenerator() {
return newGenerator;
}
public static boolean hasCentralIsland() {
return generateCentralIsland;
}
}

View file

@ -29,10 +29,11 @@ public class IslandLayer {
private final int minY;
private final int maxY;
private final long center;
private final boolean hasCentralIsland;
private int lastX = Integer.MIN_VALUE;
private int lastZ = Integer.MIN_VALUE;
public IslandLayer(int seed, double distance, float scale, int center, int heightVariation) {
public IslandLayer(int seed, double distance, float scale, int center, int heightVariation, boolean hasCentralIsland) {
this.distance = distance;
this.density = new OpenSimplexNoise(seed);
this.scale = scale;
@ -40,6 +41,7 @@ public class IslandLayer {
this.minY = center - heightVariation;
this.maxY = center + heightVariation;
this.center = MHelper.floor(1000 / distance);
this.hasCentralIsland = hasCentralIsland;
}
private int getSeed(int x, int z) {
@ -59,7 +61,7 @@ public class IslandLayer {
int px = pox + ix;
for (int poz = -1; poz < 2; poz++) {
int pz = poz + iz;
if (TerrainGenerator.noRingVoid() || (long) px + (long) pz > center) {
if (GeneratorOptions.noRingVoid() || (long) px + (long) pz > center) {
RANDOM.setSeed(getSeed(px, pz));
double posX = (px + RANDOM.nextFloat()) * distance;
double posY = MHelper.randRange(minY, maxY, RANDOM);
@ -70,6 +72,14 @@ public class IslandLayer {
}
}
}
if (hasCentralIsland && GeneratorOptions.hasCentralIsland() && ix == 0 && iz == 0) {
if (positions.size() > 4) {
positions.set(4, new BlockPos(0, 64, 0));
}
else {
positions.add(new BlockPos(0, 64, 0));
}
}
}
}

View file

@ -4,7 +4,6 @@ import java.util.Random;
import java.util.concurrent.locks.ReentrantLock;
import net.minecraft.util.math.MathHelper;
import ru.betterend.config.Configs;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.util.MHelper;
@ -19,35 +18,20 @@ public class TerrainGenerator {
private static IslandLayer smallIslands;
private static OpenSimplexNoise noise1;
private static OpenSimplexNoise noise2;
private static boolean newGenerator;
private static boolean noRingVoid;
public static void init() {
newGenerator = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "useNewGenerator", false);
noRingVoid = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "noRingVoid", false);
public static boolean canGenerate(int x, int z) {
return GeneratorOptions.noRingVoid() || (long) x + (long) z > CENTER;
}
public static void initNoise(long seed) {
Random random = new Random(seed);
largeIslands = new IslandLayer(random.nextInt(), 300, 200, 70, 10);
mediumIslands = new IslandLayer(random.nextInt(), 150, 100, 70, 20);
smallIslands = new IslandLayer(random.nextInt(), 60, 50, 70, 30);
largeIslands = new IslandLayer(random.nextInt(), 300, 200, 70, 10, false);
mediumIslands = new IslandLayer(random.nextInt(), 150, 100, 70, 20, true);
smallIslands = new IslandLayer(random.nextInt(), 60, 50, 70, 30, false);
noise1 = new OpenSimplexNoise(random.nextInt());
noise2 = new OpenSimplexNoise(random.nextInt());
}
public static boolean canGenerate(int x, int z) {
return noRingVoid || (long) x + (long) z > CENTER;
}
public static boolean noRingVoid() {
return noRingVoid;
}
public static boolean useNewGenerator() {
return newGenerator;
}
public static void fillTerrainDensity(double[] buffer, int x, int z) {
LOCKER.lock();
@ -128,8 +112,6 @@ public class TerrainGenerator {
public static int getHeight(int x, int z) {
LOCKER.lock();
//x >>= 3;
//z >>= 3;
double px = (double) x / 8.0;
double pz = (double) z / 8.0;