mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-22 16:18:32 +00:00
Clean up imports
This commit is contained in:
@@ -9,40 +9,44 @@ import org.bukkit.World;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.polydev.gaea.math.FastNoiseLite;
|
||||
import org.polydev.gaea.math.MathUtil;
|
||||
import org.polydev.gaea.world.carving.CarvingData;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Cavern {
|
||||
private final Node node;
|
||||
private final long seed;
|
||||
|
||||
public Cavern(World w) {
|
||||
this.node = new Node(w);
|
||||
this.seed = w.getSeed();
|
||||
}
|
||||
|
||||
public VoxelGeometry carveChunk(int chunkX, int chunkZ) {
|
||||
long seedC = MathUtil.getCarverChunkSeed(chunkX, chunkZ, seed);
|
||||
Random chunk = new Random(seedC);
|
||||
Vector org = node.getNodeLocation((chunkX << 4)+8, (chunkZ << 4)+8).clone().setY(chunk.nextInt(128));
|
||||
Vector org = node.getNodeLocation((chunkX << 4) + 8, (chunkZ << 4) + 8).clone().setY(chunk.nextInt(128));
|
||||
VoxelGeometry carve = VoxelGeometry.getBlank();
|
||||
|
||||
FastNoiseLite smpl = new FastNoiseLite((int) seedC);
|
||||
smpl.setFrequency(0.01f);
|
||||
smpl.setNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
|
||||
Bukkit.getLogger().info("Cavern: " + org.toString());
|
||||
carve.merge(new DeformedSphere(org.clone(), chunk.nextInt(4)+3, 0.75, smpl));
|
||||
carve.merge(new DeformedSphere(org.clone(), chunk.nextInt(4) + 3, 0.75, smpl));
|
||||
|
||||
Vector _00 = new Vector(org.getX()+16, new Random(MathUtil.getCarverChunkSeed(chunkX+1, chunkZ, seed)).nextInt(128), org.getZ());
|
||||
Vector _00 = new Vector(org.getX() + 16, new Random(MathUtil.getCarverChunkSeed(chunkX + 1, chunkZ, seed)).nextInt(128), org.getZ());
|
||||
|
||||
carve.merge(new Tube(org, _00, 4));
|
||||
return carve;
|
||||
}
|
||||
|
||||
public static class Node {
|
||||
private final long seed;
|
||||
private final GridSpawn spawn = new GridSpawn(16, 0);
|
||||
|
||||
public Node(World w) {
|
||||
this.seed = w.getSeed();
|
||||
}
|
||||
|
||||
public Vector getNodeLocation(int x, int z) {
|
||||
return spawn.getNearestSpawn(x, z, seed);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ public class SimplexCarver extends Carver {
|
||||
private final FastNoiseLite height;
|
||||
private final FastNoiseLite column;
|
||||
private final FastNoiseLite hasCaves;
|
||||
private final double root2inverse = 1D/Math.sqrt(2);
|
||||
private final double root2inverse = 1D / Math.sqrt(2);
|
||||
|
||||
public SimplexCarver(int minY, int maxY) {
|
||||
super(minY, maxY);
|
||||
noise = new FastNoiseLite(2403);
|
||||
@@ -53,19 +54,19 @@ public class SimplexCarver extends Carver {
|
||||
CarvingData c = new CarvingData(chunkX, chunkZ);
|
||||
int ox = chunkX << 4;
|
||||
int oz = chunkZ << 4;
|
||||
for(int x = ox; x < ox+16; x++) {
|
||||
for(int z = oz; z < oz+16; z++) {
|
||||
for(int x = ox; x < ox + 16; x++) {
|
||||
for(int z = oz; z < oz + 16; z++) {
|
||||
double heightNoise = height.getNoise(x, z);
|
||||
double mainNoise = noise.getNoise(x, z)*2;
|
||||
double columnNoise = Math.pow(Math.max(column.getNoise(x, z), 0)*2, 3);
|
||||
double hc = (acot(16*(hasCaves.getNoise(x, z)-0.2))/Math.PI)-0.1;
|
||||
double mainNoise = noise.getNoise(x, z) * 2;
|
||||
double columnNoise = Math.pow(Math.max(column.getNoise(x, z), 0) * 2, 3);
|
||||
double hc = (acot(16 * (hasCaves.getNoise(x, z) - 0.2)) / Math.PI) - 0.1;
|
||||
CarvingData.CarvingType type = CarvingData.CarvingType.BOTTOM;
|
||||
double simplex = (Math.pow(mainNoise + root2inverse, 3)/2 + columnNoise) * hc;
|
||||
double simplex = (Math.pow(mainNoise + root2inverse, 3) / 2 + columnNoise) * hc;
|
||||
for(int y = 0; y < 64; y++) {
|
||||
double finalNoise = (-0.05*Math.abs(y-(heightNoise*16 + 24))+1 - simplex) * hc;
|
||||
double finalNoise = (- 0.05 * Math.abs(y - (heightNoise * 16 + 24)) + 1 - simplex) * hc;
|
||||
if(finalNoise > 0.5) {
|
||||
c.carve(x-ox, y, z-oz, type);
|
||||
double finalNoiseUp = (-0.05*Math.abs((y+1)-(heightNoise*16 + 24))+1 - simplex) * hc;
|
||||
c.carve(x - ox, y, z - oz, type);
|
||||
double finalNoiseUp = (- 0.05 * Math.abs((y + 1) - (heightNoise * 16 + 24)) + 1 - simplex) * hc;
|
||||
if(finalNoiseUp > 0.5) {
|
||||
type = CarvingData.CarvingType.CENTER;
|
||||
} else type = CarvingData.CarvingType.TOP;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.dfsek.terra.carving;
|
||||
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import org.polydev.gaea.math.Range;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.polydev.gaea.generation.GenerationPhase;
|
||||
import org.polydev.gaea.math.Range;
|
||||
import org.polydev.gaea.world.carving.Carver;
|
||||
import org.polydev.gaea.world.carving.Worm;
|
||||
|
||||
@@ -36,37 +36,38 @@ public class UserDefinedCarver extends Carver {
|
||||
|
||||
@Override
|
||||
public Worm getWorm(long l, Vector vector) {
|
||||
Random r = new Random(l+hash);
|
||||
return new UserDefinedWorm((int) (length.get(r)/2), r, vector, radius.getMax(), topCut, bottomCut);
|
||||
Random r = new Random(l + hash);
|
||||
return new UserDefinedWorm((int) (length.get(r) / 2), r, vector, radius.getMax(), topCut, bottomCut);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChunkCarved(World w, int chunkX, int chunkZ, Random random) {
|
||||
ConfigPack c = TerraWorld.getWorld(w).getConfig();
|
||||
return new Random(random.nextLong()+hash).nextInt(100) < c.getBiome((UserDefinedBiome) TerraWorld.getWorld(w).getGrid().getBiome(chunkX << 4, chunkZ << 4, GenerationPhase.POPULATE)).getCarverChance(this);
|
||||
return new Random(random.nextLong() + hash).nextInt(100) < c.getBiome((UserDefinedBiome) TerraWorld.getWorld(w).getGrid().getBiome(chunkX << 4, chunkZ << 4, GenerationPhase.POPULATE)).getCarverChance(this);
|
||||
}
|
||||
|
||||
private class UserDefinedWorm extends Worm {
|
||||
private final Vector direction;
|
||||
private final int maxRad;
|
||||
private double runningRadius;
|
||||
|
||||
public UserDefinedWorm(int length, Random r, Vector origin, int maxRad, int topCut, int bottomCut) {
|
||||
super(length, r, origin);
|
||||
super.setTopCut(topCut);
|
||||
super.setBottomCut(bottomCut);
|
||||
runningRadius = radius.get(r);
|
||||
this.maxRad = maxRad;
|
||||
direction = new Vector((r.nextDouble()-0.5D)*start[0], (r.nextDouble()-0.5D)*start[1], (r.nextDouble()-0.5D)*start[2]).normalize().multiply(2);
|
||||
direction = new Vector((r.nextDouble() - 0.5D) * start[0], (r.nextDouble() - 0.5D) * start[1], (r.nextDouble() - 0.5D) * start[2]).normalize().multiply(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void step() {
|
||||
setRadius(new int[] {(int) (runningRadius*radiusMultiplier[0]), (int) (runningRadius*radiusMultiplier[1]), (int) (runningRadius*radiusMultiplier[2])});
|
||||
runningRadius += (getRandom().nextDouble()-0.5)*mutate[3];
|
||||
setRadius(new int[] {(int) (runningRadius * radiusMultiplier[0]), (int) (runningRadius * radiusMultiplier[1]), (int) (runningRadius * radiusMultiplier[2])});
|
||||
runningRadius += (getRandom().nextDouble() - 0.5) * mutate[3];
|
||||
runningRadius = Math.max(Math.min(runningRadius, maxRad), 1);
|
||||
direction.rotateAroundX(Math.toRadians(getRandom().nextDouble()*mutate[0]*2));
|
||||
direction.rotateAroundY(Math.toRadians(getRandom().nextDouble()*mutate[1]*2));
|
||||
direction.rotateAroundZ(Math.toRadians(getRandom().nextDouble()*mutate[2]*2));
|
||||
direction.rotateAroundX(Math.toRadians(getRandom().nextDouble() * mutate[0] * 2));
|
||||
direction.rotateAroundY(Math.toRadians(getRandom().nextDouble() * mutate[1] * 2));
|
||||
direction.rotateAroundZ(Math.toRadians(getRandom().nextDouble() * mutate[2] * 2));
|
||||
getRunning().add(direction);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user