Java Code Examples for com.nukkitx.network.VarInts#readLong()
The following examples show how to use
com.nukkitx.network.VarInts#readLong() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 6 votes |
public static StructureSettings readStructureSettings(ByteBuf buffer) { Preconditions.checkNotNull(buffer, "buffer"); String paletteName = BedrockUtils.readString(buffer); boolean ignoreEntities = buffer.readBoolean(); boolean ignoreBlocks = buffer.readBoolean(); Vector3i structureSize = BedrockUtils.readBlockPosition(buffer); Vector3i structureOffset = BedrockUtils.readBlockPosition(buffer); long lastTouchedByEntityId = VarInts.readLong(buffer); byte rotation = buffer.readByte(); byte mirror = buffer.readByte(); float integrityValue = buffer.readFloatLE(); int integritySeed = VarInts.readUnsignedInt(buffer); return new StructureSettings(paletteName, ignoreEntities, ignoreBlocks, structureSize, structureOffset, lastTouchedByEntityId, rotation, mirror, integrityValue, integritySeed); }
Example 2
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 5 votes |
public static CommandOriginData readCommandOriginData(ByteBuf buffer) { Preconditions.checkNotNull(buffer, "buffer"); CommandOriginData.Origin origin = CommandOriginData.Origin.values()[VarInts.readUnsignedInt(buffer)]; UUID uuid = readUuid(buffer); String requestId = readString(buffer); long varLong = -1; if (origin == CommandOriginData.Origin.DEV_CONSOLE || origin == CommandOriginData.Origin.TEST) { varLong = VarInts.readLong(buffer); } return new CommandOriginData(origin, uuid, requestId, varLong); }
Example 3
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 5 votes |
public static CommandOriginData readCommandOriginData(ByteBuf buffer) { Preconditions.checkNotNull(buffer, "buffer"); CommandOriginData.Origin origin = CommandOriginData.Origin.values()[VarInts.readUnsignedInt(buffer)]; UUID uuid = readUuid(buffer); String requestId = readString(buffer); long varLong = -1; if (origin == CommandOriginData.Origin.DEV_CONSOLE || origin == CommandOriginData.Origin.TEST) { varLong = VarInts.readLong(buffer); } return new CommandOriginData(origin, uuid, requestId, varLong); }
Example 4
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 5 votes |
public static EntityLink readEntityLink(ByteBuf buffer) { Preconditions.checkNotNull(buffer, "buffer"); long from = VarInts.readLong(buffer); long to = VarInts.readLong(buffer); int type = buffer.readUnsignedByte(); boolean immediate = buffer.readBoolean(); return new EntityLink(from, to, EntityLink.Type.values()[type], immediate); }
Example 5
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 5 votes |
public static CommandOriginData readCommandOriginData(ByteBuf buffer) { Preconditions.checkNotNull(buffer, "buffer"); CommandOriginData.Origin origin = CommandOriginData.Origin.values()[VarInts.readUnsignedInt(buffer)]; UUID uuid = readUuid(buffer); String requestId = readString(buffer); long varLong = -1; if (origin == CommandOriginData.Origin.DEV_CONSOLE || origin == CommandOriginData.Origin.TEST) { varLong = VarInts.readLong(buffer); } return new CommandOriginData(origin, uuid, requestId, varLong); }
Example 6
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 5 votes |
public static EntityLink readEntityLink(ByteBuf buffer) { Preconditions.checkNotNull(buffer, "buffer"); long from = VarInts.readLong(buffer); long to = VarInts.readLong(buffer); int type = buffer.readUnsignedByte(); boolean immediate = buffer.readBoolean(); return new EntityLink(from, to, EntityLink.Type.values()[type], immediate); }
Example 7
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 5 votes |
public static CommandOriginData readCommandOriginData(ByteBuf buffer) { Preconditions.checkNotNull(buffer, "buffer"); CommandOriginData.Origin origin = CommandOriginData.Origin.values()[VarInts.readUnsignedInt(buffer)]; UUID uuid = readUuid(buffer); String requestId = readString(buffer); long varLong = -1; if (origin == CommandOriginData.Origin.DEV_CONSOLE || origin == CommandOriginData.Origin.TEST) { varLong = VarInts.readLong(buffer); } return new CommandOriginData(origin, uuid, requestId, varLong); }
Example 8
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 5 votes |
public static EntityLink readEntityLink(ByteBuf buffer) { Preconditions.checkNotNull(buffer, "buffer"); long from = VarInts.readLong(buffer); long to = VarInts.readLong(buffer); int type = buffer.readUnsignedByte(); boolean immediate = buffer.readBoolean(); return new EntityLink(from, to, EntityLink.Type.values()[type], immediate); }
Example 9
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 5 votes |
public static EntityLink readEntityLink(ByteBuf buffer) { Preconditions.checkNotNull(buffer, "buffer"); long from = VarInts.readLong(buffer); long to = VarInts.readLong(buffer); int type = buffer.readUnsignedByte(); boolean immediate = buffer.readBoolean(); return new EntityLink(from, to, EntityLink.Type.values()[type], immediate); }
Example 10
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 5 votes |
public static EntityLink readEntityLink(ByteBuf buffer) { Preconditions.checkNotNull(buffer, "buffer"); long from = VarInts.readLong(buffer); long to = VarInts.readLong(buffer); int type = buffer.readUnsignedByte(); boolean immediate = buffer.readBoolean(); return new EntityLink(from, to, EntityLink.Type.values()[type], immediate); }
Example 11
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 5 votes |
public static CommandOriginData readCommandOriginData(ByteBuf buffer) { Preconditions.checkNotNull(buffer, "buffer"); CommandOriginData.Origin origin = CommandOriginData.Origin.values()[VarInts.readUnsignedInt(buffer)]; UUID uuid = readUuid(buffer); String requestId = readString(buffer); long varLong = -1; if (origin == CommandOriginData.Origin.DEV_CONSOLE || origin == CommandOriginData.Origin.TEST) { varLong = VarInts.readLong(buffer); } return new CommandOriginData(origin, uuid, requestId, varLong); }
Example 12
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 5 votes |
public static EntityLink readEntityLink(ByteBuf buffer) { Preconditions.checkNotNull(buffer, "buffer"); long from = VarInts.readLong(buffer); long to = VarInts.readLong(buffer); int type = buffer.readUnsignedByte(); boolean immediate = buffer.readBoolean(); return new EntityLink(from, to, EntityLink.Type.values()[type], immediate); }
Example 13
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 5 votes |
public static CommandOriginData readCommandOriginData(ByteBuf buffer) { Preconditions.checkNotNull(buffer, "buffer"); CommandOriginData.Origin origin = CommandOriginData.Origin.values()[VarInts.readUnsignedInt(buffer)]; UUID uuid = readUuid(buffer); String requestId = readString(buffer); long varLong = -1; if (origin == CommandOriginData.Origin.DEV_CONSOLE || origin == CommandOriginData.Origin.TEST) { varLong = VarInts.readLong(buffer); } return new CommandOriginData(origin, uuid, requestId, varLong); }
Example 14
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 5 votes |
public static EntityLink readEntityLink(ByteBuf buffer) { Preconditions.checkNotNull(buffer, "buffer"); long from = VarInts.readLong(buffer); long to = VarInts.readLong(buffer); int type = buffer.readUnsignedByte(); boolean immediate = buffer.readBoolean(); return new EntityLink(from, to, EntityLink.Type.values()[type], immediate); }
Example 15
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 5 votes |
public static CommandOriginData readCommandOriginData(ByteBuf buffer) { Preconditions.checkNotNull(buffer, "buffer"); CommandOriginData.Origin origin = CommandOriginData.Origin.values()[VarInts.readUnsignedInt(buffer)]; UUID uuid = readUuid(buffer); String requestId = readString(buffer); long varLong = -1; if (origin == CommandOriginData.Origin.DEV_CONSOLE || origin == CommandOriginData.Origin.TEST) { varLong = VarInts.readLong(buffer); } return new CommandOriginData(origin, uuid, requestId, varLong); }
Example 16
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 4 votes |
public static void readEntityData(ByteBuf buffer, EntityDataMap entityDataMap) { Preconditions.checkNotNull(buffer, "buffer"); Preconditions.checkNotNull(entityDataMap, "entityDataDictionary"); int length = VarInts.readUnsignedInt(buffer); for (int i = 0; i < length; i++) { int metadataInt = VarInts.readUnsignedInt(buffer); EntityData entityData = METADATAS.get(metadataInt); EntityData.Type type = METADATA_TYPES.get(VarInts.readUnsignedInt(buffer)); if (entityData != null && entityData.isFlags()) { if (type != Type.LONG) { throw new IllegalArgumentException("Expected long value for flags, got " + type.name()); } type = Type.FLAGS; } Object object; switch (type) { case BYTE: object = buffer.readByte(); break; case SHORT: object = buffer.readShortLE(); break; case INT: object = VarInts.readInt(buffer); break; case FLOAT: object = buffer.readFloatLE(); break; case STRING: object = BedrockUtils.readString(buffer); break; case NBT: object = BedrockUtils.readItemData(buffer); break; case VECTOR3I: object = BedrockUtils.readVector3i(buffer); break; case FLAGS: int index = entityData == FLAGS_2 ? 1 : 0; entityDataMap.getOrCreateFlags().set(VarInts.readLong(buffer), index, METADATA_FLAGS); continue; case LONG: object = VarInts.readLong(buffer); break; case VECTOR3F: object = BedrockUtils.readVector3f(buffer); break; default: throw new IllegalArgumentException("Unknown entity data type received"); } if (entityData != null) { entityDataMap.put(entityData, object); } else { log.debug("Unknown entity data: {} type {} value {}", metadataInt, type, object); } } }
Example 17
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 4 votes |
public static void readEntityData(ByteBuf buffer, EntityDataMap entityDataMap) { Preconditions.checkNotNull(buffer, "buffer"); Preconditions.checkNotNull(entityDataMap, "entityDataDictionary"); int length = VarInts.readUnsignedInt(buffer); for (int i = 0; i < length; i++) { int metadataInt = VarInts.readUnsignedInt(buffer); EntityData entityData = METADATAS.get(metadataInt); EntityData.Type type = METADATA_TYPES.get(VarInts.readUnsignedInt(buffer)); if (entityData != null && entityData.isFlags()) { if (type != Type.LONG) { throw new IllegalArgumentException("Expected long value for flags, got " + type.name()); } type = Type.FLAGS; } Object object; switch (type) { case BYTE: object = buffer.readByte(); break; case SHORT: object = buffer.readShortLE(); break; case INT: object = VarInts.readInt(buffer); break; case FLOAT: object = buffer.readFloatLE(); break; case STRING: object = BedrockUtils.readString(buffer); break; case NBT: object = BedrockUtils.readItemData(buffer); break; case VECTOR3I: object = BedrockUtils.readVector3i(buffer); break; case FLAGS: int index = entityData == FLAGS_2 ? 1 : 0; entityDataMap.getOrCreateFlags().set(VarInts.readLong(buffer), index, METADATA_FLAGS); continue; case LONG: object = VarInts.readLong(buffer); break; case VECTOR3F: object = BedrockUtils.readVector3f(buffer); break; default: throw new IllegalArgumentException("Unknown entity data type received"); } if (entityData != null) { entityDataMap.put(entityData, object); } else { log.debug("Unknown entity data: {} type {} value {}", metadataInt, type, object); } } }
Example 18
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 4 votes |
public static void readEntityData(ByteBuf buffer, EntityDataMap entityDataMap) { Preconditions.checkNotNull(buffer, "buffer"); Preconditions.checkNotNull(entityDataMap, "entityDataDictionary"); int length = VarInts.readUnsignedInt(buffer); for (int i = 0; i < length; i++) { int metadataInt = VarInts.readUnsignedInt(buffer); EntityData entityData = METADATAS.get(metadataInt); EntityData.Type type = METADATA_TYPES.get(VarInts.readUnsignedInt(buffer)); if (entityData != null && entityData.isFlags()) { if (type != Type.LONG) { throw new IllegalArgumentException("Expected long value for flags, got " + type.name()); } type = Type.FLAGS; } Object object; switch (type) { case BYTE: object = buffer.readByte(); break; case SHORT: object = buffer.readShortLE(); break; case INT: object = VarInts.readInt(buffer); break; case FLOAT: object = buffer.readFloatLE(); break; case STRING: object = BedrockUtils.readString(buffer); break; case NBT: object = BedrockUtils.readItemData(buffer); break; case VECTOR3I: object = BedrockUtils.readVector3i(buffer); break; case FLAGS: int index = entityData == FLAGS_2 ? 1 : 0; entityDataMap.getOrCreateFlags().set(VarInts.readLong(buffer), index, METADATA_FLAGS); continue; case LONG: object = VarInts.readLong(buffer); break; case VECTOR3F: object = BedrockUtils.readVector3f(buffer); break; default: throw new IllegalArgumentException("Unknown entity data type received"); } if (entityData != null) { entityDataMap.put(entityData, object); } else { log.debug("Unknown entity data: {} type {} value {}", metadataInt, type, object); } } }
Example 19
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 4 votes |
public static void readEntityData(ByteBuf buffer, EntityDataMap entityDataMap) { Preconditions.checkNotNull(buffer, "buffer"); Preconditions.checkNotNull(entityDataMap, "entityDataDictionary"); int length = VarInts.readUnsignedInt(buffer); for (int i = 0; i < length; i++) { int metadataInt = VarInts.readUnsignedInt(buffer); EntityData entityData = METADATAS.get(metadataInt); EntityData.Type type = METADATA_TYPES.get(VarInts.readUnsignedInt(buffer)); if (entityData != null && entityData.isFlags()) { if (type != Type.LONG) { throw new IllegalArgumentException("Expected long value for flags, got " + type.name()); } type = Type.FLAGS; } Object object; switch (type) { case BYTE: object = buffer.readByte(); break; case SHORT: object = buffer.readShortLE(); break; case INT: object = VarInts.readInt(buffer); break; case FLOAT: object = buffer.readFloatLE(); break; case STRING: object = BedrockUtils.readString(buffer); break; case NBT: object = BedrockUtils.readItemData(buffer); break; case VECTOR3I: object = BedrockUtils.readVector3i(buffer); break; case FLAGS: int index = entityData == FLAGS_2 ? 1 : 0; entityDataMap.getOrCreateFlags().set(VarInts.readLong(buffer), index, METADATA_FLAGS); continue; case LONG: object = VarInts.readLong(buffer); break; case VECTOR3F: object = BedrockUtils.readVector3f(buffer); break; default: throw new IllegalArgumentException("Unknown entity data type received"); } if (entityData != null) { entityDataMap.put(entityData, object); } else { log.debug("Unknown entity data: {} type {} value {}", metadataInt, type, object); } } }
Example 20
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 4 votes |
public static void readEntityData(ByteBuf buffer, EntityDataMap entityDataMap) { Preconditions.checkNotNull(buffer, "buffer"); Preconditions.checkNotNull(entityDataMap, "entityDataDictionary"); int length = VarInts.readUnsignedInt(buffer); for (int i = 0; i < length; i++) { int metadataInt = VarInts.readUnsignedInt(buffer); EntityData entityData = METADATAS.get(metadataInt); EntityData.Type type = METADATA_TYPES.get(VarInts.readUnsignedInt(buffer)); if (entityData != null && entityData.isFlags()) { if (type != Type.LONG) { throw new IllegalArgumentException("Expected long value for flags, got " + type.name()); } type = Type.FLAGS; } Object object; switch (type) { case BYTE: object = buffer.readByte(); break; case SHORT: object = buffer.readShortLE(); break; case INT: object = VarInts.readInt(buffer); break; case FLOAT: object = buffer.readFloatLE(); break; case STRING: object = BedrockUtils.readString(buffer); break; case NBT: object = BedrockUtils.readItemData(buffer); break; case VECTOR3I: object = BedrockUtils.readVector3i(buffer); break; case FLAGS: int index = entityData == FLAGS_2 ? 1 : 0; entityDataMap.getOrCreateFlags().set(VarInts.readLong(buffer), index, METADATA_FLAGS); continue; case LONG: object = VarInts.readLong(buffer); break; case VECTOR3F: object = BedrockUtils.readVector3f(buffer); break; default: throw new IllegalArgumentException("Unknown entity data type received"); } if (entityData != null) { entityDataMap.put(entityData, object); } else { log.debug("Unknown entity data: {} type {} value {}", metadataInt, type, object); } } }