Block
This commit is contained in:
23
core/src/main/java/mc/core/block/AbstractBlock.java
Normal file
23
core/src/main/java/mc/core/block/AbstractBlock.java
Normal 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();
|
||||
}
|
||||
}
|
||||
46
core/src/main/java/mc/core/block/Block.java
Normal file
46
core/src/main/java/mc/core/block/Block.java
Normal 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();
|
||||
|
||||
}
|
||||
20
core/src/main/java/mc/core/block/BlockType.java
Normal file
20
core/src/main/java/mc/core/block/BlockType.java
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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");
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class FlatWorld implements World {
|
||||
|
||||
@Override
|
||||
public IWorldType getWorldType() {
|
||||
return WorldType.GENERAl;
|
||||
return WorldType.GENERAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user