Archived
0

Interfaces fix

This commit is contained in:
Forwolk
2018-07-26 08:56:00 +03:00
parent e22b32b9fb
commit 0da566acb0
7 changed files with 60 additions and 4 deletions

View File

@@ -20,6 +20,10 @@ public class Location {
);
}
public static Location startPointLocation () {
return new Location(0,10,0);
}
public void set(Location location) {
this.x = location.x;
this.y = location.y;

View 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);
}

View File

@@ -6,10 +6,14 @@ package mc.core.world;
import mc.core.Location;
import java.util.UUID;
public interface World {
UUID getWorldId();
Location getSpawn();
void setSpawn(Location location);
Chunk getChunk(int x, int z);
void setChunk(int x, int z, Chunk chunk);
Chunk getChunk(int x, int y, int z);
void setChunk(int x, int y, int z, Chunk chunk);
}

View File

@@ -0,0 +1,6 @@
package mc.core.world;
public interface WorldGenerator {
Chunk generateChunk (int x, int z, World world);
}

View File

@@ -10,19 +10,25 @@ import mc.core.Location;
import mc.core.world.Chunk;
import mc.core.world.World;
import java.util.UUID;
public class FlatWorld implements World {
@Getter@Setter
private UUID worldId;
@Getter
@Setter
private Location spawn = new Location(0, 6, 0);
private Chunk chunk = new SimpleChunk();
@Override
public Chunk getChunk(int x, int z) {
public Chunk getChunk(int x, int y, int z) {
return chunk;
}
@Override
public void setChunk(int x, int z, Chunk chunk) {
public void setChunk(int x, int y, int z, Chunk chunk) {
throw new UnsupportedOperationException();
}
}

View File

@@ -0,0 +1,7 @@
group 'mc'
version '1.0-SNAPSHOT'
dependencies {
compile_excludeCopy project(':core')
testCompile group: 'junit', name: 'junit', version: '4.12'
}

View File

@@ -5,3 +5,5 @@ include('flat_world')
include('vanilla_commands')
include('proto_1.12.2') // Protocol 1.12.2
include('proto_1.12.2_netty') // Protocol 1.12.2 (Netty impl.)
include 'generated_world'