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");
|
EntityData player = EntityDataRegistry.getInstance().create("Test:Player");
|
||||||
|
|
||||||
player.setEntityId(TestContent.PLAYER_ENTITY_ID);
|
player.setEntityId(TestContent.PLAYER_ENTITY_ID);
|
||||||
player.setPosition(TestContent.SPAWN);
|
player.setPosition(getServer().getWorld().getGenerator().suggestSpawnLocation());
|
||||||
|
|
||||||
player.setUpVector(new Vec3(0, 0, 1));
|
player.setUpVector(new Vec3(0, 0, 1));
|
||||||
player.setLookingAt(new Vec3(2, 1, 0));
|
player.setLookingAt(new Vec3(2, 1, 0));
|
||||||
|
@ -106,7 +106,9 @@ public class WorldLogic
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ChunkData generate(Vec3i chunkPos) {
|
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) {
|
public ChunkLogic getChunk(ChunkData chunkData) {
|
||||||
|
@ -22,6 +22,7 @@ import java.io.DataInputStream;
|
|||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import glm.vec._3.Vec3;
|
||||||
import glm.vec._3.i.Vec3i;
|
import glm.vec._3.i.Vec3i;
|
||||||
import ru.windcorp.progressia.common.util.namespaces.Namespaced;
|
import ru.windcorp.progressia.common.util.namespaces.Namespaced;
|
||||||
import ru.windcorp.progressia.common.world.ChunkData;
|
import ru.windcorp.progressia.common.world.ChunkData;
|
||||||
@ -45,5 +46,7 @@ public abstract class WorldGenerator extends Namespaced {
|
|||||||
public abstract boolean isChunkReady(Object hint);
|
public abstract boolean isChunkReady(Object hint);
|
||||||
|
|
||||||
public abstract GravityModel getGravityModel();
|
public abstract GravityModel getGravityModel();
|
||||||
|
|
||||||
|
public abstract Vec3 suggestSpawnLocation();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,6 @@ import java.util.function.Consumer;
|
|||||||
|
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
import glm.vec._3.Vec3;
|
|
||||||
import glm.vec._3.i.Vec3i;
|
import glm.vec._3.i.Vec3i;
|
||||||
import ru.windcorp.progressia.client.ClientState;
|
import ru.windcorp.progressia.client.ClientState;
|
||||||
import ru.windcorp.progressia.client.audio.SoundEffect;
|
import ru.windcorp.progressia.client.audio.SoundEffect;
|
||||||
@ -66,8 +65,6 @@ public class TestContent {
|
|||||||
public static final String PLAYER_LOGIN = "Sasha";
|
public static final String PLAYER_LOGIN = "Sasha";
|
||||||
public static final long PLAYER_ENTITY_ID = 0x42;
|
public static final long PLAYER_ENTITY_ID = 0x42;
|
||||||
public static final long STATIE_ENTITY_ID = 0xDEADBEEF;
|
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<BlockData> PLACEABLE_BLOCKS = new ArrayList<>();
|
||||||
public static final List<TileData> PLACEABLE_TILES = 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.io.IOException;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import glm.vec._3.Vec3;
|
||||||
import glm.vec._3.i.Vec3i;
|
import glm.vec._3.i.Vec3i;
|
||||||
import ru.windcorp.progressia.common.util.VectorUtil;
|
import ru.windcorp.progressia.common.util.VectorUtil;
|
||||||
import ru.windcorp.progressia.common.util.Vectors;
|
import ru.windcorp.progressia.common.util.Vectors;
|
||||||
@ -54,6 +55,11 @@ public class TestWorldGenerator extends AbstractWorldGenerator<Boolean> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vec3 suggestSpawnLocation() {
|
||||||
|
return new Vec3(8, 8, 880);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Boolean doReadGenerationHint(DataInputStream input) throws IOException, DecodingException {
|
protected Boolean doReadGenerationHint(DataInputStream input) throws IOException, DecodingException {
|
||||||
@ -72,9 +78,7 @@ public class TestWorldGenerator extends AbstractWorldGenerator<Boolean> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChunkData generate(Vec3i chunkPos, WorldData world) {
|
public ChunkData generate(Vec3i chunkPos, WorldData world) {
|
||||||
ChunkData chunk = generateUnpopulated(chunkPos, world);
|
return generateUnpopulated(chunkPos, world);
|
||||||
world.addChunk(chunk);
|
|
||||||
return chunk;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChunkData generateUnpopulated(Vec3i chunkPos, WorldData world) {
|
private ChunkData generateUnpopulated(Vec3i chunkPos, WorldData world) {
|
||||||
|
@ -22,6 +22,7 @@ import java.io.DataOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import glm.vec._3.Vec3;
|
||||||
import glm.vec._3.i.Vec3i;
|
import glm.vec._3.i.Vec3i;
|
||||||
import ru.windcorp.progressia.common.util.VectorUtil;
|
import ru.windcorp.progressia.common.util.VectorUtil;
|
||||||
import ru.windcorp.progressia.common.world.ChunkData;
|
import ru.windcorp.progressia.common.world.ChunkData;
|
||||||
@ -47,6 +48,11 @@ public class TestPlanetGenerator extends AbstractWorldGenerator<Boolean> {
|
|||||||
throw new IllegalArgumentException("planetRadius too small, must be at least 32 m");
|
throw new IllegalArgumentException("planetRadius too small, must be at least 32 m");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vec3 suggestSpawnLocation() {
|
||||||
|
return new Vec3(0, 0, 66);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Boolean doReadGenerationHint(DataInputStream input) throws IOException, DecodingException {
|
protected Boolean doReadGenerationHint(DataInputStream input) throws IOException, DecodingException {
|
||||||
@ -70,7 +76,6 @@ public class TestPlanetGenerator extends AbstractWorldGenerator<Boolean> {
|
|||||||
generate(chunk);
|
generate(chunk);
|
||||||
chunk.setGenerationHint(true);
|
chunk.setGenerationHint(true);
|
||||||
|
|
||||||
world.addChunk(chunk);
|
|
||||||
return chunk;
|
return chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user