Archived
0
This commit is contained in:
Forwolk
2018-07-26 12:25:48 +03:00
parent 39b85bd64d
commit 4f214ed250
5 changed files with 91 additions and 2 deletions

View File

@@ -0,0 +1,23 @@
package mc.core.block;
import lombok.Getter;
import lombok.Setter;
import mc.core.Location;
public abstract class AbstractBlock implements Block {
@Getter@Setter
private Location location;
@Getter@Setter
private int meta;
@Getter
private final BlockType blockType;
protected AbstractBlock(BlockType type) {
this.blockType = type;
}
@Override
public int getId() {
return blockType.getId();
}
}

View File

@@ -0,0 +1,46 @@
package mc.core.block;
import mc.core.Location;
/**
* Serialize info about block
*
* +------------+--------+------------+
* | param | range | bits |
* +------------+--------+------------+
* | id | 0-255 | 8 |
* +------------+--------+------------+
* | meta | 0-15 | 4 |
* +------------+--------+------------+
* | x | 0-15 | 4 |
* +------------+--------+------------+
* | y | 0-15 | 4 |
* +------------+--------+------------+
* | z | 0-15 | 4 |
* +------------+--------+------------+
*
* Total: 24 bits per block (3 bytes)
*
*/
public interface Block {
/** Block id */
int getId();
/**
* Addition in 0-15
* F.e. 35:0 - white wool
* 35:15 - black wool
*/
int getMeta();
/**
* Getting block type
*/
BlockType getBlockType();
/** Block location */
Location getLocation();
}

View File

@@ -0,0 +1,20 @@
package mc.core.block;
import lombok.Getter;
public enum BlockType {
DIRT(1, "Dirt"),
GRASS(2, "Grass"),
BEDROCK(7, "Bedrock");
@Getter
private final int id;
@Getter
private final String name;
BlockType(int id, String name) {
this.id = id;
this.name = name;
}
}

View File

@@ -1,7 +1,7 @@
package mc.core.world;
public enum WorldType implements IWorldType {
GENERAl ("Standard world type"),
GENERAL("Standard world type"),
NETHER ("Nether world type"),
END ("End world type");

View File

@@ -26,7 +26,7 @@ public class FlatWorld implements World {
@Override
public IWorldType getWorldType() {
return WorldType.GENERAl;
return WorldType.GENERAL;
}
@Override