Java Code Examples for com.nukkitx.network.VarInts#writeUnsignedLong()
The following examples show how to use
com.nukkitx.network.VarInts#writeUnsignedLong() .
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: AddPlayerSerializer_v340.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_v340.INSTANCE.serialize(buffer, packet.getAdventureSettings()); BedrockUtils.writeArray(buffer, packet.getEntityLinks(), BedrockUtils::writeEntityLink); BedrockUtils.writeString(buffer, packet.getDeviceId()); }
Example 2
Source File: MovePlayerSerializer_v340.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, MovePlayerPacket packet) { VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); BedrockUtils.writeVector3f(buffer, packet.getPosition()); BedrockUtils.writeVector3f(buffer, packet.getRotation()); buffer.writeByte(packet.getMode().ordinal()); buffer.writeBoolean(packet.isOnGround()); VarInts.writeUnsignedLong(buffer, packet.getRidingRuntimeEntityId()); if (packet.getMode() == Mode.TELEPORT) { buffer.writeIntLE(packet.getTeleportationCause().ordinal()); buffer.writeIntLE(packet.getEntityType()); } }
Example 3
Source File: MoveEntityDeltaSerializer_v388.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, MoveEntityDeltaPacket packet) { VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); short flags = 0; Vector3i movementDelta = packet.getMovementDelta(); Vector3f rotationDelta = packet.getRotationDelta(); flags |= movementDelta.getX() != 0 ? HAS_X : 0; flags |= movementDelta.getY() != 0 ? HAS_Y : 0; flags |= movementDelta.getZ() != 0 ? HAS_Z : 0; flags |= rotationDelta.getX() != 0 ? HAS_PITCH : 0; flags |= rotationDelta.getY() != 0 ? HAS_YAW : 0; flags |= rotationDelta.getZ() != 0 ? HAS_ROLL : 0; buffer.writeShortLE(flags); if ((flags & HAS_X) != 0) { VarInts.writeInt(buffer, movementDelta.getX()); } if ((flags & HAS_Y) != 0) { VarInts.writeInt(buffer, movementDelta.getY()); } if ((flags & HAS_Z) != 0) { VarInts.writeInt(buffer, movementDelta.getZ()); } if ((flags & HAS_PITCH) != 0) { BedrockUtils.writeByteAngle(buffer, rotationDelta.getX()); } if ((flags & HAS_YAW) != 0) { BedrockUtils.writeByteAngle(buffer, rotationDelta.getY()); } if ((flags & HAS_ROLL) != 0) { BedrockUtils.writeByteAngle(buffer, rotationDelta.getZ()); } }
Example 4
Source File: InteractSerializer_v313.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, InteractPacket packet) { buffer.writeByte(packet.getAction().ordinal()); VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); if (packet.getAction() == InteractPacket.Action.MOUSEOVER || packet.getAction() == InteractPacket.Action.NPC_OPEN) { BedrockUtils.writeVector3f(buffer, packet.getMousePosition()); } }
Example 5
Source File: MovePlayerSerializer_v332.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, MovePlayerPacket packet) { VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); BedrockUtils.writeVector3f(buffer, packet.getPosition()); BedrockUtils.writeVector3f(buffer, packet.getRotation()); buffer.writeByte(packet.getMode().ordinal()); buffer.writeBoolean(packet.isOnGround()); VarInts.writeUnsignedLong(buffer, packet.getRidingRuntimeEntityId()); if (packet.getMode() == Mode.TELEPORT) { buffer.writeIntLE(packet.getTeleportationCause().ordinal()); buffer.writeIntLE(packet.getEntityType()); } }
Example 6
Source File: MobEffectSerializer_v313.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, MobEffectPacket packet) { VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); buffer.writeByte(packet.getEvent().ordinal()); VarInts.writeInt(buffer, packet.getEffectId()); VarInts.writeInt(buffer, packet.getAmplifier()); buffer.writeBoolean(packet.isParticles()); VarInts.writeInt(buffer, packet.getDuration()); }
Example 7
Source File: MoveEntityAbsoluteSerializer_v354.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, MoveEntityAbsolutePacket packet) { VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); int flags = 0; if (packet.isOnGround()) { flags |= FLAG_ON_GROUND; } if (packet.isTeleported()) { flags |= FLAG_TELEPORTED; } buffer.writeByte(flags); BedrockUtils.writeVector3f(buffer, packet.getPosition()); BedrockUtils.writeByteRotation(buffer, packet.getRotation()); }
Example 8
Source File: InventoryTransactionSerializer_v388.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, InventoryTransactionPacket packet) { Type transactionType = packet.getTransactionType(); VarInts.writeUnsignedInt(buffer, transactionType.ordinal()); BedrockUtils.writeArray(buffer, packet.getActions(), BedrockUtils::writeInventoryAction); switch (transactionType) { case ITEM_USE: VarInts.writeUnsignedInt(buffer, packet.getActionType()); BedrockUtils.writeBlockPosition(buffer, packet.getBlockPosition()); VarInts.writeInt(buffer, packet.getFace()); VarInts.writeInt(buffer, packet.getHotbarSlot()); BedrockUtils.writeItemData(buffer, packet.getItemInHand()); BedrockUtils.writeVector3f(buffer, packet.getPlayerPosition()); BedrockUtils.writeVector3f(buffer, packet.getClickPosition()); VarInts.writeUnsignedInt(buffer, packet.getBlockRuntimeId()); break; case ITEM_USE_ON_ENTITY: VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); VarInts.writeUnsignedInt(buffer, packet.getActionType()); VarInts.writeInt(buffer, packet.getHotbarSlot()); BedrockUtils.writeItemData(buffer, packet.getItemInHand()); BedrockUtils.writeVector3f(buffer, packet.getPlayerPosition()); BedrockUtils.writeVector3f(buffer, packet.getClickPosition()); break; case ITEM_RELEASE: VarInts.writeUnsignedInt(buffer, packet.getActionType()); VarInts.writeInt(buffer, packet.getHotbarSlot()); BedrockUtils.writeItemData(buffer, packet.getItemInHand()); BedrockUtils.writeVector3f(buffer, packet.getHeadPosition()); } }
Example 9
Source File: MobArmorEquipmentSerializer_v340.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, MobArmorEquipmentPacket packet) { VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); BedrockUtils.writeItemData(buffer, packet.getHelmet()); BedrockUtils.writeItemData(buffer, packet.getChestplate()); BedrockUtils.writeItemData(buffer, packet.getLeggings()); BedrockUtils.writeItemData(buffer, packet.getBoots()); }
Example 10
Source File: TakeItemEntitySerializer_v332.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void serialize(ByteBuf buffer, TakeItemEntityPacket packet) { VarInts.writeUnsignedLong(buffer, packet.getItemRuntimeEntityId()); VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); }
Example 11
Source File: SetLocalPlayerAsInitializedSerializer_v291.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void serialize(ByteBuf buffer, SetLocalPlayerAsInitializedPacket packet) { VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); }
Example 12
Source File: EntityEventSerializer_v361.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void serialize(ByteBuf buffer, EntityEventPacket packet) { VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); buffer.writeByte(events.get(packet.getType())); VarInts.writeInt(buffer, packet.getData()); }
Example 13
Source File: SetEntityMotionSerializer_v313.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void serialize(ByteBuf buffer, SetEntityMotionPacket packet) { VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); BedrockUtils.writeVector3f(buffer, packet.getMotion()); }
Example 14
Source File: UpdateAttributesSerializer_v361.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void serialize(ByteBuf buffer, UpdateAttributesPacket packet) { VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); BedrockUtils.writeArray(buffer, packet.getAttributes(), BedrockUtils::writePlayerAttribute); }
Example 15
Source File: TakeItemEntitySerializer_v340.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void serialize(ByteBuf buffer, TakeItemEntityPacket packet) { VarInts.writeUnsignedLong(buffer, packet.getItemRuntimeEntityId()); VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); }
Example 16
Source File: StartGameSerializer_v388.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void serialize(ByteBuf buffer, StartGamePacket packet) { VarInts.writeLong(buffer, packet.getUniqueEntityId()); VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); VarInts.writeInt(buffer, packet.getPlayerGamemode()); BedrockUtils.writeVector3f(buffer, packet.getPlayerPosition()); BedrockUtils.writeVector2f(buffer, packet.getRotation()); // Level settings start VarInts.writeInt(buffer, packet.getSeed()); VarInts.writeInt(buffer, packet.getDimensionId()); VarInts.writeInt(buffer, packet.getGeneratorId()); VarInts.writeInt(buffer, packet.getLevelGamemode()); VarInts.writeInt(buffer, packet.getDifficulty()); BedrockUtils.writeBlockPosition(buffer, packet.getDefaultSpawn()); buffer.writeBoolean(packet.isAchievementsDisabled()); VarInts.writeInt(buffer, packet.getTime()); VarInts.writeInt(buffer, packet.getEduEditionOffers()); buffer.writeBoolean(packet.isEduFeaturesEnabled()); buffer.writeFloatLE(packet.getRainLevel()); buffer.writeFloatLE(packet.getLightningLevel()); buffer.writeBoolean(packet.isPlatformLockedContentConfirmed()); buffer.writeBoolean(packet.isMultiplayerGame()); buffer.writeBoolean(packet.isBroadcastingToLan()); VarInts.writeInt(buffer, packet.getXblBroadcastMode().ordinal()); VarInts.writeInt(buffer, packet.getPlatformBroadcastMode().ordinal()); buffer.writeBoolean(packet.isCommandsEnabled()); buffer.writeBoolean(packet.isTexturePacksRequired()); BedrockUtils.writeArray(buffer, packet.getGamerules(), BedrockUtils::writeGameRule); buffer.writeBoolean(packet.isBonusChestEnabled()); buffer.writeBoolean(packet.isStartingWithMap()); VarInts.writeInt(buffer, packet.getDefaultPlayerPermission().ordinal()); buffer.writeIntLE(packet.getServerChunkTickRange()); buffer.writeBoolean(packet.isBehaviorPackLocked()); buffer.writeBoolean(packet.isResourcePackLocked()); buffer.writeBoolean(packet.isFromLockedWorldTemplate()); buffer.writeBoolean(packet.isUsingMsaGamertagsOnly()); buffer.writeBoolean(packet.isFromWorldTemplate()); buffer.writeBoolean(packet.isWorldTemplateOptionLocked()); buffer.writeBoolean(packet.isOnlySpawningV1Villagers()); BedrockUtils.writeString(buffer, packet.getVanillaVersion()); // Level settings end BedrockUtils.writeString(buffer, packet.getLevelId()); BedrockUtils.writeString(buffer, packet.getWorldName()); BedrockUtils.writeString(buffer, packet.getPremiumWorldTemplateId()); buffer.writeBoolean(packet.isTrial()); buffer.writeBoolean(packet.isMovementServerAuthoritative()); buffer.writeLongLE(packet.getCurrentTick()); VarInts.writeInt(buffer, packet.getEnchantmentSeed()); // cache palette for fast writing try (NBTOutputStream stream = NbtUtils.createNetworkWriter(new ByteBufOutputStream(buffer))) { stream.write(packet.getBlockPalette()); } catch (IOException e) { throw new RuntimeException(e); } BedrockUtils.writeArray(buffer, packet.getItemEntries(), (buf, entry) -> { BedrockUtils.writeString(buf, entry.getIdentifier()); buf.writeShortLE(entry.getId()); }); BedrockUtils.writeString(buffer, packet.getMultiplayerCorrelationId()); }
Example 17
Source File: TakeItemEntitySerializer_v313.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void serialize(ByteBuf buffer, TakeItemEntityPacket packet) { VarInts.writeUnsignedLong(buffer, packet.getItemRuntimeEntityId()); VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); }
Example 18
Source File: StartGameSerializer_v291.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void serialize(ByteBuf buffer, StartGamePacket packet) { VarInts.writeLong(buffer, packet.getUniqueEntityId()); VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); VarInts.writeInt(buffer, packet.getPlayerGamemode()); BedrockUtils.writeVector3f(buffer, packet.getPlayerPosition()); BedrockUtils.writeVector2f(buffer, packet.getRotation()); // Level settings start VarInts.writeInt(buffer, packet.getSeed()); VarInts.writeInt(buffer, packet.getDimensionId()); VarInts.writeInt(buffer, packet.getGeneratorId()); VarInts.writeInt(buffer, packet.getLevelGamemode()); VarInts.writeInt(buffer, packet.getDifficulty()); BedrockUtils.writeBlockPosition(buffer, packet.getDefaultSpawn()); buffer.writeBoolean(packet.isAchievementsDisabled()); VarInts.writeInt(buffer, packet.getTime()); buffer.writeBoolean(packet.getEduEditionOffers() != 0); buffer.writeBoolean(packet.isEduFeaturesEnabled()); buffer.writeFloatLE(packet.getRainLevel()); buffer.writeFloatLE(packet.getLightningLevel()); buffer.writeBoolean(packet.isMultiplayerGame()); buffer.writeBoolean(packet.isBroadcastingToLan()); buffer.writeBoolean(packet.getXblBroadcastMode() != GamePublishSetting.NO_MULTI_PLAY); buffer.writeBoolean(packet.isCommandsEnabled()); buffer.writeBoolean(packet.isTexturePacksRequired()); BedrockUtils.writeArray(buffer, packet.getGamerules(), BedrockUtils::writeGameRule); buffer.writeBoolean(packet.isBonusChestEnabled()); buffer.writeBoolean(packet.isStartingWithMap()); buffer.writeBoolean(packet.isTrustingPlayers()); VarInts.writeInt(buffer, packet.getDefaultPlayerPermission().ordinal()); VarInts.writeInt(buffer, packet.getXblBroadcastMode().ordinal()); buffer.writeIntLE(packet.getServerChunkTickRange()); buffer.writeBoolean(packet.getPlatformBroadcastMode() != GamePublishSetting.NO_MULTI_PLAY); VarInts.writeInt(buffer, packet.getPlatformBroadcastMode().ordinal()); buffer.writeBoolean(packet.getXblBroadcastMode() != GamePublishSetting.NO_MULTI_PLAY); buffer.writeBoolean(packet.isBehaviorPackLocked()); buffer.writeBoolean(packet.isResourcePackLocked()); buffer.writeBoolean(packet.isFromLockedWorldTemplate()); buffer.writeBoolean(packet.isUsingMsaGamertagsOnly()); // Level settings end BedrockUtils.writeString(buffer, packet.getLevelId()); BedrockUtils.writeString(buffer, packet.getWorldName()); BedrockUtils.writeString(buffer, packet.getPremiumWorldTemplateId()); buffer.writeBoolean(packet.isTrial()); buffer.writeLongLE(packet.getCurrentTick()); VarInts.writeInt(buffer, packet.getEnchantmentSeed()); List<CompoundTag> palette = packet.getBlockPalette().getValue(); VarInts.writeUnsignedInt(buffer, palette.size()); for (CompoundTag entry : palette) { CompoundTag blockTag = entry.getCompound("block"); BedrockUtils.writeString(buffer, blockTag.getString("name")); buffer.writeShortLE(entry.getShort("meta")); } BedrockUtils.writeString(buffer, packet.getMultiplayerCorrelationId()); }
Example 19
Source File: ShowCreditsSerializer_v340.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void serialize(ByteBuf buffer, ShowCreditsPacket packet) { VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); VarInts.writeInt(buffer, packet.getStatus().ordinal()); }
Example 20
Source File: SetEntityMotionSerializer_v388.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void serialize(ByteBuf buffer, SetEntityMotionPacket packet) { VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId()); BedrockUtils.writeVector3f(buffer, packet.getMotion()); }