генератор плоской карты
This commit is contained in:
@@ -26,7 +26,7 @@ public final class ChunkSerializeUtil {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
Block block = section.getBlock(x, y, z);
|
||||
int blockState = (block.getId() << 4) | block.getMeta();
|
||||
int blockState = blockIdMetaSerialize(block.getId(), block.getMeta());
|
||||
|
||||
blockArray.put(blockState);
|
||||
blockLight.put(block.getLight());
|
||||
@@ -45,4 +45,15 @@ public final class ChunkSerializeUtil {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static int blockIdMetaSerialize(int id, int meta) {
|
||||
return (id << 4) | meta;
|
||||
}
|
||||
|
||||
public static int[] blockIdMetaDeserialize(int blockState) {
|
||||
return new int[]{
|
||||
blockState >> 4,
|
||||
blockState & 0b1111
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package mc.protocol.world;
|
||||
|
||||
import mc.protocol.model.Location;
|
||||
import mc.protocol.model.BlockLocation;
|
||||
|
||||
public interface Block {
|
||||
|
||||
int getId();
|
||||
int getMeta();
|
||||
|
||||
Location getLocation();
|
||||
BlockLocation getLocation();
|
||||
|
||||
int getLight();
|
||||
void setLight(int value);
|
||||
|
||||
@@ -5,6 +5,6 @@ public interface Chunk {
|
||||
int getX();
|
||||
int getZ();
|
||||
|
||||
ChunkSection getSection(int index);
|
||||
ChunkSection getSection(int height);
|
||||
byte getBiome(int x, int z);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
package mc.protocol.world;
|
||||
|
||||
import mc.protocol.model.BlockLocation;
|
||||
|
||||
public interface ChunkSection {
|
||||
|
||||
int getY();
|
||||
|
||||
Block getBlock(int x, int y, int z);
|
||||
Block getBlock(BlockLocation blockLocation);
|
||||
|
||||
int getSkyLight(int x, int y, int z);
|
||||
int getSkyLight(BlockLocation blockLocation);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user