Example usage for io.netty.buffer ByteBuf writeBoolean

List of usage examples for io.netty.buffer ByteBuf writeBoolean

Introduction

In this page you can find the example usage for io.netty.buffer ByteBuf writeBoolean.

Prototype

public abstract ByteBuf writeBoolean(boolean value);

Source Link

Document

Sets the specified boolean at the current writerIndex and increases the writerIndex by 1 in this buffer.

Usage

From source file:de.jackwhite20.hftp.shared.packet.ListDirectoryPacket.java

License:Open Source License

@Override
public void write(ByteBuf byteBuf) throws Exception {

    byteBuf.writeInt(listFileData.size());
    for (ListFileData data : listFileData) {
        writeString(byteBuf, data.getName());
        byteBuf.writeFloat(data.getSize());
        writeString(byteBuf, data.getHash());
        byteBuf.writeBoolean(data.isDirectory());
    }/*w w w . j a v  a 2s . c om*/
}

From source file:de.sanandrew.mods.turretmod.entity.projectile.EntityProjectileFlame.java

License:Creative Commons License

@Override
public void writeSpawnData(ByteBuf buffer) {
    super.writeSpawnData(buffer);

    buffer.writeBoolean(this.purifying);
}

From source file:de.sanandrew.mods.turretmod.entity.projectile.EntityTurretProjectile.java

License:Creative Commons License

@Override
public void writeSpawnData(ByteBuf buffer) {
    buffer.writeFloat(this.rotationYaw);
    buffer.writeFloat(this.rotationPitch);
    buffer.writeBoolean(this.shooterCache != null);
    if (this.shooterCache != null) {
        buffer.writeInt(this.shooterCache.getEntityId());
    }//from   w w w  . j a v a  2  s  .com
    buffer.writeBoolean(this.targetCache != null);
    if (this.targetCache != null) {
        buffer.writeInt(this.targetCache.getEntityId());
    }
}

From source file:de.sanandrew.mods.turretmod.entity.turret.EntityTurret.java

License:Creative Commons License

@Override
public void writeSpawnData(ByteBuf buffer) {
    UUID turretId = this.delegate.getId();
    buffer.writeLong(turretId.getMostSignificantBits());
    buffer.writeLong(turretId.getLeastSignificantBits());

    NBTTagCompound targetNbt = new NBTTagCompound();
    this.targetProc.writeToNbt(targetNbt);
    ByteBufUtils.writeTag(buffer, targetNbt);

    NBTTagCompound upgNbt = new NBTTagCompound();
    this.upgProc.writeToNbt(upgNbt);
    ByteBufUtils.writeTag(buffer, upgNbt);

    buffer.writeBoolean(this.isUpsideDown);

    if (this.ownerUUID != null) {
        buffer.writeBoolean(true);/*  ww w . j av a 2s  . com*/
        buffer.writeLong(this.ownerUUID.getMostSignificantBits());
        buffer.writeLong(this.ownerUUID.getLeastSignificantBits());
        ByteBufUtils.writeUTF8String(buffer, this.ownerName);
    } else {
        buffer.writeBoolean(false);
    }

    this.delegate.writeSpawnData(this, buffer);
}

From source file:de.sanandrew.mods.turretmod.network.PacketUpdateTargets.java

License:Creative Commons License

@Override
public void toBytes(ByteBuf buf) {
    buf.writeInt(this.turretID);
    buf.writeInt(this.entityTargets.size());
    for (Class entityTarget : this.entityTargets) {
        ByteBufUtils.writeUTF8String(buf, entityTarget.getName());
    }/*  w w w.  j  ava2s . c o m*/
    buf.writeInt(this.playerTargets.length);
    for (UUID playerTarget : this.playerTargets) {
        ByteBufUtils.writeUTF8String(buf, playerTarget.toString());
    }
    buf.writeBoolean(this.isBlacklistEntity);
    buf.writeBoolean(this.isBlacklistPlayer);
}

From source file:de.sanandrew.mods.turretmod.network.PacketUpdateTurretState.java

License:Creative Commons License

@Override
public void toBytes(ByteBuf buf) {
    buf.writeInt(this.turretId);
    buf.writeInt(this.entityToAttackId);
    buf.writeInt(this.currAmmoCap);
    buf.writeBoolean(this.isShooting);
    ByteBufUtils.writeItemStack(buf, this.ammoStack);
    buf.writeInt(this.delegateData.length);
    buf.writeBytes(this.delegateData);
}

From source file:de.sanandrew.mods.turretmod.tileentity.assembly.TileEntityTurretAssembly.java

License:Creative Commons License

@Override
public void toBytes(ByteBuf buf) {
    buf.writeInt(this.energyStorage.fluxAmount);
    buf.writeInt(this.fluxConsumption);
    buf.writeBoolean(this.isActive);
    buf.writeInt(this.ticksCrafted);
    buf.writeInt(this.maxTicksCrafted);
    buf.writeBoolean(this.automate);
    buf.writeBoolean(this.isActiveClient);
    if (this.currCrafting != null) {
        ByteBufUtils.writeItemStack(buf, this.currCrafting.getValue(1));
        ByteBufUtils.writeUTF8String(buf, this.currCrafting.getValue(0).toString());
    } else {/*w  w  w .  ja v  a2s .c o m*/
        ByteBufUtils.writeItemStack(buf, ItemStackUtils.getEmpty());
    }
}

From source file:de.sanandrew.mods.turretmod.tileentity.electrolytegen.TileEntityElectrolyteGenerator.java

License:Creative Commons License

@Override
public void toBytes(ByteBuf buf) {
    buf.writeInt(this.energyStorage.fluxAmount);
    buf.writeFloat(this.effectiveness);
    for (ElectrolyteProcess process : this.processes) {
        if (process != null) {
            buf.writeBoolean(true);
            process.writeToByteBuf(buf);
        } else {/*from  w  w w  .ja v a 2  s .  c o m*/
            buf.writeBoolean(false);
        }
    }
}

From source file:de.unipassau.isl.evs.ssh.core.network.UDPDiscoveryClient.java

License:Open Source License

/**
 * Send a single UDP discovery request. It contains of {@link CoreConstants.NettyConstants#DISCOVERY_PAYLOAD_REQUEST}
 * as header followed by the Public Key of the sought-after Master.
 * Both byte arrays are prefixed by their length as int.
 *
 * @return the ChannelFuture returned by {@link io.netty.channel.Channel#write(Object)}
 *//* w ww .j  av  a2s . co  m*/
private ChannelFuture sendDiscoveryRequest() {
    final NamingManager namingManager = requireComponent(NamingManager.KEY);
    if (namingManager.isMasterIDKnown()) {
        Log.v(TAG, "sendDiscoveryRequest looking for Master " + namingManager.getMasterID());
    } else {
        Log.v(TAG, "sendDiscoveryRequest looking for any Master");
    }

    final byte[] header = DISCOVERY_PAYLOAD_REQUEST.getBytes();
    final byte[] ownIDBytes = namingManager.getOwnID().getIDBytes();
    final ByteBuf buffer = channel.channel().alloc().buffer();
    buffer.writeInt(header.length);
    buffer.writeBytes(header);
    buffer.writeInt(ownIDBytes.length);
    buffer.writeBytes(ownIDBytes);

    if (namingManager.isMasterIDKnown()) {
        buffer.writeBoolean(true);
        final byte[] masterIDBytes = namingManager.getMasterID().getIDBytes();
        buffer.writeInt(masterIDBytes.length);
        buffer.writeBytes(masterIDBytes);
    } else {
        buffer.writeBoolean(false);
    }

    final InetSocketAddress recipient = new InetSocketAddress(DISCOVERY_HOST, DISCOVERY_SERVER_PORT);
    final DatagramPacket request = new DatagramPacket(buffer, recipient);
    return channel.channel().writeAndFlush(request);
}

From source file:eu.xworlds.util.raknet.protocol.ConnectionRequest.java

License:Open Source License

@Override
public ByteBuf encode() {
    int size = 1 + SIZE_GUID + SIZE_TIME + 1;
    if (this.doSecurity) {
        size += 32 + 1;//  www . ja v  a  2 s.  c  om
        if (this.doIdentity) {
            size += EASYHANDSHAKE_IDENTITY_BYTES;
        }
    }
    final ByteBuf buf = Unpooled.buffer(size);
    buf.order(ByteOrder.BIG_ENDIAN);
    buf.writeByte(ID);
    writeGuid(buf, this.clientGuid);
    writeTime(buf, this.time);
    buf.writeBoolean(this.doSecurity);
    if (this.doSecurity) {
        buf.writeBytes(this.proof);
        buf.writeBoolean(this.doIdentity);
        if (this.doIdentity) {
            buf.writeBytes(this.identity);
        }
    }
    return buf;
}