Archived
0

генератор плоской карты

This commit is contained in:
2021-07-18 12:15:10 +03:00
parent f280e9beaa
commit ee82930426
14 changed files with 241 additions and 14 deletions

View File

@@ -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
};
}
}

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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);
}