Moved some functionality into WorldGenerator
- WorldGenerators now suggest a spawn location - WorldGenerators are no longer responsible for adding chunks
This commit is contained in:
parent
a9a21ce664
commit
abd8d9eebb
@ -60,7 +60,7 @@ public class PlayerManager {
|
||||
EntityData player = EntityDataRegistry.getInstance().create("Test:Player");
|
||||
|
||||
player.setEntityId(TestContent.PLAYER_ENTITY_ID);
|
||||
player.setPosition(TestContent.SPAWN);
|
||||
player.setPosition(getServer().getWorld().getGenerator().suggestSpawnLocation());
|
||||
|
||||
player.setUpVector(new Vec3(0, 0, 1));
|
||||
player.setLookingAt(new Vec3(2, 1, 0));
|
||||
|
@ -106,7 +106,9 @@ public class WorldLogic
|
||||
}
|
||||
|
||||
public ChunkData generate(Vec3i chunkPos) {
|
||||
return getGenerator().generate(chunkPos, getData());
|
||||
ChunkData chunk = getGenerator().generate(chunkPos, getData());
|
||||
getData().addChunk(chunk);
|
||||
return chunk;
|
||||
}
|
||||
|
||||
public ChunkLogic getChunk(ChunkData chunkData) {
|
||||
|
@ -22,6 +22,7 @@ import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import glm.vec._3.Vec3;
|
||||
import glm.vec._3.i.Vec3i;
|
||||
import ru.windcorp.progressia.common.util.namespaces.Namespaced;
|
||||
import ru.windcorp.progressia.common.world.ChunkData;
|
||||
@ -46,4 +47,6 @@ public abstract class WorldGenerator extends Namespaced {
|
||||
|
||||
public abstract GravityModel getGravityModel();
|
||||
|
||||
public abstract Vec3 suggestSpawnLocation();
|
||||
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ import java.util.function.Consumer;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import glm.vec._3.Vec3;
|
||||
import glm.vec._3.i.Vec3i;
|
||||
import ru.windcorp.progressia.client.ClientState;
|
||||
import ru.windcorp.progressia.client.audio.SoundEffect;
|
||||
@ -66,8 +65,6 @@ public class TestContent {
|
||||
public static final String PLAYER_LOGIN = "Sasha";
|
||||
public static final long PLAYER_ENTITY_ID = 0x42;
|
||||
public static final long STATIE_ENTITY_ID = 0xDEADBEEF;
|
||||
// public static final Vec3 SPAWN = new Vec3(8, 8, 880);
|
||||
public static final Vec3 SPAWN = new Vec3(0, 0, 66);
|
||||
|
||||
public static final List<BlockData> PLACEABLE_BLOCKS = new ArrayList<>();
|
||||
public static final List<TileData> PLACEABLE_TILES = new ArrayList<>();
|
||||
|
@ -23,6 +23,7 @@ import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
|
||||
import glm.vec._3.Vec3;
|
||||
import glm.vec._3.i.Vec3i;
|
||||
import ru.windcorp.progressia.common.util.VectorUtil;
|
||||
import ru.windcorp.progressia.common.util.Vectors;
|
||||
@ -55,6 +56,11 @@ public class TestWorldGenerator extends AbstractWorldGenerator<Boolean> {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 suggestSpawnLocation() {
|
||||
return new Vec3(8, 8, 880);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doReadGenerationHint(DataInputStream input) throws IOException, DecodingException {
|
||||
return input.readBoolean();
|
||||
@ -72,9 +78,7 @@ public class TestWorldGenerator extends AbstractWorldGenerator<Boolean> {
|
||||
|
||||
@Override
|
||||
public ChunkData generate(Vec3i chunkPos, WorldData world) {
|
||||
ChunkData chunk = generateUnpopulated(chunkPos, world);
|
||||
world.addChunk(chunk);
|
||||
return chunk;
|
||||
return generateUnpopulated(chunkPos, world);
|
||||
}
|
||||
|
||||
private ChunkData generateUnpopulated(Vec3i chunkPos, WorldData world) {
|
||||
|
@ -22,6 +22,7 @@ import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import glm.vec._3.Vec3;
|
||||
import glm.vec._3.i.Vec3i;
|
||||
import ru.windcorp.progressia.common.util.VectorUtil;
|
||||
import ru.windcorp.progressia.common.world.ChunkData;
|
||||
@ -48,6 +49,11 @@ public class TestPlanetGenerator extends AbstractWorldGenerator<Boolean> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 suggestSpawnLocation() {
|
||||
return new Vec3(0, 0, 66);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doReadGenerationHint(DataInputStream input) throws IOException, DecodingException {
|
||||
return input.readBoolean();
|
||||
@ -70,7 +76,6 @@ public class TestPlanetGenerator extends AbstractWorldGenerator<Boolean> {
|
||||
generate(chunk);
|
||||
chunk.setGenerationHint(true);
|
||||
|
||||
world.addChunk(chunk);
|
||||
return chunk;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user