List of usage examples for io.netty.buffer ByteBuf readDouble
public abstract double readDouble();
From source file:hellfirepvp.astralsorcery.common.network.packet.server.PktSyncKnowledge.java
License:Open Source License
@Override public void fromBytes(ByteBuf buf) { this.state = buf.readByte(); int cLength = buf.readInt(); if (cLength != -1) { knownConstellations = new ArrayList<>(cLength); for (int i = 0; i < cLength; i++) { String val = ByteBufUtils.readString(buf); knownConstellations.add(val); }// www . j a v a 2 s . c o m } else { knownConstellations = new ArrayList<>(); } cLength = buf.readInt(); if (cLength != -1) { seenConstellations = new ArrayList<>(cLength); for (int i = 0; i < cLength; i++) { String val = ByteBufUtils.readString(buf); seenConstellations.add(val); } } else { seenConstellations = new ArrayList<>(); } int rLength = buf.readInt(); if (rLength != -1) { researchProgression = new ArrayList<>(rLength); for (int i = 0; i < rLength; i++) { researchProgression.add(ResearchProgression.getById(buf.readInt())); } } else { researchProgression = new ArrayList<>(); } int attunementPresent = buf.readByte(); if (attunementPresent != -1) { String attunement = ByteBufUtils.readString(buf); IConstellation c = ConstellationRegistry.getConstellationByName(attunement); if (c == null || !(c instanceof IMajorConstellation)) { AstralSorcery.log.warn( "[AstralSorcery] received constellation-attunement progress-packet with unknown constellation: " + attunement); } else { this.attunedConstellation = (IMajorConstellation) c; } } int perkLength = buf.readInt(); if (perkLength != -1) { this.appliedPerks = new HashMap<>(perkLength); for (int i = 0; i < perkLength; i++) { int id = buf.readInt(); int lvl = buf.readInt(); this.appliedPerks.put(ConstellationPerks.getById(id).getSingleInstance(), lvl); } } else { this.appliedPerks = new HashMap<>(); } this.wasOnceAttuned = buf.readBoolean(); this.progressTier = buf.readInt(); this.alignmentCharge = buf.readDouble(); }
From source file:hellfirepvp.astralsorcery.common.util.data.Vector3.java
License:Open Source License
public static Vector3 fromBytes(ByteBuf buf) { return new Vector3(buf.readDouble(), buf.readDouble(), buf.readDouble()); }
From source file:herddb.proto.PduCodec.java
License:Apache License
public static Object readObject(ByteBuf dii) { int type = ByteBufUtils.readVInt(dii); switch (type) { case TYPE_BYTEARRAY: return ByteBufUtils.readArray(dii); case TYPE_LONG: return dii.readLong(); case TYPE_INTEGER: return dii.readInt(); case TYPE_SHORT: return dii.readShort(); case TYPE_BYTE: return dii.readByte(); case TYPE_STRING: return ByteBufUtils.readUnpooledRawString(dii); case TYPE_TIMESTAMP: return new java.sql.Timestamp(dii.readLong()); case TYPE_NULL: return null; case TYPE_BOOLEAN: return dii.readBoolean(); case TYPE_DOUBLE: return dii.readDouble(); default:/* w w w. java2 s . c o m*/ throw new IllegalArgumentException("bad column type " + type); } }
From source file:io.crate.protocols.postgres.types.DoubleType.java
License:Apache License
@Override public Object readBinaryValue(ByteBuf buffer, int valueLength) { assert valueLength == TYPE_LEN : "length should be " + TYPE_LEN + " because double is int64. Actual length: " + valueLength; return buffer.readDouble(); }
From source file:io.crate.protocols.postgres.types.TimestampType.java
License:Apache License
@Override public Object readBinaryValue(ByteBuf buffer, int valueLength) { assert valueLength == TYPE_LEN : "valueLength must be " + TYPE_LEN + " because timestamp is a 64 bit double. Actual length: " + valueLength; return toCrateTimestamp(buffer.readDouble()); }
From source file:io.github.stormcloud_dev.stormcloud.seralization.RORObjectDecoder.java
License:Apache License
private Object readNextObject(ByteBuf buf) { if (buf.readableBytes() < 12) { return null; }/*from w w w . j av a 2 s . c om*/ byte[] header = new byte[8]; buf.readBytes(8).readBytes(header); //Handshake header if (Arrays.equals(header, new byte[] { -66, -70, -2, -54, 11, -80, -83, -34 })) { if (buf.readableBytes() >= 8) { buf.readBytes(8); //We read the rest of the handshake packet //Contains the length (inclusive the header) and 2 unknown numbers return new HandshakeFrame(); } else { return null; } } int length = buf.readByte(); buf.readBytes(3); byte id = buf.readByte(); if (id != 16) { int readerIndex = buf.readerIndex(), writerIndex = buf.writerIndex(); byte[] bytes = new byte[buf.readableBytes()]; buf.readBytes(buf.readableBytes()).readBytes(bytes); buf.setIndex(readerIndex, writerIndex); // Print packets - debugging purposes //System.out.println("ID: " + id + " - " + Arrays.toString(bytes)); } switch (id) { case 0: //if (length < 39) return null; return new PositionInfoServerBoundFrame(buf.readDouble(), buf.readDouble(), buf.readByte(), buf.readByte(), buf.readByte(), buf.readByte(), buf.readByte(), buf.readByte()); case 1: return new SetReadyServerBoundFrame(buf.readByte()); case 2: return new SetPlayerServerBoundFrame(buf.readDouble(), buf.readDouble(), readString(buf)); case 3: return new AddPlayerServerBoundFrame(buf.readDouble(), buf.readDouble(), buf.readDouble(), buf.readInt(), buf.readInt(), readString(buf)); case 4: return new ChatPlayerServerBoundFrame(readString(buf)); case 5: return new UpdatePlayerServerBoundFrame(buf.readInt(), buf.readDouble(), buf.readDouble(), readString(buf)); case 6: return new KeyPlayerServerBoundFrame(buf.readShort(), buf.readShort(), buf.readByte(), buf.readByte(), buf.readByte(), buf.readByte(), buf.readShort(), buf.readByte()); case 7: return new HealPlayerServerBoundFrame(buf.readDouble(), buf.readDouble(), buf.readDouble(), buf.readDouble()); case 8: return new NPCHPServerBoundFrame(buf.readDouble(), buf.readDouble(), buf.readDouble(), buf.readShort(), buf.readShort(), buf.readShort()); case 9: return new MDeadServerBoundFrame(); case 10: return new NPCTargetServerBoundFrame(buf.readDouble(), buf.readDouble(), buf.readInt(), buf.readShort(), buf.readByte()); case 11: return new KeyMonsterServerBoundFrame(buf.readDouble(), buf.readDouble(), buf.readByte(), buf.readByte(), buf.readByte(), buf.readByte(), buf.readShort()); case 12: return new CreateObjectServerBoundFrame(buf.readDouble(), buf.readDouble(), buf.readDouble()); case 13: return new CreateLevelObjectServerBoundFrame(buf.readDouble(), buf.readDouble(), buf.readDouble(), buf.readDouble(), buf.readInt()); case 14: return new SyncAlarmServerBoundFrame(buf.readDouble(), buf.readDouble(), buf.readDouble(), buf.readDouble(), buf.readInt()); case 15: return new SpawnClassicServerBoundFrame(buf.readShort(), buf.readDouble(), buf.readDouble(), buf.readByte(), buf.readShort(), buf.readShort(), buf.readShort()); case 16: return new LagPlayerServerBoundFrame(readString(buf)); case 17: return new DisPlayerServerBoundFrame(); case 18: return new TransportServerBoundFrame(buf.readDouble(), buf.readDouble(), buf.readDouble(), buf.readDouble(), buf.readDouble(), buf.readByte()); case 19: return new ActivateObjectServerBoundFrame(buf.readDouble(), buf.readDouble(), buf.readShort(), buf.readShort(), buf.readByte(), buf.readByte()); case 20: return new SpawnItemServerBoundFrame(buf.readDouble(), buf.readDouble(), buf.readInt()); case 21: return new SyncVarServerBoundFrame(buf.readDouble()); case 22: return new SpawnBossServerBoundFrame(buf.readDouble(), buf.readDouble(), buf.readByte(), buf.readDouble()); case 23: return new SpawnClassicBossServerBoundFrame(buf.readDouble(), buf.readDouble(), buf.readInt(), buf.readInt(), buf.readDouble(), buf.readByte(), buf.readShort(), buf.readShort(), buf.readShort(), buf.readDouble()); case 24: return new LevelUpServerBoundFrame(); case 25: return new ItemPickupServerBoundFrame(buf.readInt(), buf.readByte()); case 26: return new ChatSystemServerBoundFrame(buf.readByte(), readString(buf)); case 27: return new TestServerBoundFrame(); case 28: return new ItemSwapServerBoundFrame(); case 29: return readItemProcFrame(buf); case 30: return new ShrineProcServerBoundFrame(buf.readByte()); case 31: return new SpawnDroneServerBoundFrame(buf.readShort(), buf.readShort(), buf.readShort(), buf.readShort(), buf.readShort(), buf.readShort(), buf.readShort()); case 32: return new SetPriceServerBoundFrame(buf.readShort(), buf.readShort()); case 33: return new CreateChestServerBoundFrame(); case 34: return new UpdateBuffsServerBoundFrame(buf.readDouble(), buf.readShort(), buf.readShort()); case 35: return new SpawnImpmServerboundFrame(buf.readShort(), buf.readShort(), buf.readShort(), buf.readByte(), buf.readByte()); case 36: return new UpdateChest4ServerBoundFrame(buf.readShort()); case 37: return new EliteTeleportServerBoundFrame(buf.readShort(), buf.readShort()); case 38: return new UpdateHpServerBoundFrame(buf.readShort()); case 39: return new UpdateDiffServerBoundFrame(buf.readByte(), buf.readByte(), buf.readByte(), buf.readByte(), buf.readByte(), buf.readByte(), buf.readByte(), buf.readByte(), buf.readByte(), buf.readByte(), buf.readByte(), buf.readByte()); case 40: return new SpawnGhostServerBoundFrame(buf.readShort(), buf.readShort(), buf.readFloat(), buf.readFloat()); case 41: return new StopTimeServerBoundFrame(buf.readShort()); case 42: return new LandLizardServerBoundFrame(buf.readShort(), buf.readShort()); case 43: return new DestroyObjectServerBoundFrame(); case 44: return new CreateSlimeServerBoundFrame(buf.readShort(), buf.readShort(), buf.readFloat(), buf.readShort(), buf.readShort(), buf.readShort(), buf.readByte(), buf.readShort(), buf.readDouble()); case 45: return new CrewChoiceServerBoundFrame(buf.readShort()); case 46: return new CreateItemServerBoundFrame(buf.readShort(), buf.readShort(), buf.readShort()); case 47: return new ActivateSwitchServerBoundFrame(buf.readShort(), buf.readShort()); default: return null; } }
From source file:io.github.stormcloud_dev.stormcloud.seralization.RORObjectDecoder.java
License:Apache License
private Object readItemProcFrame(ByteBuf buf) { short id = buf.readShort(); switch (id) { case 1:/*from w ww .j av a2s .co m*/ return new PauldronItemProcFrame(buf.readDouble(), buf.readDouble(), buf.readDouble(), buf.readShort(), readString(buf)); case 3: return new DebuffsItemProcFrame(buf.readDouble(), buf.readShort(), buf.readShort(), buf.readShort()); case 4: return new MortarItemProcFrame(buf.readDouble(), buf.readDouble(), buf.readDouble(), buf.readShort()); case 5: return new ScopeItemProcFrame(buf.readDouble(), buf.readDouble(), buf.readDouble(), buf.readShort()); case 6: return new PlasmaChainItemProcFrame(buf.readShort(), buf.readDouble(), buf.readShort(), buf.readShort()); case 8: return new BleedItemProcFrame(buf.readDouble(), buf.readShort(), buf.readShort()); case 9: return new LightningItemProcFrame(buf.readDouble(), buf.readDouble(), buf.readShort(), readString(buf)); case 10: return new MissileItemProcFrame(buf.readDouble(), buf.readDouble(), buf.readShort(), buf.readShort(), buf.readShort()); case 11: return new MineItemProcFrame(buf.readShort(), buf.readShort(), buf.readShort(), buf.readShort(), buf.readShort()); case 12: return new EnemyMissileItemProcFrame(buf.readDouble(), buf.readDouble(), buf.readShort(), buf.readShort(), buf.readShort()); case 13: return new StickyItemProcFrame(buf.readShort(), buf.readShort(), buf.readShort()); case 14: return new MeteorItemProcFrame(buf.readDouble(), buf.readDouble()); case 15: return new GoldItemProcFrame(buf.readDouble(), buf.readDouble(), buf.readDouble()); case 16: return new BottleItemProcFrame(buf.readDouble(), buf.readDouble(), buf.readDouble(), buf.readByte()); case 17: return new HornItemProcFrame(buf.readShort(), buf.readDouble(), buf.readDouble(), buf.readByte(), buf.readDouble()); default: return null; } }
From source file:io.github.vastframework.codecs.primitives.DecodingPrimitiveSupport.java
License:Apache License
default double decodeDouble(ByteBuf buffer) { return buffer.readDouble(); }
From source file:io.hydramq.core.type.converters.MessagePropertiesConverter.java
License:Open Source License
@Override public MessageProperties read(final ConversionContext context, final ByteBuf buffer) { MessageProperties properties = new MessageProperties(); int flags = buffer.readInt(); if ((flags & HAS_STRING_PROPERTIES) == HAS_STRING_PROPERTIES) { int count = buffer.readInt(); for (int i = 0; i < count; i++) { properties.setString(context.read(String.class, buffer), context.read(String.class, buffer)); }/*from w w w . j a v a 2 s . co m*/ } if ((flags & HAS_BOOLEAN_PROPERTIES) == HAS_BOOLEAN_PROPERTIES) { int count = buffer.readInt(); for (int i = 0; i < count; i++) { properties.setBoolean(context.read(String.class, buffer), buffer.readBoolean()); } } if ((flags & HAS_INTEGER_PROPERTIES) == HAS_INTEGER_PROPERTIES) { int count = buffer.readInt(); for (int i = 0; i < count; i++) { properties.setInteger(context.read(String.class, buffer), buffer.readInt()); } } if ((flags & HAS_LONG_PROPERTIES) == HAS_LONG_PROPERTIES) { int count = buffer.readInt(); for (int i = 0; i < count; i++) { properties.setLong(context.read(String.class, buffer), buffer.readLong()); } } if ((flags & HAS_FLOAT_PROPERTIES) == HAS_FLOAT_PROPERTIES) { int count = buffer.readInt(); for (int i = 0; i < count; i++) { properties.setFloat(context.read(String.class, buffer), buffer.readFloat()); } } if ((flags & HAS_DOUBLE_PROPERTIES) == HAS_DOUBLE_PROPERTIES) { int count = buffer.readInt(); for (int i = 0; i < count; i++) { properties.setDouble(context.read(String.class, buffer), buffer.readDouble()); } } if ((flags & HAS_BYTES_PROPERTIES) == HAS_BYTES_PROPERTIES) { int count = buffer.readInt(); for (int i = 0; i < count; i++) { properties.setBytes(context.read(String.class, buffer), context.read(byte[].class, buffer)); } } if ((flags & HAS_SHORT_PROPERTIES) == HAS_SHORT_PROPERTIES) { int count = buffer.readInt(); for (int i = 0; i < count; i++) { properties.setShort(context.read(String.class, buffer), buffer.readShort()); } } if ((flags & HAS_BYTE_PROPERTIES) == HAS_BYTE_PROPERTIES) { int count = buffer.readInt(); for (int i = 0; i < count; i++) { properties.setByte(context.read(String.class, buffer), buffer.readByte()); } } return properties; }
From source file:jp.llv.locapi.PlayerPosition.java
License:Open Source License
@Override public void read(ByteBuf buf) { this.x = buf.readDouble(); this.y = buf.readDouble(); this.z = buf.readDouble(); this.onGround = buf.readBoolean(); }