Java Code Examples for io.netty.buffer.ByteBuf#readBoolean()
The following examples show how to use
io.netty.buffer.ByteBuf#readBoolean() .
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: MixMessageDecoder.java From incubator-hivemall with Apache License 2.0 | 6 votes |
@Override protected MixMessage decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception { ByteBuf frame = (ByteBuf) super.decode(ctx, in); if (frame == null) { return null; } byte b = frame.readByte(); MixEventName event = MixEventName.resolve(b); Object feature = decodeObject(frame); float weight = frame.readFloat(); float covariance = frame.readFloat(); short clock = frame.readShort(); int deltaUpdates = frame.readInt(); boolean cancelRequest = frame.readBoolean(); String groupID = readString(frame); MixMessage msg = new MixMessage(event, feature, weight, covariance, clock, deltaUpdates, cancelRequest); msg.setGroupID(groupID); return msg; }
Example 2
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 6 votes |
public static List<ResourcePacksInfoPacket.Entry> readPacksInfoEntries(ByteBuf buffer) { Preconditions.checkNotNull(buffer, "buffer"); List<ResourcePacksInfoPacket.Entry> entries = new ObjectArrayList<>(); int length = buffer.readUnsignedShortLE(); for (int i = 0; i < length; i++) { String packId = readString(buffer); String packVersion = readString(buffer); long packSize = buffer.readLongLE(); String encryptionKey = readString(buffer); String subpackName = readString(buffer); String contentId = readString(buffer); boolean unknownBool = buffer.readBoolean(); entries.add(new ResourcePacksInfoPacket.Entry(packId, packVersion, packSize, encryptionKey, subpackName, contentId, unknownBool)); } return entries; }
Example 3
Source File: InventoryCommandsImplementation.java From malmo with MIT License | 5 votes |
@Override public void fromBytes(ByteBuf buf) { boolean gainedItems = buf.readBoolean(); if (gainedItems) this.itemsGained = ByteBufUtils.readItemStack(buf); boolean lostItems = buf.readBoolean(); if (lostItems) this.itemsLost = ByteBufUtils.readItemStack(buf); }
Example 4
Source File: MessagePresentConnect.java From Chisel-2 with GNU General Public License v2.0 | 5 votes |
@Override public void fromBytes(ByteBuf buf) { super.fromBytes(buf); dir = ForgeDirection.values()[buf.readInt()]; connect = buf.readBoolean(); preserveDir = buf.readBoolean(); }
Example 5
Source File: PacketSettings.java From The-5zig-Mod with MIT License | 5 votes |
@Override public void read(ByteBuf buffer) throws IOException { int i = buffer.readInt(); if (i < 0 || i >= SettingType.values().length) throw new IllegalArgumentException("Received Integer is out of enum range"); this.settingType = SettingType.values()[i]; if (settingType == SettingType.PROFILE_MESSAGE) { this.status = PacketBuffer.readString(buffer); } if (settingType == SettingType.SHOW_CURRENT_SERVER || settingType == SettingType.SHOW_LAST_SEEN_TIME) { this.enabled = buffer.readBoolean(); } }
Example 6
Source File: GetTopicConfigAckCodec.java From joyqueue with Apache License 2.0 | 5 votes |
@Override public Object decode(Header header, ByteBuf buffer) throws Exception { GetTopicConfigAck getTopicConfigAck = new GetTopicConfigAck(); if(buffer.readBoolean()){ getTopicConfigAck.topicConfig(Serializer.readTopicConfig(buffer, header.getVersion())); } return getTopicConfigAck; }
Example 7
Source File: AbsoluteMovementCommandsImplementation.java From malmo with MIT License | 5 votes |
@Override public void fromBytes(ByteBuf buf) { this.x = buf.readDouble(); this.y = buf.readDouble(); this.z = buf.readDouble(); this.yaw = buf.readFloat(); this.pitch = buf.readFloat(); this.setX = buf.readBoolean(); this.setY = buf.readBoolean(); this.setZ = buf.readBoolean(); this.setYaw = buf.readBoolean(); this.setPitch = buf.readBoolean(); }
Example 8
Source File: PlayerLookCodec.java From Cleanstone with MIT License | 5 votes |
@Override public PlayerLookPacket decode(ByteBuf byteBuf) { final float yaw = byteBuf.readFloat(); final float pitch = byteBuf.readFloat(); final boolean onGround = byteBuf.readBoolean(); Preconditions.checkArgument(Float.isFinite(yaw) && Float.isFinite(pitch), "Non-finite rotation " + yaw + ":" + pitch); return new PlayerLookPacket(yaw, pitch, onGround); }
Example 9
Source File: PacketPartyStatus.java From The-5zig-Mod with GNU General Public License v3.0 | 5 votes |
@Override public void read(ByteBuf buffer) throws IOException { action = PacketBuffer.readEnum(buffer, Action.class); switch (action) { case MEMBER_ADD: user = PacketBuffer.readUser(buffer); break; case MEMBER_REMOVE: case TRANSFER_OWNER: memberId = PacketBuffer.readUUID(buffer); break; case ADMIN: memberId = PacketBuffer.readUUID(buffer); flag = buffer.readBoolean(); break; case SWITCH_SERVER: server = PacketBuffer.readString(buffer); break; case SWITCH_SERVER_COMPLETE: memberId = PacketBuffer.readUUID(buffer); break; case CHAT: chatMessageType = PacketBuffer.readEnum(buffer, ChatMessageType.class); switch (chatMessageType) { case NORMAL: chatUsername = PacketBuffer.readString(buffer); chatMessage = PacketBuffer.readString(buffer); break; case BROADCAST: chatMessage = PacketBuffer.readString(buffer); break; default: break; } break; default: break; } }
Example 10
Source File: EntityElevatorCapsule.java From AdvancedRocketry with MIT License | 5 votes |
@Override public void readDataFromNetwork(ByteBuf in, byte packetId, NBTTagCompound nbt) { if(packetId == PACKET_WRITE_DST_INFO || packetId == PACKET_WRITE_SRC_INFO) { if(in.readBoolean()) { nbt.setInteger("dimid", in.readInt()); nbt.setInteger("x", in.readInt()); nbt.setInteger("y", in.readInt()); nbt.setInteger("z", in.readInt()); } } }
Example 11
Source File: Move.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void readClientData(ByteBuf clientdata) { x = clientdata.readDouble(); y = clientdata.readDouble(); clientdata.readDouble(); z = clientdata.readDouble(); onGround = clientdata.readBoolean(); }
Example 12
Source File: TabComplete.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void readClientData(ByteBuf clientdata) { id = 0; string = StringSerializer.readVarIntUTF8String(clientdata, 256); if (string.equals("/")) { string = ""; } if (clientdata.readBoolean()) { PositionSerializer.skipPosition(clientdata); } }
Example 13
Source File: ServerPacketCodec.java From JLilyPad with GNU General Public License v3.0 | 5 votes |
public ServerPacket decode(ByteBuf buffer) throws Exception { boolean addOrRemove = buffer.readBoolean(); String server = BufferUtils.readString(buffer); if(addOrRemove) { return new ServerAddPacket(server, BufferUtils.readString(buffer), BufferUtils.readString(buffer), buffer.readUnsignedShort()); } return new ServerPacket(server); }
Example 14
Source File: StartGameSerializer_v291.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void deserialize(ByteBuf buffer, StartGamePacket packet) { packet.setUniqueEntityId(VarInts.readLong(buffer)); packet.setRuntimeEntityId(VarInts.readUnsignedLong(buffer)); packet.setPlayerGamemode(VarInts.readInt(buffer)); packet.setPlayerPosition(BedrockUtils.readVector3f(buffer)); packet.setRotation(BedrockUtils.readVector2f(buffer)); // Level settings start packet.setSeed(VarInts.readInt(buffer)); packet.setDimensionId(VarInts.readInt(buffer)); packet.setGeneratorId(VarInts.readInt(buffer)); packet.setLevelGamemode(VarInts.readInt(buffer)); packet.setDifficulty(VarInts.readInt(buffer)); packet.setDefaultSpawn(BedrockUtils.readBlockPosition(buffer)); packet.setAchievementsDisabled(buffer.readBoolean()); packet.setTime(VarInts.readInt(buffer)); packet.setEduEditionOffers(buffer.readBoolean() ? 1 : 0); packet.setEduFeaturesEnabled(buffer.readBoolean()); packet.setRainLevel(buffer.readFloatLE()); packet.setLightningLevel(buffer.readFloatLE()); packet.setMultiplayerGame(buffer.readBoolean()); packet.setBroadcastingToLan(buffer.readBoolean()); buffer.readBoolean(); // broadcasting to XBL packet.setCommandsEnabled(buffer.readBoolean()); packet.setTexturePacksRequired(buffer.readBoolean()); BedrockUtils.readArray(buffer, packet.getGamerules(), BedrockUtils::readGameRule); packet.setBonusChestEnabled(buffer.readBoolean()); packet.setStartingWithMap(buffer.readBoolean()); packet.setTrustingPlayers(buffer.readBoolean()); packet.setDefaultPlayerPermission(PLAYER_PERMISSIONS[VarInts.readInt(buffer)]); packet.setXblBroadcastMode(GamePublishSetting.byId(VarInts.readInt(buffer))); packet.setServerChunkTickRange(buffer.readIntLE()); buffer.readBoolean(); // Broadcasting to Platform packet.setPlatformBroadcastMode(GamePublishSetting.byId(VarInts.readInt(buffer))); buffer.readBoolean(); // Intent on XBL broadcast packet.setBehaviorPackLocked(buffer.readBoolean()); packet.setResourcePackLocked(buffer.readBoolean()); packet.setFromLockedWorldTemplate(buffer.readBoolean()); packet.setUsingMsaGamertagsOnly(buffer.readBoolean()); // Level settings end packet.setLevelId(BedrockUtils.readString(buffer)); packet.setWorldName(BedrockUtils.readString(buffer)); packet.setPremiumWorldTemplateId(BedrockUtils.readString(buffer)); packet.setTrial(buffer.readBoolean()); packet.setCurrentTick(buffer.readLongLE()); packet.setEnchantmentSeed(VarInts.readInt(buffer)); int paletteLength = VarInts.readUnsignedInt(buffer); List<CompoundTag> palette = new ObjectArrayList<>(paletteLength); for (int i = 0; i < paletteLength; i++) { palette.add(CompoundTagBuilder.builder() .tag(CompoundTagBuilder.builder() .stringTag("name", BedrockUtils.readString(buffer)) .build("block")) .shortTag("meta", buffer.readShortLE()) .buildRootTag()); } packet.setBlockPalette(new ListTag<>("", CompoundTag.class, palette)); packet.setMultiplayerCorrelationId(BedrockUtils.readString(buffer)); }
Example 15
Source File: PacketUpdateMinecartEngineState.java From Signals with GNU General Public License v3.0 | 4 votes |
@Override public void fromBytes(ByteBuf buffer){ entityId = buffer.readInt(); active = buffer.readBoolean(); }
Example 16
Source File: ReactorCommandEjectMessage.java From BigReactors with MIT License | 4 votes |
@Override public void fromBytes(ByteBuf buf) { super.fromBytes(buf); ejectFuel = buf.readBoolean(); dumpExcess = buf.readBoolean(); }
Example 17
Source File: MiddleInventoryConfirmTransaction.java From ProtocolSupport with GNU Affero General Public License v3.0 | 4 votes |
@Override protected void readServerData(ByteBuf serverdata) { windowId = serverdata.readUnsignedByte(); actionNumber = serverdata.readShort(); accepted = serverdata.readBoolean(); }
Example 18
Source File: StartGameSerializer_v313.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void deserialize(ByteBuf buffer, StartGamePacket packet) { packet.setUniqueEntityId(VarInts.readLong(buffer)); packet.setRuntimeEntityId(VarInts.readUnsignedLong(buffer)); packet.setPlayerGamemode(VarInts.readInt(buffer)); packet.setPlayerPosition(BedrockUtils.readVector3f(buffer)); packet.setRotation(BedrockUtils.readVector2f(buffer)); // Level settings start packet.setSeed(VarInts.readInt(buffer)); packet.setDimensionId(VarInts.readInt(buffer)); packet.setGeneratorId(VarInts.readInt(buffer)); packet.setLevelGamemode(VarInts.readInt(buffer)); packet.setDifficulty(VarInts.readInt(buffer)); packet.setDefaultSpawn(BedrockUtils.readBlockPosition(buffer)); packet.setAchievementsDisabled(buffer.readBoolean()); packet.setTime(VarInts.readInt(buffer)); packet.setEduEditionOffers(buffer.readBoolean() ? 1 : 0); packet.setEduFeaturesEnabled(buffer.readBoolean()); packet.setRainLevel(buffer.readFloatLE()); packet.setLightningLevel(buffer.readFloatLE()); packet.setMultiplayerGame(buffer.readBoolean()); packet.setBroadcastingToLan(buffer.readBoolean()); buffer.readBoolean(); // broadcasting to XBL packet.setCommandsEnabled(buffer.readBoolean()); packet.setTexturePacksRequired(buffer.readBoolean()); BedrockUtils.readArray(buffer, packet.getGamerules(), BedrockUtils::readGameRule); packet.setBonusChestEnabled(buffer.readBoolean()); packet.setStartingWithMap(buffer.readBoolean()); packet.setTrustingPlayers(buffer.readBoolean()); packet.setDefaultPlayerPermission(PLAYER_PERMISSIONS[VarInts.readInt(buffer)]); packet.setXblBroadcastMode(GamePublishSetting.byId(VarInts.readInt(buffer))); packet.setServerChunkTickRange(buffer.readIntLE()); buffer.readBoolean(); // broadcasting to Platform packet.setPlatformBroadcastMode(GamePublishSetting.byId(VarInts.readInt(buffer))); buffer.readBoolean(); // Intent to broadcast XBL packet.setBehaviorPackLocked(buffer.readBoolean()); packet.setResourcePackLocked(buffer.readBoolean()); packet.setFromLockedWorldTemplate(buffer.readBoolean()); packet.setUsingMsaGamertagsOnly(buffer.readBoolean()); packet.setFromWorldTemplate(buffer.readBoolean()); packet.setWorldTemplateOptionLocked(buffer.readBoolean()); // Level settings end packet.setLevelId(BedrockUtils.readString(buffer)); packet.setWorldName(BedrockUtils.readString(buffer)); packet.setPremiumWorldTemplateId(BedrockUtils.readString(buffer)); packet.setTrial(buffer.readBoolean()); packet.setCurrentTick(buffer.readLongLE()); packet.setEnchantmentSeed(VarInts.readInt(buffer)); int paletteLength = VarInts.readUnsignedInt(buffer); List<CompoundTag> palette = new ObjectArrayList<>(paletteLength); for (int i = 0; i < paletteLength; i++) { palette.add(CompoundTagBuilder.builder() .tag(CompoundTagBuilder.builder() .stringTag("name", BedrockUtils.readString(buffer)) .build("block")) .shortTag("meta", buffer.readShortLE()) .buildRootTag()); } packet.setBlockPalette(new ListTag<>("", CompoundTag.class, palette)); packet.setMultiplayerCorrelationId(BedrockUtils.readString(buffer)); }
Example 19
Source File: InventoryTransaction.java From ProtocolSupport with GNU Affero General Public License v3.0 | 4 votes |
@Override protected void readClientData(ByteBuf clientdata) { windowId = clientdata.readUnsignedByte(); actionNumber = clientdata.readShort(); accepted = clientdata.readBoolean(); }
Example 20
Source File: NetworkEntityMetadataObjectOptionalPosition.java From ProtocolSupport with GNU Affero General Public License v3.0 | 4 votes |
@Override public void readFromStream(ByteBuf from) { if (from.readBoolean()) { value = PositionSerializer.readPosition(from); } }