Initial commit

This commit is contained in:
Astatin3
2024-04-30 22:07:50 -06:00
commit 8565caa62a
8463 changed files with 4915934 additions and 0 deletions
+511
View File
@@ -0,0 +1,511 @@
project(protocolCraft)
set(protocolCraft_PUBLIC_HDR
include/protocolCraft/AllClientboundMessages.hpp
include/protocolCraft/AllMessages.hpp
include/protocolCraft/AllServerboundMessages.hpp
include/protocolCraft/BaseMessage.hpp
include/protocolCraft/BinaryReadWrite.hpp
include/protocolCraft/enums.hpp
include/protocolCraft/GenericHandler.hpp
include/protocolCraft/Handler.hpp
include/protocolCraft/Message.hpp
include/protocolCraft/MessageFactory.hpp
include/protocolCraft/NetworkType.hpp
include/protocolCraft/Messages/Handshaking/Serverbound/ServerboundClientIntentionPacket.hpp
include/protocolCraft/Messages/Login/Clientbound/ClientboundCustomQueryPacket.hpp
include/protocolCraft/Messages/Login/Clientbound/ClientboundGameProfilePacket.hpp
include/protocolCraft/Messages/Login/Clientbound/ClientboundHelloPacket.hpp
include/protocolCraft/Messages/Login/Clientbound/ClientboundLoginCompressionPacket.hpp
include/protocolCraft/Messages/Login/Clientbound/ClientboundLoginDisconnectPacket.hpp
include/protocolCraft/Messages/Login/Serverbound/ServerboundCustomQueryAnswerPacket.hpp
include/protocolCraft/Messages/Login/Serverbound/ServerboundCustomQueryPacket.hpp
include/protocolCraft/Messages/Login/Serverbound/ServerboundHelloPacket.hpp
include/protocolCraft/Messages/Login/Serverbound/ServerboundKeyPacket.hpp
include/protocolCraft/Messages/Login/Serverbound/ServerboundLoginAcknowledgedPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundAddEntityPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundAddExperienceOrbPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundAddGlobalEntityPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundAddMobPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundAddPaintingPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundAddPlayerPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundAddVibrationSignalPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundAnimatePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundAwardStatsPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundBlockBreakAckPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundBlockChangedAckPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundBlockDestructionPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundBlockEntityDataPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundBlockEventPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundBlockUpdatePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundBossEventPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundBundlePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundChangeDifficultyPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundChatPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundChatPreviewPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundChunkBatchFinishedPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundChunkBatchStartPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundChunksBiomesPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundClearTitlesPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundCommandsPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundCommandSuggestionsPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundContainerAckPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundContainerClosePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundContainerSetContentPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundContainerSetDataPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundContainerSetSlotPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundCooldownPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundCustomChatCompletionsPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundCustomPayloadPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundCustomSoundPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundDamageEventPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundDeleteChatPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundDisconnectPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundDisguisedChatPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundEntityEventPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundExplodePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundForgetLevelChunkPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundGameEventPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundHorseScreenOpenPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundHurtAnimationPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundInitializeBorderPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundKeepAlivePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundLevelChunkPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundLevelChunkWithLightPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundLevelEventPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundLevelParticlesPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundLightUpdatePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundLoginPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundMapItemDataPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundMerchantOffersPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundMoveEntityPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundMoveEntityPacketPos.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundMoveEntityPacketPosRot.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundMoveEntityPacketRot.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundMoveVehiclePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundOpenBookPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundOpenScreenPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundOpenSignEditorPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundPingPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundPlaceGhostRecipePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundPlayerAbilitiesPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundPlayerChatHeaderPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundPlayerChatPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundPlayerCombatEndPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundPlayerCombatEnterPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundPlayerCombatKillPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundPlayerCombatPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundPlayerInfoPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundPlayerInfoRemovePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundPlayerInfoUpdatePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundPlayerLookAtPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundPlayerPositionPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundPongResponsePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundRecipePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundRemoveEntitiesPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundRemoveEntityPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundRemoveMobEffectPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundResourcePackPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundResetScorePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundResourcePackPopPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundResourcePackPushPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundRespawnPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundRotateHeadPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSectionBlocksUpdatePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSelectAdvancementsTabPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundServerDataPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetActionBarTextPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetBorderCenterPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetBorderLerpSizePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetBorderPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetBorderSizePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetBorderWarningDelayPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetBorderWarningDistancePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetCameraPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetCarriedItemPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetChunkCacheCenterPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetChunkCacheRadiusPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetDefaultSpawnPositionPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetDisplayChatPreviewPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetDisplayObjectivePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetEntityDataPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetEntityLinkPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetEntityMotionPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetEquipmentPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetExperiencePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetHealthPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetObjectivePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetPassengersPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetPlayerTeamPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetScorePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetSimulationDistancePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetSubtitleTextPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetTimePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetTitlesAnimationPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetTitlesPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSetTitleTextPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSoundEntityPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSoundPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundStartConfigurationPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundStopSoundPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundSystemChatPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundTabListPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundTagQueryPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundTakeItemEntityPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundTeleportEntityPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundTickingStatePacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundTickingStepPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundUpdateAdvancementsPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundUpdateAttributesPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundUpdateEnabledFeaturesPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundUpdateMobEffectPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundUpdateRecipesPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundUpdateTagsPacket.hpp
include/protocolCraft/Messages/Play/Clientbound/ClientboundUseBedPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundAcceptTeleportationPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundBlockEntityTagQuery.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundChangeDifficultyPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundChatAckPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundChatCommandPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundChatPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundChatPreviewPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundChatSessionUpdatePacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundChunkBatchReceivedPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundClientCommandPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundClientInformationPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundCommandSuggestionPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundConfigurationAcknowledgedPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundContainerAckPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundContainerButtonClickPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundContainerClickPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundContainerClosePacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundContainerSlotStateChangedPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundCustomPayloadPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundEditBookPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundEnchantItemPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundEntityTagQuery.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundInteractPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundJigsawGeneratePacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundKeepAlivePacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundLockDifficultyPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundMovePlayerPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundMovePlayerPacketPos.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundMovePlayerPacketPosRot.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundMovePlayerPacketRot.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundMovePlayerPacketStatusOnly.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundMoveVehiclePacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundPaddleBoatPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundPickItemPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundPingRequestPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundPlaceRecipePacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundPlayerAbilitiesPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundPlayerActionPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundPlayerCommandPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundPlayerInputPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundPongPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundRecipeBookChangeSettingsPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundRecipeBookSeenRecipePacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundRecipeBookUpdatePacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundRenameItemPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundResourcePackPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundSeenAdvancementsPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundSelectTradePacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundSetBeaconPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundSetCarriedItemPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundSetCommandBlockPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundSetCommandMinecartPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundSetCreativeModeSlotPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundSetJigsawBlockPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundSetStructureBlockPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundSignUpdatePacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundSwingPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundTeleportToEntityPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundUseItemOnPacket.hpp
include/protocolCraft/Messages/Play/Serverbound/ServerboundUseItemPacket.hpp
include/protocolCraft/Messages/Status/Clientbound/ClientboundPongResponsePacket.hpp
include/protocolCraft/Messages/Status/Clientbound/ClientboundStatusResponsePacket.hpp
include/protocolCraft/Messages/Status/Serverbound/ServerboundPingRequestPacket.hpp
include/protocolCraft/Messages/Status/Serverbound/ServerboundStatusRequestPacket.hpp
include/protocolCraft/Messages/Configuration/Clientbound/ClientboundCustomPayloadPacket.hpp
include/protocolCraft/Messages/Configuration/Clientbound/ClientboundDisconnectPacket.hpp
include/protocolCraft/Messages/Configuration/Clientbound/ClientboundFinishConfigurationPacket.hpp
include/protocolCraft/Messages/Configuration/Clientbound/ClientboundKeepAlivePacket.hpp
include/protocolCraft/Messages/Configuration/Clientbound/ClientboundPingPacket.hpp
include/protocolCraft/Messages/Configuration/Clientbound/ClientboundRegistryDataPacket.hpp
include/protocolCraft/Messages/Configuration/Clientbound/ClientboundResourcePackPacket.hpp
include/protocolCraft/Messages/Configuration/Clientbound/ClientboundResourcePackPopConfigurationPacket.hpp
include/protocolCraft/Messages/Configuration/Clientbound/ClientboundResourcePackPushConfigurationPacket.hpp
include/protocolCraft/Messages/Configuration/Clientbound/ClientboundUpdateEnabledFeaturesPacket.hpp
include/protocolCraft/Messages/Configuration/Clientbound/ClientboundUpdateTagsPacket.hpp
include/protocolCraft/Messages/Configuration/Serverbound/ServerboundClientInformationPacket.hpp
include/protocolCraft/Messages/Configuration/Serverbound/ServerboundCustomPayloadPacket.hpp
include/protocolCraft/Messages/Configuration/Serverbound/ServerboundFinishConfigurationPacket.hpp
include/protocolCraft/Messages/Configuration/Serverbound/ServerboundKeepAlivePacket.hpp
include/protocolCraft/Messages/Configuration/Serverbound/ServerboundPongPacket.hpp
include/protocolCraft/Messages/Configuration/Serverbound/ServerboundResourcePackPacket.hpp
include/protocolCraft/Types/Advancement.hpp
include/protocolCraft/Types/AdvancementDisplay.hpp
include/protocolCraft/Types/AdvancementProgress.hpp
include/protocolCraft/Types/BlockEntityInfo.hpp
include/protocolCraft/Types/BlockEntityTag.hpp
include/protocolCraft/Types/ChunkBiomeData.hpp
include/protocolCraft/Types/ChunkPos.hpp
include/protocolCraft/Types/ClientboundLevelChunkPacketData.hpp
include/protocolCraft/Types/ClientboundLightUpdatePacketData.hpp
include/protocolCraft/Types/ClientInformation.hpp
include/protocolCraft/Types/CommonPlayerSpawnInfo.hpp
include/protocolCraft/Types/CriterionProgress.hpp
include/protocolCraft/Types/EntityModifierData.hpp
include/protocolCraft/Types/EntityProperty.hpp
include/protocolCraft/Types/GlobalPos.hpp
include/protocolCraft/Types/Identifier.hpp
include/protocolCraft/Types/MapDecoration.hpp
include/protocolCraft/Types/NetworkPosition.hpp
include/protocolCraft/Types/PlayerUpdate.hpp
include/protocolCraft/Types/Record.hpp
include/protocolCraft/Types/SaltSignature.hpp
include/protocolCraft/Types/Slot.hpp
include/protocolCraft/Types/Trade.hpp
include/protocolCraft/Types/Chat/Chat.hpp
include/protocolCraft/Types/Chat/ChatMessageContent.hpp
include/protocolCraft/Types/Chat/ChatSender.hpp
include/protocolCraft/Types/Chat/ChatTypeBoundNetwork.hpp
include/protocolCraft/Types/Chat/FilterMask.hpp
include/protocolCraft/Types/Chat/LastSeenMessagesEntry.hpp
include/protocolCraft/Types/Chat/LastSeenMessagesUpdate.hpp
include/protocolCraft/Types/Chat/NumberFormat.hpp
include/protocolCraft/Types/Chat/PlayerChatMessage.hpp
include/protocolCraft/Types/Chat/RemoteChatSessionData.hpp
include/protocolCraft/Types/Chat/SignedMessageHeader.hpp
include/protocolCraft/Types/Chat/SignedMessageBody.hpp
include/protocolCraft/Types/CommandNode/BrigadierProperty.hpp
include/protocolCraft/Types/CommandNode/BrigadierPropertyDouble.hpp
include/protocolCraft/Types/CommandNode/BrigadierPropertyEntity.hpp
include/protocolCraft/Types/CommandNode/BrigadierPropertyFloat.hpp
include/protocolCraft/Types/CommandNode/BrigadierPropertyInteger.hpp
include/protocolCraft/Types/CommandNode/BrigadierPropertyLong.hpp
include/protocolCraft/Types/CommandNode/BrigadierPropertyNone.hpp
include/protocolCraft/Types/CommandNode/BrigadierPropertyRange.hpp
include/protocolCraft/Types/CommandNode/BrigadierPropertyResourceOrTag.hpp
include/protocolCraft/Types/CommandNode/BrigadierPropertyScoreHolder.hpp
include/protocolCraft/Types/CommandNode/BrigadierPropertyString.hpp
include/protocolCraft/Types/CommandNode/BrigadierPropertyTime.hpp
include/protocolCraft/Types/CommandNode/CommandNode.hpp
include/protocolCraft/Types/GameProfile/GameProfile.hpp
include/protocolCraft/Types/GameProfile/GameProfileProperty.hpp
include/protocolCraft/Types/GameProfile/ProfilePublicKey.hpp
include/protocolCraft/Types/NBT/NBT.hpp
include/protocolCraft/Types/NBT/Tag.hpp
include/protocolCraft/Types/Particles/BlockcrackParticle.hpp
include/protocolCraft/Types/Particles/BlockdustParticle.hpp
include/protocolCraft/Types/Particles/BlockMarkerParticle.hpp
include/protocolCraft/Types/Particles/BlockParticle.hpp
include/protocolCraft/Types/Particles/DustColorTransitionParticle.hpp
include/protocolCraft/Types/Particles/DustParticle.hpp
include/protocolCraft/Types/Particles/FallingDustParticle.hpp
include/protocolCraft/Types/Particles/IconcrackParticle.hpp
include/protocolCraft/Types/Particles/ItemParticle.hpp
include/protocolCraft/Types/Particles/NoDataTypedParticle.hpp
include/protocolCraft/Types/Particles/Particle.hpp
include/protocolCraft/Types/Particles/SculkChargeParticle.hpp
include/protocolCraft/Types/Particles/ShriekParticle.hpp
include/protocolCraft/Types/Particles/VibrationParticle.hpp
include/protocolCraft/Types/Recipes/Ingredient.hpp
include/protocolCraft/Types/Recipes/Recipe.hpp
include/protocolCraft/Types/Recipes/RecipeBookSettings.hpp
include/protocolCraft/Types/Recipes/RecipeTypeData.hpp
include/protocolCraft/Types/Recipes/RecipeTypeDataBlasting.hpp
include/protocolCraft/Types/Recipes/RecipeTypeDataCampfireCooking.hpp
include/protocolCraft/Types/Recipes/RecipeTypeDataNone.hpp
include/protocolCraft/Types/Recipes/RecipeTypeDataShaped.hpp
include/protocolCraft/Types/Recipes/RecipeTypeDataShapeless.hpp
include/protocolCraft/Types/Recipes/RecipeTypeDataSmelting.hpp
include/protocolCraft/Types/Recipes/RecipeTypeDataSmithing.hpp
include/protocolCraft/Types/Recipes/RecipeTypeDataSmithingTransform.hpp
include/protocolCraft/Types/Recipes/RecipeTypeDataSmithingTrim.hpp
include/protocolCraft/Types/Recipes/RecipeTypeDataSmoking.hpp
include/protocolCraft/Types/Recipes/RecipeTypeDataStoneCutting.hpp
include/protocolCraft/Types/Sound/SoundEvent.hpp
include/protocolCraft/Types/Vibrations/BlockPositionSource.hpp
include/protocolCraft/Types/Vibrations/EntityPositionSource.hpp
include/protocolCraft/Types/Vibrations/PositionSource.hpp
include/protocolCraft/Types/Vibrations/VibrationPath.hpp
include/protocolCraft/Utilities/GZip.hpp
include/protocolCraft/Utilities/Json.hpp
include/protocolCraft/Utilities/RecursiveWrapper.hpp
include/protocolCraft/Utilities/TupleCat.hpp
include/protocolCraft/Utilities/Plugins/PluginLoader.hpp
include/protocolCraft/Utilities/Plugins/PluginObject.hpp
)
set(protocolCraft_SRC
src/BaseMessage.cpp
src/BinaryReadWrite.cpp
src/MessageFactory.cpp
src/Types/Chat/Chat.cpp
src/Types/CommandNode/BrigadierProperty.cpp
src/Types/NBT/NBT.cpp
src/Types/NBT/Tag.cpp
src/Types/Particles/BlockcrackParticle.cpp
src/Types/Particles/BlockdustParticle.cpp
src/Types/Particles/BlockMarkerParticle.cpp
src/Types/Particles/BlockParticle.cpp
src/Types/Particles/DustColorTransitionParticle.cpp
src/Types/Particles/DustParticle.cpp
src/Types/Particles/FallingDustParticle.cpp
src/Types/Particles/IconcrackParticle.cpp
src/Types/Particles/ItemParticle.cpp
src/Types/Particles/NoDataTypedParticle.cpp
src/Types/Particles/Particle.cpp
src/Types/Particles/SculkChargeParticle.cpp
src/Types/Particles/ShriekParticle.cpp
src/Types/Particles/VibrationParticle.cpp
src/Types/Recipes/RecipeTypeData.cpp
src/Types/Vibrations/PositionSource.cpp
src/Utilities/GZip.cpp
src/Utilities/Json.cpp
src/Utilities/Plugins/PluginLoader.cpp
)
# To have a nice files structure in Visual Studio
if(MSVC)
foreach(source IN LISTS protocolCraft_PUBLIC_HDR)
get_filename_component(source_path_header "${source}" PATH)
string(REPLACE "include/protocolCraft" "Header Files/public" source_path_header "${source_path_header}")
string(REPLACE "/" "\\" source_path_msvc "${source_path_header}")
source_group("${source_path_msvc}" FILES "${source}")
endforeach()
foreach(source IN LISTS protocolCraft_SRC)
get_filename_component(source_path "${source}" PATH)
string(REPLACE "src" "Source Files" source_path "${source_path}")
string(REPLACE "/" "\\" source_path_msvc "${source_path}")
source_group("${source_path_msvc}" FILES "${source}")
endforeach()
endif()
if(PROTOCOLCRAFT_STATIC)
add_library(protocolCraft STATIC ${protocolCraft_SRC} ${protocolCraft_PUBLIC_HDR})
else()
add_library(protocolCraft SHARED ${protocolCraft_SRC} ${protocolCraft_PUBLIC_HDR})
endif(PROTOCOLCRAFT_STATIC)
set_property(TARGET protocolCraft PROPERTY CXX_STANDARD 17)
set_property(TARGET protocolCraft PROPERTY POSITION_INDEPENDENT_CODE ON)
set_target_properties(protocolCraft PROPERTIES DEBUG_POSTFIX "_d")
set_target_properties(protocolCraft PROPERTIES RELWITHDEBINFO_POSTFIX "_rd")
if(MSVC)
# To avoid having folder for each configuration when building with Visual
set_target_properties(protocolCraft PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG "${BOTCRAFT_OUTPUT_DIR}/bin")
set_target_properties(protocolCraft PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE "${BOTCRAFT_OUTPUT_DIR}/bin")
set_target_properties(protocolCraft PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${BOTCRAFT_OUTPUT_DIR}/bin")
set_target_properties(protocolCraft PROPERTIES RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${BOTCRAFT_OUTPUT_DIR}/bin")
set_target_properties(protocolCraft PROPERTIES LIBRARY_OUTPUT_DIRECTORY_DEBUG "${BOTCRAFT_OUTPUT_DIR}/bin")
set_target_properties(protocolCraft PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELEASE "${BOTCRAFT_OUTPUT_DIR}/bin")
set_target_properties(protocolCraft PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${BOTCRAFT_OUTPUT_DIR}/bin")
set_target_properties(protocolCraft PROPERTIES LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL "${BOTCRAFT_OUTPUT_DIR}/bin")
set_target_properties(protocolCraft PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${BOTCRAFT_OUTPUT_DIR}/lib")
set_target_properties(protocolCraft PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${BOTCRAFT_OUTPUT_DIR}/lib")
set_target_properties(protocolCraft PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${BOTCRAFT_OUTPUT_DIR}/lib")
set_target_properties(protocolCraft PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL "${BOTCRAFT_OUTPUT_DIR}/lib")
else()
set_target_properties(protocolCraft PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${BOTCRAFT_OUTPUT_DIR}/bin")
set_target_properties(protocolCraft PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${BOTCRAFT_OUTPUT_DIR}/bin")
set_target_properties(protocolCraft PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${BOTCRAFT_OUTPUT_DIR}/lib")
endif(MSVC)
if (MSVC)
target_compile_options(protocolCraft PRIVATE "$<$<CONFIG:Debug>:/bigobj>")
endif (MSVC)
# Set version
target_compile_definitions(protocolCraft PUBLIC PROTOCOL_VERSION=${PROTOCOL_VERSION})
# Add include folders
target_include_directories(protocolCraft
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)
if(BOTCRAFT_COMPRESSION)
target_link_libraries(protocolCraft PRIVATE ZLIB::ZLIB)
target_compile_definitions(protocolCraft PRIVATE USE_COMPRESSION=1)
endif(BOTCRAFT_COMPRESSION)
# Add DL lib for linux compilation
target_link_libraries(protocolCraft PUBLIC ${CMAKE_DL_LIBS})
# Installation stuff
include(GNUInstallDirs)
install(TARGETS protocolCraft
EXPORT protocolCraft-targets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_BINDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/protocolCraft"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
install(EXPORT protocolCraft-targets
# lowercase as required by find_package
FILE protocolcraft-targets.cmake
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/protocolCraft"
)
include(CMakePackageConfigHelpers)
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/protocolCraft-config.cmake.in"
# lowercase as required by find_package
"${CMAKE_CURRENT_BINARY_DIR}/cmake/protocolcraft-config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/protocolCraft"
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/cmake/protocolcraft-config.cmake"
DESTINATION
"${CMAKE_INSTALL_LIBDIR}/cmake/protocolCraft"
)
export(EXPORT protocolCraft-targets
# lowercase as required by find_package
FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/protocolcraft-targets.cmake"
)
@@ -0,0 +1,6 @@
@PACKAGE_INIT@
if(NOT TARGET protocolCraft)
# lowercase as required by find_package
include(${CMAKE_CURRENT_LIST_DIR}/protocolcraft-targets.cmake)
endif()
@@ -0,0 +1,530 @@
#pragma once
#include <tuple>
#include "protocolCraft/Utilities/TupleCat.hpp"
// Login clientbound
#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
#include "protocolCraft/Messages/Login/Clientbound/ClientboundCustomQueryPacket.hpp"
#endif
#include "protocolCraft/Messages/Login/Clientbound/ClientboundLoginDisconnectPacket.hpp"
#include "protocolCraft/Messages/Login/Clientbound/ClientboundHelloPacket.hpp"
#include "protocolCraft/Messages/Login/Clientbound/ClientboundGameProfilePacket.hpp"
#include "protocolCraft/Messages/Login/Clientbound/ClientboundLoginCompressionPacket.hpp"
// Status Clientbound
#include "protocolCraft/Messages/Status/Clientbound/ClientboundPongResponsePacket.hpp"
#include "protocolCraft/Messages/Status/Clientbound/ClientboundStatusResponsePacket.hpp"
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
// Configuration Clientbound
#include "protocolCraft/Messages/Configuration/Clientbound/ClientboundCustomPayloadPacket.hpp"
#include "protocolCraft/Messages/Configuration/Clientbound/ClientboundDisconnectPacket.hpp"
#include "protocolCraft/Messages/Configuration/Clientbound/ClientboundFinishConfigurationPacket.hpp"
#include "protocolCraft/Messages/Configuration/Clientbound/ClientboundKeepAlivePacket.hpp"
#include "protocolCraft/Messages/Configuration/Clientbound/ClientboundPingPacket.hpp"
#include "protocolCraft/Messages/Configuration/Clientbound/ClientboundRegistryDataPacket.hpp"
#include "protocolCraft/Messages/Configuration/Clientbound/ClientboundResourcePackPacket.hpp"
#include "protocolCraft/Messages/Configuration/Clientbound/ClientboundUpdateEnabledFeaturesPacket.hpp"
#include "protocolCraft/Messages/Configuration/Clientbound/ClientboundUpdateTagsPacket.hpp"
#endif
#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
#include "protocolCraft/Messages/Configuration/Clientbound/ClientboundResourcePackPopConfigurationPacket.hpp"
#include "protocolCraft/Messages/Configuration/Clientbound/ClientboundResourcePackPushConfigurationPacket.hpp"
#endif
// Play clientbound
#include "protocolCraft/Messages/Play/Clientbound/ClientboundBlockUpdatePacket.hpp"
#if PROTOCOL_VERSION < 759 /* < 1.19 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundChatPacket.hpp"
#endif
#include "protocolCraft/Messages/Play/Clientbound/ClientboundChangeDifficultyPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSectionBlocksUpdatePacket.hpp"
#if PROTOCOL_VERSION < 755 /* < 1.17 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundContainerAckPacket.hpp"
#endif
#include "protocolCraft/Messages/Play/Clientbound/ClientboundDisconnectPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundForgetLevelChunkPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundKeepAlivePacket.hpp"
#if PROTOCOL_VERSION < 757 /* < 1.18 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundLevelChunkPacket.hpp"
#endif
#include "protocolCraft/Messages/Play/Clientbound/ClientboundLoginPacket.hpp"
#if PROTOCOL_VERSION < 755 /* < 1.17 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundMoveEntityPacket.hpp"
#endif
#include "protocolCraft/Messages/Play/Clientbound/ClientboundMoveEntityPacketPos.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundMoveEntityPacketPosRot.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundMoveEntityPacketRot.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundPlayerPositionPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetHealthPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundTeleportEntityPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundPlayerAbilitiesPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetTimePacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundRespawnPacket.hpp"
#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundLightUpdatePacket.hpp"
#endif
#include "protocolCraft/Messages/Play/Clientbound/ClientboundBlockEntityDataPacket.hpp"
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundPlayerInfoPacket.hpp"
#endif
#if PROTOCOL_VERSION > 493 /* > 1.14.3 */ && PROTOCOL_VERSION < 759 /* < 1.19 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundBlockBreakAckPacket.hpp"
#endif
#include "protocolCraft/Messages/Play/Clientbound/ClientboundContainerSetSlotPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundContainerSetContentPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundOpenScreenPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetCarriedItemPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundAddEntityPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundAddExperienceOrbPacket.hpp"
#if PROTOCOL_VERSION < 721 /* < 1.16 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundAddGlobalEntityPacket.hpp"
#endif
#if PROTOCOL_VERSION < 759 /* < 1.19 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundAddMobPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundAddPaintingPacket.hpp"
#endif
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundAddPlayerPacket.hpp"
#endif
#include "protocolCraft/Messages/Play/Clientbound/ClientboundAnimatePacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundAwardStatsPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundBlockDestructionPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundBlockEventPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundBossEventPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundCommandSuggestionsPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundContainerClosePacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundContainerSetDataPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundCooldownPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundCustomPayloadPacket.hpp"
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundCustomSoundPacket.hpp"
#endif
#include "protocolCraft/Messages/Play/Clientbound/ClientboundEntityEventPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundExplodePacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundGameEventPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundLevelEventPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundLevelParticlesPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundMapItemDataPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundMoveVehiclePacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundOpenSignEditorPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundPlaceGhostRecipePacket.hpp"
#if PROTOCOL_VERSION < 755 /* < 1.17 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundPlayerCombatPacket.hpp"
#endif
#if PROTOCOL_VERSION < 461 /* < 1.14 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundUseBedPacket.hpp"
#endif
#include "protocolCraft/Messages/Play/Clientbound/ClientboundRecipePacket.hpp"
#if PROTOCOL_VERSION == 755 /* 1.17 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundRemoveEntityPacket.hpp"
#else
#include "protocolCraft/Messages/Play/Clientbound/ClientboundRemoveEntitiesPacket.hpp"
#endif
#include "protocolCraft/Messages/Play/Clientbound/ClientboundRemoveMobEffectPacket.hpp"
#if PROTOCOL_VERSION < 765 /* < 1.20.3 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundResourcePackPacket.hpp"
#endif
#include "protocolCraft/Messages/Play/Clientbound/ClientboundRotateHeadPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSelectAdvancementsTabPacket.hpp"
#if PROTOCOL_VERSION < 755 /* < 1.17 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetBorderPacket.hpp"
#endif
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetCameraPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetDisplayObjectivePacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetEntityDataPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetEntityLinkPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetEntityMotionPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetEquipmentPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetExperiencePacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetObjectivePacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetPassengersPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetPlayerTeamPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetScorePacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetDefaultSpawnPositionPacket.hpp"
#if PROTOCOL_VERSION < 755 /* < 1.17 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetTitlesPacket.hpp"
#endif
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSoundPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundTabListPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundTakeItemEntityPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundUpdateAdvancementsPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundUpdateAttributesPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundUpdateMobEffectPacket.hpp"
#if PROTOCOL_VERSION > 344 /* > 1.12.2 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundCommandsPacket.hpp"
#endif
#if PROTOCOL_VERSION > 388 /* > 1.12.2 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundTagQueryPacket.hpp"
#endif
#if PROTOCOL_VERSION > 351 /* > 1.12.2 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundPlayerLookAtPacket.hpp"
#endif
#if PROTOCOL_VERSION > 342 /* > 1.12.2 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundStopSoundPacket.hpp"
#endif
#if PROTOCOL_VERSION > 347 /* > 1.12.2 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundUpdateRecipesPacket.hpp"
#endif
#if PROTOCOL_VERSION > 348 /* > 1.12.2 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundUpdateTagsPacket.hpp"
#endif
#if PROTOCOL_VERSION > 451 /* > 1.13.2 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundHorseScreenOpenPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundMerchantOffersPacket.hpp"
#endif
#if PROTOCOL_VERSION > 450 /* > 1.13.2 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundOpenBookPacket.hpp"
#endif
#if PROTOCOL_VERSION > 471 /* > 1.13.2 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetChunkCacheCenterPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetChunkCacheRadiusPacket.hpp"
#endif
#if PROTOCOL_VERSION > 440 /* > 1.13.2 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSoundEntityPacket.hpp"
#endif
#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
#if PROTOCOL_VERSION < 759 /* < 1.19 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundAddVibrationSignalPacket.hpp"
#endif
#include "protocolCraft/Messages/Play/Clientbound/ClientboundClearTitlesPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundInitializeBorderPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundPingPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundPlayerCombatEndPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundPlayerCombatEnterPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundPlayerCombatKillPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetActionBarTextPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetBorderCenterPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetBorderLerpSizePacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetBorderSizePacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetBorderWarningDelayPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetBorderWarningDistancePacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetSubtitleTextPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetTitleTextPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetTitlesAnimationPacket.hpp"
#endif
#if PROTOCOL_VERSION > 756 /* > 1.17.1 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundLevelChunkWithLightPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetSimulationDistancePacket.hpp"
#endif
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundBlockChangedAckPacket.hpp"
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundChatPreviewPacket.hpp"
#endif
#include "protocolCraft/Messages/Play/Clientbound/ClientboundPlayerChatPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundServerDataPacket.hpp"
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSetDisplayChatPreviewPacket.hpp"
#endif
#include "protocolCraft/Messages/Play/Clientbound/ClientboundSystemChatPacket.hpp"
#endif
#if PROTOCOL_VERSION > 759 /* > 1.19 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundCustomChatCompletionsPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundDeleteChatPacket.hpp"
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundPlayerChatHeaderPacket.hpp"
#endif
#endif
#if PROTOCOL_VERSION > 760 /* > 1.19.2 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundDisguisedChatPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundPlayerInfoRemovePacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundPlayerInfoUpdatePacket.hpp"
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundUpdateEnabledFeaturesPacket.hpp"
#endif
#endif
#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundBundlePacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundChunksBiomesPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundDamageEventPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundHurtAnimationPacket.hpp"
#endif
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundChunkBatchFinishedPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundChunkBatchStartPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundPongResponsePacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundStartConfigurationPacket.hpp"
#endif
#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
#include "protocolCraft/Messages/Play/Clientbound/ClientboundResetScorePacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundResourcePackPopPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundResourcePackPushPacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundTickingStatePacket.hpp"
#include "protocolCraft/Messages/Play/Clientbound/ClientboundTickingStepPacket.hpp"
#endif
namespace ProtocolCraft
{
using AllClientboundLoginMessages = std::tuple<
#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
ClientboundCustomQueryPacket,
#endif
ClientboundLoginDisconnectPacket,
ClientboundHelloPacket,
ClientboundGameProfilePacket,
ClientboundLoginCompressionPacket
>;
using AllClientboundStatusMessages = std::tuple<
ClientboundStatusResponsePacket,
ClientboundPongResponseStatusPacket
>;
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
using AllClientboundConfigurationMessages = std::tuple<
ClientboundCustomPayloadConfigurationPacket,
ClientboundDisconnectConfigurationPacket,
ClientboundFinishConfigurationPacket,
ClientboundKeepAliveConfigurationPacket,
ClientboundPingConfigurationPacket,
ClientboundRegistryDataPacket,
#if PROTOCOL_VERSION < 765 /* < 1.20.3 */
ClientboundResourcePackConfigurationPacket,
#endif
#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
ClientboundResourcePackPopConfigurationPacket,
ClientboundResourcePackPushConfigurationPacket,
#endif
ClientboundUpdateEnabledFeaturesPacket,
ClientboundUpdateTagsConfigurationPacket
>;
#endif
using AllClientboundPlayMessages = std::tuple<
ClientboundUpdateAdvancementsPacket,
ClientboundSetEntityLinkPacket,
ClientboundBlockEventPacket,
ClientboundBlockDestructionPacket,
ClientboundBlockUpdatePacket,
ClientboundBossEventPacket,
ClientboundSetCameraPacket,
ClientboundContainerClosePacket,
ClientboundTakeItemEntityPacket,
#if PROTOCOL_VERSION < 755 /* < 1.17 */
ClientboundPlayerCombatPacket,
#endif
#if PROTOCOL_VERSION == 755 /* 1.17 */
ClientboundRemoveEntityPacket,
#else
ClientboundRemoveEntitiesPacket,
#endif
#if PROTOCOL_VERSION > 345 /* > 1.12.2 */
ClientboundCommandsPacket,
#endif
#if PROTOCOL_VERSION > 347 /* > 1.12.2 */
ClientboundUpdateRecipesPacket,
#endif
#if PROTOCOL_VERSION > 351 /* > 1.12.2 */
ClientboundPlayerLookAtPacket,
#endif
ClientboundChangeDifficultyPacket,
ClientboundMapItemDataPacket,
ClientboundSectionBlocksUpdatePacket,
#if PROTOCOL_VERSION < 755 /* < 1.17 */
ClientboundContainerAckPacket,
#endif
ClientboundGameEventPacket,
ClientboundPlaceGhostRecipePacket,
ClientboundDisconnectPacket,
ClientboundSetDisplayObjectivePacket,
ClientboundForgetLevelChunkPacket,
ClientboundKeepAlivePacket,
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
ClientboundCustomSoundPacket,
#endif
#if PROTOCOL_VERSION > 388 /* > 1.12.2 */
ClientboundTagQueryPacket,
#endif
ClientboundOpenSignEditorPacket,
#if PROTOCOL_VERSION > 451 /* > 1.13.2 */
ClientboundHorseScreenOpenPacket,
#endif
#if PROTOCOL_VERSION > 450 /* > 1.13.2 */
ClientboundOpenBookPacket,
#endif
#if PROTOCOL_VERSION < 757 /* < 1.18 */
ClientboundLevelChunkPacket,
#endif
ClientboundLoginPacket,
ClientboundLevelEventPacket,
#if PROTOCOL_VERSION < 755 /* < 1.17 */
ClientboundMoveEntityPacket,
#endif
ClientboundAnimatePacket,
ClientboundSetEquipmentPacket,
ClientboundUpdateMobEffectPacket,
ClientboundRotateHeadPacket,
ClientboundMoveEntityPacketPos,
ClientboundMoveEntityPacketPosRot,
ClientboundMoveEntityPacketRot,
ClientboundSetEntityDataPacket,
ClientboundUpdateAttributesPacket,
#if PROTOCOL_VERSION > 450 /* > 1.13.2 */
ClientboundSoundEntityPacket,
#endif
ClientboundEntityEventPacket,
ClientboundSetEntityMotionPacket,
ClientboundExplodePacket,
ClientboundLevelParticlesPacket,
ClientboundPlayerPositionPacket,
ClientboundSetHealthPacket,
ClientboundTeleportEntityPacket,
ClientboundPlayerAbilitiesPacket,
ClientboundSetTimePacket,
#if PROTOCOL_VERSION < 759 /* < 1.19 */
ClientboundChatPacket,
#endif
ClientboundRespawnPacket,
#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
ClientboundLightUpdatePacket,
#endif
#if PROTOCOL_VERSION > 493 /* > 1.14.3 */ && PROTOCOL_VERSION < 759 /* < 1.19 */
ClientboundBlockBreakAckPacket,
#endif
ClientboundBlockEntityDataPacket,
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
ClientboundPlayerInfoPacket,
#endif
ClientboundTabListPacket,
ClientboundCustomPayloadPacket,
ClientboundRemoveMobEffectPacket,
#if PROTOCOL_VERSION < 765 /* < 1.20.3 */
ClientboundResourcePackPacket,
#endif
ClientboundSetObjectivePacket,
ClientboundSelectAdvancementsTabPacket,
ClientboundSetExperiencePacket,
ClientboundContainerSetSlotPacket,
ClientboundCooldownPacket,
ClientboundSetPassengersPacket,
ClientboundSoundPacket,
ClientboundAddExperienceOrbPacket,
#if PROTOCOL_VERSION < 721 /* < 1.16 */
ClientboundAddGlobalEntityPacket,
#endif
#if PROTOCOL_VERSION < 759 /* < 1.19 */
ClientboundAddMobPacket,
#endif
ClientboundAddEntityPacket,
#if PROTOCOL_VERSION < 759 /* < 1.19 */
ClientboundAddPaintingPacket,
#endif
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
ClientboundAddPlayerPacket,
#endif
ClientboundSetDefaultSpawnPositionPacket,
ClientboundAwardStatsPacket,
#if PROTOCOL_VERSION > 342 /* > 1.12.2 */
ClientboundStopSoundPacket,
#endif
#if PROTOCOL_VERSION > 348 /* > 1.12.2 */
ClientboundUpdateTagsPacket,
#endif
ClientboundCommandSuggestionsPacket,
ClientboundSetPlayerTeamPacket,
#if PROTOCOL_VERSION < 755 /* < 1.17 */
ClientboundSetTitlesPacket,
#endif
#if PROTOCOL_VERSION < 461 /* < 1.14 */
ClientboundUseBedPacket,
#endif
#if PROTOCOL_VERSION > 451 /* > 1.13.2 */
ClientboundMerchantOffersPacket,
#endif
ClientboundRecipePacket,
ClientboundSetScorePacket,
#if PROTOCOL_VERSION > 471 /* > 1.13.2 */
ClientboundSetChunkCacheCenterPacket,
ClientboundSetChunkCacheRadiusPacket,
#endif
ClientboundMoveVehiclePacket,
ClientboundContainerSetContentPacket,
ClientboundContainerSetDataPacket,
ClientboundOpenScreenPacket,
#if PROTOCOL_VERSION < 755 /* < 1.17 */
ClientboundSetBorderPacket,
#endif
#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
#if PROTOCOL_VERSION < 759 /* < 1.19 */
ClientboundAddVibrationSignalPacket,
#endif
ClientboundClearTitlesPacket,
ClientboundInitializeBorderPacket,
ClientboundPingPacket,
ClientboundPlayerCombatEndPacket,
ClientboundPlayerCombatEnterPacket,
ClientboundPlayerCombatKillPacket,
ClientboundSetActionBarTextPacket,
ClientboundSetBorderCenterPacket,
ClientboundSetBorderLerpSizePacket,
ClientboundSetBorderSizePacket,
ClientboundSetBorderWarningDelayPacket,
ClientboundSetBorderWarningDistancePacket,
ClientboundSetSubtitleTextPacket,
ClientboundSetTitleTextPacket,
ClientboundSetTitlesAnimationPacket,
#endif
#if PROTOCOL_VERSION > 756 /* > 1.17.1 */
ClientboundLevelChunkWithLightPacket,
ClientboundSetSimulationDistancePacket,
#endif
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
ClientboundBlockChangedAckPacket,
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
ClientboundChatPreviewPacket,
#endif
ClientboundPlayerChatPacket,
ClientboundServerDataPacket,
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
ClientboundSetDisplayChatPreviewPacket,
#endif
ClientboundSystemChatPacket,
#endif
#if PROTOCOL_VERSION > 759 /* > 1.19 */
ClientboundCustomChatCompletionsPacket,
ClientboundDeleteChatPacket,
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
ClientboundPlayerChatHeaderPacket,
#endif
#endif
#if PROTOCOL_VERSION > 760 /* > 1.19.2 */
ClientboundDisguisedChatPacket,
ClientboundPlayerInfoRemovePacket,
ClientboundPlayerInfoUpdatePacket,
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
ClientboundUpdateEnabledFeaturesPacket,
#endif
#endif
#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
ClientboundBundlePacket,
ClientboundChunksBiomesPacket,
ClientboundDamageEventPacket,
ClientboundHurtAnimationPacket,
#endif
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
ClientboundChunkBatchFinishedPacket,
ClientboundChunkBatchStartPacket,
ClientboundPongResponsePacket,
ClientboundStartConfigurationPacket,
#endif
#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
ClientboundResetScorePacket,
ClientboundResourcePackPopPacket,
ClientboundResourcePackPushPacket,
ClientboundTickingStatePacket,
ClientboundTickingStepPacket,
#endif
ClientboundSetCarriedItemPacket
>;
using AllClientboundMessages = Internal::tuple_cat_t<
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
AllClientboundConfigurationMessages,
#endif
AllClientboundLoginMessages,
AllClientboundStatusMessages,
AllClientboundPlayMessages
>;
} //ProtocolCraft
@@ -0,0 +1,15 @@
#pragma once
#include <tuple>
#include "protocolCraft/Utilities/TupleCat.hpp"
#include "protocolCraft/AllClientboundMessages.hpp"
#include "protocolCraft/AllServerboundMessages.hpp"
namespace ProtocolCraft
{
using AllMessages = Internal::tuple_cat_t<
AllClientboundMessages,
AllServerboundMessages
>;
} //ProtocolCraft
@@ -0,0 +1,285 @@
#pragma once
#include <tuple>
#include "protocolCraft/Utilities/TupleCat.hpp"
// Handshaking serverbound
#include "protocolCraft/Messages/Handshaking/Serverbound/ServerboundClientIntentionPacket.hpp"
// Login serverbound
#if PROTOCOL_VERSION > 340 /* > 1.12.2 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
#include "protocolCraft/Messages/Login/Serverbound/ServerboundCustomQueryPacket.hpp"
#endif
#include "protocolCraft/Messages/Login/Serverbound/ServerboundHelloPacket.hpp"
#include "protocolCraft/Messages/Login/Serverbound/ServerboundKeyPacket.hpp"
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
#include "protocolCraft/Messages/Login/Serverbound/ServerboundCustomQueryAnswerPacket.hpp"
#include "protocolCraft/Messages/Login/Serverbound/ServerboundLoginAcknowledgedPacket.hpp"
#endif
// Status Serverbound
#include "protocolCraft/Messages/Status/Serverbound/ServerboundPingRequestPacket.hpp"
#include "protocolCraft/Messages/Status/Serverbound/ServerboundStatusRequestPacket.hpp"
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
// Configuration Serverbound
#include "protocolCraft/Messages/Configuration/Serverbound/ServerboundClientInformationPacket.hpp"
#include "protocolCraft/Messages/Configuration/Serverbound/ServerboundCustomPayloadPacket.hpp"
#include "protocolCraft/Messages/Configuration/Serverbound/ServerboundFinishConfigurationPacket.hpp"
#include "protocolCraft/Messages/Configuration/Serverbound/ServerboundKeepAlivePacket.hpp"
#include "protocolCraft/Messages/Configuration/Serverbound/ServerboundPongPacket.hpp"
#include "protocolCraft/Messages/Configuration/Serverbound/ServerboundResourcePackPacket.hpp"
#endif
// Play serverbound
#include "protocolCraft/Messages/Play/Serverbound/ServerboundChatPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundClientCommandPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundMovePlayerPacketPosRot.hpp"
#if PROTOCOL_VERSION < 755 /* < 1.17 */
#include "protocolCraft/Messages/Play/Serverbound/ServerboundContainerAckPacket.hpp"
#endif
#include "protocolCraft/Messages/Play/Serverbound/ServerboundKeepAlivePacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundClientInformationPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundAcceptTeleportationPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundPlayerActionPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundCommandSuggestionPacket.hpp"
#if PROTOCOL_VERSION < 476 /* < 1.14 */
#include "protocolCraft/Messages/Play/Serverbound/ServerboundEnchantItemPacket.hpp"
#endif
#include "protocolCraft/Messages/Play/Serverbound/ServerboundContainerClickPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundContainerClosePacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundCustomPayloadPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundInteractPacket.hpp"
#if PROTOCOL_VERSION < 755 /* < 1.17 */
#include "protocolCraft/Messages/Play/Serverbound/ServerboundMovePlayerPacket.hpp"
#endif
#include "protocolCraft/Messages/Play/Serverbound/ServerboundMovePlayerPacketPos.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundMovePlayerPacketRot.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundMoveVehiclePacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundPaddleBoatPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundPlaceRecipePacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundPlayerAbilitiesPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundPlayerCommandPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundPlayerInputPacket.hpp"
#if PROTOCOL_VERSION > 736 /* > 1.16.1 */
#include "protocolCraft/Messages/Play/Serverbound/ServerboundRecipeBookSeenRecipePacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundRecipeBookChangeSettingsPacket.hpp"
#else
#include "protocolCraft/Messages/Play/Serverbound/ServerboundRecipeBookUpdatePacket.hpp"
#endif
#include "protocolCraft/Messages/Play/Serverbound/ServerboundResourcePackPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundSeenAdvancementsPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundSetCarriedItemPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundSetCreativeModeSlotPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundSignUpdatePacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundSwingPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundTeleportToEntityPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundUseItemOnPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundUseItemPacket.hpp"
#if PROTOCOL_VERSION > 388 /* > 1.12.2 */
#include "protocolCraft/Messages/Play/Serverbound/ServerboundBlockEntityTagQuery.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundEntityTagQuery.hpp"
#endif
#if PROTOCOL_VERSION > 385 /* > 1.12.2 */
#include "protocolCraft/Messages/Play/Serverbound/ServerboundEditBookPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundPickItemPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundRenameItemPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundSelectTradePacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundSetBeaconPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundSetCommandBlockPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundSetCommandMinecartPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundSetStructureBlockPacket.hpp"
#endif
#if PROTOCOL_VERSION > 463 /* > 1.13.2 */
#include "protocolCraft/Messages/Play/Serverbound/ServerboundChangeDifficultyPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundLockDifficultyPacket.hpp"
#endif
#if PROTOCOL_VERSION > 476 /* > 1.13.2 */
#include "protocolCraft/Messages/Play/Serverbound/ServerboundContainerButtonClickPacket.hpp"
#endif
#if PROTOCOL_VERSION > 471 /* > 1.13.2 */
#include "protocolCraft/Messages/Play/Serverbound/ServerboundSetJigsawBlockPacket.hpp"
#endif
#if PROTOCOL_VERSION > 711 /* > 1.15.2 */
#include "protocolCraft/Messages/Play/Serverbound/ServerboundJigsawGeneratePacket.hpp"
#endif
#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
#include "protocolCraft/Messages/Play/Serverbound/ServerboundMovePlayerPacketStatusOnly.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundPongPacket.hpp"
#endif
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
#include "protocolCraft/Messages/Play/Serverbound/ServerboundChatCommandPacket.hpp"
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
#include "protocolCraft/Messages/Play/Serverbound/ServerboundChatPreviewPacket.hpp"
#endif
#endif
#if PROTOCOL_VERSION > 759 /* > 1.19 */
#include "protocolCraft/Messages/Play/Serverbound/ServerboundChatAckPacket.hpp"
#endif
#if PROTOCOL_VERSION > 760 /* > 1.19.2 */
#include "protocolCraft/Messages/Play/Serverbound/ServerboundChatSessionUpdatePacket.hpp"
#endif
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
#include "protocolCraft/Messages/Play/Serverbound/ServerboundChunkBatchReceivedPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundConfigurationAcknowledgedPacket.hpp"
#include "protocolCraft/Messages/Play/Serverbound/ServerboundPingRequestPacket.hpp"
#endif
#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
#include "protocolCraft/Messages/Play/Serverbound/ServerboundContainerSlotStateChangedPacket.hpp"
#endif
namespace ProtocolCraft
{
using AllServerboundLoginMessages = std::tuple<
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
ServerboundCustomQueryAnswerPacket,
ServerboundLoginAcknowledgedPacket,
#endif
#if PROTOCOL_VERSION > 340 /* > 1.12.2 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
ServerboundCustomQueryPacket,
#endif
ServerboundHelloPacket,
ServerboundKeyPacket
>;
using AllServerboundStatusMessages = std::tuple<
ServerboundStatusRequestPacket,
ServerboundPingRequestStatusPacket
>;
using AllServerboundHandshakeMessages = std::tuple<
ServerboundClientIntentionPacket
>;
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
using AllServerboundConfigurationMessages = std::tuple<
ServerboundClientInformationConfigurationPacket,
ServerboundCustomPayloadConfigurationPacket,
ServerboundFinishConfigurationPacket,
ServerboundKeepAliveConfigurationPacket,
ServerboundPongConfigurationPacket,
ServerboundResourcePackConfigurationPacket
>;
#endif
using AllServerboundPlayMessages = std::tuple<
ServerboundSeenAdvancementsPacket,
ServerboundSwingPacket,
ServerboundChatPacket,
ServerboundContainerClickPacket,
#if PROTOCOL_VERSION > 476 /* > 1.13.2 */
ServerboundContainerButtonClickPacket,
#endif
ServerboundClientInformationPacket,
ServerboundClientCommandPacket,
ServerboundContainerClosePacket,
#if PROTOCOL_VERSION < 755 /* < 1.17 */
ServerboundContainerAckPacket,
#endif
ServerboundPlaceRecipePacket,
ServerboundSetCreativeModeSlotPacket,
#if PROTOCOL_VERSION > 385 /* > 1.12.2 */
ServerboundEditBookPacket,
#endif
#if PROTOCOL_VERSION < 476 /* < 1.14 */
ServerboundEnchantItemPacket,
#endif
ServerboundPlayerCommandPacket,
#if PROTOCOL_VERSION > 711 /* > 1.15.2 */
ServerboundJigsawGeneratePacket,
#endif
ServerboundSetCarriedItemPacket,
ServerboundInteractPacket,
#if PROTOCOL_VERSION > 463 /* > 1.13.2 */
ServerboundLockDifficultyPacket,
#endif
#if PROTOCOL_VERSION > 385 /* > 1.12.2 */
ServerboundRenameItemPacket,
ServerboundPickItemPacket,
#endif
ServerboundPlayerAbilitiesPacket,
ServerboundUseItemOnPacket,
ServerboundPlayerActionPacket,
ServerboundMovePlayerPacketRot,
#if PROTOCOL_VERSION < 755 /* < 1.17 */
ServerboundMovePlayerPacket,
#endif
ServerboundMovePlayerPacketPos,
ServerboundMovePlayerPacketPosRot,
ServerboundCustomPayloadPacket,
#if PROTOCOL_VERSION > 388 /* > 1.12.2 */
ServerboundBlockEntityTagQuery,
ServerboundEntityTagQuery,
#endif
#if PROTOCOL_VERSION > 736 /* > 1.16.1 */
ServerboundRecipeBookSeenRecipePacket,
ServerboundRecipeBookChangeSettingsPacket,
#else
ServerboundRecipeBookUpdatePacket,
#endif
ServerboundResourcePackPacket,
#if PROTOCOL_VERSION > 385 /* > 1.12.2 */
ServerboundSelectTradePacket,
ServerboundSetBeaconPacket,
#endif
#if PROTOCOL_VERSION > 463 /* > 1.13.2 */
ServerboundChangeDifficultyPacket,
#endif
ServerboundTeleportToEntityPacket,
ServerboundPaddleBoatPacket,
ServerboundPlayerInputPacket,
ServerboundCommandSuggestionPacket,
ServerboundAcceptTeleportationPacket,
#if PROTOCOL_VERSION > 385 /* > 1.12.2 */
ServerboundSetCommandBlockPacket,
ServerboundSetCommandMinecartPacket,
#endif
#if PROTOCOL_VERSION > 471 /* > 1.13.2 */
ServerboundSetJigsawBlockPacket,
#endif
ServerboundSignUpdatePacket,
#if PROTOCOL_VERSION > 385 /* > 1.12.2 */
ServerboundSetStructureBlockPacket,
#endif
ServerboundUseItemPacket,
ServerboundMoveVehiclePacket,
#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
ServerboundMovePlayerPacketStatusOnly,
ServerboundPongPacket,
#endif
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
ServerboundChatCommandPacket,
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
ServerboundChatPreviewPacket,
#endif
#endif
#if PROTOCOL_VERSION > 759 /* > 1.19 */
ServerboundChatAckPacket,
#endif
#if PROTOCOL_VERSION > 760 /* > 1.19.2 */
ServerboundChatSessionUpdatePacket,
#endif
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
ServerboundChunkBatchReceivedPacket,
ServerboundConfigurationAcknowledgedPacket,
ServerboundPingRequestPacket,
#endif
#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
ServerboundContainerSlotStateChangedPacket,
#endif
ServerboundKeepAlivePacket
>;
using AllServerboundMessages = Internal::tuple_cat_t <
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
AllServerboundConfigurationMessages,
#endif
AllServerboundLoginMessages,
AllServerboundStatusMessages,
AllServerboundHandshakeMessages,
AllServerboundPlayMessages
>;
} //ProtocolCraft
@@ -0,0 +1,32 @@
#pragma once
#include "protocolCraft/Message.hpp"
namespace ProtocolCraft
{
class Handler;
template<typename TDerived>
class BaseMessage : public Message
{
public:
virtual ~BaseMessage() override {};
virtual int GetId() const override
{
return TDerived::packet_id;
}
virtual std::string_view GetName() const override
{
return TDerived::packet_name;
}
virtual std::shared_ptr<Message> Clone() const override
{
return std::make_shared<TDerived>(*reinterpret_cast<const TDerived*>(this));
}
protected:
virtual void DispatchImpl(Handler* handler) override;
};
}
@@ -0,0 +1,354 @@
#pragma once
#include <vector>
#include <array>
#include <string>
#include <cstring>
#include <algorithm>
#include <stdexcept>
#include <type_traits>
#include <optional>
#include <functional>
#include <map>
#if PROTOCOL_VERSION > 760 /* > 1.19.2 */
#include <bitset>
#endif
namespace ProtocolCraft
{
class NetworkType;
using ReadIterator = std::vector<unsigned char>::const_iterator;
using WriteContainer = std::vector<unsigned char>;
using Angle = unsigned char;
using UUID = std::array<unsigned char, 16>;
template <class T>
class VarType
{
public:
VarType(const T& val) : value(val) {}
VarType() {}
operator T() const { return value; }
private:
T value;
};
using VarInt = VarType<int>;
using VarLong = VarType<long long int>;
std::string ReadRawString(ReadIterator& iter, size_t& length, const int size);
void WriteRawString(const std::string& s, WriteContainer& container);
std::vector<unsigned char> ReadByteArray(ReadIterator& iter, size_t& length, const size_t& desired_length);
void WriteByteArray(const std::vector<unsigned char>& my_array, WriteContainer& container);
void WriteByteArray(const unsigned char* data, const size_t& length, WriteContainer& container);
template <typename T>
T ChangeEndianness(const T& in)
{
T out;
std::reverse_copy(
reinterpret_cast<const unsigned char*>(&in),
reinterpret_cast<const unsigned char*>(&in) + sizeof(T),
reinterpret_cast<unsigned char*>(&out)
);
return out;
}
template<
typename T,
typename std::enable_if_t<!std::is_base_of_v<NetworkType, T>, bool> = true
>
T ReadData(ReadIterator& iter, size_t& length)
{
if (length < sizeof(T))
{
throw std::runtime_error("Not enough input in ReadData");
}
else
{
T output;
std::memcpy(&output, &(*iter), sizeof(T));
length -= sizeof(T);
iter += sizeof(T);
// Don't need to change endianess of char!
if (sizeof(T) > 1)
{
// The compiler should(?) optimize that
// This check doesn't work if int and char
// have the same size, but I guess this is not
// the only thing that souldn't work in this case
const int num = 1;
if (*(char*)&num == 1)
{
// Little endian
return ChangeEndianness(output);
}
}
// Big endian or sizeof(1)
return output;
}
}
template<
typename T,
typename std::enable_if_t<std::is_base_of_v<NetworkType, T>, bool> = true
>
T ReadData(ReadIterator& iter, size_t& length)
{
T output;
output.Read(iter, length);
return output;
}
template<>
std::string ReadData(ReadIterator& iter, size_t& length);
template<>
VarInt ReadData(ReadIterator& iter, size_t& length);
template<>
VarLong ReadData(ReadIterator& iter, size_t& length);
// We could use base ReadData<T>, but sizeof(std::array<?, N>)
// is not guaranteed to be N
template<>
UUID ReadData(ReadIterator& iter, size_t& length);
template<
typename T,
typename std::enable_if_t<!std::is_base_of_v<NetworkType, T>, bool> = true
>
void WriteData(const T& value, WriteContainer& container)
{
T val = value;
// Don't need to change endianess of char!
if constexpr(sizeof(T) > 1)
{
// Little endian check
// It doesn't work if int and char
// have the same size, but I guess this is not
// the only thing that souldn't work in this case
constexpr int num = 1;
if (*(char*)&num == 1)
{
// Little endian
val = ChangeEndianness(value);
}
}
// Big endian or sizeof(T) == 1
container.insert(
container.end(),
reinterpret_cast<unsigned char*>(&val),
reinterpret_cast<unsigned char*>(&val) + sizeof(T)
);
}
template<
typename T,
typename std::enable_if_t<std::is_base_of_v<NetworkType, T>, bool> = true
>
void WriteData(const T& value, WriteContainer& container)
{
value.Write(container);
}
template<>
void WriteData(const std::string& value, WriteContainer& container);
template<>
void WriteData(const VarInt& value, WriteContainer& container);
template<>
void WriteData(const VarLong& value, WriteContainer& container);
// We could use base WriteData<T>, but sizeof(std::array<?, N>)
// is not guaranteed to be N
template<>
void WriteData(const UUID& value, WriteContainer& container);
template<typename T>
std::optional<T> ReadOptional(ReadIterator& iter, size_t& length, const std::function<T(ReadIterator&, size_t&)>& read_func = ReadData<T>)
{
std::optional<T> output;
const bool has_value = ReadData<bool>(iter, length);
if (has_value)
{
output = read_func(iter, length);
}
return output;
}
template<typename T>
void WriteOptional(const std::optional<T>& value, WriteContainer& container, const std::function<void(const T&, WriteContainer&)>& write_func = WriteData<T>)
{
WriteData<bool>(value.has_value(), container);
if (value.has_value())
{
write_func(value.value(), container);
}
}
template<typename T, typename SizeType = VarInt>
std::vector<T> ReadVector(ReadIterator& iter, size_t& length)
{
const int output_length = ReadData<SizeType>(iter, length);
std::vector<T> output(output_length);
if constexpr(sizeof(T) == 1 && !std::is_base_of<NetworkType, T>::value)
{
if (length < output_length)
{
throw std::runtime_error("Not enough input in ReadVector");
}
std::memcpy(output.data(), &(*iter), output_length);
length -= output_length;
iter += output_length;
}
else
{
for (int i = 0; i < output_length; ++i)
{
output[i] = ReadData<T>(iter, length);
}
}
return output;
}
template<typename T, typename SizeType = VarInt>
std::vector<T> ReadVector(ReadIterator& iter, size_t& length, const std::function<T(ReadIterator&, size_t&)>& read_func)
{
const int output_length = ReadData<SizeType>(iter, length);
std::vector<T> output(output_length);
for (int i = 0; i < output_length; ++i)
{
output[i] = read_func(iter, length);
}
return output;
}
template<typename T, typename SizeType = VarInt>
void WriteVector(const std::vector<T>& value, WriteContainer& container)
{
WriteData<SizeType>(static_cast<int>(value.size()), container);
if constexpr (sizeof(T) == 1 && !std::is_base_of<NetworkType, T>::value)
{
container.insert(container.end(), value.begin(), value.end());
}
else
{
for (const auto& e: value)
{
WriteData<T>(e, container);
}
}
}
template<typename T, typename SizeType = VarInt>
void WriteVector(const std::vector<T>& value, WriteContainer& container, const std::function<void(const T&, WriteContainer&)>& write_func)
{
WriteData<SizeType>(static_cast<int>(value.size()), container);
for (const auto& e: value)
{
write_func(e, container);
}
}
template<typename K, typename V, typename SizeType = VarInt>
std::map<K, V> ReadMap(ReadIterator& iter, size_t& length)
{
const int output_length = ReadData<SizeType>(iter, length);
std::map<K, V> output;
for (int i = 0; i < output_length; ++i)
{
const K key = ReadData<K>(iter, length);
const V val = ReadData<V>(iter, length);
output.insert(std::make_pair(key, val));
}
return output;
}
template<typename K, typename V, typename SizeType = VarInt>
std::map<K, V> ReadMap(ReadIterator& iter, size_t& length, const std::function<std::pair<const K, V>(ReadIterator&, size_t&)>& read_func)
{
const int output_length = ReadData<SizeType>(iter, length);
std::map<K, V> output;
for (int i = 0; i < output_length; ++i)
{
output.insert(read_func(iter, length));
}
return output;
}
template<typename K, typename V, typename SizeType = VarInt>
void WriteMap(const std::map<K, V>& value, WriteContainer& container)
{
WriteData<SizeType>(static_cast<int>(value.size()), container);
for (const auto& p : value)
{
WriteData<K>(p.first, container);
WriteData<V>(p.second, container);
}
}
template<typename K, typename V, typename SizeType = VarInt>
void WriteMap(const std::map<K, V>& value, WriteContainer& container, const std::function<void(const std::pair<const K, V>&, WriteContainer&)>& write_func)
{
WriteData<SizeType>(static_cast<int>(value.size()), container);
for (const auto& p : value)
{
write_func(p, container);
}
}
#if PROTOCOL_VERSION > 760 /* > 1.19.2 */
template<size_t N>
std::bitset<N> ReadBitset(ReadIterator& iter, size_t& length)
{
std::bitset<N> output;
const std::vector<unsigned char> bytes = ReadByteArray(iter, length, N / 8 + (N % 8 != 0));
for (size_t i = 0; i < N; ++i)
{
output.set(i, (bytes[i / 8] >> (i % 8)) & 0x01);
}
return output;
}
template<size_t N>
void WriteBitset(const std::bitset<N>& values, WriteContainer& container)
{
std::vector<unsigned char> bytes(N / 8 + (N % 8 != 0), 0);
for (size_t i = 0; i < N; ++i)
{
if (values[i])
{
bytes[i / 8] |= 1 << (i % 8);
}
}
WriteByteArray(bytes, container);
}
#endif
} // ProtocolCraft
@@ -0,0 +1,78 @@
#pragma once
#include <tuple>
namespace ProtocolCraft
{
// This class is inspired by https://arobenko.gitbooks.io/comms-protocols-cpp/content/
// TCommon is common interface class for all the messages
// TAll is all the message types, that need to be handled, bundled in std::tuple
template <typename TCommon, typename TAll>
class GenericHandler;
template <typename TCommon, typename TFirst, typename TSecond, typename TThird, typename... TRest>
class GenericHandler<TCommon, std::tuple<TFirst, TSecond, TThird, TRest...> > : public GenericHandler<TCommon, std::tuple<TRest...> >
{
using Base = GenericHandler<TCommon, std::tuple<TRest...> >;
public:
using Base::Handle; // Don't hide all Handle() functions from base classes
virtual void Handle(TFirst& msg)
{
this->Handle(static_cast<TCommon&>(msg));
}
virtual void Handle(TSecond& msg)
{
this->Handle(static_cast<TCommon&>(msg));
}
virtual void Handle(TThird& msg)
{
this->Handle(static_cast<TCommon&>(msg));
}
};
template <typename TCommon, typename TFirst, typename TSecond>
class GenericHandler<TCommon, std::tuple<TFirst, TSecond> >
{
public:
virtual ~GenericHandler() {}
virtual void Handle(TFirst& msg)
{
this->Handle(static_cast<TCommon&>(msg));
}
virtual void Handle(TSecond& msg)
{
this->Handle(static_cast<TCommon&>(msg));
}
virtual void Handle(TCommon&)
{
//Nothing to do
}
};
template <typename TCommon, typename TFirst>
class GenericHandler<TCommon, std::tuple<TFirst> >
{
public:
virtual ~GenericHandler() {}
virtual void Handle(TFirst& msg)
{
this->Handle(static_cast<TCommon&>(msg));
}
virtual void Handle(TCommon&)
{
//Nothing to do
}
};
template <typename TCommon>
class GenericHandler<TCommon, std::tuple<> >
{
public:
virtual ~GenericHandler() {}
virtual void Handle(TCommon&)
{
//Nothing to do
}
};
} //ProtocolCraft
@@ -0,0 +1,10 @@
#pragma once
#include "protocolCraft/GenericHandler.hpp"
#include "protocolCraft/Message.hpp"
#include "protocolCraft/AllMessages.hpp"
namespace ProtocolCraft
{
class Handler : public GenericHandler<Message, AllMessages> {};
} //ProtocolCraft
@@ -0,0 +1,40 @@
#pragma once
#include <vector>
#include <memory>
#include "protocolCraft/NetworkType.hpp"
namespace ProtocolCraft
{
class Handler;
class Message : public NetworkType
{
public:
virtual ~Message()
{
}
virtual void Write(WriteContainer& container) const override
{
WriteData<VarInt>(GetId(), container);
return WriteImpl(container);
}
void Dispatch(Handler *handler)
{
return DispatchImpl(handler);
}
virtual int GetId() const = 0;
virtual std::string_view GetName() const = 0;
virtual std::shared_ptr<Message> Clone() const = 0;
protected:
virtual void DispatchImpl(Handler *handler) = 0;
};
} // ProtocolCraft
@@ -0,0 +1,13 @@
#pragma once
#include <memory>
#include "protocolCraft/enums.hpp"
namespace ProtocolCraft
{
class Message;
std::shared_ptr<Message> CreateClientboundMessage(const ConnectionState state, const int id);
std::shared_ptr<Message> CreateServerboundMessage(const ConnectionState state, const int id);
} //ProtocolCraft
@@ -0,0 +1,114 @@
#pragma once
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Utilities/Plugins/PluginLoader.hpp"
#include "protocolCraft/Utilities/Plugins/PluginObject.hpp"
namespace ProtocolCraft
{
class ClientboundCustomPayloadConfigurationPacket : public BaseMessage<ClientboundCustomPayloadConfigurationPacket>
{
public:
static constexpr int packet_id = 0x00;
static constexpr std::string_view packet_name = "Custom Payload (Configuration)";
virtual ~ClientboundCustomPayloadConfigurationPacket() override
{
}
void SetIdentifier(const std::string& identifier_)
{
identifier = identifier_;
}
void SetRawData(const std::vector<unsigned char>& raw_data_)
{
raw_data = raw_data_;
}
void SetParsedData(const std::shared_ptr<PluginObject>& parsed_data_)
{
parsed_data = parsed_data_;
}
const std::string& GetIdentifier() const
{
return identifier;
}
const std::vector<unsigned char>& GetRawData() const
{
return raw_data;
}
const std::shared_ptr<PluginObject>& GetParsedData() const
{
return parsed_data;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
identifier = ReadData<std::string>(iter, length);
parsed_data = CreateObjectFromPlugin(identifier.c_str());
if (parsed_data == nullptr)
{
raw_data = ReadByteArray(iter, length, length);
}
else
{
raw_data.clear();
unsigned long long int data_size = static_cast<unsigned long long int>(length);
const unsigned char* data_ptr = &(*iter);
parsed_data->Read(data_ptr, data_size);
iter += length - data_size;
length = static_cast<size_t>(data_size);
}
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<std::string>(identifier, container);
if (parsed_data == nullptr)
{
WriteByteArray(raw_data, container);
}
else
{
unsigned long long int serialized_length = 0;
const unsigned char* serialized = parsed_data->Write(serialized_length);
WriteByteArray(serialized, static_cast<size_t>(serialized_length), container);
}
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["identifier"] = identifier;
if (parsed_data == nullptr)
{
output["data"] = "Vector of " + std::to_string(raw_data.size()) + " unsigned chars";
}
else
{
const std::string json_serialized(parsed_data->Serialize());
output["data"] = Json::Parse(json_serialized);
}
return output;
}
private:
std::string identifier;
std::vector<unsigned char> raw_data;
std::shared_ptr<PluginObject> parsed_data;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,55 @@
#pragma once
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/Chat/Chat.hpp"
namespace ProtocolCraft
{
class ClientboundDisconnectConfigurationPacket : public BaseMessage<ClientboundDisconnectConfigurationPacket>
{
public:
static constexpr int packet_id = 0x01;
static constexpr std::string_view packet_name = "Disconnect (Configuration)";
virtual ~ClientboundDisconnectConfigurationPacket() override
{
}
void SetReason(const Chat& reason_)
{
reason = reason_;
}
const Chat& GetReason() const
{
return reason;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
reason = ReadData<Chat>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<Chat>(reason, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["reason"] = reason;
return output;
}
private:
Chat reason;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,44 @@
#pragma once
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundFinishConfigurationPacket : public BaseMessage<ClientboundFinishConfigurationPacket>
{
public:
static constexpr int packet_id = 0x02;
static constexpr std::string_view packet_name = "Finish Configuration";
virtual ~ClientboundFinishConfigurationPacket() override
{
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
}
virtual void WriteImpl(WriteContainer& container) const override
{
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
return output;
}
private:
};
} //ProtocolCraft
#endif
@@ -0,0 +1,54 @@
#pragma once
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundKeepAliveConfigurationPacket : public BaseMessage<ClientboundKeepAliveConfigurationPacket>
{
public:
static constexpr int packet_id = 0x03;
static constexpr std::string_view packet_name = "Keep Alive (Configuration)";
virtual ~ClientboundKeepAliveConfigurationPacket() override
{
}
void SetId_(const long long int id__)
{
id_ = id__;
}
long long int GetId_() const
{
return id_;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
id_ = ReadData<long long int>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<long long int>(id_, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["id_"] = id_;
return output;
}
private:
long long int id_ = 0;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,55 @@
#pragma once
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundPingConfigurationPacket : public BaseMessage<ClientboundPingConfigurationPacket>
{
public:
static constexpr int packet_id = 0x04;
static constexpr std::string_view packet_name = "Ping (Configuration)";
virtual ~ClientboundPingConfigurationPacket() override
{
}
void SetId_(const int id__)
{
id_ = id__;
}
int GetId_() const
{
return id_;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
id_ = ReadData<int>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<int>(id_, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["id"] = id_;
return output;
}
private:
int id_ = 0;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,56 @@
#pragma once
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/NBT/NBT.hpp"
namespace ProtocolCraft
{
class ClientboundRegistryDataPacket : public BaseMessage<ClientboundRegistryDataPacket>
{
public:
static constexpr int packet_id = 0x05;
static constexpr std::string_view packet_name = "Registry Data";
virtual ~ClientboundRegistryDataPacket() override
{
}
void SetRegistryHolder(const NBT::Value& registry_holder_)
{
registry_holder = registry_holder_;
}
const NBT::Value& GetRegistryHolder() const
{
return registry_holder;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
registry_holder = ReadData<NBT::UnnamedValue>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<NBT::UnnamedValue>(registry_holder, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["registry_holder"] = registry_holder;
return output;
}
private:
NBT::Value registry_holder;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,101 @@
#pragma once
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */ && PROTOCOL_VERSION < 765 /* < 1.20.3 */
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/Chat/Chat.hpp"
namespace ProtocolCraft
{
class ClientboundResourcePackConfigurationPacket : public BaseMessage<ClientboundResourcePackConfigurationPacket>
{
public:
static constexpr int packet_id = 0x06;
static constexpr std::string_view packet_name = "Resource Pack (Configuration)";
virtual ~ClientboundResourcePackConfigurationPacket() override
{
}
void SetUrl(const std::string& url_)
{
url = url_;
}
void SetHash(const std::string& hash_)
{
hash = hash_;
}
void SetRequired(const bool required_)
{
required = required_;
}
void SetPrompt(const std::optional<Chat>& prompt_)
{
prompt = prompt_;
}
const std::string& GetUrl() const
{
return url;
}
const std::string& GetHash() const
{
return hash;
}
bool GetRequired() const
{
return required;
}
const std::optional<Chat>& GetPrompt() const
{
return prompt;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
url = ReadData<std::string>(iter, length);
hash = ReadData<std::string>(iter, length);
required = ReadData<bool>(iter, length);
prompt = ReadOptional<Chat>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<std::string>(url, container);
WriteData<std::string>(hash, container);
WriteData<bool>(required, container);
WriteOptional<Chat>(prompt, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["url"] = url;
output["hash"] = hash;
output["required"] = required;
if (prompt.has_value())
{
output["prompt"] = prompt.value();
}
return output;
}
private:
std::string url;
std::string hash;
bool required = false;
std::optional<Chat> prompt;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,59 @@
#pragma once
#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/Chat/Chat.hpp"
namespace ProtocolCraft
{
class ClientboundResourcePackPopConfigurationPacket : public BaseMessage<ClientboundResourcePackPopConfigurationPacket>
{
public:
static constexpr int packet_id = 0x06;
static constexpr std::string_view packet_name = "Resource Pack Pop (Configuration)";
virtual ~ClientboundResourcePackPopConfigurationPacket() override
{
}
void SetUUID(const std::optional<UUID>& uuid_)
{
uuid = uuid_;
}
const std::optional<UUID>& GetUUID() const
{
return uuid;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
uuid = ReadOptional<UUID>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteOptional<UUID>(uuid, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
if (uuid.has_value())
{
output["uuid"] = uuid.value();
}
return output;
}
private:
std::optional<UUID> uuid;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,115 @@
#pragma once
#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/Chat/Chat.hpp"
namespace ProtocolCraft
{
class ClientboundResourcePackPushConfigurationPacket : public BaseMessage<ClientboundResourcePackPushConfigurationPacket>
{
public:
static constexpr int packet_id = 0x07;
static constexpr std::string_view packet_name = "Resource Pack Push (Configuration)";
virtual ~ClientboundResourcePackPushConfigurationPacket() override
{
}
void SetUUID(const UUID& uuid_)
{
uuid = uuid_;
}
void SetUrl(const std::string& url_)
{
url = url_;
}
void SetHash(const std::string& hash_)
{
hash = hash_;
}
void SetRequired(const bool required_)
{
required = required_;
}
void SetPrompt(const std::optional<Chat>& prompt_)
{
prompt = prompt_;
}
const UUID& GetUUID() const
{
return uuid;
}
const std::string& GetUrl() const
{
return url;
}
const std::string& GetHash() const
{
return hash;
}
bool GetRequired() const
{
return required;
}
const std::optional<Chat>& GetPrompt() const
{
return prompt;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
uuid = ReadData<UUID>(iter, length);
url = ReadData<std::string>(iter, length);
hash = ReadData<std::string>(iter, length);
required = ReadData<bool>(iter, length);
prompt = ReadOptional<Chat>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<UUID>(uuid, container);
WriteData<std::string>(url, container);
WriteData<std::string>(hash, container);
WriteData<bool>(required, container);
WriteOptional<Chat>(prompt, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["uuid"] = uuid;
output["url"] = url;
output["hash"] = hash;
output["required"] = required;
if (prompt.has_value())
{
output["prompt"] = prompt.value();
}
return output;
}
private:
UUID uuid;
std::string url;
std::string hash;
bool required = false;
std::optional<Chat> prompt;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,61 @@
#pragma once
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
#include "protocolCraft/BaseMessage.hpp"
#include <vector>
#include <string>
namespace ProtocolCraft
{
class ClientboundUpdateEnabledFeaturesPacket : public BaseMessage<ClientboundUpdateEnabledFeaturesPacket>
{
public:
#if PROTOCOL_VERSION < 765 /* < 1.20.3 */
static constexpr int packet_id = 0x07;
#else
static constexpr int packet_id = 0x08;
#endif
static constexpr std::string_view packet_name = "Update Enabled Features";
virtual ~ClientboundUpdateEnabledFeaturesPacket() override
{
}
void SetFeatures(const std::vector<std::string>& features_)
{
features = features_;
}
const std::vector<std::string>& GetFeatures() const
{
return features;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
features = ReadVector<std::string>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteVector<std::string>(features, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["features"] = features;
return output;
}
private:
std::vector<std::string> features;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,77 @@
#pragma once
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/BlockEntityTag.hpp"
namespace ProtocolCraft
{
class ClientboundUpdateTagsConfigurationPacket : public BaseMessage<ClientboundUpdateTagsConfigurationPacket>
{
public:
#if PROTOCOL_VERSION < 765 /* < 1.20.3 */
static constexpr int packet_id = 0x08;
#else
static constexpr int packet_id = 0x09;
#endif
static constexpr std::string_view packet_name = "Update Tags (Configuration)";
virtual ~ClientboundUpdateTagsConfigurationPacket() override
{
}
void SetTags(const std::map<Identifier, std::vector<BlockEntityTag> >& tags_)
{
tags = tags_;
}
const std::map<Identifier, std::vector<BlockEntityTag> >& GetTags() const
{
return tags;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
tags = ReadMap<Identifier, std::vector<BlockEntityTag>>(iter, length,
[](ReadIterator& i, size_t& l)
{
const Identifier key = ReadData<Identifier>(i, l);
const std::vector<BlockEntityTag> val = ReadVector<BlockEntityTag>(i, l);
return std::make_pair(key, val);
}
);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteMap<Identifier, std::vector<BlockEntityTag>>(tags, container,
[](const std::pair<const Identifier, std::vector<BlockEntityTag>>& p, WriteContainer& c)
{
WriteData<Identifier>(p.first, c);
WriteVector<BlockEntityTag>(p.second, c);
}
);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["tags"] = Json::Object();
for (const auto& p : tags)
{
output["tags"][p.first.GetFull()] = p.second;
}
return output;
}
private:
std::map<Identifier, std::vector<BlockEntityTag> > tags;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,59 @@
#pragma once
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/ClientInformation.hpp"
namespace ProtocolCraft
{
class ServerboundClientInformationConfigurationPacket : public BaseMessage<ServerboundClientInformationConfigurationPacket>
{
public:
static constexpr int packet_id = 0x00;
static constexpr std::string_view packet_name = "Client Information (Configuration)";
virtual ~ServerboundClientInformationConfigurationPacket() override
{
}
void SetClientInformation(const ClientInformation& client_information_)
{
client_information = client_information_;
}
const ClientInformation& GetClientInformation() const
{
return client_information;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
client_information = ReadData<ClientInformation>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<ClientInformation>(client_information, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["client_information"] = client_information;
return output;
}
private:
ClientInformation client_information;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,114 @@
#pragma once
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Utilities/Plugins/PluginLoader.hpp"
#include "protocolCraft/Utilities/Plugins/PluginObject.hpp"
namespace ProtocolCraft
{
class ServerboundCustomPayloadConfigurationPacket : public BaseMessage<ServerboundCustomPayloadConfigurationPacket>
{
public:
static constexpr int packet_id = 0x01;
static constexpr std::string_view packet_name = "Custom Payload (Configuration)";
virtual ~ServerboundCustomPayloadConfigurationPacket() override
{
}
void SetIdentifier(const std::string& identifier_)
{
identifier = identifier_;
}
void SetRawData(const std::vector<unsigned char>& raw_data_)
{
raw_data = raw_data_;
}
void SetParsedData(const std::shared_ptr<PluginObject>& parsed_data_)
{
parsed_data = parsed_data_;
}
const std::string& GetIdentifier() const
{
return identifier;
}
const std::vector<unsigned char>& GetRawData() const
{
return raw_data;
}
const std::shared_ptr<PluginObject>& GetParsedData() const
{
return parsed_data;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
identifier = ReadData<std::string>(iter, length);
parsed_data = CreateObjectFromPlugin(identifier.c_str());
if (parsed_data == nullptr)
{
raw_data = ReadByteArray(iter, length, length);
}
else
{
raw_data.clear();
unsigned long long int data_size = static_cast<unsigned long long int>(length);
const unsigned char* data_ptr = &(*iter);
parsed_data->Read(data_ptr, data_size);
iter += length - data_size;
length = static_cast<size_t>(data_size);
}
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<std::string>(identifier, container);
if (parsed_data == nullptr)
{
WriteByteArray(raw_data, container);
}
else
{
unsigned long long int serialized_length = 0;
const unsigned char* serialized = parsed_data->Write(serialized_length);
WriteByteArray(serialized, static_cast<size_t>(serialized_length), container);
}
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["identifier"] = identifier;
if (parsed_data == nullptr)
{
output["data"] = "Vector of " + std::to_string(raw_data.size()) + " unsigned chars";
}
else
{
const std::string json_serialized(parsed_data->Serialize());
output["data"] = Json::Parse(json_serialized);
}
return output;
}
private:
std::string identifier;
std::vector<unsigned char> raw_data;
std::shared_ptr<PluginObject> parsed_data;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,44 @@
#pragma once
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ServerboundFinishConfigurationPacket : public BaseMessage<ServerboundFinishConfigurationPacket>
{
public:
static constexpr int packet_id = 0x02;
static constexpr std::string_view packet_name = "Finish Configuration";
virtual ~ServerboundFinishConfigurationPacket() override
{
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
}
virtual void WriteImpl(WriteContainer& container) const override
{
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
return output;
}
private:
};
} //ProtocolCraft
#endif
@@ -0,0 +1,54 @@
#pragma once
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ServerboundKeepAliveConfigurationPacket : public BaseMessage<ServerboundKeepAliveConfigurationPacket>
{
public:
static constexpr int packet_id = 0x03;
static constexpr std::string_view packet_name = "Keep Alive (Configuration)";
virtual ~ServerboundKeepAliveConfigurationPacket() override
{
}
void SetId_(const long long int l)
{
id_ = l;
}
long long int GetId_() const
{
return id_;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
id_ = ReadData<long long int>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<long long int>(id_, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["id_"] = id_;
return output;
}
private:
long long int id_ = 0;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,56 @@
#pragma once
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ServerboundPongConfigurationPacket : public BaseMessage<ServerboundPongConfigurationPacket>
{
public:
static constexpr int packet_id = 0x04;
static constexpr std::string_view packet_name = "Pong (Configuration)";
virtual ~ServerboundPongConfigurationPacket() override
{
}
void SetId_(const int id__)
{
id_ = id__;
}
int GetId_() const
{
return id_;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
id_ = ReadData<int>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<int>(id_, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["id"] = id_;
return output;
}
private:
int id_ = 0;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,83 @@
#pragma once
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ServerboundResourcePackConfigurationPacket : public BaseMessage<ServerboundResourcePackConfigurationPacket>
{
public:
static constexpr int packet_id = 0x05;
static constexpr std::string_view packet_name = "Resource Pack (Configuration)";
virtual ~ServerboundResourcePackConfigurationPacket() override
{
}
#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
void SetUUID(const UUID& uuid_)
{
uuid = uuid_;
}
#endif
void SetAction(const int action_)
{
action = action_;
}
#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
const UUID& GetUUID() const
{
return uuid;
}
#endif
int GetAction() const
{
return action;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
uuid = ReadData<UUID>(iter, length);
#endif
action = ReadData<VarInt>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
WriteData<UUID>(uuid, container);
#endif
WriteData<VarInt>(action, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
output["uuid"] = uuid;
#endif
output["action"] = action;
return output;
}
private:
#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
UUID uuid = {};
#endif
int action = 0;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,93 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ServerboundClientIntentionPacket : public BaseMessage<ServerboundClientIntentionPacket>
{
public:
static constexpr int packet_id = 0x00;
static constexpr std::string_view packet_name = "Client Intention";
virtual ~ServerboundClientIntentionPacket() override
{
}
void SetProtocolVersion(const int p)
{
protocol_version = p;
}
void SetHostName(const std::string& s)
{
host_name = s;
}
void SetPort(const unsigned short p)
{
port = p;
}
void SetIntention(const int n)
{
intention = n;
}
int GetProtocolVersion() const
{
return protocol_version;
}
const std::string& GetHostName() const
{
return host_name;
}
unsigned short GetPort() const
{
return port;
}
int GetIntention() const
{
return intention;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
protocol_version = ReadData<VarInt>(iter, length);
host_name = ReadData<std::string>(iter, length);
port = ReadData<unsigned short>(iter, length);
intention = ReadData<VarInt>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(protocol_version, container);
WriteData<std::string>(host_name, container);
WriteData<unsigned short>(port, container);
WriteData<VarInt>(intention, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["protocol_version"] = protocol_version;
output["host_name"] = host_name;
output["port"] = port;
output["intention"] = intention;
return output;
}
private:
int protocol_version = 0;
std::string host_name;
unsigned short port = 0;
int intention = 0;
};
} //ProtocolCraft
@@ -0,0 +1,87 @@
#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/Identifier.hpp"
namespace ProtocolCraft
{
class ClientboundCustomQueryPacket : public BaseMessage<ClientboundCustomQueryPacket>
{
public:
static constexpr int packet_id = 0x04;
static constexpr std::string_view packet_name = "Custom Query";
virtual ~ClientboundCustomQueryPacket() override
{
}
void SetTransactionId(const int transaction_id_)
{
transaction_id = transaction_id_;
}
void SetIdentifier(const Identifier& identifier_)
{
identifier = identifier_;
}
void SetData(const std::vector<unsigned char>& data_)
{
data = data_;
}
int GetTransactionId() const
{
return transaction_id;
}
const Identifier& GetIdentifier() const
{
return identifier;
}
const std::vector<unsigned char>& GetData() const
{
return data;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
transaction_id = ReadData<VarInt>(iter, length);
identifier = ReadData<Identifier>(iter, length);
data = ReadByteArray(iter, length, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(transaction_id, container);
WriteData<Identifier>(identifier, container);
WriteByteArray(data, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["transaction_id"] = transaction_id;
output["identifier"] = identifier;
output["data"] = "Vector of " + std::to_string(data.size()) + " unsigned char";
return output;
}
private:
int transaction_id = 0;
Identifier identifier;
std::vector<unsigned char> data;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,125 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
#include "protocolCraft/Types/GameProfile/GameProfile.hpp"
#endif
namespace ProtocolCraft
{
class ClientboundGameProfilePacket : public BaseMessage<ClientboundGameProfilePacket>
{
public:
static constexpr int packet_id = 0x02;
static constexpr std::string_view packet_name = "Game Profile";
virtual ~ClientboundGameProfilePacket() override
{
}
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
void SetGameProfile(const GameProfile& game_profile_)
{
game_profile = game_profile_;
}
const GameProfile& GetGameProfile() const
{
return game_profile;
}
#else
#if PROTOCOL_VERSION > 706 /* > 1.15.2 */
void SetUUID(const UUID& uuid_)
{
uuid = uuid_;
}
#else
void SetUUID(const std::string& uuid_)
{
uuid = uuid_;
}
#endif
void SetUsername(const std::string& username_)
{
username = username_;
}
#if PROTOCOL_VERSION > 706 /* > 1.15.2 */
const UUID& GetUUID() const
{
return uuid;
}
#else
const std::string& GetUUID() const
{
return uuid;
}
#endif
const std::string& GetUsername() const
{
return username;
}
#endif
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
game_profile = ReadData<GameProfile>(iter, length);
#else
#if PROTOCOL_VERSION > 706 /* > 1.15.2 */
uuid = ReadData<UUID>(iter, length);
#else
uuid = ReadData<std::string>(iter, length);
#endif
username = ReadData<std::string>(iter, length);
#endif
}
virtual void WriteImpl(WriteContainer& container) const override
{
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
WriteData<GameProfile>(game_profile, container);
#else
#if PROTOCOL_VERSION > 706 /* > 1.15.2 */
WriteData<UUID>(uuid, container);
#else
WriteData<std::string>(uuid, container);
#endif
WriteData<std::string>(username, container);
#endif
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
output["game_profile"] = game_profile;
#else
output["uuid"] = uuid;
output["username"] = username;
#endif
return output;
}
private:
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
GameProfile game_profile;
#else
#if PROTOCOL_VERSION > 706 /* > 1.15.2 */
UUID uuid = {};
#else
// This uuid is not a normal uuid but a regular string
std::string uuid;
#endif
std::string username;
#endif
};
} //ProtocolCraft
@@ -0,0 +1,109 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundHelloPacket : public BaseMessage<ClientboundHelloPacket>
{
public:
static constexpr int packet_id = 0x01;
static constexpr std::string_view packet_name = "Hello";
virtual ~ClientboundHelloPacket() override
{
}
void SetServerID(const std::string& server_id_)
{
server_ID = server_id_;
}
void SetPublicKey(const std::vector<unsigned char>& public_key_)
{
public_key = public_key_;
}
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
void SetNonce(const std::vector<unsigned char>& nonce_)
{
nonce = nonce_;
}
#else
void SetChallenge(const std::vector<unsigned char>& challenge_)
{
challenge = challenge_;
}
#endif
const std::string& GetServerID() const
{
return server_ID;
}
const std::vector<unsigned char>& GetPublicKey() const
{
return public_key;
}
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
const std::vector<unsigned char>& GetNonce() const
{
return nonce;
}
#else
const std::vector<unsigned char>& GetChallenge() const
{
return challenge;
}
#endif
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
server_ID = ReadData<std::string>(iter, length);
public_key = ReadVector<unsigned char>(iter, length);
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
nonce = ReadVector<unsigned char>(iter, length);
#else
challenge = ReadVector<unsigned char>(iter, length);
#endif
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<std::string>(server_ID, container);
WriteVector<unsigned char>(public_key, container);
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
WriteVector<unsigned char>(nonce, container);
#else
WriteVector<unsigned char>(challenge, container);
#endif
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["server_ID"] = server_ID;
output["public_key"] = "vector of " + std::to_string(public_key.size()) + " unsigned char";
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
output["nonce"] = "vector of " + std::to_string(nonce.size()) + " unsigned char";
#else
output["challenge"] = "vector of " + std::to_string(challenge.size()) + " unsigned char";
#endif
return output;
}
private:
std::string server_ID;
std::vector<unsigned char> public_key;
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
std::vector<unsigned char> nonce;
#else
std::vector<unsigned char> challenge;
#endif
};
}
@@ -0,0 +1,51 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundLoginCompressionPacket : public BaseMessage<ClientboundLoginCompressionPacket>
{
public:
static constexpr int packet_id = 0x03;
static constexpr std::string_view packet_name = "Login Compression";
virtual ~ClientboundLoginCompressionPacket() override
{
}
void SetCompressionThreshold(const int compression_threshold_)
{
compression_threshold = compression_threshold_;
}
int GetCompressionThreshold() const
{
return compression_threshold;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
compression_threshold = ReadData<VarInt>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(compression_threshold, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["compression_threshold"] = compression_threshold;
return output;
}
private:
int compression_threshold = 0;
};
} //ProtocolCraft
@@ -0,0 +1,80 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#if PROTOCOL_VERSION < 765 /* < 1.20.3 */
#include "protocolCraft/Types/Chat/Chat.hpp"
#endif
namespace ProtocolCraft
{
class ClientboundLoginDisconnectPacket : public BaseMessage<ClientboundLoginDisconnectPacket>
{
public:
static constexpr int packet_id = 0x00;
static constexpr std::string_view packet_name = "Login Disconnect";
virtual ~ClientboundLoginDisconnectPacket() override
{
}
#if PROTOCOL_VERSION < 765 /* < 1.20.3 */
void SetReason(const Chat& reason_)
{
reason = reason_;
}
#else
void SetReason(const std::string& reason_)
{
reason = reason_;
}
#endif
#if PROTOCOL_VERSION < 765 /* < 1.20.3 */
const Chat& GetReason() const
{
return reason;
}
#else
const std::string& GetReason() const
{
return reason;
}
#endif
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
#if PROTOCOL_VERSION < 765 /* < 1.20.3 */
reason = ReadData<Chat>(iter, length);
#else
reason = ReadData<std::string>(iter, length);
#endif
}
virtual void WriteImpl(WriteContainer& container) const override
{
#if PROTOCOL_VERSION < 765 /* < 1.20.3 */
WriteData<Chat>(reason, container);
#else
WriteData<std::string>(reason, container);
#endif
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["reason"] = reason;
return output;
}
private:
#if PROTOCOL_VERSION < 765 /* < 1.20.3 */
Chat reason;
#else
std::string reason;
#endif
};
}
@@ -0,0 +1,80 @@
#pragma once
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ServerboundCustomQueryAnswerPacket : public BaseMessage<ServerboundCustomQueryAnswerPacket>
{
public:
static constexpr int packet_id = 0x02;
static constexpr std::string_view packet_name = "Custom Query Answer";
virtual ~ServerboundCustomQueryAnswerPacket() override
{
}
void SetTransactionId(const int transaction_id_)
{
transaction_id = transaction_id_;
}
void SetPayload(const std::optional<std::vector<unsigned char>>& payload_)
{
payload = payload_;
}
int GetTransationId() const
{
return transaction_id;
}
const std::optional<std::vector<unsigned char>>& GetPayload() const
{
return payload;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
transaction_id = ReadData<VarInt>(iter, length);
payload = ReadOptional<std::vector<unsigned char>>(iter, length,
[](ReadIterator& i, size_t& l)
{
return ReadByteArray(i, l, l);
}
);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(transaction_id, container);
WriteOptional<std::vector<unsigned char>>(payload, container,
[](const std::vector<unsigned char>& v, WriteContainer& c)
{
WriteByteArray(v, c);
}
);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["transaction_id"] = transaction_id;
if (payload.has_value())
{
output["payload"] = "Vector of " + std::to_string(payload.value().size()) + " unsigned char";
}
return output;
}
private:
int transaction_id = 0;
std::optional<std::vector<unsigned char>> payload;
};
} // ProtocolCraft
#endif
@@ -0,0 +1,80 @@
#pragma once
#if PROTOCOL_VERSION > 340 /* > 1.12.2 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ServerboundCustomQueryPacket : public BaseMessage<ServerboundCustomQueryPacket>
{
public:
static constexpr int packet_id = 0x02;
static constexpr std::string_view packet_name = "Custom Query";
virtual ~ServerboundCustomQueryPacket() override
{
}
void SetTransactionId(const int transaction_id_)
{
transaction_id = transaction_id_;
}
void SetData(const std::optional<std::vector<unsigned char>>& data_)
{
data = data_;
}
int GetTransationId() const
{
return transaction_id;
}
const std::optional<std::vector<unsigned char>>& GetData() const
{
return data;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
transaction_id = ReadData<VarInt>(iter, length);
data = ReadOptional<std::vector<unsigned char>>(iter, length,
[](ReadIterator& i, size_t& l)
{
return ReadByteArray(i, l, l);
}
);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(transaction_id, container);
WriteOptional<std::vector<unsigned char>>(data, container,
[](const std::vector<unsigned char>& v, WriteContainer& c)
{
WriteByteArray(v, c);
}
);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["transaction_id"] = transaction_id;
if (data.has_value())
{
output["data"] = "Vector of " + std::to_string(data.value().size()) + " unsigned char";
}
return output;
}
private:
int transaction_id = 0;
std::optional<std::vector<unsigned char>> data;
};
} // ProtocolCraft
#endif
@@ -0,0 +1,171 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
#include "protocolCraft/Types/GameProfile/ProfilePublicKey.hpp"
#endif
namespace ProtocolCraft
{
class ServerboundHelloPacket : public BaseMessage<ServerboundHelloPacket>
{
public:
static constexpr int packet_id = 0x00;
static constexpr std::string_view packet_name = "Hello";
virtual ~ServerboundHelloPacket() override
{
}
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
void SetName(const std::string& name__)
{
name_ = name__;
}
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
void SetPublicKey(const std::optional<ProfilePublicKey>& public_key_)
{
public_key = public_key_;
}
#endif
#if PROTOCOL_VERSION > 759 /* > 1.19 */
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
void SetProfileId(const std::optional<UUID>& profile_id_)
{
profile_id = profile_id_;
}
#else
void SetProfileId(const UUID& profile_id_)
{
profile_id = profile_id_;
}
#endif
#endif
const std::string& GetName_() const
{
return name_;
}
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
const std::optional<ProfilePublicKey>& GetPublicKey() const
{
return public_key;
}
#endif
#if PROTOCOL_VERSION > 759 /* > 1.19 */
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
const std::optional<UUID>& GetProfileId() const
{
return profile_id;
}
#else
const UUID& GetProfileId() const
{
return profile_id;
}
#endif
#endif
#else
void SetGameProfile(const std::string& n)
{
game_profile = n;
}
const std::string& GetGameProfile() const
{
return game_profile;
}
#endif
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
name_ = ReadData<std::string>(iter, length);
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
public_key = ReadOptional<ProfilePublicKey>(iter, length);
#endif
#if PROTOCOL_VERSION > 759 /* > 1.19 */
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
profile_id = ReadOptional<UUID>(iter, length);
#else
profile_id = ReadData<UUID>(iter, length);
#endif
#endif
#else
game_profile = ReadData<std::string>(iter, length);
#endif
}
virtual void WriteImpl(WriteContainer& container) const override
{
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
WriteData<std::string>(name_, container);
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
WriteOptional<ProfilePublicKey>(public_key, container);
#endif
#if PROTOCOL_VERSION > 759 /* > 1.19 */
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
WriteOptional<UUID>(profile_id, container);
#else
WriteData<UUID>(profile_id, container);
#endif
#endif
#else
WriteData<std::string>(game_profile, container);
#endif
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
output["name"] = name_;
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
if (public_key.has_value())
{
output["public_key"] = public_key.value();
}
#endif
#if PROTOCOL_VERSION > 759 /* > 1.19 */
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
if (profile_id.has_value())
{
output["profile_id"] = profile_id.value();
}
#else
output["profile_id"] = profile_id;
#endif
#endif
#else
output["game_profile"] = game_profile;
#endif
return output;
}
private:
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
std::string name_;
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
std::optional<ProfilePublicKey> public_key;
#endif
#if PROTOCOL_VERSION > 759 /* > 1.19 */
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
std::optional<UUID> profile_id;
#else
UUID profile_id = {};
#endif
#endif
#else
std::string game_profile;
#endif
};
} // ProtocolCraft
@@ -0,0 +1,153 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
#include "protocolCraft/Types/SaltSignature.hpp"
#endif
namespace ProtocolCraft
{
class ServerboundKeyPacket : public BaseMessage<ServerboundKeyPacket>
{
public:
static constexpr int packet_id = 0x01;
static constexpr std::string_view packet_name = "Key";
virtual ~ServerboundKeyPacket() override
{
}
void SetKeyBytes(const std::vector<unsigned char>& key_bytes_)
{
key_bytes = key_bytes_;
}
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
void SetNonce(const std::vector<unsigned char>& nonce_)
{
nonce = nonce_;
}
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
void SetSaltSignature(const SaltSignature& salt_signature_)
{
salt_signature = salt_signature_;
}
#endif
#else
void SetEncryptedChallenge(const std::vector<unsigned char>& encrypted_challenge_)
{
encrypted_challenge = encrypted_challenge_;
}
#endif
const std::vector<unsigned char>& GetKeyBytes() const
{
return key_bytes;
}
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
const std::vector<unsigned char>& GetNonce() const
{
return nonce;
}
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
const SaltSignature& GetSaltSignature() const
{
return salt_signature;
}
#endif
#else
const std::vector<unsigned char>& GetEncryptedChallenge() const
{
return encrypted_challenge;
}
#endif
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
key_bytes = ReadVector<unsigned char>(iter, length);
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
const bool has_nonce = ReadData<bool>(iter, length);
if (has_nonce)
{
const int nonce_length = ReadData<VarInt>(iter, length);
nonce = ReadByteArray(iter, length, nonce_length);
}
else
{
salt_signature = ReadData<SaltSignature>(iter, length);
}
#else
nonce = ReadVector<unsigned char>(iter, length);
#endif
#else
encrypted_challenge = ReadVector<unsigned char>(iter, length);
#endif
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteVector<unsigned char>(key_bytes, container);
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
WriteData<bool>(salt_signature.GetSignature().empty(), container);
if (salt_signature.GetSignature().empty())
{
WriteData<VarInt>(static_cast<int>(nonce.size()), container);
WriteByteArray(nonce, container);
}
else
{
WriteData<SaltSignature>(salt_signature, container);
}
#else
WriteVector<unsigned char>(nonce, container);
#endif
#else
WriteVector<unsigned char>(encrypted_challenge, container);
#endif
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["key_bytes"] = "vector of " + std::to_string(key_bytes.size()) + " unsigned char";
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
if (salt_signature.GetSignature().empty())
{
output["nonce"] = "vector of " + std::to_string(nonce.size()) + " unsigned char";
}
else
{
output["salt_signature"] = salt_signature;
}
#else
output["nonce"] = "vector of " + std::to_string(nonce.size()) + " unsigned char";
#endif
#else
output["encrypted_challenge"] = "vector of " + std::to_string(encrypted_challenge.size()) + " unsigned char";
#endif
return output;
}
private:
std::vector<unsigned char> key_bytes;
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
std::vector<unsigned char> nonce;
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
SaltSignature salt_signature;
#endif
#else
std::vector<unsigned char> encrypted_challenge;
#endif
};
} // ProtocolCraft
@@ -0,0 +1,41 @@
#pragma once
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ServerboundLoginAcknowledgedPacket : public BaseMessage<ServerboundLoginAcknowledgedPacket>
{
public:
static constexpr int packet_id = 0x03;
static constexpr std::string_view packet_name = "Login Acknowledged";
virtual ~ServerboundLoginAcknowledgedPacket() override
{
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
}
virtual void WriteImpl(WriteContainer& container) const override
{
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
return output;
}
private:
};
} // ProtocolCraft
#endif
@@ -0,0 +1,267 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundAddEntityPacket : public BaseMessage<ClientboundAddEntityPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */ || PROTOCOL_VERSION == 393 /* 1.13 */ || \
PROTOCOL_VERSION == 401 /* 1.13.1 */ || PROTOCOL_VERSION == 404 /* 1.13.2 */ || \
PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */ || PROTOCOL_VERSION == 573 /* 1.15 */ || \
PROTOCOL_VERSION == 575 /* 1.15.1 */ || PROTOCOL_VERSION == 578 /* 1.15.2 */ || \
PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */ || \
PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */ || PROTOCOL_VERSION == 755 /* 1.17 */ || \
PROTOCOL_VERSION == 756 /* 1.17.1 */ || PROTOCOL_VERSION == 757 /* 1.18/.1 */ || \
PROTOCOL_VERSION == 758 /* 1.18.2 */ || PROTOCOL_VERSION == 759 /* 1.19 */ || \
PROTOCOL_VERSION == 760 /* 1.19.1/2 */ || PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x00;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */ || \
PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x01;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Add Entity";
virtual ~ClientboundAddEntityPacket() override
{
}
void SetId_(const int id__)
{
id_ = id__;
}
void SetUUID(const UUID& uuid_)
{
uuid = uuid_;
}
void SetX(const double x_)
{
x = x_;
}
void SetY(const double y_)
{
y = y_;
}
void SetZ(const double z_)
{
z = z_;
}
void SetXa(const short xa_)
{
xa = xa_;
}
void SetYa(const short ya_)
{
ya = ya_;
}
void SetZa(const short za_)
{
za = za_;
}
void SetXRot(const Angle xRot_)
{
x_rot = xRot_;
}
void SetYRot(const Angle yRot_)
{
y_rot = yRot_;
}
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
void SetYHeadRot(const Angle y_head_rot_)
{
y_head_rot = y_head_rot_;
}
#endif
void SetType(const char type_)
{
type = type_;
}
void SetData(const int data_)
{
data = data_;
}
int GetId_() const
{
return id_;
}
const UUID& GetUUID() const
{
return uuid;
}
double GetX() const
{
return x;
}
double GetY() const
{
return y;
}
double GetZ() const
{
return z;
}
short GetXa() const
{
return xa;
}
short GetYa() const
{
return ya;
}
short GetZa() const
{
return za;
}
Angle GetXRot() const
{
return x_rot;
}
Angle GetYRot() const
{
return y_rot;
}
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
Angle GetYHeadRot() const
{
return y_head_rot;
}
#endif
char GetType() const
{
return type;
}
int GetData() const
{
return data;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
id_ = ReadData<VarInt>(iter, length);
uuid = ReadData<UUID>(iter, length);
#if PROTOCOL_VERSION < 458 /* < 1.14 */
type = ReadData<char>(iter, length);
#else
type = ReadData<VarInt>(iter, length);
#endif
x = ReadData<double>(iter, length);
y = ReadData<double>(iter, length);
z = ReadData<double>(iter, length);
x_rot = ReadData<Angle>(iter, length);
y_rot = ReadData<Angle>(iter, length);
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
y_head_rot = ReadData<Angle>(iter, length);
data = ReadData<VarInt>(iter, length);
#else
data = ReadData<int>(iter, length);
#endif
xa = ReadData<short>(iter, length);
ya = ReadData<short>(iter, length);
za = ReadData<short>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(id_, container);
WriteData<UUID>(uuid, container);
#if PROTOCOL_VERSION < 458 /* < 1.14 */
WriteData<char>(type, container);
#else
WriteData<VarInt>(type, container);
#endif
WriteData<double>(x, container);
WriteData<double>(y, container);
WriteData<double>(z, container);
WriteData<Angle>(x_rot, container);
WriteData<Angle>(y_rot, container);
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
WriteData<Angle>(y_head_rot, container);
WriteData<VarInt>(data, container);
#else
WriteData<int>(data, container);
#endif
WriteData<short>(xa, container);
WriteData<short>(ya, container);
WriteData<short>(za, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["id_"] = id_;
output["uuid"] = uuid;
output["type"] = type;
output["x"] = x;
output["y"] = y;
output["z"] = z;
output["x_rot"] = x_rot;
output["y_rot"] = y_rot;
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
output["y_head_rot"] = y_head_rot;
#endif
output["data"] = data;
output["xa"] = xa;
output["ya"] = ya;
output["za"] = za;
return output;
}
private:
int id_ = 0;
UUID uuid = {};
#if PROTOCOL_VERSION < 458 /* < 1.14 */
char type = 0;
#else
int type = 0;
#endif
double x = 0.0;
double y = 0.0;
double z = 0.0;
short xa = 0;
short ya = 0;
short za = 0;
Angle x_rot = 0;
Angle y_rot = 0;
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
Angle y_head_rot = 0;
#endif
int data = 0;
};
} //ProtocolCraft
@@ -0,0 +1,129 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundAddExperienceOrbPacket : public BaseMessage<ClientboundAddExperienceOrbPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */ || PROTOCOL_VERSION == 393 /* 1.13 */ || \
PROTOCOL_VERSION == 401 /* 1.13.1 */ || PROTOCOL_VERSION == 404 /* 1.13.2 */ || \
PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */ || PROTOCOL_VERSION == 573 /* 1.15 */ || \
PROTOCOL_VERSION == 575 /* 1.15.1 */ || PROTOCOL_VERSION == 578 /* 1.15.2 */ || \
PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */ || \
PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */ || PROTOCOL_VERSION == 755 /* 1.17 */ || \
PROTOCOL_VERSION == 756 /* 1.17.1 */ || PROTOCOL_VERSION == 757 /* 1.18/.1 */ || \
PROTOCOL_VERSION == 758 /* 1.18.2 */ || PROTOCOL_VERSION == 759 /* 1.19 */ || \
PROTOCOL_VERSION == 760 /* 1.19.1/2 */ || PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x01;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */ || \
PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x02;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Add Experience Orb";
virtual ~ClientboundAddExperienceOrbPacket() override
{
}
void SetId_(const int id__)
{
id_ = id__;
}
void SetX(const double x_)
{
x = x_;
}
void SetY(const double y_)
{
y = y_;
}
void SetZ(const double z_)
{
z = z_;
}
void SetValue(const short value__)
{
value_ = value__;
}
int GetId_() const
{
return id_;
}
double GetX() const
{
return x;
}
double GetY() const
{
return y;
}
double GetZ() const
{
return z;
}
short GetValue() const
{
return value_;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
id_ = ReadData<VarInt>(iter, length);
x = ReadData<double>(iter, length);
y = ReadData<double>(iter, length);
z = ReadData<double>(iter, length);
value_ = ReadData<short>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(id_, container);
WriteData<double>(x, container);
WriteData<double>(y, container);
WriteData<double>(z, container);
WriteData<short>(value_, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["id_"] = id_;
output["x"] = x;
output["y"] = y;
output["z"] = z;
output["value"] = value_;
return output;
}
private:
int id_ = 0;
double x = 0.0;
double y = 0.0;
double z = 0.0;
short value_ = 0;
};
} //ProtocolCraft
@@ -0,0 +1,122 @@
#pragma once
#if PROTOCOL_VERSION < 721 /* < 1.16 */
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundAddGlobalEntityPacket : public BaseMessage<ClientboundAddGlobalEntityPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */ || PROTOCOL_VERSION == 393 /* 1.13 */ || \
PROTOCOL_VERSION == 401 /* 1.13.1 */ || PROTOCOL_VERSION == 404 /* 1.13.2 */ || \
PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */ || PROTOCOL_VERSION == 573 /* 1.15 */ || \
PROTOCOL_VERSION == 575 /* 1.15.1 */ || PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x02;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Add Global Entity";
virtual ~ClientboundAddGlobalEntityPacket() override
{
}
void SetId_(const int id__)
{
id_ = id__;
}
void SetX(const double x_)
{
x = x_;
}
void SetY(const double y_)
{
y = y_;
}
void SetZ(const double z_)
{
z = z_;
}
void SetType(const char type_)
{
type = type_;
}
int GetId_() const
{
return id_;
}
double GetX() const
{
return x;
}
double GetY() const
{
return y;
}
double GetZ() const
{
return z;
}
char GetType() const
{
return type;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
id_ = ReadData<VarInt>(iter, length);
type = ReadData<char>(iter, length);
x = ReadData<double>(iter, length);
y = ReadData<double>(iter, length);
z = ReadData<double>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(id_, container);
WriteData<char>(type, container);
WriteData<double>(x, container);
WriteData<double>(y, container);
WriteData<double>(z, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["id_"] = id_;
output["type"] = type;
output["x"] = x;
output["y"] = y;
output["z"] = z;
return output;
}
private:
int id_ = 0;
double x = 0.0;
double y = 0.0;
double z = 0.0;
char type = 0;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,252 @@
#if PROTOCOL_VERSION < 759 /* < 1.19 */
#pragma once
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundAddMobPacket : public BaseMessage<ClientboundAddMobPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */ || PROTOCOL_VERSION == 393 /* 1.13 */ || \
PROTOCOL_VERSION == 401 /* 1.13.1 */ || PROTOCOL_VERSION == 404 /* 1.13.2 */ || \
PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */ || PROTOCOL_VERSION == 573 /* 1.15 */ || \
PROTOCOL_VERSION == 575 /* 1.15.1 */ || PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x03;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */ || \
PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */ || PROTOCOL_VERSION == 755 /* 1.17 */ || \
PROTOCOL_VERSION == 756 /* 1.17.1 */ || PROTOCOL_VERSION == 757 /* 1.18/.1 */ || \
PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x02;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Add Mob";
virtual ~ClientboundAddMobPacket() override
{
}
void SetId_(const int id__)
{
id_ = id__;
}
void SetUUID(const UUID& uuid_)
{
uuid = uuid_;
}
void SetType(const int type_)
{
type = type_;
}
void SetX(const double x_)
{
x = x_;
}
void SetY(const double y_)
{
y = y_;
}
void SetZ(const double z_)
{
z = z_;
}
void SetYRot(const Angle yRot_)
{
y_rot = yRot_;
}
void SetXRot(const Angle xRot_)
{
x_rot = xRot_;
}
void SetYHeadRot(const Angle y_head_rot_)
{
y_head_rot = y_head_rot_;
}
void SetXd(const short xd_)
{
xd = xd_;
}
void SetYd(const short yd_)
{
yd = yd_;
}
void SetZd(const short zd_)
{
zd = zd_;
}
#if PROTOCOL_VERSION < 550 /* < 1.15 */
void SetRawMetadata(const std::vector<unsigned char>& raw_metadata_)
{
raw_metadata = raw_metadata_;
}
#endif
int GetId_() const
{
return id_;
}
const UUID& GetUUID() const
{
return uuid;
}
int GetType() const
{
return type;
}
double GetX() const
{
return x;
}
double GetY() const
{
return y;
}
double GetZ() const
{
return z;
}
Angle GetYRot() const
{
return y_rot;
}
Angle GetXRot() const
{
return x_rot;
}
Angle GetYHeadRot() const
{
return y_head_rot;
}
short GetXd() const
{
return xd;
}
short GetYd() const
{
return yd;
}
short GetZd() const
{
return zd;
}
#if PROTOCOL_VERSION < 550 /* < 1.15 */
const std::vector<unsigned char>& GetRawMetadata() const
{
return raw_metadata;
}
#endif
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
id_ = ReadData<VarInt>(iter, length);
uuid = ReadData<UUID>(iter, length);
type = ReadData<VarInt>(iter, length);
x = ReadData<double>(iter, length);
y = ReadData<double>(iter, length);
z = ReadData<double>(iter, length);
y_rot = ReadData<Angle>(iter, length);
x_rot = ReadData<Angle>(iter, length);
y_head_rot = ReadData<Angle>(iter, length);
xd = ReadData<short>(iter, length);
yd = ReadData<short>(iter, length);
zd = ReadData<short>(iter, length);
#if PROTOCOL_VERSION < 550 /* < 1.15 */
raw_metadata = ReadByteArray(iter, length, length);
#endif
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(id_, container);
WriteData<UUID>(uuid, container);
WriteData<VarInt>(type, container);
WriteData<double>(x, container);
WriteData<double>(y, container);
WriteData<double>(z, container);
WriteData<Angle>(y_rot, container);
WriteData<Angle>(x_rot, container);
WriteData<Angle>(y_head_rot, container);
WriteData<short>(xd, container);
WriteData<short>(yd, container);
WriteData<short>(zd, container);
#if PROTOCOL_VERSION < 550 /* < 1.15 */
WriteByteArray(raw_metadata, container);
#endif
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["id_"] = id_;
output["uuid"] = uuid;
output["type"] = type;
output["x"] = x;
output["y"] = y;
output["z"] = z;
output["y_rot"] = y_rot;
output["x_rot"] = x_rot;
output["y_head_rot"] = y_head_rot;
output["xd"] = xd;
output["yd"] = yd;
output["zd"] = zd;
#if PROTOCOL_VERSION < 550 /* < 1.15 */
output["raw_metadata"] = "Vector of " + std::to_string(raw_metadata.size()) + " unsigned char";
#endif
return output;
}
private:
int id_ = 0;
UUID uuid = {};
int type = 0;
double x = 0.0;
double y = 0.0;
double z = 0.0;
short xd = 0;
short yd = 0;
short zd = 0;
Angle y_rot = 0;
Angle x_rot = 0;
Angle y_head_rot = 0;
#if PROTOCOL_VERSION < 550 /* < 1.15 */
std::vector<unsigned char> raw_metadata;
#endif
};
} //ProtocolCraft
#endif
@@ -0,0 +1,159 @@
#if PROTOCOL_VERSION < 759 /* < 1.19 */
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/NetworkPosition.hpp"
namespace ProtocolCraft
{
class ClientboundAddPaintingPacket : public BaseMessage<ClientboundAddPaintingPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */ || PROTOCOL_VERSION == 393 /* 1.13 */ || \
PROTOCOL_VERSION == 401 /* 1.13.1 */ || PROTOCOL_VERSION == 404 /* 1.13.2 */ || \
PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */ || PROTOCOL_VERSION == 573 /* 1.15 */ || \
PROTOCOL_VERSION == 575 /* 1.15.1 */ || PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x04;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */ || \
PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */ || PROTOCOL_VERSION == 755 /* 1.17 */ || \
PROTOCOL_VERSION == 756 /* 1.17.1 */ || PROTOCOL_VERSION == 757 /* 1.18/.1 */ || \
PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x03;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Add Painting";
virtual ~ClientboundAddPaintingPacket() override
{
}
void SetId_(const int id__)
{
id_ = id__;
}
void SetUuid(const UUID& uuid_)
{
uuid = uuid_;
}
void SetPos(const NetworkPosition& pos_)
{
pos = pos_;
}
void SetDirection(const char direction_)
{
direction = direction_;
}
#if PROTOCOL_VERSION < 353 /* < 1.13 */
void SetTitle(const std::string& title_)
{
title = title_;
}
#else
void SetMotive(const int motive_)
{
motive = motive_;
}
#endif
int GetId_() const
{
return id_;
}
const UUID& GetUuid() const
{
return uuid;
}
const NetworkPosition& GetPos() const
{
return pos;
}
char GetDirection() const
{
return direction;
}
#if PROTOCOL_VERSION < 353 /* < 1.13 */
const std::string& GetTitle() const
{
return title;
}
#else
int GetMotive() const
{
return motive;
}
#endif
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
id_ = ReadData<VarInt>(iter, length);
uuid = ReadData<UUID>(iter, length);
#if PROTOCOL_VERSION < 353 /* < 1.13 */
title = ReadData<std::string>(iter, length);
#else
motive = ReadData<VarInt>(iter, length);
#endif
pos = ReadData<NetworkPosition>(iter, length);
direction = ReadData<char>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(id_, container);
WriteData<UUID>(uuid, container);
#if PROTOCOL_VERSION < 353 /* < 1.13 */
WriteData<std::string>(title, container);
#else
WriteData<VarInt>(motive, container);
#endif
WriteData<NetworkPosition>(pos, container);
WriteData<char>(direction, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["id_"] = id_;
output["uuid"] = uuid;
#if PROTOCOL_VERSION < 353 /* < 1.13 */
output["title"] = title;
#else
output["motive"] = motive;
#endif
output["pos"] = pos;
output["direction"] = direction;
return output;
}
private:
int id_ = 0;
UUID uuid = {};
NetworkPosition pos;
char direction = 0;
#if PROTOCOL_VERSION < 353 /* < 1.13 */
std::string title;
#else
int motive = 0;
#endif
};
} //ProtocolCraft
#endif
@@ -0,0 +1,187 @@
#pragma once
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundAddPlayerPacket : public BaseMessage<ClientboundAddPlayerPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */ || PROTOCOL_VERSION == 393 /* 1.13 */ || \
PROTOCOL_VERSION == 401 /* 1.13.1 */ || PROTOCOL_VERSION == 404 /* 1.13.2 */ || \
PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */ || PROTOCOL_VERSION == 573 /* 1.15 */ || \
PROTOCOL_VERSION == 575 /* 1.15.1 */ || PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x05;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */ || \
PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */ || PROTOCOL_VERSION == 755 /* 1.17 */ || \
PROTOCOL_VERSION == 756 /* 1.17.1 */ || PROTOCOL_VERSION == 757 /* 1.18/.1 */ || \
PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x04;
#elif PROTOCOL_VERSION == 759 /* 1.19 */ || PROTOCOL_VERSION == 760 /* 1.19.1/2 */ || \
PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x02;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x03;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Add Player";
virtual ~ClientboundAddPlayerPacket() override
{
}
void SetEntityId(const int entity_id_)
{
entity_id = entity_id_;
}
void SetPlayerId(const UUID& player_id_)
{
player_id = player_id_;
}
void SetX(const double x_)
{
x = x_;
}
void SetY(const double y_)
{
y = y_;
}
void SetZ(const double z_)
{
z = z_;
}
void SetYRot(const Angle yRot_)
{
yRot = yRot_;
}
void SetXRot(const Angle xRot_)
{
xRot = xRot_;
}
#if PROTOCOL_VERSION < 550 /* < 1.15 */
void SetRawMetadata(const std::vector<unsigned char> raw_metadata_)
{
raw_metadata = raw_metadata_;
}
#endif
int GetEntityId() const
{
return entity_id;
}
const UUID& GetPlayerId() const
{
return player_id;
}
double GetX() const
{
return x;
}
double GetY() const
{
return y;
}
double GetZ() const
{
return z;
}
Angle GetYRot() const
{
return yRot;
}
Angle GetXRot() const
{
return xRot;
}
#if PROTOCOL_VERSION < 550 /* < 1.15 */
const std::vector<unsigned char>& GetRawMetadata() const
{
return raw_metadata;
}
#endif
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
entity_id = ReadData<VarInt>(iter, length);
player_id = ReadData<UUID>(iter, length);
x = ReadData<double>(iter, length);
y = ReadData<double>(iter, length);
z = ReadData<double>(iter, length);
yRot = ReadData<Angle>(iter, length);
xRot = ReadData<Angle>(iter, length);
#if PROTOCOL_VERSION < 550 /* < 1.15 */
raw_metadata = ReadByteArray(iter, length, length);
#endif
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(entity_id, container);
WriteData<UUID>(player_id, container);
WriteData<double>(x, container);
WriteData<double>(y, container);
WriteData<double>(z, container);
WriteData<Angle>(yRot, container);
WriteData<Angle>(xRot, container);
#if PROTOCOL_VERSION < 550 /* < 1.15 */
WriteByteArray(raw_metadata, container);
#endif
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["entity_id"] = entity_id;
output["player_id"] = player_id;
output["x"] = x;
output["y"] = y;
output["z"] = z;
output["yRot"] = yRot;
output["xRot"] = xRot;
#if PROTOCOL_VERSION < 550 /* < 1.15 */
output["raw_metadata"] = "Vector of " + std::to_string(raw_metadata.size()) + " unsigned char";
#endif
return output;
}
private:
int entity_id = 0;
UUID player_id = {};
double x = 0.0;
double y = 0.0;
double z = 0.0;
Angle yRot = 0;
Angle xRot = 0;
#if PROTOCOL_VERSION < 550 /* < 1.15 */
std::vector<unsigned char> raw_metadata;
#endif
};
} //ProtocolCraft
#endif
@@ -0,0 +1,63 @@
#if PROTOCOL_VERSION > 754 /* > 1.16.5 */ && PROTOCOL_VERSION < 759 /* < 1.19 */
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/Vibrations/VibrationPath.hpp"
namespace ProtocolCraft
{
class ClientboundAddVibrationSignalPacket : public BaseMessage<ClientboundAddVibrationSignalPacket>
{
public:
#if PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x05;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Add Vibration Signal";
virtual ~ClientboundAddVibrationSignalPacket() override
{
}
void SetVibrationPath(const VibrationPath& vibration_path_)
{
vibration_path = vibration_path_;
}
const VibrationPath& GetVibrationPath() const
{
return vibration_path;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
vibration_path = ReadData<VibrationPath>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VibrationPath>(vibration_path, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["vibration_path"] = vibration_path;
return output;
}
private:
VibrationPath vibration_path;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,92 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundAnimatePacket : public BaseMessage<ClientboundAnimatePacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */ || PROTOCOL_VERSION == 393 /* 1.13 */ || \
PROTOCOL_VERSION == 401 /* 1.13.1 */ || PROTOCOL_VERSION == 404 /* 1.13.2 */ || \
PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */ || PROTOCOL_VERSION == 573 /* 1.15 */ || \
PROTOCOL_VERSION == 575 /* 1.15.1 */ || PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x06;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */ || \
PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x05;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x06;
#elif PROTOCOL_VERSION == 759 /* 1.19 */ || PROTOCOL_VERSION == 760 /* 1.19.1/2 */ || \
PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x03;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x04;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x03;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Animate";
virtual ~ClientboundAnimatePacket() override
{
}
void SetId_(const int id__)
{
id_ = id__;
}
void SetAction(const unsigned char action_)
{
action = action_;
}
int GetId_() const
{
return id_;
}
unsigned char GetAction() const
{
return action;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
id_ = ReadData<VarInt>(iter, length);
action = ReadData<unsigned char>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(id_, container);
WriteData<unsigned char>(action, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["id_"] = id_;
output["action"] = action;
return output;
}
private:
int id_ = 0;
unsigned char action = 0;
};
} //ProtocolCraft
@@ -0,0 +1,149 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#include <map>
namespace ProtocolCraft
{
class ClientboundAwardStatsPacket : public BaseMessage<ClientboundAwardStatsPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */ || PROTOCOL_VERSION == 393 /* 1.13 */ || \
PROTOCOL_VERSION == 401 /* 1.13.1 */ || PROTOCOL_VERSION == 404 /* 1.13.2 */ || \
PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */ || PROTOCOL_VERSION == 573 /* 1.15 */ || \
PROTOCOL_VERSION == 575 /* 1.15.1 */ || PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x07;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */ || \
PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x06;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x07;
#elif PROTOCOL_VERSION == 759 /* 1.19 */ || PROTOCOL_VERSION == 760 /* 1.19.1/2 */ || \
PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x04;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x05;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x04;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Award Stats";
virtual ~ClientboundAwardStatsPacket() override
{
}
#if PROTOCOL_VERSION < 346 /* < 1.13 */
void SetStats(const std::map<std::string, int>& stats_)
{
stats = stats_;
}
#else
void SetStats(const std::map<std::pair<int, int>, int>& stats_)
{
stats = stats_;
}
#endif
#if PROTOCOL_VERSION < 346 /* < 1.13 */
const std::map<std::string, int>& GetStats() const
{
return stats;
}
#else
const std::map<std::pair<int, int>, int>& GetStats() const
{
return stats;
}
#endif
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
#if PROTOCOL_VERSION < 346 /* < 1.13 */
stats = ReadMap<std::string, int>(iter, length,
[](ReadIterator& i, size_t& l)
{
const std::string name = ReadData<std::string>(i, l);
const int val = ReadData<VarInt>(i, l);
return std::make_pair(name, val);
}
);
#else
stats = ReadMap<std::pair<int, int>, int>(iter, length,
[](ReadIterator& i, size_t& l)
{
const int category_id = ReadData<VarInt>(i, l);
const int stats_id = ReadData<VarInt>(i, l);
const int val = ReadData<VarInt>(i, l);
return std::make_pair(std::make_pair(category_id, stats_id), val);
}
);
#endif
}
virtual void WriteImpl(WriteContainer& container) const override
{
#if PROTOCOL_VERSION < 346 /* < 1.13 */
WriteMap<std::string, int>(stats, container,
[](const std::pair<const std::string, int>& p, WriteContainer& c)
{
WriteData<std::string>(p.first, c);
WriteData<VarInt>(p.second, c);
}
);
#else
WriteMap<std::pair<int, int>, int>(stats, container,
[](const std::pair<const std::pair<int, int>, int>& p, WriteContainer& c)
{
WriteData<VarInt>(p.first.first, c);
WriteData<VarInt>(p.first.second, c);
WriteData<VarInt>(p.second, c);
}
);
#endif
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
#if PROTOCOL_VERSION < 346 /* < 1.13 */
output["stats"] = stats;
#else
output["stats"] = Json::Array();
for (const auto& p : stats)
{
output.push_back({
{"category_id", p.first.first},
{"stats_id", p.first.second},
{"value", p.second} }
);
}
#endif
return output;
}
private:
#if PROTOCOL_VERSION < 346 /* < 1.13 */
std::map<std::string, int> stats;
#else
std::map<std::pair<int, int>, int> stats;
#endif
};
} //ProtocolCraft
@@ -0,0 +1,111 @@
#if PROTOCOL_VERSION > 493 /* > 1.14.3 */ && PROTOCOL_VERSION < 759 /* < 1.19 */
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/NetworkPosition.hpp"
namespace ProtocolCraft
{
class ClientboundBlockBreakAckPacket : public BaseMessage<ClientboundBlockBreakAckPacket>
{
public:
#if PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x5C;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x08;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */ || \
PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x07;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x08;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Block Break Ack";
virtual ~ClientboundBlockBreakAckPacket() override
{
}
void SetPos(const NetworkPosition& pos_)
{
pos = pos_;
}
void SetState(const int state_)
{
state = state_;
}
void SetAction(const int action_)
{
action = action_;
}
void SetAllGood(const bool all_good_)
{
all_good = all_good_;
}
const NetworkPosition& GetPos() const
{
return pos;
}
int GetState() const
{
return state;
}
int GetAction() const
{
return action;
}
bool GetAllGood() const
{
return all_good;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
pos = ReadData<NetworkPosition>(iter, length);
state = ReadData<VarInt>(iter, length);
action = ReadData<VarInt>(iter, length);
all_good = ReadData<bool>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<NetworkPosition>(pos, container);
WriteData<VarInt>(state, container);
WriteData<VarInt>(action, container);
WriteData<bool>(all_good, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["pos"] = pos;
output["state"] = state;
output["action"] = action;
output["all_good"] = all_good;
return output;
}
private:
NetworkPosition pos;
int state = 0;
int action = 0;
bool all_good = false;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,65 @@
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
#pragma once
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundBlockChangedAckPacket : public BaseMessage<ClientboundBlockChangedAckPacket>
{
public:
#if PROTOCOL_VERSION == 759 /* 1.19 */ || PROTOCOL_VERSION == 760 /* 1.19.1/2 */ || \
PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x05;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x06;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x05;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Block Changed Ack";
virtual ~ClientboundBlockChangedAckPacket() override
{
}
void SetSequence(const int sequence_)
{
sequence = sequence_;
}
int GetSequence() const
{
return sequence;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
sequence = ReadData<VarInt>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(sequence, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["sequence"] = sequence;
return output;
}
private:
int sequence = 0;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,109 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/NetworkPosition.hpp"
namespace ProtocolCraft
{
class ClientboundBlockDestructionPacket : public BaseMessage<ClientboundBlockDestructionPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */ || PROTOCOL_VERSION == 393 /* 1.13 */ || \
PROTOCOL_VERSION == 401 /* 1.13.1 */ || PROTOCOL_VERSION == 404 /* 1.13.2 */ || \
PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x08;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x09;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */ || \
PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x08;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x09;
#elif PROTOCOL_VERSION == 759 /* 1.19 */ || PROTOCOL_VERSION == 760 /* 1.19.1/2 */ || \
PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x06;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x07;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x06;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Block Break Animation";
virtual ~ClientboundBlockDestructionPacket() override
{
}
void SetId_(const int id__)
{
id_ = id__;
}
void SetPos(const NetworkPosition& pos_)
{
pos = pos_;
}
void SetProgress(const char progress_)
{
progress = progress_;
}
int GetId_() const
{
return id_;
}
const NetworkPosition& GetPos() const
{
return pos;
}
char GetProgress() const
{
return progress;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
id_ = ReadData<VarInt>(iter, length);
pos = ReadData<NetworkPosition>(iter, length);
progress = ReadData<char>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(id_, container);
WriteData<NetworkPosition>(pos, container);
WriteData<char>(progress, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["id_"] = id_;
output["pos"] = pos;
output["progress"] = progress;
return output;
}
private:
int id_ = 0;
NetworkPosition pos;
char progress = 0;
};
} //ProtocolCraft
@@ -0,0 +1,133 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/NBT/NBT.hpp"
#include "protocolCraft/Types/NetworkPosition.hpp"
namespace ProtocolCraft
{
class ClientboundBlockEntityDataPacket : public BaseMessage<ClientboundBlockEntityDataPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */ || PROTOCOL_VERSION == 393 /* 1.13 */ || \
PROTOCOL_VERSION == 401 /* 1.13.1 */ || PROTOCOL_VERSION == 404 /* 1.13.2 */ || \
PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x09;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x0A;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */ || \
PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x09;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x0A;
#elif PROTOCOL_VERSION == 759 /* 1.19 */ || PROTOCOL_VERSION == 760 /* 1.19.1/2 */ || \
PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x07;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x08;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x07;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Block Entity Data";
virtual ~ClientboundBlockEntityDataPacket() override
{
}
void SetPos(const NetworkPosition& pos_)
{
pos = pos_;
}
#if PROTOCOL_VERSION < 757 /* < 1.18 */
void SetType(const unsigned char type_)
{
type = type_;
}
#else
void SetType(const int type_)
{
type = type_;
}
#endif
void SetTag(const NBT::Value& tag_)
{
tag = tag_;
}
const NetworkPosition& GetPos() const
{
return pos;
}
#if PROTOCOL_VERSION < 757 /* < 1.18 */
unsigned char GetType() const
{
return type;
}
#else
int GetType() const
{
return type;
}
#endif
const NBT::Value& GetTag() const
{
return tag;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
pos = ReadData<NetworkPosition>(iter, length);
#if PROTOCOL_VERSION < 757 /* < 1.18 */
type = ReadData<unsigned char>(iter, length);
#else
type = ReadData<VarInt>(iter, length);
#endif
tag = ReadData<NBT::UnnamedValue>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<NetworkPosition>(pos, container);
#if PROTOCOL_VERSION < 757 /* < 1.18 */
WriteData<unsigned char>(type, container);
#else
WriteData<VarInt>(type, container);
#endif
WriteData<NBT::UnnamedValue>(tag, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["pos"] = pos;
output["type"] = type;
output["tag"] = tag;
return output;
}
private:
NetworkPosition pos;
#if PROTOCOL_VERSION < 757 /* < 1.18 */
unsigned char type = 0;
#else
int type = 0;
#endif
NBT::Value tag;
};
} //ProtocolCraft
@@ -0,0 +1,123 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/NetworkPosition.hpp"
namespace ProtocolCraft
{
class ClientboundBlockEventPacket : public BaseMessage<ClientboundBlockEventPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */ || PROTOCOL_VERSION == 393 /* 1.13 */ || \
PROTOCOL_VERSION == 401 /* 1.13.1 */ || PROTOCOL_VERSION == 404 /* 1.13.2 */ || \
PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x0A;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x0B;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */ || \
PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x0A;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x0B;
#elif PROTOCOL_VERSION == 759 /* 1.19 */ || PROTOCOL_VERSION == 760 /* 1.19.1/2 */ || \
PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x08;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x09;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x08;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Block Event";
virtual ~ClientboundBlockEventPacket() override
{
}
void SetPos(const NetworkPosition& pos_)
{
pos = pos_;
}
void SetB0(const unsigned char b0_)
{
b0 = b0_;
}
void SetB1(const unsigned char b1_)
{
b1 = b1_;
}
void SetBlock(const int block_)
{
block = block_;
}
const NetworkPosition& GetPos() const
{
return pos;
}
unsigned char GetB0() const
{
return b0;
}
unsigned char GetB1() const
{
return b1;
}
int GetBlock() const
{
return block;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
pos = ReadData<NetworkPosition>(iter, length);
b0 = ReadData<unsigned char>(iter, length);
b1 = ReadData<unsigned char>(iter, length);
block = ReadData<VarInt>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<NetworkPosition>(pos, container);
WriteData<unsigned char>(b0, container);
WriteData<unsigned char>(b1, container);
WriteData<VarInt>(block, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["pos"] = pos;
output["b0"] = b0;
output["b1"] = b1;
output["block"] = block;
return output;
}
private:
NetworkPosition pos;
unsigned char b0 = 0;
unsigned char b1 = 0;
int block = 0;
};
} //ProtocolCraft
@@ -0,0 +1,92 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/NetworkPosition.hpp"
namespace ProtocolCraft
{
class ClientboundBlockUpdatePacket : public BaseMessage<ClientboundBlockUpdatePacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */ || PROTOCOL_VERSION == 393 /* 1.13 */ || \
PROTOCOL_VERSION == 401 /* 1.13.1 */ || PROTOCOL_VERSION == 404 /* 1.13.2 */ || \
PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x0B;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x0C;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */ || \
PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x0B;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x0C;
#elif PROTOCOL_VERSION == 759 /* 1.19 */ || PROTOCOL_VERSION == 760 /* 1.19.1/2 */ || \
PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x09;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x0A;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x09;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Block Update";
virtual ~ClientboundBlockUpdatePacket() override
{
}
void SetPos(const NetworkPosition& pos_)
{
pos = pos_;
}
void SetBlockstate(const int blockstate_)
{
blockstate = blockstate_;
}
const NetworkPosition& GetPos() const
{
return pos;
}
int GetBlockstate() const
{
return blockstate;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
pos = ReadData<NetworkPosition>(iter, length);
blockstate = ReadData<VarInt>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<NetworkPosition>(pos, container);
WriteData<VarInt>(blockstate, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["pos"] = pos;
output["blockstate"] = blockstate;
return output;
}
private:
NetworkPosition pos;
int blockstate = 0;
};
} //ProtocolCraft
@@ -0,0 +1,232 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/Chat/Chat.hpp"
namespace ProtocolCraft
{
class ClientboundBossEventPacket : public BaseMessage<ClientboundBossEventPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */ || PROTOCOL_VERSION == 393 /* 1.13 */ || \
PROTOCOL_VERSION == 401 /* 1.13.1 */ || PROTOCOL_VERSION == 404 /* 1.13.2 */ || \
PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x0C;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x0D;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */ || \
PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x0C;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x0D;
#elif PROTOCOL_VERSION == 759 /* 1.19 */ || PROTOCOL_VERSION == 760 /* 1.19.1/2 */ || \
PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x0A;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x0B;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x0A;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Boss Event";
virtual ~ClientboundBossEventPacket() override
{
}
void SetId_(const UUID& id__)
{
id_ = id__;
}
void SetOperation(const int operation_)
{
operation = operation_;
}
void SetName_(const Chat& name__)
{
name_ = name__;
}
void SetPct(const float pct_)
{
pct = pct_;
}
void SetColor(const int color_)
{
color = color_;
}
void SetOverlay(const int overlay_)
{
overlay = overlay_;
}
void SetFlags(const unsigned char flags_)
{
flags = flags_;
}
const UUID& GetId_() const
{
return id_;
}
int GetOperation() const
{
return operation;
}
const Chat& GetName_() const
{
return name_;
}
float GetPct() const
{
return pct;
}
int GetColor() const
{
return color;
}
int GetOverlay() const
{
return overlay;
}
unsigned char GetFlags() const
{
return flags;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
id_ = ReadData<UUID>(iter, length);
operation = ReadData<VarInt>(iter, length);
switch (operation)
{
case 0:
name_ = ReadData<Chat>(iter, length);
pct = ReadData<float>(iter, length);
color = ReadData<VarInt>(iter, length);
overlay = ReadData<VarInt>(iter, length);
flags = ReadData<unsigned char>(iter, length);
break;
case 1:
break;
case 2:
pct = ReadData<float>(iter, length);
break;
case 3:
name_ = ReadData<Chat>(iter, length);
break;
case 4:
color = ReadData<VarInt>(iter, length);
overlay = ReadData<VarInt>(iter, length);
break;
case 5:
flags = ReadData<unsigned char>(iter, length);
break;
default:
break;
}
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<UUID>(id_, container);
WriteData<VarInt>(operation, container);
switch (operation)
{
case 0:
WriteData<Chat>(name_, container);
WriteData<float>(pct, container);
WriteData<VarInt>(color, container);
WriteData<VarInt>(overlay, container);
WriteData<unsigned char>(flags, container);
break;
case 1:
break;
case 2:
WriteData<float>(pct, container);
break;
case 3:
WriteData<Chat>(name_, container);
break;
case 4:
WriteData<VarInt>(color, container);
WriteData<VarInt>(overlay, container);
break;
case 5:
WriteData<unsigned char>(flags, container);
break;
default:
break;
}
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["id_"] = id_;
output["operation"] = operation;
switch (operation)
{
case 0:
output["name_"] = name_;
output["pct"] = pct;
output["color"] = color;
output["overlay"] = overlay;
output["flags"] = flags;
break;
case 1:
break;
case 2:
output["pct"] = pct;
break;
case 3:
output["name_"] = name_;
break;
case 4:
output["color"] = color;
output["overlay"] = overlay;
break;
case 5:
output["flags"] = flags;
break;
default:
break;
}
return output;
}
private:
UUID id_ = {};
int operation = 0;
Chat name_;
float pct = 0.0f;
int color = 0;
int overlay = 0;
unsigned char flags = 0;
};
} //ProtocolCraft
@@ -0,0 +1,48 @@
#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
#pragma once
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundBundlePacket : public BaseMessage<ClientboundBundlePacket>
{
public:
#if PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */ || \
PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x00;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Bundle";
virtual ~ClientboundBundlePacket() override
{
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
}
virtual void WriteImpl(WriteContainer& container) const override
{
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
return output;
}
private:
};
} //ProtocolCraft
#endif
@@ -0,0 +1,104 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundChangeDifficultyPacket : public BaseMessage<ClientboundChangeDifficultyPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */ || PROTOCOL_VERSION == 393 /* 1.13 */ || \
PROTOCOL_VERSION == 401 /* 1.13.1 */ || PROTOCOL_VERSION == 404 /* 1.13.2 */ || \
PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x0D;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x0E;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */ || \
PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x0D;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x0E;
#elif PROTOCOL_VERSION == 759 /* 1.19 */ || PROTOCOL_VERSION == 760 /* 1.19.1/2 */ || \
PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x0B;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x0C;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x0B;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Change Difficulty";
virtual ~ClientboundChangeDifficultyPacket() override
{
}
void SetDifficulty(const int difficulty_)
{
difficulty = difficulty_;
}
#if PROTOCOL_VERSION >= 477 /* >= 1.14 */
void SetLocked(const bool locked_)
{
locked = locked_;
}
#endif
int GetDifficulty() const
{
return difficulty;
}
#if PROTOCOL_VERSION >= 477 /* >= 1.14 */
bool GetLocked() const
{
return locked;
}
#endif
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
difficulty = ReadData<unsigned char>(iter, length);
#if PROTOCOL_VERSION >= 477 /* >= 1.14 */
locked = ReadData<bool>(iter, length);
#endif
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<unsigned char>((unsigned char)difficulty, container);
#if PROTOCOL_VERSION >= 477 /* >= 1.14 */
WriteData<bool>(locked, container);
#endif
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["difficulty"] = difficulty;
#if PROTOCOL_VERSION >= 477 /* >= 1.14 */
output["locked"] = locked;
#endif
return output;
}
private:
int difficulty = 0;
#if PROTOCOL_VERSION >= 477 /* >= 1.14 */
bool locked = false;
#endif
};
} //ProtocolCraft
@@ -0,0 +1,114 @@
#if PROTOCOL_VERSION < 759 /* < 1.19 */
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/Chat/Chat.hpp"
namespace ProtocolCraft
{
class ClientboundChatPacket : public BaseMessage<ClientboundChatPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x0F;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */ || PROTOCOL_VERSION == 477 /* 1.14 */ || \
PROTOCOL_VERSION == 480 /* 1.14.1 */ || PROTOCOL_VERSION == 485 /* 1.14.2 */ || \
PROTOCOL_VERSION == 490 /* 1.14.3 */ || PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x0E;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x0F;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */ || \
PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x0E;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x0F;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Chat";
virtual ~ClientboundChatPacket() override
{
}
void SetMessage(const Chat& message_)
{
message = message_;
}
void SetType(const char type_)
{
type = type_;
}
#if PROTOCOL_VERSION > 717 /* > 1.15.2 */
void SetSender(const UUID& sender_)
{
sender = sender_;
}
#endif
const Chat& GetMessage() const
{
return message;
}
char GetType() const
{
return type;
}
#if PROTOCOL_VERSION > 717 /* > 1.15.2 */
const UUID& GetSender() const
{
return sender;
}
#endif
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
message = ReadData<Chat>(iter, length);
type = ReadData<char>(iter, length);
#if PROTOCOL_VERSION > 717 /* > 1.15.2 */
sender = ReadData<UUID>(iter, length);
#endif
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<Chat>(message, container);
WriteData<char>(type, container);
#if PROTOCOL_VERSION > 717 /* > 1.15.2 */
WriteData<UUID>(sender, container);
#endif
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["message"] = message;
output["type"] = type;
#if PROTOCOL_VERSION > 717 /* > 1.15.2 */
output["sender"] = sender;
#endif
return output;
}
private:
Chat message;
char type = 0;
#if PROTOCOL_VERSION > 717 /* > 1.15.2 */
UUID sender = {};
#endif
};
} //ProtocolCraft
#endif
@@ -0,0 +1,79 @@
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */ && PROTOCOL_VERSION < 761 /* < 1.19.3 */
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/Chat/Chat.hpp"
namespace ProtocolCraft
{
class ClientboundChatPreviewPacket : public BaseMessage<ClientboundChatPreviewPacket>
{
public:
#if PROTOCOL_VERSION == 759 /* 1.19 */ || PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x0C;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Chat Preview";
virtual ~ClientboundChatPreviewPacket() override
{
}
void SetQueryId(const int query_id_)
{
query_id = query_id_;
}
void SetPreview(const std::optional<Chat>& preview_)
{
preview = preview_;
}
char GetQueryId() const
{
return query_id;
}
const std::optional<Chat>& Getpreview() const
{
return preview;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
query_id = ReadData<int>(iter, length);
preview = ReadOptional<Chat>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<int>(query_id, container);
WriteOptional<Chat>(preview, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["query_id"] = query_id;
if (preview.has_value())
{
output["preview"] = preview.value();
}
return output;
}
private:
int query_id = 0;
std::optional<Chat> preview;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,58 @@
#pragma once
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundChunkBatchFinishedPacket : public BaseMessage<ClientboundChunkBatchFinishedPacket>
{
public:
#if PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x0C;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Chunk Batch Finished";
virtual ~ClientboundChunkBatchFinishedPacket() override
{
}
void SetBatchSize(const int batch_size_)
{
batch_size = batch_size_;
}
int GetBatchSize() const
{
return batch_size;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
batch_size = ReadData<VarInt>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(batch_size, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["batch_size"] = batch_size;
return output;
}
private:
int batch_size = 0;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,47 @@
#pragma once
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundChunkBatchStartPacket : public BaseMessage<ClientboundChunkBatchStartPacket>
{
public:
#if PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x0D;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Chunk Batch Start";
virtual ~ClientboundChunkBatchStartPacket() override
{
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
}
virtual void WriteImpl(WriteContainer& container) const override
{
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
return output;
}
private:
};
} //ProtocolCraft
#endif
@@ -0,0 +1,66 @@
#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/ChunkBiomeData.hpp"
namespace ProtocolCraft
{
class ClientboundChunksBiomesPacket : public BaseMessage<ClientboundChunksBiomesPacket>
{
public:
#if PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x0D;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x0E;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Chunks Biome";
virtual ~ClientboundChunksBiomesPacket() override
{
}
void SetChunkBiomeData(const std::vector<ChunkBiomeData>& chunk_biome_data_)
{
chunk_biome_data = chunk_biome_data_;
}
const std::vector<ChunkBiomeData>& GetChunkBiomeData() const
{
return chunk_biome_data;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
chunk_biome_data = ReadVector<ChunkBiomeData>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteVector<ChunkBiomeData>(chunk_biome_data, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["chunk_biome_data"] = chunk_biome_data;
return output;
}
private:
std::vector<ChunkBiomeData> chunk_biome_data;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,69 @@
#pragma once
#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundClearTitlesPacket : public BaseMessage<ClientboundClearTitlesPacket>
{
public:
#if PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x10;
#elif PROTOCOL_VERSION == 759 /* 1.19 */ || PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x0D;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x0C;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x0E;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x0F;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Clear Titles";
virtual ~ClientboundClearTitlesPacket() override
{
}
void SetResetTimes(const bool reset_times_)
{
reset_times = reset_times_;
}
bool GetResetTimes() const
{
return reset_times;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
reset_times = ReadData<bool>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<bool>(reset_times, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["reset_times"] = reset_times;
return output;
}
private:
bool reset_times = false;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,185 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#if PROTOCOL_VERSION > 356 /* > 1.12.2 */
#include "protocolCraft/Types/Chat/Chat.hpp"
#endif
namespace ProtocolCraft
{
class ClientboundCommandSuggestionsPacket : public BaseMessage<ClientboundCommandSuggestionsPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x0E;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */ || PROTOCOL_VERSION == 477 /* 1.14 */ || \
PROTOCOL_VERSION == 480 /* 1.14.1 */ || PROTOCOL_VERSION == 485 /* 1.14.2 */ || \
PROTOCOL_VERSION == 490 /* 1.14.3 */ || PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x10;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x11;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x10;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x0F;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x11;
#elif PROTOCOL_VERSION == 759 /* 1.19 */ || PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x0E;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x0D;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x0F;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x10;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Command Suggestions";
virtual ~ClientboundCommandSuggestionsPacket() override
{
}
#if PROTOCOL_VERSION > 356 /* > 1.12.2 */
void SetId_(const int id__)
{
id_ = id__;
}
void SetStart(const int start_)
{
start = start_;
}
void SetLength(const int length__)
{
length_ = length__;
}
#endif
void SetSuggestions(const std::vector<std::string>& suggestions_)
{
suggestions = suggestions_;
}
#if PROTOCOL_VERSION > 356 /* > 1.12.2 */
void SetTooltips(const std::vector<std::optional<Chat>>& tooltips_)
{
tooltips = tooltips_;
}
#endif
#if PROTOCOL_VERSION > 356 /* > 1.12.2 */
int GetId_() const
{
return id_;
}
int GetStart() const
{
return start;
}
int GetLength() const
{
return length_;
}
#endif
const std::vector<std::string>& GetSuggestions() const
{
return suggestions;
}
#if PROTOCOL_VERSION > 356 /* > 1.12.2 */
const std::vector<std::optional<Chat>>& GetTooltips() const
{
return tooltips;
}
#endif
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
#if PROTOCOL_VERSION > 356 /* > 1.12.2 */
id_ = ReadData<VarInt>(iter, length);
start = ReadData<VarInt>(iter, length);
length_ = ReadData<VarInt>(iter, length);
#endif
const int count = ReadData<VarInt>(iter, length);
suggestions = std::vector<std::string>(count);
#if PROTOCOL_VERSION > 356 /* > 1.12.2 */
tooltips = std::vector<std::optional<Chat>>(count);
#endif
for (int i = 0; i < count; ++i)
{
suggestions[i] = ReadData<std::string>(iter, length);
#if PROTOCOL_VERSION > 356 /* > 1.12.2 */
tooltips[i] = ReadOptional<Chat>(iter, length);
#endif
}
}
virtual void WriteImpl(WriteContainer& container) const override
{
#if PROTOCOL_VERSION > 356 /* > 1.12.2 */
WriteData<VarInt>(id_, container);
WriteData<VarInt>(start, container);
WriteData<VarInt>(length_, container);
#endif
WriteData<VarInt>(static_cast<int>(suggestions.size()), container);
for (int i = 0; i < suggestions.size(); ++i)
{
WriteData<std::string>(suggestions[i], container);
#if PROTOCOL_VERSION > 356 /* > 1.12.2 */
WriteOptional<Chat>(tooltips[i], container);
#endif
}
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
#if PROTOCOL_VERSION > 356 /* > 1.12.2 */
output["id_"] = id_;
output["start"] = start;
output["length_"] = length_;
#endif
output["suggestions"] = suggestions;
#if PROTOCOL_VERSION > 356 /* > 1.12.2 */
output["tooltips"] = Json::Array();
for (const auto& t : tooltips)
{
output["tooltips"].push_back(t.has_value() ? t.value().Serialize() : Json::Value());
}
#endif
return output;
}
private:
#if PROTOCOL_VERSION > 356 /* > 1.12.2 */
int id_ = 0;
int start = 0;
int length_ = 0;
#endif
std::vector<std::string> suggestions;
#if PROTOCOL_VERSION > 356 /* > 1.12.2 */
std::vector<std::optional<Chat>> tooltips;
#endif
};
} //ProtocolCraft
@@ -0,0 +1,98 @@
#pragma once
#if PROTOCOL_VERSION > 344 /* > 1.12.2 */
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/CommandNode/CommandNode.hpp"
namespace ProtocolCraft
{
class ClientboundCommandsPacket : public BaseMessage<ClientboundCommandsPacket>
{
public:
#if PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */ || PROTOCOL_VERSION == 477 /* 1.14 */ || \
PROTOCOL_VERSION == 480 /* 1.14.1 */ || PROTOCOL_VERSION == 485 /* 1.14.2 */ || \
PROTOCOL_VERSION == 490 /* 1.14.3 */ || PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x11;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x12;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x11;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x10;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x12;
#elif PROTOCOL_VERSION == 759 /* 1.19 */ || PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x0F;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x0E;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x10;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x11;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Commands";
virtual ~ClientboundCommandsPacket() override
{
}
void SetNodes(const std::vector<CommandNode>& nodes_)
{
nodes = nodes_;
}
void SetRootIndex(const int root_index_)
{
root_index = root_index_;
}
const std::vector<CommandNode>& GetNodes() const
{
return nodes;
}
int GetRootIndex() const
{
return root_index;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
nodes = ReadVector<CommandNode>(iter, length);
root_index = ReadData<VarInt>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteVector<CommandNode>(nodes, container);
WriteData<VarInt>(root_index, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["nodes"] = nodes;
output["root_index"] = root_index;
return output;
}
private:
std::vector<CommandNode> nodes;
int root_index = 0;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,99 @@
#pragma once
#if PROTOCOL_VERSION < 755 /* < 1.17 */
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundContainerAckPacket : public BaseMessage<ClientboundContainerAckPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x11;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */ || PROTOCOL_VERSION == 477 /* 1.14 */ || \
PROTOCOL_VERSION == 480 /* 1.14.1 */ || PROTOCOL_VERSION == 485 /* 1.14.2 */ || \
PROTOCOL_VERSION == 490 /* 1.14.3 */ || PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x12;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x13;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x12;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x11;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Container Ack";
virtual ~ClientboundContainerAckPacket() override
{
}
void SetContainerId(const char container_id_)
{
container_id = container_id_;
}
void SetUid(const short uid_)
{
uid = uid_;
}
void SetAccepted(const bool accepted_)
{
accepted = accepted_;
}
char GetContainerId() const
{
return container_id;
}
short GetUid() const
{
return uid;
}
bool GetAccepted() const
{
return accepted;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
container_id = ReadData<char>(iter, length);
uid = ReadData<short>(iter, length);
accepted = ReadData<bool>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<char>(container_id, container);
WriteData<short>(uid, container);
WriteData<bool>(accepted, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["container_id"] = container_id;
output["uid"] = uid;
output["accepted"] = accepted;
return output;
}
private:
char container_id = 0;
short uid = 0;
bool accepted = false;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,83 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundContainerClosePacket : public BaseMessage<ClientboundContainerClosePacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x12;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */ || PROTOCOL_VERSION == 477 /* 1.14 */ || \
PROTOCOL_VERSION == 480 /* 1.14.1 */ || PROTOCOL_VERSION == 485 /* 1.14.2 */ || \
PROTOCOL_VERSION == 490 /* 1.14.3 */ || PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x13;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x14;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x13;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x12;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x13;
#elif PROTOCOL_VERSION == 759 /* 1.19 */ || PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x10;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x0F;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x11;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x12;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Container Close";
virtual ~ClientboundContainerClosePacket() override
{
}
void SetContainerId(const unsigned char container_id_)
{
container_id = container_id_;
}
unsigned char GetContainerId() const
{
return container_id;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
container_id = ReadData<unsigned char>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<unsigned char>(container_id, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["container_id"] = container_id;
return output;
}
private:
unsigned char container_id = 0;
};
} //ProtocolCraft
@@ -0,0 +1,142 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/Slot.hpp"
namespace ProtocolCraft
{
class ClientboundContainerSetContentPacket : public BaseMessage<ClientboundContainerSetContentPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x14;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */
static constexpr int packet_id = 0x15;
#elif PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x14;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x15;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x14;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x13;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x14;
#elif PROTOCOL_VERSION == 759 /* 1.19 */ || PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x11;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x10;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x12;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x13;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Container Set Content";
virtual ~ClientboundContainerSetContentPacket() override
{
}
void SetContainerId(const unsigned char container_id_)
{
container_id = container_id_;
}
void SetItems(const std::vector<Slot>& items_)
{
items = items_;
}
#if PROTOCOL_VERSION > 755 /* > 1.17 */
void SetCarriedItem(const Slot& carried_item_)
{
carried_item = carried_item_;
}
void SetStateId(const int state_id_)
{
state_id = state_id_;
}
#endif
unsigned char GetContainerId() const
{
return container_id;
}
const std::vector<Slot>& GetSlotData() const
{
return items;
}
#if PROTOCOL_VERSION > 755 /* > 1.17 */
const Slot& GetCarriedItem() const
{
return carried_item;
}
int GetStateId() const
{
return state_id;
}
#endif
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
container_id = ReadData<unsigned char>(iter, length);
#if PROTOCOL_VERSION < 756 /* < 1.17.1 */
items = ReadVector<Slot, short>(iter, length);
#else
state_id = ReadData<VarInt>(iter, length);
items = ReadVector<Slot>(iter, length);
carried_item = ReadData<Slot>(iter, length);
#endif
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<unsigned char>(container_id, container);
#if PROTOCOL_VERSION < 756 /* < 1.17.1 */
WriteVector<Slot, short>(items, container);
#else
WriteData<VarInt>(state_id, container);
WriteVector<Slot>(items, container);
WriteData<Slot>(carried_item, container);
#endif
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["container_id"] = container_id;
output["items"] = items;
#if PROTOCOL_VERSION > 755 /* > 1.17 */
output["state_id"] = state_id;
output["carried_item"] = carried_item;
#endif
return output;
}
private:
unsigned char container_id = 0;
std::vector<Slot> items;
#if PROTOCOL_VERSION > 755 /* > 1.17 */
Slot carried_item;
int state_id = 0;
#endif
};
} //ProtocolCraft
@@ -0,0 +1,113 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundContainerSetDataPacket : public BaseMessage<ClientboundContainerSetDataPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x15;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */
static constexpr int packet_id = 0x16;
#elif PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x15;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x16;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x15;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x14;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x15;
#elif PROTOCOL_VERSION == 759 /* 1.19 */ || PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x12;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x11;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x13;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x14;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Container Set Data";
virtual ~ClientboundContainerSetDataPacket() override
{
}
void SetContainerId(const unsigned char container_id_)
{
container_id = container_id_;
}
void SetId_(const short id__)
{
id_ = id__;
}
void SetValue(const short value_)
{
value = value_;
}
unsigned char GetWindowId() const
{
return container_id;
}
short GetId_() const
{
return id_;
}
short GetValue() const
{
return value;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
container_id = ReadData<unsigned char>(iter, length);
id_ = ReadData<short>(iter, length);
value = ReadData<short>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<unsigned char>(container_id, container);
WriteData<short>(id_, container);
WriteData<short>(value, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["container_id"] = container_id;
output["id_"] = id_;
output["value"] = value;
return output;
}
private:
unsigned char container_id = 0;
short id_ = 0;
short value = 0;
};
} //ProtocolCraft
@@ -0,0 +1,140 @@
#pragma once
#include <string>
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/Slot.hpp"
namespace ProtocolCraft
{
class ClientboundContainerSetSlotPacket : public BaseMessage<ClientboundContainerSetSlotPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x16;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */
static constexpr int packet_id = 0x17;
#elif PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x16;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x17;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x16;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x15;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x16;
#elif PROTOCOL_VERSION == 759 /* 1.19 */ || PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x13;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x12;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x14;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x15;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Container Set Slot";
virtual ~ClientboundContainerSetSlotPacket() override
{
}
void SetContainerId(const char container_id_)
{
container_id = container_id_;
}
void SetSlot_(const short slot_)
{
slot = slot_;
}
void SetItemStack(const Slot& item_stack_)
{
item_stack = item_stack_;
}
#if PROTOCOL_VERSION > 755 /* > 1.17 */
void SetStateId(const int state_id_)
{
state_id = state_id_;
}
#endif
char GetContainerId() const
{
return container_id;
}
short GetSlot() const
{
return slot;
}
const Slot& GetItemStack() const
{
return item_stack;
}
#if PROTOCOL_VERSION > 755 /* > 1.17 */
int GetStateId() const
{
return state_id;
}
#endif
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
container_id = ReadData<char>(iter, length);
#if PROTOCOL_VERSION > 755 /* > 1.17 */
state_id = ReadData<VarInt>(iter, length);
#endif
slot = ReadData<short>(iter, length);
item_stack = ReadData<Slot>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<char>(container_id, container);
#if PROTOCOL_VERSION > 755 /* > 1.17 */
WriteData<VarInt>(state_id, container);
#endif
WriteData<short>(slot, container);
WriteData<Slot>(item_stack, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["container_id"] = container_id;
output["slot"] = slot;
output["item_stack"] = item_stack;
#if PROTOCOL_VERSION > 755 /* > 1.17 */
output["state_id"] = state_id;
#endif
return output;
}
private:
char container_id = 0;
short slot = 0;
Slot item_stack;
#if PROTOCOL_VERSION > 755 /* > 1.17 */
int state_id = 0;
#endif
};
} //ProtocolCraft
@@ -0,0 +1,99 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundCooldownPacket : public BaseMessage<ClientboundCooldownPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x17;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */
static constexpr int packet_id = 0x18;
#elif PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x17;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x18;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x17;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x16;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x17;
#elif PROTOCOL_VERSION == 759 /* 1.19 */ || PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x14;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x13;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x15;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x16;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Cooldown";
virtual ~ClientboundCooldownPacket() override
{
}
void SetItem(const int item_)
{
item = item_;
}
void SetDuration(const int duration_)
{
duration = duration_;
}
int GetItem() const
{
return item;
}
int GetDuration() const
{
return duration;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
item = ReadData<VarInt>(iter, length);
duration = ReadData<VarInt>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(item, container);
WriteData<VarInt>(duration, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["item"] = item;
output["duration"] = duration;
return output;
}
private:
int item = 0;
int duration = 0;
};
} //ProtocolCraft
@@ -0,0 +1,81 @@
#if PROTOCOL_VERSION > 759 /* > 1.19 */
#pragma once
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundCustomChatCompletionsPacket : public BaseMessage<ClientboundCustomChatCompletionsPacket>
{
public:
#if PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x15;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x14;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x16;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x17;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Custom Chat Completion Packet";
virtual ~ClientboundCustomChatCompletionsPacket() override
{
}
void SetAction(const int action_)
{
action = action_;
}
void SetEntries(const std::vector<std::string>& entries_)
{
entries = entries_;
}
int GetAction() const
{
return action;
}
const std::vector<std::string>& GetEntries() const
{
return entries;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
action = ReadData<VarInt>(iter, length);
entries = ReadVector<std::string>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(action, container);
WriteVector<std::string>(entries, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["action"] = action;
output["entries"] = entries;
return output;
}
private:
int action = 0;
std::vector<std::string> entries;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,144 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Utilities/Plugins/PluginLoader.hpp"
#include "protocolCraft/Utilities/Plugins/PluginObject.hpp"
namespace ProtocolCraft
{
class ClientboundCustomPayloadPacket : public BaseMessage<ClientboundCustomPayloadPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x18;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */
static constexpr int packet_id = 0x19;
#elif PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x18;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x19;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x18;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x17;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x18;
#elif PROTOCOL_VERSION == 759 /* 1.19 */
static constexpr int packet_id = 0x15;
#elif PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x16;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x15;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x17;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x18;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Custom Payload";
virtual ~ClientboundCustomPayloadPacket() override
{
}
void SetIdentifier(const std::string& identifier_)
{
identifier = identifier_;
}
void SetRawData(const std::vector<unsigned char>& raw_data_)
{
raw_data = raw_data_;
}
void SetParsedData(const std::shared_ptr<PluginObject>& parsed_data_)
{
parsed_data = parsed_data_;
}
const std::string& GetIdentifier() const
{
return identifier;
}
const std::vector<unsigned char>& GetRawData() const
{
return raw_data;
}
const std::shared_ptr<PluginObject>& GetParsedData() const
{
return parsed_data;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
identifier = ReadData<std::string>(iter, length);
parsed_data = CreateObjectFromPlugin(identifier.c_str());
if (parsed_data == nullptr)
{
raw_data = ReadByteArray(iter, length, length);
}
else
{
raw_data.clear();
unsigned long long int data_size = static_cast<unsigned long long int>(length);
const unsigned char* data_ptr = &(*iter);
parsed_data->Read(data_ptr, data_size);
iter += length - data_size;
length = static_cast<size_t>(data_size);
}
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<std::string>(identifier, container);
if (parsed_data == nullptr)
{
WriteByteArray(raw_data, container);
}
else
{
unsigned long long int serialized_length = 0;
const unsigned char* serialized = parsed_data->Write(serialized_length);
WriteByteArray(serialized, static_cast<size_t>(serialized_length), container);
}
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["identifier"] = identifier;
if (parsed_data == nullptr)
{
output["data"] = "Vector of " + std::to_string(raw_data.size()) + " unsigned chars";
}
else
{
const std::string json_serialized(parsed_data->Serialize());
output["data"] = Json::Parse(json_serialized);
}
return output;
}
private:
std::string identifier;
std::vector<unsigned char> raw_data;
std::shared_ptr<PluginObject> parsed_data;
};
} //ProtocolCraft
@@ -0,0 +1,193 @@
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
#pragma once
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundCustomSoundPacket : public BaseMessage<ClientboundCustomSoundPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x19;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */
static constexpr int packet_id = 0x1A;
#elif PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x19;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x1A;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x19;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x18;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x19;
#elif PROTOCOL_VERSION == 759 /* 1.19 */
static constexpr int packet_id = 0x16;
#elif PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x17;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Custom Sound";
virtual ~ClientboundCustomSoundPacket() override
{
}
void SetName_(const std::string& name__)
{
name_ = name__;
}
void SetSource(const int source_)
{
source = source_;
}
void SetX(const int x_)
{
x = x_;
}
void SetY(const int y_)
{
y = y_;
}
void SetZ(const int z_)
{
z = z_;
}
void SetVolume(const float volume_)
{
volume = volume_;
}
void SetPitch(const float pitch_)
{
pitch = pitch_;
}
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
void SetSeed(const long long int seed_)
{
seed = seed_;
}
#endif
const std::string& GetName_() const
{
return name_;
}
int GetSource() const
{
return source;
}
int GetX() const
{
return x;
}
int GetY() const
{
return y;
}
int GetZ() const
{
return z;
}
float GetVolume() const
{
return volume;
}
float GetPitch() const
{
return pitch;
}
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
long long int GetSeed() const
{
return seed;
}
#endif
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
name_ = ReadData<std::string>(iter, length);
source = ReadData<VarInt>(iter, length);
x = ReadData<int>(iter, length);
y = ReadData<int>(iter, length);
z = ReadData<int>(iter, length);
volume = ReadData<float>(iter, length);
pitch = ReadData<float>(iter, length);
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
seed = ReadData<long long int>(iter, length);
#endif
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<std::string>(name_, container);
WriteData<VarInt>(source, container);
WriteData<int>(x, container);
WriteData<int>(y, container);
WriteData<int>(z, container);
WriteData<float>(volume, container);
WriteData<float>(pitch, container);
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
WriteData<long long int>(seed, container);
#endif
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["name_"] = name_;
output["source"] = source;
output["x"] = x;
output["y"] = y;
output["z"] = z;
output["volume"] = volume;
output["pitch"] = pitch;
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
output["seed"] = seed;
#endif
return output;
}
private:
std::string name_;
int source = 0;
int x = 0;
int y = 0;
int z = 0;
float volume = 0.0f;
float pitch = 0.0f;
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
long long int seed = 0;
#endif
};
} //ProtocolCraft
#endif
@@ -0,0 +1,142 @@
#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#if PROTOCOL_VERSION > 356 /* > 1.12.2 */
#include "protocolCraft/Types/Chat/Chat.hpp"
#endif
namespace ProtocolCraft
{
class ClientboundDamageEventPacket : public BaseMessage<ClientboundDamageEventPacket>
{
public:
#if PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x18;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x19;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Damage Event";
virtual ~ClientboundDamageEventPacket() override
{
}
void SetEntityId(const int entity_id_)
{
entity_id = entity_id_;
}
void SetSourceTypeId(const int source_type_id_)
{
source_type_id = source_type_id_;
}
void SetSourceCauseId(const int source_cause_id_)
{
source_cause_id = source_cause_id_;
}
void SetSourceDirectId(const int source_direct_id_)
{
source_direct_id = source_direct_id_;
}
void SetSourcePosition(const std::optional<std::array<double, 3>>& source_position_)
{
source_position = source_position_;
}
int GetEntityId() const
{
return entity_id;
}
int GetSourceTypeId() const
{
return source_type_id;
}
int GetSourceCauseId() const
{
return source_cause_id;
}
int GetSourceDirectId() const
{
return source_direct_id;
}
const std::optional<std::array<double, 3>>& GetSourcePosition() const
{
return source_position;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
entity_id = ReadData<VarInt>(iter, length);
source_type_id = ReadData<VarInt>(iter, length);
source_cause_id = ReadData<VarInt>(iter, length) - 1;
source_direct_id = ReadData<VarInt>(iter, length) - 1;
source_position = ReadOptional<std::array<double, 3>>(iter, length,
[](ReadIterator& i, size_t& l)
{
std::array<double, 3> output;
output[0] = ReadData<double>(i, l);
output[1] = ReadData<double>(i, l);
output[2] = ReadData<double>(i, l);
return output;
}
);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(entity_id, container);
WriteData<VarInt>(source_type_id, container);
WriteData<VarInt>(source_cause_id + 1, container);
WriteData<VarInt>(source_direct_id + 1, container);
WriteOptional<std::array<double, 3>>(source_position, container,
[](const std::array<double, 3>& v, WriteContainer& c)
{
WriteData<double>(v[0], c);
WriteData<double>(v[1], c);
WriteData<double>(v[2], c);
}
);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["entity_id"] = entity_id;
output["source_type_id"] = source_type_id;
output["source_cause_id"] = source_cause_id;
output["source_direct_id"] = source_direct_id;
if (source_position.has_value())
{
output["source_position"] = source_position.value();
}
return output;
}
private:
int entity_id = 0;
int source_type_id = 0;
int source_cause_id = 0;
int source_direct_id = 0;
std::optional<std::array<double, 3>> source_position;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,106 @@
#if PROTOCOL_VERSION > 759 /* > 1.19 */
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/Chat/Chat.hpp"
namespace ProtocolCraft
{
class ClientboundDeleteChatPacket : public BaseMessage<ClientboundDeleteChatPacket>
{
public:
#if PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x18;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x16;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x19;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x1A;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Delete Chat";
virtual ~ClientboundDeleteChatPacket() override
{
}
#if PROTOCOL_VERSION > 760 /* > 1.19.2 */
void SetMessageSignatureId(const int message_signature_id_)
{
message_signature_id = message_signature_id_;
}
#endif
void SetMessageSignature(const std::vector<unsigned char>& message_signature_)
{
message_signature = message_signature_;
}
#if PROTOCOL_VERSION > 760 /* > 1.19.2 */
int GetMessageSignatureId() const
{
return message_signature_id;
}
#endif
const std::vector<unsigned char>& GetMessageSignature() const
{
return message_signature;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
#if PROTOCOL_VERSION > 760 /* > 1.19.2 */
message_signature_id = ReadData<VarInt>(iter, length) - 1;
if (message_signature_id == -1)
{
message_signature = ReadByteArray(iter, length, 256);
}
#else
message_signature = ReadVector<unsigned char>(iter, length);
#endif
}
virtual void WriteImpl(WriteContainer& container) const override
{
#if PROTOCOL_VERSION > 760 /* > 1.19.2 */
WriteData<VarInt>(message_signature_id + 1, container);
if (message_signature_id == -1)
{
WriteByteArray(message_signature, container);
}
#else
WriteVector<unsigned char>(message_signature, container);
#endif
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
#if PROTOCOL_VERSION > 760 /* > 1.19.2 */
output["message_signature_id"] = message_signature_id;
if (message_signature_id == -1)
{
output["message_signature"] = "Vector of " + std::to_string(message_signature.size()) + " unsigned char";
}
#else
output["message_signature"] = "Vector of " + std::to_string(message_signature.size()) + " unsigned char";
#endif
return output;
}
private:
#if PROTOCOL_VERSION > 760 /* > 1.19.2 */
int message_signature_id = 0;
#endif
std::vector<unsigned char> message_signature;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,85 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/Chat/Chat.hpp"
namespace ProtocolCraft
{
class ClientboundDisconnectPacket : public BaseMessage<ClientboundDisconnectPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x1A;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */
static constexpr int packet_id = 0x1B;
#elif PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x1A;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x1B;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x1A;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x19;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x1A;
#elif PROTOCOL_VERSION == 759 /* 1.19 */
static constexpr int packet_id = 0x17;
#elif PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x19;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x17;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x1A;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x1B;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Disconnect";
virtual ~ClientboundDisconnectPacket() override
{
}
void SetReason(const Chat& reason_)
{
reason = reason_;
}
const Chat& GetReason() const
{
return reason;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
reason = ReadData<Chat>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<Chat>(reason, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["reason"] = reason;
return output;
}
private:
Chat reason;
};
} //ProtocolCraft
@@ -0,0 +1,80 @@
#if PROTOCOL_VERSION > 760 /* > 1.19.2 */
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/Chat/Chat.hpp"
#include "protocolCraft/Types/Chat/ChatTypeBoundNetwork.hpp"
namespace ProtocolCraft
{
class ClientboundDisguisedChatPacket : public BaseMessage<ClientboundDisguisedChatPacket>
{
public:
#if PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x18;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x1B;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x1C;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Disguised Chat";
virtual ~ClientboundDisguisedChatPacket() override
{
}
void SetMessage(const Chat& message_)
{
message = message_;
}
void SetChatType(const ChatTypeBoundNetwork& chat_type_)
{
chat_type = chat_type_;
}
const Chat& GetMessage() const
{
return message;
}
const ChatTypeBoundNetwork& GetChatType() const
{
return chat_type;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
message = ReadData<Chat>(iter, length);
chat_type = ReadData<ChatTypeBoundNetwork>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<Chat>(message, container);
WriteData<ChatTypeBoundNetwork>(chat_type, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["message"] = message;
output["chat_type"] = chat_type;
return output;
}
private:
Chat message;
ChatTypeBoundNetwork chat_type;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,101 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundEntityEventPacket : public BaseMessage<ClientboundEntityEventPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x1B;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */
static constexpr int packet_id = 0x1C;
#elif PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x1B;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x1C;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x1B;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x1A;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x1B;
#elif PROTOCOL_VERSION == 759 /* 1.19 */
static constexpr int packet_id = 0x18;
#elif PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x1A;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x19;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x1C;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x1D;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Entity Event";
virtual ~ClientboundEntityEventPacket() override
{
}
void SetEntityId(const int entity_id_)
{
entity_id = entity_id_;
}
void SetEventId(const char event_id_)
{
event_id = event_id_;
}
int GetEntityId() const
{
return entity_id;
}
char GetEventId() const
{
return event_id;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
entity_id = ReadData<int>(iter, length);
event_id = ReadData<char>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<int>(entity_id, container);
WriteData<char>(event_id, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["entity_id"] = entity_id;
output["event_id"] = event_id;
return output;
}
private:
int entity_id = 0;
char event_id = 0;
};
} //ProtocolCraft
@@ -0,0 +1,363 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/NetworkPosition.hpp"
#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
#include "protocolCraft/Types/Particles/Particle.hpp"
#include "protocolCraft/Types/Sound/SoundEvent.hpp"
#include <memory>
#endif
namespace ProtocolCraft
{
class ClientboundExplodePacket : public BaseMessage<ClientboundExplodePacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x1C;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */
static constexpr int packet_id = 0x1E;
#elif PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x1C;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x1D;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x1C;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x1B;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x1C;
#elif PROTOCOL_VERSION == 759 /* 1.19 */
static constexpr int packet_id = 0x19;
#elif PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x1B;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x1A;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x1D;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x1E;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Explode";
virtual ~ClientboundExplodePacket() override
{
}
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
void SetX(const float x_)
{
x = x_;
}
void SetY(const float y_)
{
y = y_;
}
void SetZ(const float z_)
{
z = z_;
}
#else
void SetX(const double x_)
{
x = x_;
}
void SetY(const double y_)
{
y = y_;
}
void SetZ(const double z_)
{
z = z_;
}
#endif
void SetPower(const float power_)
{
power = power_;
}
void SetToBlow(const std::vector<NetworkPosition>& to_blow_)
{
to_blow = to_blow_;
}
void SetKnockbackX(const float knockback_x_)
{
knockback_x = knockback_x_;
}
void SetKnockbackY(const float knockback_y_)
{
knockback_y = knockback_y_;
}
void SetKnockbackZ(const float knockback_z_)
{
knockback_z = knockback_z_;
}
#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
void SetSmallExplosionParticles(const std::shared_ptr<Particle>& small_explosion_particles_)
{
small_explosion_particles = small_explosion_particles_;
}
void SetLargeExplosionParticles(const std::shared_ptr<Particle>& large_explosion_particles_)
{
large_explosion_particles = large_explosion_particles_;
}
void SetBlockInteraction(const int block_interaction_)
{
block_interaction = block_interaction_;
}
void SetExplosionSound(const SoundEvent& explosion_sound_)
{
explosion_sound = explosion_sound_;
}
#endif
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
float GetX() const
{
return x;
}
float GetY() const
{
return y;
}
float GetZ() const
{
return z;
}
#else
double GetX() const
{
return x;
}
double GetY() const
{
return y;
}
double GetZ() const
{
return z;
}
#endif
float GetPower() const
{
return power;
}
const std::vector<NetworkPosition>& GetToBlow() const
{
return to_blow;
}
float GetKnockbackX() const
{
return knockback_x;
}
float GetKnockbackY() const
{
return knockback_y;
}
float GetKnockbackZ() const
{
return knockback_z;
}
#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
const std::shared_ptr<Particle>& GetSmallExplosionParticles() const
{
return small_explosion_particles;
}
const std::shared_ptr<Particle>& GetLargeExplosionParticles() const
{
return large_explosion_particles;
}
int GetBlockInteraction() const
{
return block_interaction;
}
const SoundEvent& GetExplosionSound() const
{
return explosion_sound;
}
#endif
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
x = ReadData<float>(iter, length);
y = ReadData<float>(iter, length);
z = ReadData<float>(iter, length);
#else
x = ReadData<double>(iter, length);
y = ReadData<double>(iter, length);
z = ReadData<double>(iter, length);
#endif
power = ReadData<float>(iter, length);
#if PROTOCOL_VERSION < 755 /* < 1.17 */
to_blow = ReadVector<NetworkPosition, int>(iter, length,
[](ReadIterator& i, size_t& l)
{
NetworkPosition output;
output.SetX(static_cast<int>(ReadData<char>(i, l)));
output.SetY(static_cast<int>(ReadData<char>(i, l)));
output.SetZ(static_cast<int>(ReadData<char>(i, l)));
return output;
}
);
#else
to_blow = ReadVector<NetworkPosition>(iter, length,
[](ReadIterator& i, size_t& l)
{
NetworkPosition output;
output.SetX(static_cast<int>(ReadData<char>(i, l)));
output.SetY(static_cast<int>(ReadData<char>(i, l)));
output.SetZ(static_cast<int>(ReadData<char>(i, l)));
return output;
}
);
#endif
knockback_x = ReadData<float>(iter, length);
knockback_y = ReadData<float>(iter, length);
knockback_z = ReadData<float>(iter, length);
#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
block_interaction = ReadData<VarInt>(iter, length);
const int small_explosion_particles_type = ReadData<VarInt>(iter, length);
small_explosion_particles = Particle::CreateParticle(static_cast<ParticleType>(small_explosion_particles_type));
small_explosion_particles->Read(iter, length);
const int large_explosion_particles_type = ReadData<VarInt>(iter, length);
large_explosion_particles = Particle::CreateParticle(static_cast<ParticleType>(large_explosion_particles_type));
large_explosion_particles->Read(iter, length);
explosion_sound = ReadData<SoundEvent>(iter, length);
#endif
}
virtual void WriteImpl(WriteContainer& container) const override
{
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
WriteData<float>(x, container);
WriteData<float>(y, container);
WriteData<float>(z, container);
#else
WriteData<double>(x, container);
WriteData<double>(y, container);
WriteData<double>(z, container);
#endif
WriteData<float>(power, container);
#if PROTOCOL_VERSION < 755 /* < 1.17 */
WriteVector<NetworkPosition, int>(to_blow, container,
[](const NetworkPosition& n, WriteContainer& c)
{
WriteData<char>(static_cast<char>(n.GetX()), c);
WriteData<char>(static_cast<char>(n.GetY()), c);
WriteData<char>(static_cast<char>(n.GetZ()), c);
}
);
#else
WriteVector<NetworkPosition>(to_blow, container,
[](const NetworkPosition& n, WriteContainer& c)
{
WriteData<char>(static_cast<char>(n.GetX()), c);
WriteData<char>(static_cast<char>(n.GetY()), c);
WriteData<char>(static_cast<char>(n.GetZ()), c);
}
);
#endif
WriteData<float>(knockback_x, container);
WriteData<float>(knockback_y, container);
WriteData<float>(knockback_z, container);
#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
WriteData<VarInt>(block_interaction, container);
WriteData<VarInt>(static_cast<int>(small_explosion_particles->GetType()), container);
small_explosion_particles->Write(container);
WriteData<VarInt>(static_cast<int>(large_explosion_particles->GetType()), container);
large_explosion_particles->Write(container);
WriteData<SoundEvent>(explosion_sound, container);
#endif
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["x"] = x;
output["y"] = y;
output["z"] = z;
output["power"] = power;
output["to_blow"] = to_blow;
output["knockback_x"] = knockback_x;
output["knockback_y"] = knockback_y;
output["knockback_z"] = knockback_z;
#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
output["block_interaction"] = block_interaction;
output["small_explosion_particles"] = small_explosion_particles->Serialize();
output["large_explosion_particles"] = large_explosion_particles->Serialize();
output["explosion_sound"] = explosion_sound;
#endif
return output;
}
private:
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
float x = 0.0f;
float y = 0.0f;
float z = 0.0f;
#else
double x = 0.0;
double y = 0.0;
double z = 0.0;
#endif
float power = 0.0f;
std::vector<NetworkPosition> to_blow;
float knockback_x = 0.0f;
float knockback_y = 0.0f;
float knockback_z = 0.0f;
#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
std::shared_ptr<Particle> small_explosion_particles;
std::shared_ptr<Particle> large_explosion_particles;
int block_interaction;
SoundEvent explosion_sound;
#endif
};
} //ProtocolCraft
@@ -0,0 +1,131 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
#include "protocolCraft/Types/ChunkPos.hpp"
#endif
namespace ProtocolCraft
{
class ClientboundForgetLevelChunkPacket : public BaseMessage<ClientboundForgetLevelChunkPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x1D;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */
static constexpr int packet_id = 0x1F;
#elif PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x1D;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x1E;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x1D;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x1C;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x1D;
#elif PROTOCOL_VERSION == 759 /* 1.19 */
static constexpr int packet_id = 0x1A;
#elif PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x1C;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x1B;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x1E;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x1F;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Forget Level Chunk";
virtual ~ClientboundForgetLevelChunkPacket() override
{
}
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
void SetX(const int x_)
{
x = x_;
}
void SetZ(const int z_)
{
z = z_;
}
#else
void SetPos(const ChunkPos& pos_)
{
pos = pos_;
}
#endif
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
int GetX() const
{
return x;
}
int GetZ() const
{
return z;
}
#else
const ChunkPos& GetPos() const
{
return pos;
}
#endif
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
x = ReadData<int>(iter, length);
z = ReadData<int>(iter, length);
#else
pos = ReadData<ChunkPos>(iter, length);
#endif
}
virtual void WriteImpl(WriteContainer& container) const override
{
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
WriteData<int>(x, container);
WriteData<int>(z, container);
#else
WriteData<ChunkPos>(pos, container);
#endif
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
output["x"] = x;
output["z"] = z;
#else
output["pos"] = pos;
#endif
return output;
}
private:
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
int x = 0;
int z = 0;
#else
ChunkPos pos;
#endif
};
} //ProtocolCraft
@@ -0,0 +1,101 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundGameEventPacket : public BaseMessage<ClientboundGameEventPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x1E;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */
static constexpr int packet_id = 0x20;
#elif PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x1E;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x1F;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x1E;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x1D;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x1E;
#elif PROTOCOL_VERSION == 759 /* 1.19 */
static constexpr int packet_id = 0x1B;
#elif PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x1D;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x1C;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x1F;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x20;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Game Event";
virtual ~ClientboundGameEventPacket() override
{
}
void SetType(const unsigned char type_)
{
type = type_;
}
void SetParam(const float param_)
{
param = param_;
}
unsigned char GetType() const
{
return type;
}
float GetParam() const
{
return param;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
type = ReadData<unsigned char>(iter, length);
param = ReadData<float>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<unsigned char>(type, container);
WriteData<float>(param, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["type"] = type;
output["param"] = param;
return output;
}
private:
unsigned char type = 0;
float param = 0.0f;
};
} //ProtocolCraft
@@ -0,0 +1,112 @@
#pragma once
#if PROTOCOL_VERSION > 451 /* > 1.13.2 */
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundHorseScreenOpenPacket : public BaseMessage<ClientboundHorseScreenOpenPacket>
{
public:
#if PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x1F;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x20;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x1F;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x1E;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x1F;
#elif PROTOCOL_VERSION == 759 /* 1.19 */
static constexpr int packet_id = 0x1C;
#elif PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x1E;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x1D;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x20;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x21;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Horse Screen Open";
virtual ~ClientboundHorseScreenOpenPacket() override
{
}
void SetContainerId(const char container_id_)
{
container_id = container_id_;
}
void SetSize(const int size_)
{
size = size_;
}
void SetEntityId(const int entity_id_)
{
entity_id = entity_id_;
}
char GetContainerId() const
{
return container_id;
}
int GetSize() const
{
return size;
}
int GetEntityId() const
{
return entity_id;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
container_id = ReadData<char>(iter, length);
size = ReadData<VarInt>(iter, length);
entity_id = ReadData<int>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<char>(container_id, container);
WriteData<VarInt>(size, container);
WriteData<int>(entity_id, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["container_id"] = container_id;
output["size"] = size;
output["entity_id"] = entity_id;
return output;
}
private:
char container_id = 0;
int size = 0;
int entity_id = 0;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,77 @@
#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
#pragma once
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundHurtAnimationPacket : public BaseMessage<ClientboundHurtAnimationPacket>
{
public:
#if PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x21;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x22;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Hurt Animation";
virtual ~ClientboundHurtAnimationPacket() override
{
}
void SetId_(const int id__)
{
id_ = id__;
}
void SetYaw(const float yaw_)
{
yaw = yaw_;
}
int GetId_() const
{
return id_;
}
float GetYaw() const
{
return yaw;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
id_ = ReadData<VarInt>(iter, length);
yaw = ReadData<float>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(id_, container);
WriteData<float>(yaw, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["id_"] = id_;
output["yaw"] = yaw;
return output;
}
private:
int id_ = 0;
float yaw = 0.0f;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,170 @@
#pragma once
#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundInitializeBorderPacket : public BaseMessage<ClientboundInitializeBorderPacket>
{
public:
#if PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x20;
#elif PROTOCOL_VERSION == 759 /* 1.19 */
static constexpr int packet_id = 0x1D;
#elif PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x1F;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x1E;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x22;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x23;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Initialize Border";
virtual ~ClientboundInitializeBorderPacket() override
{
}
void SetNewCenterX(const double new_center_x_)
{
new_center_x = new_center_x_;
}
void SetNewCenterZ(const double new_center_z_)
{
new_center_z = new_center_z_;
}
void SetOldSize(const double old_size_)
{
old_size = old_size_;
}
void SetNewSize(const double new_size_)
{
new_size = new_size_;
}
void SetLerpTime(const long long int lerp_time_)
{
lerp_time = lerp_time_;
}
void SetNewAbsoluteMaxSize(const int new_absolute_max_size_)
{
new_absolute_max_size = new_absolute_max_size_;
}
void SetWarningTime(const int warning_time_)
{
warning_time = warning_time_;
}
void SetWarningBlocks(const int warning_blocks_)
{
warning_blocks = warning_blocks_;
}
double GetNewCenterX() const
{
return new_center_x;
}
double GetNewCenterZ() const
{
return new_center_z;
}
double GetOldSize() const
{
return old_size;
}
double GetNewSize() const
{
return new_size;
}
long long int GetLerpTime() const
{
return lerp_time;
}
int GetNewAbsoluteMaxSize() const
{
return new_absolute_max_size;
}
int GetWarningTime() const
{
return warning_time;
}
int GetWarningBlocks() const
{
return warning_blocks;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
new_center_x = ReadData<double>(iter, length);
new_center_z = ReadData<double>(iter, length);
old_size = ReadData<double>(iter, length);
new_size = ReadData<double>(iter, length);
lerp_time = ReadData<VarLong>(iter, length);
new_absolute_max_size = ReadData<VarInt>(iter, length);
warning_blocks = ReadData<VarInt>(iter, length);
warning_time = ReadData<VarInt>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<double>(new_center_x, container);
WriteData<double>(new_center_z, container);
WriteData<double>(old_size, container);
WriteData<double>(new_size, container);
WriteData<VarLong>(lerp_time, container);
WriteData<VarInt>(new_absolute_max_size, container);
WriteData<VarInt>(warning_blocks, container);
WriteData<VarInt>(warning_time, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["new_center_x"] = new_center_x;
output["new_center_z"] = new_center_z;
output["old_size"] = old_size;
output["new_size"] = new_size;
output["lerp_time"] = lerp_time;
output["new_absolute_max_size"] = new_absolute_max_size;
output["warning_blocks"] = warning_blocks;
output["warning_time"] = warning_time;
return output;
}
private:
double new_center_x = 0.0;
double new_center_z = 0.0;
double old_size = 0.0;
double new_size = 0.0;
long long int lerp_time = 0;
int new_absolute_max_size = 0;
int warning_blocks = 0;
int warning_time = 0;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,84 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundKeepAlivePacket : public BaseMessage<ClientboundKeepAlivePacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x1F;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */
static constexpr int packet_id = 0x21;
#elif PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x20;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x21;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x20;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x1F;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x21;
#elif PROTOCOL_VERSION == 759 /* 1.19 */
static constexpr int packet_id = 0x1E;
#elif PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x20;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x1F;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x23;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x24;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Keep Alive";
virtual ~ClientboundKeepAlivePacket() override
{
}
void SetId_(const long long int id__)
{
id_ = id__;
}
long long int GetId_() const
{
return id_;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
id_ = ReadData<long long int>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<long long int>(id_, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["id_"] = id_;
return output;
}
private:
long long int id_ = 0;
};
} //ProtocolCraft
@@ -0,0 +1,314 @@
#pragma once
#if PROTOCOL_VERSION < 757 /* < 1.18 */
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/NBT/NBT.hpp"
namespace ProtocolCraft
{
class ClientboundLevelChunkPacket : public BaseMessage<ClientboundLevelChunkPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x20;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */
static constexpr int packet_id = 0x22;
#elif PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x21;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x22;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x21;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x20;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */
static constexpr int packet_id = 0x22;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Level Chunk";
virtual ~ClientboundLevelChunkPacket() override
{
}
void SetX(const int x_)
{
x = x_;
}
void SetZ(const int z_)
{
z = z_;
}
#if PROTOCOL_VERSION > 730 /* > 1.15.2 */ && PROTOCOL_VERSION < 745 /* < 1.16.2 */
void SetIgnoreOldData(const bool ignore_old_data_)
{
ignore_old_data = ignore_old_data_;
}
#endif
#if PROTOCOL_VERSION < 755 /* < 1.17 */
void SetAvailableSections(const int available_sections_)
#else
void SetAvailableSections(const std::vector<unsigned long long int>& available_sections_)
#endif
{
available_sections = available_sections_;
}
#if PROTOCOL_VERSION > 442 /* > 1.13.2 */
void SetHeightmaps(const NBT::Value& heightmaps_)
{
heightmaps = heightmaps_;
}
#endif
#if PROTOCOL_VERSION > 551 /* > 1.14.4 */
void SetBiomes(const std::vector<int>& biomes_)
{
biomes = biomes_;
}
#endif
void SetBuffer(const std::vector<unsigned char>& buffer_)
{
buffer = buffer_;
}
void SetBlockEntitiesTags(const std::vector<NBT::Value>& block_entities_tags_)
{
block_entities_tags = block_entities_tags_;
}
#if PROTOCOL_VERSION < 755 /* < 1.17 */
void SetFullChunk(const bool full_chunk_)
{
full_chunk = full_chunk_;
}
#endif
int GetX() const
{
return x;
}
int GetZ() const
{
return z;
}
#if PROTOCOL_VERSION > 730 /* > 1.15.2 */ && PROTOCOL_VERSION < 745 /* < 1.16.2 */
bool GetIgnoreOldData() const
{
return ignore_old_data;
}
#endif
#if PROTOCOL_VERSION < 755 /* < 1.17 */
int GetAvailableSections() const
#else
const std::vector<unsigned long long int>& GetAvailableSections() const
#endif
{
return available_sections;
}
#if PROTOCOL_VERSION > 442 /* > 1.13.2 */
const NBT::Value& GetHeightmaps() const
{
return heightmaps;
}
#endif
#if PROTOCOL_VERSION > 551 /* > 1.14.4 */
const std::vector<int>& GetBiomes() const
{
return biomes;
}
#endif
const std::vector<unsigned char>& GetBuffer() const
{
return buffer;
}
const std::vector<NBT::Value>& GetBlockEntitiesTags() const
{
return block_entities_tags;
}
#if PROTOCOL_VERSION < 755 /* < 1.17 */
bool GetFullChunk() const
{
return full_chunk;
}
#endif
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
x = ReadData<int>(iter, length);
z = ReadData<int>(iter, length);
#if PROTOCOL_VERSION < 755 /* < 1.17 */
full_chunk = ReadData<bool>(iter, length);
#endif
#if PROTOCOL_VERSION > 730 /* > 1.15.2 */ && PROTOCOL_VERSION < 745 /* < 1.16.2 */
ignore_old_data = ReadData<bool>(iter, length);
#endif
#if PROTOCOL_VERSION < 755 /* < 1.17 */
available_sections = ReadData<VarInt>(iter, length);
#else
available_sections = ReadVector<unsigned long long int>(iter, length);
#endif
#if PROTOCOL_VERSION > 442 /* > 1.13.2 */
heightmaps = ReadData<NBT::UnnamedValue>(iter, length);
#endif
#if PROTOCOL_VERSION > 551 /* > 1.14.4 */
#if PROTOCOL_VERSION < 755 /* < 1.17 */
if (full_chunk)
{
#endif
#if PROTOCOL_VERSION > 738 /* > 1.16.1 */
biomes = ReadVector<int>(iter, length,
[](ReadIterator& i, size_t& l)
{
return ReadData<VarInt>(i, l);
}
);
#else
biomes = std::vector<int>(1024);
for (size_t i = 0; i < biomes.size(); ++i)
{
biomes[i] = ReadData<int>(iter, length);
}
#endif
#if PROTOCOL_VERSION < 755 /* < 1.17 */
}
#endif
#endif
buffer = ReadVector<unsigned char>(iter, length);
block_entities_tags = ReadVector<NBT::Value>(iter, length,
[](ReadIterator& i, size_t& l)
{
return ReadData<NBT::UnnamedValue>(i, l);
}
);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<int>(x, container);
WriteData<int>(z, container);
#if PROTOCOL_VERSION < 755 /* < 1.17 */
WriteData<bool>(full_chunk, container);
#endif
#if PROTOCOL_VERSION > 730 /* > 1.15.2 */ && PROTOCOL_VERSION < 745 /* < 1.16.2 */
WriteData<bool>(ignore_old_data, container);
#endif
#if PROTOCOL_VERSION < 755 /* < 1.17 */
WriteData<VarInt>(available_sections, container);
#else
WriteVector<unsigned long long int>(available_sections, container);
#endif
#if PROTOCOL_VERSION > 442 /* > 1.13.2 */
WriteData<NBT::UnnamedValue>(heightmaps, container);
#endif
#if PROTOCOL_VERSION > 551 /* > 1.14.4 */
#if PROTOCOL_VERSION < 755 /* < 1.17 */
if (full_chunk)
{
#endif
#if PROTOCOL_VERSION > 738 /* > 1.16.1 */
WriteVector<int>(biomes, container,
[](const int& i, WriteContainer& c)
{
WriteData<VarInt>(i, c);
}
);
#else
for (const auto i : biomes)
{
WriteData<int>(i, container);
}
#endif
#if PROTOCOL_VERSION < 755 /* < 1.17 */
}
#endif
#endif
WriteVector<unsigned char>(buffer, container);
WriteVector<NBT::Value>(block_entities_tags, container,
[](const NBT::UnnamedValue& i, WriteContainer& c)
{
WriteData<NBT::UnnamedValue>(i, c);
}
);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["x"] = x;
output["z"] = z;
#if PROTOCOL_VERSION > 730 /* > 1.15.2 */ && PROTOCOL_VERSION < 745 /* < 1.16.2 */
output["ignore_old_data"] = ignore_old_data;
#endif
#if PROTOCOL_VERSION < 755 /* < 1.17 */
output["available_sections"] = available_sections;
#else
output["available_sections"] = available_sections;
#endif
#if PROTOCOL_VERSION > 442 /* > 1.13.2 */
output["heightmaps"] = heightmaps;
#endif
#if PROTOCOL_VERSION > 551 /* > 1.14.4 */
output["biomes"] = "Vector of " + std::to_string(biomes.size()) + " int";
#endif
output["buffer"] = "Vector of " + std::to_string(buffer.size()) + " unsigned char";
output["block_entities_tags"] = block_entities_tags;
#if PROTOCOL_VERSION < 755 /* < 1.17 */
output["full_chunk"] = full_chunk;
#endif
return output;
}
private:
int x = 0;
int z = 0;
#if PROTOCOL_VERSION > 730 /* > 1.15.2 */ && PROTOCOL_VERSION < 745 /* < 1.16.2 */
bool ignore_old_data = false;
#endif
#if PROTOCOL_VERSION < 755 /* < 1.17 */
int available_sections = 0;
#else
std::vector<unsigned long long int> available_sections;
#endif
#if PROTOCOL_VERSION > 442 /* > 1.13.2 */
NBT::Value heightmaps;
#endif
#if PROTOCOL_VERSION > 551 /* > 1.14.4 */
std::vector<int> biomes;
#endif
std::vector<unsigned char> buffer;
std::vector<NBT::Value> block_entities_tags;
#if PROTOCOL_VERSION < 755 /* < 1.17 */
bool full_chunk = false;
#endif
};
} //ProtocolCraft
#endif
@@ -0,0 +1,117 @@
#pragma once
#if PROTOCOL_VERSION > 756 /* > 1.17.1 */
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/ClientboundLevelChunkPacketData.hpp"
#include "protocolCraft/Types/ClientboundLightUpdatePacketData.hpp"
namespace ProtocolCraft
{
class ClientboundLevelChunkWithLightPacket : public BaseMessage<ClientboundLevelChunkWithLightPacket>
{
public:
#if PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x22;
#elif PROTOCOL_VERSION == 759 /* 1.19 */
static constexpr int packet_id = 0x1F;
#elif PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x21;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x20;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x24;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x25;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Level Chunk With Light";
virtual ~ClientboundLevelChunkWithLightPacket() override
{
}
void SetX(const int x_)
{
x = x_;
}
void SetZ(const int z_)
{
z = z_;
}
void SetChunkData(const ClientboundLevelChunkPacketData& chunk_data_)
{
chunk_data = chunk_data_;
}
void SetLightData(const ClientboundLightUpdatePacketData& light_data_)
{
light_data = light_data_;
}
int GetX() const
{
return x;
}
int GetZ() const
{
return z;
}
const ClientboundLevelChunkPacketData& GetChunkData() const
{
return chunk_data;
}
const ClientboundLightUpdatePacketData& GetLightData() const
{
return light_data;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
x = ReadData<int>(iter, length);
z = ReadData<int>(iter, length);
chunk_data = ReadData<ClientboundLevelChunkPacketData>(iter, length);
light_data = ReadData<ClientboundLightUpdatePacketData>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<int>(x, container);
WriteData<int>(z, container);
WriteData<ClientboundLevelChunkPacketData>(chunk_data, container);
WriteData<ClientboundLightUpdatePacketData>(light_data, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["x"] = x;
output["z"] = z;
output["chunk_data"] = chunk_data;
output["light_data"] = light_data;
return output;
}
private:
int x = 0;
int z = 0;
ClientboundLevelChunkPacketData chunk_data;
ClientboundLightUpdatePacketData light_data;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,130 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/NetworkPosition.hpp"
namespace ProtocolCraft
{
class ClientboundLevelEventPacket : public BaseMessage<ClientboundLevelEventPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x21;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */
static constexpr int packet_id = 0x23;
#elif PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x22;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x23;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x22;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x21;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x23;
#elif PROTOCOL_VERSION == 759 /* 1.19 */
static constexpr int packet_id = 0x20;
#elif PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x22;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x21;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x25;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x26;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Level Event";
virtual ~ClientboundLevelEventPacket() override
{
}
void SetType(const int type_)
{
type = type_;
}
void SetPos(const NetworkPosition& pos_)
{
pos = pos_;
}
void SetData(const int data_)
{
data = data_;
}
void SetGlobalEvent(const bool global_event_)
{
global_event = global_event_;
}
int GetType() const
{
return type;
}
const NetworkPosition& GetPos() const
{
return pos;
}
int GetData() const
{
return data;
}
bool GetGlobalEvent() const
{
return global_event;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
type = ReadData<int>(iter, length);
pos = ReadData<NetworkPosition>(iter, length);
data = ReadData<int>(iter, length);
global_event = ReadData<bool>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<int>(type, container);
WriteData<NetworkPosition>(pos, container);
WriteData<int>(data, container);
WriteData<bool>(global_event, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["type"] = type;
output["pos"] = pos;
output["data"] = data;
output["global_event"] = global_event;
return output;
}
private:
int type = 0;
NetworkPosition pos;
int data = 0;
bool global_event = false;
};
} //ProtocolCraft
@@ -0,0 +1,280 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/Particles/Particle.hpp"
namespace ProtocolCraft
{
class ClientboundLevelParticlesPacket : public BaseMessage<ClientboundLevelParticlesPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x22;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */
static constexpr int packet_id = 0x24;
#elif PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x23;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x24;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x23;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x22;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x24;
#elif PROTOCOL_VERSION == 759 /* 1.19 */
static constexpr int packet_id = 0x21;
#elif PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x23;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x22;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x26;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x27;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Level Particles";
virtual ~ClientboundLevelParticlesPacket() override
{
}
#if PROTOCOL_VERSION < 569 /* < 1.15 */
void SetX(const float x_)
{
x = x_;
}
void SetY(const float y_)
{
y = y_;
}
void SetZ(const float z_)
{
z = z_;
}
#else
void SetX(const double x_)
{
x = x_;
}
void SetY(const double y_)
{
y = y_;
}
void SetZ(const double z_)
{
z = z_;
}
#endif
void SetXDist(const float x_dist_)
{
x_dist = x_dist_;
}
void SetYDist(const float y_dist_)
{
y_dist = y_dist_;
}
void SetZDist(const float z_dist_)
{
z_dist = z_dist_;
}
void SetMaxSpeed(const float max_speed_)
{
max_speed = max_speed_;
}
void SetCount(const int count_)
{
count = count_;
}
void SetOverrideLimiter(const bool override_limiter_)
{
override_limiter = override_limiter_;
}
void SetParticle(const std::shared_ptr<Particle>& particle_)
{
particle = particle_;
}
#if PROTOCOL_VERSION < 569 /* < 1.15 */
float GetX() const
{
return x;
}
float GetY() const
{
return y;
}
float GetZ() const
{
return z;
}
#else
double GetX() const
{
return x;
}
double GetY() const
{
return y;
}
double GetZ() const
{
return z;
}
#endif
float GetXDist() const
{
return x_dist;
}
float GetYDist() const
{
return y_dist;
}
float GetZDist() const
{
return z_dist;
}
float GetMaxSpeed() const
{
return max_speed;
}
int GetCount() const
{
return count;
}
bool GetOverrideLimiter() const
{
return override_limiter;
}
std::shared_ptr<Particle> GetParticle() const
{
return particle;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
#if PROTOCOL_VERSION < 759 /* < 1.19 */
const ParticleType particle_type = static_cast<ParticleType>(ReadData<int>(iter, length));
#else
const ParticleType particle_type = static_cast<ParticleType>(static_cast<int>(ReadData<VarInt>(iter, length)));
#endif
override_limiter = ReadData<bool>(iter, length);
#if PROTOCOL_VERSION < 569 /* < 1.15 */
x = ReadData<float>(iter, length);
y = ReadData<float>(iter, length);
z = ReadData<float>(iter, length);
#else
x = ReadData<double>(iter, length);
y = ReadData<double>(iter, length);
z = ReadData<double>(iter, length);
#endif
x_dist = ReadData<float>(iter, length);
y_dist = ReadData<float>(iter, length);
z_dist = ReadData<float>(iter, length);
max_speed = ReadData<float>(iter, length);
count = ReadData<int>(iter, length);
particle = Particle::CreateParticle(particle_type);
particle->Read(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
#if PROTOCOL_VERSION < 759 /* < 1.19 */
WriteData<int>(static_cast<int>(particle->GetType()), container);
#else
WriteData<VarInt>(static_cast<int>(particle->GetType()), container);
#endif
WriteData<bool>(override_limiter, container);
#if PROTOCOL_VERSION < 569 /* < 1.15 */
WriteData<float>(x, container);
WriteData<float>(y, container);
WriteData<float>(z, container);
#else
WriteData<double>(x, container);
WriteData<double>(y, container);
WriteData<double>(z, container);
#endif
WriteData<float>(x_dist, container);
WriteData<float>(y_dist, container);
WriteData<float>(z_dist, container);
WriteData<float>(max_speed, container);
WriteData<int>(count, container);
particle->Write(container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["override_limiter"] = override_limiter;
output["x"] = x;
output["y"] = y;
output["z"] = z;
output["x_dist"] = x_dist;
output["y_dist"] = y_dist;
output["z_dist"] = z_dist;
output["max_speed"] = max_speed;
output["count"] = count;
output["particle_type"] = particle->GetName();
output["particle"] = particle->Serialize();
return output;
}
private:
#if PROTOCOL_VERSION < 569 /* < 1.15 */
float x = 0.0f;
float y = 0.0f;
float z = 0.0f;
#else
double x = 0.0;
double y = 0.0;
double z = 0.0;
#endif
float x_dist = 0.0f;
float y_dist = 0.0f;
float z_dist = 0.0f;
float max_speed = 0.0f;
int count = 0;
bool override_limiter = false;
std::shared_ptr<Particle> particle;
};
} //ProtocolCraft
@@ -0,0 +1,363 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#if PROTOCOL_VERSION > 756 /* > 1.17.1 */
#include "protocolCraft/Types/ClientboundLightUpdatePacketData.hpp"
#endif
#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
namespace ProtocolCraft
{
class ClientboundLightUpdatePacket : public BaseMessage<ClientboundLightUpdatePacket>
{
public:
#if PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x24;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x25;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x24;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x23;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x25;
#elif PROTOCOL_VERSION == 759 /* 1.19 */
static constexpr int packet_id = 0x22;
#elif PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x24;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x23;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x27;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x28;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Light Update";
virtual ~ClientboundLightUpdatePacket() override
{
}
void SetX(const int x_)
{
x = x_;
}
void SetZ(const int z_)
{
z = z_;
}
#if PROTOCOL_VERSION < 757 /* < 1.18 */
#if PROTOCOL_VERSION < 755 /* < 1.17 */
void SetSkyYMask(const int sky_Y_mask_)
{
sky_Y_mask = sky_Y_mask_;
}
void SetBlockYMask(const int block_Y_mask_)
{
block_Y_mask = block_Y_mask_;
}
void SetEmptySkyYMask(const int empty_sky_Y_mask_)
{
empty_sky_Y_mask = empty_sky_Y_mask_;
}
void SetEmptyBlockYMask(const int empty_block_Y_mask_)
{
empty_block_Y_mask = empty_block_Y_mask_;
}
#else
void SetSkyYMask(const std::vector<unsigned long long int>& sky_Y_mask_)
{
sky_Y_mask = sky_Y_mask_;
}
void SetBlockYMask(const std::vector<unsigned long long int>& block_Y_mask_)
{
block_Y_mask = block_Y_mask_;
}
void SetEmptySkyYMask(const std::vector<unsigned long long int>& empty_sky_Y_mask_)
{
empty_sky_Y_mask = empty_sky_Y_mask_;
}
void SetEmptyBlockYMask(const std::vector<unsigned long long int>& empty_block_Y_mask_)
{
empty_block_Y_mask = empty_block_Y_mask_;
}
#endif
void SetSkyUpdates(std::vector<std::vector<char> >& sky_updates_)
{
sky_updates = sky_updates_;
}
void SetBlockUpdates(std::vector<std::vector<char> >& block_updates_)
{
block_updates = block_updates_;
}
#if PROTOCOL_VERSION > 722 /* > 1.15.2 */
void SetTrustEdges(const bool trust_edges_)
{
trust_edges = trust_edges_;
}
#endif
#else
void SetLightData(const ClientboundLightUpdatePacketData& light_data_)
{
light_data = light_data_;
}
#endif
int GetX() const
{
return x;
}
int GetZ() const
{
return z;
}
#if PROTOCOL_VERSION < 757 /* < 1.18 */
#if PROTOCOL_VERSION < 755 /* < 1.17 */
int GetSkyYMask() const
{
return sky_Y_mask;
}
int GetBlockYMask() const
{
return block_Y_mask;
}
int GetEmptySkyYMask() const
{
return empty_sky_Y_mask;
}
int GetEmptyBlockYMask() const
{
return empty_block_Y_mask;
}
#else
const std::vector<unsigned long long int>& GetSkyYMask() const
{
return sky_Y_mask;
}
const std::vector<unsigned long long int>& GetBlockYMask() const
{
return block_Y_mask;
}
const std::vector<unsigned long long int>& GetEmptySkyYMask() const
{
return empty_sky_Y_mask;
}
const std::vector<unsigned long long int>& GetEmptyBlockYMask() const
{
return empty_block_Y_mask;
}
#endif
const std::vector<std::vector<char> >& GetSkyUpdates() const
{
return sky_updates;
}
const std::vector<std::vector<char> >& GetBlockUpdates() const
{
return block_updates;
}
#if PROTOCOL_VERSION > 722 /* > 1.15.2 */
bool GetTrustEdges() const
{
return trust_edges;
}
#endif
#else
const ClientboundLightUpdatePacketData& GetLightData() const
{
return light_data;
}
#endif
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
x = ReadData<VarInt>(iter, length);
z = ReadData<VarInt>(iter, length);
#if PROTOCOL_VERSION < 757 /* < 1.18 */
#if PROTOCOL_VERSION > 722 /* > 1.15.2 */
trust_edges = ReadData<bool>(iter, length);
#endif
#if PROTOCOL_VERSION < 755 /* < 1.17 */
sky_Y_mask = ReadData<VarInt>(iter, length);
block_Y_mask = ReadData<VarInt>(iter, length);
empty_sky_Y_mask = ReadData<VarInt>(iter, length);
empty_block_Y_mask = ReadData<VarInt>(iter, length);
#else
sky_Y_mask = ReadVector<unsigned long long int>(iter, length);
block_Y_mask = ReadVector<unsigned long long int>(iter, length);
empty_sky_Y_mask = ReadVector<unsigned long long int>(iter, length);
empty_block_Y_mask = ReadVector<unsigned long long int>(iter, length);
#endif
#if PROTOCOL_VERSION < 755 /* < 1.17 */
sky_updates.clear();
for (int i = 0; i < 18; ++i)
{
if ((sky_Y_mask >> i) & 1)
{
sky_updates.push_back(ReadVector<char>(iter, length)); // Should always contain 2048 chars
}
}
block_updates.clear();
for (int i = 0; i < 18; ++i)
{
if ((block_Y_mask >> i) & 1)
{
block_updates.push_back(ReadVector<char>(iter, length)); // Should always contain 2048 chars
}
}
#else
sky_updates = ReadVector<std::vector<char>>(iter, length,
[](ReadIterator& i, size_t& l)
{
return ReadVector<char>(i, l); // Should always contain 2048 chars
}
);
block_updates = ReadVector<std::vector<char>>(iter, length,
[](ReadIterator& i, size_t& l)
{
return ReadVector<char>(i, l); // Should always contain 2048 chars
}
);
#endif
#else
light_data = ReadData<ClientboundLightUpdatePacketData>(iter, length);
#endif
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(x, container);
WriteData<VarInt>(z, container);
#if PROTOCOL_VERSION < 757 /* < 1.18 */
#if PROTOCOL_VERSION > 722 /* > 1.15.2 */
WriteData<bool>(trust_edges, container);
#endif
#if PROTOCOL_VERSION < 755 /* < 1.17 */
WriteData<VarInt>(sky_Y_mask, container);
WriteData<VarInt>(block_Y_mask, container);
WriteData<VarInt>(empty_sky_Y_mask, container);
WriteData<VarInt>(empty_block_Y_mask, container);
#else
WriteVector<unsigned long long int>(sky_Y_mask, container);
WriteVector<unsigned long long int>(block_Y_mask, container);
WriteVector<unsigned long long int>(empty_sky_Y_mask, container);
WriteVector<unsigned long long int>(empty_block_Y_mask, container);
#endif
#if PROTOCOL_VERSION < 755 /* < 1.17 */
for (const auto& v : sky_updates)
{
WriteVector<char>(v, container);
}
#else
WriteVector<std::vector<char>>(sky_updates, container,
[](const std::vector<char>& v, WriteContainer& c)
{
WriteVector<char>(v, c);
}
);
#endif
#if PROTOCOL_VERSION < 755 /* < 1.17 */
for (const auto& v : block_updates)
{
WriteVector<char>(v, container);
}
#else
WriteVector<std::vector<char>>(block_updates, container,
[](const std::vector<char>& v, WriteContainer& c)
{
WriteVector<char>(v, c);
}
);
#endif
#else
WriteData<ClientboundLightUpdatePacketData>(light_data, container);
#endif
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["x"] = x;
output["z"] = z;
#if PROTOCOL_VERSION < 757 /* < 1.18 */
#if PROTOCOL_VERSION > 722 /* > 1.15.2 */
output["trust_edges"] = trust_edges;
#endif
output["sky_Y_mask"] = sky_Y_mask;
output["block_Y_mask"] = block_Y_mask;
output["empty_sky_Y_mask"] = empty_sky_Y_mask;
output["empty_block_Y_mask"] = empty_block_Y_mask;
output["sky_updates"] = sky_updates;
output["block_updates"] = block_updates;
#else
output["light_data"] = light_data;
#endif
return output;
}
private:
int x = 0;
int z = 0;
#if PROTOCOL_VERSION < 757 /* < 1.18 */
#if PROTOCOL_VERSION < 755 /* < 1.17 */
int sky_Y_mask = 0;
int block_Y_mask = 0;
int empty_sky_Y_mask = 0;
int empty_block_Y_mask = 0;
#else
std::vector<unsigned long long int> sky_Y_mask;
std::vector<unsigned long long int> block_Y_mask;
std::vector<unsigned long long int> empty_sky_Y_mask;
std::vector<unsigned long long int> empty_block_Y_mask;
#endif
std::vector<std::vector<char> > sky_updates;
std::vector<std::vector<char> > block_updates;
#if PROTOCOL_VERSION > 722 /* > 1.15.2 */
bool trust_edges = false;
#endif
#else
ClientboundLightUpdatePacketData light_data;
#endif
};
} //ProtocolCraft
#endif
@@ -0,0 +1,645 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/Identifier.hpp"
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
#include "protocolCraft/Types/GlobalPos.hpp"
#endif
#include "protocolCraft/Types/NBT/NBT.hpp"
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
#include "protocolCraft/Types/CommonPlayerSpawnInfo.hpp"
#endif
namespace ProtocolCraft
{
class ClientboundLoginPacket : public BaseMessage<ClientboundLoginPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x23;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */ || PROTOCOL_VERSION == 477 /* 1.14 */ || \
PROTOCOL_VERSION == 480 /* 1.14.1 */ || PROTOCOL_VERSION == 485 /* 1.14.2 */ || \
PROTOCOL_VERSION == 490 /* 1.14.3 */ || PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x25;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x26;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x25;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x24;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x26;
#elif PROTOCOL_VERSION == 759 /* 1.19 */
static constexpr int packet_id = 0x23;
#elif PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x25;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x24;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x28;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x29;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Login";
virtual ~ClientboundLoginPacket() override
{
}
void SetPlayerId(const int player_id_)
{
player_id = player_id_;
}
#if PROTOCOL_VERSION > 551 /* > 1.14.4 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
void SetSeed(const long long int seed_)
{
seed = seed_;
}
#endif
#if PROTOCOL_VERSION > 737 /* > 1.16.1 */
void SetHardcore(const bool hardcore_)
{
hardcore = hardcore_;
}
#endif
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
void SetGameType(const unsigned char game_type_)
{
game_type = game_type_;
}
#endif
#if PROTOCOL_VERSION > 718 /* > 1.15.2 */
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
void SetPreviousGameType(const unsigned char previous_game_type_)
{
previous_game_type = previous_game_type_;
}
#endif
void SetLevels(const std::vector<Identifier>& levels_)
{
levels = levels_;
}
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
void SetRegistryHolder(const NBT::Value& registry_holder_)
{
registry_holder = registry_holder_;
}
#endif
#if PROTOCOL_VERSION > 747 /* > 1.16.1 */ && PROTOCOL_VERSION < 759 /* < 1.19 */
void SetDimensionType(const NBT::Value& dimension_type_)
{
dimension_type = dimension_type_;
}
#elif PROTOCOL_VERSION > 758 /* > 1.18.2 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
void SetDimensionType(const Identifier& dimension_type_)
{
dimension_type = dimension_type_;
}
#endif
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
void SetDimension(const Identifier& dimension_)
{
dimension = dimension_;
}
#endif
#else
void SetDimension(const int dimension_)
{
dimension = dimension_;
}
#endif
#if PROTOCOL_VERSION < 477 /* < 1.14 */
void SetDifficulty(const unsigned char difficulty_)
{
difficulty = difficulty_;
}
#endif
#if PROTOCOL_VERSION < 749 /* < 1.16.2 */
void SetMaxPlayers(const unsigned char max_players_)
{
max_players = max_players_;
}
#else
void SetMaxPlayers(const int max_players_)
{
max_players = max_players_;
}
#endif
#if PROTOCOL_VERSION < 719 /* < 1.16 */
void SetLevelType(const std::string& level_type_)
{
level_type = level_type_;
}
#endif
#if PROTOCOL_VERSION >= 477 /* >= 1.14 */
void SetChunkRadius(const int chunk_radius_)
{
chunk_radius = chunk_radius_;
}
#endif
#if PROTOCOL_VERSION > 756 /* > 1.17.1 */
void SetSimulationDistance(const int simulation_distance_)
{
simulation_distance = simulation_distance_;
}
#endif
void SetReducedDebugInfo(const bool reduced_debug_info_)
{
reduced_debug_info = reduced_debug_info_;
}
#if PROTOCOL_VERSION > 565 /* > 1.14.4 */
void SetShowDeathScreen(const bool show_death_screen_)
{
show_death_screen = show_death_screen_;
}
#endif
#if PROTOCOL_VERSION > 718 /* > 1.15.2 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
void SetIsDebug(const bool is_debug_)
{
is_debug = is_debug_;
}
void SetIsFlat(const bool is_flat_)
{
is_flat = is_flat_;
}
#endif
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
void SetLastDeathLocation(const std::optional<GlobalPos>& last_death_location_)
{
last_death_location = last_death_location_;
}
#endif
#if PROTOCOL_VERSION > 762 /* > 1.19.4 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
void SetPortalCooldown(const int portal_cooldown_)
{
portal_cooldown = portal_cooldown_;
}
#endif
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
void SetDoLimitedCrafting(const bool do_limited_crafting_)
{
do_limited_crafting = do_limited_crafting_;
}
void SetCommonPlayerSpawnInfo(const CommonPlayerSpawnInfo& common_player_spawn_info_)
{
common_player_spawn_info = common_player_spawn_info_;
}
#endif
int GetPlayerId() const
{
return player_id;
}
#if PROTOCOL_VERSION > 551 /* > 1.14.4 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
long long int GetSeed() const
{
return seed;
}
#endif
#if PROTOCOL_VERSION > 737 /* > 1.16.1 */
bool GetHardcore() const
{
return hardcore;
}
#endif
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
unsigned char GetGameType() const
{
return game_type;
}
#endif
#if PROTOCOL_VERSION > 718 /* > 1.15.2 */
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
unsigned char GetPreviousGameType() const
{
return previous_game_type;
}
#endif
const std::vector<Identifier>& GetLevels() const
{
return levels;
}
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
const NBT::Value& GetRegistryHolder() const
{
return registry_holder;
}
#endif
#if PROTOCOL_VERSION > 747 /* > 1.16.1 */ && PROTOCOL_VERSION < 759 /* < 1.19 */
const NBT::Value& GetDimensionType() const
{
return dimension_type;
}
#elif PROTOCOL_VERSION > 758 /* > 1.18.2 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
const Identifier& GetDimensionType() const
{
return dimension_type;
}
#endif
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
const Identifier& GetDimension() const
{
return dimension;
}
#endif
#else
int GetDimension() const
{
return dimension;
}
#endif
#if PROTOCOL_VERSION < 477 /* < 1.14 */
unsigned char GetDifficulty() const
{
return difficulty;
}
#endif
#if PROTOCOL_VERSION < 749 /* < 1.16.2 */
unsigned char GetMaxPlayers() const
{
return max_players;
}
#else
int GetMaxPlayers() const
{
return max_players;
}
#endif
#if PROTOCOL_VERSION < 719 /* < 1.16 */
const std::string& GetLevelType() const
{
return level_type;
}
#endif
#if PROTOCOL_VERSION >= 477 /* >= 1.14 */
int GetChunkRadius() const
{
return chunk_radius;
}
#endif
#if PROTOCOL_VERSION > 756 /* > 1.17.1 */
int GetSimulationDistance() const
{
return simulation_distance;
}
#endif
bool GetReducedDebugInfo() const
{
return reduced_debug_info;
}
#if PROTOCOL_VERSION > 565 /* > 1.14.4 */
bool GetShowDeathScreen() const
{
return show_death_screen;
}
#endif
#if PROTOCOL_VERSION > 718 /* > 1.15.2 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
bool GetIsDebug() const
{
return is_debug;
}
bool GetIsFlat() const
{
return is_flat;
}
#endif
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
const std::optional<GlobalPos>& GetLastDeathLocation() const
{
return last_death_location;
}
#endif
#if PROTOCOL_VERSION > 762 /* > 1.19.4 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
int GetPortalCooldown() const
{
return portal_cooldown;
}
#endif
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
bool GetDoLimitedCrafting() const
{
return do_limited_crafting;
}
const CommonPlayerSpawnInfo& GetCommonPlayerSpawnInfo() const
{
return common_player_spawn_info;
}
#endif
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
player_id = ReadData<int>(iter, length);
#if PROTOCOL_VERSION > 737 /* > 1.16.1 */
hardcore = ReadData<bool>(iter, length);
#endif
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
game_type = ReadData<unsigned char>(iter, length);
#endif
#if PROTOCOL_VERSION > 718 /* > 1.15.2 */
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
previous_game_type = ReadData<unsigned char>(iter, length);
#endif
levels = ReadVector<Identifier>(iter, length);
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
registry_holder = ReadData<NBT::UnnamedValue>(iter, length);
#endif
#if PROTOCOL_VERSION > 747 /* > 1.16.1 */ && PROTOCOL_VERSION < 759 /* < 1.19 */
dimension_type = ReadData<NBT::UnnamedValue>(iter, length);
#elif PROTOCOL_VERSION > 758 /* > 1.18.2 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
dimension_type = ReadData<Identifier>(iter, length);
#endif
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
dimension = ReadData<Identifier>(iter, length);
#endif
#else
dimension = ReadData<int>(iter, length);
#endif
#if PROTOCOL_VERSION > 551 /* > 1.14.4 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
seed = ReadData<long long int>(iter, length);
#endif
#if PROTOCOL_VERSION < 477 /* < 1.14 */
difficulty = ReadData<unsigned char>(iter, length);
#endif
#if PROTOCOL_VERSION < 749 /* < 1.16.2 */
max_players = ReadData<unsigned char>(iter, length);
#else
max_players = ReadData<VarInt>(iter, length);
#endif
#if PROTOCOL_VERSION < 719 /* < 1.16 */
level_type = ReadData<std::string>(iter, length);
#endif
#if PROTOCOL_VERSION >= 477 /* >= 1.14 */
chunk_radius = ReadData<VarInt>(iter, length);
#if PROTOCOL_VERSION > 756 /* > 1.17.1 */
simulation_distance = ReadData<VarInt>(iter, length);
#endif
#endif
reduced_debug_info = ReadData<bool>(iter, length);
#if PROTOCOL_VERSION > 565 /* > 1.14.4 */
show_death_screen = ReadData<bool>(iter, length);
#endif
#if PROTOCOL_VERSION > 718 /* > 1.15.2 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
is_debug = ReadData<bool>(iter, length);
is_flat = ReadData<bool>(iter, length);
#endif
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
last_death_location = ReadOptional<GlobalPos>(iter, length);
#endif
#if PROTOCOL_VERSION > 762 /* > 1.19.4 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
portal_cooldown = ReadData<VarInt>(iter, length);
#endif
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
do_limited_crafting = ReadData<bool>(iter, length);
common_player_spawn_info = ReadData<CommonPlayerSpawnInfo>(iter, length);
#endif
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<int>(player_id, container);
#if PROTOCOL_VERSION > 737 /* > 1.16.1 */
WriteData<bool>(hardcore, container);
#endif
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
WriteData<unsigned char>(game_type, container);
#endif
#if PROTOCOL_VERSION > 718 /* > 1.15.2 */
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
WriteData<unsigned char>(previous_game_type, container);
#endif
WriteVector<Identifier>(levels, container);
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
WriteData<NBT::UnnamedValue>(registry_holder, container);
#endif
#if PROTOCOL_VERSION > 747 /* > 1.16.1 */ && PROTOCOL_VERSION < 759 /* < 1.19 */
WriteData<NBT::UnnamedValue>(dimension_type, container);
#elif PROTOCOL_VERSION > 758 /* > 1.18.2 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
WriteData<Identifier>(dimension_type, container);
#endif
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
WriteData<Identifier>(dimension, container);
#endif
#else
WriteData<int>(dimension, container);
#endif
#if PROTOCOL_VERSION > 551 /* > 1.14.4 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
WriteData<long long int>(seed, container);
#endif
#if PROTOCOL_VERSION < 477 /* < 1.14 */
WriteData<unsigned char>(difficulty, container);
#endif
#if PROTOCOL_VERSION < 749 /* < 1.16.2 */
WriteData<unsigned char>(max_players, container);
#else
WriteData<VarInt>(max_players, container);
#endif
#if PROTOCOL_VERSION < 719 /* < 1.16 */
WriteData<std::string>(level_type, container);
#endif
#if PROTOCOL_VERSION >= 477 /* >= 1.14 */
WriteData<VarInt>(chunk_radius, container);
#endif
#if PROTOCOL_VERSION > 756 /* > 1.17.1 */
WriteData<VarInt>(simulation_distance, container);
#endif
WriteData<bool>(reduced_debug_info, container);
#if PROTOCOL_VERSION > 565 /* > 1.14.4 */
WriteData<bool>(show_death_screen, container);
#endif
#if PROTOCOL_VERSION > 718 /* > 1.15.2 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
WriteData<bool>(is_debug, container);
WriteData<bool>(is_flat, container);
#endif
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
WriteOptional<GlobalPos>(last_death_location, container);
#endif
#if PROTOCOL_VERSION > 762 /* > 1.19.4 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
WriteData<VarInt>(portal_cooldown, container);
#endif
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
WriteData<bool>(do_limited_crafting, container);
WriteData<CommonPlayerSpawnInfo>(common_player_spawn_info, container);
#endif
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["player_id"] = player_id;
#if PROTOCOL_VERSION > 737 /* > 1.16.1 */
output["hardcore"] = hardcore;
#endif
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
output["game_type"] = game_type;
#endif
#if PROTOCOL_VERSION > 718 /* > 1.15.2 */
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
output["previous_game_type"] = previous_game_type;
#endif
output["levels"] = levels;
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
output["registry_holder"] = registry_holder;
#endif
#if PROTOCOL_VERSION > 747 /* > 1.16.1 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
output["dimension_type"] = dimension_type;
#endif
#endif
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
output["dimension"] = dimension;
#endif
#if PROTOCOL_VERSION > 551 /* > 1.14.4 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
output["seed"] = seed;
#endif
output["difficulty"] = difficulty;
output["max_players"] = max_players;
#if PROTOCOL_VERSION < 719 /* < 1.16 */
output["level_type"] = level_type;
#endif
#if PROTOCOL_VERSION >= 477 /* >= 1.14 */
output["chunk_radius"] = chunk_radius;
#endif
#if PROTOCOL_VERSION > 756 /* > 1.17.1 */
output["simulation_distance"] = simulation_distance;
#endif
output["reduced_debug_info"] = reduced_debug_info;
#if PROTOCOL_VERSION > 565 /* > 1.14.4 */
output["show_death_screen"] = show_death_screen;
#endif
#if PROTOCOL_VERSION > 718 /* > 1.15.2 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
output["is_debug"] = is_debug;
output["is_flat"] = is_flat;
#endif
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
if (last_death_location.has_value())
{
output["last_death_location"] = last_death_location.value();
}
#endif
#if PROTOCOL_VERSION > 762 /* > 1.19.4 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
output["portal_cooldown"] = portal_cooldown;
#endif
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
output["do_limited_crafting"] = do_limited_crafting;
output["common_player_spawn_info"] = common_player_spawn_info;
#endif
return output;
}
private:
int player_id = 0;
#if PROTOCOL_VERSION > 551 /* > 1.14.4 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
long long int seed = 0;
#endif
#if PROTOCOL_VERSION > 737 /* > 1.16.1 */
bool hardcore = false;
#endif
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
unsigned char game_type = 0;
#endif
#if PROTOCOL_VERSION > 718 /* > 1.15.2 */
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
unsigned char previous_game_type = 0;
#endif
std::vector<Identifier> levels;
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
NBT::Value registry_holder;
#endif
#if PROTOCOL_VERSION > 747 /* > 1.16.1 */ && PROTOCOL_VERSION < 759 /* < 1.19 */
NBT::Value dimension_type;
#elif PROTOCOL_VERSION > 758 /* > 1.18.2 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
Identifier dimension_type;
#endif
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
Identifier dimension;
#endif
#else
int dimension = 0;
#endif
unsigned char difficulty = 0;
#if PROTOCOL_VERSION < 749 /* < 1.16.2 */
unsigned char max_players = 0;
#else
int max_players = 0;
#endif
#if PROTOCOL_VERSION < 719 /* < 1.16 */
std::string level_type;
#endif
#if PROTOCOL_VERSION >= 477 /* >= 1.14 */
int chunk_radius = 0;
#endif
#if PROTOCOL_VERSION > 756 /* > 1.17.1 */
int simulation_distance = 0;
#endif
bool reduced_debug_info = false;
#if PROTOCOL_VERSION > 565 /* > 1.14.4 */
bool show_death_screen = false;
#endif
#if PROTOCOL_VERSION > 718 /* > 1.15.2 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
bool is_debug = false;
bool is_flat = false;
#endif
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
std::optional<GlobalPos> last_death_location;
#endif
#if PROTOCOL_VERSION > 762 /* > 1.19.4 */ && PROTOCOL_VERSION < 764 /* < 1.20.2 */
int portal_cooldown = 0;
#endif
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
bool do_limited_crafting = false;
CommonPlayerSpawnInfo common_player_spawn_info;
#endif
};
} //ProtocolCraft
@@ -0,0 +1,290 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/MapDecoration.hpp"
namespace ProtocolCraft
{
class ClientboundMapItemDataPacket : public BaseMessage<ClientboundMapItemDataPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x24;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */ || PROTOCOL_VERSION == 477 /* 1.14 */ || \
PROTOCOL_VERSION == 480 /* 1.14.1 */ || PROTOCOL_VERSION == 485 /* 1.14.2 */ || \
PROTOCOL_VERSION == 490 /* 1.14.3 */ || PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x26;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x27;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x26;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x25;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x27;
#elif PROTOCOL_VERSION == 759 /* 1.19 */
static constexpr int packet_id = 0x24;
#elif PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x26;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x25;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x29;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x2A;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Map Item Data";
virtual ~ClientboundMapItemDataPacket() override
{
}
void SetMapId(const int map_id_)
{
map_id = map_id_;
}
void SetScale(const char scale_)
{
scale = scale_;
}
#if PROTOCOL_VERSION < 755 /* < 1.17 */
void SetTrackingPosition(const bool tracking_position_)
{
tracking_position = tracking_position_;
}
#endif
#if PROTOCOL_VERSION > 451 /* > 1.13.2 */
void SetLocked(const bool locked_)
{
locked = locked_;
}
#endif
#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
void SetDecorations(const std::optional<std::vector<MapDecoration>>& decorations_)
{
decorations = decorations_;
}
#else
void SetDecorations(const std::vector<MapDecoration>& decorations_)
{
decorations = decorations_;
}
#endif
void SetStartX(const unsigned char start_x_)
{
start_x = start_x_;
}
void SetStartZ(const unsigned char start_z_)
{
start_z = start_z_;
}
void SetWidth(const unsigned char width_)
{
width = width_;
}
void SetHeight(const unsigned char height_)
{
height = height_;
}
void SetMapColors(const std::vector<unsigned char>& map_colors_)
{
map_colors = map_colors_;
}
int GetMapId() const
{
return map_id;
}
char GetScale() const
{
return scale;
}
#if PROTOCOL_VERSION < 755 /* < 1.17 */
bool GetTrackingPosition() const
{
return tracking_position;
}
#endif
#if PROTOCOL_VERSION > 451 /* > 1.13.2 */
bool GetLocked() const
{
return locked;
}
#endif
#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
const std::optional<std::vector<MapDecoration>>& GetDecorations() const
{
return decorations;
}
#else
const std::vector<MapDecoration>& GetDecorations() const
{
return decorations;
}
#endif
unsigned char GetStartX() const
{
return start_x;
}
unsigned char GetStartZ() const
{
return start_z;
}
unsigned char GetWidth() const
{
return width;
}
unsigned char GetHeight() const
{
return height;
}
const std::vector<unsigned char>& GetMapColors() const
{
return map_colors;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
map_id = ReadData<VarInt>(iter, length);
scale = ReadData<char>(iter, length);
#if PROTOCOL_VERSION < 755 /* < 1.17 */
tracking_position = ReadData<bool>(iter, length);
#endif
#if PROTOCOL_VERSION > 451 /* > 1.13.2 */
locked = ReadData<bool>(iter, length);
#endif
#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
decorations = ReadOptional<std::vector<MapDecoration>>(iter, length,
[](ReadIterator& i, size_t& l)
{
return ReadVector<MapDecoration>(i, l);
}
);
#else
decorations = ReadVector<MapDecoration>(iter, length);
#endif
width = ReadData<unsigned char>(iter, length);
if (width > 0)
{
height = ReadData<unsigned char>(iter, length);
start_x = ReadData<unsigned char>(iter, length);
start_z = ReadData<unsigned char>(iter, length);
map_colors = ReadVector<unsigned char>(iter, length);
}
}
virtual void WriteImpl(WriteContainer & container) const override
{
WriteData<VarInt>(map_id, container);
WriteData<char>(scale, container);
#if PROTOCOL_VERSION < 755 /* < 1.17 */
WriteData<bool>(tracking_position, container);
#endif
#if PROTOCOL_VERSION > 451 /* > 1.13.2 */
WriteData<bool>(locked, container);
#endif
#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
WriteOptional<std::vector<MapDecoration>>(decorations, container,
[](const std::vector<MapDecoration>& v, WriteContainer& c)
{
WriteVector<MapDecoration>(v, c);
}
);
#else
WriteVector<MapDecoration>(decorations, container);
#endif
WriteData<unsigned char>(width, container);
if (width > 0)
{
WriteData<unsigned char>(height, container);
WriteData<unsigned char>(start_x, container);
WriteData<unsigned char>(start_z, container);
WriteVector<unsigned char>(map_colors, container);
}
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["map_id"] = map_id;
output["scale"] = scale;
#if PROTOCOL_VERSION < 755 /* < 1.17 */
output["tracking_position"] = tracking_position;
#endif
#if PROTOCOL_VERSION > 451 /* > 1.13.2 */
output["locked"] = locked;
#endif
#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
if (decorations.has_value())
{
output["decorations"] = decorations.value();
}
#else
output["decorations"] = decorations;
#endif
output["width"] = width;
if (width > 0)
{
output["height"] = height;
output["start_x"] = start_x;
output["start_z"] = start_z;
output["map_colors"] = "Vector of " + std::to_string(map_colors.size()) + " unsigned chars";
}
return output;
}
private:
int map_id = 0;
char scale = 0;
#if PROTOCOL_VERSION < 755 /* < 1.17 */
bool tracking_position = false;
#endif
#if PROTOCOL_VERSION > 451 /* > 1.13.2 */
bool locked = false;
#endif
#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
std::optional<std::vector<MapDecoration>> decorations;
#else
std::vector<MapDecoration> decorations;
#endif
unsigned char start_x = 0;
unsigned char start_z = 0;
unsigned char width = 0;
unsigned char height = 0;
std::vector<unsigned char> map_colors;
};
} //ProtocolCraft
@@ -0,0 +1,155 @@
#pragma once
#if PROTOCOL_VERSION > 451 /* > 1.13.2 */
#include "protocolCraft/BaseMessage.hpp"
#include "protocolCraft/Types/Trade.hpp"
namespace ProtocolCraft
{
class ClientboundMerchantOffersPacket : public BaseMessage<ClientboundMerchantOffersPacket>
{
public:
#if PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x27;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x28;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x27;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x26;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x28;
#elif PROTOCOL_VERSION == 759 /* 1.19 */
static constexpr int packet_id = 0x25;
#elif PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x27;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x26;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x2A;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x2B;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Merchant Offers";
virtual ~ClientboundMerchantOffersPacket() override
{
}
void SetContainerId(const int container_id_)
{
container_id = container_id_;
}
void SetOffers(const std::vector<Trade>& offers_)
{
offers = offers_;
}
void SetVillagerLevel(const int villager_level_)
{
villager_level = villager_level_;
}
void SetVillagerXp(const int villager_xp_)
{
villager_xp = villager_xp_;
}
void SetShowProgress(const bool show_progress_)
{
show_progress = show_progress_;
}
void SetCanRestock(const bool can_restock_)
{
can_restock = can_restock_;
}
int GetContainerId() const
{
return container_id;
}
const std::vector<Trade>& GetOffers() const
{
return offers;
}
int GetVillagerLevel() const
{
return villager_level;
}
int GetVillagerXp() const
{
return villager_xp;
}
bool GetShowProgress() const
{
return show_progress;
}
bool GetCanRestock() const
{
return can_restock;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
container_id = ReadData<VarInt>(iter, length);
offers = ReadVector<Trade, char>(iter, length);
villager_level = ReadData<VarInt>(iter, length);
villager_xp = ReadData<VarInt>(iter, length);
show_progress = ReadData<bool>(iter, length);
can_restock = ReadData<bool>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(container_id, container);
WriteVector<Trade, char>(offers, container);
WriteData<VarInt>(villager_level, container);
WriteData<VarInt>(villager_xp, container);
WriteData<bool>(show_progress, container);
WriteData<bool>(can_restock, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["container_id"] = container_id;
output["offers"] = offers;
output["villager_level"] = villager_level;
output["villager_xp"] = villager_xp;
output["show_progress"] = show_progress;
output["can_restock"] = can_restock;
return output;
}
private:
int container_id = 0;
std::vector<Trade> offers;
int villager_level = 0;
int villager_xp = 0;
bool show_progress = false;
bool can_restock = false;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,73 @@
#pragma once
#if PROTOCOL_VERSION < 755 /* < 1.17 */
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundMoveEntityPacket : public BaseMessage<ClientboundMoveEntityPacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x25;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */
static constexpr int packet_id = 0x27;
#elif PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x2B;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x2C;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x2B;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x2A;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Move Entity";
virtual ~ClientboundMoveEntityPacket() override
{
}
void SetEntityId(const int entity_id_)
{
entity_id = entity_id_;
}
int GetEntityId() const
{
return entity_id;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
entity_id = ReadData<VarInt>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(entity_id, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["entity_id"] = entity_id;
return output;
}
private:
int entity_id = 0;
};
} //ProtocolCraft
#endif
@@ -0,0 +1,138 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundMoveEntityPacketPos : public BaseMessage<ClientboundMoveEntityPacketPos>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x26;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */ || PROTOCOL_VERSION == 477 /* 1.14 */ || \
PROTOCOL_VERSION == 480 /* 1.14.1 */ || PROTOCOL_VERSION == 485 /* 1.14.2 */ || \
PROTOCOL_VERSION == 490 /* 1.14.3 */ || PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x28;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x29;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x28;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x27;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x29;
#elif PROTOCOL_VERSION == 759 /* 1.19 */
static constexpr int packet_id = 0x26;
#elif PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x28;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x27;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x2B;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x2C;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Move Entity Pos";
virtual ~ClientboundMoveEntityPacketPos() override
{
}
void SetEntityId(const int entity_id_)
{
entity_id = entity_id_;
}
void SetXA(const short x_a_)
{
x_a = x_a_;
}
void SetYA(const short y_a_)
{
y_a = y_a_;
}
void SetZA(const short z_a_)
{
z_a = z_a_;
}
void SetOnGround(const bool on_ground_)
{
on_ground = on_ground_;
}
int GetEntityId() const
{
return entity_id;
}
short GetXA() const
{
return x_a;
}
short GetYA() const
{
return y_a;
}
short GetZA() const
{
return z_a;
}
bool GetOnGround() const
{
return on_ground;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
entity_id = ReadData<VarInt>(iter, length);
x_a = ReadData<short>(iter, length);
y_a = ReadData<short>(iter, length);
z_a = ReadData<short>(iter, length);
on_ground = ReadData<bool>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(entity_id, container);
WriteData<short>(x_a, container);
WriteData<short>(y_a, container);
WriteData<short>(z_a, container);
WriteData<bool>(on_ground, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["entity_id"] = entity_id;
output["x_a"] = x_a;
output["y_a"] = y_a;
output["z_a"] = z_a;
output["on_ground"] = on_ground;
return output;
}
private:
int entity_id = 0;
short x_a = 0;
short y_a = 0;
short z_a = 0;
bool on_ground = false;
};
} //ProtocolCraft
@@ -0,0 +1,166 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundMoveEntityPacketPosRot : public BaseMessage<ClientboundMoveEntityPacketPosRot>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x27;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */ || PROTOCOL_VERSION == 477 /* 1.14 */ || \
PROTOCOL_VERSION == 480 /* 1.14.1 */ || PROTOCOL_VERSION == 485 /* 1.14.2 */ || \
PROTOCOL_VERSION == 490 /* 1.14.3 */ || PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x29;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x2A;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x29;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x28;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x2A;
#elif PROTOCOL_VERSION == 759 /* 1.19 */
static constexpr int packet_id = 0x27;
#elif PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x29;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x28;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x2C;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x2D;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Move Entity PosRot";
virtual ~ClientboundMoveEntityPacketPosRot() override
{
}
void SetEntityId(const int entity_id_)
{
entity_id = entity_id_;
}
void SetXA(const short x_a_)
{
x_a = x_a_;
}
void SetYA(const short y_a_)
{
y_a = y_a_;
}
void SetZA(const short z_a_)
{
z_a = z_a_;
}
void SetYRot(const unsigned char yRot_)
{
yRot = yRot_;
}
void SetXRot(const unsigned char xRot_)
{
xRot = xRot_;
}
void SetOnGround(const bool on_ground_)
{
on_ground = on_ground_;
}
int GetEntityId() const
{
return entity_id;
}
short GetXA() const
{
return x_a;
}
short GetYA() const
{
return y_a;
}
short GetZA() const
{
return z_a;
}
unsigned char GetYRot() const
{
return yRot;
}
unsigned char GetXRot() const
{
return xRot;
}
bool GetOnGround() const
{
return on_ground;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
entity_id = ReadData<VarInt>(iter, length);
x_a = ReadData<short>(iter, length);
y_a = ReadData<short>(iter, length);
z_a = ReadData<short>(iter, length);
yRot = ReadData<unsigned char>(iter, length);
xRot = ReadData<unsigned char>(iter, length);
on_ground = ReadData<bool>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(entity_id, container);
WriteData<short>(x_a, container);
WriteData<short>(y_a, container);
WriteData<short>(z_a, container);
WriteData<unsigned char>(yRot, container);
WriteData<unsigned char>(xRot, container);
WriteData<bool>(on_ground, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["entity_id"] = entity_id;
output["x_a"] = x_a;
output["y_a"] = y_a;
output["z_a"] = z_a;
output["yRot"] = yRot;
output["xRot"] = xRot;
output["on_ground"] = on_ground;
return output;
}
private:
int entity_id = 0;
short x_a = 0;
short y_a = 0;
short z_a = 0;
unsigned char yRot = 0;
unsigned char xRot = 0;
bool on_ground = false;
};
} //ProtocolCraft
@@ -0,0 +1,124 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundMoveEntityPacketRot : public BaseMessage<ClientboundMoveEntityPacketRot>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x28;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */ || PROTOCOL_VERSION == 477 /* 1.14 */ || \
PROTOCOL_VERSION == 480 /* 1.14.1 */ || PROTOCOL_VERSION == 485 /* 1.14.2 */ || \
PROTOCOL_VERSION == 490 /* 1.14.3 */ || PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x2A;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x2B;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x2A;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x29;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x2B;
#elif PROTOCOL_VERSION == 759 /* 1.19 */
static constexpr int packet_id = 0x28;
#elif PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x2A;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x29;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x2D;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x2E;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Move Entity Rot";
virtual ~ClientboundMoveEntityPacketRot() override
{
}
void SetEntityId(const int entity_id_)
{
entity_id = entity_id_;
}
void SetYRot(const unsigned char yRot_)
{
yRot = yRot_;
}
void SetXRot(const unsigned char xRot_)
{
xRot = xRot_;
}
void SetOnGround(const bool on_ground_)
{
on_ground = on_ground_;
}
int GetEntityId() const
{
return entity_id;
}
unsigned char GetYRot() const
{
return yRot;
}
unsigned char GetXRot() const
{
return xRot;
}
bool GetOnGround() const
{
return on_ground;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
entity_id = ReadData<VarInt>(iter, length);
yRot = ReadData<unsigned char>(iter, length);
xRot = ReadData<unsigned char>(iter, length);
on_ground = ReadData<bool>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(entity_id, container);
WriteData<unsigned char>(yRot, container);
WriteData<unsigned char>(xRot, container);
WriteData<bool>(on_ground, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["entity_id"] = entity_id;
output["yRot"] = yRot;
output["xRot"] = xRot;
output["on_ground"] = on_ground;
return output;
}
private:
int entity_id = 0;
unsigned char yRot = 0;
unsigned char xRot = 0;
bool on_ground = false;
};
} //ProtocolCraft
@@ -0,0 +1,143 @@
#pragma once
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundMoveVehiclePacket : public BaseMessage<ClientboundMoveVehiclePacket>
{
public:
#if PROTOCOL_VERSION == 340 /* 1.12.2 */
static constexpr int packet_id = 0x29;
#elif PROTOCOL_VERSION == 393 /* 1.13 */ || PROTOCOL_VERSION == 401 /* 1.13.1 */ || \
PROTOCOL_VERSION == 404 /* 1.13.2 */
static constexpr int packet_id = 0x2B;
#elif PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x2C;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x2D;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x2C;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x2B;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x2C;
#elif PROTOCOL_VERSION == 759 /* 1.19 */
static constexpr int packet_id = 0x29;
#elif PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x2B;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x2A;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x2E;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x2F;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Move Vehicle";
virtual ~ClientboundMoveVehiclePacket() override
{
}
void SetX(const double x_)
{
x = x_;
}
void SetY(const double y_)
{
y = y_;
}
void SetZ(const double z_)
{
z = z_;
}
void SetYRot(const float yRot_)
{
yRot = yRot_;
}
void SetXRot(const float xRot_)
{
xRot = xRot_;
}
double GetX() const
{
return x;
}
double GetY() const
{
return y;
}
double GetZ() const
{
return z;
}
float GetYRot() const
{
return yRot;
}
float GetXRot() const
{
return xRot;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
x = ReadData<double>(iter, length);
y = ReadData<double>(iter, length);
z = ReadData<double>(iter, length);
yRot = ReadData<float>(iter, length);
xRot = ReadData<float>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<double>(x, container);
WriteData<double>(y, container);
WriteData<double>(z, container);
WriteData<float>(yRot, container);
WriteData<float>(xRot, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["x"] = x;
output["y"] = y;
output["z"] = z;
output["yRot"] = yRot;
output["xRot"] = xRot;
return output;
}
private:
double x = 0.0;
double y = 0.0;
double z = 0.0;
float yRot = 0.0f;
float xRot = 0.0f;
};
} //ProtocolCraft
@@ -0,0 +1,84 @@
#pragma once
#if PROTOCOL_VERSION > 450 /* > 1.13.2 */
#include "protocolCraft/BaseMessage.hpp"
namespace ProtocolCraft
{
class ClientboundOpenBookPacket : public BaseMessage<ClientboundOpenBookPacket>
{
public:
#if PROTOCOL_VERSION == 477 /* 1.14 */ || PROTOCOL_VERSION == 480 /* 1.14.1 */ || \
PROTOCOL_VERSION == 485 /* 1.14.2 */ || PROTOCOL_VERSION == 490 /* 1.14.3 */ || \
PROTOCOL_VERSION == 498 /* 1.14.4 */
static constexpr int packet_id = 0x2D;
#elif PROTOCOL_VERSION == 573 /* 1.15 */ || PROTOCOL_VERSION == 575 /* 1.15.1 */ || \
PROTOCOL_VERSION == 578 /* 1.15.2 */
static constexpr int packet_id = 0x2E;
#elif PROTOCOL_VERSION == 735 /* 1.16 */ || PROTOCOL_VERSION == 736 /* 1.16.1 */
static constexpr int packet_id = 0x2D;
#elif PROTOCOL_VERSION == 751 /* 1.16.2 */ || PROTOCOL_VERSION == 753 /* 1.16.3 */ || \
PROTOCOL_VERSION == 754 /* 1.16.4/5 */
static constexpr int packet_id = 0x2C;
#elif PROTOCOL_VERSION == 755 /* 1.17 */ || PROTOCOL_VERSION == 756 /* 1.17.1 */ || \
PROTOCOL_VERSION == 757 /* 1.18/.1 */ || PROTOCOL_VERSION == 758 /* 1.18.2 */
static constexpr int packet_id = 0x2D;
#elif PROTOCOL_VERSION == 759 /* 1.19 */
static constexpr int packet_id = 0x2A;
#elif PROTOCOL_VERSION == 760 /* 1.19.1/2 */
static constexpr int packet_id = 0x2C;
#elif PROTOCOL_VERSION == 761 /* 1.19.3 */
static constexpr int packet_id = 0x2B;
#elif PROTOCOL_VERSION == 762 /* 1.19.4 */ || PROTOCOL_VERSION == 763 /* 1.20/.1 */
static constexpr int packet_id = 0x2F;
#elif PROTOCOL_VERSION == 764 /* 1.20.2 */ || PROTOCOL_VERSION == 765 /* 1.20.3/4 */
static constexpr int packet_id = 0x30;
#else
#error "Protocol version not implemented"
#endif
static constexpr std::string_view packet_name = "Open Book";
virtual ~ClientboundOpenBookPacket() override
{
}
void SetHand(const int hand_)
{
hand = hand_;
}
int GetHand() const
{
return hand;
}
protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
hand = ReadData<VarInt>(iter, length);
}
virtual void WriteImpl(WriteContainer& container) const override
{
WriteData<VarInt>(hand, container);
}
virtual Json::Value SerializeImpl() const override
{
Json::Value output;
output["hand"] = hand;
return output;
}
private:
int hand = 0;
};
} //ProtocolCraft
#endif

Some files were not shown because too many files have changed in this diff Show More