Merge & resolve conflicts
This commit is contained in:
@@ -14,4 +14,6 @@ dependencies {
|
||||
/* Components */
|
||||
compile (group: 'commons-io', name: 'commons-io', version: '2.6')
|
||||
compile (group: 'com.google.guava', name: 'guava', version: '24.1-jre')
|
||||
/* Named Binary Tags */
|
||||
compile (group: 'com.flowpowered', name: 'flow-nbt', version: '1.0.0')
|
||||
}
|
||||
|
||||
@@ -6,10 +6,9 @@ package mc.core;
|
||||
|
||||
import lombok.Data;
|
||||
import mc.core.exception.ResourceUnloadedException;
|
||||
import mc.core.world.Chunk;
|
||||
import mc.core.world.Region;
|
||||
import mc.core.world.World;
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
import mc.core.world.chunk.Chunk;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.ref.Reference;
|
||||
@@ -61,6 +60,12 @@ public class Location implements Serializable{
|
||||
this.world = new WeakReference<>(world);
|
||||
}
|
||||
|
||||
public void set(double x, double y, double z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public void set(Location location) {
|
||||
this.x = location.x;
|
||||
this.y = location.y;
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package mc.core.block;
|
||||
|
||||
import mc.core.Location;
|
||||
|
||||
public class BlockFactory {
|
||||
|
||||
public Block create(BlockType blockType, int meta) {
|
||||
return new EmbeddedBlock(blockType, meta);
|
||||
}
|
||||
|
||||
/**
|
||||
* For first-time generation
|
||||
*/
|
||||
private class EmbeddedBlock extends AbstractBlock {
|
||||
EmbeddedBlock(BlockType type, int meta) {
|
||||
super(type, meta);
|
||||
super.setLocation(new Location(0,0,0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package mc.core.world;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public enum Biome {
|
||||
OCEAN(0, "Ocean", 0x0000cd),
|
||||
PLAINS(1, "Plains", 0x008000),
|
||||
@@ -23,13 +25,24 @@ public enum Biome {
|
||||
DESERT_HILLS(17, "Desert hills", 0xffe4b5),
|
||||
FOREST_HILLS(18, "Forest hills", 0x006400),
|
||||
TAIGA_HILLS(19, "Taiga hills", 0xf0f8ff),
|
||||
EXTREME_HILLS_EDGE(20, "Extreme hills edge", 0xffffff),
|
||||
EXTREME_HILLS_ED(20, "Extreme hills edge", 0xffffff),
|
||||
JUNGLE(21, "Jungle", 0xadff2f),
|
||||
JUNGLE_HILLS(22, "Jungle hills", 0xadff2f),
|
||||
DEEP_OCEAN(23, "Deep ocean", 0x000080),
|
||||
TUNDRA(24, "Tundra", 0xc0c0c0),
|
||||
SAVANNA(25, "Savana", 0xcd8513),
|
||||
SAVANNA_FOREST(26, "Savana forest", 0x8b4513);
|
||||
JUNGLE_HILLS_2(23, "Jungle hills", 0xadff2f), //WTF?
|
||||
DEEP_OCEAN(24, "Deep ocean", 0x000080),
|
||||
STONE_BEACH(25, "Stone beach", 0xffffff),
|
||||
COLD_BEACH(26, "Cold beach", 0xffffff),
|
||||
BIRCH_FOREST(27, "Birch forest", 0xffffff),
|
||||
BIRCH_FOREST_HILLS(28, "Birch forest hills", 0xffffff),
|
||||
DARK_FOREST(29, "Dark forest", 0xffffff),
|
||||
COLD_TAIGA(30, "Cold taiga", 0xffffff),
|
||||
COLD_TAIGA_HILLS(31, "Cold taiga hills", 0xffffff),
|
||||
MEGA_TAIGA(32, "Mega taiga", 0xffffff),
|
||||
MEGA_TAIGA_HILLS(33, "Mega taiga hills", 0xffffff),
|
||||
EXTREME_HILLS_PLUS(34, "Extreme hills plus", 0xffffff),
|
||||
SAVANNA(35, "Savana", 0xcd8513),
|
||||
SAVANNA_PLATO(36, "Savana plato", 0x8b4513),
|
||||
VOID(127, "Void", 0xffffff);
|
||||
|
||||
@Getter
|
||||
private final int id;
|
||||
@@ -38,6 +51,8 @@ public enum Biome {
|
||||
@Getter
|
||||
private final int color;
|
||||
|
||||
private final static EnumSet<Biome> waterBiomes = EnumSet.of(OCEAN, RIVER, FROZEN_OCEAN, FROZEN_RIVER, DEEP_OCEAN);
|
||||
|
||||
Biome(int id, String name, int color) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
@@ -47,4 +62,8 @@ public enum Biome {
|
||||
public static Biome getById(int id) {
|
||||
return Biome.values()[id];
|
||||
}
|
||||
|
||||
public static boolean isWaterBiome (Biome biome) {
|
||||
return waterBiomes.contains(biome);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
package mc.core.world;
|
||||
|
||||
import mc.core.block.Block;
|
||||
import mc.core.world.block.Block;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -23,14 +23,6 @@ import java.io.Serializable;
|
||||
*/
|
||||
/* 16x16x16 */
|
||||
public interface ChunkSection extends Serializable{
|
||||
int getBlockType(int x, int y, int z);
|
||||
void setBlockType(int x, int y, int z, int type);
|
||||
|
||||
int getBlockMetadata(int x, int y, int z);
|
||||
void setBlockMetadata(int x, int y, int z, int metadata);
|
||||
|
||||
int getBlockLight(int x, int y, int z);
|
||||
void setBlockLight(int x, int y, int z, int lightLevel);
|
||||
|
||||
int getSkyLight(int x, int y, int z);
|
||||
void setSkyLight(int x, int y, int z, int lightLevel);
|
||||
@@ -45,7 +37,7 @@ public interface ChunkSection extends Serializable{
|
||||
int getY();
|
||||
int getZ();
|
||||
|
||||
void setBlock(int x, int y, int z, Block block);
|
||||
void setBlock(Block block);
|
||||
Block getBlock(int x, int y, int z);
|
||||
|
||||
Region getRegion();
|
||||
|
||||
@@ -2,6 +2,7 @@ package mc.core.world;
|
||||
|
||||
import mc.core.serialization.IRegionReaderWriter;
|
||||
import mc.core.serialization.Serializer;
|
||||
import mc.core.world.chunk.Chunk;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package mc.core.block;
|
||||
package mc.core.world.block;
|
||||
|
||||
import com.flowpowered.nbt.Tag;
|
||||
import lombok.Getter;
|
||||
@@ -10,11 +10,15 @@ import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public abstract class AbstractBlock implements Block {
|
||||
@Getter@Setter
|
||||
@Getter
|
||||
@Setter
|
||||
private Location location;
|
||||
@Getter
|
||||
private int meta;
|
||||
@Getter
|
||||
@Setter
|
||||
private int light = 0; //TODO need to know range of values
|
||||
@Getter
|
||||
private final BlockType blockType;
|
||||
private final Map<String, Tag<?>> nbtTagsMap = new HashMap<>();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mc.core.block;
|
||||
package mc.core.world.block;
|
||||
|
||||
import com.flowpowered.nbt.Tag;
|
||||
import mc.core.Location;
|
||||
import mc.core.nbt.Taggable;
|
||||
|
||||
@@ -29,20 +28,6 @@ import java.io.Serializable;
|
||||
|
||||
public interface Block extends Taggable, Serializable{
|
||||
|
||||
static Block airBlock (int x, int y, int z) {
|
||||
return new AbstractBlock(BlockType.AIR) {
|
||||
@Override
|
||||
public Tag<?> getTag(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return new Location(x, y, z);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/** Block id */
|
||||
int getId();
|
||||
|
||||
@@ -53,6 +38,9 @@ public interface Block extends Taggable, Serializable{
|
||||
*/
|
||||
int getMeta();
|
||||
|
||||
int getLight();
|
||||
void setLight(int light);
|
||||
|
||||
/**
|
||||
* Getting block type
|
||||
*/
|
||||
28
core/src/main/java/mc/core/world/block/BlockFactory.java
Normal file
28
core/src/main/java/mc/core/world/block/BlockFactory.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package mc.core.world.block;
|
||||
|
||||
import mc.core.Location;
|
||||
|
||||
public class BlockFactory {
|
||||
|
||||
public Block create(BlockType blockType, int meta, int x, int y, int z) {
|
||||
return new EmbeddedBlock(blockType, meta, x, y, z);
|
||||
}
|
||||
|
||||
public Block create(BlockType blockType, int meta) {
|
||||
return new EmbeddedBlock(blockType, meta, 0, 0, 0);
|
||||
}
|
||||
|
||||
public Block create(BlockType blockType) {
|
||||
return create(blockType, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* For first-time generation
|
||||
*/
|
||||
private class EmbeddedBlock extends AbstractBlock {
|
||||
EmbeddedBlock(BlockType type, int meta, int x, int y, int z) {
|
||||
super(type, meta);
|
||||
super.setLocation(new Location(x,y,z));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
package mc.core.block;
|
||||
package mc.core.world.block;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public enum BlockType {
|
||||
AIR(0, "Air"),
|
||||
STONE(1, "Stone"),
|
||||
GRASS(2, "Grass"),
|
||||
DIRT(3, "Dirt"),
|
||||
BEDROCK(7, "Bedrock"),
|
||||
WATER(8, "Water"),
|
||||
SAND(12, "Sand"),
|
||||
SNOW(32, "Snow"),
|
||||
AIR(0, "Air");
|
||||
SNOW(32, "Snow");
|
||||
|
||||
@Getter
|
||||
private final int id;
|
||||
@@ -1,4 +1,8 @@
|
||||
package mc.core.world;
|
||||
package mc.core.world.chunk;
|
||||
|
||||
import mc.core.world.ChunkSection;
|
||||
import mc.core.world.Region;
|
||||
import mc.core.world.World;
|
||||
|
||||
public interface Chunk {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
package mc.core.world;
|
||||
package mc.core.world.chunk;
|
||||
|
||||
import mc.core.world.ChunkSection;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
Reference in New Issue
Block a user