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 hash;
|
||||||
private final int topCut;
|
private final int topCut;
|
||||||
private final int bottomCut;
|
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) {
|
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());
|
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);
|
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
|
@Override
|
||||||
public boolean isChunkCarved(World w, int chunkX, int chunkZ, Random random) {
|
public boolean isChunkCarved(World w, int chunkX, int chunkZ, Random random) {
|
||||||
ConfigPack c = TerraWorld.getWorld(w).getConfig();
|
ConfigPack c = TerraWorld.getWorld(w).getConfig();
|
||||||
@ -50,6 +65,9 @@ public class UserDefinedCarver extends Carver {
|
|||||||
private final Vector direction;
|
private final Vector direction;
|
||||||
private final int maxRad;
|
private final int maxRad;
|
||||||
private double runningRadius;
|
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) {
|
public UserDefinedWorm(int length, Random r, Vector origin, int maxRad, int topCut, int bottomCut) {
|
||||||
super(length, r, origin);
|
super(length, r, origin);
|
||||||
@ -57,17 +75,27 @@ public class UserDefinedCarver extends Carver {
|
|||||||
super.setBottomCut(bottomCut);
|
super.setBottomCut(bottomCut);
|
||||||
runningRadius = radius.get(r);
|
runningRadius = radius.get(r);
|
||||||
this.maxRad = maxRad;
|
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
|
@Override
|
||||||
public void step() {
|
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])});
|
setRadius(new int[] {(int) (runningRadius * radiusMultiplier[0]), (int) (runningRadius * radiusMultiplier[1]), (int) (runningRadius * radiusMultiplier[2])});
|
||||||
runningRadius += (getRandom().nextDouble() - 0.5) * mutate[3];
|
runningRadius += (getRandom().nextDouble() - 0.5) * mutate[3];
|
||||||
runningRadius = Math.max(Math.min(runningRadius, maxRad), 1);
|
runningRadius = Math.max(Math.min(runningRadius, maxRad), 1);
|
||||||
direction.rotateAroundX(Math.toRadians(getRandom().nextDouble() * mutate[0] * 2));
|
direction.rotateAroundX(Math.toRadians(currentRotation[0] * mutate[0]));
|
||||||
direction.rotateAroundY(Math.toRadians(getRandom().nextDouble() * mutate[1] * 2));
|
direction.rotateAroundY(Math.toRadians(currentRotation[1] * mutate[1]));
|
||||||
direction.rotateAroundZ(Math.toRadians(getRandom().nextDouble() * mutate[2] * 2));
|
direction.rotateAroundZ(Math.toRadians(currentRotation[2] * mutate[2]));
|
||||||
getRunning().add(direction);
|
getRunning().add(direction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ public class CarverConfig extends TerraConfig {
|
|||||||
private final boolean replaceIsBlacklistTop;
|
private final boolean replaceIsBlacklistTop;
|
||||||
private final boolean replaceIsBlacklistBottom;
|
private final boolean replaceIsBlacklistBottom;
|
||||||
private final boolean updateOcean;
|
private final boolean updateOcean;
|
||||||
|
private final Range recalc;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public CarverConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
public CarverConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
||||||
@ -69,6 +70,9 @@ public class CarverConfig extends TerraConfig {
|
|||||||
|
|
||||||
updateOcean = getBoolean("update-liquids", false);
|
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<>();
|
shift = new HashMap<>();
|
||||||
for(Map.Entry<String, Object> e : Objects.requireNonNull(getConfigurationSection("shift")).getValues(false).entrySet()) {
|
for(Map.Entry<String, Object> e : Objects.requireNonNull(getConfigurationSection("shift")).getValues(false).entrySet()) {
|
||||||
Set<Material> l = new HashSet<>();
|
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"));
|
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 = 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")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
id: CAVE
|
id: CAVE
|
||||||
|
step: 2
|
||||||
length:
|
length:
|
||||||
min: 20
|
min: 40
|
||||||
max: 100
|
max: 80
|
||||||
start:
|
start:
|
||||||
x: 1
|
x: 1
|
||||||
y: 0.25
|
y: 0.25
|
||||||
@ -11,18 +12,18 @@ start:
|
|||||||
x: 1
|
x: 1
|
||||||
y: 1
|
y: 1
|
||||||
z: 1
|
z: 1
|
||||||
min: 2
|
min: 3
|
||||||
max: 4
|
max: 4
|
||||||
height:
|
height:
|
||||||
min: 4
|
min: 4
|
||||||
max: 72
|
max: 72
|
||||||
cut:
|
cut:
|
||||||
top: 0
|
top: 0
|
||||||
bottom: 1
|
bottom: 2
|
||||||
mutate:
|
mutate:
|
||||||
x: 2
|
x: 1
|
||||||
y: 6
|
y: 3
|
||||||
z: 2
|
z: 1
|
||||||
radius: 0.125
|
radius: 0.125
|
||||||
palette:
|
palette:
|
||||||
inner:
|
inner:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
id: "CAVE_OCEAN"
|
id: "CAVE_OCEAN"
|
||||||
length:
|
length:
|
||||||
min: 20
|
min: 40
|
||||||
max: 100
|
max: 80
|
||||||
start:
|
start:
|
||||||
x: 1
|
x: 1
|
||||||
y: 0.25
|
y: 0.25
|
||||||
@ -20,9 +20,9 @@ cut:
|
|||||||
top: 0
|
top: 0
|
||||||
bottom: 0
|
bottom: 0
|
||||||
mutate:
|
mutate:
|
||||||
x: 2
|
x: 1
|
||||||
y: 6
|
y: 3
|
||||||
z: 2
|
z: 1
|
||||||
radius: 0.125
|
radius: 0.125
|
||||||
palette:
|
palette:
|
||||||
inner:
|
inner:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
id: "CAVE_SWAMP"
|
id: "CAVE_SWAMP"
|
||||||
length:
|
length:
|
||||||
min: 20
|
min: 40
|
||||||
max: 100
|
max: 80
|
||||||
start:
|
start:
|
||||||
x: 1
|
x: 1
|
||||||
y: 0.25
|
y: 0.25
|
||||||
@ -20,9 +20,9 @@ cut:
|
|||||||
top: 0
|
top: 0
|
||||||
bottom: 0
|
bottom: 0
|
||||||
mutate:
|
mutate:
|
||||||
x: 2
|
x: 1
|
||||||
y: 6
|
y: 3
|
||||||
z: 2
|
z: 1
|
||||||
radius: 0.125
|
radius: 0.125
|
||||||
palette:
|
palette:
|
||||||
inner:
|
inner:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
id: "CAVE_TUNDRA"
|
id: "CAVE_TUNDRA"
|
||||||
length:
|
length:
|
||||||
min: 20
|
min: 40
|
||||||
max: 100
|
max: 80
|
||||||
start:
|
start:
|
||||||
x: 1
|
x: 1
|
||||||
y: 0.25
|
y: 0.25
|
||||||
@ -20,9 +20,9 @@ cut:
|
|||||||
top: 0
|
top: 0
|
||||||
bottom: 0
|
bottom: 0
|
||||||
mutate:
|
mutate:
|
||||||
x: 2
|
x: 1
|
||||||
y: 6
|
y: 3
|
||||||
z: 2
|
z: 1
|
||||||
radius: 0.125
|
radius: 0.125
|
||||||
palette:
|
palette:
|
||||||
inner:
|
inner:
|
||||||
|
@ -9,7 +9,7 @@ start:
|
|||||||
radius:
|
radius:
|
||||||
multiply:
|
multiply:
|
||||||
x: 1
|
x: 1
|
||||||
y: 4
|
y: 6
|
||||||
z: 1
|
z: 1
|
||||||
min: 3
|
min: 3
|
||||||
max: 4
|
max: 4
|
||||||
@ -17,11 +17,11 @@ start:
|
|||||||
min: 12
|
min: 12
|
||||||
max: 56
|
max: 56
|
||||||
cut:
|
cut:
|
||||||
top: 1
|
top: 6
|
||||||
bottom: 2
|
bottom: 4
|
||||||
mutate:
|
mutate:
|
||||||
x: 1
|
x: 1
|
||||||
y: 4
|
y: 2
|
||||||
z: 1
|
z: 1
|
||||||
radius: 0.125
|
radius: 0.125
|
||||||
palette:
|
palette:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user