Interfaces fix
This commit is contained in:
@@ -20,6 +20,10 @@ public class Location {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Location startPointLocation () {
|
||||||
|
return new Location(0,10,0);
|
||||||
|
}
|
||||||
|
|
||||||
public void set(Location location) {
|
public void set(Location location) {
|
||||||
this.x = location.x;
|
this.x = location.x;
|
||||||
this.y = location.y;
|
this.y = location.y;
|
||||||
|
|||||||
27
core/src/main/java/mc/core/world/ChunkLoader.java
Normal file
27
core/src/main/java/mc/core/world/ChunkLoader.java
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package mc.core.world;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface ChunkLoader {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads chunk from cache. If chunk in cache doesn't exist, loads from file (or other storage)
|
||||||
|
*
|
||||||
|
* @param x chunk position
|
||||||
|
* @param y chunk position
|
||||||
|
* @param z chunk position
|
||||||
|
* @return optional of chunk (nullable)
|
||||||
|
*/
|
||||||
|
Optional<Chunk> loadChunk (int x, int y, int z);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to load chunk like {@link #loadChunk(int, int, int)}
|
||||||
|
* If chunk doesn't exist, generates it with selected world generator
|
||||||
|
*
|
||||||
|
* @param x chunk position
|
||||||
|
* @param y chunk position
|
||||||
|
* @param z chunk position
|
||||||
|
* @return chunk
|
||||||
|
*/
|
||||||
|
Chunk loadOrGenerateChunk (int x, int y, int z);
|
||||||
|
}
|
||||||
@@ -6,10 +6,14 @@ package mc.core.world;
|
|||||||
|
|
||||||
import mc.core.Location;
|
import mc.core.Location;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface World {
|
public interface World {
|
||||||
|
UUID getWorldId();
|
||||||
|
|
||||||
Location getSpawn();
|
Location getSpawn();
|
||||||
void setSpawn(Location location);
|
void setSpawn(Location location);
|
||||||
|
|
||||||
Chunk getChunk(int x, int z);
|
Chunk getChunk(int x, int y, int z);
|
||||||
void setChunk(int x, int z, Chunk chunk);
|
void setChunk(int x, int y, int z, Chunk chunk);
|
||||||
}
|
}
|
||||||
|
|||||||
6
core/src/main/java/mc/core/world/WorldGenerator.java
Normal file
6
core/src/main/java/mc/core/world/WorldGenerator.java
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
package mc.core.world;
|
||||||
|
|
||||||
|
public interface WorldGenerator {
|
||||||
|
|
||||||
|
Chunk generateChunk (int x, int z, World world);
|
||||||
|
}
|
||||||
@@ -10,19 +10,25 @@ import mc.core.Location;
|
|||||||
import mc.core.world.Chunk;
|
import mc.core.world.Chunk;
|
||||||
import mc.core.world.World;
|
import mc.core.world.World;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class FlatWorld implements World {
|
public class FlatWorld implements World {
|
||||||
|
|
||||||
|
@Getter@Setter
|
||||||
|
private UUID worldId;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private Location spawn = new Location(0, 6, 0);
|
private Location spawn = new Location(0, 6, 0);
|
||||||
private Chunk chunk = new SimpleChunk();
|
private Chunk chunk = new SimpleChunk();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Chunk getChunk(int x, int z) {
|
public Chunk getChunk(int x, int y, int z) {
|
||||||
return chunk;
|
return chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setChunk(int x, int z, Chunk chunk) {
|
public void setChunk(int x, int y, int z, Chunk chunk) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7
generated_world/build.gradle
Normal file
7
generated_world/build.gradle
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
group 'mc'
|
||||||
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile_excludeCopy project(':core')
|
||||||
|
testCompile group: 'junit', name: 'junit', version: '4.12'
|
||||||
|
}
|
||||||
@@ -5,3 +5,5 @@ include('flat_world')
|
|||||||
include('vanilla_commands')
|
include('vanilla_commands')
|
||||||
include('proto_1.12.2') // Protocol 1.12.2
|
include('proto_1.12.2') // Protocol 1.12.2
|
||||||
include('proto_1.12.2_netty') // Protocol 1.12.2 (Netty impl.)
|
include('proto_1.12.2_netty') // Protocol 1.12.2 (Netty impl.)
|
||||||
|
include 'generated_world'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user