List of usage examples for io.netty.buffer ByteBuf readBoolean
public abstract boolean readBoolean();
From source file:com.parachute.common.AscendKeyPressMessage.java
License:Open Source License
@Override public void fromBytes(ByteBuf bb) { keyPressed = bb.readBoolean(); }
From source file:com.parachute.common.KeyPressMessage.java
License:Open Source License
@Override public void fromBytes(ByteBuf bb) { keyCode = bb.readInt(); keyPressed = bb.readBoolean(); }
From source file:com.seventh_root.ld33.client.network.LD33ClientBoundPacketDecoder.java
License:Apache License
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { byte[] output = new byte[in.readableBytes()]; in.readBytes(output);/* w w w . j av a 2 s . c om*/ System.out.println(Arrays.toString(output)); in.resetReaderIndex(); while (in.isReadable()) { int id = in.readInt(); switch (id) { case 0: byte[] encodedPublicKey = new byte[in.readInt()]; in.readBytes(encodedPublicKey); out.add(new PublicKeyClientBoundPacket(encodedPublicKey)); break; case 1: out.add(new PlayerLoginClientBoundPacket()); break; case 2: String joiningPlayerUUID = readString(in); String joiningPlayerName = readString(in); int joiningPlayerResources = in.readInt(); out.add(new PlayerJoinClientBoundPacket(UUID.fromString(joiningPlayerUUID), joiningPlayerName, joiningPlayerResources)); break; case 3: String quittingPlayerUUID = readString(in); String quittingPlayerName = readString(in); out.add(new PlayerQuitClientBoundPacket(UUID.fromString(quittingPlayerUUID), quittingPlayerName)); break; case 4: String loginResponseMessage = readString(in); boolean loginSuccess = in.readBoolean(); out.add(new PlayerLoginResponseClientBoundPacket(loginResponseMessage, loginSuccess)); break; case 5: String spawningUnitUUID = readString(in); String spawningUnitPlayerUUID = readString(in); int spawningUnitX = in.readInt(); int spawningUnitY = in.readInt(); String type = readString(in); long spawningUnitCompletionTime = in.readLong(); Unit unit; switch (type) { case "wall": unit = new Wall(UUID.fromString(spawningUnitUUID), Player.getByUUID(null, UUID.fromString(spawningUnitPlayerUUID)), client.getWorldPanel().getWorld().getTileAt(spawningUnitX, spawningUnitY), spawningUnitCompletionTime); break; case "dragon": unit = new Dragon(UUID.fromString(spawningUnitUUID), Player.getByUUID(null, UUID.fromString(spawningUnitPlayerUUID)), client.getWorldPanel().getWorld().getTileAt(spawningUnitX, spawningUnitY), spawningUnitCompletionTime); break; case "flag": unit = new Flag(UUID.fromString(spawningUnitUUID), Player.getByUUID(null, UUID.fromString(spawningUnitPlayerUUID)), client.getWorldPanel().getWorld().getTileAt(spawningUnitX, spawningUnitY), spawningUnitCompletionTime); break; default: unit = null; break; } out.add(new UnitSpawnClientBoundPacket(unit)); break; case 6: String movingUnitUUID = readString(in); int movingUnitX = in.readInt(); int movingUnitY = in.readInt(); int movingUnitTargetX = in.readInt(); int movingUnitTargetY = in.readInt(); out.add(new UnitMoveClientBoundPacket( Unit.getByUUID(null, client.getWorldPanel().getWorld(), UUID.fromString(movingUnitUUID)), movingUnitX, movingUnitY, movingUnitTargetX, movingUnitTargetY)); break; case 7: String chatMessage = readString(in); out.add(new ChatMessageClientBoundPacket(chatMessage)); break; case 8: String purchasingPlayerUUID = readString(in); int purchasedUnitX = in.readInt(); int purchasedUnitY = in.readInt(); String purchasedUnitType = readString(in); out.add(new UnitPurchaseClientBoundPacket(UUID.fromString(purchasingPlayerUUID), purchasedUnitX, purchasedUnitY, purchasedUnitType)); break; } } }
From source file:com.seventh_root.ld33.server.network.LD33ServerBoundPacketDecoder.java
License:Apache License
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { while (in.isReadable()) { int id = in.readInt(); switch (id) { case 0:/*from ww w . j a va2s. co m*/ byte[] encodedPublicKey = new byte[in.readInt()]; in.readBytes(encodedPublicKey); out.add(new PublicKeyServerBoundPacket(encodedPublicKey)); break; case 1: String loggingInPlayerName = readString(in); byte[] encryptedPassword = new byte[in.readInt()]; in.readBytes(encryptedPassword); boolean signUp = in.readBoolean(); out.add(new PlayerLoginServerBoundPacket(loggingInPlayerName, encryptedPassword, signUp)); break; case 2: out.add(new PlayerJoinServerBoundPacket()); break; case 3: out.add(new PlayerQuitServerBoundPacket()); break; case 4: String loginResponseMessage = readString(in); boolean loginSuccess = in.readBoolean(); out.add(new PlayerLoginResponseServerBoundPacket(loginResponseMessage, loginSuccess)); break; case 5: String spawningUnitUUID = readString(in); String spawningUnitPlayerUUID = readString(in); int spawningUnitX = in.readInt(); int spawningUnitY = in.readInt(); String spawningUnitType = readString(in); long spawningUnitCompletionTime = in.readLong(); Unit spawningUnit; switch (spawningUnitType) { case "wall": spawningUnit = new Wall(UUID.fromString(spawningUnitUUID), Player.getByUUID(null, UUID.fromString(spawningUnitPlayerUUID)), server.getWorld().getTileAt(spawningUnitX, spawningUnitY), spawningUnitCompletionTime); break; case "dragon": spawningUnit = new Dragon(UUID.fromString(spawningUnitUUID), Player.getByUUID(null, UUID.fromString(spawningUnitPlayerUUID)), server.getWorld().getTileAt(spawningUnitX, spawningUnitY), spawningUnitCompletionTime); break; case "flag": spawningUnit = new Flag(UUID.fromString(spawningUnitUUID), Player.getByUUID(null, UUID.fromString(spawningUnitPlayerUUID)), server.getWorld().getTileAt(spawningUnitX, spawningUnitY), spawningUnitCompletionTime); break; default: spawningUnit = null; break; } out.add(new UnitSpawnServerBoundPacket(spawningUnit)); break; case 6: String movingUnitUUID = readString(in); int movingUnitTargetX = in.readInt(); int movingUnitTargetY = in.readInt(); out.add(new UnitMoveServerBoundPacket(Unit.getByUUID(server.getDatabaseConnection(), server.getWorld(), UUID.fromString(movingUnitUUID)), movingUnitTargetX, movingUnitTargetY)); break; case 7: String chatMessage = readString(in); out.add(new ChatMessageServerBoundPacket(chatMessage)); break; case 8: int purchasedUnitX = in.readInt(); int purchasedUnitY = in.readInt(); String purchasedUnitType = readString(in); out.add(new UnitPurchaseServerBoundPacket(purchasedUnitX, purchasedUnitY, purchasedUnitType)); break; } } }
From source file:com.teambr.bookshelf.network.SyncableFieldPacket.java
License:Creative Commons License
/******************************************************************************************************************* * IMessage * *******************************************************************************************************************/ @Override/*from w w w .j a v a 2 s . com*/ public void fromBytes(ByteBuf buf) { returnValue = buf.readBoolean(); id = buf.readInt(); value = buf.readDouble(); blockPosition = BlockPos.fromLong(buf.readLong()); }
From source file:com.teamdman_9201.flow.TileFloodGate.java
License:Minecraft Mod Public
public void readData(ByteBuf stream) { for (int i = 0; i < 6; i++) { blockedSides[i] = stream.readBoolean(); }//from w w w. ja v a2 s .c o m }
From source file:com.theoriginalbit.moarperipherals.common.network.message.MessageGeneric.java
License:Apache License
@Override public void fromBytes(ByteBuf buf) { int nStr = buf.readInt(); stringData = new String[nStr]; if (nStr > 0) { for (int i = 0; i < nStr; ++i) { stringData[i] = ByteBufUtils.readUTF8String(buf); }/* w ww . j a v a 2 s . c o m*/ } int nInt = buf.readInt(); intData = new int[nInt]; if (nInt > 0) { for (int i = 0; i < nInt; ++i) { intData[i] = buf.readInt(); } } int nByte = buf.readInt(); byteData = new byte[nByte]; if (nByte > 0) { buf.readBytes(byteData); } int nChar = buf.readInt(); charData = new char[nChar]; if (nChar > 0) { for (int i = 0; i < nChar; ++i) { charData[i] = buf.readChar(); } } int nFloat = buf.readInt(); floatData = new float[nFloat]; if (nFloat > 0) { for (int i = 0; i < nFloat; ++i) { floatData[i] = buf.readFloat(); } } int nDouble = buf.readInt(); doubleData = new double[nDouble]; if (nDouble > 0) { for (int i = 0; i < nDouble; ++i) { doubleData[i] = buf.readDouble(); } } boolean wasNBT = buf.readBoolean(); if (wasNBT) { nbtData = ByteBufUtils.readTag(buf); } }
From source file:com.vethrfolnir.login.network.game.received.RequestServerRegistration.java
License:Open Source License
@Override public void read(NetworkClient context, ByteBuf buff, Object... params) { final GameNameService gns = as(params[0]); final ChannelHandlerContext ctx = as(params[1]); final int serverId = readD(buff); final String host = readS(buff); final int port = readD(buff); final int capacity = readD(buff); final String password = readS(buff); final boolean acceptAnyId = buff.readBoolean(); // XXX: Java 8 lambda, make it a closure enqueue(new Runnable() { @Override//from w w w .j a v a2s .com public void run() { GameServer gn = gns.create(ctx, serverId, host, port); gn.setAcceptAnyId(acceptAnyId); gn.setCap(capacity); gns.registerNewServer(gn, password); } }); }
From source file:com.yyon.grapplinghook.entities.grappleArrow.java
License:Open Source License
@Override public void readSpawnData(ByteBuf data) { this.shootingEntityID = data.readInt(); this.shootingEntity = this.worldObj.getEntityByID(this.shootingEntityID); this.righthand = data.readBoolean(); }
From source file:com.yyon.grapplinghook.network.GrappleClickMessage.java
License:Open Source License
@Override public void fromBytes(ByteBuf buf) { this.id = buf.readInt(); this.leftclick = buf.readBoolean(); }