本文整理汇总了Java中cn.nukkit.utils.BinaryStream.putByte方法的典型用法代码示例。如果您正苦于以下问题:Java BinaryStream.putByte方法的具体用法?Java BinaryStream.putByte怎么用?Java BinaryStream.putByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.nukkit.utils.BinaryStream
的用法示例。
在下文中一共展示了BinaryStream.putByte方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toFastBinary
import cn.nukkit.utils.BinaryStream; //导入方法依赖的package包/类
@Override
public byte[] toFastBinary() {
BinaryStream stream = new BinaryStream(new byte[65536]);
stream.put(Binary.writeInt(this.x));
stream.put(Binary.writeInt(this.z));
stream.put(this.getBlockIdArray());
stream.put(this.getBlockDataArray());
stream.put(this.getBlockSkyLightArray());
stream.put(this.getBlockLightArray());
for (int height : this.getHeightMapArray()) {
stream.putByte((byte) height);
}
for (int color : this.getBiomeColorArray()) {
stream.put(Binary.writeInt(color));
}
stream.putByte((byte) ((this.isLightPopulated() ? 1 << 2 : 0) + (this.isPopulated() ? 1 << 2 : 0) + (this.isGenerated() ? 1 : 0)));
return stream.getBuffer();
}
示例2: toFastBinary
import cn.nukkit.utils.BinaryStream; //导入方法依赖的package包/类
@Override
public byte[] toFastBinary() {
BinaryStream stream = new BinaryStream(new byte[65536]);
stream.put(Binary.writeInt(this.x));
stream.put(Binary.writeInt(this.z));
stream.put(this.getBlockIdArray());
stream.put(this.getBlockDataArray());
stream.put(this.getBlockSkyLightArray());
stream.put(this.getBlockLightArray());
for (int height : this.getHeightMapArray()) {
stream.putByte((byte) (height & 0xff));
}
for (int color : this.getBiomeColorArray()) {
stream.put(Binary.writeInt(color));
}
stream.putByte((byte) ((this.isLightPopulated() ? 1 << 2 : 0) + (this.isPopulated() ? 1 << 2 : 0) + (this.isGenerated() ? 1 : 0)));
return stream.getBuffer();
}
示例3: getEmptyChunkPayload
import cn.nukkit.utils.BinaryStream; //导入方法依赖的package包/类
public static byte[] getEmptyChunkPayload() {
BaseFullChunk chunk = new Chunk(McRegion.class);
byte[] tiles = new byte[0];
BinaryStream extraData = new BinaryStream();
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 & 0xff));
}
for (int color : chunk.getBiomeColorArray()) {
stream.put(Binary.writeInt(color));
}
stream.put(extraData.getBuffer());
stream.put(tiles);
return stream.getBuffer();
}
示例4: writeEnchantList
import cn.nukkit.utils.BinaryStream; //导入方法依赖的package包/类
private static int writeEnchantList(EnchantmentList list, BinaryStream stream) {
stream.putByte((byte) list.getSize());
for (int i = 0; i < list.getSize(); ++i) {
EnchantmentEntry entry = list.getSlot(i);
stream.putUnsignedVarInt(entry.getCost());
stream.putUnsignedVarInt(entry.getEnchantments().length);
for (Enchantment enchantment : entry.getEnchantments()) {
stream.putUnsignedVarInt(enchantment.getId());
stream.putUnsignedVarInt(enchantment.getLevel());
}
stream.putString(entry.getRandomName());
}
return CraftingDataPacket.ENTRY_ENCHANT_LIST;
}
示例5: writeEnchantList
import cn.nukkit.utils.BinaryStream; //导入方法依赖的package包/类
private static int writeEnchantList(EnchantmentList list, BinaryStream stream) {
stream.putByte((byte) list.getSize());
for (int i = 0; i < list.getSize(); ++i) {
EnchantmentEntry entry = list.getSlot(i);
stream.putInt(entry.getCost());
stream.putByte((byte) entry.getEnchantments().length);
for (Enchantment enchantment : entry.getEnchantments()) {
stream.putInt(enchantment.getId());
stream.putInt(enchantment.getLevel());
}
stream.putString(entry.getRandomName());
}
return CraftingDataPacket.ENTRY_ENCHANT_LIST;
}
示例6: requestChunkTask
import cn.nukkit.utils.BinaryStream; //导入方法依赖的package包/类
@Override
public AsyncTask requestChunkTask(int x, int z) throws ChunkException {
BaseFullChunk 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);
}
}
BinaryStream extraData = new BinaryStream();
extraData.putLInt(chunk.getBlockExtraDataArray().size());
for (Integer key : chunk.getBlockExtraDataArray().keySet()) {
extraData.putLInt(key);
extraData.putLShort(chunk.getBlockExtraDataArray().get(key));
}
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 & 0xff));
}
for (int color : chunk.getBiomeColorArray()) {
stream.put(Binary.writeInt(color));
}
stream.put(extraData.getBuffer());
stream.put(tiles);
this.getLevel().chunkRequestCallback(x, z, stream.getBuffer());
return null;
}
示例7: requestChunkTask
import cn.nukkit.utils.BinaryStream; //导入方法依赖的package包/类
@Override
public AsyncTask requestChunkTask(int x, int z) throws ChunkException {
FullChunk chunk = this.getChunk(x, z, false);
if (chunk == null) {
throw new ChunkException("Invalid Chunk Set");
}
byte[] blockEntities = 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 {
blockEntities = NBTIO.write(tagList, ByteOrder.LITTLE_ENDIAN);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
BinaryStream extraData = new BinaryStream();
extraData.putLInt(chunk.getBlockExtraDataArray().size());
for (Integer key : chunk.getBlockExtraDataArray().values()) {
extraData.putLInt(key);
extraData.putLShort(chunk.getBlockExtraDataArray().get(key));
}
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 & 0xff));
}
for (int color : chunk.getBiomeColorArray()) {
stream.put(Binary.writeInt(color));
}
stream.put(extraData.getBuffer());
stream.put(blockEntities);
this.getLevel().chunkRequestCallback(x, z, stream.getBuffer(), FullChunkDataPacket.ORDER_LAYERED);
return null;
}