mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-18 10:32:30 +00:00
Make caves not suck anymore
This commit is contained in:
parent
548cd8a30a
commit
e9e9417410
@ -21,6 +21,9 @@ public class UserDefinedCarver extends Carver {
|
||||
private final int hash;
|
||||
private final int topCut;
|
||||
private final int bottomCut;
|
||||
private double step = 2;
|
||||
private Range recalc = new Range(8, 10);
|
||||
private double recalcMagnitude = 3;
|
||||
|
||||
public UserDefinedCarver(Range height, Range radius, Range length, double[] start, double[] mutate, double[] radiusMultiplier, int hash, int topCut, int bottomCut) {
|
||||
super(height.getMin(), height.getMax());
|
||||
@ -40,6 +43,18 @@ public class UserDefinedCarver extends Carver {
|
||||
return new UserDefinedWorm(length.get(r) / 2, r, vector, radius.getMax(), topCut, bottomCut);
|
||||
}
|
||||
|
||||
public void setStep(double step) {
|
||||
this.step = step;
|
||||
}
|
||||
|
||||
public void setRecalc(Range recalc) {
|
||||
this.recalc = recalc;
|
||||
}
|
||||
|
||||
public void setRecalcMagnitude(double recalcMagnitude) {
|
||||
this.recalcMagnitude = recalcMagnitude;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChunkCarved(World w, int chunkX, int chunkZ, Random random) {
|
||||
ConfigPack c = TerraWorld.getWorld(w).getConfig();
|
||||
@ -50,6 +65,9 @@ public class UserDefinedCarver extends Carver {
|
||||
private final Vector direction;
|
||||
private final int maxRad;
|
||||
private double runningRadius;
|
||||
private int steps;
|
||||
private int nextDirection = 0;
|
||||
private double[] currentRotation = new double[3];
|
||||
|
||||
public UserDefinedWorm(int length, Random r, Vector origin, int maxRad, int topCut, int bottomCut) {
|
||||
super(length, r, origin);
|
||||
@ -57,17 +75,27 @@ public class UserDefinedCarver extends Carver {
|
||||
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(step);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void step() {
|
||||
if(steps == nextDirection) {
|
||||
direction.rotateAroundX(Math.toRadians((getRandom().nextGaussian()) * mutate[0] * recalcMagnitude));
|
||||
direction.rotateAroundY(Math.toRadians((getRandom().nextGaussian()) * mutate[1] * recalcMagnitude));
|
||||
direction.rotateAroundZ(Math.toRadians((getRandom().nextGaussian()) * mutate[2] * recalcMagnitude));
|
||||
currentRotation = new double[] {(getRandom().nextGaussian()) * mutate[0],
|
||||
(getRandom().nextGaussian()) * mutate[1],
|
||||
(getRandom().nextGaussian()) * mutate[2]};
|
||||
nextDirection += recalc.get(getRandom());
|
||||
}
|
||||
steps++;
|
||||
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(currentRotation[0] * mutate[0]));
|
||||
direction.rotateAroundY(Math.toRadians(currentRotation[1] * mutate[1]));
|
||||
direction.rotateAroundZ(Math.toRadians(currentRotation[2] * mutate[2]));
|
||||
getRunning().add(direction);
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ public class CarverConfig extends TerraConfig {
|
||||
private final boolean replaceIsBlacklistTop;
|
||||
private final boolean replaceIsBlacklistBottom;
|
||||
private final boolean updateOcean;
|
||||
private final Range recalc;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public CarverConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
||||
@ -69,6 +70,9 @@ public class CarverConfig extends TerraConfig {
|
||||
|
||||
updateOcean = getBoolean("update-liquids", false);
|
||||
|
||||
double step = getDouble("step", 2);
|
||||
recalc = new Range(getInt("recalculate-direction.min", 8), getInt("recalculate-direction.max", 12));
|
||||
double rm = getDouble("recalculate-magnitude", 4);
|
||||
shift = new HashMap<>();
|
||||
for(Map.Entry<String, Object> e : Objects.requireNonNull(getConfigurationSection("shift")).getValues(false).entrySet()) {
|
||||
Set<Material> l = new HashSet<>();
|
||||
@ -93,6 +97,9 @@ public class CarverConfig extends TerraConfig {
|
||||
Range height = new Range(getInt("start.height.min"), getInt("start.height.max"));
|
||||
|
||||
carver = new UserDefinedCarver(height, radius, length, start, mutate, radiusMultiplier, id.hashCode(), getInt("cut.top", 0), getInt("cut.bottom", 0));
|
||||
carver.setStep(step);
|
||||
carver.setRecalc(recalc);
|
||||
carver.setRecalcMagnitude(rm);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -1,7 +1,8 @@
|
||||
id: CAVE
|
||||
step: 2
|
||||
length:
|
||||
min: 20
|
||||
max: 100
|
||||
min: 40
|
||||
max: 80
|
||||
start:
|
||||
x: 1
|
||||
y: 0.25
|
||||
@ -11,18 +12,18 @@ start:
|
||||
x: 1
|
||||
y: 1
|
||||
z: 1
|
||||
min: 2
|
||||
min: 3
|
||||
max: 4
|
||||
height:
|
||||
min: 4
|
||||
max: 72
|
||||
cut:
|
||||
top: 0
|
||||
bottom: 1
|
||||
bottom: 2
|
||||
mutate:
|
||||
x: 2
|
||||
y: 6
|
||||
z: 2
|
||||
x: 1
|
||||
y: 3
|
||||
z: 1
|
||||
radius: 0.125
|
||||
palette:
|
||||
inner:
|
||||
|
@ -1,7 +1,7 @@
|
||||
id: "CAVE_OCEAN"
|
||||
length:
|
||||
min: 20
|
||||
max: 100
|
||||
min: 40
|
||||
max: 80
|
||||
start:
|
||||
x: 1
|
||||
y: 0.25
|
||||
@ -20,9 +20,9 @@ cut:
|
||||
top: 0
|
||||
bottom: 0
|
||||
mutate:
|
||||
x: 2
|
||||
y: 6
|
||||
z: 2
|
||||
x: 1
|
||||
y: 3
|
||||
z: 1
|
||||
radius: 0.125
|
||||
palette:
|
||||
inner:
|
||||
|
@ -1,7 +1,7 @@
|
||||
id: "CAVE_SWAMP"
|
||||
length:
|
||||
min: 20
|
||||
max: 100
|
||||
min: 40
|
||||
max: 80
|
||||
start:
|
||||
x: 1
|
||||
y: 0.25
|
||||
@ -20,9 +20,9 @@ cut:
|
||||
top: 0
|
||||
bottom: 0
|
||||
mutate:
|
||||
x: 2
|
||||
y: 6
|
||||
z: 2
|
||||
x: 1
|
||||
y: 3
|
||||
z: 1
|
||||
radius: 0.125
|
||||
palette:
|
||||
inner:
|
||||
|
@ -1,7 +1,7 @@
|
||||
id: "CAVE_TUNDRA"
|
||||
length:
|
||||
min: 20
|
||||
max: 100
|
||||
min: 40
|
||||
max: 80
|
||||
start:
|
||||
x: 1
|
||||
y: 0.25
|
||||
@ -20,9 +20,9 @@ cut:
|
||||
top: 0
|
||||
bottom: 0
|
||||
mutate:
|
||||
x: 2
|
||||
y: 6
|
||||
z: 2
|
||||
x: 1
|
||||
y: 3
|
||||
z: 1
|
||||
radius: 0.125
|
||||
palette:
|
||||
inner:
|
||||
|
@ -9,7 +9,7 @@ start:
|
||||
radius:
|
||||
multiply:
|
||||
x: 1
|
||||
y: 4
|
||||
y: 6
|
||||
z: 1
|
||||
min: 3
|
||||
max: 4
|
||||
@ -17,11 +17,11 @@ start:
|
||||
min: 12
|
||||
max: 56
|
||||
cut:
|
||||
top: 1
|
||||
bottom: 2
|
||||
top: 6
|
||||
bottom: 4
|
||||
mutate:
|
||||
x: 1
|
||||
y: 4
|
||||
y: 2
|
||||
z: 1
|
||||
radius: 0.125
|
||||
palette:
|
||||
|
Loading…
x
Reference in New Issue
Block a user