Terrain generator fixes
This commit is contained in:
parent
ce88ec23f7
commit
4256e954ca
7 changed files with 66 additions and 249 deletions
|
@ -1,26 +0,0 @@
|
||||||
package ru.betterend.mixin.common;
|
|
||||||
|
|
||||||
import net.minecraft.core.Registry;
|
|
||||||
import net.minecraft.world.level.biome.BiomeSource;
|
|
||||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
|
||||||
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
|
|
||||||
import net.minecraft.world.level.levelgen.StructureSettings;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
import ru.betterend.world.generator.TerrainGenerator;
|
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
@Mixin(NoiseBasedChunkGenerator.class)
|
|
||||||
public abstract class NoiseBasedChunkGeneratorMixin extends ChunkGenerator {
|
|
||||||
public NoiseBasedChunkGeneratorMixin(BiomeSource populationSource, BiomeSource biomeSource, StructureSettings structuresConfig, long worldSeed) {
|
|
||||||
super(populationSource, biomeSource, structuresConfig, worldSeed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "<init>(Lnet/minecraft/core/Registry;Lnet/minecraft/world/level/biome/BiomeSource;Lnet/minecraft/world/level/biome/BiomeSource;JLjava/util/function/Supplier;)V", at = @At("TAIL"))
|
|
||||||
private void be_onInit(Registry registry, BiomeSource biomeSource, BiomeSource biomeSource2, long seed, Supplier supplier, CallbackInfo ci) {
|
|
||||||
TerrainGenerator.initNoise(seed);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -14,15 +14,15 @@ import ru.betterend.interfaces.TargetChecker;
|
||||||
|
|
||||||
@Mixin(NoiseChunk.class)
|
@Mixin(NoiseChunk.class)
|
||||||
public class NoiseChunkMixin implements TargetChecker {
|
public class NoiseChunkMixin implements TargetChecker {
|
||||||
private boolean bnv_isNetherGenerator;
|
private boolean be_isEndGenerator;
|
||||||
|
|
||||||
@Inject(method = "<init>*", at = @At("TAIL"))
|
@Inject(method = "<init>*", at = @At("TAIL"))
|
||||||
private void bnv_onNoiseChunkInit(int i, int j, int k, NoiseSampler noiseSampler, int l, int m, NoiseFiller noiseFiller, NoiseGeneratorSettings noiseGeneratorSettings, Aquifer.FluidPicker fluidPicker, Blender blender, CallbackInfo info) {
|
private void be_onNoiseChunkInit(int i, int j, int k, NoiseSampler noiseSampler, int l, int m, NoiseFiller noiseFiller, NoiseGeneratorSettings noiseGeneratorSettings, Aquifer.FluidPicker fluidPicker, Blender blender, CallbackInfo info) {
|
||||||
bnv_isNetherGenerator = noiseGeneratorSettings.stable(NoiseGeneratorSettings.END);
|
be_isEndGenerator = noiseGeneratorSettings.stable(NoiseGeneratorSettings.END);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isTarget() {
|
public boolean isTarget() {
|
||||||
return bnv_isNetherGenerator;
|
return be_isEndGenerator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import ru.betterend.interfaces.TargetChecker;
|
import ru.betterend.interfaces.TargetChecker;
|
||||||
|
import ru.betterend.world.generator.TerrainGenerator;
|
||||||
|
|
||||||
@Mixin(NoiseChunk.NoiseInterpolator.class)
|
@Mixin(NoiseChunk.NoiseInterpolator.class)
|
||||||
public class NoiseInterpolatorMixin {
|
public class NoiseInterpolatorMixin {
|
||||||
|
@ -29,26 +30,16 @@ public class NoiseInterpolatorMixin {
|
||||||
|
|
||||||
final int sizeY = noiseSettings.getCellHeight();
|
final int sizeY = noiseSettings.getCellHeight();
|
||||||
final int sizeXZ = noiseSettings.getCellWidth();
|
final int sizeXZ = noiseSettings.getCellWidth();
|
||||||
final int cellsY = accessor.bnv_getCellCountY() + 1;
|
//final int cellsY = accessor.bnv_getCellCountY() + 1;
|
||||||
final int cellsXZ = accessor.bnv_getCellCountXZ() + 1;
|
final int cellsXZ = accessor.bnv_getCellCountXZ() + 1;
|
||||||
final int firstCellZ = accessor.bnv_getFirstCellZ();
|
final int firstCellZ = accessor.bnv_getFirstCellZ();
|
||||||
final int cellNoiseMinY = accessor.bnv_getCellNoiseMinY();
|
//final int cellNoiseMinY = accessor.bnv_getCellNoiseMinY();
|
||||||
|
|
||||||
x *= sizeXZ;
|
x *= sizeXZ;
|
||||||
|
|
||||||
for (int cellXZ = 0; cellXZ < cellsXZ; ++cellXZ) {
|
for (int cellXZ = 0; cellXZ < cellsXZ; ++cellXZ) {
|
||||||
int z = (firstCellZ + cellXZ) * sizeXZ;
|
int z = (firstCellZ + cellXZ) * sizeXZ;
|
||||||
for (int cellY = 0; cellY < cellsY; ++cellY) {
|
TerrainGenerator.fillTerrainDensity(data[cellXZ], x, z, sizeXZ, sizeY);
|
||||||
int y = (cellY + cellNoiseMinY) * sizeY;
|
|
||||||
data[cellXZ][cellY] = be_calculateNoise(x, y, z);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private float be_calculateNoise(int x, int y, int z) {
|
|
||||||
float gradient = (64 - y) * 0.1F;
|
|
||||||
float sinX = (float) Math.sin(x * 0.1);
|
|
||||||
float sinZ = (float) Math.sin(z * 0.1);
|
|
||||||
return gradient + sinX + sinZ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,18 @@ package ru.betterend.mixin.common;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.server.level.progress.ChunkProgressListener;
|
||||||
import net.minecraft.util.profiling.ProfilerFiller;
|
import net.minecraft.util.profiling.ProfilerFiller;
|
||||||
|
import net.minecraft.world.level.CustomSpawner;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||||
import net.minecraft.world.level.dimension.DimensionType;
|
import net.minecraft.world.level.dimension.DimensionType;
|
||||||
|
import net.minecraft.world.level.storage.LevelStorageSource.LevelStorageAccess;
|
||||||
|
import net.minecraft.world.level.storage.ServerLevelData;
|
||||||
import net.minecraft.world.level.storage.WritableLevelData;
|
import net.minecraft.world.level.storage.WritableLevelData;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
@ -20,7 +26,10 @@ import ru.bclib.api.biomes.BiomeAPI;
|
||||||
import ru.betterend.BetterEnd;
|
import ru.betterend.BetterEnd;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
import ru.betterend.world.generator.GeneratorOptions;
|
import ru.betterend.world.generator.GeneratorOptions;
|
||||||
|
import ru.betterend.world.generator.TerrainGenerator;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@Mixin(ServerLevel.class)
|
@Mixin(ServerLevel.class)
|
||||||
|
@ -42,6 +51,14 @@ public abstract class ServerLevelMixin extends Level {
|
||||||
// //EndBiomes.onWorldLoad(world.getSeed(), world.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY));
|
// //EndBiomes.onWorldLoad(world.getSeed(), world.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@Inject(method = "<init>*", at = @At("TAIL"))
|
||||||
|
private void be_onServerWorldInit(MinecraftServer minecraftServer, Executor executor, LevelStorageAccess levelStorageAccess, ServerLevelData serverLevelData, ResourceKey<Level> resourceKey, DimensionType dimensionType, ChunkProgressListener chunkProgressListener, ChunkGenerator chunkGenerator, boolean bl, long seed, List<CustomSpawner> list, boolean bl2, CallbackInfo ci) {
|
||||||
|
ServerLevel level = ServerLevel.class.cast(this);
|
||||||
|
if (level.dimension() == Level.END) {
|
||||||
|
TerrainGenerator.initNoise(seed, chunkGenerator.getBiomeSource(), chunkGenerator.climateSampler());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(method = "getSharedSpawnPos", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "getSharedSpawnPos", at = @At("HEAD"), cancellable = true)
|
||||||
private void be_getSharedSpawnPos(CallbackInfoReturnable<BlockPos> info) {
|
private void be_getSharedSpawnPos(CallbackInfoReturnable<BlockPos> info) {
|
||||||
if (GeneratorOptions.changeSpawn()) {
|
if (GeneratorOptions.changeSpawn()) {
|
||||||
|
|
|
@ -1,67 +0,0 @@
|
||||||
package ru.betterend.world.generator;
|
|
||||||
|
|
||||||
import net.minecraft.util.Mth;
|
|
||||||
import net.minecraft.world.level.biome.BiomeSource;
|
|
||||||
import net.minecraft.world.level.levelgen.NoiseChunk.NoiseFiller;
|
|
||||||
|
|
||||||
public class EndNoiseFiller implements NoiseFiller {
|
|
||||||
public static final EndNoiseFiller INSTANCE = new EndNoiseFiller();
|
|
||||||
private double[][][] noiseColumns = new double[3][3][33];
|
|
||||||
private BiomeSource biomeSource;
|
|
||||||
private int chunkX;
|
|
||||||
private int chunkZ;
|
|
||||||
|
|
||||||
private EndNoiseFiller() {}
|
|
||||||
|
|
||||||
public void setBiomeSource(BiomeSource biomeSource) {
|
|
||||||
this.biomeSource = biomeSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double calculateNoise(int x, int y, int z) {
|
|
||||||
if (y < 0 || y > 127) {
|
|
||||||
return -10;
|
|
||||||
}
|
|
||||||
|
|
||||||
int cx = x >> 4;
|
|
||||||
int cz = z >> 4;
|
|
||||||
if (chunkX != cx || chunkZ != cz) {
|
|
||||||
chunkX = cx;
|
|
||||||
chunkZ = cz;
|
|
||||||
int px = cx << 1;
|
|
||||||
int pz = cz << 1;
|
|
||||||
for (byte i = 0; i < 3; i++) {
|
|
||||||
for (byte j = 0; j < 3; j++) {
|
|
||||||
TerrainGenerator.fillTerrainDensity(noiseColumns[i][j], px + i, pz + j, biomeSource);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
byte ix = (byte) ((x & 15) >> 3);
|
|
||||||
byte iy = (byte) (y >> 2);
|
|
||||||
byte iz = (byte) ((z & 15) >> 3);
|
|
||||||
float dx = (x & 7) / 8F;
|
|
||||||
float dy = (y & 3) / 4F;
|
|
||||||
float dz = (z & 7) / 8F;
|
|
||||||
|
|
||||||
float a = (float) noiseColumns[ix][iz][iy];
|
|
||||||
float b = (float) noiseColumns[ix + 1][iz][iy];
|
|
||||||
float c = (float) noiseColumns[ix][iz][iy + 1];
|
|
||||||
float d = (float) noiseColumns[ix + 1][iz][iy + 1];
|
|
||||||
|
|
||||||
float e = (float) noiseColumns[ix][iz + 1][iy];
|
|
||||||
float f = (float) noiseColumns[ix + 1][iz + 1][iy];
|
|
||||||
float g = (float) noiseColumns[ix][iz + 1][iy + 1];
|
|
||||||
float h = (float) noiseColumns[ix + 1][iz + 1][iy + 1];
|
|
||||||
|
|
||||||
a = Mth.lerp(dx, a, b);
|
|
||||||
b = Mth.lerp(dx, c, d);
|
|
||||||
c = Mth.lerp(dx, e, f);
|
|
||||||
d = Mth.lerp(dx, g, h);
|
|
||||||
|
|
||||||
a = Mth.lerp(dy, a, b);
|
|
||||||
b = Mth.lerp(dy, c, d);
|
|
||||||
|
|
||||||
return Mth.lerp(dz, a, b);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.level.biome.BiomeSource;
|
import net.minecraft.world.level.biome.BiomeSource;
|
||||||
|
import net.minecraft.world.level.biome.Climate.Sampler;
|
||||||
import ru.bclib.api.biomes.BiomeAPI;
|
import ru.bclib.api.biomes.BiomeAPI;
|
||||||
import ru.bclib.util.MHelper;
|
import ru.bclib.util.MHelper;
|
||||||
import ru.bclib.world.biomes.BCLBiome;
|
import ru.bclib.world.biomes.BCLBiome;
|
||||||
|
@ -29,8 +30,10 @@ public class TerrainGenerator {
|
||||||
private static IslandLayer smallIslands;
|
private static IslandLayer smallIslands;
|
||||||
private static OpenSimplexNoise noise1;
|
private static OpenSimplexNoise noise1;
|
||||||
private static OpenSimplexNoise noise2;
|
private static OpenSimplexNoise noise2;
|
||||||
|
private static BiomeSource biomeSource;
|
||||||
|
private static Sampler sampler;
|
||||||
|
|
||||||
public static void initNoise(long seed) {
|
public static void initNoise(long seed, BiomeSource biomeSource, Sampler sampler) {
|
||||||
Random random = new Random(seed);
|
Random random = new Random(seed);
|
||||||
largeIslands = new IslandLayer(random.nextInt(), GeneratorOptions.bigOptions);
|
largeIslands = new IslandLayer(random.nextInt(), GeneratorOptions.bigOptions);
|
||||||
mediumIslands = new IslandLayer(random.nextInt(), GeneratorOptions.mediumOptions);
|
mediumIslands = new IslandLayer(random.nextInt(), GeneratorOptions.mediumOptions);
|
||||||
|
@ -38,15 +41,19 @@ public class TerrainGenerator {
|
||||||
noise1 = new OpenSimplexNoise(random.nextInt());
|
noise1 = new OpenSimplexNoise(random.nextInt());
|
||||||
noise2 = new OpenSimplexNoise(random.nextInt());
|
noise2 = new OpenSimplexNoise(random.nextInt());
|
||||||
TERRAIN_BOOL_CACHE_MAP.clear();
|
TERRAIN_BOOL_CACHE_MAP.clear();
|
||||||
|
TerrainGenerator.biomeSource = biomeSource;
|
||||||
|
TerrainGenerator.sampler = sampler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void fillTerrainDensity(double[] buffer, int x, int z, BiomeSource biomeSource) {
|
public static void fillTerrainDensity(double[] buffer, int posX, int posZ, int scaleXZ, int scaleY) {
|
||||||
LOCKER.lock();
|
LOCKER.lock();
|
||||||
|
|
||||||
largeIslands.clearCache();
|
largeIslands.clearCache();
|
||||||
mediumIslands.clearCache();
|
mediumIslands.clearCache();
|
||||||
smallIslands.clearCache();
|
smallIslands.clearCache();
|
||||||
|
|
||||||
|
int x = Mth.floor(posX / scaleXZ);
|
||||||
|
int z = Mth.floor(posZ / scaleXZ);
|
||||||
double distortion1 = noise1.eval(x * 0.1, z * 0.1) * 20 + noise2.eval(
|
double distortion1 = noise1.eval(x * 0.1, z * 0.1) * 20 + noise2.eval(
|
||||||
x * 0.2,
|
x * 0.2,
|
||||||
z * 0.2
|
z * 0.2
|
||||||
|
@ -55,17 +62,17 @@ public class TerrainGenerator {
|
||||||
x * 0.2,
|
x * 0.2,
|
||||||
z * 0.2
|
z * 0.2
|
||||||
) * 10 + noise2.eval(x * 0.4, z * 0.4) * 5;
|
) * 10 + noise2.eval(x * 0.4, z * 0.4) * 5;
|
||||||
double px = (double) x * SCALE_XZ + distortion1;
|
double px = (double) x * scaleXZ + distortion1;
|
||||||
double pz = (double) z * SCALE_XZ + distortion2;
|
double pz = (double) z * scaleXZ + distortion2;
|
||||||
|
|
||||||
largeIslands.updatePositions(px, pz);
|
largeIslands.updatePositions(px, pz);
|
||||||
mediumIslands.updatePositions(px, pz);
|
mediumIslands.updatePositions(px, pz);
|
||||||
smallIslands.updatePositions(px, pz);
|
smallIslands.updatePositions(px, pz);
|
||||||
|
|
||||||
float height = getAverageDepth(biomeSource, x << 1, z << 1) * 0.5F;
|
float height = getAverageDepth(x << 1, z << 1) * 0.5F;
|
||||||
|
|
||||||
for (int y = 0; y < buffer.length; y++) {
|
for (int y = 0; y < buffer.length; y++) {
|
||||||
double py = (double) y * SCALE_Y;
|
double py = (double) y * scaleY;
|
||||||
float dist = largeIslands.getDensity(px, py, pz, height);
|
float dist = largeIslands.getDensity(px, py, pz, height);
|
||||||
dist = dist > 1 ? dist : MHelper.max(dist, mediumIslands.getDensity(px, py, pz, height));
|
dist = dist > 1 ? dist : MHelper.max(dist, mediumIslands.getDensity(px, py, pz, height));
|
||||||
dist = dist > 1 ? dist : MHelper.max(dist, smallIslands.getDensity(px, py, pz, height));
|
dist = dist > 1 ? dist : MHelper.max(dist, smallIslands.getDensity(px, py, pz, height));
|
||||||
|
@ -83,49 +90,11 @@ public class TerrainGenerator {
|
||||||
LOCKER.unlock();
|
LOCKER.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float getTerrainDensity(int x, int y, int z, BiomeSource biomeSource) {
|
private static float getAverageDepth(int x, int z) {
|
||||||
LOCKER.lock();
|
if (biomeSource == null) {
|
||||||
|
return 0;
|
||||||
largeIslands.clearCache();
|
|
||||||
mediumIslands.clearCache();
|
|
||||||
smallIslands.clearCache();
|
|
||||||
|
|
||||||
double distortion1 = noise1.eval(x * 0.1, z * 0.1) * 20 + noise2.eval(
|
|
||||||
x * 0.2,
|
|
||||||
z * 0.2
|
|
||||||
) * 10 + noise1.eval(x * 0.4, z * 0.4) * 5;
|
|
||||||
double distortion2 = noise2.eval(x * 0.1, z * 0.1) * 20 + noise1.eval(
|
|
||||||
x * 0.2,
|
|
||||||
z * 0.2
|
|
||||||
) * 10 + noise2.eval(x * 0.4, z * 0.4) * 5;
|
|
||||||
double px = (double) x * SCALE_XZ + distortion1;
|
|
||||||
double pz = (double) z * SCALE_XZ + distortion2;
|
|
||||||
|
|
||||||
largeIslands.updatePositions(px, pz);
|
|
||||||
mediumIslands.updatePositions(px, pz);
|
|
||||||
smallIslands.updatePositions(px, pz);
|
|
||||||
|
|
||||||
float height = getAverageDepth(biomeSource, x << 1, z << 1) * 0.5F;
|
|
||||||
|
|
||||||
double py = (double) y * SCALE_Y;
|
|
||||||
float dist = largeIslands.getDensity(px, py, pz, height);
|
|
||||||
dist = dist > 1 ? dist : MHelper.max(dist, mediumIslands.getDensity(px, py, pz, height));
|
|
||||||
dist = dist > 1 ? dist : MHelper.max(dist, smallIslands.getDensity(px, py, pz, height));
|
|
||||||
if (dist > -0.5F) {
|
|
||||||
dist += noise1.eval(px * 0.01, py * 0.01, pz * 0.01) * 0.02 + 0.02;
|
|
||||||
dist += noise2.eval(px * 0.05, py * 0.05, pz * 0.05) * 0.01 + 0.01;
|
|
||||||
dist += noise1.eval(px * 0.1, py * 0.1, pz * 0.1) * 0.005 + 0.005;
|
|
||||||
}
|
}
|
||||||
if (py > 100) {
|
if (getBiome(biomeSource, x, z).getTerrainHeight() < 0.1F) {
|
||||||
dist = (float) Mth.lerp((py - 100) / 27F, dist, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
LOCKER.unlock();
|
|
||||||
return dist;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static float getAverageDepth(BiomeSource biomeSource, int x, int z) {
|
|
||||||
/*if (getBiome(biomeSource, x, z).getTerrainHeight() < 0.1F) {
|
|
||||||
return 0F;
|
return 0F;
|
||||||
}
|
}
|
||||||
float depth = 0F;
|
float depth = 0F;
|
||||||
|
@ -134,22 +103,35 @@ public class TerrainGenerator {
|
||||||
int pz = z + OFFS[i].y;
|
int pz = z + OFFS[i].y;
|
||||||
depth += getBiome(biomeSource, px, pz).getTerrainHeight() * COEF[i];
|
depth += getBiome(biomeSource, px, pz).getTerrainHeight() * COEF[i];
|
||||||
}
|
}
|
||||||
return depth;*/
|
return depth;
|
||||||
return 0F;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BCLBiome getBiome(BiomeSource biomeSource, int x, int z) {
|
private static BCLBiome getBiome(BiomeSource biomeSource, int x, int z) {
|
||||||
// TODO replace null sampler
|
return BiomeAPI.getBiome(biomeSource.getNoiseBiome(x, 0, z, sampler));
|
||||||
return BiomeAPI.getBiome(biomeSource.getNoiseBiome(x, 0, z, null));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static {
|
||||||
* Check if this is land
|
float sum = 0;
|
||||||
*
|
List<Float> coef = Lists.newArrayList();
|
||||||
* @param x - biome pos x
|
List<Point> pos = Lists.newArrayList();
|
||||||
* @param z - biome pos z
|
for (int x = -3; x <= 3; x++) {
|
||||||
*/
|
for (int z = -3; z <= 3; z++) {
|
||||||
public static boolean isLand(int x, int z) {
|
float dist = MHelper.length(x, z) / 3F;
|
||||||
|
if (dist <= 1) {
|
||||||
|
sum += dist;
|
||||||
|
coef.add(dist);
|
||||||
|
pos.add(new Point(x, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
OFFS = pos.toArray(new Point[] {});
|
||||||
|
COEF = new float[coef.size()];
|
||||||
|
for (int i = 0; i < COEF.length; i++) {
|
||||||
|
COEF[i] = coef.get(i) / sum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Boolean isLand(int x, int z) {
|
||||||
int sectionX = TerrainBoolCache.scaleCoordinate(x);
|
int sectionX = TerrainBoolCache.scaleCoordinate(x);
|
||||||
int sectionZ = TerrainBoolCache.scaleCoordinate(z);
|
int sectionZ = TerrainBoolCache.scaleCoordinate(z);
|
||||||
|
|
||||||
|
@ -210,83 +192,4 @@ public class TerrainGenerator {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get something like height
|
|
||||||
*
|
|
||||||
* @param x - block pos x
|
|
||||||
* @param z - block pos z
|
|
||||||
*/
|
|
||||||
public static int getHeight(int x, int z, BiomeSource biomeSource) {
|
|
||||||
int posX = (x >> 3) << 3;
|
|
||||||
int posZ = (z >> 3) << 3;
|
|
||||||
float dx = (x - posX) / 8.0F;
|
|
||||||
float dz = (z - posZ) / 8.0F;
|
|
||||||
double[][][] buffer = new double[2][2][32];
|
|
||||||
|
|
||||||
LOCKER.lock();
|
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
int ix = i & 1;
|
|
||||||
int iz = i >> 1;
|
|
||||||
int px = ((ix << 3) + posX) >> 3;
|
|
||||||
int pz = ((iz << 3) + posZ) >> 3;
|
|
||||||
fillTerrainDensity(buffer[ix][iz], px, pz, biomeSource);
|
|
||||||
}
|
|
||||||
LOCKER.unlock();
|
|
||||||
|
|
||||||
for (int j = 30; j >= 0; j--) {
|
|
||||||
float a = (float) buffer[0][0][j];
|
|
||||||
float b = (float) buffer[1][0][j];
|
|
||||||
float c = (float) buffer[0][1][j];
|
|
||||||
float d = (float) buffer[1][1][j];
|
|
||||||
|
|
||||||
float e = (float) buffer[0][0][j + 1];
|
|
||||||
float f = (float) buffer[1][0][j + 1];
|
|
||||||
float g = (float) buffer[0][1][j + 1];
|
|
||||||
float h = (float) buffer[1][1][j + 1];
|
|
||||||
|
|
||||||
if (a < 0 && b < 0 && c < 0 && d < 0 && e < 0 && f < 0 && g < 0 && h < 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
a = Mth.lerp(dx, a, b);
|
|
||||||
b = Mth.lerp(dx, c, d);
|
|
||||||
c = Mth.lerp(dx, e, f);
|
|
||||||
d = Mth.lerp(dx, g, h);
|
|
||||||
|
|
||||||
a = Mth.lerp(dz, a, b);
|
|
||||||
b = Mth.lerp(dz, c, d);
|
|
||||||
|
|
||||||
for (int n = 7; n >= 0; n--) {
|
|
||||||
float dy = n / 8.0F;
|
|
||||||
float dens = Mth.lerp(dy, a, b);
|
|
||||||
if (dens > 0) {
|
|
||||||
return (j << 3 | n) + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return -256;
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
|
||||||
float sum = 0;
|
|
||||||
List<Float> coef = Lists.newArrayList();
|
|
||||||
List<Point> pos = Lists.newArrayList();
|
|
||||||
for (int x = -3; x <= 3; x++) {
|
|
||||||
for (int z = -3; z <= 3; z++) {
|
|
||||||
float dist = MHelper.length(x, z) / 3F;
|
|
||||||
if (dist <= 1) {
|
|
||||||
sum += dist;
|
|
||||||
coef.add(dist);
|
|
||||||
pos.add(new Point(x, z));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
OFFS = pos.toArray(new Point[] {});
|
|
||||||
COEF = new float[coef.size()];
|
|
||||||
for (int i = 0; i < COEF.length; i++) {
|
|
||||||
COEF[i] = coef.get(i) / sum;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
"package": "ru.betterend.mixin.common",
|
"package": "ru.betterend.mixin.common",
|
||||||
"compatibilityLevel": "JAVA_16",
|
"compatibilityLevel": "JAVA_16",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"NoiseBasedChunkGeneratorMixin",
|
|
||||||
"ChorusPlantFeatureMixin",
|
"ChorusPlantFeatureMixin",
|
||||||
"PlayerAdvancementsMixin",
|
"PlayerAdvancementsMixin",
|
||||||
"ChorusFlowerBlockMixin",
|
"ChorusFlowerBlockMixin",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue