Fixed stupid bugs
This commit is contained in:
parent
b2567d4c89
commit
a0e27450a3
@ -107,7 +107,7 @@ public class Server {
|
|||||||
public void setWorld(Path worldPath) throws IOException {
|
public void setWorld(Path worldPath) throws IOException {
|
||||||
Path propsFile = workDir.resolve("server.properties");
|
Path propsFile = workDir.resolve("server.properties");
|
||||||
if (!Files.exists(propsFile)) {
|
if (!Files.exists(propsFile)) {
|
||||||
Files.write(propsFile, "level-name=".concat(propsFile.toString()).getBytes());
|
Files.write(propsFile, "level-name=".concat(worldPath.toString()).getBytes());
|
||||||
} else {
|
} else {
|
||||||
serverProperties.backup();
|
serverProperties.backup();
|
||||||
|
|
||||||
|
@ -92,8 +92,8 @@ public class World {
|
|||||||
handler.backup();
|
handler.backup();
|
||||||
try (NBTOutputStream out = new NBTOutputStream(Files.newOutputStream(handler.file))) {
|
try (NBTOutputStream out = new NBTOutputStream(Files.newOutputStream(handler.file))) {
|
||||||
CompoundMap dataMap = new CompoundMap();
|
CompoundMap dataMap = new CompoundMap();
|
||||||
dataMap.put(new LongArrayTag("Forced",
|
dataMap.put(new LongArrayTag("Forced", chunks.stream()
|
||||||
chunks.stream().mapToLong(v -> ((long) v.y << 32) | v.x).toArray()));
|
.mapToLong(v -> ((long) v.y << 32) | ((long) v.x & 0xFFFFFFFF)).toArray()));
|
||||||
CompoundMap rootMap = new CompoundMap();
|
CompoundMap rootMap = new CompoundMap();
|
||||||
rootMap.put(new CompoundTag("data", dataMap));
|
rootMap.put(new CompoundTag("data", dataMap));
|
||||||
out.writeTag(new CompoundTag("", rootMap));
|
out.writeTag(new CompoundTag("", rootMap));
|
||||||
|
@ -9,25 +9,26 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import morlok8k.MinecraftLandGenerator.World;
|
import morlok8k.MinecraftLandGenerator.World;
|
||||||
|
|
||||||
public class SpawnpointTest {
|
public class LandGeneratorTest {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
System.setProperty("joml.format", "false");
|
System.setProperty("joml.format", "false");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void simpleTest() {
|
public void testSpawnpoints() {
|
||||||
test(0, 0, 25, 25, 25);
|
testSpawnpoint(0, 0, 25, 25, 25);
|
||||||
test(-100, 10, 500, 400, 25);
|
testSpawnpoint(-100, 10, 500, 400, 25);
|
||||||
test(-256, 16, 512, 256, 25);
|
testSpawnpoint(-256, 16, 512, 256, 25);
|
||||||
test(-255, 15, 512, 256, 25);
|
testSpawnpoint(-255, 15, 512, 256, 25);
|
||||||
test(-256, 16, 511, 255, 25);
|
testSpawnpoint(-256, 16, 511, 255, 25);
|
||||||
test(-255, 15, 511, 255, 25);
|
testSpawnpoint(-255, 15, 511, 255, 25);
|
||||||
test(25, 24, 50, 49, 25);
|
testSpawnpoint(25, 24, 50, 49, 25);
|
||||||
test(25, 24, 49, 50, 25);
|
testSpawnpoint(25, 24, 49, 50, 25);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void test(int startX, int startZ, int width, int height, int increment) {
|
private static void testSpawnpoint(int startX, int startZ, int width, int height,
|
||||||
|
int increment) {
|
||||||
List<Vector2i> spawn = World.generateSpawnpoints(startX, startZ, width, height, increment);
|
List<Vector2i> spawn = World.generateSpawnpoints(startX, startZ, width, height, increment);
|
||||||
int margin = increment / 2;
|
int margin = increment / 2;
|
||||||
Set<Vector2i> coverage = new HashSet<>();
|
Set<Vector2i> coverage = new HashSet<>();
|
Reference in New Issue
Block a user