Example usage for io.netty.buffer ByteBuf writeDouble

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

Introduction

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

Prototype

public abstract ByteBuf writeDouble(double value);

Source Link

Document

Sets the specified 64-bit floating point number at the current writerIndex and increases the writerIndex by 8 in this buffer.

Usage

From source file:mal.carbonization.network.TunnelBoreMessageServer.java

License:Open Source License

@Override
public void toBytes(ByteBuf buf) {
    buf.writeInt(xpos);//from w  w  w.  j  a  v a 2s .c  om
    buf.writeInt(ypos);
    buf.writeInt(zpos);
    buf.writeInt(xSize);
    buf.writeInt(ySize);
    buf.writeInt(facing);
    buf.writeInt(cycles);
    buf.writeInt(maxDigCooldown);
    buf.writeInt(digCooldown);
    buf.writeInt(fuelStack);
    buf.writeInt(maxFuel);
    buf.writeBoolean(digSilkTouch);
    buf.writeBoolean(digIgnoreHardness);
    buf.writeInt(digFortuneLevel);
    buf.writeBoolean(hollowScaffold);
    buf.writeDouble(fuelMultiplyer);
    buf.writeBoolean(fixedPosition);
    buf.writeBoolean(voidUpgrade);
    buf.writeBoolean(inventory);
    if (inventory) {
        byte[] i = ItemStacktoByteArray(upgradeSlots);
        buf.writeInt(i.length);
        buf.writeInt(upgradeSlots.length);
        buf.writeBytes(i);
        byte[] o = ItemStacktoByteArray(dimensionStack);
        buf.writeInt(o.length);
        buf.writeInt(dimensionStack.length);
        buf.writeBytes(o);
    }
}

From source file:matteroverdrive.network.packet.bi.PacketFirePlasmaShot.java

License:Open Source License

@Override
public void toBytes(ByteBuf buf) {
    shot.writeTo(buf);/*from w  w w.j  a  va2s. co m*/
    buf.writeInt(sender);
    buf.writeDouble(position.xCoord);
    buf.writeDouble(position.yCoord);
    buf.writeDouble(position.zCoord);
    buf.writeFloat((float) direction.xCoord);
    buf.writeFloat((float) direction.yCoord);
    buf.writeFloat((float) direction.zCoord);
}

From source file:mca.network.PacketCodec.java

License:Open Source License

public void encode(Packet packet, ChannelHandlerContext context, ByteBuf buffer) {
    EnumPacketType type = (EnumPacketType) packet.packetType;

    try {//from ww w .j a v  a2s .  c  o m
        switch (type) {
        case AddAI:
            buffer.writeInt((Integer) packet.arguments[0]);
            break;

        case AddBaby:
            buffer.writeBoolean((Boolean) packet.arguments[0]);
            break;

        case ArrangedMarriageParticles:
            buffer.writeInt((Integer) packet.arguments[0]);
            buffer.writeInt((Integer) packet.arguments[1]);
            break;

        case BabyInfo:
            writeObject(buffer, packet.arguments[0]);
            break;

        case BroadcastKillEntity:
            buffer.writeInt((Integer) packet.arguments[0]);
            break;

        case AddBabyRequest:
            writeObject(buffer, packet.arguments[0]);
            writeObject(buffer, packet.arguments[1]);
            break;

        case AddMarriageRequest:
            writeObject(buffer, packet.arguments[0]);
            writeObject(buffer, packet.arguments[1]);
            break;

        case RemoveBabyRequest:
            writeObject(buffer, packet.arguments[0]);
            break;

        case RemoveMarriageRequest:
            writeObject(buffer, packet.arguments[0]);
            break;

        case ClientSideCommand:
            writeObject(buffer, packet.arguments[0]);
            break;

        case GiveRelationshipGift:
            buffer.writeInt((Integer) packet.arguments[0]);
            break;

        case GiveAid:
            buffer.writeInt((Integer) packet.arguments[0]);
            break;

        case Engagement:
            buffer.writeInt((Integer) packet.arguments[0]);
            break;

        case ForceRespawn:
            buffer.writeInt((Integer) packet.arguments[0]);
            buffer.writeInt((Integer) packet.arguments[1]);
            buffer.writeInt((Integer) packet.arguments[2]);
            buffer.writeInt((Integer) packet.arguments[3]);
            break;

        case GetTombstoneText:
            buffer.writeInt((Integer) packet.arguments[0]);
            buffer.writeInt((Integer) packet.arguments[1]);
            buffer.writeInt((Integer) packet.arguments[2]);
            break;

        case HaveBaby:
            buffer.writeInt((Integer) packet.arguments[0]);
            buffer.writeInt((Integer) packet.arguments[1]);
            break;

        case KillEntity:
            buffer.writeInt((Integer) packet.arguments[0]);
            break;

        case MountHorse:
            buffer.writeInt((Integer) packet.arguments[0]);
            buffer.writeInt((Integer) packet.arguments[1]);
            break;

        case NameBaby:
            buffer.writeInt((Integer) packet.arguments[0]);
            buffer.writeBoolean((Boolean) packet.arguments[1]);
            break;

        case NotifyPlayer:
            buffer.writeInt((Integer) packet.arguments[0]);
            writeObject(buffer, packet.arguments[1]);
            break;

        case OpenGui:
            buffer.writeInt((Integer) packet.arguments[0]);
            buffer.writeByte((Byte) packet.arguments[1]);
            break;
        case PlayerMarriage:
            buffer.writeInt((Integer) packet.arguments[0]);
            writeObject(buffer, packet.arguments[1]);
            buffer.writeInt((Integer) packet.arguments[2]);
            break;

        case RemoveItem:
            buffer.writeInt((Integer) packet.arguments[0]);
            buffer.writeInt((Integer) packet.arguments[1]);
            buffer.writeInt((Integer) packet.arguments[2]);
            buffer.writeInt((Integer) packet.arguments[3]);
            break;

        case ReturnInventory:
            buffer.writeInt((Integer) packet.arguments[0]);
            break;

        case SayLocalized:
            boolean hasPlayer = packet.arguments[0] != null;
            boolean hasEntity = packet.arguments[1] != null;
            boolean hasPrefix = packet.arguments[4] != null;
            boolean hasSuffix = packet.arguments[5] != null;

            buffer.writeBoolean(hasPlayer);
            buffer.writeBoolean(hasEntity);
            buffer.writeBoolean(hasPrefix);
            buffer.writeBoolean(hasSuffix);

            if (hasPlayer) {
                writeObject(buffer, ((EntityPlayer) packet.arguments[0]).getCommandSenderName());
            }

            if (hasEntity) {
                buffer.writeInt(((AbstractEntity) packet.arguments[1]).getEntityId());
            }

            writeObject(buffer, packet.arguments[2]);
            buffer.writeBoolean((Boolean) packet.arguments[3]);

            if (hasPrefix) {
                writeObject(buffer, packet.arguments[4]);
            }

            if (hasSuffix) {
                writeObject(buffer, packet.arguments[5]);
            }

            break;

        case SetChore:
            buffer.writeInt((Integer) packet.arguments[0]);
            writeObject(buffer, packet.arguments[1]);
            break;

        case SetFamilyTree:
            buffer.writeInt((Integer) packet.arguments[0]);
            writeObject(buffer, packet.arguments[1]);
            break;

        case SetFieldValue:
            buffer.writeInt((Integer) packet.arguments[0]);
            writeObject(buffer, packet.arguments[1]);
            writeObject(buffer, packet.arguments[2]);
            break;

        case SetInventory:
            buffer.writeInt((Integer) packet.arguments[0]);
            writeObject(buffer, packet.arguments[1]);
            break;

        case SetPosition:
            buffer.writeInt((Integer) packet.arguments[0]);
            buffer.writeDouble((Double) packet.arguments[1]);
            buffer.writeDouble((Double) packet.arguments[2]);
            buffer.writeDouble((Double) packet.arguments[3]);
            break;

        case SetTarget:
            buffer.writeInt((Integer) packet.arguments[0]);
            buffer.writeInt((Integer) packet.arguments[1]);
            break;

        case SetTombstoneText:
            buffer.writeInt((Integer) packet.arguments[0]);
            buffer.writeInt((Integer) packet.arguments[1]);
            buffer.writeInt((Integer) packet.arguments[2]);
            writeObject(buffer, packet.arguments[3]);
            writeObject(buffer, packet.arguments[4]);
            writeObject(buffer, packet.arguments[5]);
            writeObject(buffer, packet.arguments[6]);
            break;

        case SetWorldProperties:
            writeObject(buffer, packet.arguments[0]);
            break;

        case StartTrade:
            buffer.writeInt((Integer) packet.arguments[0]);
            break;

        case StopJumping:
            buffer.writeInt((Integer) packet.arguments[0]);
            break;

        case SwingArm:
            buffer.writeInt((Integer) packet.arguments[0]);
            break;

        case SyncEditorSettings:
            buffer.writeInt((Integer) packet.arguments[0]);
            writeObject(buffer, packet.arguments[1]);
            buffer.writeBoolean((Boolean) packet.arguments[2]);
            buffer.writeInt((Integer) packet.arguments[3]);
            buffer.writeFloat((Float) packet.arguments[4]);
            buffer.writeFloat((Float) packet.arguments[5]);
            buffer.writeFloat((Float) packet.arguments[6]);
            buffer.writeInt((Integer) packet.arguments[7]);
            writeObject(buffer, packet.arguments[8]);
            writeObject(buffer, packet.arguments[9]);
            break;

        case SyncRequest:
            buffer.writeInt((Integer) packet.arguments[0]);
            break;

        case Sync:
            buffer.writeInt((Integer) packet.arguments[0]);
            writeObject(buffer, packet.arguments[1]);
            break;

        case UpdateFurnace:
            buffer.writeInt((Integer) packet.arguments[0]);
            buffer.writeBoolean((Boolean) packet.arguments[1]);
            break;

        default:
            break;
        }
    }

    catch (Throwable e) {
        MCA.getInstance().getLogger().log(e);
    }
}

From source file:mca.network.packets.PacketSetPosition.java

License:Open Source License

@Override
public void toBytes(ByteBuf byteBuf) {
    byteBuf.writeInt(entityId);//  ww  w.j  ava 2 s .  com
    byteBuf.writeDouble(posX);
    byteBuf.writeDouble(posY);
    byteBuf.writeDouble(posZ);
}

From source file:minechess.common.network.PacketSpawnParticle.java

License:LGPL

@Override
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
    super.encodeInto(ctx, buffer);
    ByteBufUtils.writeUTF8String(buffer, particleName);
    buffer.writeDouble(dx);
    buffer.writeDouble(dy);/*from  w ww .  ja  v  a2 s .  c o  m*/
    buffer.writeDouble(dz);
}

From source file:net.mechanicalcat.pycode.net.InvokeWandMessage.java

License:Open Source License

@Override
public void toBytes(ByteBuf buf) {
    buf.writeDouble(this.traceResult.hitVec.xCoord);
    buf.writeDouble(this.traceResult.hitVec.yCoord);
    buf.writeDouble(this.traceResult.hitVec.zCoord);
    buf.writeShort(this.traceResult.typeOfHit.ordinal());
    switch (this.traceResult.typeOfHit) {
    case ENTITY://from w  ww .  j  a  v a2s . c om
        buf.writeInt(this.traceResult.entityHit.getEntityId());
        break;
    case BLOCK:
        BlockPos blockPos = this.traceResult.getBlockPos();
        buf.writeInt(blockPos.getX());
        buf.writeInt(blockPos.getY());
        buf.writeInt(blockPos.getZ());
        buf.writeShort(this.traceResult.sideHit.ordinal());
    }
}

From source file:net.tridentsdk.data.PropertyBuilder.java

License:Open Source License

@Override
public void write(ByteBuf buf) {
    this.cleanup();

    Codec.writeString(buf, this.key);
    buf.writeDouble(this.value);
    Codec.writeVarInt32(buf, this.modifiers.length);

    for (String s : this.modifiers)
        Codec.writeString(buf, s);
}

From source file:net.tridentsdk.packets.play.out.PacketPlayOutPlayerCompleteMove.java

License:Open Source License

@Override
public void encode(ByteBuf buf) {
    buf.writeDouble(this.location.getX());
    buf.writeDouble(this.location.getY());
    buf.writeDouble(this.location.getZ());

    buf.writeFloat(this.location.getYaw());
    buf.writeFloat(this.location.getPitch());

    buf.writeByte((int) this.flags);
}

From source file:net.tridentsdk.packets.play.out.PacketPlayOutWorldBorder.java

License:Open Source License

@Override
public void encode(ByteBuf buf) {
    Codec.writeVarInt32(buf, this.action);

    for (Object o : this.values) {
        switch (o.getClass().getSimpleName()) {
        case "Double":
            buf.writeDouble((Double) o);
            break;

        case "Integer":
            Codec.writeVarInt32(buf, (Integer) o);
            break;

        case "Long":
            Codec.writeVarInt64(buf, (Long) o);
            break;

        default:// w  w  w  . j a  v  a2s .  c o m
            // ignore bad developers
            break;
        }
    }
}

From source file:net.tridentsdk.server.packets.play.out.PacketPlayOutPlayerCompleteMove.java

License:Apache License

@Override
public void encode(ByteBuf buf) {
    buf.writeDouble(this.location.x());
    buf.writeDouble(this.location.y());
    buf.writeDouble(this.location.z());

    buf.writeFloat(this.location.yaw());
    buf.writeFloat(this.location.pitch());

    buf.writeByte((int) this.flags);
}