Java Code Examples for cn.nukkit.utils.BinaryStream#getBuffer()
The following examples show how to use
cn.nukkit.utils.BinaryStream#getBuffer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Chunk.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@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(); }
Example 2
Source File: Chunk.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public byte[] toFastBinary() { BinaryStream stream = new BinaryStream(new byte[65536]); stream.put(Binary.writeInt(this.getX())); stream.put(Binary.writeInt(this.getZ())); stream.put(this.getBlockIdArray()); stream.put(this.getBlockDataArray()); stream.put(this.getBlockSkyLightArray()); stream.put(this.getBlockLightArray()); stream.put(this.getHeightMapArray()); 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(); }
Example 3
Source File: Session.java From Jupiter with GNU General Public License v3.0 | 5 votes |
private void handleSplit(EncapsulatedPacket packet) throws Exception { if (packet.splitCount >= MAX_SPLIT_SIZE || packet.splitIndex >= MAX_SPLIT_SIZE || packet.splitIndex < 0) { return; } if (!this.splitPackets.containsKey(packet.splitID)) { if (this.splitPackets.size() >= MAX_SPLIT_COUNT) { return; } this.splitPackets.put(packet.splitID, new HashMap<Integer, EncapsulatedPacket>() {{ put(packet.splitIndex, packet); }}); } else { this.splitPackets.get(packet.splitID).put(packet.splitIndex, packet); } if (this.splitPackets.get(packet.splitID).size() == packet.splitCount) { EncapsulatedPacket pk = new EncapsulatedPacket(); BinaryStream stream = new BinaryStream(); for (int i = 0; i < packet.splitCount; i++) { stream.put(this.splitPackets.get(packet.splitID).get(i).buffer); } pk.buffer = stream.getBuffer(); pk.length = pk.buffer.length; this.splitPackets.remove(packet.splitID); this.handleEncapsulatedPacketRoute(pk); } }
Example 4
Source File: Chunk.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public byte[] toFastBinary() { BinaryStream stream = new BinaryStream(new byte[65536]); stream.put(Binary.writeInt(this.getX())); stream.put(Binary.writeInt(this.getZ())); stream.put(this.getBlockIdArray()); stream.put(this.getBlockDataArray()); stream.put(this.getBlockSkyLightArray()); stream.put(this.getBlockLightArray()); stream.put(this.getHeightMapArray()); stream.put(this.getBiomeIdArray()); stream.putByte((byte) ((this.isLightPopulated() ? 1 << 2 : 0) + (this.isPopulated() ? 1 << 2 : 0) + (this.isGenerated() ? 1 : 0))); return stream.getBuffer(); }
Example 5
Source File: Session.java From Nukkit with GNU General Public License v3.0 | 5 votes |
private void handleSplit(EncapsulatedPacket packet) throws Exception { if (packet.splitCount >= MAX_SPLIT_SIZE || packet.splitIndex >= MAX_SPLIT_SIZE || packet.splitIndex < 0) { return; } if (!this.splitPackets.containsKey(packet.splitID)) { if (this.splitPackets.size() >= MAX_SPLIT_COUNT) { return; } this.splitPackets.put(packet.splitID, new HashMap<Integer, EncapsulatedPacket>() {{ put(packet.splitIndex, packet); }}); } else { this.splitPackets.get(packet.splitID).put(packet.splitIndex, packet); } if (this.splitPackets.get(packet.splitID).size() == packet.splitCount) { EncapsulatedPacket pk = new EncapsulatedPacket(); BinaryStream stream = new BinaryStream(); for (int i = 0; i < packet.splitCount; i++) { stream.put(this.splitPackets.get(packet.splitID).get(i).buffer); } pk.buffer = stream.getBuffer(); pk.length = pk.buffer.length; this.splitPackets.remove(packet.splitID); this.handleEncapsulatedPacketRoute(pk); } }
Example 6
Source File: Session.java From Nukkit with GNU General Public License v3.0 | 5 votes |
private void handleSplit(EncapsulatedPacket packet) throws Exception { if (packet.splitCount >= MAX_SPLIT_SIZE || packet.splitIndex >= MAX_SPLIT_SIZE || packet.splitIndex < 0) { return; } if (!this.splitPackets.containsKey(packet.splitID)) { if (this.splitPackets.size() >= MAX_SPLIT_COUNT) { return; } this.splitPackets.put(packet.splitID, new HashMap<Integer, EncapsulatedPacket>() {{ put(packet.splitIndex, packet); }}); } else { this.splitPackets.get(packet.splitID).put(packet.splitIndex, packet); } if (this.splitPackets.get(packet.splitID).size() == packet.splitCount) { EncapsulatedPacket pk = new EncapsulatedPacket(); BinaryStream stream = new BinaryStream(); for (int i = 0; i < packet.splitCount; i++) { stream.put(this.splitPackets.get(packet.splitID).get(i).buffer); } pk.buffer = stream.getBuffer(); pk.length = pk.buffer.length; this.splitPackets.remove(packet.splitID); this.handleEncapsulatedPacketRoute(pk); } }