Example usage for io.netty.buffer ByteBuf readFloat

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

Introduction

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

Prototype

public abstract float readFloat();

Source Link

Document

Gets a 32-bit floating point number at the current readerIndex and increases the readerIndex by 4 in this buffer.

Usage

From source file:matteroverdrive.starmap.data.Star.java

License:Open Source License

@Override
public void readFromBuffer(ByteBuf byteBuf) {
    super.readFromBuffer(byteBuf);
    x = byteBuf.readFloat();
    y = byteBuf.readFloat();//from w ww.  ja v a  2  s .  c  o m
    z = byteBuf.readFloat();
    size = byteBuf.readFloat();
    mass = byteBuf.readFloat();
    type = byteBuf.readByte();
    temperature = byteBuf.readInt();
    color = byteBuf.readInt();
    /*int planetCount = byteBuf.readInt();
    for (int i = 0;i < planetCount;i++)
    {
    Planet planet = new Planet();
    planet.readFromBuffer(byteBuf);
    addPlanet(planet);
    planet.setStar(this);
    }*/
}

From source file:mca.network.PacketCodec.java

License:Open Source License

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

    try {/*from w w w .  java  2s . c om*/
        switch (type) {
        case AddAI:
            packet.arguments[0] = buffer.readInt();
            break;

        case AddBaby:
            packet.arguments[0] = buffer.readBoolean();
            break;

        case ArrangedMarriageParticles:
            packet.arguments[0] = buffer.readInt();
            packet.arguments[1] = buffer.readInt();
            break;

        case BabyInfo:
            packet.arguments[0] = readObject(buffer);
            break;

        case BroadcastKillEntity:
            packet.arguments[0] = buffer.readInt();
            break;

        case AddBabyRequest:
            packet.arguments[0] = readObject(buffer);
            packet.arguments[1] = readObject(buffer);
            break;

        case AddMarriageRequest:
            packet.arguments[0] = readObject(buffer);
            packet.arguments[1] = readObject(buffer);
            break;

        case RemoveBabyRequest:
            packet.arguments[0] = readObject(buffer);
            break;

        case RemoveMarriageRequest:
            packet.arguments[0] = readObject(buffer);
            break;

        case ClientSideCommand:
            packet.arguments[0] = readObject(buffer);
            break;

        case GiveRelationshipGift:
            packet.arguments[0] = buffer.readInt();
            break;

        case GiveAid:
            packet.arguments[0] = buffer.readInt();
            break;

        case Engagement:
            packet.arguments[0] = buffer.readInt();
            break;

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

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

        case HaveBaby:
            packet.arguments[0] = buffer.readInt();
            packet.arguments[1] = buffer.readInt();
            break;

        case KillEntity:
            packet.arguments[0] = buffer.readInt();
            break;

        case MountHorse:
            packet.arguments[0] = buffer.readInt();
            packet.arguments[1] = buffer.readInt();
            break;

        case NameBaby:
            packet.arguments[0] = buffer.readInt();
            packet.arguments[1] = buffer.readBoolean();
            break;

        case NotifyPlayer:
            packet.arguments[0] = buffer.readInt();
            packet.arguments[1] = readObject(buffer);
            break;

        case OpenGui:
            packet.arguments[0] = buffer.readInt();
            packet.arguments[1] = buffer.readByte();
            break;

        case PlayerMarriage:
            packet.arguments[0] = buffer.readInt();
            packet.arguments[1] = readObject(buffer);
            packet.arguments[2] = buffer.readInt();
            break;

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

        case ReturnInventory:
            packet.arguments[0] = buffer.readInt();
            break;

        case SayLocalized:
            boolean hasPlayer = buffer.readBoolean();
            boolean hasEntity = buffer.readBoolean();
            boolean hasPrefix = buffer.readBoolean();
            boolean hasSuffix = buffer.readBoolean();

            final String playerName = hasPlayer ? (String) readObject(buffer) : null;
            final int entityId = hasEntity ? buffer.readInt() : -1;
            final String phraseId = (String) readObject(buffer);
            final boolean useCharacterType = buffer.readBoolean();
            final String prefix = hasPrefix ? (String) readObject(buffer) : null;
            final String suffix = hasSuffix ? (String) readObject(buffer) : null;

            packet.arguments = new Object[10];
            packet.arguments[0] = hasPlayer;
            packet.arguments[1] = hasEntity;
            packet.arguments[2] = hasPrefix;
            packet.arguments[3] = hasSuffix;
            packet.arguments[4] = playerName;
            packet.arguments[5] = entityId;
            packet.arguments[6] = phraseId;
            packet.arguments[7] = useCharacterType;
            packet.arguments[8] = prefix;
            packet.arguments[9] = suffix;
            break;

        case SetChore:
            packet.arguments[0] = buffer.readInt();
            packet.arguments[1] = readObject(buffer);
            break;

        case SetFamilyTree:
            packet.arguments[0] = buffer.readInt();
            packet.arguments[1] = readObject(buffer);
            break;

        case SetFieldValue:
            packet.arguments[0] = buffer.readInt();
            packet.arguments[1] = readObject(buffer);
            packet.arguments[2] = readObject(buffer);
            break;

        case SetInventory:
            packet.arguments[0] = buffer.readInt();
            packet.arguments[1] = readObject(buffer);
            break;

        case SetPosition:
            packet.arguments[0] = buffer.readInt();
            packet.arguments[1] = buffer.readDouble();
            packet.arguments[2] = buffer.readDouble();
            packet.arguments[3] = buffer.readDouble();
            break;

        case SetTarget:
            packet.arguments[0] = buffer.readInt();
            packet.arguments[1] = buffer.readInt();
            break;

        case SetTombstoneText:
            packet.arguments[0] = buffer.readInt();
            packet.arguments[1] = buffer.readInt();
            packet.arguments[2] = buffer.readInt();
            packet.arguments[3] = readObject(buffer);
            packet.arguments[4] = readObject(buffer);
            packet.arguments[5] = readObject(buffer);
            packet.arguments[6] = readObject(buffer);
            break;

        case SetWorldProperties:
            packet.arguments[0] = readObject(buffer);
            break;

        case StartTrade:
            packet.arguments[0] = buffer.readInt();
            break;

        case StopJumping:
            packet.arguments[0] = buffer.readInt();
            break;

        case SwingArm:
            packet.arguments[0] = buffer.readInt();
            break;

        case SyncEditorSettings:
            packet.arguments[0] = buffer.readInt();
            packet.arguments[1] = readObject(buffer);
            packet.arguments[2] = buffer.readBoolean();
            packet.arguments[3] = buffer.readInt();
            packet.arguments[4] = buffer.readFloat();
            packet.arguments[5] = buffer.readFloat();
            packet.arguments[6] = buffer.readFloat();
            packet.arguments[7] = buffer.readInt();
            packet.arguments[8] = readObject(buffer);
            packet.arguments[9] = readObject(buffer);
            break;

        case SyncRequest:
            packet.arguments[0] = buffer.readInt();
            break;

        case Sync:
            packet.arguments[0] = buffer.readInt();
            packet.arguments[1] = readObject(buffer);
            break;

        case UpdateFurnace:
            packet.arguments[0] = buffer.readInt();
            packet.arguments[1] = buffer.readBoolean();
            break;

        default:
            break;
        }
    }

    catch (Throwable e) {
        e.printStackTrace();
    }
}

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

License:Open Source License

@Override
public void fromBytes(ByteBuf byteBuf) {
    entityId = byteBuf.readInt();//  ww w.  j a  v a  2s  .  c  o m
    name = (String) ByteBufIO.readObject(byteBuf);
    isMale = byteBuf.readBoolean();
    profession = byteBuf.readInt();
    moodPointsAnger = byteBuf.readFloat();
    moodPointsHappy = byteBuf.readFloat();
    moodPointsSad = byteBuf.readFloat();
    traitId = byteBuf.readInt();
    inventory = (Inventory) ByteBufIO.readObject(byteBuf);
    texture = (String) ByteBufIO.readObject(byteBuf);
}

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

License:LGPL

@Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
    super.decodeInto(ctx, buffer);
    sound = ByteBufUtils.readUTF8String(buffer);
    volume = buffer.readFloat();
    pitch = buffer.readFloat();//from   w  w  w. j  ava 2s  . c o m
    bool = buffer.readBoolean();
}

From source file:net.malisis.advert.advert.AdvertSelection.java

License:Open Source License

public static AdvertSelection fromBytes(ByteBuf buf) {
    AdvertSelection as = new AdvertSelection(buf.readInt(), buf.readFloat(), buf.readFloat(), buf.readFloat(),
            buf.readFloat());//from   w w  w. ja va 2 s .  co m
    return as;
}

From source file:net.shadowmage.ancientwarfare.structure.entity.EntityGate.java

License:Open Source License

@Override
public void readSpawnData(ByteBuf data) {
    this.pos1 = new BlockPosition(data.readInt(), data.readInt(), data.readInt());
    this.pos2 = new BlockPosition(data.readInt(), data.readInt(), data.readInt());
    this.gateType = Gate.getGateByID(data.readInt());
    this.edgePosition = data.readFloat();
    this.edgeMax = data.readFloat();
    this.gateStatus = data.readByte();
    this.gateOrientation = data.readByte();
    this.health = data.readInt();
}

From source file:net.tridentsdk.packets.play.in.PacketPlayInEntityInteract.java

License:Open Source License

@Override
public Packet decode(ByteBuf buf) {
    this.target = Codec.readVarInt32(buf);
    this.type = InteractType.fromId(Codec.readVarInt32(buf));

    double x = (double) buf.readFloat();
    double y = (double) buf.readFloat();
    double z = (double) buf.readFloat();

    this.location = new Location(null, x, y, z); // TODO: Get the clients world
    return this;
}

From source file:net.tridentsdk.packets.play.in.PacketPlayInPlayerAbilities.java

License:Open Source License

@Override
public Packet decode(ByteBuf buf) {
    this.flags = buf.readByte();

    this.flyingSpeed = buf.readFloat();
    this.walkingSpeed = buf.readFloat();

    return this;
}

From source file:net.tridentsdk.packets.play.in.PacketPlayInPlayerCompleteMove.java

License:Open Source License

@Override
public Packet decode(ByteBuf buf) {
    double x = buf.readDouble();
    double y = buf.readDouble();
    double z = buf.readDouble();

    super.location = new Location(null, x, y, z);

    this.newYaw = buf.readFloat();
    this.newPitch = buf.readFloat();

    super.onGround = buf.readBoolean();
    return this;
}

From source file:net.tridentsdk.packets.play.in.PacketPlayInPlayerLook.java

License:Open Source License

@Override
public Packet decode(ByteBuf buf) {
    this.newYaw = buf.readFloat();
    this.newPitch = buf.readFloat();
    this.onGround = buf.readBoolean();

    return this;
}