List of usage examples for com.google.common.io ByteArrayDataOutput writeInt
@Override void writeInt(int v);
From source file:shadowmage.ancient_warfare.common.network.PacketBase.java
/** * create the custom250packet from the current data in this packet. *//*from w ww.java2s . com*/ protected void constructPacket() { ByteArrayDataOutput data = ByteStreams.newDataOutput(); /** * write the packet type number to the stream, decoded in packetHandler to create a new packet */ data.writeInt(this.getPacketType()); /** * write default packet data NBTCompound to the stream */ NBTWriter.writeTagToStream(packetData, data); /** * write custom data to the output stream */ this.writeDataToStream(data); this.packet250 = new Packet250CustomPayload(); packet250.isChunkDataPacket = this.chunkPacket; packet250.channel = this.getChannel(); packet250.data = data.toByteArray(); packet250.length = packet250.data.length; }
From source file:shadowmage.ancient_framework.common.network.PacketBase.java
/** * create the custom250packet from the current data in this packet. *///from ww w .ja va 2s. c om protected void constructPacket() { ByteArrayDataOutput data = ByteStreams.newDataOutput(); /** * write the packet type number to the stream, decoded in packetHandler to create a new packet */ data.writeInt(this.getPacketType()); /** * write default packet data NBTCompound to the stream */ NBTTools.writeTagToStream(packetData, data); /** * write custom data to the output stream */ this.writeDataToStream(data); this.packet250 = new Packet250CustomPayload(); packet250.isChunkDataPacket = this.chunkPacket; packet250.channel = this.getChannel(); packet250.data = data.toByteArray(); packet250.length = packet250.data.length; }
From source file:smpships.entity.EntityBlock.java
@Override public void writeSpawnData(ByteArrayDataOutput data) { //child (all) entities get spawned on server only, so need to be able to pass this data to their client copies data.writeInt(blockID); data.writeInt(metadata);//from www . ja v a 2 s .c o m data.writeInt(xOff); data.writeInt(yOff); data.writeInt(zOff); writeControlBlockSpawnData(data); }
From source file:buildcraft.core.EntityRobot.java
@Override public void writeSpawnData(ByteArrayDataOutput data) { if (box == null) { box = new Box(); }/*w w w . j ava2 s. c om*/ data.writeInt(box.xMin); data.writeInt(box.yMin); data.writeInt(box.zMin); data.writeInt(box.xMax); data.writeInt(box.yMax); data.writeInt(box.zMax); }
From source file:shadowmage.ancient_warfare.common.gates.EntityGate.java
@Override public void writeSpawnData(ByteArrayDataOutput data) { data.writeInt(pos1.x); data.writeInt(pos1.y);/*ww w . j ava 2s .c o m*/ data.writeInt(pos1.z); data.writeInt(pos2.x); data.writeInt(pos2.y); data.writeInt(pos2.z); data.writeInt(this.gateType.getGlobalID()); data.writeInt(this.teamNum); data.writeFloat(this.edgePosition); data.writeFloat(this.edgeMax); data.writeByte(this.gateStatus); data.writeByte(this.gateOrientation); data.writeInt(health); }
From source file:shadowmage.ancient_warfare.common.vehicles.missiles.MissileBase.java
@Override public void writeSpawnData(ByteArrayDataOutput data) { data.writeInt(missileType); data.writeFloat(rotationYaw);/*from w ww . j ava 2s .c o m*/ data.writeFloat(rotationPitch); data.writeBoolean(inGround); data.writeInt(blockX); data.writeInt(blockY); data.writeInt(blockZ); data.writeInt(blockID); data.writeInt(blockMeta); data.writeInt(rocketBurnTime); data.writeBoolean(this.launcher != null); if (this.launcher != null) { data.writeInt(this.launcher.entityId); } }
From source file:de.paleocrafter.pmfw.tileentity.TileEntityWithData.java
public byte[] getPacketData() { ByteArrayDataOutput out = ByteStreams.newDataOutput(); Class<?> clazz = this.getClass(); int superClassCount = 0; while ((clazz = clazz.getSuperclass()) != TileEntityWithData.class) { superClassCount++;// w ww. ja va 2s. c o m } out.writeInt(superClassCount); clazz = this.getClass(); int iteration = 0; do { writePacketFromClass(out, clazz, iteration); iteration++; } while ((clazz = clazz.getSuperclass()) != TileEntityWithData.class); return out.toByteArray(); }
From source file:org.apache.hadoop.hbase.client.Mutation.java
/** * Marks that the clusters with the given clusterIds have consumed the mutation * @param clusterIds of the clusters that have consumed the mutation *//*from w w w .j a v a2 s. c om*/ public void setClusterIds(List<UUID> clusterIds) { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeInt(clusterIds.size()); for (UUID clusterId : clusterIds) { out.writeLong(clusterId.getMostSignificantBits()); out.writeLong(clusterId.getLeastSignificantBits()); } setAttribute(CONSUMED_CLUSTER_IDS, out.toByteArray()); }
From source file:codecrafter47.bungeetablistplus.bridge.BukkitBridge.java
@SneakyThrows private void initializeHandshake(Server server) { ByteArrayDataOutput data = ByteStreams.newDataOutput(); data.writeByte(BridgeProtocolConstants.MESSAGE_ID_PROXY_HANDSHAKE); DataStreamUtils.writeUUID(data, proxyId); data.writeInt(BridgeProtocolConstants.VERSION); server.sendData(BridgeProtocolConstants.CHANNEL, data.toByteArray()); }
From source file:io.github.apfelcreme.GuildsBungee.GuildsBungee.java
private void sendQueueingMessage(String operation, String args, Object... write) { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF(args);// w w w .j av a 2 s . c o m for (Object w : write) { if (w instanceof String) { out.writeUTF((String) w); } else if (w instanceof Integer) { out.writeInt((Integer) w); } else { try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oOut = new ObjectOutputStream(bos)) { oOut.writeObject(w); out.write(bos.toByteArray()); } catch (IOException e) { e.printStackTrace(); } } } QueueingPluginMessage pm = new QueueingPluginMessage(operation, args, out); for (ServerInfo serverInfo : getProxy().getServers().values()) { if (serverInfo.getPlayers().size() > 0) { pm.send(serverInfo); } } if (pm.getSendTo().size() < getProxy().getServers().size()) { // plugin message wasn't sent to all servers because no players where online, queue it pmQueue.put(pm.getCommand(), pm); } else { // remove previously queued plugin message if we already send a newer one pmQueue.remove(pm.getCommand()); } }