List of usage examples for com.google.common.io ByteArrayDataInput readInt
@Override
int readInt();
From source file:com.yogpc.qp.TileMarker.java
@Override protected void C_recievePacket(final byte id, final byte[] data, final EntityPlayer ep) {// onPacketData final ByteArrayDataInput badi = ByteStreams.newDataInput(data); switch (id) { case PacketHandler.StC_LINK_RES: if (this.link != null) this.link.removeConnection(false); this.link = new Link(this.worldObj, badi.readInt(), badi.readInt(), badi.readInt(), badi.readInt(), badi.readInt(), badi.readInt()); this.link.init(); this.link.makeLaser(); //$FALL-THROUGH$ case PacketHandler.StC_UPDATE_MARKER: G_updateSignal();/*w w w .ja va 2 s. co m*/ break; } }
From source file:ocelot.mods.qp2.TileMarkerPlus.java
@Override void C_recievePacket(byte pattern, ByteArrayDataInput data, EntityPlayer ep) {// onPacketData switch (pattern) { case PacketHandler.StC_LINK_RES: if (this.link != null) this.link.removeConnection(false); this.link = new Link(this.worldObj, data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt()); this.link.init(); this.link.makeLaser(); case PacketHandler.StC_UPDATE_MARKER: G_updateSignal();//from w ww .j av a2s. c o m break; } }
From source file:shadowmage.ancient_warfare.common.npcs.NpcBase.java
@Override public void readSpawnData(ByteArrayDataInput data) { this.teamNum = data.readInt(); this.rank = data.readInt(); INpcType t = NpcTypeBase.getNpcType(data.readInt()); this.setNpcType(t, rank); }
From source file:shadowmage.ancient_warfare.common.vehicles.VehicleBase.java
@Override public void readSpawnData(ByteArrayDataInput data) { this.setHealth(data.readFloat()); IVehicleType type = VehicleType.getVehicleType(data.readInt()); this.setVehicleType(type, data.readInt()); this.upgradeHelper.readFromNBT(ByteTools.readNBTTagCompound(data)); this.ammoHelper.readFromNBT(ByteTools.readNBTTagCompound(data)); this.moveHelper.readFromNBT(ByteTools.readNBTTagCompound(data)); this.firingHelper.readFromNBT(ByteTools.readNBTTagCompound(data)); this.firingVarsHelper.readFromNBT(ByteTools.readNBTTagCompound(data)); this.localLaunchPower = data.readFloat(); this.localTurretPitch = data.readFloat(); this.localTurretRotation = data.readFloat(); this.localTurretDestPitch = data.readFloat(); this.localTurretDestRot = data.readFloat(); this.firingHelper.clientLaunchSpeed = localLaunchPower; this.firingHelper.clientTurretPitch = localTurretPitch; this.firingHelper.clientTurretYaw = localTurretRotation; this.upgradeHelper.updateUpgradeStats(); this.teamNum = data.readInt(); this.localTurretRotationHome = data.readFloat(); this.isSettingUp = data.readBoolean(); if (this.isSettingUp) { this.setupTicks = data.readInt(); }// w w w . ja va 2 s . c o m this.setPosition(posX, posY, posZ);//this is to reset the bounding box, because the size of the entity changed during vehicleType setup }
From source file:com.yogpc.qp.TilePump.java
@Override protected void C_recievePacket(final byte id, final byte[] data, final EntityPlayer ep) { final ByteArrayDataInput badi = ByteStreams.newDataInput(data); switch (id) { case PacketHandler.StC_NOW:// B final byte flag = badi.readByte(); if ((flag & 0x80) != 0) this.cy = this.py = -1; else/*from w w w . j a va 2 s. co m*/ this.py = Integer.MIN_VALUE; this.connectTo = ForgeDirection.getOrientation(flag & 0x7F); this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); break; case PacketHandler.StC_OPENGUI_MAPPING:// BI[Ljava.lang.String; final byte target = badi.readByte(); final int len = badi.readInt(); this.mapping[target].clear(); for (int i = 0; i < len; i++) this.mapping[target].add(badi.readUTF()); ep.openGui(QuarryPlus.instance, QuarryPlus.guiIdPump + target, this.worldObj, this.xCoord, this.yCoord, this.zCoord); break; } }
From source file:org.yogpstop.qp.TilePump.java
@Override void C_recievePacket(byte pattern, ByteArrayDataInput data, EntityPlayer ep) { switch (pattern) { case PacketHandler.StC_NOW:// B byte flag = data.readByte(); if ((flag & 0x80) != 0) this.cy = this.currentHeight = -1; else//from w w w.ja v a2s.c om this.currentHeight = Integer.MIN_VALUE; this.connectTo = ForgeDirection.getOrientation(flag & 0x7F); this.worldObj.markBlockForRenderUpdate(this.xCoord, this.yCoord, this.zCoord); break; case PacketHandler.StC_OPENGUI_MAPPING:// BI[Ljava.lang.String; byte target = data.readByte(); int len = data.readInt(); this.mapping[target].clear(); for (int i = 0; i < len; i++) this.mapping[target].add(data.readUTF()); ep.openGui(QuarryPlus.instance, QuarryPlus.guiIdPump + target, this.worldObj, this.xCoord, this.yCoord, this.zCoord); break; } }
From source file:ocelot.mods.qp2.TilePumpPlus.java
@Override void C_recievePacket(byte pattern, ByteArrayDataInput data, EntityPlayer ep) { switch (pattern) { case PacketHandler.StC_NOW:// B byte flag = data.readByte(); if ((flag & 0x80) != 0) this.cy = this.currentHeight = -1; else//w ww . j a va 2s . c o m this.currentHeight = Integer.MIN_VALUE; this.connectTo = ForgeDirection.getOrientation(flag & 0x7F); this.worldObj.markBlockForRenderUpdate(this.xCoord, this.yCoord, this.zCoord); break; case PacketHandler.StC_OPENGUI_MAPPING:// BI[Ljava.lang.String; byte target = data.readByte(); int len = data.readInt(); this.mapping[target].clear(); for (int i = 0; i < len; i++) this.mapping[target].add(data.readUTF()); ep.openGui(QuarryPlus2.instance, QuarryPlus2.guiIdPump + target, this.worldObj, this.xCoord, this.yCoord, this.zCoord); break; } }
From source file:com.yogpc.qp.tile.TilePump.java
@Override public void C_recievePacket(final byte id, final byte[] data, final EntityPlayer ep) { final ByteArrayDataInput badi = ByteStreams.newDataInput(data); switch (id) { case PacketHandler.StC_NOW:// B final byte flag = badi.readByte(); if ((flag & 0x80) != 0) this.cy = this.py = -1; else//from ww w. j ava2 s . c o m this.py = Integer.MIN_VALUE; this.connectTo = ForgeDirection.getOrientation(flag & 0x7F); this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); break; case PacketHandler.StC_OPENGUI_MAPPING:// BI[Ljava.lang.String; final byte target = badi.readByte(); final int len = badi.readInt(); this.mapping[target].clear(); for (int i = 0; i < len; i++) this.mapping[target].add(badi.readUTF()); ep.openGui(QuarryPlus.I, QuarryPlusI.guiIdPump + target, this.worldObj, this.xCoord, this.yCoord, this.zCoord); break; } }
From source file:io.github.leonardosnt.bungeechannelapi.BungeeChannelApi.java
@SuppressWarnings("unchecked") private void onPluginMessageReceived(String channel, Player player, byte[] message) { if (!channel.equalsIgnoreCase("BungeeCord")) return;//from w w w. j ava2s .c o m ByteArrayDataInput input = ByteStreams.newDataInput(message); String subchannel = input.readUTF(); synchronized (callbackMap) { Queue<CompletableFuture<?>> callbacks; if (subchannel.equals("PlayerCount") || subchannel.equals("PlayerList") || subchannel.equals("UUIDOther") || subchannel.equals("ServerIP")) { String identifier = input.readUTF(); // Server/player name callbacks = callbackMap.get(subchannel + "-" + identifier); if (callbacks == null || callbacks.isEmpty()) { return; } CompletableFuture<?> callback = callbacks.poll(); try { switch (subchannel) { case "PlayerCount": ((CompletableFuture<Integer>) callback).complete(Integer.valueOf(input.readInt())); break; case "PlayerList": ((CompletableFuture<List<String>>) callback) .complete(Arrays.asList(input.readUTF().split(", "))); break; case "UUIDOther": ((CompletableFuture<String>) callback).complete(input.readUTF()); break; case "ServerIP": { String ip = input.readUTF(); int port = input.readUnsignedShort(); ((CompletableFuture<InetSocketAddress>) callback).complete(new InetSocketAddress(ip, port)); break; } } } catch (Exception ex) { callback.completeExceptionally(ex); } return; } callbacks = callbackMap.get(subchannel); if (callbacks == null) { short dataLength = input.readShort(); byte[] data = new byte[dataLength]; input.readFully(data); if (globalForwardListener != null) { globalForwardListener.accept(subchannel, player, data); } if (forwardListeners != null) { synchronized (forwardListeners) { ForwardConsumer listener = forwardListeners.get(subchannel); if (listener != null) { listener.accept(subchannel, player, data); } } } return; } if (callbacks.isEmpty()) { return; } final CompletableFuture<?> callback = callbacks.poll(); try { switch (subchannel) { case "GetServers": ((CompletableFuture<List<String>>) callback) .complete(Arrays.asList(input.readUTF().split(", "))); break; case "GetServer": case "UUID": ((CompletableFuture<String>) callback).complete(input.readUTF()); break; case "IP": { String ip = input.readUTF(); int port = input.readInt(); ((CompletableFuture<InetSocketAddress>) callback).complete(new InetSocketAddress(ip, port)); break; } default: break; } } catch (Exception ex) { callback.completeExceptionally(ex); } } }