Archived
0

Chunk generations & basic saving

This commit is contained in:
Forwolk
2018-08-01 17:49:59 +03:00
parent 62d4ec6768
commit 75bec3ed93
16 changed files with 422 additions and 21 deletions

View File

@@ -25,6 +25,30 @@ import mc.core.Location;
public interface Block {
static Block airBlock (int x, int y, int z) {
return new Block() {
@Override
public int getId() {
return 0;
}
@Override
public int getMeta() {
return 0;
}
@Override
public BlockType getBlockType() {
return BlockType.AIR;
}
@Override
public Location getLocation() {
return new Location(x, y, z);
}
};
}
/** Block id */
int getId();

View File

@@ -1,5 +1,7 @@
package mc.core.block;
import mc.core.Location;
public class BlockFactory {
public Block create(BlockType blockType, int meta) {
@@ -12,6 +14,7 @@ public class BlockFactory {
private class EmbeddedBlock extends AbstractBlock {
EmbeddedBlock(BlockType type, int meta) {
super(type, meta);
super.setLocation(new Location(0,0,0));
}
}
}

View File

@@ -9,7 +9,8 @@ public enum BlockType {
BEDROCK(7, "Bedrock"),
WATER(8, "Water"),
SAND(12, "Sand"),
SNOW(32, "Snow");
SNOW(32, "Snow"),
AIR(0, "Air");
@Getter
private final int id;

View File

@@ -47,6 +47,7 @@ public interface Chunk {
int getY();
int getZ();
Block[] getNotAirBlocks();
Block[] getModifiedBlocks();
void setBlock (int x, int y, int z, Block block);
Block getBlock (int x, int y, int z);
}

View File

@@ -1,5 +1,9 @@
package mc.core.world;
import mc.core.serialization.Serializer;
import java.io.IOException;
/**
* Simple world generation unit
* 16x16x16 chunks
@@ -23,4 +27,6 @@ public interface Region {
Biome getBiomeAt (int x, int z);
void setBiome (int x, int z, Biome biome);
void save(Serializer<Chunk> chunkSerializer, Serializer<Region> regionSerializer) throws IOException;
}