Java Code Examples for com.nukkitx.network.VarInts#writeLong()
The following examples show how to use
com.nukkitx.network.VarInts#writeLong() .
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: UpdateTradeSerializer_v361.java From Protocol with Apache License 2.0 | 6 votes |
@Override public void serialize(ByteBuf buffer, UpdateTradePacket packet) { buffer.writeByte(packet.getWindowId()); buffer.writeByte(packet.getWindowType()); VarInts.writeInt(buffer, packet.getUnknownInt()); VarInts.writeInt(buffer, packet.getTradeTier()); VarInts.writeLong(buffer, packet.getTraderUniqueEntityId()); VarInts.writeLong(buffer, packet.getPlayerUniqueEntityId()); BedrockUtils.writeString(buffer, packet.getDisplayName()); buffer.writeBoolean(packet.isScreen2()); buffer.writeBoolean(packet.isWilling()); try (NBTOutputStream writer = NbtUtils.createNetworkWriter(new ByteBufOutputStream(buffer))) { writer.write(packet.getOffers()); } catch (IOException e) { throw new RuntimeException(e); } }
Example 2
Source File: PlayerListSerializer_v361.java From Protocol with Apache License 2.0 | 6 votes |
@Override public void serialize(ByteBuf buffer, PlayerListPacket packet) { buffer.writeByte(packet.getAction().ordinal()); VarInts.writeUnsignedInt(buffer, packet.getEntries().size()); for (Entry entry : packet.getEntries()) { BedrockUtils.writeUuid(buffer, entry.getUuid()); if (packet.getAction() == Action.ADD) { VarInts.writeLong(buffer, entry.getEntityId()); BedrockUtils.writeString(buffer, entry.getName()); SerializedSkin skin = entry.getSkin(); BedrockUtils.writeString(buffer, skin.getSkinId()); skin.getSkinData().checkLegacySkinSize(); BedrockUtils.writeByteArray(buffer, skin.getSkinData().getImage()); skin.getCapeData().checkLegacyCapeSize(); BedrockUtils.writeByteArray(buffer, skin.getCapeData().getImage()); BedrockUtils.writeString(buffer, skin.getGeometryName()); BedrockUtils.writeString(buffer, skin.getGeometryData()); BedrockUtils.writeString(buffer, entry.getXuid()); BedrockUtils.writeString(buffer, entry.getPlatformChatId()); } } }
Example 3
Source File: AddPlayerSerializer_v313.java From Protocol with Apache License 2.0 | 6 votes |
@Override public void serialize(ByteBuf buffer, AddPlayerPacket packet) { BedrockUtils.writeUuid(buffer, packet.getUuid()); BedrockUtils.writeString(buffer, packet.getUsername()); VarInts.writeLong(buffer, packet.getUniqueEntityId()); VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); BedrockUtils.writeString(buffer, packet.getPlatformChatId()); BedrockUtils.writeVector3f(buffer, packet.getPosition()); BedrockUtils.writeVector3f(buffer, packet.getMotion()); BedrockUtils.writeVector3f(buffer, packet.getRotation()); BedrockUtils.writeItemData(buffer, packet.getHand()); BedrockUtils.writeEntityData(buffer, packet.getMetadata()); AdventureSettingsSerializer_v313.INSTANCE.serialize(buffer, packet.getAdventureSettings()); BedrockUtils.writeArray(buffer, packet.getEntityLinks(), BedrockUtils::writeEntityLink); BedrockUtils.writeString(buffer, packet.getDeviceId()); }
Example 4
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 5 votes |
public static void writeEntityLink(ByteBuf buffer, EntityLink entityLink) { Preconditions.checkNotNull(buffer, "buffer"); Preconditions.checkNotNull(entityLink, "entityLink"); VarInts.writeLong(buffer, entityLink.getFrom()); VarInts.writeLong(buffer, entityLink.getTo()); buffer.writeByte(entityLink.getType().ordinal()); buffer.writeBoolean(entityLink.isImmediate()); }
Example 5
Source File: AddItemEntitySerializer_v291.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, AddItemEntityPacket packet) { VarInts.writeLong(buffer, packet.getUniqueEntityId()); VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); BedrockUtils.writeItemData(buffer, packet.getItemInHand()); BedrockUtils.writeVector3f(buffer, packet.getPosition()); BedrockUtils.writeVector3f(buffer, packet.getMotion()); BedrockUtils.writeEntityData(buffer, packet.getMetadata()); buffer.writeBoolean(packet.isFromFishing()); }
Example 6
Source File: AddItemEntitySerializer_v340.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, AddItemEntityPacket packet) { VarInts.writeLong(buffer, packet.getUniqueEntityId()); VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); BedrockUtils.writeItemData(buffer, packet.getItemInHand()); BedrockUtils.writeVector3f(buffer, packet.getPosition()); BedrockUtils.writeVector3f(buffer, packet.getMotion()); BedrockUtils.writeEntityData(buffer, packet.getMetadata()); buffer.writeBoolean(packet.isFromFishing()); }
Example 7
Source File: AddItemEntitySerializer_v332.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, AddItemEntityPacket packet) { VarInts.writeLong(buffer, packet.getUniqueEntityId()); VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); BedrockUtils.writeItemData(buffer, packet.getItemInHand()); BedrockUtils.writeVector3f(buffer, packet.getPosition()); BedrockUtils.writeVector3f(buffer, packet.getMotion()); BedrockUtils.writeEntityData(buffer, packet.getMetadata()); buffer.writeBoolean(packet.isFromFishing()); }
Example 8
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 5 votes |
public static void writeEntityLink(ByteBuf buffer, EntityLink entityLink) { Preconditions.checkNotNull(buffer, "buffer"); Preconditions.checkNotNull(entityLink, "entityLink"); VarInts.writeLong(buffer, entityLink.getFrom()); VarInts.writeLong(buffer, entityLink.getTo()); buffer.writeByte(entityLink.getType().ordinal()); buffer.writeBoolean(entityLink.isImmediate()); }
Example 9
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 5 votes |
public static void writeCommandOriginData(ByteBuf buffer, CommandOriginData originData) { Preconditions.checkNotNull(buffer, "buffer"); Preconditions.checkNotNull(originData, "commandOriginData"); VarInts.writeUnsignedInt(buffer, originData.getOrigin().ordinal()); writeUuid(buffer, originData.getUuid()); writeString(buffer, originData.getRequestId()); if (originData.getOrigin() == CommandOriginData.Origin.DEV_CONSOLE || originData.getOrigin() == CommandOriginData.Origin.TEST) { VarInts.writeLong(buffer, originData.getEvent()); } }
Example 10
Source File: UpdateEquipSerializer_v388.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, UpdateEquipPacket packet) { buffer.writeByte(packet.getWindowId()); buffer.writeByte(packet.getWindowType()); VarInts.writeInt(buffer, packet.getUnknown0()); VarInts.writeLong(buffer, packet.getUniqueEntityId()); try (NBTOutputStream writer = NbtUtils.createNetworkWriter(new ByteBufOutputStream(buffer))) { writer.write(packet.getTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example 11
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 5 votes |
public static void writeEntityLink(ByteBuf buffer, EntityLink entityLink) { Preconditions.checkNotNull(buffer, "buffer"); Preconditions.checkNotNull(entityLink, "entityLink"); VarInts.writeLong(buffer, entityLink.getFrom()); VarInts.writeLong(buffer, entityLink.getTo()); buffer.writeByte(entityLink.getType().ordinal()); buffer.writeBoolean(entityLink.isImmediate()); }
Example 12
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 5 votes |
public static void writeCommandOriginData(ByteBuf buffer, CommandOriginData originData) { Preconditions.checkNotNull(buffer, "buffer"); Preconditions.checkNotNull(originData, "commandOriginData"); VarInts.writeUnsignedInt(buffer, originData.getOrigin().ordinal()); writeUuid(buffer, originData.getUuid()); writeString(buffer, originData.getRequestId()); if (originData.getOrigin() == CommandOriginData.Origin.DEV_CONSOLE || originData.getOrigin() == CommandOriginData.Origin.TEST) { VarInts.writeLong(buffer, originData.getEvent()); } }
Example 13
Source File: AddHangingEntitySerializer_v313.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, AddHangingEntityPacket packet) { VarInts.writeLong(buffer, packet.getUniqueEntityId()); VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); BedrockUtils.writeBlockPosition(buffer, packet.getPosition().toInt()); VarInts.writeInt(buffer, packet.getDirection()); }
Example 14
Source File: UpdateEquipSerializer_v354.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, UpdateEquipPacket packet) { buffer.writeByte(packet.getWindowId()); buffer.writeByte(packet.getWindowType()); VarInts.writeInt(buffer, packet.getUnknown0()); VarInts.writeLong(buffer, packet.getUniqueEntityId()); try (NBTOutputStream writer = NbtUtils.createNetworkWriter(new ByteBufOutputStream(buffer))) { writer.write(packet.getTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example 15
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 5 votes |
public static void writeEntityLink(ByteBuf buffer, EntityLink entityLink) { Preconditions.checkNotNull(buffer, "buffer"); Preconditions.checkNotNull(entityLink, "entityLink"); VarInts.writeLong(buffer, entityLink.getFrom()); VarInts.writeLong(buffer, entityLink.getTo()); buffer.writeByte(entityLink.getType().ordinal()); buffer.writeBoolean(entityLink.isImmediate()); }
Example 16
Source File: MapInfoRequestSerializer_v332.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void serialize(ByteBuf buffer, MapInfoRequestPacket packet) { VarInts.writeLong(buffer, packet.getUniqueMapId()); }
Example 17
Source File: CameraSerializer_v313.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void serialize(ByteBuf buffer, CameraPacket packet) { VarInts.writeLong(buffer, packet.getCameraUniqueEntityId()); VarInts.writeLong(buffer, packet.getPlayerUniqueEntityId()); }
Example 18
Source File: ClientboundMapItemDataSerializer_v361.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void serialize(ByteBuf buffer, ClientboundMapItemDataPacket packet) { VarInts.writeLong(buffer, packet.getUniqueMapId()); int type = 0; int[] colors = packet.getColors(); if (colors != null && colors.length > 0) { type |= 0x2; } List<MapDecoration> decorations = packet.getDecorations(); List<MapTrackedObject> trackedObjects = packet.getTrackedObjects(); if (!decorations.isEmpty() && !trackedObjects.isEmpty()) { type |= 0x4; } LongList trackedEntityIds = packet.getTrackedEntityIds(); if (!trackedEntityIds.isEmpty()) { type |= 0x8; } VarInts.writeUnsignedInt(buffer, type); buffer.writeByte(packet.getDimensionId()); buffer.writeBoolean(packet.isLocked()); if ((type & 0x8) != 0) { VarInts.writeUnsignedInt(buffer, trackedEntityIds.size()); for (long trackedEntityId : trackedEntityIds) { VarInts.writeLong(buffer, trackedEntityId); } } if ((type & 0xe) != 0) { buffer.writeByte(packet.getScale()); } if ((type & 0x4) != 0) { VarInts.writeUnsignedInt(buffer, trackedObjects.size()); for (MapTrackedObject object : trackedObjects) { switch (object.getType()) { case BLOCK: buffer.writeIntLE(object.getType().ordinal()); BedrockUtils.writeBlockPosition(buffer, object.getPosition()); break; case ENTITY: buffer.writeIntLE(object.getType().ordinal()); VarInts.writeLong(buffer, object.getEntityId()); break; } } VarInts.writeUnsignedInt(buffer, decorations.size()); for (MapDecoration decoration : decorations) { buffer.writeByte(decoration.getImage()); buffer.writeByte(decoration.getRotation()); buffer.writeByte(decoration.getXOffset()); buffer.writeByte(decoration.getYOffset()); BedrockUtils.writeString(buffer, decoration.getLabel()); VarInts.writeUnsignedInt(buffer, decoration.getColor()); } } if ((type & 0x2) != 0) { VarInts.writeInt(buffer, packet.getWidth()); VarInts.writeInt(buffer, packet.getHeight()); VarInts.writeInt(buffer, packet.getXOffset()); VarInts.writeInt(buffer, packet.getYOffset()); VarInts.writeUnsignedInt(buffer, colors.length); for (int color : colors) { VarInts.writeUnsignedInt(buffer, color); } } }
Example 19
Source File: MapCreateLockedCopySerializer_v354.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void serialize(ByteBuf buffer, MapCreateLockedCopyPacket packet) { VarInts.writeLong(buffer, packet.getOriginalMapId()); VarInts.writeLong(buffer, packet.getNewMapId()); }
Example 20
Source File: ClientboundMapItemDataSerializer_v313.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void serialize(ByteBuf buffer, ClientboundMapItemDataPacket packet) { VarInts.writeLong(buffer, packet.getUniqueMapId()); int type = 0; int[] colors = packet.getColors(); if (colors != null && colors.length > 0) { type |= 0x2; } List<MapDecoration> decorations = packet.getDecorations(); List<MapTrackedObject> trackedObjects = packet.getTrackedObjects(); if (!decorations.isEmpty() && !trackedObjects.isEmpty()) { type |= 0x4; } LongList trackedEntityIds = packet.getTrackedEntityIds(); if (!trackedEntityIds.isEmpty()) { type |= 0x8; } VarInts.writeUnsignedInt(buffer, type); buffer.writeByte(packet.getDimensionId()); if ((type & 0x8) != 0) { VarInts.writeUnsignedInt(buffer, trackedEntityIds.size()); for (long trackedEntityId : trackedEntityIds) { VarInts.writeLong(buffer, trackedEntityId); } } if ((type & 0xe) != 0) { buffer.writeByte(packet.getScale()); } if ((type & 0x4) != 0) { VarInts.writeUnsignedInt(buffer, trackedObjects.size()); for (MapTrackedObject object : trackedObjects) { switch (object.getType()) { case BLOCK: buffer.writeIntLE(object.getType().ordinal()); BedrockUtils.writeBlockPosition(buffer, object.getPosition()); break; case ENTITY: buffer.writeIntLE(object.getType().ordinal()); VarInts.writeLong(buffer, object.getEntityId()); break; } } VarInts.writeUnsignedInt(buffer, decorations.size()); for (MapDecoration decoration : decorations) { buffer.writeByte(decoration.getImage()); buffer.writeByte(decoration.getRotation()); buffer.writeByte(decoration.getXOffset()); buffer.writeByte(decoration.getYOffset()); BedrockUtils.writeString(buffer, decoration.getLabel()); VarInts.writeUnsignedInt(buffer, decoration.getColor()); } } if ((type & 0x2) != 0) { VarInts.writeInt(buffer, packet.getWidth()); VarInts.writeInt(buffer, packet.getHeight()); VarInts.writeInt(buffer, packet.getXOffset()); VarInts.writeInt(buffer, packet.getYOffset()); VarInts.writeUnsignedInt(buffer, colors.length); for (int color : colors) { VarInts.writeUnsignedInt(buffer, color); } } }