Fix SquareTerrainGenerator not being square
This commit is contained in:
parent
671857b9e4
commit
4fc8503d63
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -73,7 +73,6 @@ public class Score {
|
|||||||
public List<String> getMapFormatted() {
|
public List<String> getMapFormatted() {
|
||||||
List<String> out = new ArrayList<>();
|
List<String> out = new ArrayList<>();
|
||||||
|
|
||||||
int counter = 0;
|
|
||||||
for (Map.Entry<Player, Integer> entry : getMap().entrySet()) {
|
for (Map.Entry<Player, Integer> entry : getMap().entrySet()) {
|
||||||
out.add(entry.getValue() + ": " + entry.getKey().getUsername());
|
out.add(entry.getValue() + ": " + entry.getKey().getUsername());
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import net.minestom.server.instance.generator.GenerationUnit;
|
|||||||
import net.minestom.server.instance.generator.Generator;
|
import net.minestom.server.instance.generator.Generator;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class SquareTerrainGenerator implements Generator {
|
public class SquareTerrainGenerator implements Generator {
|
||||||
@ -21,8 +22,6 @@ public class SquareTerrainGenerator implements Generator {
|
|||||||
|
|
||||||
private final boolean generatePlate;
|
private final boolean generatePlate;
|
||||||
|
|
||||||
protected final Pos mapStart = new Pos(0, 50, 0);
|
|
||||||
|
|
||||||
public SquareTerrainGenerator(int width, int length, boolean generatePlate) {
|
public SquareTerrainGenerator(int width, int length, boolean generatePlate) {
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.length = length;
|
this.length = length;
|
||||||
@ -60,8 +59,6 @@ public class SquareTerrainGenerator implements Generator {
|
|||||||
for (int z = 0; z < unit.size().z(); z++) {
|
for (int z = 0; z < unit.size().z(); z++) {
|
||||||
Point bottom = start.add(x, 0, z);
|
Point bottom = start.add(x, 0, z);
|
||||||
|
|
||||||
double distance = bottom.distance(new Pos(0, 0, 0));
|
|
||||||
|
|
||||||
if(generatePlate) {
|
if(generatePlate) {
|
||||||
if(bottom.x() <= width && bottom.x() >= 0 && bottom.z() <= length && bottom.z() >= 0) {
|
if(bottom.x() <= width && bottom.x() >= 0 && bottom.z() <= length && bottom.z() >= 0) {
|
||||||
unit.modifier().fill(bottom, bottom.add(1, 50, 1), BlockPallet.GROUND.rnd());
|
unit.modifier().fill(bottom, bottom.add(1, 50, 1), BlockPallet.GROUND.rnd());
|
||||||
@ -73,7 +70,14 @@ public class SquareTerrainGenerator implements Generator {
|
|||||||
|
|
||||||
synchronized (base) {
|
synchronized (base) {
|
||||||
double baseNoise = base.getNoise(bottom.x(), bottom.z());
|
double baseNoise = base.getNoise(bottom.x(), bottom.z());
|
||||||
double currentHeight = minTwo(RangeMap.map(distance, 0, 400, -(this.width / 5), 200)) + baseNoise * 8;
|
double possibleHeights[] = {
|
||||||
|
minTwo(RangeMap.map(bottom.distance(new Pos(0, 0, 0)), 0, 400, -(this.width / 5), 200)) + baseNoise * 8,
|
||||||
|
minTwo(RangeMap.map(bottom.distance(new Pos(width, 0, 0)), 0, 400, -(this.width / 5), 200)) + baseNoise * 8,
|
||||||
|
minTwo(RangeMap.map(bottom.distance(new Pos(0, 0, length)), 0, 400, -(this.width / 5), 200)) + baseNoise * 8,
|
||||||
|
minTwo(RangeMap.map(bottom.distance(new Pos(width, 0, length)), 0, 400, -(this.width / 5), 200)) + baseNoise * 8
|
||||||
|
};
|
||||||
|
|
||||||
|
double currentHeight = Arrays.stream(possibleHeights).min().getAsDouble();
|
||||||
|
|
||||||
synchronized (batches) {
|
synchronized (batches) {
|
||||||
double elementNoise = batches.getNoise(bottom.x(), bottom.z());
|
double elementNoise = batches.getNoise(bottom.x(), bottom.z());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user