本文整理汇总了Java中cn.nukkit.level.format.FullChunk.getHeightMapArray方法的典型用法代码示例。如果您正苦于以下问题:Java FullChunk.getHeightMapArray方法的具体用法?Java FullChunk.getHeightMapArray怎么用?Java FullChunk.getHeightMapArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.nukkit.level.format.FullChunk
的用法示例。
在下文中一共展示了FullChunk.getHeightMapArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: requestChunkTask
import cn.nukkit.level.format.FullChunk; //导入方法依赖的package包/类
@Override
public AsyncTask requestChunkTask(int x, int z) {
FullChunk chunk = this.getChunk(x, z, false);
if (chunk == null) {
throw new ChunkException("Invalid Chunk sent");
}
byte[] tiles = new byte[0];
if (!chunk.getBlockEntities().isEmpty()) {
List<CompoundTag> tagList = new ArrayList<>();
for (BlockEntity blockEntity : chunk.getBlockEntities().values()) {
if (blockEntity instanceof BlockEntitySpawnable) {
tagList.add(((BlockEntitySpawnable) blockEntity).getSpawnCompound());
}
}
try {
tiles = NBTIO.write(tagList, ByteOrder.LITTLE_ENDIAN);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Map<Integer, Integer> extra = chunk.getBlockExtraDataArray();
BinaryStream extraData;
if (!extra.isEmpty()) {
extraData = new BinaryStream();
extraData.putLInt(extra.size());
for (Integer key : extra.values()) {
extraData.putLInt(key);
extraData.putLShort(extra.get(key));
}
} else {
extraData = null;
}
BinaryStream stream = new BinaryStream();
stream.put(chunk.getBlockIdArray());
stream.put(chunk.getBlockDataArray());
stream.put(chunk.getBlockSkyLightArray());
stream.put(chunk.getBlockLightArray());
for (int height : chunk.getHeightMapArray()) {
stream.putByte((byte) height);
}
for (int color : chunk.getBiomeColorArray()) {
stream.put(Binary.writeInt(color));
}
if (extraData != null) {
stream.put(extraData.getBuffer());
} else {
stream.putLInt(0);
}
stream.put(tiles);
this.getLevel().chunkRequestCallback(x, z, stream.getBuffer());
return null;
}
示例2: requestChunkTask
import cn.nukkit.level.format.FullChunk; //导入方法依赖的package包/类
@Override
public byte[] requestChunkTask(int x, int z) {
FullChunk chunk = this.getChunk(x, z, false);
if (chunk == null) {
throw new ChunkException("Invalid Chunk sent");
}
byte[] tiles = new byte[0];
if (!chunk.getBlockEntities().isEmpty()) {
List<CompoundTag> tagList = new ArrayList<>();
for (BlockEntity blockEntity : chunk.getBlockEntities().values()) {
if (blockEntity instanceof BlockEntitySpawnable) {
tagList.add(((BlockEntitySpawnable) blockEntity).getSpawnCompound());
}
}
try {
tiles = NBTIO.write(tagList, ByteOrder.LITTLE_ENDIAN);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Map<Integer, Integer> extra = chunk.getBlockExtraDataArray();
BinaryStream extraData;
if (!extra.isEmpty()) {
extraData = new BinaryStream();
extraData.putLInt(extra.size());
for (Integer key : extra.values()) {
extraData.putLInt(key);
extraData.putLShort(extra.get(key));
}
} else {
extraData = null;
}
BinaryStream stream = new BinaryStream();
stream.put(chunk.getBlockIdArray());
stream.put(chunk.getBlockDataArray());
stream.put(chunk.getBlockSkyLightArray());
stream.put(chunk.getBlockLightArray());
for (int height : chunk.getHeightMapArray()) {
stream.putByte((byte) height);
}
for (int color : chunk.getBiomeColorArray()) {
stream.put(Binary.writeInt(color));
}
if (extraData != null) {
stream.put(extraData.getBuffer());
} else {
stream.putLInt(0);
}
stream.put(tiles);
return stream.getBuffer();
}