Fixed stupid bugs

This commit is contained in:
Piegames 2018-11-28 08:54:04 +01:00
parent b2567d4c89
commit a0e27450a3
3 changed files with 15 additions and 14 deletions

View File

@ -107,7 +107,7 @@ public class Server {
public void setWorld(Path worldPath) throws IOException {
Path propsFile = workDir.resolve("server.properties");
if (!Files.exists(propsFile)) {
Files.write(propsFile, "level-name=".concat(propsFile.toString()).getBytes());
Files.write(propsFile, "level-name=".concat(worldPath.toString()).getBytes());
} else {
serverProperties.backup();

View File

@ -92,8 +92,8 @@ public class World {
handler.backup();
try (NBTOutputStream out = new NBTOutputStream(Files.newOutputStream(handler.file))) {
CompoundMap dataMap = new CompoundMap();
dataMap.put(new LongArrayTag("Forced",
chunks.stream().mapToLong(v -> ((long) v.y << 32) | v.x).toArray()));
dataMap.put(new LongArrayTag("Forced", chunks.stream()
.mapToLong(v -> ((long) v.y << 32) | ((long) v.x & 0xFFFFFFFF)).toArray()));
CompoundMap rootMap = new CompoundMap();
rootMap.put(new CompoundTag("data", dataMap));
out.writeTag(new CompoundTag("", rootMap));

View File

@ -9,25 +9,26 @@ import org.junit.Test;
import morlok8k.MinecraftLandGenerator.World;
public class SpawnpointTest {
public class LandGeneratorTest {
static {
System.setProperty("joml.format", "false");
}
@Test
public void simpleTest() {
test(0, 0, 25, 25, 25);
test(-100, 10, 500, 400, 25);
test(-256, 16, 512, 256, 25);
test(-255, 15, 512, 256, 25);
test(-256, 16, 511, 255, 25);
test(-255, 15, 511, 255, 25);
test(25, 24, 50, 49, 25);
test(25, 24, 49, 50, 25);
public void testSpawnpoints() {
testSpawnpoint(0, 0, 25, 25, 25);
testSpawnpoint(-100, 10, 500, 400, 25);
testSpawnpoint(-256, 16, 512, 256, 25);
testSpawnpoint(-255, 15, 512, 256, 25);
testSpawnpoint(-256, 16, 511, 255, 25);
testSpawnpoint(-255, 15, 511, 255, 25);
testSpawnpoint(25, 24, 50, 49, 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);
int margin = increment / 2;
Set<Vector2i> coverage = new HashSet<>();