Java Code Examples for io.netty.buffer.ByteBuf.writeBoolean()

The following are Jave code examples for showing how to use writeBoolean() of the io.netty.buffer.ByteBuf class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: pnc-repressurized   File: AmadronOfferCustom.java   Source Code and License Vote up 6 votes
public void writeToBuf(ByteBuf buf) {
    ByteBufUtils.writeUTF8String(buf, offeringPlayerName);
    ByteBufUtils.writeUTF8String(buf, offeringPlayerId);
    if (providingPosition != null) {
        buf.writeBoolean(true);
        buf.writeInt(providingPosition.getX());
        buf.writeInt(providingPosition.getY());
        buf.writeInt(providingPosition.getZ());
        buf.writeInt(providingDimensionId);
    } else {
        buf.writeBoolean(false);
    }
    if (returningPosition != null) {
        buf.writeBoolean(true);
        buf.writeInt(returningPosition.getX());
        buf.writeInt(returningPosition.getY());
        buf.writeInt(returningPosition.getZ());
        buf.writeInt(returningDimensionId);
    } else {
        buf.writeBoolean(false);
    }
    buf.writeInt(inStock);
    buf.writeInt(maxTrades);
    buf.writeInt(pendingPayments);
}
 
Example 2
Project: ArcaneMagic   File: PacketNotebookToastOrFail.java   Source Code and License Vote up 5 votes
@Override
public void toBytes(ByteBuf buf)
{
	if (cat != null)
	{
		buf.writeInt(ArcaneMagicAPI.getNotebookCategories().indexOf(cat));
	} else
	{
		buf.writeInt(-1);
	}
	buf.writeBoolean(showIfFail);
}
 
Example 3
Project: interactionwheel   File: PacketPerformAction.java   Source Code and License Vote up 5 votes
@Override
public void toBytes(ByteBuf buf) {
    if (pos != null) {
        buf.writeBoolean(true);
        NetworkTools.writePos(buf, pos);
    } else {
        buf.writeBoolean(false);
    }
    NetworkTools.writeString(buf, actionId);
    buf.writeBoolean(extended);
}
 
Example 4
Project: RockSolid   File: PacketMovement.java   Source Code and License Vote up 5 votes
@Override
public void toBuffer(ByteBuf buf) throws IOException
{
	buf.writeBytes(this.uuid.toString().getBytes(StandardCharsets.UTF_8));
	buf.writeDouble(this.motionY);
	buf.writeDouble(this.fallStartY);
	buf.writeBoolean(this.isFalling);
	buf.writeDouble(this.playerX);
	buf.writeDouble(this.playerY);
}
 
Example 5
Project: FlexMC   File: MessageS27EntityRelMoveLook.java   Source Code and License Vote up 5 votes
@Override
public void write( ByteBuf buf ) throws IOException {
    writeVarInt( entityId, buf );
    buf.writeShort( deltaX );
    buf.writeShort( deltaY );
    buf.writeShort( deltaZ );
    buf.writeByte( toAngle( yaw ) );
    buf.writeByte( toAngle( pitch ) );
    buf.writeBoolean( onGround );
}
 
Example 6
Project: Proyecto-DASI   File: AbsoluteMovementCommandsImplementation.java   Source Code and License Vote up 5 votes
@Override
public void toBytes(ByteBuf buf)
{
    buf.writeDouble(this.x);
    buf.writeDouble(this.y);
    buf.writeDouble(this.z);
    buf.writeFloat(this.yaw);
    buf.writeFloat(this.pitch);

    buf.writeBoolean(this.setX);
    buf.writeBoolean(this.setY);
    buf.writeBoolean(this.setZ);
    buf.writeBoolean(this.setYaw);
    buf.writeBoolean(this.setPitch);
}
 
Example 7
Project: RakNetty   File: AcknowledgePacket.java   Source Code and License Vote up 5 votes
@Override
public void write(RakNetByteBuf out) {
    super.write(out);
    ByteBuf buf = Unpooled.buffer();

    int recodeCnt = 0;

    Integer[] records = this.records.toArray(new Integer[0]);
    Arrays.sort(records);

    for (int i = 0; i < records.length; i++) {
        int indexStart = records[i];
        int indexEnd = indexStart;

        while (i + 1 < records.length && records[i + 1] == (indexEnd + 1)) {
            indexEnd++;
            i++;
        }

        if (indexStart == indexEnd) {
            buf.writeBoolean(true); //No range
            buf.writeMediumLE(indexStart);
            recodeCnt++;
        } else {
            buf.writeBoolean(false); //Range
            buf.writeMediumLE(indexStart);
            buf.writeMediumLE(indexEnd);
            recodeCnt++;
        }
    }

    out.writeShort(recodeCnt);
    out.writeBytes(buf);
}
 
Example 8
Project: Proyecto-DASI   File: DiscreteMovementCommandsImplementation.java   Source Code and License Vote up 5 votes
@Override
public void toBytes(ByteBuf buf)
{
    buf.writeInt(this.pos.getX());
    buf.writeInt(this.pos.getY());
    buf.writeInt(this.pos.getZ());
    ByteBufUtils.writeItemStack(buf, this.itemStack);
    buf.writeInt(this.face.ordinal());
    buf.writeBoolean(this.standOnPlacedBlock);
}
 
Example 9
Project: JungleTree   File: TextMessageCodec.java   Source Code and License Vote up 4 votes
@Override
public void encode(Packet msg, ByteBuf buf) {
    TextMessagePacket packet = (TextMessagePacket) msg;
    TextMessageType type = packet.getMessage().getType();

    buf.writeByte(type.getOrdinal());
    buf.writeBoolean(packet.isLocalized());

    switch (type) {
        case RAW: {
            encodeRaw(buf, ((RawMessage) packet.getMessage()));
            break;
        }
        case CHAT: {
            encodeChat(buf, ((ChatMessage) packet.getMessage()));
            break;
        }
        case LOCALIZED: {
            encodeLocalized(buf, ((LocalizedMessage) packet.getMessage()));
            break;
        }
        case POPUP: {
            encodePopup(buf, ((PopupMessage) packet.getMessage()));
            break;
        }
        case JUKEBOX_POPUP: {
            encodeJukeboxPopup(buf, ((JukeboxPopupMessage) packet.getMessage()));
            break;
        }
        case TIP: {
            encodeTip(buf, ((TipMessage) packet.getMessage()));
            break;
        }
        case SYSTEM: {
            encodeSystem(buf, ((SystemMessage) packet.getMessage()));
            break;
        }
        case WHISPER: {
            encodeWhisper(buf, ((WhisperMessage) packet.getMessage()));
            break;
        }
        case ANNOUNCEMENT: {
            encodeAnnouncement(buf, ((AnnouncementMessage) packet.getMessage()));
            break;
        }
    }
}
 
Example 10
Project: SimpleTubes   File: PacketDisplacerSync.java   Source Code and License Vote up 4 votes
@Override
public void toBytes(ByteBuf buf) {
	buf.writeInt(this.tile.getWorld().provider.getDimension());
	buf.writeLong(this.tile.getPos().toLong());
	buf.writeBoolean(this.hasFilter);
}
 
Example 11
Project: angel   File: RegLoss.java   Source Code and License Vote up 4 votes
@Override
public void serialize(ByteBuf buf) {
  buf.writeInt(interceptIndex);
  buf.writeBoolean(fitIntercept);
  buf.writeBoolean(standardization);
}
 
Example 12
Project: Ye-Olde-Chat   File: MessageSyncRoleplayMode.java   Source Code and License Vote up 4 votes
@Override
public void toBytes(ByteBuf buf)
{
	buf.writeBoolean(roleplayMode);
}
 
Example 13
Project: SurvivalMMO   File: HandshakeAnswer.java   Source Code and License Vote up 4 votes
@Override
public void writeData(ByteBuf buf) {
    buf.writeInt(mProtcolVersion);
    buf.writeBoolean(status);
}
 
Example 14
Project: FirstAid   File: MessageApplyHealingItem.java   Source Code and License Vote up 4 votes
@Override
public void toBytes(ByteBuf buf) {
    buf.writeByte(part.id);
    buf.writeBoolean(hand == EnumHand.MAIN_HAND);
}
 
Example 15
Project: Firma   File: KnapToServer.java   Source Code and License Vote up 4 votes
@Override
public void toBytes(ByteBuf buf) {
	buf.writeInt(x);
	buf.writeInt(y);
	buf.writeBoolean(b);
}
 
Example 16
Project: Minecoprocessors   File: MessageEnableGuiUpdates.java   Source Code and License Vote up 4 votes
@Override
public void toBytes(ByteBuf buf) {
  buf.writeLong(pos.toLong());
  buf.writeBoolean(enable);
}
 
Example 17
Project: harshencastle   File: MessagePacketSpawnItemParticles.java   Source Code and License Vote up 4 votes
@Override
public void toBytes(ByteBuf buf) {		
	buf.writeDouble(position.x);
	buf.writeDouble(position.y);
	buf.writeDouble(position.z);
	
	buf.writeDouble(directionSpeed.x);
	buf.writeDouble(directionSpeed.y);
	buf.writeDouble(directionSpeed.z);
	
	ByteBufUtils.writeItemStack(buf, stack);
	
	buf.writeFloat(scale);
	
	buf.writeBoolean(disableMoving);
	
	buf.writeInt(timesSpawn);
	
	ByteBufUtils.writeUTF8String(buf, tag);
	
}
 
Example 18
Project: PAYDAY   File: PacketSyncPlayerPropertiesServer.java   Source Code and License Vote up 4 votes
@Override
public void toBytes(ByteBuf buf) {
	buf.writeBoolean(inLobby);
	buf.writeBoolean(ready);
}
 
Example 19
Project: reactive-pg-client   File: DataType.java   Source Code and License Vote up 4 votes
@Override
public void encodeBinary(Boolean value, ByteBuf buff) {
  buff.writeInt(1);
  buff.writeBoolean(value);
}
 
Example 20
Project: hekate   File: NettyMessageTest.java   Source Code and License Vote up 4 votes
@Test
public void testPreview() throws Exception {
    ByteBuf buf = Unpooled.buffer();

    buf.writeByte(10);
    buf.writeBoolean(true);
    buf.writeInt(100);
    buf.writeLong(1000);
    buf.writeDouble(1.01);

    NettyMessage msg = new NettyMessage(buf, new Codec<Object>() {
        @Override
        public boolean isStateful() {
            return false;
        }

        @Override
        public Class<Object> baseType() {
            return Object.class;
        }

        @Override
        public Object decode(DataReader in) throws IOException {
            throw new AssertionError("Should not be called.");
        }

        @Override
        public void encode(Object obj, DataWriter out) throws IOException {
            throw new AssertionError("Should not be called.");
        }
    });

    assertEquals((byte)10, (byte)msg.preview(DataInput::readByte));
    assertEquals(0, buf.readerIndex());

    assertTrue(msg.previewBoolean(m -> {
        m.skipBytes(1);

        return m.readBoolean();
    }));
    assertEquals(0, buf.readerIndex());

    assertEquals(100, msg.previewInt(m -> {
        m.skipBytes(2);

        return m.readInt();
    }));
    assertEquals(0, buf.readerIndex());

    assertEquals(1000, msg.previewLong(m -> {
        m.skipBytes(6);

        return m.readLong();
    }));
    assertEquals(0, buf.readerIndex());

    assertEquals(1.01, msg.previewDouble(m -> {
        m.skipBytes(14);

        return m.readDouble();
    }), 1000);
    assertEquals(0, buf.readerIndex());

    assertEquals(1, buf.refCnt());

    msg.release();

    assertEquals(0, buf.refCnt());
}