From a2e2196a9089b1206ca0e7a5b9978943cc162100 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 14 Jul 2021 20:32:15 +0100 Subject: [PATCH] Start using pocketmine/bedrock-protocol library --- composer.json | 1 + composer.lock | 51 +- .../mcpe/protocol/ActorEventPacket.php | 124 --- .../mcpe/protocol/ActorPickRequestPacket.php | 51 -- src/network/mcpe/protocol/AddActorPacket.php | 119 --- .../mcpe/protocol/AddBehaviorTreePacket.php | 47 -- src/network/mcpe/protocol/AddEntityPacket.php | 57 -- .../mcpe/protocol/AddItemActorPacket.php | 77 -- .../mcpe/protocol/AddPaintingPacket.php | 64 -- src/network/mcpe/protocol/AddPlayerPacket.php | 156 ---- .../mcpe/protocol/AddVolumeEntityPacket.php | 65 -- .../mcpe/protocol/AdventureSettingsPacket.php | 123 --- .../mcpe/protocol/AnimateEntityPacket.php | 108 --- src/network/mcpe/protocol/AnimatePacket.php | 80 -- .../mcpe/protocol/AnvilDamagePacket.php | 78 -- .../AutomationClientConnectPacket.php | 47 -- .../AvailableActorIdentifiersPacket.php | 60 -- .../mcpe/protocol/AvailableCommandsPacket.php | 487 ----------- .../protocol/BiomeDefinitionListPacket.php | 60 -- .../mcpe/protocol/BlockActorDataPacket.php | 69 -- .../mcpe/protocol/BlockEventPacket.php | 70 -- .../mcpe/protocol/BlockPickRequestPacket.php | 59 -- src/network/mcpe/protocol/BookEditPacket.php | 119 --- src/network/mcpe/protocol/BossEventPacket.php | 184 ---- src/network/mcpe/protocol/CameraPacket.php | 51 -- .../mcpe/protocol/CameraShakePacket.php | 82 -- .../mcpe/protocol/ChangeDimensionPacket.php | 56 -- .../protocol/ChunkRadiusUpdatedPacket.php | 53 -- .../protocol/ClientCacheBlobStatusPacket.php | 93 -- .../ClientCacheMissResponsePacket.php | 76 -- .../mcpe/protocol/ClientCacheStatusPacket.php | 57 -- .../ClientToServerHandshakePacket.php | 48 -- .../ClientboundDebugRendererPacket.php | 137 --- .../protocol/ClientboundMapItemDataPacket.php | 208 ----- .../mcpe/protocol/ClientboundPacket.php | 28 - .../mcpe/protocol/CodeBuilderPacket.php | 66 -- .../protocol/CommandBlockUpdatePacket.php | 111 --- .../mcpe/protocol/CommandOutputPacket.php | 111 --- .../mcpe/protocol/CommandRequestPacket.php | 56 -- .../protocol/CompletedUsingItemPacket.php | 68 -- .../mcpe/protocol/ContainerClosePacket.php | 58 -- .../mcpe/protocol/ContainerOpenPacket.php | 85 -- .../mcpe/protocol/ContainerSetDataPacket.php | 73 -- .../CorrectPlayerMovePredictionPacket.php | 77 -- .../mcpe/protocol/CraftingDataPacket.php | 131 --- .../mcpe/protocol/CraftingEventPacket.php | 82 -- .../mcpe/protocol/CreativeContentPacket.php | 67 -- src/network/mcpe/protocol/DataPacket.php | 129 --- src/network/mcpe/protocol/DebugInfoPacket.php | 65 -- .../mcpe/protocol/DisconnectPacket.php | 72 -- .../mcpe/protocol/EducationSettingsPacket.php | 100 --- src/network/mcpe/protocol/EmoteListPacket.php | 74 -- src/network/mcpe/protocol/EmotePacket.php | 80 -- src/network/mcpe/protocol/EventPacket.php | 85 -- .../mcpe/protocol/FilterTextPacket.php | 62 -- .../mcpe/protocol/GameRulesChangedPacket.php | 51 -- .../mcpe/protocol/GuiDataPickItemPacket.php | 55 -- src/network/mcpe/protocol/HurtArmorPacket.php | 51 -- src/network/mcpe/protocol/InteractPacket.php | 76 -- .../mcpe/protocol/InventoryContentPacket.php | 71 -- .../mcpe/protocol/InventorySlotPacket.php | 65 -- .../protocol/InventoryTransactionPacket.php | 108 --- .../mcpe/protocol/ItemComponentPacket.php | 79 -- .../mcpe/protocol/ItemFrameDropItemPacket.php | 52 -- .../mcpe/protocol/ItemStackRequestPacket.php | 67 -- .../mcpe/protocol/ItemStackResponsePacket.php | 67 -- src/network/mcpe/protocol/LabTablePacket.php | 65 -- .../mcpe/protocol/LecternUpdatePacket.php | 63 -- .../mcpe/protocol/LevelChunkPacket.php | 133 --- .../mcpe/protocol/LevelEventGenericPacket.php | 74 -- .../mcpe/protocol/LevelEventPacket.php | 151 ---- .../mcpe/protocol/LevelSoundEventPacket.php | 408 --------- .../mcpe/protocol/LevelSoundEventPacketV1.php | 71 -- .../mcpe/protocol/LevelSoundEventPacketV2.php | 71 -- src/network/mcpe/protocol/LoginPacket.php | 101 --- .../protocol/MapCreateLockedCopyPacket.php | 51 -- .../mcpe/protocol/MapInfoRequestPacket.php | 47 -- .../mcpe/protocol/MobArmorEquipmentPacket.php | 78 -- src/network/mcpe/protocol/MobEffectPacket.php | 90 -- .../mcpe/protocol/MobEquipmentPacket.php | 74 -- .../mcpe/protocol/ModalFormRequestPacket.php | 58 -- .../mcpe/protocol/ModalFormResponsePacket.php | 51 -- .../protocol/MotionPredictionHintsPacket.php | 70 -- .../mcpe/protocol/MoveActorAbsolutePacket.php | 83 -- .../mcpe/protocol/MoveActorDeltaPacket.php | 118 --- .../mcpe/protocol/MovePlayerPacket.php | 97 --- .../protocol/MultiplayerSettingsPacket.php | 61 -- .../NetworkChunkPublisherUpdatePacket.php | 64 -- .../mcpe/protocol/NetworkSettingsPacket.php | 60 -- .../protocol/NetworkStackLatencyPacket.php | 65 -- .../mcpe/protocol/NpcDialoguePacket.php | 87 -- .../mcpe/protocol/NpcRequestPacket.php | 70 -- .../OnScreenTextureAnimationPacket.php | 47 -- src/network/mcpe/protocol/Packet.php | 57 -- .../mcpe/protocol/PacketDecodeException.php | 31 - .../mcpe/protocol/PacketHandlerInterface.php | 357 -------- src/network/mcpe/protocol/PacketPool.php | 227 ----- .../protocol/PacketViolationWarningPacket.php | 84 -- .../mcpe/protocol/PhotoTransferPacket.php | 55 -- src/network/mcpe/protocol/PlaySoundPacket.php | 66 -- .../mcpe/protocol/PlayStatusPacket.php | 66 -- .../mcpe/protocol/PlayerActionPacket.php | 92 -- .../mcpe/protocol/PlayerArmorDamagePacket.php | 108 --- .../mcpe/protocol/PlayerAuthInputPacket.php | 179 ---- .../protocol/PlayerEnchantOptionsPacket.php | 69 -- src/network/mcpe/protocol/PlayerFogPacket.php | 73 -- .../mcpe/protocol/PlayerHotbarPacket.php | 64 -- .../mcpe/protocol/PlayerInputPacket.php | 59 -- .../mcpe/protocol/PlayerListPacket.php | 120 --- .../mcpe/protocol/PlayerSkinPacket.php | 70 -- .../PositionTrackingDBClientRequestPacket.php | 64 -- ...ositionTrackingDBServerBroadcastPacket.php | 81 -- src/network/mcpe/protocol/ProtocolInfo.php | 220 ----- .../mcpe/protocol/PurchaseReceiptPacket.php | 54 -- .../mcpe/protocol/RemoveActorPacket.php | 53 -- .../mcpe/protocol/RemoveEntityPacket.php | 57 -- .../mcpe/protocol/RemoveObjectivePacket.php | 47 -- .../protocol/RemoveVolumeEntityPacket.php | 55 -- .../protocol/RequestChunkRadiusPacket.php | 47 -- .../protocol/ResourcePackChunkDataPacket.php | 68 -- .../ResourcePackChunkRequestPacket.php | 51 -- .../ResourcePackClientResponsePacket.php | 64 -- .../protocol/ResourcePackDataInfoPacket.php | 82 -- .../mcpe/protocol/ResourcePackStackPacket.php | 101 --- .../mcpe/protocol/ResourcePacksInfoPacket.php | 95 --- src/network/mcpe/protocol/RespawnPacket.php | 68 -- src/network/mcpe/protocol/RiderJumpPacket.php | 47 -- .../mcpe/protocol/ScriptCustomEventPacket.php | 51 -- .../protocol/ServerSettingsRequestPacket.php | 44 - .../protocol/ServerSettingsResponsePacket.php | 51 -- .../ServerToClientHandshakePacket.php | 60 -- .../mcpe/protocol/ServerboundPacket.php | 28 - .../mcpe/protocol/SetActorDataPacket.php | 73 -- .../mcpe/protocol/SetActorLinkPacket.php | 48 -- .../mcpe/protocol/SetActorMotionPacket.php | 59 -- .../protocol/SetCommandsEnabledPacket.php | 53 -- .../protocol/SetDefaultGameTypePacket.php | 53 -- .../mcpe/protocol/SetDifficultyPacket.php | 53 -- .../protocol/SetDisplayObjectivePacket.php | 70 -- src/network/mcpe/protocol/SetHealthPacket.php | 47 -- .../mcpe/protocol/SetLastHurtByPacket.php | 47 -- .../SetLocalPlayerAsInitializedPacket.php | 47 -- .../mcpe/protocol/SetPlayerGameTypePacket.php | 53 -- src/network/mcpe/protocol/SetScorePacket.php | 95 --- .../protocol/SetScoreboardIdentityPacket.php | 70 -- .../mcpe/protocol/SetSpawnPositionPacket.php | 88 -- src/network/mcpe/protocol/SetTimePacket.php | 53 -- src/network/mcpe/protocol/SetTitlePacket.php | 119 --- .../mcpe/protocol/SettingsCommandPacket.php | 66 -- .../mcpe/protocol/ShowCreditsPacket.php | 54 -- .../mcpe/protocol/ShowProfilePacket.php | 47 -- .../mcpe/protocol/ShowStoreOfferPacket.php | 51 -- .../mcpe/protocol/SimpleEventPacket.php | 51 -- .../mcpe/protocol/SimulationTypePacket.php | 58 -- .../protocol/SpawnExperienceOrbPacket.php | 52 -- .../protocol/SpawnParticleEffectPacket.php | 61 -- src/network/mcpe/protocol/StartGamePacket.php | 348 -------- src/network/mcpe/protocol/StopSoundPacket.php | 51 -- .../protocol/StructureBlockUpdatePacket.php | 60 -- .../StructureTemplateDataRequestPacket.php | 67 -- .../StructureTemplateDataResponsePacket.php | 60 -- .../mcpe/protocol/SubClientLoginPacket.php | 47 -- .../mcpe/protocol/SyncActorPropertyPacket.php | 58 -- .../mcpe/protocol/TakeItemActorPacket.php | 58 -- src/network/mcpe/protocol/TextPacket.php | 186 ---- src/network/mcpe/protocol/TickSyncPacket.php | 73 -- src/network/mcpe/protocol/TransferPacket.php | 58 -- src/network/mcpe/protocol/UnknownPacket.php | 66 -- .../mcpe/protocol/UpdateAttributesPacket.php | 70 -- .../mcpe/protocol/UpdateBlockPacket.php | 78 -- .../mcpe/protocol/UpdateBlockSyncedPacket.php | 57 -- .../mcpe/protocol/UpdateEquipPacket.php | 67 -- .../protocol/UpdatePlayerGameTypePacket.php | 67 -- .../mcpe/protocol/UpdateSoftEnumPacket.php | 65 -- .../mcpe/protocol/UpdateTradePacket.php | 90 -- .../serializer/ItemTypeDictionary.php | 79 -- .../serializer/NetworkNbtSerializer.php | 101 --- .../mcpe/protocol/serializer/PacketBatch.php | 80 -- .../protocol/serializer/PacketSerializer.php | 795 ------------------ .../serializer/PacketSerializerContext.php | 39 - .../mcpe/protocol/types/BlockPaletteEntry.php | 43 - .../mcpe/protocol/types/BoolGameRule.php | 53 -- .../mcpe/protocol/types/CacheableNbt.php | 60 -- .../mcpe/protocol/types/ChunkCacheBlob.php | 47 -- src/network/mcpe/protocol/types/DeviceOS.php | 44 - .../mcpe/protocol/types/DimensionIds.php | 36 - .../protocol/types/EducationEditionOffer.php | 35 - src/network/mcpe/protocol/types/Enchant.php | 53 -- .../mcpe/protocol/types/EnchantOption.php | 126 --- .../mcpe/protocol/types/Experiments.php | 72 -- .../mcpe/protocol/types/FloatGameRule.php | 52 -- src/network/mcpe/protocol/types/GameMode.php | 38 - src/network/mcpe/protocol/types/GameRule.php | 41 - .../mcpe/protocol/types/GameRuleType.php | 35 - .../mcpe/protocol/types/GeneratorType.php | 37 - src/network/mcpe/protocol/types/InputMode.php | 36 - .../mcpe/protocol/types/IntGameRule.php | 53 -- .../types/ItemComponentPacketEntry.php | 43 - .../mcpe/protocol/types/ItemTypeEntry.php | 46 - .../mcpe/protocol/types/MapDecoration.php | 74 -- .../mcpe/protocol/types/MapTrackedObject.php | 43 - .../types/MultiplayerGameVisibility.php | 37 - .../mcpe/protocol/types/ParticleIds.php | 113 --- src/network/mcpe/protocol/types/PlayMode.php | 45 - .../protocol/types/PlayerAuthInputFlags.php | 75 -- .../mcpe/protocol/types/PlayerListEntry.php | 71 -- .../protocol/types/PlayerMovementSettings.php | 61 -- .../protocol/types/PlayerMovementType.php | 31 - .../mcpe/protocol/types/PlayerPermissions.php | 37 - .../mcpe/protocol/types/ScorePacketEntry.php | 45 - .../types/ScoreboardIdentityPacketEntry.php | 32 - .../mcpe/protocol/types/SpawnSettings.php | 73 -- .../protocol/types/StructureEditorData.php | 48 -- .../mcpe/protocol/types/StructureSettings.php | 59 -- src/network/mcpe/protocol/types/UIProfile.php | 34 - .../protocol/types/command/CommandData.php | 83 -- .../protocol/types/command/CommandEnum.php | 55 -- .../types/command/CommandEnumConstraint.php | 65 -- .../types/command/CommandOriginData.php | 52 -- .../types/command/CommandOutputMessage.php | 34 - .../types/command/CommandParameter.php | 69 -- .../mcpe/protocol/types/entity/Attribute.php | 65 -- .../types/entity/BlockPosMetadataProperty.php | 59 -- .../types/entity/ByteMetadataProperty.php | 50 -- .../entity/CompoundTagMetadataProperty.php | 62 -- .../mcpe/protocol/types/entity/EntityIds.php | 148 ---- .../mcpe/protocol/types/entity/EntityLink.php | 50 -- .../types/entity/EntityMetadataCollection.php | 152 ---- .../types/entity/EntityMetadataFlags.php | 126 --- .../types/entity/EntityMetadataProperties.php | 150 ---- .../types/entity/EntityMetadataTypes.php | 41 - .../types/entity/FloatMetadataProperty.php | 56 -- .../types/entity/IntMetadataProperty.php | 50 -- .../entity/IntegerishMetadataProperty.php | 62 -- .../types/entity/LongMetadataProperty.php | 52 -- .../types/entity/MetadataProperty.php | 35 - .../types/entity/PlayerMetadataFlags.php | 34 - .../types/entity/ShortMetadataProperty.php | 50 -- .../types/entity/StringMetadataProperty.php | 51 -- .../types/entity/Vec3MetadataProperty.php | 56 -- .../protocol/types/inventory/ContainerIds.php | 43 - .../types/inventory/CreativeContentEntry.php | 54 -- .../InventoryTransactionChangedSlotsHack.php | 65 -- .../protocol/types/inventory/ItemStack.php | 142 ---- .../types/inventory/ItemStackWrapper.php | 67 -- .../inventory/MismatchTransactionData.php | 50 -- .../inventory/NetworkInventoryAction.php | 138 --- .../types/inventory/NormalTransactionData.php | 53 -- .../inventory/ReleaseItemTransactionData.php | 90 -- .../types/inventory/TransactionData.php | 71 -- .../types/inventory/UIInventorySlotOffset.php | 105 --- .../UseItemOnEntityTransactionData.php | 108 --- .../inventory/UseItemTransactionData.php | 128 --- .../protocol/types/inventory/WindowTypes.php | 70 -- .../BeaconPaymentStackRequestAction.php | 59 -- .../CraftRecipeAutoStackRequestAction.php | 34 - .../CraftRecipeOptionalStackRequestAction.php | 59 -- .../CraftRecipeStackRequestAction.php | 33 - .../CraftRecipeStackRequestActionTrait.php | 47 -- ...CraftingConsumeInputStackRequestAction.php | 33 - ...gMarkSecondaryResultStackRequestAction.php | 53 -- .../CreativeCreateStackRequestAction.php | 52 -- ...aftingNonImplementedStackRequestAction.php | 45 - ...catedCraftingResultsStackRequestAction.php | 74 -- .../DestroyStackRequestAction.php | 34 - .../DisappearStackRequestActionTrait.php | 53 -- .../stackrequest/DropStackRequestAction.php | 66 -- .../stackrequest/ItemStackRequest.php | 110 --- .../stackrequest/ItemStackRequestAction.php | 33 - .../ItemStackRequestActionType.php | 48 -- .../stackrequest/ItemStackRequestSlotInfo.php | 61 -- .../LabTableCombineStackRequestAction.php | 43 - .../MineBlockStackRequestAction.php | 63 -- .../stackrequest/PlaceStackRequestAction.php | 33 - .../stackrequest/SwapStackRequestAction.php | 59 -- .../TakeOrPlaceStackRequestActionTrait.php | 61 -- .../stackrequest/TakeStackRequestAction.php | 33 - .../stackresponse/ItemStackResponse.php | 77 -- .../ItemStackResponseContainerInfo.php | 65 -- .../ItemStackResponseSlotInfo.php | 82 -- .../types/login/AuthenticationData.php | 41 - .../mcpe/protocol/types/login/ClientData.php | 149 ---- .../types/login/ClientDataAnimationFrame.php | 48 -- .../login/ClientDataPersonaPieceTintColor.php | 38 - .../login/ClientDataPersonaSkinPiece.php | 44 - .../login/ClientDataToSkinDataHelper.php | 89 -- .../protocol/types/login/JwtBodyRfc7519.php | 39 - .../mcpe/protocol/types/login/JwtChain.php | 36 - .../protocol/types/login/JwtChainLinkBody.php | 32 - .../mcpe/protocol/types/login/JwtHeader.php | 31 - .../protocol/types/recipe/FurnaceRecipe.php | 85 -- .../protocol/types/recipe/MultiRecipe.php | 73 -- .../recipe/PotionContainerChangeRecipe.php | 51 -- .../types/recipe/PotionTypeRecipe.php | 72 -- .../types/recipe/RecipeIngredient.php | 52 -- .../types/recipe/RecipeWithTypeId.php | 41 - .../protocol/types/recipe/ShapedRecipe.php | 160 ---- .../protocol/types/recipe/ShapelessRecipe.php | 132 --- .../resourcepacks/BehaviorPackInfoEntry.php | 103 --- .../resourcepacks/ResourcePackInfoEntry.php | 110 --- .../resourcepacks/ResourcePackStackEntry.php | 67 -- .../types/resourcepacks/ResourcePackType.php | 41 - .../types/skin/PersonaPieceTintColor.php | 55 -- .../protocol/types/skin/PersonaSkinPiece.php | 77 -- .../protocol/types/skin/SkinAnimation.php | 73 -- .../mcpe/protocol/types/skin/SkinData.php | 182 ---- .../mcpe/protocol/types/skin/SkinImage.php | 73 -- 307 files changed, 51 insertions(+), 23572 deletions(-) delete mode 100644 src/network/mcpe/protocol/ActorEventPacket.php delete mode 100644 src/network/mcpe/protocol/ActorPickRequestPacket.php delete mode 100644 src/network/mcpe/protocol/AddActorPacket.php delete mode 100644 src/network/mcpe/protocol/AddBehaviorTreePacket.php delete mode 100644 src/network/mcpe/protocol/AddEntityPacket.php delete mode 100644 src/network/mcpe/protocol/AddItemActorPacket.php delete mode 100644 src/network/mcpe/protocol/AddPaintingPacket.php delete mode 100644 src/network/mcpe/protocol/AddPlayerPacket.php delete mode 100644 src/network/mcpe/protocol/AddVolumeEntityPacket.php delete mode 100644 src/network/mcpe/protocol/AdventureSettingsPacket.php delete mode 100644 src/network/mcpe/protocol/AnimateEntityPacket.php delete mode 100644 src/network/mcpe/protocol/AnimatePacket.php delete mode 100644 src/network/mcpe/protocol/AnvilDamagePacket.php delete mode 100644 src/network/mcpe/protocol/AutomationClientConnectPacket.php delete mode 100644 src/network/mcpe/protocol/AvailableActorIdentifiersPacket.php delete mode 100644 src/network/mcpe/protocol/AvailableCommandsPacket.php delete mode 100644 src/network/mcpe/protocol/BiomeDefinitionListPacket.php delete mode 100644 src/network/mcpe/protocol/BlockActorDataPacket.php delete mode 100644 src/network/mcpe/protocol/BlockEventPacket.php delete mode 100644 src/network/mcpe/protocol/BlockPickRequestPacket.php delete mode 100644 src/network/mcpe/protocol/BookEditPacket.php delete mode 100644 src/network/mcpe/protocol/BossEventPacket.php delete mode 100644 src/network/mcpe/protocol/CameraPacket.php delete mode 100644 src/network/mcpe/protocol/CameraShakePacket.php delete mode 100644 src/network/mcpe/protocol/ChangeDimensionPacket.php delete mode 100644 src/network/mcpe/protocol/ChunkRadiusUpdatedPacket.php delete mode 100644 src/network/mcpe/protocol/ClientCacheBlobStatusPacket.php delete mode 100644 src/network/mcpe/protocol/ClientCacheMissResponsePacket.php delete mode 100644 src/network/mcpe/protocol/ClientCacheStatusPacket.php delete mode 100644 src/network/mcpe/protocol/ClientToServerHandshakePacket.php delete mode 100644 src/network/mcpe/protocol/ClientboundDebugRendererPacket.php delete mode 100644 src/network/mcpe/protocol/ClientboundMapItemDataPacket.php delete mode 100644 src/network/mcpe/protocol/ClientboundPacket.php delete mode 100644 src/network/mcpe/protocol/CodeBuilderPacket.php delete mode 100644 src/network/mcpe/protocol/CommandBlockUpdatePacket.php delete mode 100644 src/network/mcpe/protocol/CommandOutputPacket.php delete mode 100644 src/network/mcpe/protocol/CommandRequestPacket.php delete mode 100644 src/network/mcpe/protocol/CompletedUsingItemPacket.php delete mode 100644 src/network/mcpe/protocol/ContainerClosePacket.php delete mode 100644 src/network/mcpe/protocol/ContainerOpenPacket.php delete mode 100644 src/network/mcpe/protocol/ContainerSetDataPacket.php delete mode 100644 src/network/mcpe/protocol/CorrectPlayerMovePredictionPacket.php delete mode 100644 src/network/mcpe/protocol/CraftingDataPacket.php delete mode 100644 src/network/mcpe/protocol/CraftingEventPacket.php delete mode 100644 src/network/mcpe/protocol/CreativeContentPacket.php delete mode 100644 src/network/mcpe/protocol/DataPacket.php delete mode 100644 src/network/mcpe/protocol/DebugInfoPacket.php delete mode 100644 src/network/mcpe/protocol/DisconnectPacket.php delete mode 100644 src/network/mcpe/protocol/EducationSettingsPacket.php delete mode 100644 src/network/mcpe/protocol/EmoteListPacket.php delete mode 100644 src/network/mcpe/protocol/EmotePacket.php delete mode 100644 src/network/mcpe/protocol/EventPacket.php delete mode 100644 src/network/mcpe/protocol/FilterTextPacket.php delete mode 100644 src/network/mcpe/protocol/GameRulesChangedPacket.php delete mode 100644 src/network/mcpe/protocol/GuiDataPickItemPacket.php delete mode 100644 src/network/mcpe/protocol/HurtArmorPacket.php delete mode 100644 src/network/mcpe/protocol/InteractPacket.php delete mode 100644 src/network/mcpe/protocol/InventoryContentPacket.php delete mode 100644 src/network/mcpe/protocol/InventorySlotPacket.php delete mode 100644 src/network/mcpe/protocol/InventoryTransactionPacket.php delete mode 100644 src/network/mcpe/protocol/ItemComponentPacket.php delete mode 100644 src/network/mcpe/protocol/ItemFrameDropItemPacket.php delete mode 100644 src/network/mcpe/protocol/ItemStackRequestPacket.php delete mode 100644 src/network/mcpe/protocol/ItemStackResponsePacket.php delete mode 100644 src/network/mcpe/protocol/LabTablePacket.php delete mode 100644 src/network/mcpe/protocol/LecternUpdatePacket.php delete mode 100644 src/network/mcpe/protocol/LevelChunkPacket.php delete mode 100644 src/network/mcpe/protocol/LevelEventGenericPacket.php delete mode 100644 src/network/mcpe/protocol/LevelEventPacket.php delete mode 100644 src/network/mcpe/protocol/LevelSoundEventPacket.php delete mode 100644 src/network/mcpe/protocol/LevelSoundEventPacketV1.php delete mode 100644 src/network/mcpe/protocol/LevelSoundEventPacketV2.php delete mode 100644 src/network/mcpe/protocol/LoginPacket.php delete mode 100644 src/network/mcpe/protocol/MapCreateLockedCopyPacket.php delete mode 100644 src/network/mcpe/protocol/MapInfoRequestPacket.php delete mode 100644 src/network/mcpe/protocol/MobArmorEquipmentPacket.php delete mode 100644 src/network/mcpe/protocol/MobEffectPacket.php delete mode 100644 src/network/mcpe/protocol/MobEquipmentPacket.php delete mode 100644 src/network/mcpe/protocol/ModalFormRequestPacket.php delete mode 100644 src/network/mcpe/protocol/ModalFormResponsePacket.php delete mode 100644 src/network/mcpe/protocol/MotionPredictionHintsPacket.php delete mode 100644 src/network/mcpe/protocol/MoveActorAbsolutePacket.php delete mode 100644 src/network/mcpe/protocol/MoveActorDeltaPacket.php delete mode 100644 src/network/mcpe/protocol/MovePlayerPacket.php delete mode 100644 src/network/mcpe/protocol/MultiplayerSettingsPacket.php delete mode 100644 src/network/mcpe/protocol/NetworkChunkPublisherUpdatePacket.php delete mode 100644 src/network/mcpe/protocol/NetworkSettingsPacket.php delete mode 100644 src/network/mcpe/protocol/NetworkStackLatencyPacket.php delete mode 100644 src/network/mcpe/protocol/NpcDialoguePacket.php delete mode 100644 src/network/mcpe/protocol/NpcRequestPacket.php delete mode 100644 src/network/mcpe/protocol/OnScreenTextureAnimationPacket.php delete mode 100644 src/network/mcpe/protocol/Packet.php delete mode 100644 src/network/mcpe/protocol/PacketDecodeException.php delete mode 100644 src/network/mcpe/protocol/PacketHandlerInterface.php delete mode 100644 src/network/mcpe/protocol/PacketPool.php delete mode 100644 src/network/mcpe/protocol/PacketViolationWarningPacket.php delete mode 100644 src/network/mcpe/protocol/PhotoTransferPacket.php delete mode 100644 src/network/mcpe/protocol/PlaySoundPacket.php delete mode 100644 src/network/mcpe/protocol/PlayStatusPacket.php delete mode 100644 src/network/mcpe/protocol/PlayerActionPacket.php delete mode 100644 src/network/mcpe/protocol/PlayerArmorDamagePacket.php delete mode 100644 src/network/mcpe/protocol/PlayerAuthInputPacket.php delete mode 100644 src/network/mcpe/protocol/PlayerEnchantOptionsPacket.php delete mode 100644 src/network/mcpe/protocol/PlayerFogPacket.php delete mode 100644 src/network/mcpe/protocol/PlayerHotbarPacket.php delete mode 100644 src/network/mcpe/protocol/PlayerInputPacket.php delete mode 100644 src/network/mcpe/protocol/PlayerListPacket.php delete mode 100644 src/network/mcpe/protocol/PlayerSkinPacket.php delete mode 100644 src/network/mcpe/protocol/PositionTrackingDBClientRequestPacket.php delete mode 100644 src/network/mcpe/protocol/PositionTrackingDBServerBroadcastPacket.php delete mode 100644 src/network/mcpe/protocol/ProtocolInfo.php delete mode 100644 src/network/mcpe/protocol/PurchaseReceiptPacket.php delete mode 100644 src/network/mcpe/protocol/RemoveActorPacket.php delete mode 100644 src/network/mcpe/protocol/RemoveEntityPacket.php delete mode 100644 src/network/mcpe/protocol/RemoveObjectivePacket.php delete mode 100644 src/network/mcpe/protocol/RemoveVolumeEntityPacket.php delete mode 100644 src/network/mcpe/protocol/RequestChunkRadiusPacket.php delete mode 100644 src/network/mcpe/protocol/ResourcePackChunkDataPacket.php delete mode 100644 src/network/mcpe/protocol/ResourcePackChunkRequestPacket.php delete mode 100644 src/network/mcpe/protocol/ResourcePackClientResponsePacket.php delete mode 100644 src/network/mcpe/protocol/ResourcePackDataInfoPacket.php delete mode 100644 src/network/mcpe/protocol/ResourcePackStackPacket.php delete mode 100644 src/network/mcpe/protocol/ResourcePacksInfoPacket.php delete mode 100644 src/network/mcpe/protocol/RespawnPacket.php delete mode 100644 src/network/mcpe/protocol/RiderJumpPacket.php delete mode 100644 src/network/mcpe/protocol/ScriptCustomEventPacket.php delete mode 100644 src/network/mcpe/protocol/ServerSettingsRequestPacket.php delete mode 100644 src/network/mcpe/protocol/ServerSettingsResponsePacket.php delete mode 100644 src/network/mcpe/protocol/ServerToClientHandshakePacket.php delete mode 100644 src/network/mcpe/protocol/ServerboundPacket.php delete mode 100644 src/network/mcpe/protocol/SetActorDataPacket.php delete mode 100644 src/network/mcpe/protocol/SetActorLinkPacket.php delete mode 100644 src/network/mcpe/protocol/SetActorMotionPacket.php delete mode 100644 src/network/mcpe/protocol/SetCommandsEnabledPacket.php delete mode 100644 src/network/mcpe/protocol/SetDefaultGameTypePacket.php delete mode 100644 src/network/mcpe/protocol/SetDifficultyPacket.php delete mode 100644 src/network/mcpe/protocol/SetDisplayObjectivePacket.php delete mode 100644 src/network/mcpe/protocol/SetHealthPacket.php delete mode 100644 src/network/mcpe/protocol/SetLastHurtByPacket.php delete mode 100644 src/network/mcpe/protocol/SetLocalPlayerAsInitializedPacket.php delete mode 100644 src/network/mcpe/protocol/SetPlayerGameTypePacket.php delete mode 100644 src/network/mcpe/protocol/SetScorePacket.php delete mode 100644 src/network/mcpe/protocol/SetScoreboardIdentityPacket.php delete mode 100644 src/network/mcpe/protocol/SetSpawnPositionPacket.php delete mode 100644 src/network/mcpe/protocol/SetTimePacket.php delete mode 100644 src/network/mcpe/protocol/SetTitlePacket.php delete mode 100644 src/network/mcpe/protocol/SettingsCommandPacket.php delete mode 100644 src/network/mcpe/protocol/ShowCreditsPacket.php delete mode 100644 src/network/mcpe/protocol/ShowProfilePacket.php delete mode 100644 src/network/mcpe/protocol/ShowStoreOfferPacket.php delete mode 100644 src/network/mcpe/protocol/SimpleEventPacket.php delete mode 100644 src/network/mcpe/protocol/SimulationTypePacket.php delete mode 100644 src/network/mcpe/protocol/SpawnExperienceOrbPacket.php delete mode 100644 src/network/mcpe/protocol/SpawnParticleEffectPacket.php delete mode 100644 src/network/mcpe/protocol/StartGamePacket.php delete mode 100644 src/network/mcpe/protocol/StopSoundPacket.php delete mode 100644 src/network/mcpe/protocol/StructureBlockUpdatePacket.php delete mode 100644 src/network/mcpe/protocol/StructureTemplateDataRequestPacket.php delete mode 100644 src/network/mcpe/protocol/StructureTemplateDataResponsePacket.php delete mode 100644 src/network/mcpe/protocol/SubClientLoginPacket.php delete mode 100644 src/network/mcpe/protocol/SyncActorPropertyPacket.php delete mode 100644 src/network/mcpe/protocol/TakeItemActorPacket.php delete mode 100644 src/network/mcpe/protocol/TextPacket.php delete mode 100644 src/network/mcpe/protocol/TickSyncPacket.php delete mode 100644 src/network/mcpe/protocol/TransferPacket.php delete mode 100644 src/network/mcpe/protocol/UnknownPacket.php delete mode 100644 src/network/mcpe/protocol/UpdateAttributesPacket.php delete mode 100644 src/network/mcpe/protocol/UpdateBlockPacket.php delete mode 100644 src/network/mcpe/protocol/UpdateBlockSyncedPacket.php delete mode 100644 src/network/mcpe/protocol/UpdateEquipPacket.php delete mode 100644 src/network/mcpe/protocol/UpdatePlayerGameTypePacket.php delete mode 100644 src/network/mcpe/protocol/UpdateSoftEnumPacket.php delete mode 100644 src/network/mcpe/protocol/UpdateTradePacket.php delete mode 100644 src/network/mcpe/protocol/serializer/ItemTypeDictionary.php delete mode 100644 src/network/mcpe/protocol/serializer/NetworkNbtSerializer.php delete mode 100644 src/network/mcpe/protocol/serializer/PacketBatch.php delete mode 100644 src/network/mcpe/protocol/serializer/PacketSerializer.php delete mode 100644 src/network/mcpe/protocol/serializer/PacketSerializerContext.php delete mode 100644 src/network/mcpe/protocol/types/BlockPaletteEntry.php delete mode 100644 src/network/mcpe/protocol/types/BoolGameRule.php delete mode 100644 src/network/mcpe/protocol/types/CacheableNbt.php delete mode 100644 src/network/mcpe/protocol/types/ChunkCacheBlob.php delete mode 100644 src/network/mcpe/protocol/types/DeviceOS.php delete mode 100644 src/network/mcpe/protocol/types/DimensionIds.php delete mode 100644 src/network/mcpe/protocol/types/EducationEditionOffer.php delete mode 100644 src/network/mcpe/protocol/types/Enchant.php delete mode 100644 src/network/mcpe/protocol/types/EnchantOption.php delete mode 100644 src/network/mcpe/protocol/types/Experiments.php delete mode 100644 src/network/mcpe/protocol/types/FloatGameRule.php delete mode 100644 src/network/mcpe/protocol/types/GameMode.php delete mode 100644 src/network/mcpe/protocol/types/GameRule.php delete mode 100644 src/network/mcpe/protocol/types/GameRuleType.php delete mode 100644 src/network/mcpe/protocol/types/GeneratorType.php delete mode 100644 src/network/mcpe/protocol/types/InputMode.php delete mode 100644 src/network/mcpe/protocol/types/IntGameRule.php delete mode 100644 src/network/mcpe/protocol/types/ItemComponentPacketEntry.php delete mode 100644 src/network/mcpe/protocol/types/ItemTypeEntry.php delete mode 100644 src/network/mcpe/protocol/types/MapDecoration.php delete mode 100644 src/network/mcpe/protocol/types/MapTrackedObject.php delete mode 100644 src/network/mcpe/protocol/types/MultiplayerGameVisibility.php delete mode 100644 src/network/mcpe/protocol/types/ParticleIds.php delete mode 100644 src/network/mcpe/protocol/types/PlayMode.php delete mode 100644 src/network/mcpe/protocol/types/PlayerAuthInputFlags.php delete mode 100644 src/network/mcpe/protocol/types/PlayerListEntry.php delete mode 100644 src/network/mcpe/protocol/types/PlayerMovementSettings.php delete mode 100644 src/network/mcpe/protocol/types/PlayerMovementType.php delete mode 100644 src/network/mcpe/protocol/types/PlayerPermissions.php delete mode 100644 src/network/mcpe/protocol/types/ScorePacketEntry.php delete mode 100644 src/network/mcpe/protocol/types/ScoreboardIdentityPacketEntry.php delete mode 100644 src/network/mcpe/protocol/types/SpawnSettings.php delete mode 100644 src/network/mcpe/protocol/types/StructureEditorData.php delete mode 100644 src/network/mcpe/protocol/types/StructureSettings.php delete mode 100644 src/network/mcpe/protocol/types/UIProfile.php delete mode 100644 src/network/mcpe/protocol/types/command/CommandData.php delete mode 100644 src/network/mcpe/protocol/types/command/CommandEnum.php delete mode 100644 src/network/mcpe/protocol/types/command/CommandEnumConstraint.php delete mode 100644 src/network/mcpe/protocol/types/command/CommandOriginData.php delete mode 100644 src/network/mcpe/protocol/types/command/CommandOutputMessage.php delete mode 100644 src/network/mcpe/protocol/types/command/CommandParameter.php delete mode 100644 src/network/mcpe/protocol/types/entity/Attribute.php delete mode 100644 src/network/mcpe/protocol/types/entity/BlockPosMetadataProperty.php delete mode 100644 src/network/mcpe/protocol/types/entity/ByteMetadataProperty.php delete mode 100644 src/network/mcpe/protocol/types/entity/CompoundTagMetadataProperty.php delete mode 100644 src/network/mcpe/protocol/types/entity/EntityIds.php delete mode 100644 src/network/mcpe/protocol/types/entity/EntityLink.php delete mode 100644 src/network/mcpe/protocol/types/entity/EntityMetadataCollection.php delete mode 100644 src/network/mcpe/protocol/types/entity/EntityMetadataFlags.php delete mode 100644 src/network/mcpe/protocol/types/entity/EntityMetadataProperties.php delete mode 100644 src/network/mcpe/protocol/types/entity/EntityMetadataTypes.php delete mode 100644 src/network/mcpe/protocol/types/entity/FloatMetadataProperty.php delete mode 100644 src/network/mcpe/protocol/types/entity/IntMetadataProperty.php delete mode 100644 src/network/mcpe/protocol/types/entity/IntegerishMetadataProperty.php delete mode 100644 src/network/mcpe/protocol/types/entity/LongMetadataProperty.php delete mode 100644 src/network/mcpe/protocol/types/entity/MetadataProperty.php delete mode 100644 src/network/mcpe/protocol/types/entity/PlayerMetadataFlags.php delete mode 100644 src/network/mcpe/protocol/types/entity/ShortMetadataProperty.php delete mode 100644 src/network/mcpe/protocol/types/entity/StringMetadataProperty.php delete mode 100644 src/network/mcpe/protocol/types/entity/Vec3MetadataProperty.php delete mode 100644 src/network/mcpe/protocol/types/inventory/ContainerIds.php delete mode 100644 src/network/mcpe/protocol/types/inventory/CreativeContentEntry.php delete mode 100644 src/network/mcpe/protocol/types/inventory/InventoryTransactionChangedSlotsHack.php delete mode 100644 src/network/mcpe/protocol/types/inventory/ItemStack.php delete mode 100644 src/network/mcpe/protocol/types/inventory/ItemStackWrapper.php delete mode 100644 src/network/mcpe/protocol/types/inventory/MismatchTransactionData.php delete mode 100644 src/network/mcpe/protocol/types/inventory/NetworkInventoryAction.php delete mode 100644 src/network/mcpe/protocol/types/inventory/NormalTransactionData.php delete mode 100644 src/network/mcpe/protocol/types/inventory/ReleaseItemTransactionData.php delete mode 100644 src/network/mcpe/protocol/types/inventory/TransactionData.php delete mode 100644 src/network/mcpe/protocol/types/inventory/UIInventorySlotOffset.php delete mode 100644 src/network/mcpe/protocol/types/inventory/UseItemOnEntityTransactionData.php delete mode 100644 src/network/mcpe/protocol/types/inventory/UseItemTransactionData.php delete mode 100644 src/network/mcpe/protocol/types/inventory/WindowTypes.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackrequest/BeaconPaymentStackRequestAction.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackrequest/CraftRecipeAutoStackRequestAction.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackrequest/CraftRecipeOptionalStackRequestAction.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackrequest/CraftRecipeStackRequestAction.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackrequest/CraftRecipeStackRequestActionTrait.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackrequest/CraftingConsumeInputStackRequestAction.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackrequest/CraftingMarkSecondaryResultStackRequestAction.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackrequest/CreativeCreateStackRequestAction.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackrequest/DeprecatedCraftingNonImplementedStackRequestAction.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackrequest/DeprecatedCraftingResultsStackRequestAction.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackrequest/DestroyStackRequestAction.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackrequest/DisappearStackRequestActionTrait.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackrequest/DropStackRequestAction.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackrequest/ItemStackRequest.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackrequest/ItemStackRequestAction.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackrequest/ItemStackRequestActionType.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackrequest/ItemStackRequestSlotInfo.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackrequest/LabTableCombineStackRequestAction.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackrequest/MineBlockStackRequestAction.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackrequest/PlaceStackRequestAction.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackrequest/SwapStackRequestAction.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackrequest/TakeOrPlaceStackRequestActionTrait.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackrequest/TakeStackRequestAction.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackresponse/ItemStackResponse.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackresponse/ItemStackResponseContainerInfo.php delete mode 100644 src/network/mcpe/protocol/types/inventory/stackresponse/ItemStackResponseSlotInfo.php delete mode 100644 src/network/mcpe/protocol/types/login/AuthenticationData.php delete mode 100644 src/network/mcpe/protocol/types/login/ClientData.php delete mode 100644 src/network/mcpe/protocol/types/login/ClientDataAnimationFrame.php delete mode 100644 src/network/mcpe/protocol/types/login/ClientDataPersonaPieceTintColor.php delete mode 100644 src/network/mcpe/protocol/types/login/ClientDataPersonaSkinPiece.php delete mode 100644 src/network/mcpe/protocol/types/login/ClientDataToSkinDataHelper.php delete mode 100644 src/network/mcpe/protocol/types/login/JwtBodyRfc7519.php delete mode 100644 src/network/mcpe/protocol/types/login/JwtChain.php delete mode 100644 src/network/mcpe/protocol/types/login/JwtChainLinkBody.php delete mode 100644 src/network/mcpe/protocol/types/login/JwtHeader.php delete mode 100644 src/network/mcpe/protocol/types/recipe/FurnaceRecipe.php delete mode 100644 src/network/mcpe/protocol/types/recipe/MultiRecipe.php delete mode 100644 src/network/mcpe/protocol/types/recipe/PotionContainerChangeRecipe.php delete mode 100644 src/network/mcpe/protocol/types/recipe/PotionTypeRecipe.php delete mode 100644 src/network/mcpe/protocol/types/recipe/RecipeIngredient.php delete mode 100644 src/network/mcpe/protocol/types/recipe/RecipeWithTypeId.php delete mode 100644 src/network/mcpe/protocol/types/recipe/ShapedRecipe.php delete mode 100644 src/network/mcpe/protocol/types/recipe/ShapelessRecipe.php delete mode 100644 src/network/mcpe/protocol/types/resourcepacks/BehaviorPackInfoEntry.php delete mode 100644 src/network/mcpe/protocol/types/resourcepacks/ResourcePackInfoEntry.php delete mode 100644 src/network/mcpe/protocol/types/resourcepacks/ResourcePackStackEntry.php delete mode 100644 src/network/mcpe/protocol/types/resourcepacks/ResourcePackType.php delete mode 100644 src/network/mcpe/protocol/types/skin/PersonaPieceTintColor.php delete mode 100644 src/network/mcpe/protocol/types/skin/PersonaSkinPiece.php delete mode 100644 src/network/mcpe/protocol/types/skin/SkinAnimation.php delete mode 100644 src/network/mcpe/protocol/types/skin/SkinData.php delete mode 100644 src/network/mcpe/protocol/types/skin/SkinImage.php diff --git a/composer.json b/composer.json index 37ac6a7b0..1f4d6cac1 100644 --- a/composer.json +++ b/composer.json @@ -34,6 +34,7 @@ "adhocore/json-comment": "^1.1", "mdanter/ecc": "^1.0", "netresearch/jsonmapper": "^4.0", + "pocketmine/bedrock-protocol": "dev-master#88ae308a03e8e61ccfdddd42623efabe9e772b42", "pocketmine/binaryutils": "^0.2.1", "pocketmine/callback-validator": "^1.0.2", "pocketmine/classloader": "dev-master", diff --git a/composer.lock b/composer.lock index 4810dab99..56ce589d9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5456f8b834ba877a4c04d1cf5a933d63", + "content-hash": "4748ce46dd62b80f9a89791d7601b57f", "packages": [ { "name": "adhocore/json-comment", @@ -319,6 +319,54 @@ }, "time": "2020-12-01T19:48:11+00:00" }, + { + "name": "pocketmine/bedrock-protocol", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/pmmp/BedrockProtocol.git", + "reference": "88ae308a03e8e61ccfdddd42623efabe9e772b42" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/88ae308a03e8e61ccfdddd42623efabe9e772b42", + "reference": "88ae308a03e8e61ccfdddd42623efabe9e772b42", + "shasum": "" + }, + "require": { + "ext-json": "*", + "netresearch/jsonmapper": "^4.0", + "php": "^7.4 || ^8.0", + "pocketmine/binaryutils": "^0.2.0", + "pocketmine/color": "^0.2.0", + "pocketmine/math": "^0.3.0", + "pocketmine/nbt": "^0.3.0", + "ramsey/uuid": "^4.1" + }, + "require-dev": { + "phpstan/phpstan": "0.12.92", + "phpstan/phpstan-phpunit": "^0.12.21", + "phpstan/phpstan-strict-rules": "^0.12.10", + "phpunit/phpunit": "^9.5" + }, + "default-branch": true, + "type": "library", + "autoload": { + "psr-4": { + "pocketmine\\network\\mcpe\\protocol\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0" + ], + "description": "An implementation of the Minecraft: Bedrock Edition protocol in PHP", + "support": { + "issues": "https://github.com/pmmp/BedrockProtocol/issues", + "source": "https://github.com/pmmp/BedrockProtocol/tree/master" + }, + "time": "2021-07-14T19:29:34+00:00" + }, { "name": "pocketmine/binaryutils", "version": "0.2.1", @@ -3547,6 +3595,7 @@ "aliases": [], "minimum-stability": "stable", "stability-flags": { + "pocketmine/bedrock-protocol": 20, "pocketmine/classloader": 20, "pocketmine/spl": 20 }, diff --git a/src/network/mcpe/protocol/ActorEventPacket.php b/src/network/mcpe/protocol/ActorEventPacket.php deleted file mode 100644 index a6cc893ab..000000000 --- a/src/network/mcpe/protocol/ActorEventPacket.php +++ /dev/null @@ -1,124 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class ActorEventPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::ACTOR_EVENT_PACKET; - - public const JUMP = 1; - public const HURT_ANIMATION = 2; - public const DEATH_ANIMATION = 3; - public const ARM_SWING = 4; - public const STOP_ATTACK = 5; - public const TAME_FAIL = 6; - public const TAME_SUCCESS = 7; - public const SHAKE_WET = 8; - public const USE_ITEM = 9; - public const EAT_GRASS_ANIMATION = 10; - public const FISH_HOOK_BUBBLE = 11; - public const FISH_HOOK_POSITION = 12; - public const FISH_HOOK_HOOK = 13; - public const FISH_HOOK_TEASE = 14; - public const SQUID_INK_CLOUD = 15; - public const ZOMBIE_VILLAGER_CURE = 16; - - public const RESPAWN = 18; - public const IRON_GOLEM_OFFER_FLOWER = 19; - public const IRON_GOLEM_WITHDRAW_FLOWER = 20; - public const LOVE_PARTICLES = 21; //breeding - public const VILLAGER_ANGRY = 22; - public const VILLAGER_HAPPY = 23; - public const WITCH_SPELL_PARTICLES = 24; - public const FIREWORK_PARTICLES = 25; - public const IN_LOVE_PARTICLES = 26; - public const SILVERFISH_SPAWN_ANIMATION = 27; - public const GUARDIAN_ATTACK = 28; - public const WITCH_DRINK_POTION = 29; - public const WITCH_THROW_POTION = 30; - public const MINECART_TNT_PRIME_FUSE = 31; - public const CREEPER_PRIME_FUSE = 32; - public const AIR_SUPPLY_EXPIRED = 33; - public const PLAYER_ADD_XP_LEVELS = 34; - public const ELDER_GUARDIAN_CURSE = 35; - public const AGENT_ARM_SWING = 36; - public const ENDER_DRAGON_DEATH = 37; - public const DUST_PARTICLES = 38; //not sure what this is - public const ARROW_SHAKE = 39; - - public const EATING_ITEM = 57; - - public const BABY_ANIMAL_FEED = 60; //green particles, like bonemeal on crops - public const DEATH_SMOKE_CLOUD = 61; - public const COMPLETE_TRADE = 62; - public const REMOVE_LEASH = 63; //data 1 = cut leash - - public const CONSUME_TOTEM = 65; - public const PLAYER_CHECK_TREASURE_HUNTER_ACHIEVEMENT = 66; //mojang... - public const ENTITY_SPAWN = 67; //used for MinecraftEventing stuff, not needed - public const DRAGON_PUKE = 68; //they call this puke particles - public const ITEM_ENTITY_MERGE = 69; - public const START_SWIM = 70; - public const BALLOON_POP = 71; - public const TREASURE_HUNT = 72; - public const AGENT_SUMMON = 73; - public const CHARGED_CROSSBOW = 74; - public const FALL = 75; - - //TODO: add more events - - /** @var int */ - public $entityRuntimeId; - /** @var int */ - public $event; - /** @var int */ - public $data = 0; - - public static function create(int $entityRuntimeId, int $eventId, int $eventData) : self{ - $result = new self; - $result->entityRuntimeId = $entityRuntimeId; - $result->event = $eventId; - $result->data = $eventData; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityRuntimeId = $in->getEntityRuntimeId(); - $this->event = $in->getByte(); - $this->data = $in->getVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityRuntimeId($this->entityRuntimeId); - $out->putByte($this->event); - $out->putVarInt($this->data); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleActorEvent($this); - } -} diff --git a/src/network/mcpe/protocol/ActorPickRequestPacket.php b/src/network/mcpe/protocol/ActorPickRequestPacket.php deleted file mode 100644 index bf04e560a..000000000 --- a/src/network/mcpe/protocol/ActorPickRequestPacket.php +++ /dev/null @@ -1,51 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class ActorPickRequestPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::ACTOR_PICK_REQUEST_PACKET; - - /** @var int */ - public $entityUniqueId; - /** @var int */ - public $hotbarSlot; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityUniqueId = $in->getLLong(); - $this->hotbarSlot = $in->getByte(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putLLong($this->entityUniqueId); - $out->putByte($this->hotbarSlot); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleActorPickRequest($this); - } -} diff --git a/src/network/mcpe/protocol/AddActorPacket.php b/src/network/mcpe/protocol/AddActorPacket.php deleted file mode 100644 index 356797ade..000000000 --- a/src/network/mcpe/protocol/AddActorPacket.php +++ /dev/null @@ -1,119 +0,0 @@ - - -use pocketmine\math\Vector3; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\entity\Attribute; -use pocketmine\network\mcpe\protocol\types\entity\EntityLink; -use pocketmine\network\mcpe\protocol\types\entity\MetadataProperty; -use function count; - -class AddActorPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::ADD_ACTOR_PACKET; - - /** @var int|null */ - public $entityUniqueId = null; //TODO - /** @var int */ - public $entityRuntimeId; - /** @var string */ - public $type; - /** @var Vector3 */ - public $position; - /** @var Vector3|null */ - public $motion; - /** @var float */ - public $pitch = 0.0; - /** @var float */ - public $yaw = 0.0; - /** @var float */ - public $headYaw = 0.0; - - /** @var Attribute[] */ - public $attributes = []; - /** - * @var MetadataProperty[] - * @phpstan-var array - */ - public $metadata = []; - /** @var EntityLink[] */ - public $links = []; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityUniqueId = $in->getEntityUniqueId(); - $this->entityRuntimeId = $in->getEntityRuntimeId(); - $this->type = $in->getString(); - $this->position = $in->getVector3(); - $this->motion = $in->getVector3(); - $this->pitch = $in->getLFloat(); - $this->yaw = $in->getLFloat(); - $this->headYaw = $in->getLFloat(); - - $attrCount = $in->getUnsignedVarInt(); - for($i = 0; $i < $attrCount; ++$i){ - $id = $in->getString(); - $min = $in->getLFloat(); - $current = $in->getLFloat(); - $max = $in->getLFloat(); - $this->attributes[] = new Attribute($id, $min, $max, $current, $current); - } - - $this->metadata = $in->getEntityMetadata(); - $linkCount = $in->getUnsignedVarInt(); - for($i = 0; $i < $linkCount; ++$i){ - $this->links[] = $in->getEntityLink(); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId); - $out->putEntityRuntimeId($this->entityRuntimeId); - $out->putString($this->type); - $out->putVector3($this->position); - $out->putVector3Nullable($this->motion); - $out->putLFloat($this->pitch); - $out->putLFloat($this->yaw); - $out->putLFloat($this->headYaw); - - $out->putUnsignedVarInt(count($this->attributes)); - foreach($this->attributes as $attribute){ - $out->putString($attribute->getId()); - $out->putLFloat($attribute->getMin()); - $out->putLFloat($attribute->getCurrent()); - $out->putLFloat($attribute->getMax()); - } - - $out->putEntityMetadata($this->metadata); - $out->putUnsignedVarInt(count($this->links)); - foreach($this->links as $link){ - $out->putEntityLink($link); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleAddActor($this); - } -} diff --git a/src/network/mcpe/protocol/AddBehaviorTreePacket.php b/src/network/mcpe/protocol/AddBehaviorTreePacket.php deleted file mode 100644 index 30052c748..000000000 --- a/src/network/mcpe/protocol/AddBehaviorTreePacket.php +++ /dev/null @@ -1,47 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class AddBehaviorTreePacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::ADD_BEHAVIOR_TREE_PACKET; - - /** @var string */ - public $behaviorTreeJson; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->behaviorTreeJson = $in->getString(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->behaviorTreeJson); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleAddBehaviorTree($this); - } -} diff --git a/src/network/mcpe/protocol/AddEntityPacket.php b/src/network/mcpe/protocol/AddEntityPacket.php deleted file mode 100644 index a8c33d130..000000000 --- a/src/network/mcpe/protocol/AddEntityPacket.php +++ /dev/null @@ -1,57 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class AddEntityPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::ADD_ENTITY_PACKET; - - /** @var int */ - private $entityNetId; - - public static function create(int $entityNetId) : self{ - $result = new self; - $result->entityNetId = $entityNetId; - return $result; - } - - public function getEntityNetId() : int{ - return $this->entityNetId; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityNetId = $in->getUnsignedVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt($this->entityNetId); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleAddEntity($this); - } -} diff --git a/src/network/mcpe/protocol/AddItemActorPacket.php b/src/network/mcpe/protocol/AddItemActorPacket.php deleted file mode 100644 index bf6f445dd..000000000 --- a/src/network/mcpe/protocol/AddItemActorPacket.php +++ /dev/null @@ -1,77 +0,0 @@ - - -use pocketmine\math\Vector3; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\entity\MetadataProperty; -use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper; - -class AddItemActorPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::ADD_ITEM_ACTOR_PACKET; - - /** @var int|null */ - public $entityUniqueId = null; //TODO - /** @var int */ - public $entityRuntimeId; - /** @var ItemStackWrapper */ - public $item; - /** @var Vector3 */ - public $position; - /** @var Vector3|null */ - public $motion; - /** - * @var MetadataProperty[] - * @phpstan-var array - */ - public $metadata = []; - /** @var bool */ - public $isFromFishing = false; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityUniqueId = $in->getEntityUniqueId(); - $this->entityRuntimeId = $in->getEntityRuntimeId(); - $this->item = ItemStackWrapper::read($in); - $this->position = $in->getVector3(); - $this->motion = $in->getVector3(); - $this->metadata = $in->getEntityMetadata(); - $this->isFromFishing = $in->getBool(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId); - $out->putEntityRuntimeId($this->entityRuntimeId); - $this->item->write($out); - $out->putVector3($this->position); - $out->putVector3Nullable($this->motion); - $out->putEntityMetadata($this->metadata); - $out->putBool($this->isFromFishing); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleAddItemActor($this); - } -} diff --git a/src/network/mcpe/protocol/AddPaintingPacket.php b/src/network/mcpe/protocol/AddPaintingPacket.php deleted file mode 100644 index 0f8a38ed7..000000000 --- a/src/network/mcpe/protocol/AddPaintingPacket.php +++ /dev/null @@ -1,64 +0,0 @@ - - -use pocketmine\math\Vector3; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class AddPaintingPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::ADD_PAINTING_PACKET; - - /** @var int|null */ - public $entityUniqueId = null; - /** @var int */ - public $entityRuntimeId; - /** @var Vector3 */ - public $position; - /** @var int */ - public $direction; - /** @var string */ - public $title; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityUniqueId = $in->getEntityUniqueId(); - $this->entityRuntimeId = $in->getEntityRuntimeId(); - $this->position = $in->getVector3(); - $this->direction = $in->getVarInt(); - $this->title = $in->getString(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId); - $out->putEntityRuntimeId($this->entityRuntimeId); - $out->putVector3($this->position); - $out->putVarInt($this->direction); - $out->putString($this->title); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleAddPainting($this); - } -} diff --git a/src/network/mcpe/protocol/AddPlayerPacket.php b/src/network/mcpe/protocol/AddPlayerPacket.php deleted file mode 100644 index c3d45cd77..000000000 --- a/src/network/mcpe/protocol/AddPlayerPacket.php +++ /dev/null @@ -1,156 +0,0 @@ - - -use pocketmine\math\Vector3; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\DeviceOS; -use pocketmine\network\mcpe\protocol\types\entity\EntityLink; -use pocketmine\network\mcpe\protocol\types\entity\MetadataProperty; -use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper; -use Ramsey\Uuid\UuidInterface; -use function count; - -class AddPlayerPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::ADD_PLAYER_PACKET; - - /** @var UuidInterface */ - public $uuid; - /** @var string */ - public $username; - /** @var int|null */ - public $entityUniqueId = null; //TODO - /** @var int */ - public $entityRuntimeId; - /** @var string */ - public $platformChatId = ""; - /** @var Vector3 */ - public $position; - /** @var Vector3|null */ - public $motion; - /** @var float */ - public $pitch = 0.0; - /** @var float */ - public $yaw = 0.0; - /** @var float|null */ - public $headYaw = null; //TODO - /** @var ItemStackWrapper */ - public $item; - /** - * @var MetadataProperty[] - * @phpstan-var array - */ - public $metadata = []; - - //TODO: adventure settings stuff - /** @var int */ - public $uvarint1 = 0; - /** @var int */ - public $uvarint2 = 0; - /** @var int */ - public $uvarint3 = 0; - /** @var int */ - public $uvarint4 = 0; - /** @var int */ - public $uvarint5 = 0; - - /** @var int */ - public $long1 = 0; - - /** @var EntityLink[] */ - public $links = []; - - /** @var string */ - public $deviceId = ""; //TODO: fill player's device ID (???) - /** @var int */ - public $buildPlatform = DeviceOS::UNKNOWN; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->uuid = $in->getUUID(); - $this->username = $in->getString(); - $this->entityUniqueId = $in->getEntityUniqueId(); - $this->entityRuntimeId = $in->getEntityRuntimeId(); - $this->platformChatId = $in->getString(); - $this->position = $in->getVector3(); - $this->motion = $in->getVector3(); - $this->pitch = $in->getLFloat(); - $this->yaw = $in->getLFloat(); - $this->headYaw = $in->getLFloat(); - $this->item = ItemStackWrapper::read($in); - $this->metadata = $in->getEntityMetadata(); - - $this->uvarint1 = $in->getUnsignedVarInt(); - $this->uvarint2 = $in->getUnsignedVarInt(); - $this->uvarint3 = $in->getUnsignedVarInt(); - $this->uvarint4 = $in->getUnsignedVarInt(); - $this->uvarint5 = $in->getUnsignedVarInt(); - - $this->long1 = $in->getLLong(); - - $linkCount = $in->getUnsignedVarInt(); - for($i = 0; $i < $linkCount; ++$i){ - $this->links[$i] = $in->getEntityLink(); - } - - $this->deviceId = $in->getString(); - $this->buildPlatform = $in->getLInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUUID($this->uuid); - $out->putString($this->username); - $out->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId); - $out->putEntityRuntimeId($this->entityRuntimeId); - $out->putString($this->platformChatId); - $out->putVector3($this->position); - $out->putVector3Nullable($this->motion); - $out->putLFloat($this->pitch); - $out->putLFloat($this->yaw); - $out->putLFloat($this->headYaw ?? $this->yaw); - $this->item->write($out); - $out->putEntityMetadata($this->metadata); - - $out->putUnsignedVarInt($this->uvarint1); - $out->putUnsignedVarInt($this->uvarint2); - $out->putUnsignedVarInt($this->uvarint3); - $out->putUnsignedVarInt($this->uvarint4); - $out->putUnsignedVarInt($this->uvarint5); - - $out->putLLong($this->long1); - - $out->putUnsignedVarInt(count($this->links)); - foreach($this->links as $link){ - $out->putEntityLink($link); - } - - $out->putString($this->deviceId); - $out->putLInt($this->buildPlatform); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleAddPlayer($this); - } -} diff --git a/src/network/mcpe/protocol/AddVolumeEntityPacket.php b/src/network/mcpe/protocol/AddVolumeEntityPacket.php deleted file mode 100644 index 612fe9042..000000000 --- a/src/network/mcpe/protocol/AddVolumeEntityPacket.php +++ /dev/null @@ -1,65 +0,0 @@ - - -use pocketmine\nbt\tag\CompoundTag; -use pocketmine\nbt\TreeRoot; -use pocketmine\network\mcpe\protocol\serializer\NetworkNbtSerializer; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class AddVolumeEntityPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::ADD_VOLUME_ENTITY_PACKET; - - /** @var int */ - private $entityNetId; - /** @var CompoundTag */ - private $data; - - public static function create(int $entityNetId, CompoundTag $data) : self{ - $result = new self; - $result->entityNetId = $entityNetId; - $result->data = $data; - return $result; - } - - public function getEntityNetId() : int{ return $this->entityNetId; } - - public function getData() : CompoundTag{ return $this->data; } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityNetId = $in->getUnsignedVarInt(); - $this->data = $in->getNbtCompoundRoot(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt($this->entityNetId); - $out->put((new NetworkNbtSerializer())->write(new TreeRoot($this->data))); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleAddVolumeEntity($this); - } -} diff --git a/src/network/mcpe/protocol/AdventureSettingsPacket.php b/src/network/mcpe/protocol/AdventureSettingsPacket.php deleted file mode 100644 index 4d69ba9b9..000000000 --- a/src/network/mcpe/protocol/AdventureSettingsPacket.php +++ /dev/null @@ -1,123 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\PlayerPermissions; - -class AdventureSettingsPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::ADVENTURE_SETTINGS_PACKET; - - public const PERMISSION_NORMAL = 0; - public const PERMISSION_OPERATOR = 1; - public const PERMISSION_HOST = 2; - public const PERMISSION_AUTOMATION = 3; - public const PERMISSION_ADMIN = 4; - - /** - * This constant is used to identify flags that should be set on the second field. In a sensible world, these - * flags would all be set on the same packet field, but as of MCPE 1.2, the new abilities flags have for some - * reason been assigned a separate field. - */ - public const BITFLAG_SECOND_SET = 1 << 16; - - public const WORLD_IMMUTABLE = 0x01; - public const NO_PVP = 0x02; - - public const AUTO_JUMP = 0x20; - public const ALLOW_FLIGHT = 0x40; - public const NO_CLIP = 0x80; - public const WORLD_BUILDER = 0x100; - public const FLYING = 0x200; - public const MUTED = 0x400; - - public const MINE = 0x01 | self::BITFLAG_SECOND_SET; - public const DOORS_AND_SWITCHES = 0x02 | self::BITFLAG_SECOND_SET; - public const OPEN_CONTAINERS = 0x04 | self::BITFLAG_SECOND_SET; - public const ATTACK_PLAYERS = 0x08 | self::BITFLAG_SECOND_SET; - public const ATTACK_MOBS = 0x10 | self::BITFLAG_SECOND_SET; - public const OPERATOR = 0x20 | self::BITFLAG_SECOND_SET; - public const TELEPORT = 0x80 | self::BITFLAG_SECOND_SET; - public const BUILD = 0x100 | self::BITFLAG_SECOND_SET; - public const DEFAULT = 0x200 | self::BITFLAG_SECOND_SET; - - /** @var int */ - public $flags = 0; - /** @var int */ - public $commandPermission = self::PERMISSION_NORMAL; - /** @var int */ - public $flags2 = -1; - /** @var int */ - public $playerPermission = PlayerPermissions::MEMBER; - /** @var int */ - public $customFlags = 0; //... - /** @var int */ - public $entityUniqueId; //This is a little-endian long, NOT a var-long. (WTF Mojang) - - protected function decodePayload(PacketSerializer $in) : void{ - $this->flags = $in->getUnsignedVarInt(); - $this->commandPermission = $in->getUnsignedVarInt(); - $this->flags2 = $in->getUnsignedVarInt(); - $this->playerPermission = $in->getUnsignedVarInt(); - $this->customFlags = $in->getUnsignedVarInt(); - $this->entityUniqueId = $in->getLLong(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt($this->flags); - $out->putUnsignedVarInt($this->commandPermission); - $out->putUnsignedVarInt($this->flags2); - $out->putUnsignedVarInt($this->playerPermission); - $out->putUnsignedVarInt($this->customFlags); - $out->putLLong($this->entityUniqueId); - } - - public function getFlag(int $flag) : bool{ - if(($flag & self::BITFLAG_SECOND_SET) !== 0){ - return ($this->flags2 & $flag) !== 0; - } - - return ($this->flags & $flag) !== 0; - } - - public function setFlag(int $flag, bool $value) : void{ - if(($flag & self::BITFLAG_SECOND_SET) !== 0){ - $flagSet =& $this->flags2; - }else{ - $flagSet =& $this->flags; - } - - if($value){ - $flagSet |= $flag; - }else{ - $flagSet &= ~$flag; - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleAdventureSettings($this); - } -} diff --git a/src/network/mcpe/protocol/AnimateEntityPacket.php b/src/network/mcpe/protocol/AnimateEntityPacket.php deleted file mode 100644 index c8202bb75..000000000 --- a/src/network/mcpe/protocol/AnimateEntityPacket.php +++ /dev/null @@ -1,108 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use function count; - -class AnimateEntityPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::ANIMATE_ENTITY_PACKET; - - /** @var string */ - private $animation; - /** @var string */ - private $nextState; - /** @var string */ - private $stopExpression; - /** @var string */ - private $controller; - /** @var float */ - private $blendOutTime; - /** - * @var int[] - * @phpstan-var list - */ - private $actorRuntimeIds; - - /** - * @param int[] $actorRuntimeIds - * @phpstan-param list $actorRuntimeIds - */ - public static function create(string $animation, string $nextState, string $stopExpression, string $controller, float $blendOutTime, array $actorRuntimeIds) : self{ - $result = new self; - $result->animation = $animation; - $result->nextState = $nextState; - $result->stopExpression = $stopExpression; - $result->controller = $controller; - $result->blendOutTime = $blendOutTime; - $result->actorRuntimeIds = $actorRuntimeIds; - return $result; - } - - public function getAnimation() : string{ return $this->animation; } - - public function getNextState() : string{ return $this->nextState; } - - public function getStopExpression() : string{ return $this->stopExpression; } - - public function getController() : string{ return $this->controller; } - - public function getBlendOutTime() : float{ return $this->blendOutTime; } - - /** - * @return int[] - * @phpstan-return list - */ - public function getActorRuntimeIds() : array{ return $this->actorRuntimeIds; } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->animation = $in->getString(); - $this->nextState = $in->getString(); - $this->stopExpression = $in->getString(); - $this->controller = $in->getString(); - $this->blendOutTime = $in->getLFloat(); - $this->actorRuntimeIds = []; - for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){ - $this->actorRuntimeIds[] = $in->getEntityRuntimeId(); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->animation); - $out->putString($this->nextState); - $out->putString($this->stopExpression); - $out->putString($this->controller); - $out->putLFloat($this->blendOutTime); - $out->putUnsignedVarInt(count($this->actorRuntimeIds)); - foreach($this->actorRuntimeIds as $id){ - $out->putEntityRuntimeId($id); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleAnimateEntity($this); - } -} diff --git a/src/network/mcpe/protocol/AnimatePacket.php b/src/network/mcpe/protocol/AnimatePacket.php deleted file mode 100644 index 95aea0479..000000000 --- a/src/network/mcpe/protocol/AnimatePacket.php +++ /dev/null @@ -1,80 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class AnimatePacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::ANIMATE_PACKET; - - public const ACTION_SWING_ARM = 1; - - public const ACTION_STOP_SLEEP = 3; - public const ACTION_CRITICAL_HIT = 4; - public const ACTION_MAGICAL_CRITICAL_HIT = 5; - public const ACTION_ROW_RIGHT = 128; - public const ACTION_ROW_LEFT = 129; - - /** @var int */ - public $action; - /** @var int */ - public $entityRuntimeId; - /** @var float */ - public $float = 0.0; //TODO (Boat rowing time?) - - public static function create(int $entityRuntimeId, int $actionId) : self{ - $result = new self; - $result->entityRuntimeId = $entityRuntimeId; - $result->action = $actionId; - return $result; - } - - public static function boatHack(int $entityRuntimeId, int $actionId, float $data) : self{ - $result = self::create($entityRuntimeId, $actionId); - $result->float = $data; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->action = $in->getVarInt(); - $this->entityRuntimeId = $in->getEntityRuntimeId(); - if(($this->action & 0x80) !== 0){ - $this->float = $in->getLFloat(); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putVarInt($this->action); - $out->putEntityRuntimeId($this->entityRuntimeId); - if(($this->action & 0x80) !== 0){ - $out->putLFloat($this->float); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleAnimate($this); - } -} diff --git a/src/network/mcpe/protocol/AnvilDamagePacket.php b/src/network/mcpe/protocol/AnvilDamagePacket.php deleted file mode 100644 index 7f6616dde..000000000 --- a/src/network/mcpe/protocol/AnvilDamagePacket.php +++ /dev/null @@ -1,78 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class AnvilDamagePacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::ANVIL_DAMAGE_PACKET; - - /** @var int */ - private $x; - /** @var int */ - private $y; - /** @var int */ - private $z; - /** @var int */ - private $damageAmount; - - public static function create(int $x, int $y, int $z, int $damageAmount) : self{ - $result = new self; - [$result->x, $result->y, $result->z] = [$x, $y, $z]; - $result->damageAmount = $damageAmount; - return $result; - } - - public function getDamageAmount() : int{ - return $this->damageAmount; - } - - public function getX() : int{ - return $this->x; - } - - public function getY() : int{ - return $this->y; - } - - public function getZ() : int{ - return $this->z; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->damageAmount = $in->getByte(); - $in->getBlockPosition($this->x, $this->y, $this->z); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putByte($this->damageAmount); - $out->putBlockPosition($this->x, $this->y, $this->z); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleAnvilDamage($this); - } -} diff --git a/src/network/mcpe/protocol/AutomationClientConnectPacket.php b/src/network/mcpe/protocol/AutomationClientConnectPacket.php deleted file mode 100644 index e9ae268c0..000000000 --- a/src/network/mcpe/protocol/AutomationClientConnectPacket.php +++ /dev/null @@ -1,47 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class AutomationClientConnectPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::AUTOMATION_CLIENT_CONNECT_PACKET; - - /** @var string */ - public $serverUri; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->serverUri = $in->getString(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->serverUri); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleAutomationClientConnect($this); - } -} diff --git a/src/network/mcpe/protocol/AvailableActorIdentifiersPacket.php b/src/network/mcpe/protocol/AvailableActorIdentifiersPacket.php deleted file mode 100644 index 93f0bab99..000000000 --- a/src/network/mcpe/protocol/AvailableActorIdentifiersPacket.php +++ /dev/null @@ -1,60 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\CacheableNbt; - -class AvailableActorIdentifiersPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::AVAILABLE_ACTOR_IDENTIFIERS_PACKET; - - /** - * @var CacheableNbt - * @phpstan-var CacheableNbt<\pocketmine\nbt\tag\CompoundTag> - */ - public $identifiers; - - /** - * @phpstan-param CacheableNbt<\pocketmine\nbt\tag\CompoundTag> $nbt - */ - public static function create(CacheableNbt $nbt) : self{ - $result = new self; - $result->identifiers = $nbt; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->identifiers = new CacheableNbt($in->getNbtCompoundRoot()); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->put($this->identifiers->getEncodedNbt()); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleAvailableActorIdentifiers($this); - } -} diff --git a/src/network/mcpe/protocol/AvailableCommandsPacket.php b/src/network/mcpe/protocol/AvailableCommandsPacket.php deleted file mode 100644 index 4ad40a69f..000000000 --- a/src/network/mcpe/protocol/AvailableCommandsPacket.php +++ /dev/null @@ -1,487 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\command\CommandData; -use pocketmine\network\mcpe\protocol\types\command\CommandEnum; -use pocketmine\network\mcpe\protocol\types\command\CommandEnumConstraint; -use pocketmine\network\mcpe\protocol\types\command\CommandParameter; -use pocketmine\utils\BinaryDataException; -use function array_search; -use function count; -use function dechex; - -class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::AVAILABLE_COMMANDS_PACKET; - - /** - * This flag is set on all types EXCEPT the POSTFIX type. Not completely sure what this is for, but it is required - * for the argtype to work correctly. VALID seems as good a name as any. - */ - public const ARG_FLAG_VALID = 0x100000; - - /** - * Basic parameter types. These must be combined with the ARG_FLAG_VALID constant. - * ARG_FLAG_VALID | (type const) - */ - public const ARG_TYPE_INT = 0x01; - public const ARG_TYPE_FLOAT = 0x03; - public const ARG_TYPE_VALUE = 0x04; - public const ARG_TYPE_WILDCARD_INT = 0x05; - public const ARG_TYPE_OPERATOR = 0x06; - public const ARG_TYPE_TARGET = 0x07; - public const ARG_TYPE_WILDCARD_TARGET = 0x08; - - public const ARG_TYPE_FILEPATH = 0x10; - - public const ARG_TYPE_STRING = 0x20; - - public const ARG_TYPE_POSITION = 0x28; - - public const ARG_TYPE_MESSAGE = 0x2c; - - public const ARG_TYPE_RAWTEXT = 0x2e; - - public const ARG_TYPE_JSON = 0x32; - - public const ARG_TYPE_COMMAND = 0x3f; - - /** - * Enums are a little different: they are composed as follows: - * ARG_FLAG_ENUM | ARG_FLAG_VALID | (enum index) - */ - public const ARG_FLAG_ENUM = 0x200000; - - /** This is used for /xp L. It can only be applied to integer parameters. */ - public const ARG_FLAG_POSTFIX = 0x1000000; - - public const HARDCODED_ENUM_NAMES = [ - "CommandName" => true - ]; - - /** - * @var CommandData[] - * List of command data, including name, description, alias indexes and parameters. - */ - public $commandData = []; - - /** - * @var CommandEnum[] - * List of enums which aren't directly referenced by any vanilla command. - * This is used for the `CommandName` enum, which is a magic enum used by the `command` argument type. - */ - public $hardcodedEnums = []; - - /** - * @var CommandEnum[] - * List of dynamic command enums, also referred to as "soft" enums. These can by dynamically updated mid-game - * without resending this packet. - */ - public $softEnums = []; - - /** - * @var CommandEnumConstraint[] - * List of constraints for enum members. Used to constrain gamerules that can bechanged in nocheats mode and more. - */ - public $enumConstraints = []; - - protected function decodePayload(PacketSerializer $in) : void{ - /** @var string[] $enumValues */ - $enumValues = []; - for($i = 0, $enumValuesCount = $in->getUnsignedVarInt(); $i < $enumValuesCount; ++$i){ - $enumValues[] = $in->getString(); - } - - /** @var string[] $postfixes */ - $postfixes = []; - for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){ - $postfixes[] = $in->getString(); - } - - /** @var CommandEnum[] $enums */ - $enums = []; - for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){ - $enums[] = $enum = $this->getEnum($enumValues, $in); - if(isset(self::HARDCODED_ENUM_NAMES[$enum->getName()])){ - $this->hardcodedEnums[] = $enum; - } - } - - for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){ - $this->commandData[] = $this->getCommandData($enums, $postfixes, $in); - } - - for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){ - $this->softEnums[] = $this->getSoftEnum($in); - } - - for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){ - $this->enumConstraints[] = $this->getEnumConstraint($enums, $enumValues, $in); - } - } - - /** - * @param string[] $enumValueList - * - * @throws PacketDecodeException - * @throws BinaryDataException - */ - protected function getEnum(array $enumValueList, PacketSerializer $in) : CommandEnum{ - $enumName = $in->getString(); - $enumValues = []; - - $listSize = count($enumValueList); - - for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){ - $index = $this->getEnumValueIndex($listSize, $in); - if(!isset($enumValueList[$index])){ - throw new PacketDecodeException("Invalid enum value index $index"); - } - //Get the enum value from the initial pile of mess - $enumValues[] = $enumValueList[$index]; - } - - return new CommandEnum($enumName, $enumValues); - } - - /** - * @throws BinaryDataException - */ - protected function getSoftEnum(PacketSerializer $in) : CommandEnum{ - $enumName = $in->getString(); - $enumValues = []; - - for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){ - //Get the enum value from the initial pile of mess - $enumValues[] = $in->getString(); - } - - return new CommandEnum($enumName, $enumValues); - } - - /** - * @param int[] $enumValueMap - */ - protected function putEnum(CommandEnum $enum, array $enumValueMap, PacketSerializer $out) : void{ - $out->putString($enum->getName()); - - $values = $enum->getValues(); - $out->putUnsignedVarInt(count($values)); - $listSize = count($enumValueMap); - foreach($values as $value){ - $index = $enumValueMap[$value] ?? -1; - if($index === -1){ - throw new \InvalidStateException("Enum value '$value' not found"); - } - $this->putEnumValueIndex($index, $listSize, $out); - } - } - - protected function putSoftEnum(CommandEnum $enum, PacketSerializer $out) : void{ - $out->putString($enum->getName()); - - $values = $enum->getValues(); - $out->putUnsignedVarInt(count($values)); - foreach($values as $value){ - $out->putString($value); - } - } - - /** - * @throws BinaryDataException - */ - protected function getEnumValueIndex(int $valueCount, PacketSerializer $in) : int{ - if($valueCount < 256){ - return $in->getByte(); - }elseif($valueCount < 65536){ - return $in->getLShort(); - }else{ - return $in->getLInt(); - } - } - - protected function putEnumValueIndex(int $index, int $valueCount, PacketSerializer $out) : void{ - if($valueCount < 256){ - $out->putByte($index); - }elseif($valueCount < 65536){ - $out->putLShort($index); - }else{ - $out->putLInt($index); - } - } - - /** - * @param CommandEnum[] $enums - * @param string[] $enumValues - * - * @throws PacketDecodeException - * @throws BinaryDataException - */ - protected function getEnumConstraint(array $enums, array $enumValues, PacketSerializer $in) : CommandEnumConstraint{ - //wtf, what was wrong with an offset inside the enum? :( - $valueIndex = $in->getLInt(); - if(!isset($enumValues[$valueIndex])){ - throw new PacketDecodeException("Enum constraint refers to unknown enum value index $valueIndex"); - } - $enumIndex = $in->getLInt(); - if(!isset($enums[$enumIndex])){ - throw new PacketDecodeException("Enum constraint refers to unknown enum index $enumIndex"); - } - $enum = $enums[$enumIndex]; - $valueOffset = array_search($enumValues[$valueIndex], $enum->getValues(), true); - if($valueOffset === false){ - throw new PacketDecodeException("Value \"" . $enumValues[$valueIndex] . "\" does not belong to enum \"" . $enum->getName() . "\""); - } - - $constraintIds = []; - for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){ - $constraintIds[] = $in->getByte(); - } - - return new CommandEnumConstraint($enum, $valueOffset, $constraintIds); - } - - /** - * @param int[] $enumIndexes string enum name -> int index - * @param int[] $enumValueIndexes string value -> int index - */ - protected function putEnumConstraint(CommandEnumConstraint $constraint, array $enumIndexes, array $enumValueIndexes, PacketSerializer $out) : void{ - $out->putLInt($enumValueIndexes[$constraint->getAffectedValue()]); - $out->putLInt($enumIndexes[$constraint->getEnum()->getName()]); - $out->putUnsignedVarInt(count($constraint->getConstraints())); - foreach($constraint->getConstraints() as $v){ - $out->putByte($v); - } - } - - /** - * @param CommandEnum[] $enums - * @param string[] $postfixes - * - * @throws PacketDecodeException - * @throws BinaryDataException - */ - protected function getCommandData(array $enums, array $postfixes, PacketSerializer $in) : CommandData{ - $name = $in->getString(); - $description = $in->getString(); - $flags = $in->getLShort(); - $permission = $in->getByte(); - $aliases = $enums[$in->getLInt()] ?? null; - $overloads = []; - - for($overloadIndex = 0, $overloadCount = $in->getUnsignedVarInt(); $overloadIndex < $overloadCount; ++$overloadIndex){ - $overloads[$overloadIndex] = []; - for($paramIndex = 0, $paramCount = $in->getUnsignedVarInt(); $paramIndex < $paramCount; ++$paramIndex){ - $parameter = new CommandParameter(); - $parameter->paramName = $in->getString(); - $parameter->paramType = $in->getLInt(); - $parameter->isOptional = $in->getBool(); - $parameter->flags = $in->getByte(); - - if(($parameter->paramType & self::ARG_FLAG_ENUM) !== 0){ - $index = ($parameter->paramType & 0xffff); - $parameter->enum = $enums[$index] ?? null; - if($parameter->enum === null){ - throw new PacketDecodeException("deserializing $name parameter $parameter->paramName: expected enum at $index, but got none"); - } - }elseif(($parameter->paramType & self::ARG_FLAG_POSTFIX) !== 0){ - $index = ($parameter->paramType & 0xffff); - $parameter->postfix = $postfixes[$index] ?? null; - if($parameter->postfix === null){ - throw new PacketDecodeException("deserializing $name parameter $parameter->paramName: expected postfix at $index, but got none"); - } - }elseif(($parameter->paramType & self::ARG_FLAG_VALID) === 0){ - throw new PacketDecodeException("deserializing $name parameter $parameter->paramName: Invalid parameter type 0x" . dechex($parameter->paramType)); - } - - $overloads[$overloadIndex][$paramIndex] = $parameter; - } - } - - return new CommandData($name, $description, $flags, $permission, $aliases, $overloads); - } - - /** - * @param int[] $enumIndexes string enum name -> int index - * @param int[] $postfixIndexes - */ - protected function putCommandData(CommandData $data, array $enumIndexes, array $postfixIndexes, PacketSerializer $out) : void{ - $out->putString($data->name); - $out->putString($data->description); - $out->putLShort($data->flags); - $out->putByte($data->permission); - - if($data->aliases !== null){ - $out->putLInt($enumIndexes[$data->aliases->getName()] ?? -1); - }else{ - $out->putLInt(-1); - } - - $out->putUnsignedVarInt(count($data->overloads)); - foreach($data->overloads as $overload){ - /** @var CommandParameter[] $overload */ - $out->putUnsignedVarInt(count($overload)); - foreach($overload as $parameter){ - $out->putString($parameter->paramName); - - if($parameter->enum !== null){ - $type = self::ARG_FLAG_ENUM | self::ARG_FLAG_VALID | ($enumIndexes[$parameter->enum->getName()] ?? -1); - }elseif($parameter->postfix !== null){ - $key = $postfixIndexes[$parameter->postfix] ?? -1; - if($key === -1){ - throw new \InvalidStateException("Postfix '$parameter->postfix' not in postfixes array"); - } - $type = self::ARG_FLAG_POSTFIX | $key; - }else{ - $type = $parameter->paramType; - } - - $out->putLInt($type); - $out->putBool($parameter->isOptional); - $out->putByte($parameter->flags); - } - } - } - - /** - * @param string[] $postfixes - * @phpstan-param array $postfixes - */ - private function argTypeToString(int $argtype, array $postfixes) : string{ - if(($argtype & self::ARG_FLAG_VALID) !== 0){ - if(($argtype & self::ARG_FLAG_ENUM) !== 0){ - return "stringenum (" . ($argtype & 0xffff) . ")"; - } - - switch($argtype & 0xffff){ - case self::ARG_TYPE_INT: - return "int"; - case self::ARG_TYPE_FLOAT: - return "float"; - case self::ARG_TYPE_VALUE: - return "mixed"; - case self::ARG_TYPE_TARGET: - return "target"; - case self::ARG_TYPE_STRING: - return "string"; - case self::ARG_TYPE_POSITION: - return "xyz"; - case self::ARG_TYPE_MESSAGE: - return "message"; - case self::ARG_TYPE_RAWTEXT: - return "text"; - case self::ARG_TYPE_JSON: - return "json"; - case self::ARG_TYPE_COMMAND: - return "command"; - } - }elseif(($argtype & self::ARG_FLAG_POSTFIX) !== 0){ - $postfix = $postfixes[$argtype & 0xffff]; - - return "int (postfix $postfix)"; - }else{ - throw new \UnexpectedValueException("Unknown arg type 0x" . dechex($argtype)); - } - - return "unknown ($argtype)"; - } - - protected function encodePayload(PacketSerializer $out) : void{ - /** @var int[] $enumValueIndexes */ - $enumValueIndexes = []; - /** @var int[] $postfixIndexes */ - $postfixIndexes = []; - /** @var int[] $enumIndexes */ - $enumIndexes = []; - /** @var CommandEnum[] $enums */ - $enums = []; - - $addEnumFn = static function(CommandEnum $enum) use (&$enums, &$enumIndexes, &$enumValueIndexes) : void{ - if(!isset($enumIndexes[$enum->getName()])){ - $enums[$enumIndexes[$enum->getName()] = count($enumIndexes)] = $enum; - } - foreach($enum->getValues() as $str){ - $enumValueIndexes[$str] = $enumValueIndexes[$str] ?? count($enumValueIndexes); //latest index - } - }; - foreach($this->hardcodedEnums as $enum){ - $addEnumFn($enum); - } - foreach($this->commandData as $commandData){ - if($commandData->aliases !== null){ - $addEnumFn($commandData->aliases); - } - /** @var CommandParameter[] $overload */ - foreach($commandData->overloads as $overload){ - /** @var CommandParameter $parameter */ - foreach($overload as $parameter){ - if($parameter->enum !== null){ - $addEnumFn($parameter->enum); - } - - if($parameter->postfix !== null){ - $postfixIndexes[$parameter->postfix] = $postfixIndexes[$parameter->postfix] ?? count($postfixIndexes); - } - } - } - } - - $out->putUnsignedVarInt(count($enumValueIndexes)); - foreach($enumValueIndexes as $enumValue => $index){ - $out->putString((string) $enumValue); //stupid PHP key casting D: - } - - $out->putUnsignedVarInt(count($postfixIndexes)); - foreach($postfixIndexes as $postfix => $index){ - $out->putString((string) $postfix); //stupid PHP key casting D: - } - - $out->putUnsignedVarInt(count($enums)); - foreach($enums as $enum){ - $this->putEnum($enum, $enumValueIndexes, $out); - } - - $out->putUnsignedVarInt(count($this->commandData)); - foreach($this->commandData as $data){ - $this->putCommandData($data, $enumIndexes, $postfixIndexes, $out); - } - - $out->putUnsignedVarInt(count($this->softEnums)); - foreach($this->softEnums as $enum){ - $this->putSoftEnum($enum, $out); - } - - $out->putUnsignedVarInt(count($this->enumConstraints)); - foreach($this->enumConstraints as $constraint){ - $this->putEnumConstraint($constraint, $enumIndexes, $enumValueIndexes, $out); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleAvailableCommands($this); - } -} diff --git a/src/network/mcpe/protocol/BiomeDefinitionListPacket.php b/src/network/mcpe/protocol/BiomeDefinitionListPacket.php deleted file mode 100644 index 6ef045632..000000000 --- a/src/network/mcpe/protocol/BiomeDefinitionListPacket.php +++ /dev/null @@ -1,60 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\CacheableNbt; - -class BiomeDefinitionListPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::BIOME_DEFINITION_LIST_PACKET; - - /** - * @var CacheableNbt - * @phpstan-var CacheableNbt<\pocketmine\nbt\tag\CompoundTag> - */ - public $defs; - - /** - * @phpstan-param CacheableNbt<\pocketmine\nbt\tag\CompoundTag> $nbt - */ - public static function create(CacheableNbt $nbt) : self{ - $result = new self; - $result->defs = $nbt; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->defs = new CacheableNbt($in->getNbtCompoundRoot()); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->put($this->defs->getEncodedNbt()); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleBiomeDefinitionList($this); - } -} diff --git a/src/network/mcpe/protocol/BlockActorDataPacket.php b/src/network/mcpe/protocol/BlockActorDataPacket.php deleted file mode 100644 index 7f111aa5d..000000000 --- a/src/network/mcpe/protocol/BlockActorDataPacket.php +++ /dev/null @@ -1,69 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\CacheableNbt; - -class BlockActorDataPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::BLOCK_ACTOR_DATA_PACKET; - - /** @var int */ - public $x; - /** @var int */ - public $y; - /** @var int */ - public $z; - /** - * @var CacheableNbt - * @phpstan-var CacheableNbt<\pocketmine\nbt\tag\CompoundTag> - */ - public $namedtag; - - /** - * @phpstan-param CacheableNbt<\pocketmine\nbt\tag\CompoundTag> $nbt - */ - public static function create(int $x, int $y, int $z, CacheableNbt $nbt) : self{ - $result = new self; - [$result->x, $result->y, $result->z] = [$x, $y, $z]; - $result->namedtag = $nbt; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $in->getBlockPosition($this->x, $this->y, $this->z); - $this->namedtag = new CacheableNbt($in->getNbtCompoundRoot()); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putBlockPosition($this->x, $this->y, $this->z); - $out->put($this->namedtag->getEncodedNbt()); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleBlockActorData($this); - } -} diff --git a/src/network/mcpe/protocol/BlockEventPacket.php b/src/network/mcpe/protocol/BlockEventPacket.php deleted file mode 100644 index bc706c29e..000000000 --- a/src/network/mcpe/protocol/BlockEventPacket.php +++ /dev/null @@ -1,70 +0,0 @@ - - -use pocketmine\math\Vector3; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class BlockEventPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::BLOCK_EVENT_PACKET; - - /** @var int */ - public $x; - /** @var int */ - public $y; - /** @var int */ - public $z; - /** @var int */ - public $eventType; - /** @var int */ - public $eventData; - - public static function create(int $eventId, int $eventData, Vector3 $pos) : self{ - $pk = new self; - $pk->eventType = $eventId; - $pk->eventData = $eventData; - $pk->x = $pos->getFloorX(); - $pk->y = $pos->getFloorY(); - $pk->z = $pos->getFloorZ(); - return $pk; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $in->getBlockPosition($this->x, $this->y, $this->z); - $this->eventType = $in->getVarInt(); - $this->eventData = $in->getVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putBlockPosition($this->x, $this->y, $this->z); - $out->putVarInt($this->eventType); - $out->putVarInt($this->eventData); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleBlockEvent($this); - } -} diff --git a/src/network/mcpe/protocol/BlockPickRequestPacket.php b/src/network/mcpe/protocol/BlockPickRequestPacket.php deleted file mode 100644 index 51a62955e..000000000 --- a/src/network/mcpe/protocol/BlockPickRequestPacket.php +++ /dev/null @@ -1,59 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class BlockPickRequestPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::BLOCK_PICK_REQUEST_PACKET; - - /** @var int */ - public $blockX; - /** @var int */ - public $blockY; - /** @var int */ - public $blockZ; - /** @var bool */ - public $addUserData = false; - /** @var int */ - public $hotbarSlot; - - protected function decodePayload(PacketSerializer $in) : void{ - $in->getSignedBlockPosition($this->blockX, $this->blockY, $this->blockZ); - $this->addUserData = $in->getBool(); - $this->hotbarSlot = $in->getByte(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putSignedBlockPosition($this->blockX, $this->blockY, $this->blockZ); - $out->putBool($this->addUserData); - $out->putByte($this->hotbarSlot); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleBlockPickRequest($this); - } -} diff --git a/src/network/mcpe/protocol/BookEditPacket.php b/src/network/mcpe/protocol/BookEditPacket.php deleted file mode 100644 index f080ad62a..000000000 --- a/src/network/mcpe/protocol/BookEditPacket.php +++ /dev/null @@ -1,119 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class BookEditPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::BOOK_EDIT_PACKET; - - public const TYPE_REPLACE_PAGE = 0; - public const TYPE_ADD_PAGE = 1; - public const TYPE_DELETE_PAGE = 2; - public const TYPE_SWAP_PAGES = 3; - public const TYPE_SIGN_BOOK = 4; - - /** @var int */ - public $type; - /** @var int */ - public $inventorySlot; - /** @var int */ - public $pageNumber; - /** @var int */ - public $secondaryPageNumber; - - /** @var string */ - public $text; - /** @var string */ - public $photoName; - - /** @var string */ - public $title; - /** @var string */ - public $author; - /** @var string */ - public $xuid; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->type = $in->getByte(); - $this->inventorySlot = $in->getByte(); - - switch($this->type){ - case self::TYPE_REPLACE_PAGE: - case self::TYPE_ADD_PAGE: - $this->pageNumber = $in->getByte(); - $this->text = $in->getString(); - $this->photoName = $in->getString(); - break; - case self::TYPE_DELETE_PAGE: - $this->pageNumber = $in->getByte(); - break; - case self::TYPE_SWAP_PAGES: - $this->pageNumber = $in->getByte(); - $this->secondaryPageNumber = $in->getByte(); - break; - case self::TYPE_SIGN_BOOK: - $this->title = $in->getString(); - $this->author = $in->getString(); - $this->xuid = $in->getString(); - break; - default: - throw new PacketDecodeException("Unknown book edit type $this->type!"); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putByte($this->type); - $out->putByte($this->inventorySlot); - - switch($this->type){ - case self::TYPE_REPLACE_PAGE: - case self::TYPE_ADD_PAGE: - $out->putByte($this->pageNumber); - $out->putString($this->text); - $out->putString($this->photoName); - break; - case self::TYPE_DELETE_PAGE: - $out->putByte($this->pageNumber); - break; - case self::TYPE_SWAP_PAGES: - $out->putByte($this->pageNumber); - $out->putByte($this->secondaryPageNumber); - break; - case self::TYPE_SIGN_BOOK: - $out->putString($this->title); - $out->putString($this->author); - $out->putString($this->xuid); - break; - default: - throw new \InvalidArgumentException("Unknown book edit type $this->type!"); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleBookEdit($this); - } -} diff --git a/src/network/mcpe/protocol/BossEventPacket.php b/src/network/mcpe/protocol/BossEventPacket.php deleted file mode 100644 index 46b7f078b..000000000 --- a/src/network/mcpe/protocol/BossEventPacket.php +++ /dev/null @@ -1,184 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class BossEventPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::BOSS_EVENT_PACKET; - - /* S2C: Shows the boss-bar to the player. */ - public const TYPE_SHOW = 0; - /* C2S: Registers a player to a boss fight. */ - public const TYPE_REGISTER_PLAYER = 1; - /* S2C: Removes the boss-bar from the client. */ - public const TYPE_HIDE = 2; - /* C2S: Unregisters a player from a boss fight. */ - public const TYPE_UNREGISTER_PLAYER = 3; - /* S2C: Sets the bar percentage. */ - public const TYPE_HEALTH_PERCENT = 4; - /* S2C: Sets title of the bar. */ - public const TYPE_TITLE = 5; - /* S2C: Not sure on this. Includes color and overlay fields, plus an unknown short. TODO: check this */ - public const TYPE_UNKNOWN_6 = 6; - /* S2C: Not implemented :( Intended to alter bar appearance, but these currently produce no effect on client-side whatsoever. */ - public const TYPE_TEXTURE = 7; - - /** @var int */ - public $bossEid; - /** @var int */ - public $eventType; - - /** @var int (long) */ - public $playerEid; - /** @var float */ - public $healthPercent; - /** @var string */ - public $title; - /** @var int */ - public $unknownShort; - /** @var int */ - public $color; - /** @var int */ - public $overlay; - - private static function base(int $bossEntityUniqueId, int $eventId) : self{ - $result = new self; - $result->bossEid = $bossEntityUniqueId; - $result->eventType = $eventId; - return $result; - } - - public static function show(int $bossEntityUniqueId, string $title, float $healthPercent, int $unknownShort = 0) : self{ - $result = self::base($bossEntityUniqueId, self::TYPE_SHOW); - $result->title = $title; - $result->healthPercent = $healthPercent; - $result->unknownShort = $unknownShort; - $result->color = 0; //hardcoded due to being useless - $result->overlay = 0; - return $result; - } - - public static function hide(int $bossEntityUniqueId) : self{ - return self::base($bossEntityUniqueId, self::TYPE_HIDE); - } - - public static function registerPlayer(int $bossEntityUniqueId, int $playerEntityUniqueId) : self{ - $result = self::base($bossEntityUniqueId, self::TYPE_REGISTER_PLAYER); - $result->playerEid = $playerEntityUniqueId; - return $result; - } - - public static function unregisterPlayer(int $bossEntityUniqueId, int $playerEntityUniqueId) : self{ - $result = self::base($bossEntityUniqueId, self::TYPE_UNREGISTER_PLAYER); - $result->playerEid = $playerEntityUniqueId; - return $result; - } - - public static function healthPercent(int $bossEntityUniqueId, float $healthPercent) : self{ - $result = self::base($bossEntityUniqueId, self::TYPE_HEALTH_PERCENT); - $result->healthPercent = $healthPercent; - return $result; - } - - public static function title(int $bossEntityUniqueId, string $title) : self{ - $result = self::base($bossEntityUniqueId, self::TYPE_TITLE); - $result->title = $title; - return $result; - } - - public static function unknown6(int $bossEntityUniqueId, int $unknownShort) : self{ - $result = self::base($bossEntityUniqueId, self::TYPE_UNKNOWN_6); - $result->unknownShort = $unknownShort; - $result->color = 0; //hardcoded due to being useless - $result->overlay = 0; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->bossEid = $in->getEntityUniqueId(); - $this->eventType = $in->getUnsignedVarInt(); - switch($this->eventType){ - case self::TYPE_REGISTER_PLAYER: - case self::TYPE_UNREGISTER_PLAYER: - $this->playerEid = $in->getEntityUniqueId(); - break; - /** @noinspection PhpMissingBreakStatementInspection */ - case self::TYPE_SHOW: - $this->title = $in->getString(); - $this->healthPercent = $in->getLFloat(); - /** @noinspection PhpMissingBreakStatementInspection */ - case self::TYPE_UNKNOWN_6: - $this->unknownShort = $in->getLShort(); - case self::TYPE_TEXTURE: - $this->color = $in->getUnsignedVarInt(); - $this->overlay = $in->getUnsignedVarInt(); - break; - case self::TYPE_HEALTH_PERCENT: - $this->healthPercent = $in->getLFloat(); - break; - case self::TYPE_TITLE: - $this->title = $in->getString(); - break; - default: - break; - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityUniqueId($this->bossEid); - $out->putUnsignedVarInt($this->eventType); - switch($this->eventType){ - case self::TYPE_REGISTER_PLAYER: - case self::TYPE_UNREGISTER_PLAYER: - $out->putEntityUniqueId($this->playerEid); - break; - /** @noinspection PhpMissingBreakStatementInspection */ - case self::TYPE_SHOW: - $out->putString($this->title); - $out->putLFloat($this->healthPercent); - /** @noinspection PhpMissingBreakStatementInspection */ - case self::TYPE_UNKNOWN_6: - $out->putLShort($this->unknownShort); - case self::TYPE_TEXTURE: - $out->putUnsignedVarInt($this->color); - $out->putUnsignedVarInt($this->overlay); - break; - case self::TYPE_HEALTH_PERCENT: - $out->putLFloat($this->healthPercent); - break; - case self::TYPE_TITLE: - $out->putString($this->title); - break; - default: - break; - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleBossEvent($this); - } -} diff --git a/src/network/mcpe/protocol/CameraPacket.php b/src/network/mcpe/protocol/CameraPacket.php deleted file mode 100644 index fac61d86c..000000000 --- a/src/network/mcpe/protocol/CameraPacket.php +++ /dev/null @@ -1,51 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class CameraPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::CAMERA_PACKET; - - /** @var int */ - public $cameraUniqueId; - /** @var int */ - public $playerUniqueId; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->cameraUniqueId = $in->getEntityUniqueId(); - $this->playerUniqueId = $in->getEntityUniqueId(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityUniqueId($this->cameraUniqueId); - $out->putEntityUniqueId($this->playerUniqueId); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleCamera($this); - } -} diff --git a/src/network/mcpe/protocol/CameraShakePacket.php b/src/network/mcpe/protocol/CameraShakePacket.php deleted file mode 100644 index 03c1fe67a..000000000 --- a/src/network/mcpe/protocol/CameraShakePacket.php +++ /dev/null @@ -1,82 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class CameraShakePacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::CAMERA_SHAKE_PACKET; - - public const TYPE_POSITIONAL = 0; - public const TYPE_ROTATIONAL = 1; - - public const ACTION_ADD = 0; - public const ACTION_STOP = 1; - - /** @var float */ - private $intensity; - /** @var float */ - private $duration; - /** @var int */ - private $shakeType; - /** @var int */ - private $shakeAction; - - public static function create(float $intensity, float $duration, int $shakeType, int $shakeAction) : self{ - $result = new self; - $result->intensity = $intensity; - $result->duration = $duration; - $result->shakeType = $shakeType; - $result->shakeAction = $shakeAction; - return $result; - } - - public function getIntensity() : float{ return $this->intensity; } - - public function getDuration() : float{ return $this->duration; } - - public function getShakeType() : int{ return $this->shakeType; } - - public function getShakeAction() : int{ return $this->shakeAction; } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->intensity = $in->getLFloat(); - $this->duration = $in->getLFloat(); - $this->shakeType = $in->getByte(); - $this->shakeAction = $in->getByte(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putLFloat($this->intensity); - $out->putLFloat($this->duration); - $out->putByte($this->shakeType); - $out->putByte($this->shakeAction); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleCameraShake($this); - } -} diff --git a/src/network/mcpe/protocol/ChangeDimensionPacket.php b/src/network/mcpe/protocol/ChangeDimensionPacket.php deleted file mode 100644 index 7e654b56e..000000000 --- a/src/network/mcpe/protocol/ChangeDimensionPacket.php +++ /dev/null @@ -1,56 +0,0 @@ - - -use pocketmine\math\Vector3; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class ChangeDimensionPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::CHANGE_DIMENSION_PACKET; - - /** @var int */ - public $dimension; - /** @var Vector3 */ - public $position; - /** @var bool */ - public $respawn = false; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->dimension = $in->getVarInt(); - $this->position = $in->getVector3(); - $this->respawn = $in->getBool(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putVarInt($this->dimension); - $out->putVector3($this->position); - $out->putBool($this->respawn); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleChangeDimension($this); - } -} diff --git a/src/network/mcpe/protocol/ChunkRadiusUpdatedPacket.php b/src/network/mcpe/protocol/ChunkRadiusUpdatedPacket.php deleted file mode 100644 index 25a06caf7..000000000 --- a/src/network/mcpe/protocol/ChunkRadiusUpdatedPacket.php +++ /dev/null @@ -1,53 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class ChunkRadiusUpdatedPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::CHUNK_RADIUS_UPDATED_PACKET; - - /** @var int */ - public $radius; - - public static function create(int $radius) : self{ - $result = new self; - $result->radius = $radius; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->radius = $in->getVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putVarInt($this->radius); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleChunkRadiusUpdated($this); - } -} diff --git a/src/network/mcpe/protocol/ClientCacheBlobStatusPacket.php b/src/network/mcpe/protocol/ClientCacheBlobStatusPacket.php deleted file mode 100644 index 6470bfc7e..000000000 --- a/src/network/mcpe/protocol/ClientCacheBlobStatusPacket.php +++ /dev/null @@ -1,93 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use function count; - -class ClientCacheBlobStatusPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::CLIENT_CACHE_BLOB_STATUS_PACKET; - - /** @var int[] xxHash64 subchunk data hashes */ - private $hitHashes = []; - /** @var int[] xxHash64 subchunk data hashes */ - private $missHashes = []; - - /** - * @param int[] $hitHashes - * @param int[] $missHashes - */ - public static function create(array $hitHashes, array $missHashes) : self{ - //type checks - (static function(int ...$hashes) : void{})(...$hitHashes); - (static function(int ...$hashes) : void{})(...$missHashes); - - $result = new self; - $result->hitHashes = $hitHashes; - $result->missHashes = $missHashes; - return $result; - } - - /** - * @return int[] - */ - public function getHitHashes() : array{ - return $this->hitHashes; - } - - /** - * @return int[] - */ - public function getMissHashes() : array{ - return $this->missHashes; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $missCount = $in->getUnsignedVarInt(); - $hitCount = $in->getUnsignedVarInt(); - for($i = 0; $i < $missCount; ++$i){ - $this->missHashes[] = $in->getLLong(); - } - for($i = 0; $i < $hitCount; ++$i){ - $this->hitHashes[] = $in->getLLong(); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt(count($this->missHashes)); - $out->putUnsignedVarInt(count($this->hitHashes)); - foreach($this->missHashes as $hash){ - $out->putLLong($hash); - } - foreach($this->hitHashes as $hash){ - $out->putLLong($hash); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleClientCacheBlobStatus($this); - } -} diff --git a/src/network/mcpe/protocol/ClientCacheMissResponsePacket.php b/src/network/mcpe/protocol/ClientCacheMissResponsePacket.php deleted file mode 100644 index afa4441fa..000000000 --- a/src/network/mcpe/protocol/ClientCacheMissResponsePacket.php +++ /dev/null @@ -1,76 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\ChunkCacheBlob; -use function count; - -class ClientCacheMissResponsePacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::CLIENT_CACHE_MISS_RESPONSE_PACKET; - - /** @var ChunkCacheBlob[] */ - private $blobs = []; - - /** - * @param ChunkCacheBlob[] $blobs - */ - public static function create(array $blobs) : self{ - //type check - (static function(ChunkCacheBlob ...$blobs) : void{})(...$blobs); - - $result = new self; - $result->blobs = $blobs; - return $result; - } - - /** - * @return ChunkCacheBlob[] - */ - public function getBlobs() : array{ - return $this->blobs; - } - - protected function decodePayload(PacketSerializer $in) : void{ - for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){ - $hash = $in->getLLong(); - $payload = $in->getString(); - $this->blobs[] = new ChunkCacheBlob($hash, $payload); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt(count($this->blobs)); - foreach($this->blobs as $blob){ - $out->putLLong($blob->getHash()); - $out->putString($blob->getPayload()); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleClientCacheMissResponse($this); - } -} diff --git a/src/network/mcpe/protocol/ClientCacheStatusPacket.php b/src/network/mcpe/protocol/ClientCacheStatusPacket.php deleted file mode 100644 index 15f493cdc..000000000 --- a/src/network/mcpe/protocol/ClientCacheStatusPacket.php +++ /dev/null @@ -1,57 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class ClientCacheStatusPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::CLIENT_CACHE_STATUS_PACKET; - - /** @var bool */ - private $enabled; - - public static function create(bool $enabled) : self{ - $result = new self; - $result->enabled = $enabled; - return $result; - } - - public function isEnabled() : bool{ - return $this->enabled; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->enabled = $in->getBool(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putBool($this->enabled); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleClientCacheStatus($this); - } -} diff --git a/src/network/mcpe/protocol/ClientToServerHandshakePacket.php b/src/network/mcpe/protocol/ClientToServerHandshakePacket.php deleted file mode 100644 index 7457d27ee..000000000 --- a/src/network/mcpe/protocol/ClientToServerHandshakePacket.php +++ /dev/null @@ -1,48 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class ClientToServerHandshakePacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::CLIENT_TO_SERVER_HANDSHAKE_PACKET; - - public function canBeSentBeforeLogin() : bool{ - return true; - } - - protected function decodePayload(PacketSerializer $in) : void{ - //No payload - } - - protected function encodePayload(PacketSerializer $out) : void{ - //No payload - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleClientToServerHandshake($this); - } -} diff --git a/src/network/mcpe/protocol/ClientboundDebugRendererPacket.php b/src/network/mcpe/protocol/ClientboundDebugRendererPacket.php deleted file mode 100644 index 35a182ce9..000000000 --- a/src/network/mcpe/protocol/ClientboundDebugRendererPacket.php +++ /dev/null @@ -1,137 +0,0 @@ - - -use pocketmine\math\Vector3; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class ClientboundDebugRendererPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::CLIENTBOUND_DEBUG_RENDERER_PACKET; - - public const TYPE_CLEAR = 1; - public const TYPE_ADD_CUBE = 2; - - /** @var int */ - private $type; - - //TODO: if more types are added, we'll probably want to make a separate data type and interfaces - /** @var string */ - private $text; - /** @var Vector3 */ - private $position; - /** @var float */ - private $red; - /** @var float */ - private $green; - /** @var float */ - private $blue; - /** @var float */ - private $alpha; - /** @var int */ - private $durationMillis; - - private static function base(int $type) : self{ - $result = new self; - $result->type = $type; - return $result; - } - - public static function clear() : self{ return self::base(self::TYPE_CLEAR); } - - public static function addCube(string $text, Vector3 $position, float $red, float $green, float $blue, float $alpha, int $durationMillis) : self{ - $result = self::base(self::TYPE_ADD_CUBE); - $result->text = $text; - $result->position = $position; - $result->red = $red; - $result->green = $green; - $result->blue = $blue; - $result->alpha = $alpha; - $result->durationMillis = $durationMillis; - return $result; - } - - public function getType() : int{ return $this->type; } - - public function getText() : string{ return $this->text; } - - public function getPosition() : Vector3{ return $this->position; } - - public function getRed() : float{ return $this->red; } - - public function getGreen() : float{ return $this->green; } - - public function getBlue() : float{ return $this->blue; } - - public function getAlpha() : float{ return $this->alpha; } - - public function getDurationMillis() : int{ return $this->durationMillis; } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->type = $in->getLInt(); - - switch($this->type){ - case self::TYPE_CLEAR: - //NOOP - break; - case self::TYPE_ADD_CUBE: - $this->text = $in->getString(); - $this->position = $in->getVector3(); - $this->red = $in->getLFloat(); - $this->green = $in->getLFloat(); - $this->blue = $in->getLFloat(); - $this->alpha = $in->getLFloat(); - $this->durationMillis = $in->getLLong(); - break; - default: - throw new \UnexpectedValueException("Unknown type " . $this->type); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putLInt($this->type); - - switch($this->type){ - case self::TYPE_CLEAR: - //NOOP - break; - case self::TYPE_ADD_CUBE: - $out->putString($this->text); - $out->putVector3($this->position); - $out->putLFloat($this->red); - $out->putLFloat($this->green); - $out->putLFloat($this->blue); - $out->putLFloat($this->alpha); - $out->putLLong($this->durationMillis); - break; - default: - throw new \InvalidArgumentException("Unknown type " . $this->type); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleClientboundDebugRenderer($this); - } -} diff --git a/src/network/mcpe/protocol/ClientboundMapItemDataPacket.php b/src/network/mcpe/protocol/ClientboundMapItemDataPacket.php deleted file mode 100644 index d92077cf1..000000000 --- a/src/network/mcpe/protocol/ClientboundMapItemDataPacket.php +++ /dev/null @@ -1,208 +0,0 @@ - - -use pocketmine\color\Color; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\DimensionIds; -use pocketmine\network\mcpe\protocol\types\MapDecoration; -use pocketmine\network\mcpe\protocol\types\MapTrackedObject; -use function count; -#ifndef COMPILE -use pocketmine\utils\Binary; -#endif - -class ClientboundMapItemDataPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::CLIENTBOUND_MAP_ITEM_DATA_PACKET; - - public const BITFLAG_TEXTURE_UPDATE = 0x02; - public const BITFLAG_DECORATION_UPDATE = 0x04; - - /** @var int */ - public $mapId; - /** @var int */ - public $type; - /** @var int */ - public $dimensionId = DimensionIds::OVERWORLD; - /** @var bool */ - public $isLocked = false; - - /** @var int[] */ - public $eids = []; - /** @var int */ - public $scale; - - /** @var MapTrackedObject[] */ - public $trackedEntities = []; - /** @var MapDecoration[] */ - public $decorations = []; - - /** @var int */ - public $width; - /** @var int */ - public $height; - /** @var int */ - public $xOffset = 0; - /** @var int */ - public $yOffset = 0; - /** @var Color[][] */ - public $colors = []; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->mapId = $in->getEntityUniqueId(); - $this->type = $in->getUnsignedVarInt(); - $this->dimensionId = $in->getByte(); - $this->isLocked = $in->getBool(); - - if(($this->type & 0x08) !== 0){ - $count = $in->getUnsignedVarInt(); - for($i = 0; $i < $count; ++$i){ - $this->eids[] = $in->getEntityUniqueId(); - } - } - - if(($this->type & (0x08 | self::BITFLAG_DECORATION_UPDATE | self::BITFLAG_TEXTURE_UPDATE)) !== 0){ //Decoration bitflag or colour bitflag - $this->scale = $in->getByte(); - } - - if(($this->type & self::BITFLAG_DECORATION_UPDATE) !== 0){ - for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){ - $object = new MapTrackedObject(); - $object->type = $in->getLInt(); - if($object->type === MapTrackedObject::TYPE_BLOCK){ - $in->getBlockPosition($object->x, $object->y, $object->z); - }elseif($object->type === MapTrackedObject::TYPE_ENTITY){ - $object->entityUniqueId = $in->getEntityUniqueId(); - }else{ - throw new PacketDecodeException("Unknown map object type $object->type"); - } - $this->trackedEntities[] = $object; - } - - for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){ - $icon = $in->getByte(); - $rotation = $in->getByte(); - $xOffset = $in->getByte(); - $yOffset = $in->getByte(); - $label = $in->getString(); - $color = Color::fromRGBA(Binary::flipIntEndianness($in->getUnsignedVarInt())); - $this->decorations[] = new MapDecoration($icon, $rotation, $xOffset, $yOffset, $label, $color); - } - } - - if(($this->type & self::BITFLAG_TEXTURE_UPDATE) !== 0){ - $this->width = $in->getVarInt(); - $this->height = $in->getVarInt(); - $this->xOffset = $in->getVarInt(); - $this->yOffset = $in->getVarInt(); - - $count = $in->getUnsignedVarInt(); - if($count !== $this->width * $this->height){ - throw new PacketDecodeException("Expected colour count of " . ($this->height * $this->width) . " (height $this->height * width $this->width), got $count"); - } - - for($y = 0; $y < $this->height; ++$y){ - for($x = 0; $x < $this->width; ++$x){ - $this->colors[$y][$x] = Color::fromRGBA(Binary::flipIntEndianness($in->getUnsignedVarInt())); - } - } - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityUniqueId($this->mapId); - - $type = 0; - if(($eidsCount = count($this->eids)) > 0){ - $type |= 0x08; - } - if(($decorationCount = count($this->decorations)) > 0){ - $type |= self::BITFLAG_DECORATION_UPDATE; - } - if(count($this->colors) > 0){ - $type |= self::BITFLAG_TEXTURE_UPDATE; - } - - $out->putUnsignedVarInt($type); - $out->putByte($this->dimensionId); - $out->putBool($this->isLocked); - - if(($type & 0x08) !== 0){ //TODO: find out what these are for - $out->putUnsignedVarInt($eidsCount); - foreach($this->eids as $eid){ - $out->putEntityUniqueId($eid); - } - } - - if(($type & (0x08 | self::BITFLAG_TEXTURE_UPDATE | self::BITFLAG_DECORATION_UPDATE)) !== 0){ - $out->putByte($this->scale); - } - - if(($type & self::BITFLAG_DECORATION_UPDATE) !== 0){ - $out->putUnsignedVarInt(count($this->trackedEntities)); - foreach($this->trackedEntities as $object){ - $out->putLInt($object->type); - if($object->type === MapTrackedObject::TYPE_BLOCK){ - $out->putBlockPosition($object->x, $object->y, $object->z); - }elseif($object->type === MapTrackedObject::TYPE_ENTITY){ - $out->putEntityUniqueId($object->entityUniqueId); - }else{ - throw new \InvalidArgumentException("Unknown map object type $object->type"); - } - } - - $out->putUnsignedVarInt($decorationCount); - foreach($this->decorations as $decoration){ - $out->putByte($decoration->getIcon()); - $out->putByte($decoration->getRotation()); - $out->putByte($decoration->getXOffset()); - $out->putByte($decoration->getYOffset()); - $out->putString($decoration->getLabel()); - $out->putUnsignedVarInt(Binary::flipIntEndianness($decoration->getColor()->toRGBA())); - } - } - - if(($type & self::BITFLAG_TEXTURE_UPDATE) !== 0){ - $out->putVarInt($this->width); - $out->putVarInt($this->height); - $out->putVarInt($this->xOffset); - $out->putVarInt($this->yOffset); - - $out->putUnsignedVarInt($this->width * $this->height); //list count, but we handle it as a 2D array... thanks for the confusion mojang - - for($y = 0; $y < $this->height; ++$y){ - for($x = 0; $x < $this->width; ++$x){ - //if mojang had any sense this would just be a regular LE int - $out->putUnsignedVarInt(Binary::flipIntEndianness($this->colors[$y][$x]->toRGBA())); - } - } - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleClientboundMapItemData($this); - } -} diff --git a/src/network/mcpe/protocol/ClientboundPacket.php b/src/network/mcpe/protocol/ClientboundPacket.php deleted file mode 100644 index edd22bf0e..000000000 --- a/src/network/mcpe/protocol/ClientboundPacket.php +++ /dev/null @@ -1,28 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class CodeBuilderPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::CODE_BUILDER_PACKET; - - /** @var string */ - private $url; - /** @var bool */ - private $openCodeBuilder; - - public static function create(string $url, bool $openCodeBuilder) : self{ - $result = new self; - $result->url = $url; - $result->openCodeBuilder = $openCodeBuilder; - return $result; - } - - public function getUrl() : string{ - return $this->url; - } - - public function openCodeBuilder() : bool{ - return $this->openCodeBuilder; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->url = $in->getString(); - $this->openCodeBuilder = $in->getBool(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->url); - $out->putBool($this->openCodeBuilder); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleCodeBuilder($this); - } -} diff --git a/src/network/mcpe/protocol/CommandBlockUpdatePacket.php b/src/network/mcpe/protocol/CommandBlockUpdatePacket.php deleted file mode 100644 index 2fadff4ec..000000000 --- a/src/network/mcpe/protocol/CommandBlockUpdatePacket.php +++ /dev/null @@ -1,111 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class CommandBlockUpdatePacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::COMMAND_BLOCK_UPDATE_PACKET; - - /** @var bool */ - public $isBlock; - - /** @var int */ - public $x; - /** @var int */ - public $y; - /** @var int */ - public $z; - /** @var int */ - public $commandBlockMode; - /** @var bool */ - public $isRedstoneMode; - /** @var bool */ - public $isConditional; - - /** @var int */ - public $minecartEid; - - /** @var string */ - public $command; - /** @var string */ - public $lastOutput; - /** @var string */ - public $name; - /** @var bool */ - public $shouldTrackOutput; - /** @var int */ - public $tickDelay; - /** @var bool */ - public $executeOnFirstTick; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->isBlock = $in->getBool(); - - if($this->isBlock){ - $in->getBlockPosition($this->x, $this->y, $this->z); - $this->commandBlockMode = $in->getUnsignedVarInt(); - $this->isRedstoneMode = $in->getBool(); - $this->isConditional = $in->getBool(); - }else{ - //Minecart with command block - $this->minecartEid = $in->getEntityRuntimeId(); - } - - $this->command = $in->getString(); - $this->lastOutput = $in->getString(); - $this->name = $in->getString(); - - $this->shouldTrackOutput = $in->getBool(); - $this->tickDelay = $in->getLInt(); - $this->executeOnFirstTick = $in->getBool(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putBool($this->isBlock); - - if($this->isBlock){ - $out->putBlockPosition($this->x, $this->y, $this->z); - $out->putUnsignedVarInt($this->commandBlockMode); - $out->putBool($this->isRedstoneMode); - $out->putBool($this->isConditional); - }else{ - $out->putEntityRuntimeId($this->minecartEid); - } - - $out->putString($this->command); - $out->putString($this->lastOutput); - $out->putString($this->name); - - $out->putBool($this->shouldTrackOutput); - $out->putLInt($this->tickDelay); - $out->putBool($this->executeOnFirstTick); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleCommandBlockUpdate($this); - } -} diff --git a/src/network/mcpe/protocol/CommandOutputPacket.php b/src/network/mcpe/protocol/CommandOutputPacket.php deleted file mode 100644 index 6dc70acc8..000000000 --- a/src/network/mcpe/protocol/CommandOutputPacket.php +++ /dev/null @@ -1,111 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\command\CommandOriginData; -use pocketmine\network\mcpe\protocol\types\command\CommandOutputMessage; -use pocketmine\utils\BinaryDataException; -use function count; - -class CommandOutputPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::COMMAND_OUTPUT_PACKET; - - public const TYPE_LAST = 1; - public const TYPE_SILENT = 2; - public const TYPE_ALL = 3; - public const TYPE_DATA_SET = 4; - - /** @var CommandOriginData */ - public $originData; - /** @var int */ - public $outputType; - /** @var int */ - public $successCount; - /** @var CommandOutputMessage[] */ - public $messages = []; - /** @var string */ - public $unknownString; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->originData = $in->getCommandOriginData(); - $this->outputType = $in->getByte(); - $this->successCount = $in->getUnsignedVarInt(); - - for($i = 0, $size = $in->getUnsignedVarInt(); $i < $size; ++$i){ - $this->messages[] = $this->getCommandMessage($in); - } - - if($this->outputType === self::TYPE_DATA_SET){ - $this->unknownString = $in->getString(); - } - } - - /** - * @throws BinaryDataException - */ - protected function getCommandMessage(PacketSerializer $in) : CommandOutputMessage{ - $message = new CommandOutputMessage(); - - $message->isInternal = $in->getBool(); - $message->messageId = $in->getString(); - - for($i = 0, $size = $in->getUnsignedVarInt(); $i < $size; ++$i){ - $message->parameters[] = $in->getString(); - } - - return $message; - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putCommandOriginData($this->originData); - $out->putByte($this->outputType); - $out->putUnsignedVarInt($this->successCount); - - $out->putUnsignedVarInt(count($this->messages)); - foreach($this->messages as $message){ - $this->putCommandMessage($message, $out); - } - - if($this->outputType === self::TYPE_DATA_SET){ - $out->putString($this->unknownString); - } - } - - protected function putCommandMessage(CommandOutputMessage $message, PacketSerializer $out) : void{ - $out->putBool($message->isInternal); - $out->putString($message->messageId); - - $out->putUnsignedVarInt(count($message->parameters)); - foreach($message->parameters as $parameter){ - $out->putString($parameter); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleCommandOutput($this); - } -} diff --git a/src/network/mcpe/protocol/CommandRequestPacket.php b/src/network/mcpe/protocol/CommandRequestPacket.php deleted file mode 100644 index ecc8f336d..000000000 --- a/src/network/mcpe/protocol/CommandRequestPacket.php +++ /dev/null @@ -1,56 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\command\CommandOriginData; - -class CommandRequestPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::COMMAND_REQUEST_PACKET; - - /** @var string */ - public $command; - /** @var CommandOriginData */ - public $originData; - /** @var bool */ - public $isInternal; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->command = $in->getString(); - $this->originData = $in->getCommandOriginData(); - $this->isInternal = $in->getBool(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->command); - $out->putCommandOriginData($this->originData); - $out->putBool($this->isInternal); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleCommandRequest($this); - } -} diff --git a/src/network/mcpe/protocol/CompletedUsingItemPacket.php b/src/network/mcpe/protocol/CompletedUsingItemPacket.php deleted file mode 100644 index f8fe5357b..000000000 --- a/src/network/mcpe/protocol/CompletedUsingItemPacket.php +++ /dev/null @@ -1,68 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class CompletedUsingItemPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::COMPLETED_USING_ITEM_PACKET; - - public const ACTION_UNKNOWN = -1; - public const ACTION_EQUIP_ARMOR = 0; - public const ACTION_EAT = 1; - public const ACTION_ATTACK = 2; - public const ACTION_CONSUME = 3; - public const ACTION_THROW = 4; - public const ACTION_SHOOT = 5; - public const ACTION_PLACE = 6; - public const ACTION_FILL_BOTTLE = 7; - public const ACTION_FILL_BUCKET = 8; - public const ACTION_POUR_BUCKET = 9; - public const ACTION_USE_TOOL = 10; - public const ACTION_INTERACT = 11; - public const ACTION_RETRIEVED = 12; - public const ACTION_DYED = 13; - public const ACTION_TRADED = 14; - - /** @var int */ - public $itemId; - /** @var int */ - public $action; - - public function decodePayload(PacketSerializer $in) : void{ - $this->itemId = $in->getShort(); - $this->action = $in->getLInt(); - } - - public function encodePayload(PacketSerializer $out) : void{ - $out->putShort($this->itemId); - $out->putLInt($this->action); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleCompletedUsingItem($this); - } -} diff --git a/src/network/mcpe/protocol/ContainerClosePacket.php b/src/network/mcpe/protocol/ContainerClosePacket.php deleted file mode 100644 index c8f5f2111..000000000 --- a/src/network/mcpe/protocol/ContainerClosePacket.php +++ /dev/null @@ -1,58 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class ContainerClosePacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::CONTAINER_CLOSE_PACKET; - - /** @var int */ - public $windowId; - /** @var bool */ - public $server = false; - - public static function create(int $windowId, bool $server) : self{ - $result = new self; - $result->windowId = $windowId; - $result->server = $server; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->windowId = $in->getByte(); - $this->server = $in->getBool(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putByte($this->windowId); - $out->putBool($this->server); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleContainerClose($this); - } -} diff --git a/src/network/mcpe/protocol/ContainerOpenPacket.php b/src/network/mcpe/protocol/ContainerOpenPacket.php deleted file mode 100644 index 54f589055..000000000 --- a/src/network/mcpe/protocol/ContainerOpenPacket.php +++ /dev/null @@ -1,85 +0,0 @@ - - -use pocketmine\math\Vector3; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class ContainerOpenPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::CONTAINER_OPEN_PACKET; - - /** @var int */ - public $windowId; - /** @var int */ - public $type; - /** @var int */ - public $x; - /** @var int */ - public $y; - /** @var int */ - public $z; - /** @var int */ - public $entityUniqueId = -1; - - public static function blockInv(int $windowId, int $windowType, int $x, int $y, int $z) : self{ - $result = new self; - $result->windowId = $windowId; - $result->type = $windowType; - [$result->x, $result->y, $result->z] = [$x, $y, $z]; - return $result; - } - - public static function blockInvVec3(int $windowId, int $windowType, Vector3 $vector3) : self{ - return self::blockInv($windowId, $windowType, $vector3->getFloorX(), $vector3->getFloorY(), $vector3->getFloorZ()); - } - - public static function entityInv(int $windowId, int $windowType, int $entityUniqueId) : self{ - $result = new self; - $result->windowId = $windowId; - $result->type = $windowType; - $result->entityUniqueId = $entityUniqueId; - $result->x = $result->y = $result->z = 0; //these have to be set even if they aren't used - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->windowId = $in->getByte(); - $this->type = $in->getByte(); - $in->getBlockPosition($this->x, $this->y, $this->z); - $this->entityUniqueId = $in->getEntityUniqueId(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putByte($this->windowId); - $out->putByte($this->type); - $out->putBlockPosition($this->x, $this->y, $this->z); - $out->putEntityUniqueId($this->entityUniqueId); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleContainerOpen($this); - } -} diff --git a/src/network/mcpe/protocol/ContainerSetDataPacket.php b/src/network/mcpe/protocol/ContainerSetDataPacket.php deleted file mode 100644 index 9778ef25e..000000000 --- a/src/network/mcpe/protocol/ContainerSetDataPacket.php +++ /dev/null @@ -1,73 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class ContainerSetDataPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::CONTAINER_SET_DATA_PACKET; - - public const PROPERTY_FURNACE_SMELT_PROGRESS = 0; - public const PROPERTY_FURNACE_REMAINING_FUEL_TIME = 1; - public const PROPERTY_FURNACE_MAX_FUEL_TIME = 2; - public const PROPERTY_FURNACE_STORED_XP = 3; - public const PROPERTY_FURNACE_FUEL_AUX = 4; - - public const PROPERTY_BREWING_STAND_BREW_TIME = 0; - public const PROPERTY_BREWING_STAND_FUEL_AMOUNT = 1; - public const PROPERTY_BREWING_STAND_FUEL_TOTAL = 2; - - /** @var int */ - public $windowId; - /** @var int */ - public $property; - /** @var int */ - public $value; - - public static function create(int $windowId, int $propertyId, int $value) : self{ - $result = new self; - $result->property = $propertyId; - $result->value = $value; - $result->windowId = $windowId; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->windowId = $in->getByte(); - $this->property = $in->getVarInt(); - $this->value = $in->getVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putByte($this->windowId); - $out->putVarInt($this->property); - $out->putVarInt($this->value); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleContainerSetData($this); - } -} diff --git a/src/network/mcpe/protocol/CorrectPlayerMovePredictionPacket.php b/src/network/mcpe/protocol/CorrectPlayerMovePredictionPacket.php deleted file mode 100644 index 3e7d49bba..000000000 --- a/src/network/mcpe/protocol/CorrectPlayerMovePredictionPacket.php +++ /dev/null @@ -1,77 +0,0 @@ - - -use pocketmine\math\Vector3; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class CorrectPlayerMovePredictionPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::CORRECT_PLAYER_MOVE_PREDICTION_PACKET; - - /** @var Vector3 */ - private $position; - /** @var Vector3 */ - private $delta; - /** @var bool */ - private $onGround; - /** @var int */ - private $tick; - - public static function create(Vector3 $position, Vector3 $delta, bool $onGround, int $tick) : self{ - $result = new self; - $result->position = $position; - $result->delta = $delta; - $result->onGround = $onGround; - $result->tick = $tick; - return $result; - } - - public function getPosition() : Vector3{ return $this->position; } - - public function getDelta() : Vector3{ return $this->delta; } - - public function isOnGround() : bool{ return $this->onGround; } - - public function getTick() : int{ return $this->tick; } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->position = $in->getVector3(); - $this->delta = $in->getVector3(); - $this->onGround = $in->getBool(); - $this->tick = $in->getUnsignedVarLong(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putVector3($this->position); - $out->putVector3($this->delta); - $out->putBool($this->onGround); - $out->putUnsignedVarLong($this->tick); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleCorrectPlayerMovePrediction($this); - } -} diff --git a/src/network/mcpe/protocol/CraftingDataPacket.php b/src/network/mcpe/protocol/CraftingDataPacket.php deleted file mode 100644 index 692c1b352..000000000 --- a/src/network/mcpe/protocol/CraftingDataPacket.php +++ /dev/null @@ -1,131 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\recipe\FurnaceRecipe; -use pocketmine\network\mcpe\protocol\types\recipe\MultiRecipe; -use pocketmine\network\mcpe\protocol\types\recipe\PotionContainerChangeRecipe; -use pocketmine\network\mcpe\protocol\types\recipe\PotionTypeRecipe; -use pocketmine\network\mcpe\protocol\types\recipe\RecipeWithTypeId; -use pocketmine\network\mcpe\protocol\types\recipe\ShapedRecipe; -use pocketmine\network\mcpe\protocol\types\recipe\ShapelessRecipe; -use function count; - -class CraftingDataPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::CRAFTING_DATA_PACKET; - - public const ENTRY_SHAPELESS = 0; - public const ENTRY_SHAPED = 1; - public const ENTRY_FURNACE = 2; - public const ENTRY_FURNACE_DATA = 3; - public const ENTRY_MULTI = 4; - public const ENTRY_SHULKER_BOX = 5; - public const ENTRY_SHAPELESS_CHEMISTRY = 6; - public const ENTRY_SHAPED_CHEMISTRY = 7; - - /** @var RecipeWithTypeId[] */ - public $entries = []; - /** @var PotionTypeRecipe[] */ - public $potionTypeRecipes = []; - /** @var PotionContainerChangeRecipe[] */ - public $potionContainerRecipes = []; - /** @var bool */ - public $cleanRecipes = false; - - protected function decodePayload(PacketSerializer $in) : void{ - $recipeCount = $in->getUnsignedVarInt(); - for($i = 0; $i < $recipeCount; ++$i){ - $recipeType = $in->getVarInt(); - - switch($recipeType){ - case self::ENTRY_SHAPELESS: - case self::ENTRY_SHULKER_BOX: - case self::ENTRY_SHAPELESS_CHEMISTRY: - $this->entries[] = ShapelessRecipe::decode($recipeType, $in); - break; - case self::ENTRY_SHAPED: - case self::ENTRY_SHAPED_CHEMISTRY: - $this->entries[] = ShapedRecipe::decode($recipeType, $in); - break; - case self::ENTRY_FURNACE: - case self::ENTRY_FURNACE_DATA: - $this->entries[] = FurnaceRecipe::decode($recipeType, $in); - break; - case self::ENTRY_MULTI: - $this->entries[] = MultiRecipe::decode($recipeType, $in); - break; - default: - throw new PacketDecodeException("Unhandled recipe type $recipeType!"); //do not continue attempting to decode - } - } - for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){ - $inputId = $in->getVarInt(); - $inputMeta = $in->getVarInt(); - $ingredientId = $in->getVarInt(); - $ingredientMeta = $in->getVarInt(); - $outputId = $in->getVarInt(); - $outputMeta = $in->getVarInt(); - $this->potionTypeRecipes[] = new PotionTypeRecipe($inputId, $inputMeta, $ingredientId, $ingredientMeta, $outputId, $outputMeta); - } - for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){ - $input = $in->getVarInt(); - $ingredient = $in->getVarInt(); - $output = $in->getVarInt(); - $this->potionContainerRecipes[] = new PotionContainerChangeRecipe($input, $ingredient, $output); - } - $this->cleanRecipes = $in->getBool(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt(count($this->entries)); - foreach($this->entries as $d){ - $out->putVarInt($d->getTypeId()); - $d->encode($out); - } - $out->putUnsignedVarInt(count($this->potionTypeRecipes)); - foreach($this->potionTypeRecipes as $recipe){ - $out->putVarInt($recipe->getInputItemId()); - $out->putVarInt($recipe->getInputItemMeta()); - $out->putVarInt($recipe->getIngredientItemId()); - $out->putVarInt($recipe->getIngredientItemMeta()); - $out->putVarInt($recipe->getOutputItemId()); - $out->putVarInt($recipe->getOutputItemMeta()); - } - $out->putUnsignedVarInt(count($this->potionContainerRecipes)); - foreach($this->potionContainerRecipes as $recipe){ - $out->putVarInt($recipe->getInputItemId()); - $out->putVarInt($recipe->getIngredientItemId()); - $out->putVarInt($recipe->getOutputItemId()); - } - - $out->putBool($this->cleanRecipes); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleCraftingData($this); - } -} diff --git a/src/network/mcpe/protocol/CraftingEventPacket.php b/src/network/mcpe/protocol/CraftingEventPacket.php deleted file mode 100644 index e35186a55..000000000 --- a/src/network/mcpe/protocol/CraftingEventPacket.php +++ /dev/null @@ -1,82 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper; -use Ramsey\Uuid\UuidInterface; -use function count; - -class CraftingEventPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::CRAFTING_EVENT_PACKET; - - /** @var int */ - public $windowId; - /** @var int */ - public $type; - /** @var UuidInterface */ - public $id; - /** @var ItemStackWrapper[] */ - public $input = []; - /** @var ItemStackWrapper[] */ - public $output = []; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->windowId = $in->getByte(); - $this->type = $in->getVarInt(); - $this->id = $in->getUUID(); - - $size = $in->getUnsignedVarInt(); - for($i = 0; $i < $size and $i < 128; ++$i){ - $this->input[] = ItemStackWrapper::read($in); - } - - $size = $in->getUnsignedVarInt(); - for($i = 0; $i < $size and $i < 128; ++$i){ - $this->output[] = ItemStackWrapper::read($in); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putByte($this->windowId); - $out->putVarInt($this->type); - $out->putUUID($this->id); - - $out->putUnsignedVarInt(count($this->input)); - foreach($this->input as $item){ - $item->write($out); - } - - $out->putUnsignedVarInt(count($this->output)); - foreach($this->output as $item){ - $item->write($out); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleCraftingEvent($this); - } -} diff --git a/src/network/mcpe/protocol/CreativeContentPacket.php b/src/network/mcpe/protocol/CreativeContentPacket.php deleted file mode 100644 index 2c7f0d522..000000000 --- a/src/network/mcpe/protocol/CreativeContentPacket.php +++ /dev/null @@ -1,67 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\inventory\CreativeContentEntry; -use function count; - -class CreativeContentPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::CREATIVE_CONTENT_PACKET; - - /** @var CreativeContentEntry[] */ - private $entries; - - /** - * @param CreativeContentEntry[] $entries - */ - public static function create(array $entries) : self{ - $result = new self; - $result->entries = $entries; - return $result; - } - - /** @return CreativeContentEntry[] */ - public function getEntries() : array{ return $this->entries; } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entries = []; - for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){ - $this->entries[] = CreativeContentEntry::read($in); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt(count($this->entries)); - foreach($this->entries as $entry){ - $entry->write($out); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleCreativeContent($this); - } -} diff --git a/src/network/mcpe/protocol/DataPacket.php b/src/network/mcpe/protocol/DataPacket.php deleted file mode 100644 index 128d96b2a..000000000 --- a/src/network/mcpe/protocol/DataPacket.php +++ /dev/null @@ -1,129 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\utils\BinaryDataException; -use function get_class; - -abstract class DataPacket implements Packet{ - - public const NETWORK_ID = 0; - - public const PID_MASK = 0x3ff; //10 bits - - private const SUBCLIENT_ID_MASK = 0x03; //2 bits - private const SENDER_SUBCLIENT_ID_SHIFT = 10; - private const RECIPIENT_SUBCLIENT_ID_SHIFT = 12; - - /** @var int */ - public $senderSubId = 0; - /** @var int */ - public $recipientSubId = 0; - - public function pid() : int{ - return $this::NETWORK_ID; - } - - public function getName() : string{ - return (new \ReflectionClass($this))->getShortName(); - } - - public function canBeSentBeforeLogin() : bool{ - return false; - } - - /** - * @throws PacketDecodeException - */ - final public function decode(PacketSerializer $in) : void{ - try{ - $this->decodeHeader($in); - $this->decodePayload($in); - }catch(BinaryDataException | PacketDecodeException $e){ - throw PacketDecodeException::wrap($e, $this->getName()); - } - } - - /** - * @throws BinaryDataException - * @throws \UnexpectedValueException - */ - protected function decodeHeader(PacketSerializer $in) : void{ - $header = $in->getUnsignedVarInt(); - $pid = $header & self::PID_MASK; - if($pid !== static::NETWORK_ID){ - //TODO: this means a logical error in the code, but how to prevent it from happening? - throw new \UnexpectedValueException("Expected " . static::NETWORK_ID . " for packet ID, got $pid"); - } - $this->senderSubId = ($header >> self::SENDER_SUBCLIENT_ID_SHIFT) & self::SUBCLIENT_ID_MASK; - $this->recipientSubId = ($header >> self::RECIPIENT_SUBCLIENT_ID_SHIFT) & self::SUBCLIENT_ID_MASK; - - } - - /** - * Decodes the packet body, without the packet ID or other generic header fields. - * - * @throws PacketDecodeException - * @throws BinaryDataException - */ - abstract protected function decodePayload(PacketSerializer $in) : void; - - final public function encode(PacketSerializer $out) : void{ - $this->encodeHeader($out); - $this->encodePayload($out); - } - - protected function encodeHeader(PacketSerializer $out) : void{ - $out->putUnsignedVarInt( - static::NETWORK_ID | - ($this->senderSubId << self::SENDER_SUBCLIENT_ID_SHIFT) | - ($this->recipientSubId << self::RECIPIENT_SUBCLIENT_ID_SHIFT) - ); - } - - /** - * Encodes the packet body, without the packet ID or other generic header fields. - */ - abstract protected function encodePayload(PacketSerializer $out) : void; - - /** - * @param string $name - * - * @return mixed - */ - public function __get($name){ - throw new \Error("Undefined property: " . get_class($this) . "::\$" . $name); - } - - /** - * @param string $name - * @param mixed $value - */ - public function __set($name, $value) : void{ - throw new \Error("Undefined property: " . get_class($this) . "::\$" . $name); - } -} diff --git a/src/network/mcpe/protocol/DebugInfoPacket.php b/src/network/mcpe/protocol/DebugInfoPacket.php deleted file mode 100644 index c6cadb463..000000000 --- a/src/network/mcpe/protocol/DebugInfoPacket.php +++ /dev/null @@ -1,65 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class DebugInfoPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::DEBUG_INFO_PACKET; - - /** @var int */ - private $entityUniqueId; - /** @var string */ - private $data; - - public static function create(int $entityUniqueId, string $data) : self{ - $result = new self; - $result->entityUniqueId = $entityUniqueId; - $result->data = $data; - return $result; - } - - /** - * TODO: we can't call this getEntityRuntimeId() because of base class collision (crap architecture, thanks Shoghi) - */ - public function getEntityUniqueIdField() : int{ return $this->entityUniqueId; } - - public function getData() : string{ return $this->data; } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityUniqueId = $in->getEntityUniqueId(); - $this->data = $in->getString(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityUniqueId($this->entityUniqueId); - $out->putString($this->data); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleDebugInfo($this); - } -} diff --git a/src/network/mcpe/protocol/DisconnectPacket.php b/src/network/mcpe/protocol/DisconnectPacket.php deleted file mode 100644 index 31bd9e509..000000000 --- a/src/network/mcpe/protocol/DisconnectPacket.php +++ /dev/null @@ -1,72 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class DisconnectPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::DISCONNECT_PACKET; - - /** @var bool */ - public $hideDisconnectionScreen = false; - /** @var string */ - public $message = ""; - - public static function silent() : self{ - $result = new self; - $result->hideDisconnectionScreen = true; - return $result; - } - - public static function message(string $message) : self{ - $result = new self; - $result->hideDisconnectionScreen = false; - $result->message = $message; - return $result; - } - - public function canBeSentBeforeLogin() : bool{ - return true; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->hideDisconnectionScreen = $in->getBool(); - if(!$this->hideDisconnectionScreen){ - $this->message = $in->getString(); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putBool($this->hideDisconnectionScreen); - if(!$this->hideDisconnectionScreen){ - $out->putString($this->message); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleDisconnect($this); - } -} diff --git a/src/network/mcpe/protocol/EducationSettingsPacket.php b/src/network/mcpe/protocol/EducationSettingsPacket.php deleted file mode 100644 index f8f6b6bb9..000000000 --- a/src/network/mcpe/protocol/EducationSettingsPacket.php +++ /dev/null @@ -1,100 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class EducationSettingsPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::EDUCATION_SETTINGS_PACKET; - - /** @var string */ - private $codeBuilderDefaultUri; - /** @var string */ - private $codeBuilderTitle; - /** @var bool */ - private $canResizeCodeBuilder; - /** @var string|null */ - private $codeBuilderOverrideUri; - /** @var bool */ - private $hasQuiz; - - public static function create(string $codeBuilderDefaultUri, string $codeBuilderTitle, bool $canResizeCodeBuilder, ?string $codeBuilderOverrideUri, bool $hasQuiz) : self{ - $result = new self; - $result->codeBuilderDefaultUri = $codeBuilderDefaultUri; - $result->codeBuilderTitle = $codeBuilderTitle; - $result->canResizeCodeBuilder = $canResizeCodeBuilder; - $result->codeBuilderOverrideUri = $codeBuilderOverrideUri; - $result->hasQuiz = $hasQuiz; - return $result; - } - - public function getCodeBuilderDefaultUri() : string{ - return $this->codeBuilderDefaultUri; - } - - public function getCodeBuilderTitle() : string{ - return $this->codeBuilderTitle; - } - - public function canResizeCodeBuilder() : bool{ - return $this->canResizeCodeBuilder; - } - - public function getCodeBuilderOverrideUri() : ?string{ - return $this->codeBuilderOverrideUri; - } - - public function getHasQuiz() : bool{ - return $this->hasQuiz; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->codeBuilderDefaultUri = $in->getString(); - $this->codeBuilderTitle = $in->getString(); - $this->canResizeCodeBuilder = $in->getBool(); - if($in->getBool()){ - $this->codeBuilderOverrideUri = $in->getString(); - }else{ - $this->codeBuilderOverrideUri = null; - } - $this->hasQuiz = $in->getBool(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->codeBuilderDefaultUri); - $out->putString($this->codeBuilderTitle); - $out->putBool($this->canResizeCodeBuilder); - $out->putBool($this->codeBuilderOverrideUri !== null); - if($this->codeBuilderOverrideUri !== null){ - $out->putString($this->codeBuilderOverrideUri); - } - $out->putBool($this->hasQuiz); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleEducationSettings($this); - } -} diff --git a/src/network/mcpe/protocol/EmoteListPacket.php b/src/network/mcpe/protocol/EmoteListPacket.php deleted file mode 100644 index f6872eac2..000000000 --- a/src/network/mcpe/protocol/EmoteListPacket.php +++ /dev/null @@ -1,74 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use Ramsey\Uuid\UuidInterface; -use function count; - -class EmoteListPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::EMOTE_LIST_PACKET; - - /** @var int */ - private $playerEntityRuntimeId; - /** @var UuidInterface[] */ - private $emoteIds; - - /** - * @param UuidInterface[] $emoteIds - */ - public static function create(int $playerEntityRuntimeId, array $emoteIds) : self{ - $result = new self; - $result->playerEntityRuntimeId = $playerEntityRuntimeId; - $result->emoteIds = $emoteIds; - return $result; - } - - public function getPlayerEntityRuntimeId() : int{ return $this->playerEntityRuntimeId; } - - /** @return UuidInterface[] */ - public function getEmoteIds() : array{ return $this->emoteIds; } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->playerEntityRuntimeId = $in->getEntityRuntimeId(); - $this->emoteIds = []; - for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){ - $this->emoteIds[] = $in->getUUID(); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityRuntimeId($this->playerEntityRuntimeId); - $out->putUnsignedVarInt(count($this->emoteIds)); - foreach($this->emoteIds as $emoteId){ - $out->putUUID($emoteId); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleEmoteList($this); - } -} diff --git a/src/network/mcpe/protocol/EmotePacket.php b/src/network/mcpe/protocol/EmotePacket.php deleted file mode 100644 index b32e6662d..000000000 --- a/src/network/mcpe/protocol/EmotePacket.php +++ /dev/null @@ -1,80 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class EmotePacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::EMOTE_PACKET; - - public const FLAG_SERVER = 1 << 0; - - /** @var int */ - private $entityRuntimeId; - /** @var string */ - private $emoteId; - /** @var int */ - private $flags; - - public static function create(int $entityRuntimeId, string $emoteId, int $flags) : self{ - $result = new self; - $result->entityRuntimeId = $entityRuntimeId; - $result->emoteId = $emoteId; - $result->flags = $flags; - return $result; - } - - /** - * TODO: we can't call this getEntityRuntimeId() because of base class collision (crap architecture, thanks Shoghi) - */ - public function getEntityRuntimeIdField() : int{ - return $this->entityRuntimeId; - } - - public function getEmoteId() : string{ - return $this->emoteId; - } - - public function getFlags() : int{ - return $this->flags; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityRuntimeId = $in->getEntityRuntimeId(); - $this->emoteId = $in->getString(); - $this->flags = $in->getByte(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityRuntimeId($this->entityRuntimeId); - $out->putString($this->emoteId); - $out->putByte($this->flags); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleEmote($this); - } -} diff --git a/src/network/mcpe/protocol/EventPacket.php b/src/network/mcpe/protocol/EventPacket.php deleted file mode 100644 index 581b02fc7..000000000 --- a/src/network/mcpe/protocol/EventPacket.php +++ /dev/null @@ -1,85 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class EventPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::EVENT_PACKET; - - public const TYPE_ACHIEVEMENT_AWARDED = 0; - public const TYPE_ENTITY_INTERACT = 1; - public const TYPE_PORTAL_BUILT = 2; - public const TYPE_PORTAL_USED = 3; - public const TYPE_MOB_KILLED = 4; - public const TYPE_CAULDRON_USED = 5; - public const TYPE_PLAYER_DEATH = 6; - public const TYPE_BOSS_KILLED = 7; - public const TYPE_AGENT_COMMAND = 8; - public const TYPE_AGENT_CREATED = 9; - public const TYPE_PATTERN_REMOVED = 10; //??? - public const TYPE_COMMANED_EXECUTED = 11; - public const TYPE_FISH_BUCKETED = 12; - public const TYPE_MOB_BORN = 13; - public const TYPE_PET_DIED = 14; - public const TYPE_CAULDRON_BLOCK_USED = 15; - public const TYPE_COMPOSTER_BLOCK_USED = 16; - public const TYPE_BELL_BLOCK_USED = 17; - public const TYPE_ACTOR_DEFINITION = 18; - public const TYPE_RAID_UPDATE = 19; - public const TYPE_PLAYER_MOVEMENT_ANOMALY = 20; //anti cheat - public const TYPE_PLAYER_MOVEMENT_CORRECTED = 21; - public const TYPE_HONEY_HARVESTED = 22; - public const TYPE_TARGET_BLOCK_HIT = 23; - public const TYPE_PIGLIN_BARTER = 24; - - /** @var int */ - public $playerRuntimeId; - /** @var int */ - public $eventData; - /** @var int */ - public $type; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->playerRuntimeId = $in->getEntityRuntimeId(); - $this->eventData = $in->getVarInt(); - $this->type = $in->getByte(); - - //TODO: nice confusing mess - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityRuntimeId($this->playerRuntimeId); - $out->putVarInt($this->eventData); - $out->putByte($this->type); - - //TODO: also nice confusing mess - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleEvent($this); - } -} diff --git a/src/network/mcpe/protocol/FilterTextPacket.php b/src/network/mcpe/protocol/FilterTextPacket.php deleted file mode 100644 index 3d19c47a7..000000000 --- a/src/network/mcpe/protocol/FilterTextPacket.php +++ /dev/null @@ -1,62 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class FilterTextPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::FILTER_TEXT_PACKET; - - /** @var string */ - private $text; - /** @var bool */ - private $fromServer; - - public static function create(string $text, bool $server) : self{ - $result = new self; - $result->text = $text; - $result->fromServer = $server; - return $result; - } - - public function getText() : string{ return $this->text; } - - public function isFromServer() : bool{ return $this->fromServer; } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->text = $in->getString(); - $this->fromServer = $in->getBool(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->text); - $out->putBool($this->fromServer); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleFilterText($this); - } -} diff --git a/src/network/mcpe/protocol/GameRulesChangedPacket.php b/src/network/mcpe/protocol/GameRulesChangedPacket.php deleted file mode 100644 index 35aa036ba..000000000 --- a/src/network/mcpe/protocol/GameRulesChangedPacket.php +++ /dev/null @@ -1,51 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\GameRule; - -class GameRulesChangedPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::GAME_RULES_CHANGED_PACKET; - - /** - * @var GameRule[] - * @phpstan-var array - */ - public $gameRules = []; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->gameRules = $in->getGameRules(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putGameRules($this->gameRules); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleGameRulesChanged($this); - } -} diff --git a/src/network/mcpe/protocol/GuiDataPickItemPacket.php b/src/network/mcpe/protocol/GuiDataPickItemPacket.php deleted file mode 100644 index 808cd882a..000000000 --- a/src/network/mcpe/protocol/GuiDataPickItemPacket.php +++ /dev/null @@ -1,55 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class GuiDataPickItemPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::GUI_DATA_PICK_ITEM_PACKET; - - /** @var string */ - public $itemDescription; - /** @var string */ - public $itemEffects; - /** @var int */ - public $hotbarSlot; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->itemDescription = $in->getString(); - $this->itemEffects = $in->getString(); - $this->hotbarSlot = $in->getLInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->itemDescription); - $out->putString($this->itemEffects); - $out->putLInt($this->hotbarSlot); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleGuiDataPickItem($this); - } -} diff --git a/src/network/mcpe/protocol/HurtArmorPacket.php b/src/network/mcpe/protocol/HurtArmorPacket.php deleted file mode 100644 index 661fbb105..000000000 --- a/src/network/mcpe/protocol/HurtArmorPacket.php +++ /dev/null @@ -1,51 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class HurtArmorPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::HURT_ARMOR_PACKET; - - /** @var int */ - public $cause; - /** @var int */ - public $health; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->cause = $in->getVarInt(); - $this->health = $in->getVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putVarInt($this->cause); - $out->putVarInt($this->health); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleHurtArmor($this); - } -} diff --git a/src/network/mcpe/protocol/InteractPacket.php b/src/network/mcpe/protocol/InteractPacket.php deleted file mode 100644 index 829d39a81..000000000 --- a/src/network/mcpe/protocol/InteractPacket.php +++ /dev/null @@ -1,76 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class InteractPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::INTERACT_PACKET; - - public const ACTION_LEAVE_VEHICLE = 3; - public const ACTION_MOUSEOVER = 4; - public const ACTION_OPEN_NPC = 5; - public const ACTION_OPEN_INVENTORY = 6; - - /** @var int */ - public $action; - /** @var int */ - public $target; - - /** @var float */ - public $x; - /** @var float */ - public $y; - /** @var float */ - public $z; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->action = $in->getByte(); - $this->target = $in->getEntityRuntimeId(); - - if($this->action === self::ACTION_MOUSEOVER){ - //TODO: should this be a vector3? - $this->x = $in->getLFloat(); - $this->y = $in->getLFloat(); - $this->z = $in->getLFloat(); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putByte($this->action); - $out->putEntityRuntimeId($this->target); - - if($this->action === self::ACTION_MOUSEOVER){ - $out->putLFloat($this->x); - $out->putLFloat($this->y); - $out->putLFloat($this->z); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleInteract($this); - } -} diff --git a/src/network/mcpe/protocol/InventoryContentPacket.php b/src/network/mcpe/protocol/InventoryContentPacket.php deleted file mode 100644 index 435f8ac15..000000000 --- a/src/network/mcpe/protocol/InventoryContentPacket.php +++ /dev/null @@ -1,71 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper; -use function count; - -class InventoryContentPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::INVENTORY_CONTENT_PACKET; - - /** @var int */ - public $windowId; - /** @var ItemStackWrapper[] */ - public $items = []; - - /** - * @param ItemStackWrapper[] $items - * - * @return InventoryContentPacket - */ - public static function create(int $windowId, array $items) : self{ - $result = new self; - $result->windowId = $windowId; - $result->items = $items; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->windowId = $in->getUnsignedVarInt(); - $count = $in->getUnsignedVarInt(); - for($i = 0; $i < $count; ++$i){ - $this->items[] = ItemStackWrapper::read($in); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt($this->windowId); - $out->putUnsignedVarInt(count($this->items)); - foreach($this->items as $item){ - $item->write($out); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleInventoryContent($this); - } -} diff --git a/src/network/mcpe/protocol/InventorySlotPacket.php b/src/network/mcpe/protocol/InventorySlotPacket.php deleted file mode 100644 index 59708dd79..000000000 --- a/src/network/mcpe/protocol/InventorySlotPacket.php +++ /dev/null @@ -1,65 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper; - -class InventorySlotPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::INVENTORY_SLOT_PACKET; - - /** @var int */ - public $windowId; - /** @var int */ - public $inventorySlot; - /** @var ItemStackWrapper */ - public $item; - - public static function create(int $windowId, int $slot, ItemStackWrapper $item) : self{ - $result = new self; - $result->inventorySlot = $slot; - $result->item = $item; - $result->windowId = $windowId; - - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->windowId = $in->getUnsignedVarInt(); - $this->inventorySlot = $in->getUnsignedVarInt(); - $this->item = ItemStackWrapper::read($in); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt($this->windowId); - $out->putUnsignedVarInt($this->inventorySlot); - $this->item->write($out); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleInventorySlot($this); - } -} diff --git a/src/network/mcpe/protocol/InventoryTransactionPacket.php b/src/network/mcpe/protocol/InventoryTransactionPacket.php deleted file mode 100644 index a5af13c40..000000000 --- a/src/network/mcpe/protocol/InventoryTransactionPacket.php +++ /dev/null @@ -1,108 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\inventory\InventoryTransactionChangedSlotsHack; -use pocketmine\network\mcpe\protocol\types\inventory\MismatchTransactionData; -use pocketmine\network\mcpe\protocol\types\inventory\NormalTransactionData; -use pocketmine\network\mcpe\protocol\types\inventory\ReleaseItemTransactionData; -use pocketmine\network\mcpe\protocol\types\inventory\TransactionData; -use pocketmine\network\mcpe\protocol\types\inventory\UseItemOnEntityTransactionData; -use pocketmine\network\mcpe\protocol\types\inventory\UseItemTransactionData; -use function count; - -/** - * This packet effectively crams multiple packets into one. - */ -class InventoryTransactionPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::INVENTORY_TRANSACTION_PACKET; - - public const TYPE_NORMAL = 0; - public const TYPE_MISMATCH = 1; - public const TYPE_USE_ITEM = 2; - public const TYPE_USE_ITEM_ON_ENTITY = 3; - public const TYPE_RELEASE_ITEM = 4; - - /** @var int */ - public $requestId; - /** @var InventoryTransactionChangedSlotsHack[] */ - public $requestChangedSlots; - /** @var TransactionData */ - public $trData; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->requestId = $in->readGenericTypeNetworkId(); - $this->requestChangedSlots = []; - if($this->requestId !== 0){ - for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){ - $this->requestChangedSlots[] = InventoryTransactionChangedSlotsHack::read($in); - } - } - - $transactionType = $in->getUnsignedVarInt(); - - switch($transactionType){ - case self::TYPE_NORMAL: - $this->trData = new NormalTransactionData(); - break; - case self::TYPE_MISMATCH: - $this->trData = new MismatchTransactionData(); - break; - case self::TYPE_USE_ITEM: - $this->trData = new UseItemTransactionData(); - break; - case self::TYPE_USE_ITEM_ON_ENTITY: - $this->trData = new UseItemOnEntityTransactionData(); - break; - case self::TYPE_RELEASE_ITEM: - $this->trData = new ReleaseItemTransactionData(); - break; - default: - throw new PacketDecodeException("Unknown transaction type $transactionType"); - } - - $this->trData->decode($in); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->writeGenericTypeNetworkId($this->requestId); - if($this->requestId !== 0){ - $out->putUnsignedVarInt(count($this->requestChangedSlots)); - foreach($this->requestChangedSlots as $changedSlots){ - $changedSlots->write($out); - } - } - - $out->putUnsignedVarInt($this->trData->getTypeId()); - - $this->trData->encode($out); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleInventoryTransaction($this); - } -} diff --git a/src/network/mcpe/protocol/ItemComponentPacket.php b/src/network/mcpe/protocol/ItemComponentPacket.php deleted file mode 100644 index 5a716966c..000000000 --- a/src/network/mcpe/protocol/ItemComponentPacket.php +++ /dev/null @@ -1,79 +0,0 @@ - - -use pocketmine\nbt\TreeRoot; -use pocketmine\network\mcpe\protocol\serializer\NetworkNbtSerializer; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\ItemComponentPacketEntry; -use function count; - -class ItemComponentPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::ITEM_COMPONENT_PACKET; - - /** - * @var ItemComponentPacketEntry[] - * @phpstan-var list - */ - private $entries; - - /** - * @param ItemComponentPacketEntry[] $entries - * @phpstan-param list $entries - */ - public static function create(array $entries) : self{ - $result = new self; - $result->entries = $entries; - return $result; - } - - /** - * @return ItemComponentPacketEntry[] - * @phpstan-return list - */ - public function getEntries() : array{ return $this->entries; } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entries = []; - for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){ - $name = $in->getString(); - $nbt = $in->getNbtCompoundRoot(); - $this->entries[] = new ItemComponentPacketEntry($name, $nbt); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt(count($this->entries)); - foreach($this->entries as $entry){ - $out->putString($entry->getName()); - $out->put((new NetworkNbtSerializer())->write(new TreeRoot($entry->getComponentNbt()))); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleItemComponent($this); - } -} diff --git a/src/network/mcpe/protocol/ItemFrameDropItemPacket.php b/src/network/mcpe/protocol/ItemFrameDropItemPacket.php deleted file mode 100644 index f09998e67..000000000 --- a/src/network/mcpe/protocol/ItemFrameDropItemPacket.php +++ /dev/null @@ -1,52 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class ItemFrameDropItemPacket extends DataPacket implements ServerboundPacket{ - - public const NETWORK_ID = ProtocolInfo::ITEM_FRAME_DROP_ITEM_PACKET; - - /** @var int */ - public $x; - /** @var int */ - public $y; - /** @var int */ - public $z; - - protected function decodePayload(PacketSerializer $in) : void{ - $in->getBlockPosition($this->x, $this->y, $this->z); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putBlockPosition($this->x, $this->y, $this->z); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleItemFrameDropItem($this); - } -} diff --git a/src/network/mcpe/protocol/ItemStackRequestPacket.php b/src/network/mcpe/protocol/ItemStackRequestPacket.php deleted file mode 100644 index 8a9a6e541..000000000 --- a/src/network/mcpe/protocol/ItemStackRequestPacket.php +++ /dev/null @@ -1,67 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\inventory\stackrequest\ItemStackRequest; -use function count; - -class ItemStackRequestPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::ITEM_STACK_REQUEST_PACKET; - - /** @var ItemStackRequest[] */ - private $requests; - - /** - * @param ItemStackRequest[] $requests - */ - public static function create(array $requests) : self{ - $result = new self; - $result->requests = $requests; - return $result; - } - - /** @return ItemStackRequest[] */ - public function getRequests() : array{ return $this->requests; } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->requests = []; - for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){ - $this->requests[] = ItemStackRequest::read($in); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt(count($this->requests)); - foreach($this->requests as $request){ - $request->write($out); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleItemStackRequest($this); - } -} diff --git a/src/network/mcpe/protocol/ItemStackResponsePacket.php b/src/network/mcpe/protocol/ItemStackResponsePacket.php deleted file mode 100644 index 07a54517d..000000000 --- a/src/network/mcpe/protocol/ItemStackResponsePacket.php +++ /dev/null @@ -1,67 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\inventory\stackresponse\ItemStackResponse; -use function count; - -class ItemStackResponsePacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::ITEM_STACK_RESPONSE_PACKET; - - /** @var ItemStackResponse[] */ - private $responses; - - /** - * @param ItemStackResponse[] $responses - */ - public static function create(array $responses) : self{ - $result = new self; - $result->responses = $responses; - return $result; - } - - /** @return ItemStackResponse[] */ - public function getResponses() : array{ return $this->responses; } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->responses = []; - for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){ - $this->responses[] = ItemStackResponse::read($in); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt(count($this->responses)); - foreach($this->responses as $response){ - $response->write($out); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleItemStackResponse($this); - } -} diff --git a/src/network/mcpe/protocol/LabTablePacket.php b/src/network/mcpe/protocol/LabTablePacket.php deleted file mode 100644 index 375572c3c..000000000 --- a/src/network/mcpe/protocol/LabTablePacket.php +++ /dev/null @@ -1,65 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class LabTablePacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::LAB_TABLE_PACKET; - - public const TYPE_START_COMBINE = 0; - public const TYPE_START_REACTION = 1; - public const TYPE_RESET = 2; - - /** @var int */ - public $type; - - /** @var int */ - public $x; - /** @var int */ - public $y; - /** @var int */ - public $z; - - /** @var int */ - public $reactionType; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->type = $in->getByte(); - $in->getSignedBlockPosition($this->x, $this->y, $this->z); - $this->reactionType = $in->getByte(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putByte($this->type); - $out->putSignedBlockPosition($this->x, $this->y, $this->z); - $out->putByte($this->reactionType); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleLabTable($this); - } -} diff --git a/src/network/mcpe/protocol/LecternUpdatePacket.php b/src/network/mcpe/protocol/LecternUpdatePacket.php deleted file mode 100644 index 9ce58e55e..000000000 --- a/src/network/mcpe/protocol/LecternUpdatePacket.php +++ /dev/null @@ -1,63 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class LecternUpdatePacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::LECTERN_UPDATE_PACKET; - - /** @var int */ - public $page; - /** @var int */ - public $totalPages; - /** @var int */ - public $x; - /** @var int */ - public $y; - /** @var int */ - public $z; - /** @var bool */ - public $dropBook; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->page = $in->getByte(); - $this->totalPages = $in->getByte(); - $in->getBlockPosition($this->x, $this->y, $this->z); - $this->dropBook = $in->getBool(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putByte($this->page); - $out->putByte($this->totalPages); - $out->putBlockPosition($this->x, $this->y, $this->z); - $out->putBool($this->dropBook); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleLecternUpdate($this); - } -} diff --git a/src/network/mcpe/protocol/LevelChunkPacket.php b/src/network/mcpe/protocol/LevelChunkPacket.php deleted file mode 100644 index bbbe2dd98..000000000 --- a/src/network/mcpe/protocol/LevelChunkPacket.php +++ /dev/null @@ -1,133 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use function count; - -class LevelChunkPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::LEVEL_CHUNK_PACKET; - - /** @var int */ - private $chunkX; - /** @var int */ - private $chunkZ; - /** @var int */ - private $subChunkCount; - /** @var bool */ - private $cacheEnabled; - /** @var int[] */ - private $usedBlobHashes = []; - /** @var string */ - private $extraPayload; - - public static function withoutCache(int $chunkX, int $chunkZ, int $subChunkCount, string $payload) : self{ - $result = new self; - $result->chunkX = $chunkX; - $result->chunkZ = $chunkZ; - $result->subChunkCount = $subChunkCount; - $result->extraPayload = $payload; - - $result->cacheEnabled = false; - - return $result; - } - - /** - * @param int[] $usedBlobHashes - */ - public static function withCache(int $chunkX, int $chunkZ, int $subChunkCount, array $usedBlobHashes, string $extraPayload) : self{ - (static function(int ...$hashes) : void{})(...$usedBlobHashes); - $result = new self; - $result->chunkX = $chunkX; - $result->chunkZ = $chunkZ; - $result->subChunkCount = $subChunkCount; - $result->extraPayload = $extraPayload; - - $result->cacheEnabled = true; - $result->usedBlobHashes = $usedBlobHashes; - - return $result; - } - - public function getChunkX() : int{ - return $this->chunkX; - } - - public function getChunkZ() : int{ - return $this->chunkZ; - } - - public function getSubChunkCount() : int{ - return $this->subChunkCount; - } - - public function isCacheEnabled() : bool{ - return $this->cacheEnabled; - } - - /** - * @return int[] - */ - public function getUsedBlobHashes() : array{ - return $this->usedBlobHashes; - } - - public function getExtraPayload() : string{ - return $this->extraPayload; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->chunkX = $in->getVarInt(); - $this->chunkZ = $in->getVarInt(); - $this->subChunkCount = $in->getUnsignedVarInt(); - $this->cacheEnabled = $in->getBool(); - if($this->cacheEnabled){ - for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){ - $this->usedBlobHashes[] = $in->getLLong(); - } - } - $this->extraPayload = $in->getString(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putVarInt($this->chunkX); - $out->putVarInt($this->chunkZ); - $out->putUnsignedVarInt($this->subChunkCount); - $out->putBool($this->cacheEnabled); - if($this->cacheEnabled){ - $out->putUnsignedVarInt(count($this->usedBlobHashes)); - foreach($this->usedBlobHashes as $hash){ - $out->putLLong($hash); - } - } - $out->putString($this->extraPayload); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleLevelChunk($this); - } -} diff --git a/src/network/mcpe/protocol/LevelEventGenericPacket.php b/src/network/mcpe/protocol/LevelEventGenericPacket.php deleted file mode 100644 index d538c6658..000000000 --- a/src/network/mcpe/protocol/LevelEventGenericPacket.php +++ /dev/null @@ -1,74 +0,0 @@ - - -use pocketmine\nbt\tag\CompoundTag; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\CacheableNbt; - -class LevelEventGenericPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::LEVEL_EVENT_GENERIC_PACKET; - - /** @var int */ - private $eventId; - /** - * @var CacheableNbt - * @phpstan-var CacheableNbt<\pocketmine\nbt\tag\CompoundTag> - */ - private $eventData; - - public static function create(int $eventId, CompoundTag $data) : self{ - $result = new self; - $result->eventId = $eventId; - $result->eventData = new CacheableNbt($data); - return $result; - } - - public function getEventId() : int{ - return $this->eventId; - } - - /** - * @phpstan-return CacheableNbt<\pocketmine\nbt\tag\CompoundTag> - */ - public function getEventData() : CacheableNbt{ - return $this->eventData; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->eventId = $in->getVarInt(); - $this->eventData = new CacheableNbt($in->getNbtCompoundRoot()); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putVarInt($this->eventId); - $out->put($this->eventData->getEncodedNbt()); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleLevelEventGeneric($this); - } -} diff --git a/src/network/mcpe/protocol/LevelEventPacket.php b/src/network/mcpe/protocol/LevelEventPacket.php deleted file mode 100644 index 6e560f91b..000000000 --- a/src/network/mcpe/protocol/LevelEventPacket.php +++ /dev/null @@ -1,151 +0,0 @@ - - -use pocketmine\math\Vector3; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class LevelEventPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::LEVEL_EVENT_PACKET; - - public const EVENT_SOUND_CLICK = 1000; - public const EVENT_SOUND_CLICK_FAIL = 1001; - public const EVENT_SOUND_SHOOT = 1002; - public const EVENT_SOUND_DOOR = 1003; - public const EVENT_SOUND_FIZZ = 1004; - public const EVENT_SOUND_IGNITE = 1005; - - public const EVENT_SOUND_GHAST = 1007; - public const EVENT_SOUND_GHAST_SHOOT = 1008; - public const EVENT_SOUND_BLAZE_SHOOT = 1009; - public const EVENT_SOUND_DOOR_BUMP = 1010; - - public const EVENT_SOUND_DOOR_CRASH = 1012; - - public const EVENT_SOUND_ENDERMAN_TELEPORT = 1018; - - public const EVENT_SOUND_ANVIL_BREAK = 1020; - public const EVENT_SOUND_ANVIL_USE = 1021; - public const EVENT_SOUND_ANVIL_FALL = 1022; - - public const EVENT_SOUND_POP = 1030; - - public const EVENT_SOUND_PORTAL = 1032; - - public const EVENT_SOUND_ITEMFRAME_ADD_ITEM = 1040; - public const EVENT_SOUND_ITEMFRAME_REMOVE = 1041; - public const EVENT_SOUND_ITEMFRAME_PLACE = 1042; - public const EVENT_SOUND_ITEMFRAME_REMOVE_ITEM = 1043; - public const EVENT_SOUND_ITEMFRAME_ROTATE_ITEM = 1044; - - public const EVENT_SOUND_CAMERA = 1050; - public const EVENT_SOUND_ORB = 1051; - public const EVENT_SOUND_TOTEM = 1052; - - public const EVENT_SOUND_ARMOR_STAND_BREAK = 1060; - public const EVENT_SOUND_ARMOR_STAND_HIT = 1061; - public const EVENT_SOUND_ARMOR_STAND_FALL = 1062; - public const EVENT_SOUND_ARMOR_STAND_PLACE = 1063; - - //TODO: check 2000-2017 - public const EVENT_PARTICLE_SHOOT = 2000; - public const EVENT_PARTICLE_DESTROY = 2001; - public const EVENT_PARTICLE_SPLASH = 2002; - public const EVENT_PARTICLE_EYE_DESPAWN = 2003; - public const EVENT_PARTICLE_SPAWN = 2004; - - public const EVENT_GUARDIAN_CURSE = 2006; - - public const EVENT_PARTICLE_BLOCK_FORCE_FIELD = 2008; - public const EVENT_PARTICLE_PROJECTILE_HIT = 2009; - public const EVENT_PARTICLE_DRAGON_EGG_TELEPORT = 2010; - - public const EVENT_PARTICLE_ENDERMAN_TELEPORT = 2013; - public const EVENT_PARTICLE_PUNCH_BLOCK = 2014; - - public const EVENT_START_RAIN = 3001; - public const EVENT_START_THUNDER = 3002; - public const EVENT_STOP_RAIN = 3003; - public const EVENT_STOP_THUNDER = 3004; - public const EVENT_PAUSE_GAME = 3005; //data: 1 to pause, 0 to resume - public const EVENT_PAUSE_GAME_NO_SCREEN = 3006; //data: 1 to pause, 0 to resume - same effect as normal pause but without screen - public const EVENT_SET_GAME_SPEED = 3007; //x coordinate of pos = scale factor (default 1.0) - - public const EVENT_REDSTONE_TRIGGER = 3500; - public const EVENT_CAULDRON_EXPLODE = 3501; - public const EVENT_CAULDRON_DYE_ARMOR = 3502; - public const EVENT_CAULDRON_CLEAN_ARMOR = 3503; - public const EVENT_CAULDRON_FILL_POTION = 3504; - public const EVENT_CAULDRON_TAKE_POTION = 3505; - public const EVENT_CAULDRON_FILL_WATER = 3506; - public const EVENT_CAULDRON_TAKE_WATER = 3507; - public const EVENT_CAULDRON_ADD_DYE = 3508; - public const EVENT_CAULDRON_CLEAN_BANNER = 3509; - - public const EVENT_BLOCK_START_BREAK = 3600; - public const EVENT_BLOCK_STOP_BREAK = 3601; - - public const EVENT_SET_DATA = 4000; - - public const EVENT_PLAYERS_SLEEPING = 9800; - - public const EVENT_ADD_PARTICLE_MASK = 0x4000; - - /** @var int */ - public $evid; - /** @var Vector3|null */ - public $position; - /** @var int */ - public $data; - - public static function create(int $evid, int $data, ?Vector3 $pos) : self{ - $pk = new self; - $pk->evid = $evid; - $pk->data = $data; - $pk->position = $pos !== null ? $pos->asVector3() : null; - return $pk; - } - - public static function standardParticle(int $particleId, int $data, Vector3 $pos) : self{ - return self::create(self::EVENT_ADD_PARTICLE_MASK | $particleId, $data, $pos); - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->evid = $in->getVarInt(); - $this->position = $in->getVector3(); - $this->data = $in->getVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putVarInt($this->evid); - $out->putVector3Nullable($this->position); - $out->putVarInt($this->data); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleLevelEvent($this); - } -} diff --git a/src/network/mcpe/protocol/LevelSoundEventPacket.php b/src/network/mcpe/protocol/LevelSoundEventPacket.php deleted file mode 100644 index 58476cae8..000000000 --- a/src/network/mcpe/protocol/LevelSoundEventPacket.php +++ /dev/null @@ -1,408 +0,0 @@ - - -use pocketmine\math\Vector3; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class LevelSoundEventPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::LEVEL_SOUND_EVENT_PACKET; - - public const SOUND_ITEM_USE_ON = 0; - public const SOUND_HIT = 1; - public const SOUND_STEP = 2; - public const SOUND_FLY = 3; - public const SOUND_JUMP = 4; - public const SOUND_BREAK = 5; - public const SOUND_PLACE = 6; - public const SOUND_HEAVY_STEP = 7; - public const SOUND_GALLOP = 8; - public const SOUND_FALL = 9; - public const SOUND_AMBIENT = 10; - public const SOUND_AMBIENT_BABY = 11; - public const SOUND_AMBIENT_IN_WATER = 12; - public const SOUND_BREATHE = 13; - public const SOUND_DEATH = 14; - public const SOUND_DEATH_IN_WATER = 15; - public const SOUND_DEATH_TO_ZOMBIE = 16; - public const SOUND_HURT = 17; - public const SOUND_HURT_IN_WATER = 18; - public const SOUND_MAD = 19; - public const SOUND_BOOST = 20; - public const SOUND_BOW = 21; - public const SOUND_SQUISH_BIG = 22; - public const SOUND_SQUISH_SMALL = 23; - public const SOUND_FALL_BIG = 24; - public const SOUND_FALL_SMALL = 25; - public const SOUND_SPLASH = 26; - public const SOUND_FIZZ = 27; - public const SOUND_FLAP = 28; - public const SOUND_SWIM = 29; - public const SOUND_DRINK = 30; - public const SOUND_EAT = 31; - public const SOUND_TAKEOFF = 32; - public const SOUND_SHAKE = 33; - public const SOUND_PLOP = 34; - public const SOUND_LAND = 35; - public const SOUND_SADDLE = 36; - public const SOUND_ARMOR = 37; - public const SOUND_MOB_ARMOR_STAND_PLACE = 38; - public const SOUND_ADD_CHEST = 39; - public const SOUND_THROW = 40; - public const SOUND_ATTACK = 41; - public const SOUND_ATTACK_NODAMAGE = 42; - public const SOUND_ATTACK_STRONG = 43; - public const SOUND_WARN = 44; - public const SOUND_SHEAR = 45; - public const SOUND_MILK = 46; - public const SOUND_THUNDER = 47; - public const SOUND_EXPLODE = 48; - public const SOUND_FIRE = 49; - public const SOUND_IGNITE = 50; - public const SOUND_FUSE = 51; - public const SOUND_STARE = 52; - public const SOUND_SPAWN = 53; - public const SOUND_SHOOT = 54; - public const SOUND_BREAK_BLOCK = 55; - public const SOUND_LAUNCH = 56; - public const SOUND_BLAST = 57; - public const SOUND_LARGE_BLAST = 58; - public const SOUND_TWINKLE = 59; - public const SOUND_REMEDY = 60; - public const SOUND_UNFECT = 61; - public const SOUND_LEVELUP = 62; - public const SOUND_BOW_HIT = 63; - public const SOUND_BULLET_HIT = 64; - public const SOUND_EXTINGUISH_FIRE = 65; - public const SOUND_ITEM_FIZZ = 66; - public const SOUND_CHEST_OPEN = 67; - public const SOUND_CHEST_CLOSED = 68; - public const SOUND_SHULKERBOX_OPEN = 69; - public const SOUND_SHULKERBOX_CLOSED = 70; - public const SOUND_ENDERCHEST_OPEN = 71; - public const SOUND_ENDERCHEST_CLOSED = 72; - public const SOUND_POWER_ON = 73; - public const SOUND_POWER_OFF = 74; - public const SOUND_ATTACH = 75; - public const SOUND_DETACH = 76; - public const SOUND_DENY = 77; - public const SOUND_TRIPOD = 78; - public const SOUND_POP = 79; - public const SOUND_DROP_SLOT = 80; - public const SOUND_NOTE = 81; - public const SOUND_THORNS = 82; - public const SOUND_PISTON_IN = 83; - public const SOUND_PISTON_OUT = 84; - public const SOUND_PORTAL = 85; - public const SOUND_WATER = 86; - public const SOUND_LAVA_POP = 87; - public const SOUND_LAVA = 88; - public const SOUND_BURP = 89; - public const SOUND_BUCKET_FILL_WATER = 90; - public const SOUND_BUCKET_FILL_LAVA = 91; - public const SOUND_BUCKET_EMPTY_WATER = 92; - public const SOUND_BUCKET_EMPTY_LAVA = 93; - public const SOUND_ARMOR_EQUIP_CHAIN = 94; - public const SOUND_ARMOR_EQUIP_DIAMOND = 95; - public const SOUND_ARMOR_EQUIP_GENERIC = 96; - public const SOUND_ARMOR_EQUIP_GOLD = 97; - public const SOUND_ARMOR_EQUIP_IRON = 98; - public const SOUND_ARMOR_EQUIP_LEATHER = 99; - public const SOUND_ARMOR_EQUIP_ELYTRA = 100; - public const SOUND_RECORD_13 = 101; - public const SOUND_RECORD_CAT = 102; - public const SOUND_RECORD_BLOCKS = 103; - public const SOUND_RECORD_CHIRP = 104; - public const SOUND_RECORD_FAR = 105; - public const SOUND_RECORD_MALL = 106; - public const SOUND_RECORD_MELLOHI = 107; - public const SOUND_RECORD_STAL = 108; - public const SOUND_RECORD_STRAD = 109; - public const SOUND_RECORD_WARD = 110; - public const SOUND_RECORD_11 = 111; - public const SOUND_RECORD_WAIT = 112; - public const SOUND_STOP_RECORD = 113; //Not really a sound - public const SOUND_FLOP = 114; - public const SOUND_ELDERGUARDIAN_CURSE = 115; - public const SOUND_MOB_WARNING = 116; - public const SOUND_MOB_WARNING_BABY = 117; - public const SOUND_TELEPORT = 118; - public const SOUND_SHULKER_OPEN = 119; - public const SOUND_SHULKER_CLOSE = 120; - public const SOUND_HAGGLE = 121; - public const SOUND_HAGGLE_YES = 122; - public const SOUND_HAGGLE_NO = 123; - public const SOUND_HAGGLE_IDLE = 124; - public const SOUND_CHORUSGROW = 125; - public const SOUND_CHORUSDEATH = 126; - public const SOUND_GLASS = 127; - public const SOUND_POTION_BREWED = 128; - public const SOUND_CAST_SPELL = 129; - public const SOUND_PREPARE_ATTACK = 130; - public const SOUND_PREPARE_SUMMON = 131; - public const SOUND_PREPARE_WOLOLO = 132; - public const SOUND_FANG = 133; - public const SOUND_CHARGE = 134; - public const SOUND_CAMERA_TAKE_PICTURE = 135; - public const SOUND_LEASHKNOT_PLACE = 136; - public const SOUND_LEASHKNOT_BREAK = 137; - public const SOUND_GROWL = 138; - public const SOUND_WHINE = 139; - public const SOUND_PANT = 140; - public const SOUND_PURR = 141; - public const SOUND_PURREOW = 142; - public const SOUND_DEATH_MIN_VOLUME = 143; - public const SOUND_DEATH_MID_VOLUME = 144; - public const SOUND_IMITATE_BLAZE = 145; - public const SOUND_IMITATE_CAVE_SPIDER = 146; - public const SOUND_IMITATE_CREEPER = 147; - public const SOUND_IMITATE_ELDER_GUARDIAN = 148; - public const SOUND_IMITATE_ENDER_DRAGON = 149; - public const SOUND_IMITATE_ENDERMAN = 150; - - public const SOUND_IMITATE_EVOCATION_ILLAGER = 152; - public const SOUND_IMITATE_GHAST = 153; - public const SOUND_IMITATE_HUSK = 154; - public const SOUND_IMITATE_ILLUSION_ILLAGER = 155; - public const SOUND_IMITATE_MAGMA_CUBE = 156; - public const SOUND_IMITATE_POLAR_BEAR = 157; - public const SOUND_IMITATE_SHULKER = 158; - public const SOUND_IMITATE_SILVERFISH = 159; - public const SOUND_IMITATE_SKELETON = 160; - public const SOUND_IMITATE_SLIME = 161; - public const SOUND_IMITATE_SPIDER = 162; - public const SOUND_IMITATE_STRAY = 163; - public const SOUND_IMITATE_VEX = 164; - public const SOUND_IMITATE_VINDICATION_ILLAGER = 165; - public const SOUND_IMITATE_WITCH = 166; - public const SOUND_IMITATE_WITHER = 167; - public const SOUND_IMITATE_WITHER_SKELETON = 168; - public const SOUND_IMITATE_WOLF = 169; - public const SOUND_IMITATE_ZOMBIE = 170; - public const SOUND_IMITATE_ZOMBIE_PIGMAN = 171; - public const SOUND_IMITATE_ZOMBIE_VILLAGER = 172; - public const SOUND_BLOCK_END_PORTAL_FRAME_FILL = 173; - public const SOUND_BLOCK_END_PORTAL_SPAWN = 174; - public const SOUND_RANDOM_ANVIL_USE = 175; - public const SOUND_BOTTLE_DRAGONBREATH = 176; - public const SOUND_PORTAL_TRAVEL = 177; - public const SOUND_ITEM_TRIDENT_HIT = 178; - public const SOUND_ITEM_TRIDENT_RETURN = 179; - public const SOUND_ITEM_TRIDENT_RIPTIDE_1 = 180; - public const SOUND_ITEM_TRIDENT_RIPTIDE_2 = 181; - public const SOUND_ITEM_TRIDENT_RIPTIDE_3 = 182; - public const SOUND_ITEM_TRIDENT_THROW = 183; - public const SOUND_ITEM_TRIDENT_THUNDER = 184; - public const SOUND_ITEM_TRIDENT_HIT_GROUND = 185; - public const SOUND_DEFAULT = 186; - public const SOUND_BLOCK_FLETCHING_TABLE_USE = 187; - public const SOUND_ELEMCONSTRUCT_OPEN = 188; - public const SOUND_ICEBOMB_HIT = 189; - public const SOUND_BALLOONPOP = 190; - public const SOUND_LT_REACTION_ICEBOMB = 191; - public const SOUND_LT_REACTION_BLEACH = 192; - public const SOUND_LT_REACTION_EPASTE = 193; - public const SOUND_LT_REACTION_EPASTE2 = 194; - - public const SOUND_LT_REACTION_FERTILIZER = 199; - public const SOUND_LT_REACTION_FIREBALL = 200; - public const SOUND_LT_REACTION_MGSALT = 201; - public const SOUND_LT_REACTION_MISCFIRE = 202; - public const SOUND_LT_REACTION_FIRE = 203; - public const SOUND_LT_REACTION_MISCEXPLOSION = 204; - public const SOUND_LT_REACTION_MISCMYSTICAL = 205; - public const SOUND_LT_REACTION_MISCMYSTICAL2 = 206; - public const SOUND_LT_REACTION_PRODUCT = 207; - public const SOUND_SPARKLER_USE = 208; - public const SOUND_GLOWSTICK_USE = 209; - public const SOUND_SPARKLER_ACTIVE = 210; - public const SOUND_CONVERT_TO_DROWNED = 211; - public const SOUND_BUCKET_FILL_FISH = 212; - public const SOUND_BUCKET_EMPTY_FISH = 213; - public const SOUND_BUBBLE_UP = 214; - public const SOUND_BUBBLE_DOWN = 215; - public const SOUND_BUBBLE_POP = 216; - public const SOUND_BUBBLE_UPINSIDE = 217; - public const SOUND_BUBBLE_DOWNINSIDE = 218; - public const SOUND_HURT_BABY = 219; - public const SOUND_DEATH_BABY = 220; - public const SOUND_STEP_BABY = 221; - - public const SOUND_BORN = 223; - public const SOUND_BLOCK_TURTLE_EGG_BREAK = 224; - public const SOUND_BLOCK_TURTLE_EGG_CRACK = 225; - public const SOUND_BLOCK_TURTLE_EGG_HATCH = 226; - public const SOUND_LAY_EGG = 227; - public const SOUND_BLOCK_TURTLE_EGG_ATTACK = 228; - public const SOUND_BEACON_ACTIVATE = 229; - public const SOUND_BEACON_AMBIENT = 230; - public const SOUND_BEACON_DEACTIVATE = 231; - public const SOUND_BEACON_POWER = 232; - public const SOUND_CONDUIT_ACTIVATE = 233; - public const SOUND_CONDUIT_AMBIENT = 234; - public const SOUND_CONDUIT_ATTACK = 235; - public const SOUND_CONDUIT_DEACTIVATE = 236; - public const SOUND_CONDUIT_SHORT = 237; - public const SOUND_SWOOP = 238; - public const SOUND_BLOCK_BAMBOO_SAPLING_PLACE = 239; - public const SOUND_PRESNEEZE = 240; - public const SOUND_SNEEZE = 241; - public const SOUND_AMBIENT_TAME = 242; - public const SOUND_SCARED = 243; - public const SOUND_BLOCK_SCAFFOLDING_CLIMB = 244; - public const SOUND_CROSSBOW_LOADING_START = 245; - public const SOUND_CROSSBOW_LOADING_MIDDLE = 246; - public const SOUND_CROSSBOW_LOADING_END = 247; - public const SOUND_CROSSBOW_SHOOT = 248; - public const SOUND_CROSSBOW_QUICK_CHARGE_START = 249; - public const SOUND_CROSSBOW_QUICK_CHARGE_MIDDLE = 250; - public const SOUND_CROSSBOW_QUICK_CHARGE_END = 251; - public const SOUND_AMBIENT_AGGRESSIVE = 252; - public const SOUND_AMBIENT_WORRIED = 253; - public const SOUND_CANT_BREED = 254; - public const SOUND_ITEM_SHIELD_BLOCK = 255; - public const SOUND_ITEM_BOOK_PUT = 256; - public const SOUND_BLOCK_GRINDSTONE_USE = 257; - public const SOUND_BLOCK_BELL_HIT = 258; - public const SOUND_BLOCK_CAMPFIRE_CRACKLE = 259; - public const SOUND_ROAR = 260; - public const SOUND_STUN = 261; - public const SOUND_BLOCK_SWEET_BERRY_BUSH_HURT = 262; - public const SOUND_BLOCK_SWEET_BERRY_BUSH_PICK = 263; - public const SOUND_BLOCK_CARTOGRAPHY_TABLE_USE = 264; - public const SOUND_BLOCK_STONECUTTER_USE = 265; - public const SOUND_BLOCK_COMPOSTER_EMPTY = 266; - public const SOUND_BLOCK_COMPOSTER_FILL = 267; - public const SOUND_BLOCK_COMPOSTER_FILL_SUCCESS = 268; - public const SOUND_BLOCK_COMPOSTER_READY = 269; - public const SOUND_BLOCK_BARREL_OPEN = 270; - public const SOUND_BLOCK_BARREL_CLOSE = 271; - public const SOUND_RAID_HORN = 272; - public const SOUND_BLOCK_LOOM_USE = 273; - public const SOUND_AMBIENT_IN_RAID = 274; - public const SOUND_UI_CARTOGRAPHY_TABLE_TAKE_RESULT = 275; - public const SOUND_UI_STONECUTTER_TAKE_RESULT = 276; - public const SOUND_UI_LOOM_TAKE_RESULT = 277; - public const SOUND_BLOCK_SMOKER_SMOKE = 278; - public const SOUND_BLOCK_BLASTFURNACE_FIRE_CRACKLE = 279; - public const SOUND_BLOCK_SMITHING_TABLE_USE = 280; - public const SOUND_SCREECH = 281; - public const SOUND_SLEEP = 282; - public const SOUND_BLOCK_FURNACE_LIT = 283; - public const SOUND_CONVERT_MOOSHROOM = 284; - public const SOUND_MILK_SUSPICIOUSLY = 285; - public const SOUND_CELEBRATE = 286; - public const SOUND_JUMP_PREVENT = 287; - public const SOUND_AMBIENT_POLLINATE = 288; - public const SOUND_BLOCK_BEEHIVE_DRIP = 289; - public const SOUND_BLOCK_BEEHIVE_ENTER = 290; - public const SOUND_BLOCK_BEEHIVE_EXIT = 291; - public const SOUND_BLOCK_BEEHIVE_WORK = 292; - public const SOUND_BLOCK_BEEHIVE_SHEAR = 293; - public const SOUND_DRINK_HONEY = 294; - public const SOUND_AMBIENT_CAVE = 295; - public const SOUND_RETREAT = 296; - public const SOUND_CONVERTED_TO_ZOMBIFIED = 297; - public const SOUND_ADMIRE = 298; - public const SOUND_STEP_LAVA = 299; - public const SOUND_TEMPT = 300; - public const SOUND_PANIC = 301; - public const SOUND_ANGRY = 302; - public const SOUND_AMBIENT_WARPED_FOREST_MOOD = 303; - public const SOUND_AMBIENT_SOULSAND_VALLEY_MOOD = 304; - public const SOUND_AMBIENT_NETHER_WASTES_MOOD = 305; - public const SOUND_RESPAWN_ANCHOR_BASALT_DELTAS_MOOD = 306; - public const SOUND_AMBIENT_CRIMSON_FOREST_MOOD = 307; - public const SOUND_RESPAWN_ANCHOR_CHARGE = 308; - public const SOUND_RESPAWN_ANCHOR_DEPLETE = 309; - public const SOUND_RESPAWN_ANCHOR_SET_SPAWN = 310; - public const SOUND_RESPAWN_ANCHOR_AMBIENT = 311; - public const SOUND_PARTICLE_SOUL_ESCAPE_QUIET = 312; - public const SOUND_PARTICLE_SOUL_ESCAPE_LOUD = 313; - public const SOUND_RECORD_PIGSTEP = 314; - public const SOUND_LODESTONE_COMPASS_LINK_COMPASS_TO_LODESTONE = 315; - public const SOUND_SMITHING_TABLE_USE = 316; - public const SOUND_ARMOR_EQUIP_NETHERITE = 317; - public const SOUND_AMBIENT_WARPED_FOREST_LOOP = 318; - public const SOUND_AMBIENT_SOULSAND_VALLEY_LOOP = 319; - public const SOUND_AMBIENT_NETHER_WASTES_LOOP = 320; - public const SOUND_AMBIENT_BASALT_DELTAS_LOOP = 321; - public const SOUND_AMBIENT_CRIMSON_FOREST_LOOP = 322; - public const SOUND_AMBIENT_WARPED_FOREST_ADDITIONS = 323; - public const SOUND_AMBIENT_SOULSAND_VALLEY_ADDITIONS = 324; - public const SOUND_AMBIENT_NETHER_WASTES_ADDITIONS = 325; - public const SOUND_AMBIENT_BASALT_DELTAS_ADDITIONS = 326; - public const SOUND_AMBIENT_CRIMSON_FOREST_ADDITIONS = 327; - public const SOUND_BUCKET_FILL_POWDER_SNOW = 328; - public const SOUND_BUCKET_EMPTY_POWDER_SNOW = 329; - public const SOUND_UNDEFINED = 330; - - public static function create(int $sound, ?Vector3 $pos, int $extraData = -1, string $entityType = ":", bool $isBabyMob = false) : self{ - $result = new self; - $result->sound = $sound; - $result->extraData = $extraData; - $result->position = $pos ?? new Vector3(0, 0, 0); - $result->disableRelativeVolume = $pos === null; - $result->entityType = $entityType; - $result->isBabyMob = $isBabyMob; - return $result; - } - - /** @var int */ - public $sound; - /** @var Vector3 */ - public $position; - /** @var int */ - public $extraData = -1; - /** @var string */ - public $entityType = ":"; //??? - /** @var bool */ - public $isBabyMob = false; //... - /** @var bool */ - public $disableRelativeVolume = false; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->sound = $in->getUnsignedVarInt(); - $this->position = $in->getVector3(); - $this->extraData = $in->getVarInt(); - $this->entityType = $in->getString(); - $this->isBabyMob = $in->getBool(); - $this->disableRelativeVolume = $in->getBool(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt($this->sound); - $out->putVector3($this->position); - $out->putVarInt($this->extraData); - $out->putString($this->entityType); - $out->putBool($this->isBabyMob); - $out->putBool($this->disableRelativeVolume); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleLevelSoundEvent($this); - } -} diff --git a/src/network/mcpe/protocol/LevelSoundEventPacketV1.php b/src/network/mcpe/protocol/LevelSoundEventPacketV1.php deleted file mode 100644 index 213db6f71..000000000 --- a/src/network/mcpe/protocol/LevelSoundEventPacketV1.php +++ /dev/null @@ -1,71 +0,0 @@ - - -use pocketmine\math\Vector3; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -/** - * Useless leftover from a 1.8 refactor, does nothing - */ -class LevelSoundEventPacketV1 extends DataPacket{ - public const NETWORK_ID = ProtocolInfo::LEVEL_SOUND_EVENT_PACKET_V1; - - /** @var int */ - public $sound; - /** @var Vector3 */ - public $position; - /** @var int */ - public $extraData = 0; - /** @var int */ - public $entityType = 1; - /** @var bool */ - public $isBabyMob = false; //... - /** @var bool */ - public $disableRelativeVolume = false; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->sound = $in->getByte(); - $this->position = $in->getVector3(); - $this->extraData = $in->getVarInt(); - $this->entityType = $in->getVarInt(); - $this->isBabyMob = $in->getBool(); - $this->disableRelativeVolume = $in->getBool(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putByte($this->sound); - $out->putVector3($this->position); - $out->putVarInt($this->extraData); - $out->putVarInt($this->entityType); - $out->putBool($this->isBabyMob); - $out->putBool($this->disableRelativeVolume); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleLevelSoundEventPacketV1($this); - } -} diff --git a/src/network/mcpe/protocol/LevelSoundEventPacketV2.php b/src/network/mcpe/protocol/LevelSoundEventPacketV2.php deleted file mode 100644 index 934004602..000000000 --- a/src/network/mcpe/protocol/LevelSoundEventPacketV2.php +++ /dev/null @@ -1,71 +0,0 @@ - - -use pocketmine\math\Vector3; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -/** - * Useless leftover from a 1.9 refactor, does nothing - */ -class LevelSoundEventPacketV2 extends DataPacket{ - public const NETWORK_ID = ProtocolInfo::LEVEL_SOUND_EVENT_PACKET_V2; - - /** @var int */ - public $sound; - /** @var Vector3 */ - public $position; - /** @var int */ - public $extraData = -1; - /** @var string */ - public $entityType = ":"; //??? - /** @var bool */ - public $isBabyMob = false; //... - /** @var bool */ - public $disableRelativeVolume = false; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->sound = $in->getByte(); - $this->position = $in->getVector3(); - $this->extraData = $in->getVarInt(); - $this->entityType = $in->getString(); - $this->isBabyMob = $in->getBool(); - $this->disableRelativeVolume = $in->getBool(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putByte($this->sound); - $out->putVector3($this->position); - $out->putVarInt($this->extraData); - $out->putString($this->entityType); - $out->putBool($this->isBabyMob); - $out->putBool($this->disableRelativeVolume); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleLevelSoundEventPacketV2($this); - } -} diff --git a/src/network/mcpe/protocol/LoginPacket.php b/src/network/mcpe/protocol/LoginPacket.php deleted file mode 100644 index 615afa138..000000000 --- a/src/network/mcpe/protocol/LoginPacket.php +++ /dev/null @@ -1,101 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\login\JwtChain; -use pocketmine\utils\BinaryStream; -use function is_object; -use function json_decode; -use function json_encode; -use function json_last_error_msg; -use function strlen; - -class LoginPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::LOGIN_PACKET; - - /** @var int */ - public $protocol; - - /** @var JwtChain */ - public $chainDataJwt; - /** @var string */ - public $clientDataJwt; - - public function canBeSentBeforeLogin() : bool{ - return true; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->protocol = $in->getInt(); - $this->decodeConnectionRequest($in->getString()); - } - - protected function decodeConnectionRequest(string $binary) : void{ - $connRequestReader = new BinaryStream($binary); - - $chainDataJson = json_decode($connRequestReader->get($connRequestReader->getLInt())); - if(!is_object($chainDataJson)){ - throw new PacketDecodeException("Failed decoding chain data JSON: " . json_last_error_msg()); - } - $mapper = new \JsonMapper; - $mapper->bExceptionOnMissingData = true; - $mapper->bExceptionOnUndefinedProperty = true; - try{ - $chainData = $mapper->map($chainDataJson, new JwtChain); - }catch(\JsonMapper_Exception $e){ - throw PacketDecodeException::wrap($e); - } - - $this->chainDataJwt = $chainData; - $this->clientDataJwt = $connRequestReader->get($connRequestReader->getLInt()); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putInt($this->protocol); - $out->putString($this->encodeConnectionRequest()); - } - - protected function encodeConnectionRequest() : string{ - $connRequestWriter = new BinaryStream(); - - $chainDataJson = json_encode($this->chainDataJwt); - if($chainDataJson === false){ - throw new \InvalidStateException("Failed to encode chain data JSON: " . json_last_error_msg()); - } - $connRequestWriter->putLInt(strlen($chainDataJson)); - $connRequestWriter->put($chainDataJson); - - $connRequestWriter->putLInt(strlen($this->clientDataJwt)); - $connRequestWriter->put($this->clientDataJwt); - - return $connRequestWriter->getBuffer(); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleLogin($this); - } -} diff --git a/src/network/mcpe/protocol/MapCreateLockedCopyPacket.php b/src/network/mcpe/protocol/MapCreateLockedCopyPacket.php deleted file mode 100644 index 2c74b60e1..000000000 --- a/src/network/mcpe/protocol/MapCreateLockedCopyPacket.php +++ /dev/null @@ -1,51 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class MapCreateLockedCopyPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::MAP_CREATE_LOCKED_COPY_PACKET; - - /** @var int */ - public $originalMapId; - /** @var int */ - public $newMapId; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->originalMapId = $in->getEntityUniqueId(); - $this->newMapId = $in->getEntityUniqueId(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityUniqueId($this->originalMapId); - $out->putEntityUniqueId($this->newMapId); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleMapCreateLockedCopy($this); - } -} diff --git a/src/network/mcpe/protocol/MapInfoRequestPacket.php b/src/network/mcpe/protocol/MapInfoRequestPacket.php deleted file mode 100644 index 7d8ac82f0..000000000 --- a/src/network/mcpe/protocol/MapInfoRequestPacket.php +++ /dev/null @@ -1,47 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class MapInfoRequestPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::MAP_INFO_REQUEST_PACKET; - - /** @var int */ - public $mapId; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->mapId = $in->getEntityUniqueId(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityUniqueId($this->mapId); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleMapInfoRequest($this); - } -} diff --git a/src/network/mcpe/protocol/MobArmorEquipmentPacket.php b/src/network/mcpe/protocol/MobArmorEquipmentPacket.php deleted file mode 100644 index 813101d6b..000000000 --- a/src/network/mcpe/protocol/MobArmorEquipmentPacket.php +++ /dev/null @@ -1,78 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper; - -class MobArmorEquipmentPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::MOB_ARMOR_EQUIPMENT_PACKET; - - /** @var int */ - public $entityRuntimeId; - - //this intentionally doesn't use an array because we don't want any implicit dependencies on internal order - - /** @var ItemStackWrapper */ - public $head; - /** @var ItemStackWrapper */ - public $chest; - /** @var ItemStackWrapper */ - public $legs; - /** @var ItemStackWrapper */ - public $feet; - - public static function create(int $entityRuntimeId, ItemStackWrapper $head, ItemStackWrapper $chest, ItemStackWrapper $legs, ItemStackWrapper $feet) : self{ - $result = new self; - $result->entityRuntimeId = $entityRuntimeId; - $result->head = $head; - $result->chest = $chest; - $result->legs = $legs; - $result->feet = $feet; - - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityRuntimeId = $in->getEntityRuntimeId(); - $this->head = ItemStackWrapper::read($in); - $this->chest = ItemStackWrapper::read($in); - $this->legs = ItemStackWrapper::read($in); - $this->feet = ItemStackWrapper::read($in); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityRuntimeId($this->entityRuntimeId); - $this->head->write($out); - $this->chest->write($out); - $this->legs->write($out); - $this->feet->write($out); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleMobArmorEquipment($this); - } -} diff --git a/src/network/mcpe/protocol/MobEffectPacket.php b/src/network/mcpe/protocol/MobEffectPacket.php deleted file mode 100644 index 7265c2253..000000000 --- a/src/network/mcpe/protocol/MobEffectPacket.php +++ /dev/null @@ -1,90 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class MobEffectPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::MOB_EFFECT_PACKET; - - public const EVENT_ADD = 1; - public const EVENT_MODIFY = 2; - public const EVENT_REMOVE = 3; - - /** @var int */ - public $entityRuntimeId; - /** @var int */ - public $eventId; - /** @var int */ - public $effectId; - /** @var int */ - public $amplifier = 0; - /** @var bool */ - public $particles = true; - /** @var int */ - public $duration = 0; - - public static function add(int $entityRuntimeId, bool $replace, int $effectId, int $amplifier, bool $particles, int $duration) : self{ - $result = new self; - $result->eventId = $replace ? self::EVENT_MODIFY : self::EVENT_ADD; - $result->entityRuntimeId = $entityRuntimeId; - $result->effectId = $effectId; - $result->amplifier = $amplifier; - $result->particles = $particles; - $result->duration = $duration; - return $result; - } - - public static function remove(int $entityRuntimeId, int $effectId) : self{ - $pk = new self; - $pk->eventId = self::EVENT_REMOVE; - $pk->entityRuntimeId = $entityRuntimeId; - $pk->effectId = $effectId; - return $pk; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityRuntimeId = $in->getEntityRuntimeId(); - $this->eventId = $in->getByte(); - $this->effectId = $in->getVarInt(); - $this->amplifier = $in->getVarInt(); - $this->particles = $in->getBool(); - $this->duration = $in->getVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityRuntimeId($this->entityRuntimeId); - $out->putByte($this->eventId); - $out->putVarInt($this->effectId); - $out->putVarInt($this->amplifier); - $out->putBool($this->particles); - $out->putVarInt($this->duration); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleMobEffect($this); - } -} diff --git a/src/network/mcpe/protocol/MobEquipmentPacket.php b/src/network/mcpe/protocol/MobEquipmentPacket.php deleted file mode 100644 index 2f36f1cb5..000000000 --- a/src/network/mcpe/protocol/MobEquipmentPacket.php +++ /dev/null @@ -1,74 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper; - -class MobEquipmentPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::MOB_EQUIPMENT_PACKET; - - /** @var int */ - public $entityRuntimeId; - /** @var ItemStackWrapper */ - public $item; - /** @var int */ - public $inventorySlot; - /** @var int */ - public $hotbarSlot; - /** @var int */ - public $windowId = 0; - - public static function create(int $entityRuntimeId, ItemStackWrapper $item, int $inventorySlot, int $windowId) : self{ - $result = new self; - $result->entityRuntimeId = $entityRuntimeId; - $result->item = $item; - $result->inventorySlot = $inventorySlot; - $result->hotbarSlot = $inventorySlot; - $result->windowId = $windowId; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityRuntimeId = $in->getEntityRuntimeId(); - $this->item = ItemStackWrapper::read($in); - $this->inventorySlot = $in->getByte(); - $this->hotbarSlot = $in->getByte(); - $this->windowId = $in->getByte(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityRuntimeId($this->entityRuntimeId); - $this->item->write($out); - $out->putByte($this->inventorySlot); - $out->putByte($this->hotbarSlot); - $out->putByte($this->windowId); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleMobEquipment($this); - } -} diff --git a/src/network/mcpe/protocol/ModalFormRequestPacket.php b/src/network/mcpe/protocol/ModalFormRequestPacket.php deleted file mode 100644 index 0d00021e3..000000000 --- a/src/network/mcpe/protocol/ModalFormRequestPacket.php +++ /dev/null @@ -1,58 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class ModalFormRequestPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::MODAL_FORM_REQUEST_PACKET; - - /** @var int */ - public $formId; - /** @var string */ - public $formData; //json - - public static function create(int $formId, string $formData) : self{ - $result = new self; - $result->formId = $formId; - $result->formData = $formData; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->formId = $in->getUnsignedVarInt(); - $this->formData = $in->getString(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt($this->formId); - $out->putString($this->formData); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleModalFormRequest($this); - } -} diff --git a/src/network/mcpe/protocol/ModalFormResponsePacket.php b/src/network/mcpe/protocol/ModalFormResponsePacket.php deleted file mode 100644 index 1d7d552a5..000000000 --- a/src/network/mcpe/protocol/ModalFormResponsePacket.php +++ /dev/null @@ -1,51 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class ModalFormResponsePacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::MODAL_FORM_RESPONSE_PACKET; - - /** @var int */ - public $formId; - /** @var string */ - public $formData; //json - - protected function decodePayload(PacketSerializer $in) : void{ - $this->formId = $in->getUnsignedVarInt(); - $this->formData = $in->getString(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt($this->formId); - $out->putString($this->formData); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleModalFormResponse($this); - } -} diff --git a/src/network/mcpe/protocol/MotionPredictionHintsPacket.php b/src/network/mcpe/protocol/MotionPredictionHintsPacket.php deleted file mode 100644 index 8afe9b9f3..000000000 --- a/src/network/mcpe/protocol/MotionPredictionHintsPacket.php +++ /dev/null @@ -1,70 +0,0 @@ - - -use pocketmine\math\Vector3; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class MotionPredictionHintsPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::MOTION_PREDICTION_HINTS_PACKET; - - /** @var int */ - private $entityRuntimeId; - /** @var Vector3 */ - private $motion; - /** @var bool */ - private $onGround; - - public static function create(int $entityRuntimeId, Vector3 $motion, bool $onGround) : self{ - $result = new self; - $result->entityRuntimeId = $entityRuntimeId; - $result->motion = $motion; - $result->onGround = $onGround; - return $result; - } - - public function getEntityRuntimeId() : int{ return $this->entityRuntimeId; } - - public function getMotion() : Vector3{ return $this->motion; } - - public function isOnGround() : bool{ return $this->onGround; } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityRuntimeId = $in->getEntityRuntimeId(); - $this->motion = $in->getVector3(); - $this->onGround = $in->getBool(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityRuntimeId($this->entityRuntimeId); - $out->putVector3($this->motion); - $out->putBool($this->onGround); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleMotionPredictionHints($this); - } -} diff --git a/src/network/mcpe/protocol/MoveActorAbsolutePacket.php b/src/network/mcpe/protocol/MoveActorAbsolutePacket.php deleted file mode 100644 index a987cc51f..000000000 --- a/src/network/mcpe/protocol/MoveActorAbsolutePacket.php +++ /dev/null @@ -1,83 +0,0 @@ - - -use pocketmine\math\Vector3; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class MoveActorAbsolutePacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::MOVE_ACTOR_ABSOLUTE_PACKET; - - public const FLAG_GROUND = 0x01; - public const FLAG_TELEPORT = 0x02; - public const FLAG_FORCE_MOVE_LOCAL_ENTITY = 0x04; - - /** @var int */ - public $entityRuntimeId; - /** @var int */ - public $flags = 0; - /** @var Vector3 */ - public $position; - /** @var float */ - public $xRot; - /** @var float */ - public $yRot; - /** @var float */ - public $zRot; - - public static function create(int $entityRuntimeId, Vector3 $pos, float $xRot, float $yRot, float $zRot, int $flags = 0) : self{ - $result = new self; - $result->entityRuntimeId = $entityRuntimeId; - $result->position = $pos->asVector3(); - $result->xRot = $xRot; - $result->yRot = $yRot; - $result->zRot = $zRot; - $result->flags = $flags; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityRuntimeId = $in->getEntityRuntimeId(); - $this->flags = $in->getByte(); - $this->position = $in->getVector3(); - $this->xRot = $in->getByteRotation(); - $this->yRot = $in->getByteRotation(); - $this->zRot = $in->getByteRotation(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityRuntimeId($this->entityRuntimeId); - $out->putByte($this->flags); - $out->putVector3($this->position); - $out->putByteRotation($this->xRot); - $out->putByteRotation($this->yRot); - $out->putByteRotation($this->zRot); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleMoveActorAbsolute($this); - } -} diff --git a/src/network/mcpe/protocol/MoveActorDeltaPacket.php b/src/network/mcpe/protocol/MoveActorDeltaPacket.php deleted file mode 100644 index 30ac900e5..000000000 --- a/src/network/mcpe/protocol/MoveActorDeltaPacket.php +++ /dev/null @@ -1,118 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\utils\BinaryDataException; - -class MoveActorDeltaPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::MOVE_ACTOR_DELTA_PACKET; - - public const FLAG_HAS_X = 0x01; - public const FLAG_HAS_Y = 0x02; - public const FLAG_HAS_Z = 0x04; - public const FLAG_HAS_ROT_X = 0x08; - public const FLAG_HAS_ROT_Y = 0x10; - public const FLAG_HAS_ROT_Z = 0x20; - public const FLAG_GROUND = 0x40; - public const FLAG_TELEPORT = 0x80; - public const FLAG_FORCE_MOVE_LOCAL_ENTITY = 0x100; - - /** @var int */ - public $entityRuntimeId; - /** @var int */ - public $flags; - /** @var float */ - public $xPos = 0; - /** @var float */ - public $yPos = 0; - /** @var float */ - public $zPos = 0; - /** @var float */ - public $xRot = 0.0; - /** @var float */ - public $yRot = 0.0; - /** @var float */ - public $zRot = 0.0; - - /** - * @throws BinaryDataException - */ - private function maybeReadCoord(int $flag, PacketSerializer $in) : float{ - if(($this->flags & $flag) !== 0){ - return $in->getLFloat(); - } - return 0; - } - - /** - * @throws BinaryDataException - */ - private function maybeReadRotation(int $flag, PacketSerializer $in) : float{ - if(($this->flags & $flag) !== 0){ - return $in->getByteRotation(); - } - return 0.0; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityRuntimeId = $in->getEntityRuntimeId(); - $this->flags = $in->getLShort(); - $this->xPos = $this->maybeReadCoord(self::FLAG_HAS_X, $in); - $this->yPos = $this->maybeReadCoord(self::FLAG_HAS_Y, $in); - $this->zPos = $this->maybeReadCoord(self::FLAG_HAS_Z, $in); - $this->xRot = $this->maybeReadRotation(self::FLAG_HAS_ROT_X, $in); - $this->yRot = $this->maybeReadRotation(self::FLAG_HAS_ROT_Y, $in); - $this->zRot = $this->maybeReadRotation(self::FLAG_HAS_ROT_Z, $in); - } - - private function maybeWriteCoord(int $flag, float $val, PacketSerializer $out) : void{ - if(($this->flags & $flag) !== 0){ - $out->putLFloat($val); - } - } - - private function maybeWriteRotation(int $flag, float $val, PacketSerializer $out) : void{ - if(($this->flags & $flag) !== 0){ - $out->putByteRotation($val); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityRuntimeId($this->entityRuntimeId); - $out->putLShort($this->flags); - $this->maybeWriteCoord(self::FLAG_HAS_X, $this->xPos, $out); - $this->maybeWriteCoord(self::FLAG_HAS_Y, $this->yPos, $out); - $this->maybeWriteCoord(self::FLAG_HAS_Z, $this->zPos, $out); - $this->maybeWriteRotation(self::FLAG_HAS_ROT_X, $this->xRot, $out); - $this->maybeWriteRotation(self::FLAG_HAS_ROT_Y, $this->yRot, $out); - $this->maybeWriteRotation(self::FLAG_HAS_ROT_Z, $this->zRot, $out); - } - - public function handle(PacketHandlerInterface $session) : bool{ - return $session->handleMoveActorDelta($this); - } -} diff --git a/src/network/mcpe/protocol/MovePlayerPacket.php b/src/network/mcpe/protocol/MovePlayerPacket.php deleted file mode 100644 index c092f6712..000000000 --- a/src/network/mcpe/protocol/MovePlayerPacket.php +++ /dev/null @@ -1,97 +0,0 @@ - - -use pocketmine\math\Vector3; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class MovePlayerPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::MOVE_PLAYER_PACKET; - - public const MODE_NORMAL = 0; - public const MODE_RESET = 1; - public const MODE_TELEPORT = 2; - public const MODE_PITCH = 3; //facepalm Mojang - - /** @var int */ - public $entityRuntimeId; - /** @var Vector3 */ - public $position; - /** @var float */ - public $pitch; - /** @var float */ - public $yaw; - /** @var float */ - public $headYaw; - /** @var int */ - public $mode = self::MODE_NORMAL; - /** @var bool */ - public $onGround = false; //TODO - /** @var int */ - public $ridingEid = 0; - /** @var int */ - public $teleportCause = 0; - /** @var int */ - public $teleportItem = 0; - /** @var int */ - public $tick = 0; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityRuntimeId = $in->getEntityRuntimeId(); - $this->position = $in->getVector3(); - $this->pitch = $in->getLFloat(); - $this->yaw = $in->getLFloat(); - $this->headYaw = $in->getLFloat(); - $this->mode = $in->getByte(); - $this->onGround = $in->getBool(); - $this->ridingEid = $in->getEntityRuntimeId(); - if($this->mode === MovePlayerPacket::MODE_TELEPORT){ - $this->teleportCause = $in->getLInt(); - $this->teleportItem = $in->getLInt(); - } - $this->tick = $in->getUnsignedVarLong(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityRuntimeId($this->entityRuntimeId); - $out->putVector3($this->position); - $out->putLFloat($this->pitch); - $out->putLFloat($this->yaw); - $out->putLFloat($this->headYaw); //TODO - $out->putByte($this->mode); - $out->putBool($this->onGround); - $out->putEntityRuntimeId($this->ridingEid); - if($this->mode === MovePlayerPacket::MODE_TELEPORT){ - $out->putLInt($this->teleportCause); - $out->putLInt($this->teleportItem); - } - $out->putUnsignedVarLong($this->tick); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleMovePlayer($this); - } -} diff --git a/src/network/mcpe/protocol/MultiplayerSettingsPacket.php b/src/network/mcpe/protocol/MultiplayerSettingsPacket.php deleted file mode 100644 index 0c635b517..000000000 --- a/src/network/mcpe/protocol/MultiplayerSettingsPacket.php +++ /dev/null @@ -1,61 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class MultiplayerSettingsPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::MULTIPLAYER_SETTINGS_PACKET; - - public const ACTION_ENABLE_MULTIPLAYER = 0; - public const ACTION_DISABLE_MULTIPLAYER = 1; - public const ACTION_REFRESH_JOIN_CODE = 2; - - /** @var int */ - private $action; - - public static function create(int $action) : self{ - $result = new self; - $result->action = $action; - return $result; - } - - public function getAction() : int{ - return $this->action; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->action = $in->getVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putVarInt($this->action); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleMultiplayerSettings($this); - } -} diff --git a/src/network/mcpe/protocol/NetworkChunkPublisherUpdatePacket.php b/src/network/mcpe/protocol/NetworkChunkPublisherUpdatePacket.php deleted file mode 100644 index 32aeb0274..000000000 --- a/src/network/mcpe/protocol/NetworkChunkPublisherUpdatePacket.php +++ /dev/null @@ -1,64 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class NetworkChunkPublisherUpdatePacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::NETWORK_CHUNK_PUBLISHER_UPDATE_PACKET; - - /** @var int */ - public $x; - /** @var int */ - public $y; - /** @var int */ - public $z; - /** @var int */ - public $radius; - - public static function create(int $x, int $y, int $z, int $blockRadius) : self{ - $result = new self; - $result->x = $x; - $result->y = $y; - $result->z = $z; - $result->radius = $blockRadius; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $in->getSignedBlockPosition($this->x, $this->y, $this->z); - $this->radius = $in->getUnsignedVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putSignedBlockPosition($this->x, $this->y, $this->z); - $out->putUnsignedVarInt($this->radius); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleNetworkChunkPublisherUpdate($this); - } -} diff --git a/src/network/mcpe/protocol/NetworkSettingsPacket.php b/src/network/mcpe/protocol/NetworkSettingsPacket.php deleted file mode 100644 index 77477d129..000000000 --- a/src/network/mcpe/protocol/NetworkSettingsPacket.php +++ /dev/null @@ -1,60 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class NetworkSettingsPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::NETWORK_SETTINGS_PACKET; - - public const COMPRESS_NOTHING = 0; - public const COMPRESS_EVERYTHING = 1; - - /** @var int */ - private $compressionThreshold; - - public static function create(int $compressionThreshold) : self{ - $result = new self; - $result->compressionThreshold = $compressionThreshold; - return $result; - } - - public function getCompressionThreshold() : int{ - return $this->compressionThreshold; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->compressionThreshold = $in->getLShort(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putLShort($this->compressionThreshold); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleNetworkSettings($this); - } -} diff --git a/src/network/mcpe/protocol/NetworkStackLatencyPacket.php b/src/network/mcpe/protocol/NetworkStackLatencyPacket.php deleted file mode 100644 index 11211fea4..000000000 --- a/src/network/mcpe/protocol/NetworkStackLatencyPacket.php +++ /dev/null @@ -1,65 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class NetworkStackLatencyPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::NETWORK_STACK_LATENCY_PACKET; - - /** @var int */ - public $timestamp; - /** @var bool */ - public $needResponse; - - public static function request(int $timestampNs) : self{ - $result = new self; - $result->timestamp = $timestampNs; - $result->needResponse = true; - return $result; - } - - public static function response(int $timestampNs) : self{ - $result = new self; - $result->timestamp = $timestampNs; - $result->needResponse = false; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->timestamp = $in->getLLong(); - $this->needResponse = $in->getBool(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putLLong($this->timestamp); - $out->putBool($this->needResponse); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleNetworkStackLatency($this); - } -} diff --git a/src/network/mcpe/protocol/NpcDialoguePacket.php b/src/network/mcpe/protocol/NpcDialoguePacket.php deleted file mode 100644 index 87beb4915..000000000 --- a/src/network/mcpe/protocol/NpcDialoguePacket.php +++ /dev/null @@ -1,87 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class NpcDialoguePacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::NPC_DIALOGUE_PACKET; - - public const ACTION_OPEN = 0; - public const ACTION_CLOSE = 1; - - private int $npcActorUniqueId; - private int $actionType; - private string $dialogue; - private string $sceneName; - private string $npcName; - private string $actionJson; - - public static function create(int $npcActorUniqueId, int $actionType, string $dialogue, string $sceneName, string $npcName, string $actionJson) : self{ - $result = new self; - $result->npcActorUniqueId = $npcActorUniqueId; - $result->actionType = $actionType; - $result->dialogue = $dialogue; - $result->sceneName = $sceneName; - $result->npcName = $npcName; - $result->actionJson = $actionJson; - return $result; - } - - public function getNpcActorUniqueId() : int{ return $this->npcActorUniqueId; } - - public function getActionType() : int{ return $this->actionType; } - - public function getDialogue() : string{ return $this->dialogue; } - - public function getSceneName() : string{ return $this->sceneName; } - - public function getNpcName() : string{ return $this->npcName; } - - public function getActionJson() : string{ return $this->actionJson; } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->npcActorUniqueId = $in->getEntityUniqueId(); - $this->actionType = $in->getVarInt(); - $this->dialogue = $in->getString(); - $this->sceneName = $in->getString(); - $this->npcName = $in->getString(); - $this->actionJson = $in->getString(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityUniqueId($this->npcActorUniqueId); - $out->putVarInt($this->actionType); - $out->putString($this->dialogue); - $out->putString($this->sceneName); - $out->putString($this->npcName); - $out->putString($this->actionJson); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleNpcDialogue($this); - } -} diff --git a/src/network/mcpe/protocol/NpcRequestPacket.php b/src/network/mcpe/protocol/NpcRequestPacket.php deleted file mode 100644 index 674bfb842..000000000 --- a/src/network/mcpe/protocol/NpcRequestPacket.php +++ /dev/null @@ -1,70 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class NpcRequestPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::NPC_REQUEST_PACKET; - - public const REQUEST_SET_ACTIONS = 0; - public const REQUEST_EXECUTE_ACTION = 1; - public const REQUEST_EXECUTE_CLOSING_COMMANDS = 2; - public const REQUEST_SET_NAME = 3; - public const REQUEST_SET_SKIN = 4; - public const REQUEST_SET_INTERACTION_TEXT = 5; - public const REQUEST_EXECUTE_OPENING_COMMANDS = 6; - - /** @var int */ - public $entityRuntimeId; - /** @var int */ - public $requestType; - /** @var string */ - public $commandString; - /** @var int */ - public $actionType; - public string $sceneName; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityRuntimeId = $in->getEntityRuntimeId(); - $this->requestType = $in->getByte(); - $this->commandString = $in->getString(); - $this->actionType = $in->getByte(); - $this->sceneName = $in->getString(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityRuntimeId($this->entityRuntimeId); - $out->putByte($this->requestType); - $out->putString($this->commandString); - $out->putByte($this->actionType); - $out->putString($this->sceneName); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleNpcRequest($this); - } -} diff --git a/src/network/mcpe/protocol/OnScreenTextureAnimationPacket.php b/src/network/mcpe/protocol/OnScreenTextureAnimationPacket.php deleted file mode 100644 index 80d66b37a..000000000 --- a/src/network/mcpe/protocol/OnScreenTextureAnimationPacket.php +++ /dev/null @@ -1,47 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class OnScreenTextureAnimationPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::ON_SCREEN_TEXTURE_ANIMATION_PACKET; - - /** @var int */ - public $effectId; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->effectId = $in->getLInt(); //unsigned - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putLInt($this->effectId); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleOnScreenTextureAnimation($this); - } -} diff --git a/src/network/mcpe/protocol/Packet.php b/src/network/mcpe/protocol/Packet.php deleted file mode 100644 index f089901ca..000000000 --- a/src/network/mcpe/protocol/Packet.php +++ /dev/null @@ -1,57 +0,0 @@ -getMessage(), 0, $previous); - } -} \ No newline at end of file diff --git a/src/network/mcpe/protocol/PacketHandlerInterface.php b/src/network/mcpe/protocol/PacketHandlerInterface.php deleted file mode 100644 index 1dc610952..000000000 --- a/src/network/mcpe/protocol/PacketHandlerInterface.php +++ /dev/null @@ -1,357 +0,0 @@ - */ - protected $pool; - - public function __construct(){ - $this->pool = new \SplFixedArray(256); - - $this->registerPacket(new LoginPacket()); - $this->registerPacket(new PlayStatusPacket()); - $this->registerPacket(new ServerToClientHandshakePacket()); - $this->registerPacket(new ClientToServerHandshakePacket()); - $this->registerPacket(new DisconnectPacket()); - $this->registerPacket(new ResourcePacksInfoPacket()); - $this->registerPacket(new ResourcePackStackPacket()); - $this->registerPacket(new ResourcePackClientResponsePacket()); - $this->registerPacket(new TextPacket()); - $this->registerPacket(new SetTimePacket()); - $this->registerPacket(new StartGamePacket()); - $this->registerPacket(new AddPlayerPacket()); - $this->registerPacket(new AddActorPacket()); - $this->registerPacket(new RemoveActorPacket()); - $this->registerPacket(new AddItemActorPacket()); - $this->registerPacket(new TakeItemActorPacket()); - $this->registerPacket(new MoveActorAbsolutePacket()); - $this->registerPacket(new MovePlayerPacket()); - $this->registerPacket(new RiderJumpPacket()); - $this->registerPacket(new UpdateBlockPacket()); - $this->registerPacket(new AddPaintingPacket()); - $this->registerPacket(new TickSyncPacket()); - $this->registerPacket(new LevelSoundEventPacketV1()); - $this->registerPacket(new LevelEventPacket()); - $this->registerPacket(new BlockEventPacket()); - $this->registerPacket(new ActorEventPacket()); - $this->registerPacket(new MobEffectPacket()); - $this->registerPacket(new UpdateAttributesPacket()); - $this->registerPacket(new InventoryTransactionPacket()); - $this->registerPacket(new MobEquipmentPacket()); - $this->registerPacket(new MobArmorEquipmentPacket()); - $this->registerPacket(new InteractPacket()); - $this->registerPacket(new BlockPickRequestPacket()); - $this->registerPacket(new ActorPickRequestPacket()); - $this->registerPacket(new PlayerActionPacket()); - $this->registerPacket(new HurtArmorPacket()); - $this->registerPacket(new SetActorDataPacket()); - $this->registerPacket(new SetActorMotionPacket()); - $this->registerPacket(new SetActorLinkPacket()); - $this->registerPacket(new SetHealthPacket()); - $this->registerPacket(new SetSpawnPositionPacket()); - $this->registerPacket(new AnimatePacket()); - $this->registerPacket(new RespawnPacket()); - $this->registerPacket(new ContainerOpenPacket()); - $this->registerPacket(new ContainerClosePacket()); - $this->registerPacket(new PlayerHotbarPacket()); - $this->registerPacket(new InventoryContentPacket()); - $this->registerPacket(new InventorySlotPacket()); - $this->registerPacket(new ContainerSetDataPacket()); - $this->registerPacket(new CraftingDataPacket()); - $this->registerPacket(new CraftingEventPacket()); - $this->registerPacket(new GuiDataPickItemPacket()); - $this->registerPacket(new AdventureSettingsPacket()); - $this->registerPacket(new BlockActorDataPacket()); - $this->registerPacket(new PlayerInputPacket()); - $this->registerPacket(new LevelChunkPacket()); - $this->registerPacket(new SetCommandsEnabledPacket()); - $this->registerPacket(new SetDifficultyPacket()); - $this->registerPacket(new ChangeDimensionPacket()); - $this->registerPacket(new SetPlayerGameTypePacket()); - $this->registerPacket(new PlayerListPacket()); - $this->registerPacket(new SimpleEventPacket()); - $this->registerPacket(new EventPacket()); - $this->registerPacket(new SpawnExperienceOrbPacket()); - $this->registerPacket(new ClientboundMapItemDataPacket()); - $this->registerPacket(new MapInfoRequestPacket()); - $this->registerPacket(new RequestChunkRadiusPacket()); - $this->registerPacket(new ChunkRadiusUpdatedPacket()); - $this->registerPacket(new ItemFrameDropItemPacket()); - $this->registerPacket(new GameRulesChangedPacket()); - $this->registerPacket(new CameraPacket()); - $this->registerPacket(new BossEventPacket()); - $this->registerPacket(new ShowCreditsPacket()); - $this->registerPacket(new AvailableCommandsPacket()); - $this->registerPacket(new CommandRequestPacket()); - $this->registerPacket(new CommandBlockUpdatePacket()); - $this->registerPacket(new CommandOutputPacket()); - $this->registerPacket(new UpdateTradePacket()); - $this->registerPacket(new UpdateEquipPacket()); - $this->registerPacket(new ResourcePackDataInfoPacket()); - $this->registerPacket(new ResourcePackChunkDataPacket()); - $this->registerPacket(new ResourcePackChunkRequestPacket()); - $this->registerPacket(new TransferPacket()); - $this->registerPacket(new PlaySoundPacket()); - $this->registerPacket(new StopSoundPacket()); - $this->registerPacket(new SetTitlePacket()); - $this->registerPacket(new AddBehaviorTreePacket()); - $this->registerPacket(new StructureBlockUpdatePacket()); - $this->registerPacket(new ShowStoreOfferPacket()); - $this->registerPacket(new PurchaseReceiptPacket()); - $this->registerPacket(new PlayerSkinPacket()); - $this->registerPacket(new SubClientLoginPacket()); - $this->registerPacket(new AutomationClientConnectPacket()); - $this->registerPacket(new SetLastHurtByPacket()); - $this->registerPacket(new BookEditPacket()); - $this->registerPacket(new NpcRequestPacket()); - $this->registerPacket(new PhotoTransferPacket()); - $this->registerPacket(new ModalFormRequestPacket()); - $this->registerPacket(new ModalFormResponsePacket()); - $this->registerPacket(new ServerSettingsRequestPacket()); - $this->registerPacket(new ServerSettingsResponsePacket()); - $this->registerPacket(new ShowProfilePacket()); - $this->registerPacket(new SetDefaultGameTypePacket()); - $this->registerPacket(new RemoveObjectivePacket()); - $this->registerPacket(new SetDisplayObjectivePacket()); - $this->registerPacket(new SetScorePacket()); - $this->registerPacket(new LabTablePacket()); - $this->registerPacket(new UpdateBlockSyncedPacket()); - $this->registerPacket(new MoveActorDeltaPacket()); - $this->registerPacket(new SetScoreboardIdentityPacket()); - $this->registerPacket(new SetLocalPlayerAsInitializedPacket()); - $this->registerPacket(new UpdateSoftEnumPacket()); - $this->registerPacket(new NetworkStackLatencyPacket()); - $this->registerPacket(new ScriptCustomEventPacket()); - $this->registerPacket(new SpawnParticleEffectPacket()); - $this->registerPacket(new AvailableActorIdentifiersPacket()); - $this->registerPacket(new LevelSoundEventPacketV2()); - $this->registerPacket(new NetworkChunkPublisherUpdatePacket()); - $this->registerPacket(new BiomeDefinitionListPacket()); - $this->registerPacket(new LevelSoundEventPacket()); - $this->registerPacket(new LevelEventGenericPacket()); - $this->registerPacket(new LecternUpdatePacket()); - $this->registerPacket(new AddEntityPacket()); - $this->registerPacket(new RemoveEntityPacket()); - $this->registerPacket(new ClientCacheStatusPacket()); - $this->registerPacket(new OnScreenTextureAnimationPacket()); - $this->registerPacket(new MapCreateLockedCopyPacket()); - $this->registerPacket(new StructureTemplateDataRequestPacket()); - $this->registerPacket(new StructureTemplateDataResponsePacket()); - $this->registerPacket(new ClientCacheBlobStatusPacket()); - $this->registerPacket(new ClientCacheMissResponsePacket()); - $this->registerPacket(new EducationSettingsPacket()); - $this->registerPacket(new EmotePacket()); - $this->registerPacket(new MultiplayerSettingsPacket()); - $this->registerPacket(new SettingsCommandPacket()); - $this->registerPacket(new AnvilDamagePacket()); - $this->registerPacket(new CompletedUsingItemPacket()); - $this->registerPacket(new NetworkSettingsPacket()); - $this->registerPacket(new PlayerAuthInputPacket()); - $this->registerPacket(new CreativeContentPacket()); - $this->registerPacket(new PlayerEnchantOptionsPacket()); - $this->registerPacket(new ItemStackRequestPacket()); - $this->registerPacket(new ItemStackResponsePacket()); - $this->registerPacket(new PlayerArmorDamagePacket()); - $this->registerPacket(new CodeBuilderPacket()); - $this->registerPacket(new UpdatePlayerGameTypePacket()); - $this->registerPacket(new EmoteListPacket()); - $this->registerPacket(new PositionTrackingDBServerBroadcastPacket()); - $this->registerPacket(new PositionTrackingDBClientRequestPacket()); - $this->registerPacket(new DebugInfoPacket()); - $this->registerPacket(new PacketViolationWarningPacket()); - $this->registerPacket(new MotionPredictionHintsPacket()); - $this->registerPacket(new AnimateEntityPacket()); - $this->registerPacket(new CameraShakePacket()); - $this->registerPacket(new PlayerFogPacket()); - $this->registerPacket(new CorrectPlayerMovePredictionPacket()); - $this->registerPacket(new ItemComponentPacket()); - $this->registerPacket(new FilterTextPacket()); - $this->registerPacket(new ClientboundDebugRendererPacket()); - $this->registerPacket(new SyncActorPropertyPacket()); - $this->registerPacket(new AddVolumeEntityPacket()); - $this->registerPacket(new RemoveVolumeEntityPacket()); - $this->registerPacket(new SimulationTypePacket()); - $this->registerPacket(new NpcDialoguePacket()); - } - - public function registerPacket(Packet $packet) : void{ - $this->pool[$packet->pid()] = clone $packet; - } - - public function getPacketById(int $pid) : Packet{ - return isset($this->pool[$pid]) ? clone $this->pool[$pid] : new UnknownPacket(); - } - - /** - * @throws BinaryDataException - */ - public function getPacket(string $buffer) : Packet{ - $offset = 0; - return $this->getPacketById(Binary::readUnsignedVarInt($buffer, $offset) & DataPacket::PID_MASK); - } -} diff --git a/src/network/mcpe/protocol/PacketViolationWarningPacket.php b/src/network/mcpe/protocol/PacketViolationWarningPacket.php deleted file mode 100644 index c100647ce..000000000 --- a/src/network/mcpe/protocol/PacketViolationWarningPacket.php +++ /dev/null @@ -1,84 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class PacketViolationWarningPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::PACKET_VIOLATION_WARNING_PACKET; - - public const TYPE_MALFORMED = 0; - - public const SEVERITY_WARNING = 0; - public const SEVERITY_FINAL_WARNING = 1; - public const SEVERITY_TERMINATING_CONNECTION = 2; - - /** @var int */ - private $type; - /** @var int */ - private $severity; - /** @var int */ - private $packetId; - /** @var string */ - private $message; - - public static function create(int $type, int $severity, int $packetId, string $message) : self{ - $result = new self; - - $result->type = $type; - $result->severity = $severity; - $result->packetId = $packetId; - $result->message = $message; - - return $result; - } - - public function getType() : int{ return $this->type; } - - public function getSeverity() : int{ return $this->severity; } - - public function getPacketId() : int{ return $this->packetId; } - - public function getMessage() : string{ return $this->message; } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->type = $in->getVarInt(); - $this->severity = $in->getVarInt(); - $this->packetId = $in->getVarInt(); - $this->message = $in->getString(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putVarInt($this->type); - $out->putVarInt($this->severity); - $out->putVarInt($this->packetId); - $out->putString($this->message); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handlePacketViolationWarning($this); - } -} diff --git a/src/network/mcpe/protocol/PhotoTransferPacket.php b/src/network/mcpe/protocol/PhotoTransferPacket.php deleted file mode 100644 index ccaf0eb51..000000000 --- a/src/network/mcpe/protocol/PhotoTransferPacket.php +++ /dev/null @@ -1,55 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class PhotoTransferPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::PHOTO_TRANSFER_PACKET; - - /** @var string */ - public $photoName; - /** @var string */ - public $photoData; - /** @var string */ - public $bookId; //photos are stored in a sibling directory to the games folder (screenshots/(some UUID)/bookID/example.png) - - protected function decodePayload(PacketSerializer $in) : void{ - $this->photoName = $in->getString(); - $this->photoData = $in->getString(); - $this->bookId = $in->getString(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->photoName); - $out->putString($this->photoData); - $out->putString($this->bookId); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handlePhotoTransfer($this); - } -} diff --git a/src/network/mcpe/protocol/PlaySoundPacket.php b/src/network/mcpe/protocol/PlaySoundPacket.php deleted file mode 100644 index 7384145fa..000000000 --- a/src/network/mcpe/protocol/PlaySoundPacket.php +++ /dev/null @@ -1,66 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class PlaySoundPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::PLAY_SOUND_PACKET; - - /** @var string */ - public $soundName; - /** @var float */ - public $x; - /** @var float */ - public $y; - /** @var float */ - public $z; - /** @var float */ - public $volume; - /** @var float */ - public $pitch; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->soundName = $in->getString(); - $in->getBlockPosition($this->x, $this->y, $this->z); - $this->x /= 8; - $this->y /= 8; - $this->z /= 8; - $this->volume = $in->getLFloat(); - $this->pitch = $in->getLFloat(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->soundName); - $out->putBlockPosition((int) ($this->x * 8), (int) ($this->y * 8), (int) ($this->z * 8)); - $out->putLFloat($this->volume); - $out->putLFloat($this->pitch); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handlePlaySound($this); - } -} diff --git a/src/network/mcpe/protocol/PlayStatusPacket.php b/src/network/mcpe/protocol/PlayStatusPacket.php deleted file mode 100644 index 98aec071c..000000000 --- a/src/network/mcpe/protocol/PlayStatusPacket.php +++ /dev/null @@ -1,66 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class PlayStatusPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::PLAY_STATUS_PACKET; - - public const LOGIN_SUCCESS = 0; - public const LOGIN_FAILED_CLIENT = 1; - public const LOGIN_FAILED_SERVER = 2; - public const PLAYER_SPAWN = 3; - public const LOGIN_FAILED_INVALID_TENANT = 4; - public const LOGIN_FAILED_VANILLA_EDU = 5; - public const LOGIN_FAILED_EDU_VANILLA = 6; - public const LOGIN_FAILED_SERVER_FULL = 7; - - /** @var int */ - public $status; - - public static function create(int $status) : self{ - $result = new self; - $result->status = $status; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->status = $in->getInt(); - } - - public function canBeSentBeforeLogin() : bool{ - return true; - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putInt($this->status); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handlePlayStatus($this); - } -} diff --git a/src/network/mcpe/protocol/PlayerActionPacket.php b/src/network/mcpe/protocol/PlayerActionPacket.php deleted file mode 100644 index 4ceef5dfe..000000000 --- a/src/network/mcpe/protocol/PlayerActionPacket.php +++ /dev/null @@ -1,92 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class PlayerActionPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::PLAYER_ACTION_PACKET; - - public const ACTION_START_BREAK = 0; - public const ACTION_ABORT_BREAK = 1; - public const ACTION_STOP_BREAK = 2; - public const ACTION_GET_UPDATED_BLOCK = 3; - public const ACTION_DROP_ITEM = 4; - public const ACTION_START_SLEEPING = 5; - public const ACTION_STOP_SLEEPING = 6; - public const ACTION_RESPAWN = 7; - public const ACTION_JUMP = 8; - public const ACTION_START_SPRINT = 9; - public const ACTION_STOP_SPRINT = 10; - public const ACTION_START_SNEAK = 11; - public const ACTION_STOP_SNEAK = 12; - public const ACTION_CREATIVE_PLAYER_DESTROY_BLOCK = 13; - public const ACTION_DIMENSION_CHANGE_ACK = 14; //sent when spawning in a different dimension to tell the server we spawned - public const ACTION_START_GLIDE = 15; - public const ACTION_STOP_GLIDE = 16; - public const ACTION_BUILD_DENIED = 17; - public const ACTION_CRACK_BREAK = 18; - public const ACTION_CHANGE_SKIN = 19; - public const ACTION_SET_ENCHANTMENT_SEED = 20; //no longer used - public const ACTION_START_SWIMMING = 21; - public const ACTION_STOP_SWIMMING = 22; - public const ACTION_START_SPIN_ATTACK = 23; - public const ACTION_STOP_SPIN_ATTACK = 24; - public const ACTION_INTERACT_BLOCK = 25; - public const ACTION_PREDICT_DESTROY_BLOCK = 26; - public const ACTION_CONTINUE_DESTROY_BLOCK = 27; - - /** @var int */ - public $entityRuntimeId; - /** @var int */ - public $action; - /** @var int */ - public $x; - /** @var int */ - public $y; - /** @var int */ - public $z; - /** @var int */ - public $face; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityRuntimeId = $in->getEntityRuntimeId(); - $this->action = $in->getVarInt(); - $in->getBlockPosition($this->x, $this->y, $this->z); - $this->face = $in->getVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityRuntimeId($this->entityRuntimeId); - $out->putVarInt($this->action); - $out->putBlockPosition($this->x, $this->y, $this->z); - $out->putVarInt($this->face); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handlePlayerAction($this); - } -} diff --git a/src/network/mcpe/protocol/PlayerArmorDamagePacket.php b/src/network/mcpe/protocol/PlayerArmorDamagePacket.php deleted file mode 100644 index 748084c61..000000000 --- a/src/network/mcpe/protocol/PlayerArmorDamagePacket.php +++ /dev/null @@ -1,108 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class PlayerArmorDamagePacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::PLAYER_ARMOR_DAMAGE_PACKET; - - private const FLAG_HEAD = 0; - private const FLAG_CHEST = 1; - private const FLAG_LEGS = 2; - private const FLAG_FEET = 3; - - /** @var int|null */ - private $headSlotDamage; - /** @var int|null */ - private $chestSlotDamage; - /** @var int|null */ - private $legsSlotDamage; - /** @var int|null */ - private $feetSlotDamage; - - public static function create(?int $headSlotDamage, ?int $chestSlotDamage, ?int $legsSlotDamage, ?int $feetSlotDamage) : self{ - $result = new self; - $result->headSlotDamage = $headSlotDamage; - $result->chestSlotDamage = $chestSlotDamage; - $result->legsSlotDamage = $legsSlotDamage; - $result->feetSlotDamage = $feetSlotDamage; - - return $result; - } - - public function getHeadSlotDamage() : ?int{ return $this->headSlotDamage; } - - public function getChestSlotDamage() : ?int{ return $this->chestSlotDamage; } - - public function getLegsSlotDamage() : ?int{ return $this->legsSlotDamage; } - - public function getFeetSlotDamage() : ?int{ return $this->feetSlotDamage; } - - private function maybeReadDamage(int $flags, int $flag, PacketSerializer $in) : ?int{ - if(($flags & (1 << $flag)) !== 0){ - return $in->getVarInt(); - } - return null; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $flags = $in->getByte(); - - $this->headSlotDamage = $this->maybeReadDamage($flags, self::FLAG_HEAD, $in); - $this->chestSlotDamage = $this->maybeReadDamage($flags, self::FLAG_CHEST, $in); - $this->legsSlotDamage = $this->maybeReadDamage($flags, self::FLAG_LEGS, $in); - $this->feetSlotDamage = $this->maybeReadDamage($flags, self::FLAG_FEET, $in); - } - - private function composeFlag(?int $field, int $flag) : int{ - return $field !== null ? (1 << $flag) : 0; - } - - private function maybeWriteDamage(?int $field, PacketSerializer $out) : void{ - if($field !== null){ - $out->putVarInt($field); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putByte( - $this->composeFlag($this->headSlotDamage, self::FLAG_HEAD) | - $this->composeFlag($this->chestSlotDamage, self::FLAG_CHEST) | - $this->composeFlag($this->legsSlotDamage, self::FLAG_LEGS) | - $this->composeFlag($this->feetSlotDamage, self::FLAG_FEET) - ); - - $this->maybeWriteDamage($this->headSlotDamage, $out); - $this->maybeWriteDamage($this->chestSlotDamage, $out); - $this->maybeWriteDamage($this->legsSlotDamage, $out); - $this->maybeWriteDamage($this->feetSlotDamage, $out); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handlePlayerArmorDamage($this); - } -} diff --git a/src/network/mcpe/protocol/PlayerAuthInputPacket.php b/src/network/mcpe/protocol/PlayerAuthInputPacket.php deleted file mode 100644 index 77fa3f5f9..000000000 --- a/src/network/mcpe/protocol/PlayerAuthInputPacket.php +++ /dev/null @@ -1,179 +0,0 @@ - - -use pocketmine\math\Vector3; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\InputMode; -use pocketmine\network\mcpe\protocol\types\PlayerAuthInputFlags; -use pocketmine\network\mcpe\protocol\types\PlayMode; -use function assert; - -class PlayerAuthInputPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::PLAYER_AUTH_INPUT_PACKET; - - /** @var Vector3 */ - private $position; - /** @var float */ - private $pitch; - /** @var float */ - private $yaw; - /** @var float */ - private $headYaw; - /** @var float */ - private $moveVecX; - /** @var float */ - private $moveVecZ; - /** @var int */ - private $inputFlags; - /** @var int */ - private $inputMode; - /** @var int */ - private $playMode; - /** @var Vector3|null */ - private $vrGazeDirection = null; - /** @var int */ - private $tick; - /** @var Vector3 */ - private $delta; - - /** - * @param int $inputFlags @see InputFlags - * @param int $inputMode @see InputMode - * @param int $playMode @see PlayMode - * @param Vector3|null $vrGazeDirection only used when PlayMode::VR - */ - public static function create(Vector3 $position, float $pitch, float $yaw, float $headYaw, float $moveVecX, float $moveVecZ, int $inputFlags, int $inputMode, int $playMode, ?Vector3 $vrGazeDirection, int $tick, Vector3 $delta) : self{ - if($playMode === PlayMode::VR and $vrGazeDirection === null){ - //yuck, can we get a properly written packet just once? ... - throw new \InvalidArgumentException("Gaze direction must be provided for VR play mode"); - } - $result = new self; - $result->position = $position->asVector3(); - $result->pitch = $pitch; - $result->yaw = $yaw; - $result->headYaw = $headYaw; - $result->moveVecX = $moveVecX; - $result->moveVecZ = $moveVecZ; - $result->inputFlags = $inputFlags; - $result->inputMode = $inputMode; - $result->playMode = $playMode; - if($vrGazeDirection !== null){ - $result->vrGazeDirection = $vrGazeDirection->asVector3(); - } - $result->tick = $tick; - $result->delta = $delta; - return $result; - } - - public function getPosition() : Vector3{ - return $this->position; - } - - public function getPitch() : float{ - return $this->pitch; - } - - public function getYaw() : float{ - return $this->yaw; - } - - public function getHeadYaw() : float{ - return $this->headYaw; - } - - public function getMoveVecX() : float{ - return $this->moveVecX; - } - - public function getMoveVecZ() : float{ - return $this->moveVecZ; - } - - /** - * @see PlayerAuthInputFlags - */ - public function getInputFlags() : int{ - return $this->inputFlags; - } - - /** - * @see InputMode - */ - public function getInputMode() : int{ - return $this->inputMode; - } - - /** - * @see PlayMode - */ - public function getPlayMode() : int{ - return $this->playMode; - } - - public function getVrGazeDirection() : ?Vector3{ - return $this->vrGazeDirection; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->pitch = $in->getLFloat(); - $this->yaw = $in->getLFloat(); - $this->position = $in->getVector3(); - $this->moveVecX = $in->getLFloat(); - $this->moveVecZ = $in->getLFloat(); - $this->headYaw = $in->getLFloat(); - $this->inputFlags = $in->getUnsignedVarLong(); - $this->inputMode = $in->getUnsignedVarInt(); - $this->playMode = $in->getUnsignedVarInt(); - if($this->playMode === PlayMode::VR){ - $this->vrGazeDirection = $in->getVector3(); - } - $this->tick = $in->getUnsignedVarLong(); - $this->delta = $in->getVector3(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putLFloat($this->pitch); - $out->putLFloat($this->yaw); - $out->putVector3($this->position); - $out->putLFloat($this->moveVecX); - $out->putLFloat($this->moveVecZ); - $out->putLFloat($this->headYaw); - $out->putUnsignedVarLong($this->inputFlags); - $out->putUnsignedVarInt($this->inputMode); - $out->putUnsignedVarInt($this->playMode); - if($this->playMode === PlayMode::VR){ - assert($this->vrGazeDirection !== null); - $out->putVector3($this->vrGazeDirection); - } - $out->putUnsignedVarLong($this->tick); - $out->putVector3($this->delta); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handlePlayerAuthInput($this); - } -} diff --git a/src/network/mcpe/protocol/PlayerEnchantOptionsPacket.php b/src/network/mcpe/protocol/PlayerEnchantOptionsPacket.php deleted file mode 100644 index d7efbd7c4..000000000 --- a/src/network/mcpe/protocol/PlayerEnchantOptionsPacket.php +++ /dev/null @@ -1,69 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\EnchantOption; -use function count; - -class PlayerEnchantOptionsPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::PLAYER_ENCHANT_OPTIONS_PACKET; - - /** @var EnchantOption[] */ - private $options; - - /** - * @param EnchantOption[] $options - */ - public static function create(array $options) : self{ - $result = new self; - $result->options = $options; - return $result; - } - - /** - * @return EnchantOption[] - */ - public function getOptions() : array{ return $this->options; } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->options = []; - for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){ - $this->options[] = EnchantOption::read($in); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt(count($this->options)); - foreach($this->options as $option){ - $option->write($out); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handlePlayerEnchantOptions($this); - } -} diff --git a/src/network/mcpe/protocol/PlayerFogPacket.php b/src/network/mcpe/protocol/PlayerFogPacket.php deleted file mode 100644 index c97c77285..000000000 --- a/src/network/mcpe/protocol/PlayerFogPacket.php +++ /dev/null @@ -1,73 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use function count; - -class PlayerFogPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::PLAYER_FOG_PACKET; - - /** - * @var string[] - * @phpstan-var list - */ - private $fogLayers; - - /** - * @param string[] $fogLayers - * @phpstan-param list $fogLayers - */ - public static function create(array $fogLayers) : self{ - $result = new self; - $result->fogLayers = $fogLayers; - return $result; - } - - /** - * @return string[] - * @phpstan-return list - */ - public function getFogLayers() : array{ return $this->fogLayers; } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->fogLayers = []; - for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){ - $this->fogLayers[] = $in->getString(); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt(count($this->fogLayers)); - foreach($this->fogLayers as $fogLayer){ - $out->putString($fogLayer); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handlePlayerFog($this); - } -} diff --git a/src/network/mcpe/protocol/PlayerHotbarPacket.php b/src/network/mcpe/protocol/PlayerHotbarPacket.php deleted file mode 100644 index b6dc141a7..000000000 --- a/src/network/mcpe/protocol/PlayerHotbarPacket.php +++ /dev/null @@ -1,64 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\inventory\ContainerIds; - -class PlayerHotbarPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::PLAYER_HOTBAR_PACKET; - - /** @var int */ - public $selectedHotbarSlot; - /** @var int */ - public $windowId = ContainerIds::INVENTORY; - /** @var bool */ - public $selectHotbarSlot = true; - - public static function create(int $slot, int $windowId, bool $selectSlot = true) : self{ - $result = new self; - $result->selectedHotbarSlot = $slot; - $result->windowId = $windowId; - $result->selectHotbarSlot = $selectSlot; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->selectedHotbarSlot = $in->getUnsignedVarInt(); - $this->windowId = $in->getByte(); - $this->selectHotbarSlot = $in->getBool(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt($this->selectedHotbarSlot); - $out->putByte($this->windowId); - $out->putBool($this->selectHotbarSlot); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handlePlayerHotbar($this); - } -} diff --git a/src/network/mcpe/protocol/PlayerInputPacket.php b/src/network/mcpe/protocol/PlayerInputPacket.php deleted file mode 100644 index 5069a66fd..000000000 --- a/src/network/mcpe/protocol/PlayerInputPacket.php +++ /dev/null @@ -1,59 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class PlayerInputPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::PLAYER_INPUT_PACKET; - - /** @var float */ - public $motionX; - /** @var float */ - public $motionY; - /** @var bool */ - public $jumping; - /** @var bool */ - public $sneaking; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->motionX = $in->getLFloat(); - $this->motionY = $in->getLFloat(); - $this->jumping = $in->getBool(); - $this->sneaking = $in->getBool(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putLFloat($this->motionX); - $out->putLFloat($this->motionY); - $out->putBool($this->jumping); - $out->putBool($this->sneaking); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handlePlayerInput($this); - } -} diff --git a/src/network/mcpe/protocol/PlayerListPacket.php b/src/network/mcpe/protocol/PlayerListPacket.php deleted file mode 100644 index 54ac6462f..000000000 --- a/src/network/mcpe/protocol/PlayerListPacket.php +++ /dev/null @@ -1,120 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\PlayerListEntry; -use function count; - -class PlayerListPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::PLAYER_LIST_PACKET; - - public const TYPE_ADD = 0; - public const TYPE_REMOVE = 1; - - /** @var PlayerListEntry[] */ - public $entries = []; - /** @var int */ - public $type; - - /** - * @param PlayerListEntry[] $entries - */ - public static function add(array $entries) : self{ - $result = new self; - $result->type = self::TYPE_ADD; - $result->entries = $entries; - return $result; - } - - /** - * @param PlayerListEntry[] $entries - */ - public static function remove(array $entries) : self{ - $result = new self; - $result->type = self::TYPE_REMOVE; - $result->entries = $entries; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->type = $in->getByte(); - $count = $in->getUnsignedVarInt(); - for($i = 0; $i < $count; ++$i){ - $entry = new PlayerListEntry(); - - if($this->type === self::TYPE_ADD){ - $entry->uuid = $in->getUUID(); - $entry->entityUniqueId = $in->getEntityUniqueId(); - $entry->username = $in->getString(); - $entry->xboxUserId = $in->getString(); - $entry->platformChatId = $in->getString(); - $entry->buildPlatform = $in->getLInt(); - $entry->skinData = $in->getSkin(); - $entry->isTeacher = $in->getBool(); - $entry->isHost = $in->getBool(); - }else{ - $entry->uuid = $in->getUUID(); - } - - $this->entries[$i] = $entry; - } - if($this->type === self::TYPE_ADD){ - for($i = 0; $i < $count; ++$i){ - $this->entries[$i]->skinData->setVerified($in->getBool()); - } - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putByte($this->type); - $out->putUnsignedVarInt(count($this->entries)); - foreach($this->entries as $entry){ - if($this->type === self::TYPE_ADD){ - $out->putUUID($entry->uuid); - $out->putEntityUniqueId($entry->entityUniqueId); - $out->putString($entry->username); - $out->putString($entry->xboxUserId); - $out->putString($entry->platformChatId); - $out->putLInt($entry->buildPlatform); - $out->putSkin($entry->skinData); - $out->putBool($entry->isTeacher); - $out->putBool($entry->isHost); - }else{ - $out->putUUID($entry->uuid); - } - } - if($this->type === self::TYPE_ADD){ - foreach($this->entries as $entry){ - $out->putBool($entry->skinData->isVerified()); - } - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handlePlayerList($this); - } -} diff --git a/src/network/mcpe/protocol/PlayerSkinPacket.php b/src/network/mcpe/protocol/PlayerSkinPacket.php deleted file mode 100644 index 3b688e46a..000000000 --- a/src/network/mcpe/protocol/PlayerSkinPacket.php +++ /dev/null @@ -1,70 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\skin\SkinData; -use Ramsey\Uuid\UuidInterface; - -class PlayerSkinPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::PLAYER_SKIN_PACKET; - - /** @var UuidInterface */ - public $uuid; - /** @var string */ - public $oldSkinName = ""; - /** @var string */ - public $newSkinName = ""; - /** @var SkinData */ - public $skin; - - public static function create(UuidInterface $uuid, SkinData $skinData) : self{ - $result = new self; - $result->uuid = $uuid; - $result->skin = $skinData; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->uuid = $in->getUUID(); - $this->skin = $in->getSkin(); - $this->newSkinName = $in->getString(); - $this->oldSkinName = $in->getString(); - $this->skin->setVerified($in->getBool()); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUUID($this->uuid); - $out->putSkin($this->skin); - $out->putString($this->newSkinName); - $out->putString($this->oldSkinName); - $out->putBool($this->skin->isVerified()); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handlePlayerSkin($this); - } -} diff --git a/src/network/mcpe/protocol/PositionTrackingDBClientRequestPacket.php b/src/network/mcpe/protocol/PositionTrackingDBClientRequestPacket.php deleted file mode 100644 index f5a6a13f7..000000000 --- a/src/network/mcpe/protocol/PositionTrackingDBClientRequestPacket.php +++ /dev/null @@ -1,64 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class PositionTrackingDBClientRequestPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::POSITION_TRACKING_D_B_CLIENT_REQUEST_PACKET; - - public const ACTION_QUERY = 0; - - /** @var int */ - private $action; - /** @var int */ - private $trackingId; - - public static function create(int $action, int $trackingId) : self{ - $result = new self; - $result->action = $action; - $result->trackingId = $trackingId; - return $result; - } - - public function getAction() : int{ return $this->action; } - - public function getTrackingId() : int{ return $this->trackingId; } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->action = $in->getByte(); - $this->trackingId = $in->getVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putByte($this->action); - $out->putVarInt($this->trackingId); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handlePositionTrackingDBClientRequest($this); - } -} diff --git a/src/network/mcpe/protocol/PositionTrackingDBServerBroadcastPacket.php b/src/network/mcpe/protocol/PositionTrackingDBServerBroadcastPacket.php deleted file mode 100644 index 7045643bc..000000000 --- a/src/network/mcpe/protocol/PositionTrackingDBServerBroadcastPacket.php +++ /dev/null @@ -1,81 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\CacheableNbt; - -class PositionTrackingDBServerBroadcastPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::POSITION_TRACKING_D_B_SERVER_BROADCAST_PACKET; - - public const ACTION_UPDATE = 0; - public const ACTION_DESTROY = 1; - public const ACTION_NOT_FOUND = 2; - - /** @var int */ - private $action; - /** @var int */ - private $trackingId; - /** - * @var CacheableNbt - * @phpstan-var CacheableNbt<\pocketmine\nbt\tag\CompoundTag> - */ - private $nbt; - - /** - * @phpstan-param CacheableNbt<\pocketmine\nbt\tag\CompoundTag> $nbt - */ - public static function create(int $action, int $trackingId, CacheableNbt $nbt) : self{ - $result = new self; - $result->action = $action; - $result->trackingId = $trackingId; - $result->nbt = $nbt; - return $result; - } - - public function getAction() : int{ return $this->action; } - - public function getTrackingId() : int{ return $this->trackingId; } - - /** @phpstan-return CacheableNbt<\pocketmine\nbt\tag\CompoundTag> */ - public function getNbt() : CacheableNbt{ return $this->nbt; } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->action = $in->getByte(); - $this->trackingId = $in->getVarInt(); - $this->nbt = new CacheableNbt($in->getNbtCompoundRoot()); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putByte($this->action); - $out->putVarInt($this->trackingId); - $out->put($this->nbt->getEncodedNbt()); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handlePositionTrackingDBServerBroadcast($this); - } -} diff --git a/src/network/mcpe/protocol/ProtocolInfo.php b/src/network/mcpe/protocol/ProtocolInfo.php deleted file mode 100644 index 9d5b94b2e..000000000 --- a/src/network/mcpe/protocol/ProtocolInfo.php +++ /dev/null @@ -1,220 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use function count; - -class PurchaseReceiptPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::PURCHASE_RECEIPT_PACKET; - - /** @var string[] */ - public $entries = []; - - protected function decodePayload(PacketSerializer $in) : void{ - $count = $in->getUnsignedVarInt(); - for($i = 0; $i < $count; ++$i){ - $this->entries[] = $in->getString(); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt(count($this->entries)); - foreach($this->entries as $entry){ - $out->putString($entry); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handlePurchaseReceipt($this); - } -} diff --git a/src/network/mcpe/protocol/RemoveActorPacket.php b/src/network/mcpe/protocol/RemoveActorPacket.php deleted file mode 100644 index 8fdc2a766..000000000 --- a/src/network/mcpe/protocol/RemoveActorPacket.php +++ /dev/null @@ -1,53 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class RemoveActorPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::REMOVE_ACTOR_PACKET; - - /** @var int */ - public $entityUniqueId; - - public static function create(int $entityUniqueId) : self{ - $result = new self; - $result->entityUniqueId = $entityUniqueId; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityUniqueId = $in->getEntityUniqueId(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityUniqueId($this->entityUniqueId); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleRemoveActor($this); - } -} diff --git a/src/network/mcpe/protocol/RemoveEntityPacket.php b/src/network/mcpe/protocol/RemoveEntityPacket.php deleted file mode 100644 index 6c9981d21..000000000 --- a/src/network/mcpe/protocol/RemoveEntityPacket.php +++ /dev/null @@ -1,57 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class RemoveEntityPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::REMOVE_ENTITY_PACKET; - - /** @var int */ - private $entityNetId; - - public static function create(int $entityNetId) : self{ - $result = new self; - $result->entityNetId = $entityNetId; - return $result; - } - - public function getEntityNetId() : int{ - return $this->entityNetId; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityNetId = $in->getUnsignedVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt($this->entityNetId); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleRemoveEntity($this); - } -} diff --git a/src/network/mcpe/protocol/RemoveObjectivePacket.php b/src/network/mcpe/protocol/RemoveObjectivePacket.php deleted file mode 100644 index 7b4bf22e8..000000000 --- a/src/network/mcpe/protocol/RemoveObjectivePacket.php +++ /dev/null @@ -1,47 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class RemoveObjectivePacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::REMOVE_OBJECTIVE_PACKET; - - /** @var string */ - public $objectiveName; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->objectiveName = $in->getString(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->objectiveName); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleRemoveObjective($this); - } -} diff --git a/src/network/mcpe/protocol/RemoveVolumeEntityPacket.php b/src/network/mcpe/protocol/RemoveVolumeEntityPacket.php deleted file mode 100644 index 3f5c069f4..000000000 --- a/src/network/mcpe/protocol/RemoveVolumeEntityPacket.php +++ /dev/null @@ -1,55 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class RemoveVolumeEntityPacket extends DataPacket{ - public const NETWORK_ID = ProtocolInfo::REMOVE_VOLUME_ENTITY_PACKET; - - /** @var int */ - private $entityNetId; - - public static function create(int $entityNetId) : self{ - $result = new self; - $result->entityNetId = $entityNetId; - return $result; - } - - public function getEntityNetId() : int{ return $this->entityNetId; } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityNetId = $in->getUnsignedVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt($this->entityNetId); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleRemoveVolumeEntity($this); - } -} diff --git a/src/network/mcpe/protocol/RequestChunkRadiusPacket.php b/src/network/mcpe/protocol/RequestChunkRadiusPacket.php deleted file mode 100644 index 76cdd8470..000000000 --- a/src/network/mcpe/protocol/RequestChunkRadiusPacket.php +++ /dev/null @@ -1,47 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class RequestChunkRadiusPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::REQUEST_CHUNK_RADIUS_PACKET; - - /** @var int */ - public $radius; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->radius = $in->getVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putVarInt($this->radius); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleRequestChunkRadius($this); - } -} diff --git a/src/network/mcpe/protocol/ResourcePackChunkDataPacket.php b/src/network/mcpe/protocol/ResourcePackChunkDataPacket.php deleted file mode 100644 index a26db209e..000000000 --- a/src/network/mcpe/protocol/ResourcePackChunkDataPacket.php +++ /dev/null @@ -1,68 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class ResourcePackChunkDataPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_CHUNK_DATA_PACKET; - - /** @var string */ - public $packId; - /** @var int */ - public $chunkIndex; - /** @var int */ - public $progress; - /** @var string */ - public $data; - - public static function create(string $packId, int $chunkIndex, int $chunkOffset, string $data) : self{ - $result = new self; - $result->packId = $packId; - $result->chunkIndex = $chunkIndex; - $result->progress = $chunkOffset; - $result->data = $data; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->packId = $in->getString(); - $this->chunkIndex = $in->getLInt(); - $this->progress = $in->getLLong(); - $this->data = $in->getString(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->packId); - $out->putLInt($this->chunkIndex); - $out->putLLong($this->progress); - $out->putString($this->data); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleResourcePackChunkData($this); - } -} diff --git a/src/network/mcpe/protocol/ResourcePackChunkRequestPacket.php b/src/network/mcpe/protocol/ResourcePackChunkRequestPacket.php deleted file mode 100644 index 30ea02cd8..000000000 --- a/src/network/mcpe/protocol/ResourcePackChunkRequestPacket.php +++ /dev/null @@ -1,51 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class ResourcePackChunkRequestPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_CHUNK_REQUEST_PACKET; - - /** @var string */ - public $packId; - /** @var int */ - public $chunkIndex; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->packId = $in->getString(); - $this->chunkIndex = $in->getLInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->packId); - $out->putLInt($this->chunkIndex); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleResourcePackChunkRequest($this); - } -} diff --git a/src/network/mcpe/protocol/ResourcePackClientResponsePacket.php b/src/network/mcpe/protocol/ResourcePackClientResponsePacket.php deleted file mode 100644 index e0ed823cb..000000000 --- a/src/network/mcpe/protocol/ResourcePackClientResponsePacket.php +++ /dev/null @@ -1,64 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use function count; - -class ResourcePackClientResponsePacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_CLIENT_RESPONSE_PACKET; - - public const STATUS_REFUSED = 1; - public const STATUS_SEND_PACKS = 2; - public const STATUS_HAVE_ALL_PACKS = 3; - public const STATUS_COMPLETED = 4; - - /** @var int */ - public $status; - /** @var string[] */ - public $packIds = []; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->status = $in->getByte(); - $entryCount = $in->getLShort(); - $this->packIds = []; - while($entryCount-- > 0){ - $this->packIds[] = $in->getString(); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putByte($this->status); - $out->putLShort(count($this->packIds)); - foreach($this->packIds as $id){ - $out->putString($id); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleResourcePackClientResponse($this); - } -} diff --git a/src/network/mcpe/protocol/ResourcePackDataInfoPacket.php b/src/network/mcpe/protocol/ResourcePackDataInfoPacket.php deleted file mode 100644 index a7ed48253..000000000 --- a/src/network/mcpe/protocol/ResourcePackDataInfoPacket.php +++ /dev/null @@ -1,82 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\resourcepacks\ResourcePackType; - -class ResourcePackDataInfoPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_DATA_INFO_PACKET; - - /** @var string */ - public $packId; - /** @var int */ - public $maxChunkSize; - /** @var int */ - public $chunkCount; - /** @var int */ - public $compressedPackSize; - /** @var string */ - public $sha256; - /** @var bool */ - public $isPremium = false; - /** @var int */ - public $packType = ResourcePackType::RESOURCES; //TODO: check the values for this - - public static function create(string $packId, int $maxChunkSize, int $chunkCount, int $compressedPackSize, string $sha256sum) : self{ - $result = new self; - $result->packId = $packId; - $result->maxChunkSize = $maxChunkSize; - $result->chunkCount = $chunkCount; - $result->compressedPackSize = $compressedPackSize; - $result->sha256 = $sha256sum; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->packId = $in->getString(); - $this->maxChunkSize = $in->getLInt(); - $this->chunkCount = $in->getLInt(); - $this->compressedPackSize = $in->getLLong(); - $this->sha256 = $in->getString(); - $this->isPremium = $in->getBool(); - $this->packType = $in->getByte(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->packId); - $out->putLInt($this->maxChunkSize); - $out->putLInt($this->chunkCount); - $out->putLLong($this->compressedPackSize); - $out->putString($this->sha256); - $out->putBool($this->isPremium); - $out->putByte($this->packType); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleResourcePackDataInfo($this); - } -} diff --git a/src/network/mcpe/protocol/ResourcePackStackPacket.php b/src/network/mcpe/protocol/ResourcePackStackPacket.php deleted file mode 100644 index 2da8ef97d..000000000 --- a/src/network/mcpe/protocol/ResourcePackStackPacket.php +++ /dev/null @@ -1,101 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\Experiments; -use pocketmine\network\mcpe\protocol\types\resourcepacks\ResourcePackStackEntry; -use function count; - -class ResourcePackStackPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_STACK_PACKET; - - /** @var bool */ - public $mustAccept = false; - - /** @var ResourcePackStackEntry[] */ - public $behaviorPackStack = []; - /** @var ResourcePackStackEntry[] */ - public $resourcePackStack = []; - - /** @var string */ - public $baseGameVersion = ProtocolInfo::MINECRAFT_VERSION_NETWORK; - - /** @var Experiments */ - public $experiments; - - /** - * @param ResourcePackStackEntry[] $resourcePacks - * @param ResourcePackStackEntry[] $behaviorPacks - * - * @return ResourcePackStackPacket - */ - public static function create(array $resourcePacks, array $behaviorPacks, bool $mustAccept, Experiments $experiments) : self{ - $result = new self; - $result->mustAccept = $mustAccept; - $result->resourcePackStack = $resourcePacks; - $result->behaviorPackStack = $behaviorPacks; - $result->experiments = $experiments; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->mustAccept = $in->getBool(); - $behaviorPackCount = $in->getUnsignedVarInt(); - while($behaviorPackCount-- > 0){ - $this->behaviorPackStack[] = ResourcePackStackEntry::read($in); - } - - $resourcePackCount = $in->getUnsignedVarInt(); - while($resourcePackCount-- > 0){ - $this->resourcePackStack[] = ResourcePackStackEntry::read($in); - } - - $this->baseGameVersion = $in->getString(); - $this->experiments = Experiments::read($in); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putBool($this->mustAccept); - - $out->putUnsignedVarInt(count($this->behaviorPackStack)); - foreach($this->behaviorPackStack as $entry){ - $entry->write($out); - } - - $out->putUnsignedVarInt(count($this->resourcePackStack)); - foreach($this->resourcePackStack as $entry){ - $entry->write($out); - } - - $out->putString($this->baseGameVersion); - $this->experiments->write($out); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleResourcePackStack($this); - } -} diff --git a/src/network/mcpe/protocol/ResourcePacksInfoPacket.php b/src/network/mcpe/protocol/ResourcePacksInfoPacket.php deleted file mode 100644 index 7f1b5dd00..000000000 --- a/src/network/mcpe/protocol/ResourcePacksInfoPacket.php +++ /dev/null @@ -1,95 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\resourcepacks\BehaviorPackInfoEntry; -use pocketmine\network\mcpe\protocol\types\resourcepacks\ResourcePackInfoEntry; -use function count; - -class ResourcePacksInfoPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::RESOURCE_PACKS_INFO_PACKET; - - /** @var bool */ - public $mustAccept = false; //if true, forces client to choose between accepting packs or being disconnected - /** @var bool */ - public $hasScripts = false; //if true, causes disconnect for any platform that doesn't support scripts yet - - public bool $forceServerPacks = false; - /** @var BehaviorPackInfoEntry[] */ - public $behaviorPackEntries = []; - /** @var ResourcePackInfoEntry[] */ - public $resourcePackEntries = []; - - /** - * @param ResourcePackInfoEntry[] $resourcePacks - * @param BehaviorPackInfoEntry[] $behaviorPacks - * - * @return ResourcePacksInfoPacket - */ - public static function create(array $resourcePacks, array $behaviorPacks, bool $mustAccept, bool $hasScripts, bool $forceServerPacks) : self{ - $result = new self; - $result->mustAccept = $mustAccept; - $result->hasScripts = $hasScripts; - $result->resourcePackEntries = $resourcePacks; - $result->behaviorPackEntries = $behaviorPacks; - $result->forceServerPacks = $forceServerPacks; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->mustAccept = $in->getBool(); - $this->hasScripts = $in->getBool(); - $this->forceServerPacks = $in->getBool(); - $behaviorPackCount = $in->getLShort(); - while($behaviorPackCount-- > 0){ - $this->behaviorPackEntries[] = BehaviorPackInfoEntry::read($in); - } - - $resourcePackCount = $in->getLShort(); - while($resourcePackCount-- > 0){ - $this->resourcePackEntries[] = ResourcePackInfoEntry::read($in); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putBool($this->mustAccept); - $out->putBool($this->hasScripts); - $out->putBool($this->forceServerPacks); - $out->putLShort(count($this->behaviorPackEntries)); - foreach($this->behaviorPackEntries as $entry){ - $entry->write($out); - } - $out->putLShort(count($this->resourcePackEntries)); - foreach($this->resourcePackEntries as $entry){ - $entry->write($out); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleResourcePacksInfo($this); - } -} diff --git a/src/network/mcpe/protocol/RespawnPacket.php b/src/network/mcpe/protocol/RespawnPacket.php deleted file mode 100644 index 4bf694517..000000000 --- a/src/network/mcpe/protocol/RespawnPacket.php +++ /dev/null @@ -1,68 +0,0 @@ - - -use pocketmine\math\Vector3; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class RespawnPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::RESPAWN_PACKET; - - public const SEARCHING_FOR_SPAWN = 0; - public const READY_TO_SPAWN = 1; - public const CLIENT_READY_TO_SPAWN = 2; - - /** @var Vector3 */ - public $position; - /** @var int */ - public $respawnState = self::SEARCHING_FOR_SPAWN; - /** @var int */ - public $entityRuntimeId; - - public static function create(Vector3 $position, int $respawnStatus, int $entityRuntimeId) : self{ - $result = new self; - $result->position = $position->asVector3(); - $result->respawnState = $respawnStatus; - $result->entityRuntimeId = $entityRuntimeId; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->position = $in->getVector3(); - $this->respawnState = $in->getByte(); - $this->entityRuntimeId = $in->getEntityRuntimeId(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putVector3($this->position); - $out->putByte($this->respawnState); - $out->putEntityRuntimeId($this->entityRuntimeId); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleRespawn($this); - } -} diff --git a/src/network/mcpe/protocol/RiderJumpPacket.php b/src/network/mcpe/protocol/RiderJumpPacket.php deleted file mode 100644 index d7186968b..000000000 --- a/src/network/mcpe/protocol/RiderJumpPacket.php +++ /dev/null @@ -1,47 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class RiderJumpPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::RIDER_JUMP_PACKET; - - /** @var int */ - public $jumpStrength; //percentage - - protected function decodePayload(PacketSerializer $in) : void{ - $this->jumpStrength = $in->getVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putVarInt($this->jumpStrength); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleRiderJump($this); - } -} diff --git a/src/network/mcpe/protocol/ScriptCustomEventPacket.php b/src/network/mcpe/protocol/ScriptCustomEventPacket.php deleted file mode 100644 index 17be40ff9..000000000 --- a/src/network/mcpe/protocol/ScriptCustomEventPacket.php +++ /dev/null @@ -1,51 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class ScriptCustomEventPacket extends DataPacket{ //TODO: this doesn't have handlers in either client or server in the game as of 1.8 - public const NETWORK_ID = ProtocolInfo::SCRIPT_CUSTOM_EVENT_PACKET; - - /** @var string */ - public $eventName; - /** @var string json data */ - public $eventData; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->eventName = $in->getString(); - $this->eventData = $in->getString(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->eventName); - $out->putString($this->eventData); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleScriptCustomEvent($this); - } -} diff --git a/src/network/mcpe/protocol/ServerSettingsRequestPacket.php b/src/network/mcpe/protocol/ServerSettingsRequestPacket.php deleted file mode 100644 index 9d1e60b35..000000000 --- a/src/network/mcpe/protocol/ServerSettingsRequestPacket.php +++ /dev/null @@ -1,44 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class ServerSettingsRequestPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::SERVER_SETTINGS_REQUEST_PACKET; - - protected function decodePayload(PacketSerializer $in) : void{ - //No payload - } - - protected function encodePayload(PacketSerializer $out) : void{ - //No payload - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleServerSettingsRequest($this); - } -} diff --git a/src/network/mcpe/protocol/ServerSettingsResponsePacket.php b/src/network/mcpe/protocol/ServerSettingsResponsePacket.php deleted file mode 100644 index b1fd1a270..000000000 --- a/src/network/mcpe/protocol/ServerSettingsResponsePacket.php +++ /dev/null @@ -1,51 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class ServerSettingsResponsePacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::SERVER_SETTINGS_RESPONSE_PACKET; - - /** @var int */ - public $formId; - /** @var string */ - public $formData; //json - - protected function decodePayload(PacketSerializer $in) : void{ - $this->formId = $in->getUnsignedVarInt(); - $this->formData = $in->getString(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt($this->formId); - $out->putString($this->formData); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleServerSettingsResponse($this); - } -} diff --git a/src/network/mcpe/protocol/ServerToClientHandshakePacket.php b/src/network/mcpe/protocol/ServerToClientHandshakePacket.php deleted file mode 100644 index 19f15ade2..000000000 --- a/src/network/mcpe/protocol/ServerToClientHandshakePacket.php +++ /dev/null @@ -1,60 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class ServerToClientHandshakePacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::SERVER_TO_CLIENT_HANDSHAKE_PACKET; - - /** - * @var string - * Server pubkey and token is contained in the JWT. - */ - public $jwt; - - public static function create(string $jwt) : self{ - $result = new self; - $result->jwt = $jwt; - return $result; - } - - public function canBeSentBeforeLogin() : bool{ - return true; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->jwt = $in->getString(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->jwt); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleServerToClientHandshake($this); - } -} diff --git a/src/network/mcpe/protocol/ServerboundPacket.php b/src/network/mcpe/protocol/ServerboundPacket.php deleted file mode 100644 index 26c083350..000000000 --- a/src/network/mcpe/protocol/ServerboundPacket.php +++ /dev/null @@ -1,28 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\entity\MetadataProperty; - -class SetActorDataPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ //TODO: check why this is serverbound - public const NETWORK_ID = ProtocolInfo::SET_ACTOR_DATA_PACKET; - - /** @var int */ - public $entityRuntimeId; - /** - * @var MetadataProperty[] - * @phpstan-var array - */ - public $metadata; - - /** @var int */ - public $tick = 0; - - /** - * @param MetadataProperty[] $metadata - * @phpstan-param array $metadata - */ - public static function create(int $entityRuntimeId, array $metadata, int $tick) : self{ - - $result = new self; - $result->entityRuntimeId = $entityRuntimeId; - $result->metadata = $metadata; - $result->tick = $tick; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityRuntimeId = $in->getEntityRuntimeId(); - $this->metadata = $in->getEntityMetadata(); - $this->tick = $in->getUnsignedVarLong(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityRuntimeId($this->entityRuntimeId); - $out->putEntityMetadata($this->metadata); - $out->putUnsignedVarLong($this->tick); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleSetActorData($this); - } -} diff --git a/src/network/mcpe/protocol/SetActorLinkPacket.php b/src/network/mcpe/protocol/SetActorLinkPacket.php deleted file mode 100644 index f8ca170b8..000000000 --- a/src/network/mcpe/protocol/SetActorLinkPacket.php +++ /dev/null @@ -1,48 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\entity\EntityLink; - -class SetActorLinkPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::SET_ACTOR_LINK_PACKET; - - /** @var EntityLink */ - public $link; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->link = $in->getEntityLink(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityLink($this->link); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleSetActorLink($this); - } -} diff --git a/src/network/mcpe/protocol/SetActorMotionPacket.php b/src/network/mcpe/protocol/SetActorMotionPacket.php deleted file mode 100644 index d848c5ca0..000000000 --- a/src/network/mcpe/protocol/SetActorMotionPacket.php +++ /dev/null @@ -1,59 +0,0 @@ - - -use pocketmine\math\Vector3; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class SetActorMotionPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::SET_ACTOR_MOTION_PACKET; - - /** @var int */ - public $entityRuntimeId; - /** @var Vector3 */ - public $motion; - - public static function create(int $entityRuntimeId, Vector3 $motion) : self{ - $result = new self; - $result->entityRuntimeId = $entityRuntimeId; - $result->motion = $motion->asVector3(); - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityRuntimeId = $in->getEntityRuntimeId(); - $this->motion = $in->getVector3(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityRuntimeId($this->entityRuntimeId); - $out->putVector3($this->motion); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleSetActorMotion($this); - } -} diff --git a/src/network/mcpe/protocol/SetCommandsEnabledPacket.php b/src/network/mcpe/protocol/SetCommandsEnabledPacket.php deleted file mode 100644 index ad5269907..000000000 --- a/src/network/mcpe/protocol/SetCommandsEnabledPacket.php +++ /dev/null @@ -1,53 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class SetCommandsEnabledPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::SET_COMMANDS_ENABLED_PACKET; - - /** @var bool */ - public $enabled; - - public static function create(bool $enabled) : self{ - $result = new self; - $result->enabled = $enabled; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->enabled = $in->getBool(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putBool($this->enabled); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleSetCommandsEnabled($this); - } -} diff --git a/src/network/mcpe/protocol/SetDefaultGameTypePacket.php b/src/network/mcpe/protocol/SetDefaultGameTypePacket.php deleted file mode 100644 index 63cd53f65..000000000 --- a/src/network/mcpe/protocol/SetDefaultGameTypePacket.php +++ /dev/null @@ -1,53 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class SetDefaultGameTypePacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::SET_DEFAULT_GAME_TYPE_PACKET; - - /** @var int */ - public $gamemode; - - public static function create(int $gameMode) : self{ - $result = new self; - $result->gamemode = $gameMode; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->gamemode = $in->getVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt($this->gamemode); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleSetDefaultGameType($this); - } -} diff --git a/src/network/mcpe/protocol/SetDifficultyPacket.php b/src/network/mcpe/protocol/SetDifficultyPacket.php deleted file mode 100644 index e430c53d6..000000000 --- a/src/network/mcpe/protocol/SetDifficultyPacket.php +++ /dev/null @@ -1,53 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class SetDifficultyPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::SET_DIFFICULTY_PACKET; - - /** @var int */ - public $difficulty; - - public static function create(int $difficulty) : self{ - $result = new self; - $result->difficulty = $difficulty; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->difficulty = $in->getUnsignedVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putUnsignedVarInt($this->difficulty); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleSetDifficulty($this); - } -} diff --git a/src/network/mcpe/protocol/SetDisplayObjectivePacket.php b/src/network/mcpe/protocol/SetDisplayObjectivePacket.php deleted file mode 100644 index 9154bfa95..000000000 --- a/src/network/mcpe/protocol/SetDisplayObjectivePacket.php +++ /dev/null @@ -1,70 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class SetDisplayObjectivePacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::SET_DISPLAY_OBJECTIVE_PACKET; - - public const DISPLAY_SLOT_LIST = "list"; - public const DISPLAY_SLOT_SIDEBAR = "sidebar"; - public const DISPLAY_SLOT_BELOW_NAME = "belowname"; - - public const SORT_ORDER_ASCENDING = 0; - public const SORT_ORDER_DESCENDING = 1; - - /** @var string */ - public $displaySlot; - /** @var string */ - public $objectiveName; - /** @var string */ - public $displayName; - /** @var string */ - public $criteriaName; - /** @var int */ - public $sortOrder; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->displaySlot = $in->getString(); - $this->objectiveName = $in->getString(); - $this->displayName = $in->getString(); - $this->criteriaName = $in->getString(); - $this->sortOrder = $in->getVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->displaySlot); - $out->putString($this->objectiveName); - $out->putString($this->displayName); - $out->putString($this->criteriaName); - $out->putVarInt($this->sortOrder); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleSetDisplayObjective($this); - } -} diff --git a/src/network/mcpe/protocol/SetHealthPacket.php b/src/network/mcpe/protocol/SetHealthPacket.php deleted file mode 100644 index 87e08b9ba..000000000 --- a/src/network/mcpe/protocol/SetHealthPacket.php +++ /dev/null @@ -1,47 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class SetHealthPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::SET_HEALTH_PACKET; - - /** @var int */ - public $health; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->health = $in->getVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putVarInt($this->health); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleSetHealth($this); - } -} diff --git a/src/network/mcpe/protocol/SetLastHurtByPacket.php b/src/network/mcpe/protocol/SetLastHurtByPacket.php deleted file mode 100644 index 6a3fd7111..000000000 --- a/src/network/mcpe/protocol/SetLastHurtByPacket.php +++ /dev/null @@ -1,47 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class SetLastHurtByPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::SET_LAST_HURT_BY_PACKET; - - /** @var int */ - public $entityTypeId; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityTypeId = $in->getVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putVarInt($this->entityTypeId); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleSetLastHurtBy($this); - } -} diff --git a/src/network/mcpe/protocol/SetLocalPlayerAsInitializedPacket.php b/src/network/mcpe/protocol/SetLocalPlayerAsInitializedPacket.php deleted file mode 100644 index 5f9eda566..000000000 --- a/src/network/mcpe/protocol/SetLocalPlayerAsInitializedPacket.php +++ /dev/null @@ -1,47 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class SetLocalPlayerAsInitializedPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::SET_LOCAL_PLAYER_AS_INITIALIZED_PACKET; - - /** @var int */ - public $entityRuntimeId; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityRuntimeId = $in->getEntityRuntimeId(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityRuntimeId($this->entityRuntimeId); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleSetLocalPlayerAsInitialized($this); - } -} diff --git a/src/network/mcpe/protocol/SetPlayerGameTypePacket.php b/src/network/mcpe/protocol/SetPlayerGameTypePacket.php deleted file mode 100644 index eb337f2a7..000000000 --- a/src/network/mcpe/protocol/SetPlayerGameTypePacket.php +++ /dev/null @@ -1,53 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class SetPlayerGameTypePacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::SET_PLAYER_GAME_TYPE_PACKET; - - /** @var int */ - public $gamemode; - - public static function create(int $gamemode) : self{ - $pk = new self; - $pk->gamemode = $gamemode; - return $pk; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->gamemode = $in->getVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putVarInt($this->gamemode); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleSetPlayerGameType($this); - } -} diff --git a/src/network/mcpe/protocol/SetScorePacket.php b/src/network/mcpe/protocol/SetScorePacket.php deleted file mode 100644 index 2d135c938..000000000 --- a/src/network/mcpe/protocol/SetScorePacket.php +++ /dev/null @@ -1,95 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\ScorePacketEntry; -use function count; - -class SetScorePacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::SET_SCORE_PACKET; - - public const TYPE_CHANGE = 0; - public const TYPE_REMOVE = 1; - - /** @var int */ - public $type; - /** @var ScorePacketEntry[] */ - public $entries = []; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->type = $in->getByte(); - for($i = 0, $i2 = $in->getUnsignedVarInt(); $i < $i2; ++$i){ - $entry = new ScorePacketEntry(); - $entry->scoreboardId = $in->getVarLong(); - $entry->objectiveName = $in->getString(); - $entry->score = $in->getLInt(); - if($this->type !== self::TYPE_REMOVE){ - $entry->type = $in->getByte(); - switch($entry->type){ - case ScorePacketEntry::TYPE_PLAYER: - case ScorePacketEntry::TYPE_ENTITY: - $entry->entityUniqueId = $in->getEntityUniqueId(); - break; - case ScorePacketEntry::TYPE_FAKE_PLAYER: - $entry->customName = $in->getString(); - break; - default: - throw new PacketDecodeException("Unknown entry type $entry->type"); - } - } - $this->entries[] = $entry; - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putByte($this->type); - $out->putUnsignedVarInt(count($this->entries)); - foreach($this->entries as $entry){ - $out->putVarLong($entry->scoreboardId); - $out->putString($entry->objectiveName); - $out->putLInt($entry->score); - if($this->type !== self::TYPE_REMOVE){ - $out->putByte($entry->type); - switch($entry->type){ - case ScorePacketEntry::TYPE_PLAYER: - case ScorePacketEntry::TYPE_ENTITY: - $out->putEntityUniqueId($entry->entityUniqueId); - break; - case ScorePacketEntry::TYPE_FAKE_PLAYER: - $out->putString($entry->customName); - break; - default: - throw new \InvalidArgumentException("Unknown entry type $entry->type"); - } - } - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleSetScore($this); - } -} diff --git a/src/network/mcpe/protocol/SetScoreboardIdentityPacket.php b/src/network/mcpe/protocol/SetScoreboardIdentityPacket.php deleted file mode 100644 index d48a7e9be..000000000 --- a/src/network/mcpe/protocol/SetScoreboardIdentityPacket.php +++ /dev/null @@ -1,70 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\ScoreboardIdentityPacketEntry; -use function count; - -class SetScoreboardIdentityPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::SET_SCOREBOARD_IDENTITY_PACKET; - - public const TYPE_REGISTER_IDENTITY = 0; - public const TYPE_CLEAR_IDENTITY = 1; - - /** @var int */ - public $type; - /** @var ScoreboardIdentityPacketEntry[] */ - public $entries = []; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->type = $in->getByte(); - for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){ - $entry = new ScoreboardIdentityPacketEntry(); - $entry->scoreboardId = $in->getVarLong(); - if($this->type === self::TYPE_REGISTER_IDENTITY){ - $entry->entityUniqueId = $in->getEntityUniqueId(); - } - - $this->entries[] = $entry; - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putByte($this->type); - $out->putUnsignedVarInt(count($this->entries)); - foreach($this->entries as $entry){ - $out->putVarLong($entry->scoreboardId); - if($this->type === self::TYPE_REGISTER_IDENTITY){ - $out->putEntityUniqueId($entry->entityUniqueId); - } - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleSetScoreboardIdentity($this); - } -} diff --git a/src/network/mcpe/protocol/SetSpawnPositionPacket.php b/src/network/mcpe/protocol/SetSpawnPositionPacket.php deleted file mode 100644 index a1cffc88f..000000000 --- a/src/network/mcpe/protocol/SetSpawnPositionPacket.php +++ /dev/null @@ -1,88 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class SetSpawnPositionPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::SET_SPAWN_POSITION_PACKET; - - public const TYPE_PLAYER_SPAWN = 0; - public const TYPE_WORLD_SPAWN = 1; - - /** @var int */ - public $spawnType; - /** @var int */ - public $x; - /** @var int */ - public $y; - /** @var int */ - public $z; - /** @var int */ - public $dimension; - /** @var int */ - public $x2; - /** @var int */ - public $y2; - /** @var int */ - public $z2; - - public static function playerSpawn(int $x, int $y, int $z, int $dimension, int $x2, int $y2, int $z2) : self{ - $result = new self; - $result->spawnType = self::TYPE_PLAYER_SPAWN; - [$result->x, $result->y, $result->z] = [$x, $y, $z]; - [$result->x2, $result->y2, $result->z2] = [$x2, $y2, $z2]; - $result->dimension = $dimension; - return $result; - } - - public static function worldSpawn(int $x, int $y, int $z, int $dimension) : self{ - $result = new self; - $result->spawnType = self::TYPE_WORLD_SPAWN; - [$result->x, $result->y, $result->z] = [$x, $y, $z]; - [$result->x2, $result->y2, $result->z2] = [$x, $y, $z]; - $result->dimension = $dimension; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->spawnType = $in->getVarInt(); - $in->getBlockPosition($this->x, $this->y, $this->z); - $this->dimension = $in->getVarInt(); - $in->getBlockPosition($this->x2, $this->y2, $this->z2); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putVarInt($this->spawnType); - $out->putBlockPosition($this->x, $this->y, $this->z); - $out->putVarInt($this->dimension); - $out->putBlockPosition($this->x2, $this->y2, $this->z2); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleSetSpawnPosition($this); - } -} diff --git a/src/network/mcpe/protocol/SetTimePacket.php b/src/network/mcpe/protocol/SetTimePacket.php deleted file mode 100644 index a8e38e03e..000000000 --- a/src/network/mcpe/protocol/SetTimePacket.php +++ /dev/null @@ -1,53 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class SetTimePacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::SET_TIME_PACKET; - - /** @var int */ - public $time; - - public static function create(int $time) : self{ - $result = new self; - $result->time = $time & 0xffffffff; //avoid overflowing the field, since the packet uses an int32 - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->time = $in->getVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putVarInt($this->time); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleSetTime($this); - } -} diff --git a/src/network/mcpe/protocol/SetTitlePacket.php b/src/network/mcpe/protocol/SetTitlePacket.php deleted file mode 100644 index da5e6ced9..000000000 --- a/src/network/mcpe/protocol/SetTitlePacket.php +++ /dev/null @@ -1,119 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class SetTitlePacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::SET_TITLE_PACKET; - - public const TYPE_CLEAR_TITLE = 0; - public const TYPE_RESET_TITLE = 1; - public const TYPE_SET_TITLE = 2; - public const TYPE_SET_SUBTITLE = 3; - public const TYPE_SET_ACTIONBAR_MESSAGE = 4; - public const TYPE_SET_ANIMATION_TIMES = 5; - public const TYPE_SET_TITLE_JSON = 6; - public const TYPE_SET_SUBTITLE_JSON = 7; - public const TYPE_SET_ACTIONBAR_MESSAGE_JSON = 8; - - /** @var int */ - public $type; - /** @var string */ - public $text = ""; - /** @var int */ - public $fadeInTime = 0; - /** @var int */ - public $stayTime = 0; - /** @var int */ - public $fadeOutTime = 0; - public string $xuid = ""; - public string $platformOnlineId = ""; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->type = $in->getVarInt(); - $this->text = $in->getString(); - $this->fadeInTime = $in->getVarInt(); - $this->stayTime = $in->getVarInt(); - $this->fadeOutTime = $in->getVarInt(); - $this->xuid = $in->getString(); - $this->platformOnlineId = $in->getString(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putVarInt($this->type); - $out->putString($this->text); - $out->putVarInt($this->fadeInTime); - $out->putVarInt($this->stayTime); - $out->putVarInt($this->fadeOutTime); - $out->putString($this->xuid); - $out->putString($this->platformOnlineId); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleSetTitle($this); - } - - private static function type(int $type) : self{ - $result = new self; - $result->type = $type; - return $result; - } - - private static function text(int $type, string $text) : self{ - $result = self::type($type); - $result->text = $text; - return $result; - } - - public static function title(string $text) : self{ - return self::text(self::TYPE_SET_TITLE, $text); - } - - public static function subtitle(string $text) : self{ - return self::text(self::TYPE_SET_SUBTITLE, $text); - } - - public static function actionBarMessage(string $text) : self{ - return self::text(self::TYPE_SET_ACTIONBAR_MESSAGE, $text); - } - - public static function clearTitle() : self{ - return self::type(self::TYPE_CLEAR_TITLE); - } - - public static function resetTitleOptions() : self{ - return self::type(self::TYPE_RESET_TITLE); - } - - public static function setAnimationTimes(int $fadeIn, int $stay, int $fadeOut) : self{ - $result = self::type(self::TYPE_SET_ANIMATION_TIMES); - $result->fadeInTime = $fadeIn; - $result->stayTime = $stay; - $result->fadeOutTime = $fadeOut; - return $result; - } -} diff --git a/src/network/mcpe/protocol/SettingsCommandPacket.php b/src/network/mcpe/protocol/SettingsCommandPacket.php deleted file mode 100644 index 3bf2d10c6..000000000 --- a/src/network/mcpe/protocol/SettingsCommandPacket.php +++ /dev/null @@ -1,66 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class SettingsCommandPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::SETTINGS_COMMAND_PACKET; - - /** @var string */ - private $command; - /** @var bool */ - private $suppressOutput; - - public static function create(string $command, bool $suppressOutput) : self{ - $result = new self; - $result->command = $command; - $result->suppressOutput = $suppressOutput; - return $result; - } - - public function getCommand() : string{ - return $this->command; - } - - public function getSuppressOutput() : bool{ - return $this->suppressOutput; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->command = $in->getString(); - $this->suppressOutput = $in->getBool(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->command); - $out->putBool($this->suppressOutput); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleSettingsCommand($this); - } -} diff --git a/src/network/mcpe/protocol/ShowCreditsPacket.php b/src/network/mcpe/protocol/ShowCreditsPacket.php deleted file mode 100644 index 22b56ed29..000000000 --- a/src/network/mcpe/protocol/ShowCreditsPacket.php +++ /dev/null @@ -1,54 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class ShowCreditsPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::SHOW_CREDITS_PACKET; - - public const STATUS_START_CREDITS = 0; - public const STATUS_END_CREDITS = 1; - - /** @var int */ - public $playerEid; - /** @var int */ - public $status; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->playerEid = $in->getEntityRuntimeId(); - $this->status = $in->getVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityRuntimeId($this->playerEid); - $out->putVarInt($this->status); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleShowCredits($this); - } -} diff --git a/src/network/mcpe/protocol/ShowProfilePacket.php b/src/network/mcpe/protocol/ShowProfilePacket.php deleted file mode 100644 index 0d3ae0165..000000000 --- a/src/network/mcpe/protocol/ShowProfilePacket.php +++ /dev/null @@ -1,47 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class ShowProfilePacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::SHOW_PROFILE_PACKET; - - /** @var string */ - public $xuid; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->xuid = $in->getString(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->xuid); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleShowProfile($this); - } -} diff --git a/src/network/mcpe/protocol/ShowStoreOfferPacket.php b/src/network/mcpe/protocol/ShowStoreOfferPacket.php deleted file mode 100644 index 5636f3c17..000000000 --- a/src/network/mcpe/protocol/ShowStoreOfferPacket.php +++ /dev/null @@ -1,51 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class ShowStoreOfferPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::SHOW_STORE_OFFER_PACKET; - - /** @var string */ - public $offerId; - /** @var bool */ - public $showAll; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->offerId = $in->getString(); - $this->showAll = $in->getBool(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->offerId); - $out->putBool($this->showAll); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleShowStoreOffer($this); - } -} diff --git a/src/network/mcpe/protocol/SimpleEventPacket.php b/src/network/mcpe/protocol/SimpleEventPacket.php deleted file mode 100644 index 0ae0bfdeb..000000000 --- a/src/network/mcpe/protocol/SimpleEventPacket.php +++ /dev/null @@ -1,51 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class SimpleEventPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::SIMPLE_EVENT_PACKET; - - public const TYPE_ENABLE_COMMANDS = 1; - public const TYPE_DISABLE_COMMANDS = 2; - public const TYPE_UNLOCK_WORLD_TEMPLATE_SETTINGS = 3; - - /** @var int */ - public $eventType; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->eventType = $in->getLShort(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putLShort($this->eventType); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleSimpleEvent($this); - } -} diff --git a/src/network/mcpe/protocol/SimulationTypePacket.php b/src/network/mcpe/protocol/SimulationTypePacket.php deleted file mode 100644 index 28f662b63..000000000 --- a/src/network/mcpe/protocol/SimulationTypePacket.php +++ /dev/null @@ -1,58 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class SimulationTypePacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::SIMULATION_TYPE_PACKET; - - public const GAME = 0; - public const EDITOR = 1; - public const TEST = 2; - - private int $type; - - public static function create(int $type) : self{ - $result = new self; - $result->type = $type; - return $result; - } - - public function getType() : int{ return $this->type; } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->type = $in->getByte(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putByte($this->type); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleSimulationType($this); - } -} diff --git a/src/network/mcpe/protocol/SpawnExperienceOrbPacket.php b/src/network/mcpe/protocol/SpawnExperienceOrbPacket.php deleted file mode 100644 index 6f1ee186d..000000000 --- a/src/network/mcpe/protocol/SpawnExperienceOrbPacket.php +++ /dev/null @@ -1,52 +0,0 @@ - - -use pocketmine\math\Vector3; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class SpawnExperienceOrbPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::SPAWN_EXPERIENCE_ORB_PACKET; - - /** @var Vector3 */ - public $position; - /** @var int */ - public $amount; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->position = $in->getVector3(); - $this->amount = $in->getVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putVector3($this->position); - $out->putVarInt($this->amount); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleSpawnExperienceOrb($this); - } -} diff --git a/src/network/mcpe/protocol/SpawnParticleEffectPacket.php b/src/network/mcpe/protocol/SpawnParticleEffectPacket.php deleted file mode 100644 index 2485608d3..000000000 --- a/src/network/mcpe/protocol/SpawnParticleEffectPacket.php +++ /dev/null @@ -1,61 +0,0 @@ - - -use pocketmine\math\Vector3; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\DimensionIds; - -class SpawnParticleEffectPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::SPAWN_PARTICLE_EFFECT_PACKET; - - /** @var int */ - public $dimensionId = DimensionIds::OVERWORLD; //wtf mojang - /** @var int */ - public $entityUniqueId = -1; //default none - /** @var Vector3 */ - public $position; - /** @var string */ - public $particleName; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->dimensionId = $in->getByte(); - $this->entityUniqueId = $in->getEntityUniqueId(); - $this->position = $in->getVector3(); - $this->particleName = $in->getString(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putByte($this->dimensionId); - $out->putEntityUniqueId($this->entityUniqueId); - $out->putVector3($this->position); - $out->putString($this->particleName); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleSpawnParticleEffect($this); - } -} diff --git a/src/network/mcpe/protocol/StartGamePacket.php b/src/network/mcpe/protocol/StartGamePacket.php deleted file mode 100644 index 2a7ee064f..000000000 --- a/src/network/mcpe/protocol/StartGamePacket.php +++ /dev/null @@ -1,348 +0,0 @@ - - -use pocketmine\math\Vector3; -use pocketmine\nbt\TreeRoot; -use pocketmine\network\mcpe\protocol\serializer\NetworkNbtSerializer; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\BlockPaletteEntry; -use pocketmine\network\mcpe\protocol\types\EducationEditionOffer; -use pocketmine\network\mcpe\protocol\types\Experiments; -use pocketmine\network\mcpe\protocol\types\GameRule; -use pocketmine\network\mcpe\protocol\types\GeneratorType; -use pocketmine\network\mcpe\protocol\types\ItemTypeEntry; -use pocketmine\network\mcpe\protocol\types\MultiplayerGameVisibility; -use pocketmine\network\mcpe\protocol\types\PlayerMovementSettings; -use pocketmine\network\mcpe\protocol\types\PlayerPermissions; -use pocketmine\network\mcpe\protocol\types\SpawnSettings; -use function count; - -class StartGamePacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::START_GAME_PACKET; - - /** @var int */ - public $entityUniqueId; - /** @var int */ - public $entityRuntimeId; - /** @var int */ - public $playerGamemode; - - /** @var Vector3 */ - public $playerPosition; - - /** @var float */ - public $pitch; - /** @var float */ - public $yaw; - - /** @var int */ - public $seed; - /** @var SpawnSettings */ - public $spawnSettings; - /** @var int */ - public $generator = GeneratorType::OVERWORLD; - /** @var int */ - public $worldGamemode; - /** @var int */ - public $difficulty; - /** @var int */ - public $spawnX; - /** @var int */ - public $spawnY; - /** @var int */ - public $spawnZ; - /** @var bool */ - public $hasAchievementsDisabled = true; - /** @var int */ - public $time = -1; - /** @var int */ - public $eduEditionOffer = EducationEditionOffer::NONE; - /** @var bool */ - public $hasEduFeaturesEnabled = false; - /** @var string */ - public $eduProductUUID = ""; - /** @var float */ - public $rainLevel; - /** @var float */ - public $lightningLevel; - /** @var bool */ - public $hasConfirmedPlatformLockedContent = false; - /** @var bool */ - public $isMultiplayerGame = true; - /** @var bool */ - public $hasLANBroadcast = true; - /** @var int */ - public $xboxLiveBroadcastMode = MultiplayerGameVisibility::PUBLIC; - /** @var int */ - public $platformBroadcastMode = MultiplayerGameVisibility::PUBLIC; - /** @var bool */ - public $commandsEnabled; - /** @var bool */ - public $isTexturePacksRequired = true; - /** - * @var GameRule[] - * @phpstan-var array - */ - public $gameRules = []; - /** @var Experiments */ - public $experiments; - /** @var bool */ - public $hasBonusChestEnabled = false; - /** @var bool */ - public $hasStartWithMapEnabled = false; - /** @var int */ - public $defaultPlayerPermission = PlayerPermissions::MEMBER; //TODO - - /** @var int */ - public $serverChunkTickRadius = 4; //TODO (leave as default for now) - - /** @var bool */ - public $hasLockedBehaviorPack = false; - /** @var bool */ - public $hasLockedResourcePack = false; - /** @var bool */ - public $isFromLockedWorldTemplate = false; - /** @var bool */ - public $useMsaGamertagsOnly = false; - /** @var bool */ - public $isFromWorldTemplate = false; - /** @var bool */ - public $isWorldTemplateOptionLocked = false; - /** @var bool */ - public $onlySpawnV1Villagers = false; - /** @var string */ - public $vanillaVersion = ProtocolInfo::MINECRAFT_VERSION_NETWORK; - /** @var int */ - public $limitedWorldWidth = 0; - /** @var int */ - public $limitedWorldLength = 0; - /** @var bool */ - public $isNewNether = true; - /** @var bool|null */ - public $experimentalGameplayOverride = null; - - /** @var string */ - public $levelId = ""; //base64 string, usually the same as world folder name in vanilla - /** @var string */ - public $worldName; - /** @var string */ - public $premiumWorldTemplateId = ""; - /** @var bool */ - public $isTrial = false; - /** @var PlayerMovementSettings */ - public $playerMovementSettings; - /** @var int */ - public $currentTick = 0; //only used if isTrial is true - /** @var int */ - public $enchantmentSeed = 0; - /** @var string */ - public $multiplayerCorrelationId = ""; //TODO: this should be filled with a UUID of some sort - /** @var bool */ - public $enableNewInventorySystem = false; //TODO - /** @var string */ - public $serverSoftwareVersion; - - /** - * @var BlockPaletteEntry[] - * @phpstan-var list - */ - public $blockPalette = []; - /** - * @var ItemTypeEntry[] - * @phpstan-var list - */ - public $itemTable; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityUniqueId = $in->getEntityUniqueId(); - $this->entityRuntimeId = $in->getEntityRuntimeId(); - $this->playerGamemode = $in->getVarInt(); - - $this->playerPosition = $in->getVector3(); - - $this->pitch = $in->getLFloat(); - $this->yaw = $in->getLFloat(); - - //Level settings - $this->seed = $in->getVarInt(); - $this->spawnSettings = SpawnSettings::read($in); - $this->generator = $in->getVarInt(); - $this->worldGamemode = $in->getVarInt(); - $this->difficulty = $in->getVarInt(); - $in->getBlockPosition($this->spawnX, $this->spawnY, $this->spawnZ); - $this->hasAchievementsDisabled = $in->getBool(); - $this->time = $in->getVarInt(); - $this->eduEditionOffer = $in->getVarInt(); - $this->hasEduFeaturesEnabled = $in->getBool(); - $this->eduProductUUID = $in->getString(); - $this->rainLevel = $in->getLFloat(); - $this->lightningLevel = $in->getLFloat(); - $this->hasConfirmedPlatformLockedContent = $in->getBool(); - $this->isMultiplayerGame = $in->getBool(); - $this->hasLANBroadcast = $in->getBool(); - $this->xboxLiveBroadcastMode = $in->getVarInt(); - $this->platformBroadcastMode = $in->getVarInt(); - $this->commandsEnabled = $in->getBool(); - $this->isTexturePacksRequired = $in->getBool(); - $this->gameRules = $in->getGameRules(); - $this->experiments = Experiments::read($in); - $this->hasBonusChestEnabled = $in->getBool(); - $this->hasStartWithMapEnabled = $in->getBool(); - $this->defaultPlayerPermission = $in->getVarInt(); - $this->serverChunkTickRadius = $in->getLInt(); - $this->hasLockedBehaviorPack = $in->getBool(); - $this->hasLockedResourcePack = $in->getBool(); - $this->isFromLockedWorldTemplate = $in->getBool(); - $this->useMsaGamertagsOnly = $in->getBool(); - $this->isFromWorldTemplate = $in->getBool(); - $this->isWorldTemplateOptionLocked = $in->getBool(); - $this->onlySpawnV1Villagers = $in->getBool(); - $this->vanillaVersion = $in->getString(); - $this->limitedWorldWidth = $in->getLInt(); - $this->limitedWorldLength = $in->getLInt(); - $this->isNewNether = $in->getBool(); - if($in->getBool()){ - $this->experimentalGameplayOverride = $in->getBool(); - }else{ - $this->experimentalGameplayOverride = null; - } - - $this->levelId = $in->getString(); - $this->worldName = $in->getString(); - $this->premiumWorldTemplateId = $in->getString(); - $this->isTrial = $in->getBool(); - $this->playerMovementSettings = PlayerMovementSettings::read($in); - $this->currentTick = $in->getLLong(); - - $this->enchantmentSeed = $in->getVarInt(); - - $this->blockPalette = []; - for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){ - $blockName = $in->getString(); - $state = $in->getNbtCompoundRoot(); - $this->blockPalette[] = new BlockPaletteEntry($blockName, $state); - } - - $this->itemTable = []; - for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){ - $stringId = $in->getString(); - $numericId = $in->getSignedLShort(); - $isComponentBased = $in->getBool(); - - $this->itemTable[] = new ItemTypeEntry($stringId, $numericId, $isComponentBased); - } - - $this->multiplayerCorrelationId = $in->getString(); - $this->enableNewInventorySystem = $in->getBool(); - $this->serverSoftwareVersion = $in->getString(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityUniqueId($this->entityUniqueId); - $out->putEntityRuntimeId($this->entityRuntimeId); - $out->putVarInt($this->playerGamemode); - - $out->putVector3($this->playerPosition); - - $out->putLFloat($this->pitch); - $out->putLFloat($this->yaw); - - //Level settings - $out->putVarInt($this->seed); - $this->spawnSettings->write($out); - $out->putVarInt($this->generator); - $out->putVarInt($this->worldGamemode); - $out->putVarInt($this->difficulty); - $out->putBlockPosition($this->spawnX, $this->spawnY, $this->spawnZ); - $out->putBool($this->hasAchievementsDisabled); - $out->putVarInt($this->time); - $out->putVarInt($this->eduEditionOffer); - $out->putBool($this->hasEduFeaturesEnabled); - $out->putString($this->eduProductUUID); - $out->putLFloat($this->rainLevel); - $out->putLFloat($this->lightningLevel); - $out->putBool($this->hasConfirmedPlatformLockedContent); - $out->putBool($this->isMultiplayerGame); - $out->putBool($this->hasLANBroadcast); - $out->putVarInt($this->xboxLiveBroadcastMode); - $out->putVarInt($this->platformBroadcastMode); - $out->putBool($this->commandsEnabled); - $out->putBool($this->isTexturePacksRequired); - $out->putGameRules($this->gameRules); - $this->experiments->write($out); - $out->putBool($this->hasBonusChestEnabled); - $out->putBool($this->hasStartWithMapEnabled); - $out->putVarInt($this->defaultPlayerPermission); - $out->putLInt($this->serverChunkTickRadius); - $out->putBool($this->hasLockedBehaviorPack); - $out->putBool($this->hasLockedResourcePack); - $out->putBool($this->isFromLockedWorldTemplate); - $out->putBool($this->useMsaGamertagsOnly); - $out->putBool($this->isFromWorldTemplate); - $out->putBool($this->isWorldTemplateOptionLocked); - $out->putBool($this->onlySpawnV1Villagers); - $out->putString($this->vanillaVersion); - $out->putLInt($this->limitedWorldWidth); - $out->putLInt($this->limitedWorldLength); - $out->putBool($this->isNewNether); - $out->putBool($this->experimentalGameplayOverride !== null); - if($this->experimentalGameplayOverride !== null){ - $out->putBool($this->experimentalGameplayOverride); - } - - $out->putString($this->levelId); - $out->putString($this->worldName); - $out->putString($this->premiumWorldTemplateId); - $out->putBool($this->isTrial); - $this->playerMovementSettings->write($out); - $out->putLLong($this->currentTick); - - $out->putVarInt($this->enchantmentSeed); - - $out->putUnsignedVarInt(count($this->blockPalette)); - $nbtWriter = new NetworkNbtSerializer(); - foreach($this->blockPalette as $entry){ - $out->putString($entry->getName()); - $out->put($nbtWriter->write(new TreeRoot($entry->getStates()))); - } - - $out->putUnsignedVarInt(count($this->itemTable)); - foreach($this->itemTable as $entry){ - $out->putString($entry->getStringId()); - $out->putLShort($entry->getNumericId()); - $out->putBool($entry->isComponentBased()); - } - - $out->putString($this->multiplayerCorrelationId); - $out->putBool($this->enableNewInventorySystem); - $out->putString($this->serverSoftwareVersion); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleStartGame($this); - } -} diff --git a/src/network/mcpe/protocol/StopSoundPacket.php b/src/network/mcpe/protocol/StopSoundPacket.php deleted file mode 100644 index 50f747500..000000000 --- a/src/network/mcpe/protocol/StopSoundPacket.php +++ /dev/null @@ -1,51 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class StopSoundPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::STOP_SOUND_PACKET; - - /** @var string */ - public $soundName; - /** @var bool */ - public $stopAll; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->soundName = $in->getString(); - $this->stopAll = $in->getBool(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->soundName); - $out->putBool($this->stopAll); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleStopSound($this); - } -} diff --git a/src/network/mcpe/protocol/StructureBlockUpdatePacket.php b/src/network/mcpe/protocol/StructureBlockUpdatePacket.php deleted file mode 100644 index 4ec92a45c..000000000 --- a/src/network/mcpe/protocol/StructureBlockUpdatePacket.php +++ /dev/null @@ -1,60 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\StructureEditorData; - -class StructureBlockUpdatePacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::STRUCTURE_BLOCK_UPDATE_PACKET; - - /** @var int */ - public $x; - /** @var int */ - public $y; - /** @var int */ - public $z; - /** @var StructureEditorData */ - public $structureEditorData; - /** @var bool */ - public $isPowered; - - protected function decodePayload(PacketSerializer $in) : void{ - $in->getBlockPosition($this->x, $this->y, $this->z); - $this->structureEditorData = $in->getStructureEditorData(); - $this->isPowered = $in->getBool(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putBlockPosition($this->x, $this->y, $this->z); - $out->putStructureEditorData($this->structureEditorData); - $out->putBool($this->isPowered); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleStructureBlockUpdate($this); - } -} diff --git a/src/network/mcpe/protocol/StructureTemplateDataRequestPacket.php b/src/network/mcpe/protocol/StructureTemplateDataRequestPacket.php deleted file mode 100644 index 376e300b3..000000000 --- a/src/network/mcpe/protocol/StructureTemplateDataRequestPacket.php +++ /dev/null @@ -1,67 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\StructureSettings; - -class StructureTemplateDataRequestPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::STRUCTURE_TEMPLATE_DATA_REQUEST_PACKET; - - public const TYPE_ALWAYS_LOAD = 1; - public const TYPE_CREATE_AND_LOAD = 2; - - /** @var string */ - public $structureTemplateName; - /** @var int */ - public $structureBlockX; - /** @var int */ - public $structureBlockY; - /** @var int */ - public $structureBlockZ; - /** @var StructureSettings */ - public $structureSettings; - /** @var int */ - public $structureTemplateResponseType; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->structureTemplateName = $in->getString(); - $in->getBlockPosition($this->structureBlockX, $this->structureBlockY, $this->structureBlockZ); - $this->structureSettings = $in->getStructureSettings(); - $this->structureTemplateResponseType = $in->getByte(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->structureTemplateName); - $out->putBlockPosition($this->structureBlockX, $this->structureBlockY, $this->structureBlockZ); - $out->putStructureSettings($this->structureSettings); - $out->putByte($this->structureTemplateResponseType); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleStructureTemplateDataRequest($this); - } -} diff --git a/src/network/mcpe/protocol/StructureTemplateDataResponsePacket.php b/src/network/mcpe/protocol/StructureTemplateDataResponsePacket.php deleted file mode 100644 index ad3e08051..000000000 --- a/src/network/mcpe/protocol/StructureTemplateDataResponsePacket.php +++ /dev/null @@ -1,60 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\CacheableNbt; - -class StructureTemplateDataResponsePacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::STRUCTURE_TEMPLATE_DATA_RESPONSE_PACKET; - - /** @var string */ - public $structureTemplateName; - /** - * @var CacheableNbt|null - * @phpstan-var CacheableNbt<\pocketmine\nbt\tag\CompoundTag> - */ - public $namedtag; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->structureTemplateName = $in->getString(); - if($in->getBool()){ - $this->namedtag = new CacheableNbt($in->getNbtCompoundRoot()); - } - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->structureTemplateName); - $out->putBool($this->namedtag !== null); - if($this->namedtag !== null){ - $out->put($this->namedtag->getEncodedNbt()); - } - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleStructureTemplateDataResponse($this); - } -} diff --git a/src/network/mcpe/protocol/SubClientLoginPacket.php b/src/network/mcpe/protocol/SubClientLoginPacket.php deleted file mode 100644 index f2685891b..000000000 --- a/src/network/mcpe/protocol/SubClientLoginPacket.php +++ /dev/null @@ -1,47 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class SubClientLoginPacket extends DataPacket implements ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::SUB_CLIENT_LOGIN_PACKET; - - /** @var string */ - public $connectionRequestData; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->connectionRequestData = $in->getString(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->connectionRequestData); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleSubClientLogin($this); - } -} diff --git a/src/network/mcpe/protocol/SyncActorPropertyPacket.php b/src/network/mcpe/protocol/SyncActorPropertyPacket.php deleted file mode 100644 index de547f4e9..000000000 --- a/src/network/mcpe/protocol/SyncActorPropertyPacket.php +++ /dev/null @@ -1,58 +0,0 @@ - - -use pocketmine\nbt\tag\CompoundTag; -use pocketmine\nbt\TreeRoot; -use pocketmine\network\mcpe\protocol\serializer\NetworkNbtSerializer; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class SyncActorPropertyPacket extends DataPacket{ - public const NETWORK_ID = ProtocolInfo::SYNC_ACTOR_PROPERTY_PACKET; - - /** @var CompoundTag */ - private $data; - - public static function create(CompoundTag $data) : self{ - $result = new self; - $result->data = $data; - return $result; - } - - public function getData() : CompoundTag{ return $this->data; } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->data = $in->getNbtCompoundRoot(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->put((new NetworkNbtSerializer())->write(new TreeRoot($this->data))); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleSyncActorProperty($this); - } -} diff --git a/src/network/mcpe/protocol/TakeItemActorPacket.php b/src/network/mcpe/protocol/TakeItemActorPacket.php deleted file mode 100644 index 74331a615..000000000 --- a/src/network/mcpe/protocol/TakeItemActorPacket.php +++ /dev/null @@ -1,58 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class TakeItemActorPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::TAKE_ITEM_ACTOR_PACKET; - - /** @var int */ - public $target; - /** @var int */ - public $eid; - - public static function create(int $takerEntityRuntimeId, int $itemEntityRuntimeId) : self{ - $result = new self; - $result->target = $itemEntityRuntimeId; - $result->eid = $takerEntityRuntimeId; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->target = $in->getEntityRuntimeId(); - $this->eid = $in->getEntityRuntimeId(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityRuntimeId($this->target); - $out->putEntityRuntimeId($this->eid); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleTakeItemActor($this); - } -} diff --git a/src/network/mcpe/protocol/TextPacket.php b/src/network/mcpe/protocol/TextPacket.php deleted file mode 100644 index 1928e40ca..000000000 --- a/src/network/mcpe/protocol/TextPacket.php +++ /dev/null @@ -1,186 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use function count; - -class TextPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::TEXT_PACKET; - - public const TYPE_RAW = 0; - public const TYPE_CHAT = 1; - public const TYPE_TRANSLATION = 2; - public const TYPE_POPUP = 3; - public const TYPE_JUKEBOX_POPUP = 4; - public const TYPE_TIP = 5; - public const TYPE_SYSTEM = 6; - public const TYPE_WHISPER = 7; - public const TYPE_ANNOUNCEMENT = 8; - public const TYPE_JSON_WHISPER = 9; - public const TYPE_JSON = 10; - - /** @var int */ - public $type; - /** @var bool */ - public $needsTranslation = false; - /** @var string */ - public $sourceName; - /** @var string */ - public $message; - /** @var string[] */ - public $parameters = []; - /** @var string */ - public $xboxUserId = ""; - /** @var string */ - public $platformChatId = ""; - - private static function messageOnly(int $type, string $message) : self{ - $result = new self; - $result->type = $type; - $result->message = $message; - return $result; - } - - /** - * @param string[] $parameters - */ - private static function baseTranslation(int $type, string $key, array $parameters) : self{ - $result = new self; - $result->type = $type; - $result->needsTranslation = true; - $result->message = $key; - $result->parameters = $parameters; - return $result; - } - - public static function raw(string $message) : self{ - return self::messageOnly(self::TYPE_RAW, $message); - } - - /** - * @param string[] $parameters - * - * @return TextPacket - */ - public static function translation(string $key, array $parameters = []) : self{ - return self::baseTranslation(self::TYPE_TRANSLATION, $key, $parameters); - } - - public static function popup(string $message) : self{ - return self::messageOnly(self::TYPE_POPUP, $message); - } - - /** - * @param string[] $parameters - * - * @return TextPacket - */ - public static function translatedPopup(string $key, array $parameters = []) : self{ - return self::baseTranslation(self::TYPE_POPUP, $key, $parameters); - } - - /** - * @param string[] $parameters - * - * @return TextPacket - */ - public static function jukeboxPopup(string $key, array $parameters = []) : self{ - return self::baseTranslation(self::TYPE_JUKEBOX_POPUP, $key, $parameters); - } - - public static function tip(string $message) : self{ - return self::messageOnly(self::TYPE_TIP, $message); - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->type = $in->getByte(); - $this->needsTranslation = $in->getBool(); - switch($this->type){ - case self::TYPE_CHAT: - case self::TYPE_WHISPER: - /** @noinspection PhpMissingBreakStatementInspection */ - case self::TYPE_ANNOUNCEMENT: - $this->sourceName = $in->getString(); - case self::TYPE_RAW: - case self::TYPE_TIP: - case self::TYPE_SYSTEM: - case self::TYPE_JSON_WHISPER: - case self::TYPE_JSON: - $this->message = $in->getString(); - break; - - case self::TYPE_TRANSLATION: - case self::TYPE_POPUP: - case self::TYPE_JUKEBOX_POPUP: - $this->message = $in->getString(); - $count = $in->getUnsignedVarInt(); - for($i = 0; $i < $count; ++$i){ - $this->parameters[] = $in->getString(); - } - break; - } - - $this->xboxUserId = $in->getString(); - $this->platformChatId = $in->getString(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putByte($this->type); - $out->putBool($this->needsTranslation); - switch($this->type){ - case self::TYPE_CHAT: - case self::TYPE_WHISPER: - /** @noinspection PhpMissingBreakStatementInspection */ - case self::TYPE_ANNOUNCEMENT: - $out->putString($this->sourceName); - case self::TYPE_RAW: - case self::TYPE_TIP: - case self::TYPE_SYSTEM: - case self::TYPE_JSON_WHISPER: - case self::TYPE_JSON: - $out->putString($this->message); - break; - - case self::TYPE_TRANSLATION: - case self::TYPE_POPUP: - case self::TYPE_JUKEBOX_POPUP: - $out->putString($this->message); - $out->putUnsignedVarInt(count($this->parameters)); - foreach($this->parameters as $p){ - $out->putString($p); - } - break; - } - - $out->putString($this->xboxUserId); - $out->putString($this->platformChatId); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleText($this); - } -} diff --git a/src/network/mcpe/protocol/TickSyncPacket.php b/src/network/mcpe/protocol/TickSyncPacket.php deleted file mode 100644 index 134ca40af..000000000 --- a/src/network/mcpe/protocol/TickSyncPacket.php +++ /dev/null @@ -1,73 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class TickSyncPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ - public const NETWORK_ID = ProtocolInfo::TICK_SYNC_PACKET; - - /** @var int */ - private $clientSendTime; - /** @var int */ - private $serverReceiveTime; - - public static function request(int $clientTime) : self{ - $result = new self; - $result->clientSendTime = $clientTime; - $result->serverReceiveTime = 0; //useless - return $result; - } - - public static function response(int $clientSendTime, int $serverReceiveTime) : self{ - $result = new self; - $result->clientSendTime = $clientSendTime; - $result->serverReceiveTime = $serverReceiveTime; - return $result; - } - - public function getClientSendTime() : int{ - return $this->clientSendTime; - } - - public function getServerReceiveTime() : int{ - return $this->serverReceiveTime; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->clientSendTime = $in->getLLong(); - $this->serverReceiveTime = $in->getLLong(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putLLong($this->clientSendTime); - $out->putLLong($this->serverReceiveTime); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleTickSync($this); - } -} diff --git a/src/network/mcpe/protocol/TransferPacket.php b/src/network/mcpe/protocol/TransferPacket.php deleted file mode 100644 index 8b25ef64e..000000000 --- a/src/network/mcpe/protocol/TransferPacket.php +++ /dev/null @@ -1,58 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class TransferPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::TRANSFER_PACKET; - - /** @var string */ - public $address; - /** @var int */ - public $port = 19132; - - public static function create(string $address, int $port) : self{ - $result = new self; - $result->address = $address; - $result->port = $port; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->address = $in->getString(); - $this->port = $in->getLShort(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->address); - $out->putLShort($this->port); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleTransfer($this); - } -} diff --git a/src/network/mcpe/protocol/UnknownPacket.php b/src/network/mcpe/protocol/UnknownPacket.php deleted file mode 100644 index feecedea2..000000000 --- a/src/network/mcpe/protocol/UnknownPacket.php +++ /dev/null @@ -1,66 +0,0 @@ -payload ?? "") > 0){ - return ord($this->payload[0]); - } - return self::NETWORK_ID; - } - - public function getName() : string{ - return "unknown packet"; - } - - protected function decodeHeader(PacketSerializer $in) : void{ - - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->payload = $in->getRemaining(); - } - - protected function encodeHeader(PacketSerializer $out) : void{ - - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->put($this->payload); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return false; - } -} diff --git a/src/network/mcpe/protocol/UpdateAttributesPacket.php b/src/network/mcpe/protocol/UpdateAttributesPacket.php deleted file mode 100644 index 2867f772a..000000000 --- a/src/network/mcpe/protocol/UpdateAttributesPacket.php +++ /dev/null @@ -1,70 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\entity\Attribute; -use function array_values; - -class UpdateAttributesPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::UPDATE_ATTRIBUTES_PACKET; - - /** @var int */ - public $entityRuntimeId; - /** @var Attribute[] */ - public $entries = []; - /** @var int */ - public $tick = 0; - - /** - * @param Attribute[] $attributes - * - * @return UpdateAttributesPacket - */ - public static function create(int $entityRuntimeId, array $attributes, int $tick) : self{ - $result = new self; - $result->entityRuntimeId = $entityRuntimeId; - $result->entries = $attributes; - $result->tick = $tick; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->entityRuntimeId = $in->getEntityRuntimeId(); - $this->entries = $in->getAttributeList(); - $this->tick = $in->getUnsignedVarLong(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putEntityRuntimeId($this->entityRuntimeId); - $out->putAttributeList(...array_values($this->entries)); - $out->putUnsignedVarLong($this->tick); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleUpdateAttributes($this); - } -} diff --git a/src/network/mcpe/protocol/UpdateBlockPacket.php b/src/network/mcpe/protocol/UpdateBlockPacket.php deleted file mode 100644 index a4ea6faff..000000000 --- a/src/network/mcpe/protocol/UpdateBlockPacket.php +++ /dev/null @@ -1,78 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class UpdateBlockPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::UPDATE_BLOCK_PACKET; - - public const DATA_LAYER_NORMAL = 0; - public const DATA_LAYER_LIQUID = 1; - - /** @var int */ - public $x; - /** @var int */ - public $z; - /** @var int */ - public $y; - /** @var int */ - public $blockRuntimeId; - /** - * @var int - * Flags are used by MCPE internally for block setting, but only flag 2 (network flag) is relevant for network. - * This field is pointless really. - */ - public $flags = 0x02; - /** @var int */ - public $dataLayerId = self::DATA_LAYER_NORMAL; - - public static function create(int $x, int $y, int $z, int $blockRuntimeId, int $dataLayerId = self::DATA_LAYER_NORMAL) : self{ - $result = new self; - [$result->x, $result->y, $result->z] = [$x, $y, $z]; - $result->blockRuntimeId = $blockRuntimeId; - $result->dataLayerId = $dataLayerId; - return $result; - } - - protected function decodePayload(PacketSerializer $in) : void{ - $in->getBlockPosition($this->x, $this->y, $this->z); - $this->blockRuntimeId = $in->getUnsignedVarInt(); - $this->flags = $in->getUnsignedVarInt(); - $this->dataLayerId = $in->getUnsignedVarInt(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putBlockPosition($this->x, $this->y, $this->z); - $out->putUnsignedVarInt($this->blockRuntimeId); - $out->putUnsignedVarInt($this->flags); - $out->putUnsignedVarInt($this->dataLayerId); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleUpdateBlock($this); - } -} diff --git a/src/network/mcpe/protocol/UpdateBlockSyncedPacket.php b/src/network/mcpe/protocol/UpdateBlockSyncedPacket.php deleted file mode 100644 index 373365b91..000000000 --- a/src/network/mcpe/protocol/UpdateBlockSyncedPacket.php +++ /dev/null @@ -1,57 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -class UpdateBlockSyncedPacket extends UpdateBlockPacket{ - public const NETWORK_ID = ProtocolInfo::UPDATE_BLOCK_SYNCED_PACKET; - - public const TYPE_NONE = 0; - public const TYPE_CREATE = 1; - public const TYPE_DESTROY = 2; - - /** @var int */ - public $entityUniqueId; - /** @var int */ - public $updateType; - - protected function decodePayload(PacketSerializer $in) : void{ - parent::decodePayload($in); - $this->entityUniqueId = $in->getUnsignedVarLong(); - $this->updateType = $in->getUnsignedVarLong(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - parent::encodePayload($out); - $out->putUnsignedVarLong($this->entityUniqueId); - $out->putUnsignedVarLong($this->updateType); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleUpdateBlockSynced($this); - } -} diff --git a/src/network/mcpe/protocol/UpdateEquipPacket.php b/src/network/mcpe/protocol/UpdateEquipPacket.php deleted file mode 100644 index 45051919c..000000000 --- a/src/network/mcpe/protocol/UpdateEquipPacket.php +++ /dev/null @@ -1,67 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\CacheableNbt; - -class UpdateEquipPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::UPDATE_EQUIP_PACKET; - - /** @var int */ - public $windowId; - /** @var int */ - public $windowType; - /** @var int */ - public $windowSlotCount; //useless, seems to be part of a standard container header - /** @var int */ - public $entityUniqueId; - /** - * @var CacheableNbt - * @phpstan-var CacheableNbt<\pocketmine\nbt\tag\CompoundTag> - */ - public $namedtag; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->windowId = $in->getByte(); - $this->windowType = $in->getByte(); - $this->windowSlotCount = $in->getVarInt(); - $this->entityUniqueId = $in->getEntityUniqueId(); - $this->namedtag = new CacheableNbt($in->getNbtCompoundRoot()); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putByte($this->windowId); - $out->putByte($this->windowType); - $out->putVarInt($this->windowSlotCount); - $out->putEntityUniqueId($this->entityUniqueId); - $out->put($this->namedtag->getEncodedNbt()); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleUpdateEquip($this); - } -} diff --git a/src/network/mcpe/protocol/UpdatePlayerGameTypePacket.php b/src/network/mcpe/protocol/UpdatePlayerGameTypePacket.php deleted file mode 100644 index a190de79f..000000000 --- a/src/network/mcpe/protocol/UpdatePlayerGameTypePacket.php +++ /dev/null @@ -1,67 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\GameMode; - -class UpdatePlayerGameTypePacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::UPDATE_PLAYER_GAME_TYPE_PACKET; - - /** - * @var int - * @see GameMode - */ - private $gameMode; - - /** @var int */ - private $playerEntityUniqueId; - - public static function create(int $gameMode, int $playerEntityUniqueId) : self{ - $result = new self; - $result->gameMode = $gameMode; - $result->playerEntityUniqueId = $playerEntityUniqueId; - return $result; - } - - public function getGameMode() : int{ return $this->gameMode; } - - public function getPlayerEntityUniqueId() : int{ return $this->playerEntityUniqueId; } - - protected function decodePayload(PacketSerializer $in) : void{ - $this->gameMode = $in->getVarInt(); - $this->playerEntityUniqueId = $in->getEntityUniqueId(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putVarInt($this->gameMode); - $out->putEntityUniqueId($this->playerEntityUniqueId); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleUpdatePlayerGameType($this); - } -} diff --git a/src/network/mcpe/protocol/UpdateSoftEnumPacket.php b/src/network/mcpe/protocol/UpdateSoftEnumPacket.php deleted file mode 100644 index 7ec0e4d74..000000000 --- a/src/network/mcpe/protocol/UpdateSoftEnumPacket.php +++ /dev/null @@ -1,65 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use function count; - -class UpdateSoftEnumPacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::UPDATE_SOFT_ENUM_PACKET; - - public const TYPE_ADD = 0; - public const TYPE_REMOVE = 1; - public const TYPE_SET = 2; - - /** @var string */ - public $enumName; - /** @var string[] */ - public $values = []; - /** @var int */ - public $type; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->enumName = $in->getString(); - for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){ - $this->values[] = $in->getString(); - } - $this->type = $in->getByte(); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putString($this->enumName); - $out->putUnsignedVarInt(count($this->values)); - foreach($this->values as $v){ - $out->putString($v); - } - $out->putByte($this->type); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleUpdateSoftEnum($this); - } -} diff --git a/src/network/mcpe/protocol/UpdateTradePacket.php b/src/network/mcpe/protocol/UpdateTradePacket.php deleted file mode 100644 index ef70485b0..000000000 --- a/src/network/mcpe/protocol/UpdateTradePacket.php +++ /dev/null @@ -1,90 +0,0 @@ - - -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\CacheableNbt; -use pocketmine\network\mcpe\protocol\types\inventory\WindowTypes; - -class UpdateTradePacket extends DataPacket implements ClientboundPacket{ - public const NETWORK_ID = ProtocolInfo::UPDATE_TRADE_PACKET; - - //TODO: find fields - - /** @var int */ - public $windowId; - /** @var int */ - public $windowType = WindowTypes::TRADING; //Mojang hardcoded this -_- - /** @var int */ - public $windowSlotCount = 0; //useless, seems to be part of a standard container header - /** @var int */ - public $tradeTier; - /** @var int */ - public $traderEid; - /** @var int */ - public $playerEid; - /** @var string */ - public $displayName; - /** @var bool */ - public $isV2Trading; - /** @var bool */ - public $isWilling; - /** - * @var CacheableNbt - * @phpstan-var CacheableNbt<\pocketmine\nbt\tag\CompoundTag> - */ - public $offers; - - protected function decodePayload(PacketSerializer $in) : void{ - $this->windowId = $in->getByte(); - $this->windowType = $in->getByte(); - $this->windowSlotCount = $in->getVarInt(); - $this->tradeTier = $in->getVarInt(); - $this->traderEid = $in->getEntityUniqueId(); - $this->playerEid = $in->getEntityUniqueId(); - $this->displayName = $in->getString(); - $this->isV2Trading = $in->getBool(); - $this->isWilling = $in->getBool(); - $this->offers = new CacheableNbt($in->getNbtCompoundRoot()); - } - - protected function encodePayload(PacketSerializer $out) : void{ - $out->putByte($this->windowId); - $out->putByte($this->windowType); - $out->putVarInt($this->windowSlotCount); - $out->putVarInt($this->tradeTier); - $out->putEntityUniqueId($this->traderEid); - $out->putEntityUniqueId($this->playerEid); - $out->putString($this->displayName); - $out->putBool($this->isV2Trading); - $out->putBool($this->isWilling); - $out->put($this->offers->getEncodedNbt()); - } - - public function handle(PacketHandlerInterface $handler) : bool{ - return $handler->handleUpdateTrade($this); - } -} diff --git a/src/network/mcpe/protocol/serializer/ItemTypeDictionary.php b/src/network/mcpe/protocol/serializer/ItemTypeDictionary.php deleted file mode 100644 index bdb166589..000000000 --- a/src/network/mcpe/protocol/serializer/ItemTypeDictionary.php +++ /dev/null @@ -1,79 +0,0 @@ - - */ - private array $itemTypes; - /** - * @var string[] - * @phpstan-var array - */ - private array $intToStringIdMap = []; - /** - * @var int[] - * @phpstan-var array - */ - private array $stringToIntMap = []; - - /** - * @param ItemTypeEntry[] $itemTypes - */ - public function __construct(array $itemTypes){ - $this->itemTypes = $itemTypes; - foreach($this->itemTypes as $type){ - $this->stringToIntMap[$type->getStringId()] = $type->getNumericId(); - $this->intToStringIdMap[$type->getNumericId()] = $type->getStringId(); - } - } - - /** - * @return ItemTypeEntry[] - * @phpstan-return list - */ - public function getEntries() : array{ - return $this->itemTypes; - } - - public function fromStringId(string $stringId) : int{ - if(!array_key_exists($stringId, $this->stringToIntMap)){ - throw new \InvalidArgumentException("Unmapped string ID \"$stringId\""); - } - return $this->stringToIntMap[$stringId]; - } - - public function fromIntId(int $intId) : string{ - if(!array_key_exists($intId, $this->intToStringIdMap)){ - throw new \InvalidArgumentException("Unmapped int ID $intId"); - } - return $this->intToStringIdMap[$intId]; - } -} diff --git a/src/network/mcpe/protocol/serializer/NetworkNbtSerializer.php b/src/network/mcpe/protocol/serializer/NetworkNbtSerializer.php deleted file mode 100644 index e3949444f..000000000 --- a/src/network/mcpe/protocol/serializer/NetworkNbtSerializer.php +++ /dev/null @@ -1,101 +0,0 @@ -buffer->getLShort(); - } - - public function readSignedShort() : int{ - return $this->buffer->getSignedLShort(); - } - - public function writeShort(int $v) : void{ - $this->buffer->putLShort($v); - } - - public function readInt() : int{ - return $this->buffer->getVarInt(); - } - - public function writeInt(int $v) : void{ - $this->buffer->putVarInt($v); - } - - public function readLong() : int{ - return $this->buffer->getVarLong(); - } - - public function writeLong(int $v) : void{ - $this->buffer->putVarLong($v); - } - - public function readString() : string{ - return $this->buffer->get(self::checkReadStringLength($this->buffer->getUnsignedVarInt())); - } - - public function writeString(string $v) : void{ - $this->buffer->putUnsignedVarInt(self::checkWriteStringLength(strlen($v))); - $this->buffer->put($v); - } - - public function readFloat() : float{ - return $this->buffer->getLFloat(); - } - - public function writeFloat(float $v) : void{ - $this->buffer->putLFloat($v); - } - - public function readDouble() : float{ - return $this->buffer->getLDouble(); - } - - public function writeDouble(float $v) : void{ - $this->buffer->putLDouble($v); - } - - public function readIntArray() : array{ - $len = $this->readInt(); //varint - $ret = []; - for($i = 0; $i < $len; ++$i){ - $ret[] = $this->readInt(); //varint - } - - return $ret; - } - - public function writeIntArray(array $array) : void{ - $this->writeInt(count($array)); //varint - foreach($array as $v){ - $this->writeInt($v); //varint - } - } -} diff --git a/src/network/mcpe/protocol/serializer/PacketBatch.php b/src/network/mcpe/protocol/serializer/PacketBatch.php deleted file mode 100644 index a1af98c35..000000000 --- a/src/network/mcpe/protocol/serializer/PacketBatch.php +++ /dev/null @@ -1,80 +0,0 @@ -buffer = $buffer; - } - - /** - * @return \Generator|Packet[] - * @phpstan-return \Generator - * @throws PacketDecodeException - */ - public function getPackets(PacketPool $packetPool, PacketSerializerContext $decoderContext, int $max) : \Generator{ - $serializer = PacketSerializer::decoder($this->buffer, 0, $decoderContext); - for($c = 0; $c < $max and !$serializer->feof(); ++$c){ - try{ - $buffer = $serializer->getString(); - yield $c => [$packetPool->getPacket($buffer), $buffer]; - }catch(BinaryDataException $e){ - throw new PacketDecodeException("Error decoding packet $c of batch: " . $e->getMessage(), 0, $e); - } - } - if(!$serializer->feof()){ - throw new PacketDecodeException("Reached limit of $max packets in a single batch"); - } - } - - /** - * Constructs a packet batch from the given list of packets. - * - * @param Packet ...$packets - * - * @return PacketBatch - */ - public static function fromPackets(PacketSerializerContext $context, Packet ...$packets) : self{ - $serializer = PacketSerializer::encoder($context); - foreach($packets as $packet){ - $subSerializer = PacketSerializer::encoder($context); - $packet->encode($subSerializer); - $serializer->putString($subSerializer->getBuffer()); - } - return new self($serializer->getBuffer()); - } - - public function getBuffer() : string{ - return $this->buffer; - } -} diff --git a/src/network/mcpe/protocol/serializer/PacketSerializer.php b/src/network/mcpe/protocol/serializer/PacketSerializer.php deleted file mode 100644 index 9df467f1c..000000000 --- a/src/network/mcpe/protocol/serializer/PacketSerializer.php +++ /dev/null @@ -1,795 +0,0 @@ - - -use pocketmine\math\Vector3; -use pocketmine\nbt\LittleEndianNbtSerializer; -use pocketmine\nbt\NbtDataException; -use pocketmine\nbt\tag\CompoundTag; -use pocketmine\nbt\TreeRoot; -use pocketmine\network\mcpe\protocol\PacketDecodeException; -use pocketmine\network\mcpe\protocol\types\BoolGameRule; -use pocketmine\network\mcpe\protocol\types\command\CommandOriginData; -use pocketmine\network\mcpe\protocol\types\entity\Attribute; -use pocketmine\network\mcpe\protocol\types\entity\BlockPosMetadataProperty; -use pocketmine\network\mcpe\protocol\types\entity\ByteMetadataProperty; -use pocketmine\network\mcpe\protocol\types\entity\CompoundTagMetadataProperty; -use pocketmine\network\mcpe\protocol\types\entity\EntityLink; -use pocketmine\network\mcpe\protocol\types\entity\FloatMetadataProperty; -use pocketmine\network\mcpe\protocol\types\entity\IntMetadataProperty; -use pocketmine\network\mcpe\protocol\types\entity\LongMetadataProperty; -use pocketmine\network\mcpe\protocol\types\entity\MetadataProperty; -use pocketmine\network\mcpe\protocol\types\entity\ShortMetadataProperty; -use pocketmine\network\mcpe\protocol\types\entity\StringMetadataProperty; -use pocketmine\network\mcpe\protocol\types\entity\Vec3MetadataProperty; -use pocketmine\network\mcpe\protocol\types\FloatGameRule; -use pocketmine\network\mcpe\protocol\types\GameRule; -use pocketmine\network\mcpe\protocol\types\GameRuleType; -use pocketmine\network\mcpe\protocol\types\IntGameRule; -use pocketmine\network\mcpe\protocol\types\inventory\ItemStack; -use pocketmine\network\mcpe\protocol\types\recipe\RecipeIngredient; -use pocketmine\network\mcpe\protocol\types\skin\PersonaPieceTintColor; -use pocketmine\network\mcpe\protocol\types\skin\PersonaSkinPiece; -use pocketmine\network\mcpe\protocol\types\skin\SkinAnimation; -use pocketmine\network\mcpe\protocol\types\skin\SkinData; -use pocketmine\network\mcpe\protocol\types\skin\SkinImage; -use pocketmine\network\mcpe\protocol\types\StructureEditorData; -use pocketmine\network\mcpe\protocol\types\StructureSettings; -use pocketmine\utils\BinaryDataException; -use pocketmine\utils\BinaryStream; -use Ramsey\Uuid\Uuid; -use Ramsey\Uuid\UuidInterface; -use function count; -use function strlen; -use function strrev; -use function substr; - -class PacketSerializer extends BinaryStream{ - - private int $shieldItemRuntimeId; - private PacketSerializerContext $context; - - protected function __construct(PacketSerializerContext $context, string $buffer = "", int $offset = 0){ - parent::__construct($buffer, $offset); - $this->context = $context; - $this->shieldItemRuntimeId = $context->getItemDictionary()->fromStringId("minecraft:shield"); - } - - public static function encoder(PacketSerializerContext $context) : self{ - return new self($context); - } - - public static function decoder(string $buffer, int $offset, PacketSerializerContext $context) : self{ - return new self($context, $buffer, $offset); - } - - /** - * @throws BinaryDataException - */ - public function getString() : string{ - return $this->get($this->getUnsignedVarInt()); - } - - public function putString(string $v) : void{ - $this->putUnsignedVarInt(strlen($v)); - $this->put($v); - } - - /** - * @throws BinaryDataException - */ - public function getUUID() : UuidInterface{ - //This is two little-endian longs: bytes 7-0 followed by bytes 15-8 - $p1 = strrev($this->get(8)); - $p2 = strrev($this->get(8)); - return Uuid::fromBytes($p1 . $p2); - } - - public function putUUID(UuidInterface $uuid) : void{ - $bytes = $uuid->getBytes(); - $this->put(strrev(substr($bytes, 0, 8))); - $this->put(strrev(substr($bytes, 8, 8))); - } - - public function getSkin() : SkinData{ - $skinId = $this->getString(); - $skinPlayFabId = $this->getString(); - $skinResourcePatch = $this->getString(); - $skinData = $this->getSkinImage(); - $animationCount = $this->getLInt(); - $animations = []; - for($i = 0; $i < $animationCount; ++$i){ - $skinImage = $this->getSkinImage(); - $animationType = $this->getLInt(); - $animationFrames = $this->getLFloat(); - $expressionType = $this->getLInt(); - $animations[] = new SkinAnimation($skinImage, $animationType, $animationFrames, $expressionType); - } - $capeData = $this->getSkinImage(); - $geometryData = $this->getString(); - $animationData = $this->getString(); - $premium = $this->getBool(); - $persona = $this->getBool(); - $capeOnClassic = $this->getBool(); - $capeId = $this->getString(); - $fullSkinId = $this->getString(); - $armSize = $this->getString(); - $skinColor = $this->getString(); - $personaPieceCount = $this->getLInt(); - $personaPieces = []; - for($i = 0; $i < $personaPieceCount; ++$i){ - $pieceId = $this->getString(); - $pieceType = $this->getString(); - $packId = $this->getString(); - $isDefaultPiece = $this->getBool(); - $productId = $this->getString(); - $personaPieces[] = new PersonaSkinPiece($pieceId, $pieceType, $packId, $isDefaultPiece, $productId); - } - $pieceTintColorCount = $this->getLInt(); - $pieceTintColors = []; - for($i = 0; $i < $pieceTintColorCount; ++$i){ - $pieceType = $this->getString(); - $colorCount = $this->getLInt(); - $colors = []; - for($j = 0; $j < $colorCount; ++$j){ - $colors[] = $this->getString(); - } - $pieceTintColors[] = new PersonaPieceTintColor( - $pieceType, - $colors - ); - } - - return new SkinData($skinId, $skinPlayFabId, $skinResourcePatch, $skinData, $animations, $capeData, $geometryData, $animationData, $premium, $persona, $capeOnClassic, $capeId, $fullSkinId, $armSize, $skinColor, $personaPieces, $pieceTintColors); - } - - public function putSkin(SkinData $skin) : void{ - $this->putString($skin->getSkinId()); - $this->putString($skin->getPlayFabId()); - $this->putString($skin->getResourcePatch()); - $this->putSkinImage($skin->getSkinImage()); - $this->putLInt(count($skin->getAnimations())); - foreach($skin->getAnimations() as $animation){ - $this->putSkinImage($animation->getImage()); - $this->putLInt($animation->getType()); - $this->putLFloat($animation->getFrames()); - $this->putLInt($animation->getExpressionType()); - } - $this->putSkinImage($skin->getCapeImage()); - $this->putString($skin->getGeometryData()); - $this->putString($skin->getAnimationData()); - $this->putBool($skin->isPremium()); - $this->putBool($skin->isPersona()); - $this->putBool($skin->isPersonaCapeOnClassic()); - $this->putString($skin->getCapeId()); - $this->putString($skin->getFullSkinId()); - $this->putString($skin->getArmSize()); - $this->putString($skin->getSkinColor()); - $this->putLInt(count($skin->getPersonaPieces())); - foreach($skin->getPersonaPieces() as $piece){ - $this->putString($piece->getPieceId()); - $this->putString($piece->getPieceType()); - $this->putString($piece->getPackId()); - $this->putBool($piece->isDefaultPiece()); - $this->putString($piece->getProductId()); - } - $this->putLInt(count($skin->getPieceTintColors())); - foreach($skin->getPieceTintColors() as $tint){ - $this->putString($tint->getPieceType()); - $this->putLInt(count($tint->getColors())); - foreach($tint->getColors() as $color){ - $this->putString($color); - } - } - } - - private function getSkinImage() : SkinImage{ - $width = $this->getLInt(); - $height = $this->getLInt(); - $data = $this->getString(); - try{ - return new SkinImage($height, $width, $data); - }catch(\InvalidArgumentException $e){ - throw new PacketDecodeException($e->getMessage(), 0, $e); - } - } - - private function putSkinImage(SkinImage $image) : void{ - $this->putLInt($image->getWidth()); - $this->putLInt($image->getHeight()); - $this->putString($image->getData()); - } - - /** - * @throws PacketDecodeException - * @throws BinaryDataException - */ - public function getItemStackWithoutStackId() : ItemStack{ - return $this->getItemStack(function() : void{ - //NOOP - }); - } - - public function putItemStackWithoutStackId(ItemStack $item) : void{ - $this->putItemStack($item, function() : void{ - //NOOP - }); - } - - /** - * @phpstan-param \Closure(PacketSerializer) : void $readExtraCrapInTheMiddle - * - * @throws PacketDecodeException - * @throws BinaryDataException - */ - public function getItemStack(\Closure $readExtraCrapInTheMiddle) : ItemStack{ - $id = $this->getVarInt(); - if($id === 0){ - return ItemStack::null(); - } - - $count = $this->getLShort(); - $meta = $this->getUnsignedVarInt(); - - $readExtraCrapInTheMiddle($this); - - $blockRuntimeId = $this->getVarInt(); - $extraData = self::decoder($this->getString(), 0, $this->context); - return (static function() use ($extraData, $id, $meta, $count, $blockRuntimeId) : ItemStack{ - $nbtLen = $extraData->getLShort(); - - /** @var CompoundTag|null $compound */ - $compound = null; - if($nbtLen === 0xffff){ - $nbtDataVersion = $extraData->getByte(); - if($nbtDataVersion !== 1){ - throw new PacketDecodeException("Unexpected NBT data version $nbtDataVersion"); - } - $offset = $extraData->getOffset(); - try{ - $compound = (new LittleEndianNbtSerializer())->read($extraData->getBuffer(), $offset, 512)->mustGetCompoundTag(); - }catch(NbtDataException $e){ - throw PacketDecodeException::wrap($e, "Failed decoding NBT root"); - }finally{ - $extraData->setOffset($offset); - } - }elseif($nbtLen !== 0){ - throw new PacketDecodeException("Unexpected fake NBT length $nbtLen"); - } - - $canPlaceOn = []; - for($i = 0, $canPlaceOnCount = $extraData->getLInt(); $i < $canPlaceOnCount; ++$i){ - $canPlaceOn[] = $extraData->get($extraData->getLShort()); - } - - $canDestroy = []; - for($i = 0, $canDestroyCount = $extraData->getLInt(); $i < $canDestroyCount; ++$i){ - $canDestroy[] = $extraData->get($extraData->getLShort()); - } - - $shieldBlockingTick = null; - if($id === $extraData->shieldItemRuntimeId){ - $shieldBlockingTick = $extraData->getLLong(); - } - - if(!$extraData->feof()){ - throw new PacketDecodeException("Unexpected trailing extradata for network item $id"); - } - - return new ItemStack($id, $meta, $count, $blockRuntimeId, $compound, $canPlaceOn, $canDestroy, $shieldBlockingTick); - })(); - } - - /** - * @phpstan-param \Closure(PacketSerializer) : void $writeExtraCrapInTheMiddle - */ - public function putItemStack(ItemStack $item, \Closure $writeExtraCrapInTheMiddle) : void{ - if($item->getId() === 0){ - $this->putVarInt(0); - - return; - } - - $this->putVarInt($item->getId()); - $this->putLShort($item->getCount()); - $this->putUnsignedVarInt($item->getMeta()); - - $writeExtraCrapInTheMiddle($this); - - $this->putVarInt($item->getBlockRuntimeId()); - $context = $this->context; - $this->putString((static function() use ($item, $context) : string{ - $extraData = PacketSerializer::encoder($context); - - $nbt = $item->getNbt(); - if($nbt !== null){ - $extraData->putLShort(0xffff); - $extraData->putByte(1); //TODO: NBT data version (?) - $extraData->put((new LittleEndianNbtSerializer())->write(new TreeRoot($nbt))); - }else{ - $extraData->putLShort(0); - } - - $extraData->putLInt(count($item->getCanPlaceOn())); - foreach($item->getCanPlaceOn() as $entry){ - $extraData->putLShort(strlen($entry)); - $extraData->put($entry); - } - $extraData->putLInt(count($item->getCanDestroy())); - foreach($item->getCanDestroy() as $entry){ - $extraData->putLShort(strlen($entry)); - $extraData->put($entry); - } - - $blockingTick = $item->getShieldBlockingTick(); - if($item->getId() === $extraData->shieldItemRuntimeId){ - $extraData->putLLong($blockingTick ?? 0); - } - return $extraData->getBuffer(); - })()); - } - - public function getRecipeIngredient() : RecipeIngredient{ - $id = $this->getVarInt(); - if($id === 0){ - return new RecipeIngredient(0, 0, 0); - } - $meta = $this->getVarInt(); - $count = $this->getVarInt(); - - return new RecipeIngredient($id, $meta, $count); - } - - public function putRecipeIngredient(RecipeIngredient $ingredient) : void{ - if($ingredient->getId() === 0){ - $this->putVarInt(0); - }else{ - $this->putVarInt($ingredient->getId()); - $this->putVarInt($ingredient->getMeta()); - $this->putVarInt($ingredient->getCount()); - } - } - - /** - * Decodes entity metadata from the stream. - * - * @return MetadataProperty[] - * @phpstan-return array - * - * @throws PacketDecodeException - * @throws BinaryDataException - */ - public function getEntityMetadata() : array{ - $count = $this->getUnsignedVarInt(); - $data = []; - for($i = 0; $i < $count; ++$i){ - $key = $this->getUnsignedVarInt(); - $type = $this->getUnsignedVarInt(); - - $data[$key] = $this->readMetadataProperty($type); - } - - return $data; - } - - private function readMetadataProperty(int $type) : MetadataProperty{ - switch($type){ - case ByteMetadataProperty::id(): - return ByteMetadataProperty::read($this); - case ShortMetadataProperty::id(): - return ShortMetadataProperty::read($this); - case IntMetadataProperty::id(): - return IntMetadataProperty::read($this); - case FloatMetadataProperty::id(): - return FloatMetadataProperty::read($this); - case StringMetadataProperty::id(): - return StringMetadataProperty::read($this); - case CompoundTagMetadataProperty::id(): - return CompoundTagMetadataProperty::read($this); - case BlockPosMetadataProperty::id(): - return BlockPosMetadataProperty::read($this); - case LongMetadataProperty::id(): - return LongMetadataProperty::read($this); - case Vec3MetadataProperty::id(): - return Vec3MetadataProperty::read($this); - default: - throw new PacketDecodeException("Unknown entity metadata type " . $type); - } - } - - /** - * Writes entity metadata to the packet buffer. - * - * @param MetadataProperty[] $metadata - * - * @phpstan-param array $metadata - */ - public function putEntityMetadata(array $metadata) : void{ - $this->putUnsignedVarInt(count($metadata)); - foreach($metadata as $key => $d){ - $this->putUnsignedVarInt($key); - $this->putUnsignedVarInt($d::id()); - $d->write($this); - } - } - - /** - * Reads a list of Attributes from the stream. - * @return Attribute[] - * - * @throws BinaryDataException - */ - public function getAttributeList() : array{ - $list = []; - $count = $this->getUnsignedVarInt(); - - for($i = 0; $i < $count; ++$i){ - $min = $this->getLFloat(); - $max = $this->getLFloat(); - $current = $this->getLFloat(); - $default = $this->getLFloat(); - $id = $this->getString(); - - $list[] = new Attribute($id, $min, $max, $current, $default); - } - - return $list; - } - - /** - * Writes a list of Attributes to the packet buffer using the standard format. - * - * @param Attribute ...$attributes - */ - public function putAttributeList(Attribute ...$attributes) : void{ - $this->putUnsignedVarInt(count($attributes)); - foreach($attributes as $attribute){ - $this->putLFloat($attribute->getMin()); - $this->putLFloat($attribute->getMax()); - $this->putLFloat($attribute->getCurrent()); - $this->putLFloat($attribute->getDefault()); - $this->putString($attribute->getId()); - } - } - - /** - * Reads and returns an EntityUniqueID - * - * @throws BinaryDataException - */ - final public function getEntityUniqueId() : int{ - return $this->getVarLong(); - } - - /** - * Writes an EntityUniqueID - */ - public function putEntityUniqueId(int $eid) : void{ - $this->putVarLong($eid); - } - - /** - * Reads and returns an EntityRuntimeID - * - * @throws BinaryDataException - */ - final public function getEntityRuntimeId() : int{ - return $this->getUnsignedVarLong(); - } - - /** - * Writes an EntityRuntimeID - */ - public function putEntityRuntimeId(int $eid) : void{ - $this->putUnsignedVarLong($eid); - } - - /** - * Reads an block position with unsigned Y coordinate. - * - * @param int $x reference parameter - * @param int $y reference parameter - * @param int $z reference parameter - * - * @throws BinaryDataException - */ - public function getBlockPosition(&$x, &$y, &$z) : void{ - $x = $this->getVarInt(); - $y = $this->getUnsignedVarInt(); - $z = $this->getVarInt(); - } - - /** - * Writes a block position with unsigned Y coordinate. - */ - public function putBlockPosition(int $x, int $y, int $z) : void{ - $this->putVarInt($x); - $this->putUnsignedVarInt($y); - $this->putVarInt($z); - } - - /** - * Reads a block position with a signed Y coordinate. - * - * @param int $x reference parameter - * @param int $y reference parameter - * @param int $z reference parameter - * - * @throws BinaryDataException - */ - public function getSignedBlockPosition(&$x, &$y, &$z) : void{ - $x = $this->getVarInt(); - $y = $this->getVarInt(); - $z = $this->getVarInt(); - } - - /** - * Writes a block position with a signed Y coordinate. - */ - public function putSignedBlockPosition(int $x, int $y, int $z) : void{ - $this->putVarInt($x); - $this->putVarInt($y); - $this->putVarInt($z); - } - - /** - * Reads a floating-point Vector3 object with coordinates rounded to 4 decimal places. - * - * @throws BinaryDataException - */ - public function getVector3() : Vector3{ - $x = $this->getLFloat(); - $y = $this->getLFloat(); - $z = $this->getLFloat(); - return new Vector3($x, $y, $z); - } - - /** - * Writes a floating-point Vector3 object, or 3x zero if null is given. - * - * Note: ONLY use this where it is reasonable to allow not specifying the vector. - * For all other purposes, use the non-nullable version. - * - * @see PacketSerializer::putVector3() - */ - public function putVector3Nullable(?Vector3 $vector) : void{ - if($vector !== null){ - $this->putVector3($vector); - }else{ - $this->putLFloat(0.0); - $this->putLFloat(0.0); - $this->putLFloat(0.0); - } - } - - /** - * Writes a floating-point Vector3 object - */ - public function putVector3(Vector3 $vector) : void{ - $this->putLFloat($vector->x); - $this->putLFloat($vector->y); - $this->putLFloat($vector->z); - } - - /** - * @throws BinaryDataException - */ - public function getByteRotation() : float{ - return ($this->getByte() * (360 / 256)); - } - - public function putByteRotation(float $rotation) : void{ - $this->putByte((int) ($rotation / (360 / 256))); - } - - private function readGameRule(int $type, bool $isPlayerModifiable) : GameRule{ - switch($type){ - case GameRuleType::BOOL: return BoolGameRule::decode($this, $isPlayerModifiable); - case GameRuleType::INT: return IntGameRule::decode($this, $isPlayerModifiable); - case GameRuleType::FLOAT: return FloatGameRule::decode($this, $isPlayerModifiable); - default: - throw new PacketDecodeException("Unknown gamerule type $type"); - } - } - - /** - * Reads gamerules - * - * @return GameRule[] game rule name => value - * @phpstan-return array - * - * @throws PacketDecodeException - * @throws BinaryDataException - */ - public function getGameRules() : array{ - $count = $this->getUnsignedVarInt(); - $rules = []; - for($i = 0; $i < $count; ++$i){ - $name = $this->getString(); - $isPlayerModifiable = $this->getBool(); - $type = $this->getUnsignedVarInt(); - $rules[$name] = $this->readGameRule($type, $isPlayerModifiable); - } - - return $rules; - } - - /** - * Writes a gamerule array - * - * @param GameRule[] $rules - * @phpstan-param array $rules - */ - public function putGameRules(array $rules) : void{ - $this->putUnsignedVarInt(count($rules)); - foreach($rules as $name => $rule){ - $this->putString($name); - $this->putBool($rule->isPlayerModifiable()); - $this->putUnsignedVarInt($rule->getType()); - $rule->encode($this); - } - } - - /** - * @throws BinaryDataException - */ - public function getEntityLink() : EntityLink{ - $fromEntityUniqueId = $this->getEntityUniqueId(); - $toEntityUniqueId = $this->getEntityUniqueId(); - $type = $this->getByte(); - $immediate = $this->getBool(); - $causedByRider = $this->getBool(); - return new EntityLink($fromEntityUniqueId, $toEntityUniqueId, $type, $immediate, $causedByRider); - } - - public function putEntityLink(EntityLink $link) : void{ - $this->putEntityUniqueId($link->fromEntityUniqueId); - $this->putEntityUniqueId($link->toEntityUniqueId); - $this->putByte($link->type); - $this->putBool($link->immediate); - $this->putBool($link->causedByRider); - } - - /** - * @throws BinaryDataException - */ - public function getCommandOriginData() : CommandOriginData{ - $result = new CommandOriginData(); - - $result->type = $this->getUnsignedVarInt(); - $result->uuid = $this->getUUID(); - $result->requestId = $this->getString(); - - if($result->type === CommandOriginData::ORIGIN_DEV_CONSOLE or $result->type === CommandOriginData::ORIGIN_TEST){ - $result->playerEntityUniqueId = $this->getVarLong(); - } - - return $result; - } - - public function putCommandOriginData(CommandOriginData $data) : void{ - $this->putUnsignedVarInt($data->type); - $this->putUUID($data->uuid); - $this->putString($data->requestId); - - if($data->type === CommandOriginData::ORIGIN_DEV_CONSOLE or $data->type === CommandOriginData::ORIGIN_TEST){ - $this->putVarLong($data->playerEntityUniqueId); - } - } - - public function getStructureSettings() : StructureSettings{ - $result = new StructureSettings(); - - $result->paletteName = $this->getString(); - - $result->ignoreEntities = $this->getBool(); - $result->ignoreBlocks = $this->getBool(); - - $this->getBlockPosition($result->structureSizeX, $result->structureSizeY, $result->structureSizeZ); - $this->getBlockPosition($result->structureOffsetX, $result->structureOffsetY, $result->structureOffsetZ); - - $result->lastTouchedByPlayerID = $this->getEntityUniqueId(); - $result->rotation = $this->getByte(); - $result->mirror = $this->getByte(); - $result->integrityValue = $this->getFloat(); - $result->integritySeed = $this->getInt(); - $result->pivot = $this->getVector3(); - - return $result; - } - - public function putStructureSettings(StructureSettings $structureSettings) : void{ - $this->putString($structureSettings->paletteName); - - $this->putBool($structureSettings->ignoreEntities); - $this->putBool($structureSettings->ignoreBlocks); - - $this->putBlockPosition($structureSettings->structureSizeX, $structureSettings->structureSizeY, $structureSettings->structureSizeZ); - $this->putBlockPosition($structureSettings->structureOffsetX, $structureSettings->structureOffsetY, $structureSettings->structureOffsetZ); - - $this->putEntityUniqueId($structureSettings->lastTouchedByPlayerID); - $this->putByte($structureSettings->rotation); - $this->putByte($structureSettings->mirror); - $this->putFloat($structureSettings->integrityValue); - $this->putInt($structureSettings->integritySeed); - $this->putVector3($structureSettings->pivot); - } - - public function getStructureEditorData() : StructureEditorData{ - $result = new StructureEditorData(); - - $result->structureName = $this->getString(); - $result->structureDataField = $this->getString(); - - $result->includePlayers = $this->getBool(); - $result->showBoundingBox = $this->getBool(); - - $result->structureBlockType = $this->getVarInt(); - $result->structureSettings = $this->getStructureSettings(); - $result->structureRedstoneSaveMove = $this->getVarInt(); - - return $result; - } - - public function putStructureEditorData(StructureEditorData $structureEditorData) : void{ - $this->putString($structureEditorData->structureName); - $this->putString($structureEditorData->structureDataField); - - $this->putBool($structureEditorData->includePlayers); - $this->putBool($structureEditorData->showBoundingBox); - - $this->putVarInt($structureEditorData->structureBlockType); - $this->putStructureSettings($structureEditorData->structureSettings); - $this->putVarInt($structureEditorData->structureRedstoneSaveMove); - } - - public function getNbtRoot() : TreeRoot{ - $offset = $this->getOffset(); - try{ - return (new NetworkNbtSerializer())->read($this->getBuffer(), $offset, 512); - }catch(NbtDataException $e){ - throw PacketDecodeException::wrap($e, "Failed decoding NBT root"); - }finally{ - $this->setOffset($offset); - } - } - - public function getNbtCompoundRoot() : CompoundTag{ - try{ - return $this->getNbtRoot()->mustGetCompoundTag(); - }catch(NbtDataException $e){ - throw PacketDecodeException::wrap($e, "Expected TAG_Compound NBT root"); - } - } - - public function readGenericTypeNetworkId() : int{ - return $this->getVarInt(); - } - - public function writeGenericTypeNetworkId(int $id) : void{ - $this->putVarInt($id); - } -} diff --git a/src/network/mcpe/protocol/serializer/PacketSerializerContext.php b/src/network/mcpe/protocol/serializer/PacketSerializerContext.php deleted file mode 100644 index 887adbc90..000000000 --- a/src/network/mcpe/protocol/serializer/PacketSerializerContext.php +++ /dev/null @@ -1,39 +0,0 @@ -itemDictionary = $itemDictionary; - } - - public function getItemDictionary() : ItemTypeDictionary{ return $this->itemDictionary; } -} diff --git a/src/network/mcpe/protocol/types/BlockPaletteEntry.php b/src/network/mcpe/protocol/types/BlockPaletteEntry.php deleted file mode 100644 index 27c5fb29e..000000000 --- a/src/network/mcpe/protocol/types/BlockPaletteEntry.php +++ /dev/null @@ -1,43 +0,0 @@ -name = $name; - $this->states = $states; - } - - public function getName() : string{ return $this->name; } - - public function getStates() : CompoundTag{ return $this->states; } -} diff --git a/src/network/mcpe/protocol/types/BoolGameRule.php b/src/network/mcpe/protocol/types/BoolGameRule.php deleted file mode 100644 index c26b2c916..000000000 --- a/src/network/mcpe/protocol/types/BoolGameRule.php +++ /dev/null @@ -1,53 +0,0 @@ -value = $value; - } - - public function getType() : int{ - return GameRuleType::BOOL; - } - - public function getValue() : bool{ - return $this->value; - } - - public function encode(PacketSerializer $out) : void{ - $out->putBool($this->value); - } - - public static function decode(PacketSerializer $in, bool $isPlayerModifiable) : self{ - return new self($in->getBool(), $isPlayerModifiable); - } -} diff --git a/src/network/mcpe/protocol/types/CacheableNbt.php b/src/network/mcpe/protocol/types/CacheableNbt.php deleted file mode 100644 index 073c40c1d..000000000 --- a/src/network/mcpe/protocol/types/CacheableNbt.php +++ /dev/null @@ -1,60 +0,0 @@ -root = $nbtRoot; - } - - /** - * @phpstan-return TTagType - */ - public function getRoot() : Tag{ - return $this->root; - } - - public function getEncodedNbt() : string{ - return $this->encodedNbt ?? ($this->encodedNbt = (new NetworkNbtSerializer())->write(new TreeRoot($this->root))); - } -} diff --git a/src/network/mcpe/protocol/types/ChunkCacheBlob.php b/src/network/mcpe/protocol/types/ChunkCacheBlob.php deleted file mode 100644 index a20137620..000000000 --- a/src/network/mcpe/protocol/types/ChunkCacheBlob.php +++ /dev/null @@ -1,47 +0,0 @@ -hash = $hash; - $this->payload = $payload; - } - - public function getHash() : int{ - return $this->hash; - } - - public function getPayload() : string{ - return $this->payload; - } -} diff --git a/src/network/mcpe/protocol/types/DeviceOS.php b/src/network/mcpe/protocol/types/DeviceOS.php deleted file mode 100644 index 97a6fe5eb..000000000 --- a/src/network/mcpe/protocol/types/DeviceOS.php +++ /dev/null @@ -1,44 +0,0 @@ -id = $id; - $this->level = $level; - } - - public function getId() : int{ return $this->id; } - - public function getLevel() : int{ return $this->level; } - - public static function read(PacketSerializer $in) : self{ - $id = $in->getByte(); - $level = $in->getByte(); - return new self($id, $level); - } - - public function write(PacketSerializer $out) : void{ - $out->putByte($this->id); - $out->putByte($this->level); - } -} diff --git a/src/network/mcpe/protocol/types/EnchantOption.php b/src/network/mcpe/protocol/types/EnchantOption.php deleted file mode 100644 index f3aa8b7f0..000000000 --- a/src/network/mcpe/protocol/types/EnchantOption.php +++ /dev/null @@ -1,126 +0,0 @@ -cost = $cost; - $this->slotFlags = $slotFlags; - $this->equipActivatedEnchantments = $equipActivatedEnchantments; - $this->heldActivatedEnchantments = $heldActivatedEnchantments; - $this->selfActivatedEnchantments = $selfActivatedEnchantments; - $this->name = $name; - $this->optionId = $optionId; - } - - public function getCost() : int{ return $this->cost; } - - public function getSlotFlags() : int{ return $this->slotFlags; } - - /** @return Enchant[] */ - public function getEquipActivatedEnchantments() : array{ return $this->equipActivatedEnchantments; } - - /** @return Enchant[] */ - public function getHeldActivatedEnchantments() : array{ return $this->heldActivatedEnchantments; } - - /** @return Enchant[] */ - public function getSelfActivatedEnchantments() : array{ return $this->selfActivatedEnchantments; } - - public function getName() : string{ return $this->name; } - - public function getOptionId() : int{ return $this->optionId; } - - /** - * @return Enchant[] - */ - private static function readEnchantList(PacketSerializer $in) : array{ - $result = []; - for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){ - $result[] = Enchant::read($in); - } - return $result; - } - - /** - * @param Enchant[] $list - */ - private static function writeEnchantList(PacketSerializer $out, array $list) : void{ - $out->putUnsignedVarInt(count($list)); - foreach($list as $item){ - $item->write($out); - } - } - - public static function read(PacketSerializer $in) : self{ - $cost = $in->getUnsignedVarInt(); - - $slotFlags = $in->getLInt(); - $equipActivatedEnchants = self::readEnchantList($in); - $heldActivatedEnchants = self::readEnchantList($in); - $selfActivatedEnchants = self::readEnchantList($in); - - $name = $in->getString(); - $optionId = $in->readGenericTypeNetworkId(); - - return new self($cost, $slotFlags, $equipActivatedEnchants, $heldActivatedEnchants, $selfActivatedEnchants, $name, $optionId); - } - - public function write(PacketSerializer $out) : void{ - $out->putUnsignedVarInt($this->cost); - - $out->putLInt($this->slotFlags); - self::writeEnchantList($out, $this->equipActivatedEnchantments); - self::writeEnchantList($out, $this->heldActivatedEnchantments); - self::writeEnchantList($out, $this->selfActivatedEnchantments); - - $out->putString($this->name); - $out->writeGenericTypeNetworkId($this->optionId); - } -} diff --git a/src/network/mcpe/protocol/types/Experiments.php b/src/network/mcpe/protocol/types/Experiments.php deleted file mode 100644 index 550e59710..000000000 --- a/src/network/mcpe/protocol/types/Experiments.php +++ /dev/null @@ -1,72 +0,0 @@ - - */ - private $experiments; - /** @var bool */ - private $hasPreviouslyUsedExperiments; - - /** - * @param bool[] $experiments - * @phpstan-param array $experiments - */ - public function __construct(array $experiments, bool $hasPreviouslyUsedExperiments){ - $this->experiments = $experiments; - $this->hasPreviouslyUsedExperiments = $hasPreviouslyUsedExperiments; - } - - /** @return bool[] */ - public function getExperiments() : array{ return $this->experiments; } - - public function hasPreviouslyUsedExperiments() : bool{ return $this->hasPreviouslyUsedExperiments; } - - public static function read(PacketSerializer $in) : self{ - $experiments = []; - for($i = 0, $len = $in->getLInt(); $i < $len; ++$i){ - $experimentName = $in->getString(); - $enabled = $in->getBool(); - $experiments[$experimentName] = $enabled; - } - $hasPreviouslyUsedExperiments = $in->getBool(); - return new self($experiments, $hasPreviouslyUsedExperiments); - } - - public function write(PacketSerializer $out) : void{ - $out->putLInt(count($this->experiments)); - foreach($this->experiments as $experimentName => $enabled){ - $out->putString($experimentName); - $out->putBool($enabled); - } - $out->putBool($this->hasPreviouslyUsedExperiments); - } -} diff --git a/src/network/mcpe/protocol/types/FloatGameRule.php b/src/network/mcpe/protocol/types/FloatGameRule.php deleted file mode 100644 index caab87c3a..000000000 --- a/src/network/mcpe/protocol/types/FloatGameRule.php +++ /dev/null @@ -1,52 +0,0 @@ -value = $value; - } - - public function getType() : int{ - return GameRuleType::FLOAT; - } - - public function getValue() : float{ - return $this->value; - } - - public function encode(PacketSerializer $out) : void{ - $out->putLFloat($this->value); - } - - public static function decode(PacketSerializer $in, bool $isPlayerModifiable) : self{ - return new self($in->getLFloat(), $isPlayerModifiable); - } -} diff --git a/src/network/mcpe/protocol/types/GameMode.php b/src/network/mcpe/protocol/types/GameMode.php deleted file mode 100644 index 616c92259..000000000 --- a/src/network/mcpe/protocol/types/GameMode.php +++ /dev/null @@ -1,38 +0,0 @@ -playerModifiable = $isPlayerModifiable; - } - - public function isPlayerModifiable() : bool{ return $this->playerModifiable; } - - abstract public function getType() : int; - - abstract public function encode(PacketSerializer $out) : void; -} diff --git a/src/network/mcpe/protocol/types/GameRuleType.php b/src/network/mcpe/protocol/types/GameRuleType.php deleted file mode 100644 index 66a6b4761..000000000 --- a/src/network/mcpe/protocol/types/GameRuleType.php +++ /dev/null @@ -1,35 +0,0 @@ -value = $value; - } - - public function getType() : int{ - return GameRuleType::INT; - } - - public function getValue() : int{ - return $this->value; - } - - public function encode(PacketSerializer $out) : void{ - $out->putUnsignedVarInt($this->value); - } - - public static function decode(PacketSerializer $in, bool $isPlayerModifiable) : self{ - return new self($in->getUnsignedVarInt(), $isPlayerModifiable); - } -} diff --git a/src/network/mcpe/protocol/types/ItemComponentPacketEntry.php b/src/network/mcpe/protocol/types/ItemComponentPacketEntry.php deleted file mode 100644 index dbe120701..000000000 --- a/src/network/mcpe/protocol/types/ItemComponentPacketEntry.php +++ /dev/null @@ -1,43 +0,0 @@ -name = $name; - $this->componentNbt = $componentNbt; - } - - public function getName() : string{ return $this->name; } - - public function getComponentNbt() : CompoundTag{ return $this->componentNbt; } -} diff --git a/src/network/mcpe/protocol/types/ItemTypeEntry.php b/src/network/mcpe/protocol/types/ItemTypeEntry.php deleted file mode 100644 index 79d063bc6..000000000 --- a/src/network/mcpe/protocol/types/ItemTypeEntry.php +++ /dev/null @@ -1,46 +0,0 @@ -stringId = $stringId; - $this->numericId = $numericId; - $this->componentBased = $componentBased; - } - - public function getStringId() : string{ return $this->stringId; } - - public function getNumericId() : int{ return $this->numericId; } - - public function isComponentBased() : bool{ return $this->componentBased; } -} diff --git a/src/network/mcpe/protocol/types/MapDecoration.php b/src/network/mcpe/protocol/types/MapDecoration.php deleted file mode 100644 index 7cf2dbde2..000000000 --- a/src/network/mcpe/protocol/types/MapDecoration.php +++ /dev/null @@ -1,74 +0,0 @@ -icon = $icon; - $this->rotation = $rotation; - $this->xOffset = $xOffset; - $this->yOffset = $yOffset; - $this->label = $label; - $this->color = $color; - } - - public function getIcon() : int{ - return $this->icon; - } - - public function getRotation() : int{ - return $this->rotation; - } - - public function getXOffset() : int{ - return $this->xOffset; - } - - public function getYOffset() : int{ - return $this->yOffset; - } - - public function getLabel() : string{ - return $this->label; - } - - public function getColor() : Color{ - return $this->color; - } -} diff --git a/src/network/mcpe/protocol/types/MapTrackedObject.php b/src/network/mcpe/protocol/types/MapTrackedObject.php deleted file mode 100644 index 7c9f10954..000000000 --- a/src/network/mcpe/protocol/types/MapTrackedObject.php +++ /dev/null @@ -1,43 +0,0 @@ -uuid = $uuid; - - return $entry; - } - - public static function createAdditionEntry(UuidInterface $uuid, int $entityUniqueId, string $username, SkinData $skinData, string $xboxUserId = "", string $platformChatId = "", int $buildPlatform = -1, bool $isTeacher = false, bool $isHost = false) : PlayerListEntry{ - $entry = new PlayerListEntry(); - $entry->uuid = $uuid; - $entry->entityUniqueId = $entityUniqueId; - $entry->username = $username; - $entry->skinData = $skinData; - $entry->xboxUserId = $xboxUserId; - $entry->platformChatId = $platformChatId; - $entry->buildPlatform = $buildPlatform; - $entry->isTeacher = $isTeacher; - $entry->isHost = $isHost; - - return $entry; - } -} diff --git a/src/network/mcpe/protocol/types/PlayerMovementSettings.php b/src/network/mcpe/protocol/types/PlayerMovementSettings.php deleted file mode 100644 index dc735523d..000000000 --- a/src/network/mcpe/protocol/types/PlayerMovementSettings.php +++ /dev/null @@ -1,61 +0,0 @@ -movementType = $movementType; - $this->rewindHistorySize = $rewindHistorySize; - //do not ask me what the F this is doing here - $this->serverAuthoritativeBlockBreaking = $serverAuthoritativeBlockBreaking; - } - - public function getMovementType() : int{ return $this->movementType; } - - public function getRewindHistorySize() : int{ return $this->rewindHistorySize; } - - public function isServerAuthoritativeBlockBreaking() : bool{ return $this->serverAuthoritativeBlockBreaking; } - - public static function read(PacketSerializer $in) : self{ - $movementType = $in->getVarInt(); - $rewindHistorySize = $in->getVarInt(); - $serverAuthBlockBreaking = $in->getBool(); - return new self($movementType, $rewindHistorySize, $serverAuthBlockBreaking); - } - - public function write(PacketSerializer $out) : void{ - $out->putVarInt($this->movementType); - $out->putVarInt($this->rewindHistorySize); - $out->putBool($this->serverAuthoritativeBlockBreaking); - } -} diff --git a/src/network/mcpe/protocol/types/PlayerMovementType.php b/src/network/mcpe/protocol/types/PlayerMovementType.php deleted file mode 100644 index 0521742ba..000000000 --- a/src/network/mcpe/protocol/types/PlayerMovementType.php +++ /dev/null @@ -1,31 +0,0 @@ -biomeType = $biomeType; - $this->biomeName = $biomeName; - $this->dimension = $dimension; - } - - public function getBiomeType() : int{ - return $this->biomeType; - } - - public function getBiomeName() : string{ - return $this->biomeName; - } - - /** - * @see DimensionIds - */ - public function getDimension() : int{ - return $this->dimension; - } - - public static function read(PacketSerializer $in) : self{ - $biomeType = $in->getLShort(); - $biomeName = $in->getString(); - $dimension = $in->getVarInt(); - - return new self($biomeType, $biomeName, $dimension); - } - - public function write(PacketSerializer $out) : void{ - $out->putLShort($this->biomeType); - $out->putString($this->biomeName); - $out->putVarInt($this->dimension); - } -} diff --git a/src/network/mcpe/protocol/types/StructureEditorData.php b/src/network/mcpe/protocol/types/StructureEditorData.php deleted file mode 100644 index 9e7f04263..000000000 --- a/src/network/mcpe/protocol/types/StructureEditorData.php +++ /dev/null @@ -1,48 +0,0 @@ -name = $name; - $this->description = $description; - $this->flags = $flags; - $this->permission = $permission; - $this->aliases = $aliases; - $this->overloads = $overloads; - } - - public function getName() : string{ - return $this->name; - } - - public function getDescription() : string{ - return $this->description; - } - - public function getFlags() : int{ - return $this->flags; - } - - public function getPermission() : int{ - return $this->permission; - } - - public function getAliases() : ?CommandEnum{ - return $this->aliases; - } - - /** - * @return CommandParameter[][] - */ - public function getOverloads() : array{ - return $this->overloads; - } -} diff --git a/src/network/mcpe/protocol/types/command/CommandEnum.php b/src/network/mcpe/protocol/types/command/CommandEnum.php deleted file mode 100644 index e7594e8bb..000000000 --- a/src/network/mcpe/protocol/types/command/CommandEnum.php +++ /dev/null @@ -1,55 +0,0 @@ - - */ - private $enumValues = []; - - /** - * @param string[] $enumValues - * @phpstan-param list $enumValues - */ - public function __construct(string $enumName, array $enumValues){ - $this->enumName = $enumName; - $this->enumValues = $enumValues; - } - - public function getName() : string{ - return $this->enumName; - } - - /** - * @return string[] - * @phpstan-return list - */ - public function getValues() : array{ - return $this->enumValues; - } -} diff --git a/src/network/mcpe/protocol/types/command/CommandEnumConstraint.php b/src/network/mcpe/protocol/types/command/CommandEnumConstraint.php deleted file mode 100644 index 923b6edbb..000000000 --- a/src/network/mcpe/protocol/types/command/CommandEnumConstraint.php +++ /dev/null @@ -1,65 +0,0 @@ -getValues()[$valueOffset])){ - throw new \InvalidArgumentException("Invalid enum value offset $valueOffset"); - } - $this->enum = $enum; - $this->valueOffset = $valueOffset; - $this->constraints = $constraints; - } - - public function getEnum() : CommandEnum{ - return $this->enum; - } - - public function getValueOffset() : int{ - return $this->valueOffset; - } - - public function getAffectedValue() : string{ - return $this->enum->getValues()[$this->valueOffset]; - } - - /** - * @return int[] - */ - public function getConstraints() : array{ - return $this->constraints; - } -} diff --git a/src/network/mcpe/protocol/types/command/CommandOriginData.php b/src/network/mcpe/protocol/types/command/CommandOriginData.php deleted file mode 100644 index 576a80112..000000000 --- a/src/network/mcpe/protocol/types/command/CommandOriginData.php +++ /dev/null @@ -1,52 +0,0 @@ -paramName = $name; - $result->paramType = $type; - $result->flags = $flags; - $result->isOptional = $optional; - return $result; - } - - public static function standard(string $name, int $type, int $flags = 0, bool $optional = false) : self{ - return self::baseline($name, AvailableCommandsPacket::ARG_FLAG_VALID | $type, $flags, $optional); - } - - public static function postfixed(string $name, string $postfix, int $flags = 0, bool $optional = false) : self{ - $result = self::baseline($name, AvailableCommandsPacket::ARG_FLAG_POSTFIX, $flags, $optional); - $result->postfix = $postfix; - return $result; - } - - public static function enum(string $name, CommandEnum $enum, int $flags, bool $optional = false) : self{ - $result = self::baseline($name, AvailableCommandsPacket::ARG_FLAG_ENUM | AvailableCommandsPacket::ARG_FLAG_VALID, $flags, $optional); - $result->enum = $enum; - return $result; - } -} diff --git a/src/network/mcpe/protocol/types/entity/Attribute.php b/src/network/mcpe/protocol/types/entity/Attribute.php deleted file mode 100644 index 84deb8c60..000000000 --- a/src/network/mcpe/protocol/types/entity/Attribute.php +++ /dev/null @@ -1,65 +0,0 @@ -id = $id; - $this->min = $min; - $this->max = $max; - $this->current = $current; - $this->default = $default; - } - - public function getId() : string{ - return $this->id; - } - - public function getMin() : float{ - return $this->min; - } - - public function getMax() : float{ - return $this->max; - } - - public function getCurrent() : float{ - return $this->current; - } - - public function getDefault() : float{ - return $this->default; - } -} diff --git a/src/network/mcpe/protocol/types/entity/BlockPosMetadataProperty.php b/src/network/mcpe/protocol/types/entity/BlockPosMetadataProperty.php deleted file mode 100644 index 0770f0bd5..000000000 --- a/src/network/mcpe/protocol/types/entity/BlockPosMetadataProperty.php +++ /dev/null @@ -1,59 +0,0 @@ -value = $value->floor(); - } - - public function getValue() : Vector3{ - return $this->value; - } - - public static function id() : int{ - return EntityMetadataTypes::POS; - } - - public static function read(PacketSerializer $in) : self{ - $x = $y = $z = 0; - $in->getSignedBlockPosition($x, $y, $z); - return new self(new Vector3($x, $y, $z)); - } - - public function write(PacketSerializer $out) : void{ - $out->putSignedBlockPosition($this->value->x, $this->value->y, $this->value->z); - } - - public function equals(MetadataProperty $other) : bool{ - return $other instanceof self and $other->value->equals($this->value); - } -} diff --git a/src/network/mcpe/protocol/types/entity/ByteMetadataProperty.php b/src/network/mcpe/protocol/types/entity/ByteMetadataProperty.php deleted file mode 100644 index b4ee55377..000000000 --- a/src/network/mcpe/protocol/types/entity/ByteMetadataProperty.php +++ /dev/null @@ -1,50 +0,0 @@ -getByte()); - } - - public function write(PacketSerializer $out) : void{ - $out->putByte($this->value); - } -} diff --git a/src/network/mcpe/protocol/types/entity/CompoundTagMetadataProperty.php b/src/network/mcpe/protocol/types/entity/CompoundTagMetadataProperty.php deleted file mode 100644 index 970c7ff63..000000000 --- a/src/network/mcpe/protocol/types/entity/CompoundTagMetadataProperty.php +++ /dev/null @@ -1,62 +0,0 @@ -value = clone $value; - } - - public function getValue() : CompoundTag{ - return clone $this->value; - } - - public static function id() : int{ - return EntityMetadataTypes::COMPOUND_TAG; - } - - public function equals(MetadataProperty $other) : bool{ - return $other instanceof self and $other->value->equals($this->value); - } - - /** - * @throws PacketDecodeException - */ - public static function read(PacketSerializer $in) : self{ - return new self($in->getNbtCompoundRoot()); - } - - public function write(PacketSerializer $out) : void{ - $out->put((new NetworkNbtSerializer())->write(new TreeRoot($this->value))); - } -} diff --git a/src/network/mcpe/protocol/types/entity/EntityIds.php b/src/network/mcpe/protocol/types/entity/EntityIds.php deleted file mode 100644 index 4d60a6653..000000000 --- a/src/network/mcpe/protocol/types/entity/EntityIds.php +++ /dev/null @@ -1,148 +0,0 @@ -fromEntityUniqueId = $fromEntityUniqueId; - $this->toEntityUniqueId = $toEntityUniqueId; - $this->type = $type; - $this->immediate = $immediate; - $this->causedByRider = $causedByRider; - } -} diff --git a/src/network/mcpe/protocol/types/entity/EntityMetadataCollection.php b/src/network/mcpe/protocol/types/entity/EntityMetadataCollection.php deleted file mode 100644 index 5d66c4163..000000000 --- a/src/network/mcpe/protocol/types/entity/EntityMetadataCollection.php +++ /dev/null @@ -1,152 +0,0 @@ - - */ - private $properties = []; - /** - * @var MetadataProperty[] - * @phpstan-var array - */ - private $dirtyProperties = []; - - public function __construct(){ - - } - - public function setByte(int $key, int $value, bool $force = false) : void{ - - $this->set($key, new ByteMetadataProperty($value), $force); - } - - public function setShort(int $key, int $value, bool $force = false) : void{ - $this->set($key, new ShortMetadataProperty($value), $force); - } - - public function setInt(int $key, int $value, bool $force = false) : void{ - $this->set($key, new IntMetadataProperty($value), $force); - } - - public function setFloat(int $key, float $value, bool $force = false) : void{ - $this->set($key, new FloatMetadataProperty($value), $force); - } - - public function setString(int $key, string $value, bool $force = false) : void{ - $this->set($key, new StringMetadataProperty($value), $force); - } - - public function setCompoundTag(int $key, CompoundTag $value, bool $force = false) : void{ - $this->set($key, new CompoundTagMetadataProperty($value), $force); - } - - public function setBlockPos(int $key, ?Vector3 $value, bool $force = false) : void{ - $this->set($key, new BlockPosMetadataProperty($value ?? new Vector3(0, 0, 0)), $force); - } - - public function setLong(int $key, int $value, bool $force = false) : void{ - $this->set($key, new LongMetadataProperty($value), $force); - } - - public function setVector3(int $key, ?Vector3 $value, bool $force = false) : void{ - $this->set($key, new Vec3MetadataProperty($value ?? new Vector3(0, 0, 0)), $force); - } - - public function set(int $key, MetadataProperty $value, bool $force = false) : void{ - if(!$force and isset($this->properties[$key]) and !($this->properties[$key] instanceof $value)){ - throw new \InvalidArgumentException("Can't overwrite property with mismatching types (have " . get_class($this->properties[$key]) . ")"); - } - if(!isset($this->properties[$key]) or !$this->properties[$key]->equals($value)){ - $this->properties[$key] = $this->dirtyProperties[$key] = $value; - } - } - - public function setGenericFlag(int $flagId, bool $value) : void{ - $propertyId = $flagId >= 64 ? EntityMetadataProperties::FLAGS2 : EntityMetadataProperties::FLAGS; - $realFlagId = $flagId % 64; - $flagSetProp = $this->properties[$propertyId] ?? null; - if($flagSetProp === null){ - $flagSet = 0; - }elseif($flagSetProp instanceof LongMetadataProperty){ - $flagSet = $flagSetProp->getValue(); - }else{ - throw new \InvalidArgumentException("Wrong type found for flags, want long, but have " . get_class($flagSetProp)); - } - - if((($flagSet >> $realFlagId) & 1) !== ($value ? 1 : 0)){ - $flagSet ^= (1 << $realFlagId); - $this->setLong($propertyId, $flagSet); - } - } - - public function setPlayerFlag(int $flagId, bool $value) : void{ - $flagSetProp = $this->properties[EntityMetadataProperties::PLAYER_FLAGS] ?? null; - if($flagSetProp === null){ - $flagSet = 0; - }elseif($flagSetProp instanceof ByteMetadataProperty){ - $flagSet = $flagSetProp->getValue(); - }else{ - throw new \InvalidArgumentException("Wrong type found for flags, want byte, but have " . get_class($flagSetProp)); - } - if((($flagSet >> $flagId) & 1) !== ($value ? 1 : 0)){ - $flagSet ^= (1 << $flagId); - $this->setByte(EntityMetadataProperties::PLAYER_FLAGS, $flagSet); - } - } - - /** - * Returns all properties. - * - * @return MetadataProperty[] - * @phpstan-return array - */ - public function getAll() : array{ - return $this->properties; - } - - /** - * Returns properties that have changed and need to be broadcasted. - * - * @return MetadataProperty[] - * @phpstan-return array - */ - public function getDirty() : array{ - return $this->dirtyProperties; - } - - /** - * Clears records of dirty properties. - */ - public function clearDirtyProperties() : void{ - $this->dirtyProperties = []; - } -} diff --git a/src/network/mcpe/protocol/types/entity/EntityMetadataFlags.php b/src/network/mcpe/protocol/types/entity/EntityMetadataFlags.php deleted file mode 100644 index 5a27fdcd6..000000000 --- a/src/network/mcpe/protocol/types/entity/EntityMetadataFlags.php +++ /dev/null @@ -1,126 +0,0 @@ -value = $value; - } - - public function getValue() : float{ - return $this->value; - } - - public static function id() : int{ - return EntityMetadataTypes::FLOAT; - } - - public function equals(MetadataProperty $other) : bool{ - return $other instanceof self and $other->value === $this->value; - } - - public static function read(PacketSerializer $in) : self{ - return new self($in->getLFloat()); - } - - public function write(PacketSerializer $out) : void{ - $out->putLFloat($this->value); - } -} diff --git a/src/network/mcpe/protocol/types/entity/IntMetadataProperty.php b/src/network/mcpe/protocol/types/entity/IntMetadataProperty.php deleted file mode 100644 index ea1731678..000000000 --- a/src/network/mcpe/protocol/types/entity/IntMetadataProperty.php +++ /dev/null @@ -1,50 +0,0 @@ -getVarInt()); - } - - public function write(PacketSerializer $out) : void{ - $out->putVarInt($this->value); - } -} diff --git a/src/network/mcpe/protocol/types/entity/IntegerishMetadataProperty.php b/src/network/mcpe/protocol/types/entity/IntegerishMetadataProperty.php deleted file mode 100644 index 62be6a0d0..000000000 --- a/src/network/mcpe/protocol/types/entity/IntegerishMetadataProperty.php +++ /dev/null @@ -1,62 +0,0 @@ -min() or $value > $this->max()){ - throw new \InvalidArgumentException("Value is out of range " . $this->min() . " - " . $this->max()); - } - $this->value = $value; - } - - abstract protected function min() : int; - - abstract protected function max() : int; - - public function getValue() : int{ - return $this->value; - } - - public function equals(MetadataProperty $other) : bool{ - return $other instanceof self and $other->value === $this->value; - } - - /** - * @param bool[] $flags - * @phpstan-param array $flags - */ - public static function buildFromFlags(array $flags) : self{ - $value = 0; - foreach($flags as $flag => $v){ - if($v){ - $value |= 1 << $flag; - } - } - return new self($value); - } -} diff --git a/src/network/mcpe/protocol/types/entity/LongMetadataProperty.php b/src/network/mcpe/protocol/types/entity/LongMetadataProperty.php deleted file mode 100644 index 895dbe706..000000000 --- a/src/network/mcpe/protocol/types/entity/LongMetadataProperty.php +++ /dev/null @@ -1,52 +0,0 @@ -getVarLong()); - } - - public function write(PacketSerializer $out) : void{ - $out->putVarLong($this->value); - } -} diff --git a/src/network/mcpe/protocol/types/entity/MetadataProperty.php b/src/network/mcpe/protocol/types/entity/MetadataProperty.php deleted file mode 100644 index 63673d932..000000000 --- a/src/network/mcpe/protocol/types/entity/MetadataProperty.php +++ /dev/null @@ -1,35 +0,0 @@ -getSignedLShort()); - } - - public function write(PacketSerializer $out) : void{ - $out->putLShort($this->value); - } -} diff --git a/src/network/mcpe/protocol/types/entity/StringMetadataProperty.php b/src/network/mcpe/protocol/types/entity/StringMetadataProperty.php deleted file mode 100644 index 5396d34b1..000000000 --- a/src/network/mcpe/protocol/types/entity/StringMetadataProperty.php +++ /dev/null @@ -1,51 +0,0 @@ -value = $value; - } - - public static function id() : int{ - return EntityMetadataTypes::STRING; - } - - public static function read(PacketSerializer $in) : self{ - return new self($in->getString()); - } - - public function write(PacketSerializer $out) : void{ - $out->putString($this->value); - } - - public function equals(MetadataProperty $other) : bool{ - return $other instanceof self and $other->value === $this->value; - } -} diff --git a/src/network/mcpe/protocol/types/entity/Vec3MetadataProperty.php b/src/network/mcpe/protocol/types/entity/Vec3MetadataProperty.php deleted file mode 100644 index 44b81e610..000000000 --- a/src/network/mcpe/protocol/types/entity/Vec3MetadataProperty.php +++ /dev/null @@ -1,56 +0,0 @@ -value = $value->asVector3(); - } - - public function getValue() : Vector3{ - return clone $this->value; - } - - public static function id() : int{ - return EntityMetadataTypes::VECTOR3F; - } - - public static function read(PacketSerializer $in) : self{ - return new self($in->getVector3()); - } - - public function write(PacketSerializer $out) : void{ - $out->putVector3($this->value); - } - - public function equals(MetadataProperty $other) : bool{ - return $other instanceof self and $other->value->equals($this->value); - } -} diff --git a/src/network/mcpe/protocol/types/inventory/ContainerIds.php b/src/network/mcpe/protocol/types/inventory/ContainerIds.php deleted file mode 100644 index 2a4501dc2..000000000 --- a/src/network/mcpe/protocol/types/inventory/ContainerIds.php +++ /dev/null @@ -1,43 +0,0 @@ -entryId = $entryId; - $this->item = $item; - } - - public function getEntryId() : int{ return $this->entryId; } - - public function getItem() : ItemStack{ return $this->item; } - - public static function read(PacketSerializer $in) : self{ - $entryId = $in->readGenericTypeNetworkId(); - $item = $in->getItemStackWithoutStackId(); - return new self($entryId, $item); - } - - public function write(PacketSerializer $out) : void{ - $out->writeGenericTypeNetworkId($this->entryId); - $out->putItemStackWithoutStackId($this->item); - } -} diff --git a/src/network/mcpe/protocol/types/inventory/InventoryTransactionChangedSlotsHack.php b/src/network/mcpe/protocol/types/inventory/InventoryTransactionChangedSlotsHack.php deleted file mode 100644 index 456666501..000000000 --- a/src/network/mcpe/protocol/types/inventory/InventoryTransactionChangedSlotsHack.php +++ /dev/null @@ -1,65 +0,0 @@ -containerId = $containerId; - $this->changedSlotIndexes = $changedSlotIndexes; - } - - public function getContainerId() : int{ return $this->containerId; } - - /** @return int[] */ - public function getChangedSlotIndexes() : array{ return $this->changedSlotIndexes; } - - public static function read(PacketSerializer $in) : self{ - $containerId = $in->getByte(); - $changedSlots = []; - for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){ - $changedSlots[] = $in->getByte(); - } - return new self($containerId, $changedSlots); - } - - public function write(PacketSerializer $out) : void{ - $out->putByte($this->containerId); - $out->putUnsignedVarInt(count($this->changedSlotIndexes)); - foreach($this->changedSlotIndexes as $index){ - $out->putByte($index); - } - } -} diff --git a/src/network/mcpe/protocol/types/inventory/ItemStack.php b/src/network/mcpe/protocol/types/inventory/ItemStack.php deleted file mode 100644 index 2250c33ad..000000000 --- a/src/network/mcpe/protocol/types/inventory/ItemStack.php +++ /dev/null @@ -1,142 +0,0 @@ -id = $id; - $this->meta = $meta; - $this->count = $count; - $this->blockRuntimeId = $blockRuntimeId; - $this->canPlaceOn = $canPlaceOn; - $this->canDestroy = $canDestroy; - $this->nbt = $nbt; - $this->shieldBlockingTick = $shieldBlockingTick; - } - - public static function null() : self{ - return new self(0, 0, 0, 0, null, [], [], null); - } - - public function getId() : int{ - return $this->id; - } - - public function getMeta() : int{ - return $this->meta; - } - - public function getCount() : int{ - return $this->count; - } - - public function getBlockRuntimeId() : int{ return $this->blockRuntimeId; } - - /** - * @return string[] - */ - public function getCanPlaceOn() : array{ - return $this->canPlaceOn; - } - - /** - * @return string[] - */ - public function getCanDestroy() : array{ - return $this->canDestroy; - } - - public function getNbt() : ?CompoundTag{ - return $this->nbt; - } - - public function getShieldBlockingTick() : ?int{ - return $this->shieldBlockingTick; - } - - public function equals(ItemStack $itemStack) : bool{ - return - $this->id === $itemStack->id && - $this->meta === $itemStack->meta && - $this->count === $itemStack->count && - $this->blockRuntimeId === $itemStack->blockRuntimeId && - $this->canPlaceOn === $itemStack->canPlaceOn && - $this->canDestroy === $itemStack->canDestroy && - $this->shieldBlockingTick === $itemStack->shieldBlockingTick && ( - $this->nbt === $itemStack->nbt || //this covers null === null and fast object identity - ($this->nbt !== null && $itemStack->nbt !== null && $this->nbt->equals($itemStack->nbt)) - ); - } - - /** @return mixed[] */ - public function jsonSerialize() : array{ - $result = [ - "id" => $this->id, - "meta" => $this->meta, - "count" => $this->count, - "blockRuntimeId" => $this->blockRuntimeId, - ]; - if(count($this->canPlaceOn) > 0){ - $result["canPlaceOn"] = $this->canPlaceOn; - } - if(count($this->canDestroy) > 0){ - $result["canDestroy"] = $this->canDestroy; - } - if($this->shieldBlockingTick !== null){ - $result["shieldBlockingTick"] = $this->shieldBlockingTick; - } - if($this->nbt !== null){ - $result["nbt"] = base64_encode((new NetworkNbtSerializer())->write(new TreeRoot($this->nbt))); - } - return $result; - } -} diff --git a/src/network/mcpe/protocol/types/inventory/ItemStackWrapper.php b/src/network/mcpe/protocol/types/inventory/ItemStackWrapper.php deleted file mode 100644 index 1ed56454d..000000000 --- a/src/network/mcpe/protocol/types/inventory/ItemStackWrapper.php +++ /dev/null @@ -1,67 +0,0 @@ -stackId = $stackId; - $this->itemStack = $itemStack; - } - - public static function legacy(ItemStack $itemStack) : self{ - return new self($itemStack->getId() === 0 ? 0 : 1, $itemStack); - } - - public function getStackId() : int{ return $this->stackId; } - - public function getItemStack() : ItemStack{ return $this->itemStack; } - - public static function read(PacketSerializer $in) : self{ - $stackId = 0; - $stack = $in->getItemStack(function(PacketSerializer $in) use (&$stackId) : void{ - $hasNetId = $in->getBool(); - if($hasNetId){ - $stackId = $in->readGenericTypeNetworkId(); - } - }); - return new self($stackId, $stack); - } - - public function write(PacketSerializer $out) : void{ - $out->putItemStack($this->itemStack, function(PacketSerializer $out) : void{ - $out->putBool($this->stackId !== 0); - if($this->stackId !== 0){ - $out->writeGenericTypeNetworkId($this->stackId); - } - }); - } -} diff --git a/src/network/mcpe/protocol/types/inventory/MismatchTransactionData.php b/src/network/mcpe/protocol/types/inventory/MismatchTransactionData.php deleted file mode 100644 index 66e0c0ff7..000000000 --- a/src/network/mcpe/protocol/types/inventory/MismatchTransactionData.php +++ /dev/null @@ -1,50 +0,0 @@ -actions) > 0){ - throw new PacketDecodeException("Mismatch transaction type should not have any actions associated with it, but got " . count($this->actions)); - } - } - - protected function encodeData(PacketSerializer $stream) : void{ - - } - - public static function new() : self{ - return new self; //no arguments - } -} diff --git a/src/network/mcpe/protocol/types/inventory/NetworkInventoryAction.php b/src/network/mcpe/protocol/types/inventory/NetworkInventoryAction.php deleted file mode 100644 index f966be26d..000000000 --- a/src/network/mcpe/protocol/types/inventory/NetworkInventoryAction.php +++ /dev/null @@ -1,138 +0,0 @@ -sourceType = $packet->getUnsignedVarInt(); - - switch($this->sourceType){ - case self::SOURCE_CONTAINER: - $this->windowId = $packet->getVarInt(); - break; - case self::SOURCE_WORLD: - $this->sourceFlags = $packet->getUnsignedVarInt(); - break; - case self::SOURCE_CREATIVE: - break; - case self::SOURCE_TODO: - $this->windowId = $packet->getVarInt(); - break; - default: - throw new PacketDecodeException("Unknown inventory action source type $this->sourceType"); - } - - $this->inventorySlot = $packet->getUnsignedVarInt(); - $this->oldItem = ItemStackWrapper::read($packet); - $this->newItem = ItemStackWrapper::read($packet); - - return $this; - } - - /** - * @throws \InvalidArgumentException - */ - public function write(PacketSerializer $packet) : void{ - $packet->putUnsignedVarInt($this->sourceType); - - switch($this->sourceType){ - case self::SOURCE_CONTAINER: - $packet->putVarInt($this->windowId); - break; - case self::SOURCE_WORLD: - $packet->putUnsignedVarInt($this->sourceFlags); - break; - case self::SOURCE_CREATIVE: - break; - case self::SOURCE_TODO: - $packet->putVarInt($this->windowId); - break; - default: - throw new \InvalidArgumentException("Unknown inventory action source type $this->sourceType"); - } - - $packet->putUnsignedVarInt($this->inventorySlot); - $this->oldItem->write($packet); - $this->newItem->write($packet); - } -} diff --git a/src/network/mcpe/protocol/types/inventory/NormalTransactionData.php b/src/network/mcpe/protocol/types/inventory/NormalTransactionData.php deleted file mode 100644 index 37c2e565d..000000000 --- a/src/network/mcpe/protocol/types/inventory/NormalTransactionData.php +++ /dev/null @@ -1,53 +0,0 @@ -actions = $actions; - return $result; - } -} diff --git a/src/network/mcpe/protocol/types/inventory/ReleaseItemTransactionData.php b/src/network/mcpe/protocol/types/inventory/ReleaseItemTransactionData.php deleted file mode 100644 index 5db088e41..000000000 --- a/src/network/mcpe/protocol/types/inventory/ReleaseItemTransactionData.php +++ /dev/null @@ -1,90 +0,0 @@ -actionType; - } - - public function getHotbarSlot() : int{ - return $this->hotbarSlot; - } - - public function getItemInHand() : ItemStackWrapper{ - return $this->itemInHand; - } - - public function getHeadPos() : Vector3{ - return $this->headPos; - } - - public function getTypeId() : int{ - return InventoryTransactionPacket::TYPE_RELEASE_ITEM; - } - - protected function decodeData(PacketSerializer $stream) : void{ - $this->actionType = $stream->getUnsignedVarInt(); - $this->hotbarSlot = $stream->getVarInt(); - $this->itemInHand = ItemStackWrapper::read($stream); - $this->headPos = $stream->getVector3(); - } - - protected function encodeData(PacketSerializer $stream) : void{ - $stream->putUnsignedVarInt($this->actionType); - $stream->putVarInt($this->hotbarSlot); - $this->itemInHand->write($stream); - $stream->putVector3($this->headPos); - } - - /** - * @param NetworkInventoryAction[] $actions - */ - public static function new(array $actions, int $actionType, int $hotbarSlot, ItemStackWrapper $itemInHand, Vector3 $headPos) : self{ - $result = new self; - $result->actions = $actions; - $result->actionType = $actionType; - $result->hotbarSlot = $hotbarSlot; - $result->itemInHand = $itemInHand; - $result->headPos = $headPos; - - return $result; - } -} diff --git a/src/network/mcpe/protocol/types/inventory/TransactionData.php b/src/network/mcpe/protocol/types/inventory/TransactionData.php deleted file mode 100644 index ea10fce25..000000000 --- a/src/network/mcpe/protocol/types/inventory/TransactionData.php +++ /dev/null @@ -1,71 +0,0 @@ -actions; - } - - abstract public function getTypeId() : int; - - /** - * @throws BinaryDataException - * @throws PacketDecodeException - */ - final public function decode(PacketSerializer $stream) : void{ - $actionCount = $stream->getUnsignedVarInt(); - for($i = 0; $i < $actionCount; ++$i){ - $this->actions[] = (new NetworkInventoryAction())->read($stream); - } - $this->decodeData($stream); - } - - /** - * @throws BinaryDataException - * @throws PacketDecodeException - */ - abstract protected function decodeData(PacketSerializer $stream) : void; - - final public function encode(PacketSerializer $stream) : void{ - $stream->putUnsignedVarInt(count($this->actions)); - foreach($this->actions as $action){ - $action->write($stream); - } - $this->encodeData($stream); - } - - abstract protected function encodeData(PacketSerializer $stream) : void; -} diff --git a/src/network/mcpe/protocol/types/inventory/UIInventorySlotOffset.php b/src/network/mcpe/protocol/types/inventory/UIInventorySlotOffset.php deleted file mode 100644 index 12e2c60eb..000000000 --- a/src/network/mcpe/protocol/types/inventory/UIInventorySlotOffset.php +++ /dev/null @@ -1,105 +0,0 @@ - 0, - 2 => 1, - ]; - public const STONE_CUTTER_INPUT = 3; - public const TRADE2_INGREDIENT = [ - 4 => 0, - 5 => 1, - ]; - public const TRADE_INGREDIENT = [ - 6 => 0, - 7 => 1, - ]; - public const MATERIAL_REDUCER_INPUT = 8; - public const LOOM = [ - 9 => 0, - 10 => 1, - 11 => 2, - ]; - public const CARTOGRAPHY_TABLE = [ - 12 => 0, - 13 => 1, - ]; - public const ENCHANTING_TABLE = [ - 14 => 0, - 15 => 1, - ]; - public const GRINDSTONE = [ - 16 => 0, - 17 => 1, - ]; - public const COMPOUND_CREATOR_INPUT = [ - 18 => 0, - 19 => 1, - 20 => 2, - 21 => 3, - 22 => 4, - 23 => 5, - 24 => 6, - 25 => 7, - 26 => 8, - ]; - public const BEACON_PAYMENT = 27; - public const CRAFTING2X2_INPUT = [ - 28 => 0, - 29 => 1, - 30 => 2, - 31 => 3, - ]; - public const CRAFTING3X3_INPUT = [ - 32 => 0, - 33 => 1, - 34 => 2, - 35 => 3, - 36 => 4, - 37 => 5, - 38 => 6, - 39 => 7, - 40 => 8, - ]; - public const MATERIAL_REDUCER_OUTPUT = [ - 41 => 0, - 42 => 1, - 43 => 2, - 44 => 3, - 45 => 4, - 46 => 5, - 47 => 6, - 48 => 7, - 49 => 8, - ]; - public const CREATED_ITEM_OUTPUT = 50; -} diff --git a/src/network/mcpe/protocol/types/inventory/UseItemOnEntityTransactionData.php b/src/network/mcpe/protocol/types/inventory/UseItemOnEntityTransactionData.php deleted file mode 100644 index 857df5e60..000000000 --- a/src/network/mcpe/protocol/types/inventory/UseItemOnEntityTransactionData.php +++ /dev/null @@ -1,108 +0,0 @@ -entityRuntimeId; - } - - public function getActionType() : int{ - return $this->actionType; - } - - public function getHotbarSlot() : int{ - return $this->hotbarSlot; - } - - public function getItemInHand() : ItemStackWrapper{ - return $this->itemInHand; - } - - public function getPlayerPos() : Vector3{ - return $this->playerPos; - } - - public function getClickPos() : Vector3{ - return $this->clickPos; - } - - public function getTypeId() : int{ - return InventoryTransactionPacket::TYPE_USE_ITEM_ON_ENTITY; - } - - protected function decodeData(PacketSerializer $stream) : void{ - $this->entityRuntimeId = $stream->getEntityRuntimeId(); - $this->actionType = $stream->getUnsignedVarInt(); - $this->hotbarSlot = $stream->getVarInt(); - $this->itemInHand = ItemStackWrapper::read($stream); - $this->playerPos = $stream->getVector3(); - $this->clickPos = $stream->getVector3(); - } - - protected function encodeData(PacketSerializer $stream) : void{ - $stream->putEntityRuntimeId($this->entityRuntimeId); - $stream->putUnsignedVarInt($this->actionType); - $stream->putVarInt($this->hotbarSlot); - $this->itemInHand->write($stream); - $stream->putVector3($this->playerPos); - $stream->putVector3($this->clickPos); - } - - /** - * @param NetworkInventoryAction[] $actions - */ - public static function new(array $actions, int $entityRuntimeId, int $actionType, int $hotbarSlot, ItemStackWrapper $itemInHand, Vector3 $playerPos, Vector3 $clickPos) : self{ - $result = new self; - $result->actions = $actions; - $result->entityRuntimeId = $entityRuntimeId; - $result->actionType = $actionType; - $result->hotbarSlot = $hotbarSlot; - $result->itemInHand = $itemInHand; - $result->playerPos = $playerPos; - $result->clickPos = $clickPos; - return $result; - } -} diff --git a/src/network/mcpe/protocol/types/inventory/UseItemTransactionData.php b/src/network/mcpe/protocol/types/inventory/UseItemTransactionData.php deleted file mode 100644 index 0a425e9d6..000000000 --- a/src/network/mcpe/protocol/types/inventory/UseItemTransactionData.php +++ /dev/null @@ -1,128 +0,0 @@ -actionType; - } - - public function getBlockPos() : Vector3{ - return $this->blockPos; - } - - public function getFace() : int{ - return $this->face; - } - - public function getHotbarSlot() : int{ - return $this->hotbarSlot; - } - - public function getItemInHand() : ItemStackWrapper{ - return $this->itemInHand; - } - - public function getPlayerPos() : Vector3{ - return $this->playerPos; - } - - public function getClickPos() : Vector3{ - return $this->clickPos; - } - - public function getBlockRuntimeId() : int{ - return $this->blockRuntimeId; - } - - public function getTypeId() : int{ - return InventoryTransactionPacket::TYPE_USE_ITEM; - } - - protected function decodeData(PacketSerializer $stream) : void{ - $this->actionType = $stream->getUnsignedVarInt(); - $x = $y = $z = 0; - $stream->getBlockPosition($x, $y, $z); - $this->blockPos = new Vector3($x, $y, $z); - $this->face = $stream->getVarInt(); - $this->hotbarSlot = $stream->getVarInt(); - $this->itemInHand = ItemStackWrapper::read($stream); - $this->playerPos = $stream->getVector3(); - $this->clickPos = $stream->getVector3(); - $this->blockRuntimeId = $stream->getUnsignedVarInt(); - } - - protected function encodeData(PacketSerializer $stream) : void{ - $stream->putUnsignedVarInt($this->actionType); - $stream->putBlockPosition($this->blockPos->x, $this->blockPos->y, $this->blockPos->z); - $stream->putVarInt($this->face); - $stream->putVarInt($this->hotbarSlot); - $this->itemInHand->write($stream); - $stream->putVector3($this->playerPos); - $stream->putVector3($this->clickPos); - $stream->putUnsignedVarInt($this->blockRuntimeId); - } - - /** - * @param NetworkInventoryAction[] $actions - */ - public static function new(array $actions, int $actionType, Vector3 $blockPos, int $face, int $hotbarSlot, ItemStackWrapper $itemInHand, Vector3 $playerPos, Vector3 $clickPos, int $blockRuntimeId) : self{ - $result = new self; - $result->actions = $actions; - $result->actionType = $actionType; - $result->blockPos = $blockPos; - $result->face = $face; - $result->hotbarSlot = $hotbarSlot; - $result->itemInHand = $itemInHand; - $result->playerPos = $playerPos; - $result->clickPos = $clickPos; - $result->blockRuntimeId = $blockRuntimeId; - return $result; - } -} diff --git a/src/network/mcpe/protocol/types/inventory/WindowTypes.php b/src/network/mcpe/protocol/types/inventory/WindowTypes.php deleted file mode 100644 index c20f80601..000000000 --- a/src/network/mcpe/protocol/types/inventory/WindowTypes.php +++ /dev/null @@ -1,70 +0,0 @@ -primaryEffectId = $primaryEffectId; - $this->secondaryEffectId = $secondaryEffectId; - } - - public function getPrimaryEffectId() : int{ return $this->primaryEffectId; } - - public function getSecondaryEffectId() : int{ return $this->secondaryEffectId; } - - public static function getTypeId() : int{ return ItemStackRequestActionType::BEACON_PAYMENT; } - - public static function read(PacketSerializer $in) : self{ - $primary = $in->getVarInt(); - $secondary = $in->getVarInt(); - return new self($primary, $secondary); - } - - public function write(PacketSerializer $out) : void{ - $out->putVarInt($this->primaryEffectId); - $out->putVarInt($this->secondaryEffectId); - } -} diff --git a/src/network/mcpe/protocol/types/inventory/stackrequest/CraftRecipeAutoStackRequestAction.php b/src/network/mcpe/protocol/types/inventory/stackrequest/CraftRecipeAutoStackRequestAction.php deleted file mode 100644 index d5f10ee1f..000000000 --- a/src/network/mcpe/protocol/types/inventory/stackrequest/CraftRecipeAutoStackRequestAction.php +++ /dev/null @@ -1,34 +0,0 @@ -recipeId = $type; - $this->filterStringIndex = $filterStringIndex; - } - - public function getRecipeId() : int{ return $this->recipeId; } - - public function getFilterStringIndex() : int{ return $this->filterStringIndex; } - - public static function getTypeId() : int{ return ItemStackRequestActionType::CRAFTING_RECIPE_OPTIONAL; } - - public static function read(PacketSerializer $in) : self{ - $recipeId = $in->readGenericTypeNetworkId(); - $filterStringIndex = $in->getLInt(); - return new self($recipeId, $filterStringIndex); - } - - public function write(PacketSerializer $out) : void{ - $out->writeGenericTypeNetworkId($this->recipeId); - $out->putLInt($this->filterStringIndex); - } -} diff --git a/src/network/mcpe/protocol/types/inventory/stackrequest/CraftRecipeStackRequestAction.php b/src/network/mcpe/protocol/types/inventory/stackrequest/CraftRecipeStackRequestAction.php deleted file mode 100644 index 6341aecc5..000000000 --- a/src/network/mcpe/protocol/types/inventory/stackrequest/CraftRecipeStackRequestAction.php +++ /dev/null @@ -1,33 +0,0 @@ -recipeId = $recipeId; - } - - public function getRecipeId() : int{ return $this->recipeId; } - - public static function read(PacketSerializer $in) : self{ - $recipeId = $in->readGenericTypeNetworkId(); - return new self($recipeId); - } - - public function write(PacketSerializer $out) : void{ - $out->writeGenericTypeNetworkId($this->recipeId); - } -} diff --git a/src/network/mcpe/protocol/types/inventory/stackrequest/CraftingConsumeInputStackRequestAction.php b/src/network/mcpe/protocol/types/inventory/stackrequest/CraftingConsumeInputStackRequestAction.php deleted file mode 100644 index 26f85f7a7..000000000 --- a/src/network/mcpe/protocol/types/inventory/stackrequest/CraftingConsumeInputStackRequestAction.php +++ /dev/null @@ -1,33 +0,0 @@ -craftingGridSlot = $craftingGridSlot; - } - - public function getCraftingGridSlot() : int{ return $this->craftingGridSlot; } - - public static function getTypeId() : int{ return ItemStackRequestActionType::CRAFTING_MARK_SECONDARY_RESULT_SLOT; } - - public static function read(PacketSerializer $in) : self{ - $slot = $in->getByte(); - return new self($slot); - } - - public function write(PacketSerializer $out) : void{ - $out->putByte($this->craftingGridSlot); - } -} diff --git a/src/network/mcpe/protocol/types/inventory/stackrequest/CreativeCreateStackRequestAction.php b/src/network/mcpe/protocol/types/inventory/stackrequest/CreativeCreateStackRequestAction.php deleted file mode 100644 index e84975afa..000000000 --- a/src/network/mcpe/protocol/types/inventory/stackrequest/CreativeCreateStackRequestAction.php +++ /dev/null @@ -1,52 +0,0 @@ -creativeItemId = $creativeItemId; - } - - public function getCreativeItemId() : int{ return $this->creativeItemId; } - - public static function getTypeId() : int{ return ItemStackRequestActionType::CREATIVE_CREATE; } - - public static function read(PacketSerializer $in) : self{ - $creativeItemId = $in->readGenericTypeNetworkId(); - return new self($creativeItemId); - } - - public function write(PacketSerializer $out) : void{ - $out->writeGenericTypeNetworkId($this->creativeItemId); - } -} diff --git a/src/network/mcpe/protocol/types/inventory/stackrequest/DeprecatedCraftingNonImplementedStackRequestAction.php b/src/network/mcpe/protocol/types/inventory/stackrequest/DeprecatedCraftingNonImplementedStackRequestAction.php deleted file mode 100644 index 5ec79617a..000000000 --- a/src/network/mcpe/protocol/types/inventory/stackrequest/DeprecatedCraftingNonImplementedStackRequestAction.php +++ /dev/null @@ -1,45 +0,0 @@ -results = $results; - $this->iterations = $iterations; - } - - /** @return ItemStack[] */ - public function getResults() : array{ return $this->results; } - - public function getIterations() : int{ return $this->iterations; } - - public static function getTypeId() : int{ - return ItemStackRequestActionType::CRAFTING_RESULTS_DEPRECATED_ASK_TY_LAING; - } - - public static function read(PacketSerializer $in) : self{ - $results = []; - for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){ - $results[] = $in->getItemStackWithoutStackId(); - } - $iterations = $in->getByte(); - return new self($results, $iterations); - } - - public function write(PacketSerializer $out) : void{ - $out->putUnsignedVarInt(count($this->results)); - foreach($this->results as $result){ - $out->putItemStackWithoutStackId($result); - } - $out->putByte($this->iterations); - } -} diff --git a/src/network/mcpe/protocol/types/inventory/stackrequest/DestroyStackRequestAction.php b/src/network/mcpe/protocol/types/inventory/stackrequest/DestroyStackRequestAction.php deleted file mode 100644 index 36f55e9a4..000000000 --- a/src/network/mcpe/protocol/types/inventory/stackrequest/DestroyStackRequestAction.php +++ /dev/null @@ -1,34 +0,0 @@ -count = $count; - $this->source = $source; - } - - final public function getCount() : int{ return $this->count; } - - final public function getSource() : ItemStackRequestSlotInfo{ return $this->source; } - - public static function read(PacketSerializer $in) : self{ - $count = $in->getByte(); - $source = ItemStackRequestSlotInfo::read($in); - return new self($count, $source); - } - - public function write(PacketSerializer $out) : void{ - $out->putByte($this->count); - $this->source->write($out); - } -} diff --git a/src/network/mcpe/protocol/types/inventory/stackrequest/DropStackRequestAction.php b/src/network/mcpe/protocol/types/inventory/stackrequest/DropStackRequestAction.php deleted file mode 100644 index 6a4857805..000000000 --- a/src/network/mcpe/protocol/types/inventory/stackrequest/DropStackRequestAction.php +++ /dev/null @@ -1,66 +0,0 @@ -count = $count; - $this->source = $source; - $this->randomly = $randomly; - } - - public function getCount() : int{ return $this->count; } - - public function getSource() : ItemStackRequestSlotInfo{ return $this->source; } - - public function isRandomly() : bool{ return $this->randomly; } - - public static function getTypeId() : int{ return ItemStackRequestActionType::DROP; } - - public static function read(PacketSerializer $in) : self{ - $count = $in->getByte(); - $source = ItemStackRequestSlotInfo::read($in); - $random = $in->getBool(); - return new self($count, $source, $random); - } - - public function write(PacketSerializer $out) : void{ - $out->putByte($this->count); - $this->source->write($out); - $out->putBool($this->randomly); - } -} diff --git a/src/network/mcpe/protocol/types/inventory/stackrequest/ItemStackRequest.php b/src/network/mcpe/protocol/types/inventory/stackrequest/ItemStackRequest.php deleted file mode 100644 index 82ac464f1..000000000 --- a/src/network/mcpe/protocol/types/inventory/stackrequest/ItemStackRequest.php +++ /dev/null @@ -1,110 +0,0 @@ - - */ - private $filterStrings; - - /** - * @param ItemStackRequestAction[] $actions - * @param string[] $filterStrings - * @phpstan-param list $filterStrings - */ - public function __construct(int $requestId, array $actions, array $filterStrings){ - $this->requestId = $requestId; - $this->actions = $actions; - $this->filterStrings = $filterStrings; - } - - public function getRequestId() : int{ return $this->requestId; } - - /** @return ItemStackRequestAction[] */ - public function getActions() : array{ return $this->actions; } - - /** - * @return string[] - * @phpstan-return list - */ - public function getFilterStrings() : array{ return $this->filterStrings; } - private static function readAction(PacketSerializer $in, int $typeId) : ItemStackRequestAction{ - switch($typeId){ - case TakeStackRequestAction::getTypeId(): return TakeStackRequestAction::read($in); - case PlaceStackRequestAction::getTypeId(): return PlaceStackRequestAction::read($in); - case SwapStackRequestAction::getTypeId(): return SwapStackRequestAction::read($in); - case DropStackRequestAction::getTypeId(): return DropStackRequestAction::read($in); - case DestroyStackRequestAction::getTypeId(): return DestroyStackRequestAction::read($in); - case CraftingConsumeInputStackRequestAction::getTypeId(): return CraftingConsumeInputStackRequestAction::read($in); - case CraftingMarkSecondaryResultStackRequestAction::getTypeId(): return CraftingMarkSecondaryResultStackRequestAction::read($in); - case LabTableCombineStackRequestAction::getTypeId(): return LabTableCombineStackRequestAction::read($in); - case BeaconPaymentStackRequestAction::getTypeId(): return BeaconPaymentStackRequestAction::read($in); - case MineBlockStackRequestAction::getTypeId(): return MineBlockStackRequestAction::read($in); - case CraftRecipeStackRequestAction::getTypeId(): return CraftRecipeStackRequestAction::read($in); - case CraftRecipeAutoStackRequestAction::getTypeId(): return CraftRecipeAutoStackRequestAction::read($in); - case CreativeCreateStackRequestAction::getTypeId(): return CreativeCreateStackRequestAction::read($in); - case CraftRecipeOptionalStackRequestAction::getTypeId(): return CraftRecipeOptionalStackRequestAction::read($in); - case DeprecatedCraftingNonImplementedStackRequestAction::getTypeId(): return DeprecatedCraftingNonImplementedStackRequestAction::read($in); - case DeprecatedCraftingResultsStackRequestAction::getTypeId(): return DeprecatedCraftingResultsStackRequestAction::read($in); - } - throw new \UnexpectedValueException("Unhandled item stack request action type $typeId"); - } - - public static function read(PacketSerializer $in) : self{ - $requestId = $in->readGenericTypeNetworkId(); - $actions = []; - for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){ - $typeId = $in->getByte(); - $actions[] = self::readAction($in, $typeId); - } - $filterStrings = []; - for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){ - $filterStrings[] = $in->getString(); - } - return new self($requestId, $actions, $filterStrings); - } - - public function write(PacketSerializer $out) : void{ - $out->writeGenericTypeNetworkId($this->requestId); - $out->putUnsignedVarInt(count($this->actions)); - foreach($this->actions as $action){ - $out->putByte($action::getTypeId()); - $action->write($out); - } - $out->putUnsignedVarInt(count($this->filterStrings)); - foreach($this->filterStrings as $string){ - $out->putString($string); - } - } -} diff --git a/src/network/mcpe/protocol/types/inventory/stackrequest/ItemStackRequestAction.php b/src/network/mcpe/protocol/types/inventory/stackrequest/ItemStackRequestAction.php deleted file mode 100644 index bd56a0797..000000000 --- a/src/network/mcpe/protocol/types/inventory/stackrequest/ItemStackRequestAction.php +++ /dev/null @@ -1,33 +0,0 @@ -containerId = $containerId; - $this->slotId = $slotId; - $this->stackId = $stackId; - } - - public function getContainerId() : int{ return $this->containerId; } - - public function getSlotId() : int{ return $this->slotId; } - - public function getStackId() : int{ return $this->stackId; } - - public static function read(PacketSerializer $in) : self{ - $containerId = $in->getByte(); - $slotId = $in->getByte(); - $stackId = $in->readGenericTypeNetworkId(); - return new self($containerId, $slotId, $stackId); - } - - public function write(PacketSerializer $out) : void{ - $out->putByte($this->containerId); - $out->putByte($this->slotId); - $out->writeGenericTypeNetworkId($this->stackId); - } -} diff --git a/src/network/mcpe/protocol/types/inventory/stackrequest/LabTableCombineStackRequestAction.php b/src/network/mcpe/protocol/types/inventory/stackrequest/LabTableCombineStackRequestAction.php deleted file mode 100644 index 8ea896a82..000000000 --- a/src/network/mcpe/protocol/types/inventory/stackrequest/LabTableCombineStackRequestAction.php +++ /dev/null @@ -1,43 +0,0 @@ -unknown1 = $unknown1; - $this->predictedDurability = $predictedDurability; - $this->stackId = $stackId; - } - - public function getUnknown1() : int{ return $this->unknown1; } - - public function getPredictedDurability() : int{ return $this->predictedDurability; } - - public function getStackId() : int{ return $this->stackId; } - - public static function getTypeId() : int{ return ItemStackRequestActionType::MINE_BLOCK; } - - public static function read(PacketSerializer $in) : self{ - $unknown1 = $in->getVarInt(); - $predictedDurability = $in->getVarInt(); - $stackId = $in->readGenericTypeNetworkId(); - return new self($unknown1, $predictedDurability, $stackId); - } - - public function write(PacketSerializer $out) : void{ - $out->putVarInt($this->unknown1); - $out->putVarInt($this->predictedDurability); - $out->writeGenericTypeNetworkId($this->stackId); - } -} diff --git a/src/network/mcpe/protocol/types/inventory/stackrequest/PlaceStackRequestAction.php b/src/network/mcpe/protocol/types/inventory/stackrequest/PlaceStackRequestAction.php deleted file mode 100644 index 2fa453e1b..000000000 --- a/src/network/mcpe/protocol/types/inventory/stackrequest/PlaceStackRequestAction.php +++ /dev/null @@ -1,33 +0,0 @@ -slot1 = $slot1; - $this->slot2 = $slot2; - } - - public function getSlot1() : ItemStackRequestSlotInfo{ return $this->slot1; } - - public function getSlot2() : ItemStackRequestSlotInfo{ return $this->slot2; } - - public static function getTypeId() : int{ return ItemStackRequestActionType::SWAP; } - - public static function read(PacketSerializer $in) : self{ - $slot1 = ItemStackRequestSlotInfo::read($in); - $slot2 = ItemStackRequestSlotInfo::read($in); - return new self($slot1, $slot2); - } - - public function write(PacketSerializer $out) : void{ - $this->slot1->write($out); - $this->slot2->write($out); - } -} diff --git a/src/network/mcpe/protocol/types/inventory/stackrequest/TakeOrPlaceStackRequestActionTrait.php b/src/network/mcpe/protocol/types/inventory/stackrequest/TakeOrPlaceStackRequestActionTrait.php deleted file mode 100644 index 2866c641d..000000000 --- a/src/network/mcpe/protocol/types/inventory/stackrequest/TakeOrPlaceStackRequestActionTrait.php +++ /dev/null @@ -1,61 +0,0 @@ -count = $count; - $this->source = $source; - $this->destination = $destination; - } - - final public function getCount() : int{ return $this->count; } - - final public function getSource() : ItemStackRequestSlotInfo{ return $this->source; } - - final public function getDestination() : ItemStackRequestSlotInfo{ return $this->destination; } - - public static function read(PacketSerializer $in) : self{ - $count = $in->getByte(); - $src = ItemStackRequestSlotInfo::read($in); - $dst = ItemStackRequestSlotInfo::read($in); - return new self($count, $src, $dst); - } - - public function write(PacketSerializer $out) : void{ - $out->putByte($this->count); - $this->source->write($out); - $this->destination->write($out); - } -} diff --git a/src/network/mcpe/protocol/types/inventory/stackrequest/TakeStackRequestAction.php b/src/network/mcpe/protocol/types/inventory/stackrequest/TakeStackRequestAction.php deleted file mode 100644 index f2946def2..000000000 --- a/src/network/mcpe/protocol/types/inventory/stackrequest/TakeStackRequestAction.php +++ /dev/null @@ -1,33 +0,0 @@ -result = $result; - $this->requestId = $requestId; - $this->containerInfos = $containerInfos; - } - - public function getResult() : int{ return $this->result; } - - public function getRequestId() : int{ return $this->requestId; } - - /** @return ItemStackResponseContainerInfo[] */ - public function getContainerInfos() : array{ return $this->containerInfos; } - - public static function read(PacketSerializer $in) : self{ - $result = $in->getByte(); - $requestId = $in->readGenericTypeNetworkId(); - $containerInfos = []; - for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){ - $containerInfos[] = ItemStackResponseContainerInfo::read($in); - } - return new self($result, $requestId, $containerInfos); - } - - public function write(PacketSerializer $out) : void{ - $out->putByte($this->result); - $out->writeGenericTypeNetworkId($this->requestId); - $out->putUnsignedVarInt(count($this->containerInfos)); - foreach($this->containerInfos as $containerInfo){ - $containerInfo->write($out); - } - } -} diff --git a/src/network/mcpe/protocol/types/inventory/stackresponse/ItemStackResponseContainerInfo.php b/src/network/mcpe/protocol/types/inventory/stackresponse/ItemStackResponseContainerInfo.php deleted file mode 100644 index 3678c84d8..000000000 --- a/src/network/mcpe/protocol/types/inventory/stackresponse/ItemStackResponseContainerInfo.php +++ /dev/null @@ -1,65 +0,0 @@ -containerId = $containerId; - $this->slots = $slots; - } - - public function getContainerId() : int{ return $this->containerId; } - - /** @return ItemStackResponseSlotInfo[] */ - public function getSlots() : array{ return $this->slots; } - - public static function read(PacketSerializer $in) : self{ - $containerId = $in->getByte(); - $slots = []; - for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){ - $slots[] = ItemStackResponseSlotInfo::read($in); - } - return new self($containerId, $slots); - } - - public function write(PacketSerializer $out) : void{ - $out->putByte($this->containerId); - $out->putUnsignedVarInt(count($this->slots)); - foreach($this->slots as $slot){ - $slot->write($out); - } - } -} diff --git a/src/network/mcpe/protocol/types/inventory/stackresponse/ItemStackResponseSlotInfo.php b/src/network/mcpe/protocol/types/inventory/stackresponse/ItemStackResponseSlotInfo.php deleted file mode 100644 index 05ae10b4c..000000000 --- a/src/network/mcpe/protocol/types/inventory/stackresponse/ItemStackResponseSlotInfo.php +++ /dev/null @@ -1,82 +0,0 @@ -slot = $slot; - $this->hotbarSlot = $hotbarSlot; - $this->count = $count; - $this->itemStackId = $itemStackId; - $this->customName = $customName; - $this->durabilityCorrection = $durabilityCorrection; - } - - public function getSlot() : int{ return $this->slot; } - - public function getHotbarSlot() : int{ return $this->hotbarSlot; } - - public function getCount() : int{ return $this->count; } - - public function getItemStackId() : int{ return $this->itemStackId; } - - public function getCustomName() : string{ return $this->customName; } - - public function getDurabilityCorrection() : int{ return $this->durabilityCorrection; } - - public static function read(PacketSerializer $in) : self{ - $slot = $in->getByte(); - $hotbarSlot = $in->getByte(); - $count = $in->getByte(); - $itemStackId = $in->readGenericTypeNetworkId(); - $customName = $in->getString(); - $durabilityCorrection = $in->getVarInt(); - return new self($slot, $hotbarSlot, $count, $itemStackId, $customName, $durabilityCorrection); - } - - public function write(PacketSerializer $out) : void{ - $out->putByte($this->slot); - $out->putByte($this->hotbarSlot); - $out->putByte($this->count); - $out->writeGenericTypeNetworkId($this->itemStackId); - $out->putString($this->customName); - $out->putVarInt($this->durabilityCorrection); - } -} diff --git a/src/network/mcpe/protocol/types/login/AuthenticationData.php b/src/network/mcpe/protocol/types/login/AuthenticationData.php deleted file mode 100644 index 535d8ca43..000000000 --- a/src/network/mcpe/protocol/types/login/AuthenticationData.php +++ /dev/null @@ -1,41 +0,0 @@ -AnimatedImageData as $k => $animation){ - $animations[] = new SkinAnimation( - new SkinImage( - $animation->ImageHeight, - $animation->ImageWidth, - self::safeB64Decode($animation->Image, "AnimatedImageData.$k.Image") - ), - $animation->Type, - $animation->Frames, - $animation->AnimationExpression - ); - } - return new SkinData( - $clientData->SkinId, - $clientData->PlayFabId, - self::safeB64Decode($clientData->SkinResourcePatch, "SkinResourcePatch"), - new SkinImage($clientData->SkinImageHeight, $clientData->SkinImageWidth, self::safeB64Decode($clientData->SkinData, "SkinData")), - $animations, - new SkinImage($clientData->CapeImageHeight, $clientData->CapeImageWidth, self::safeB64Decode($clientData->CapeData, "CapeData")), - self::safeB64Decode($clientData->SkinGeometryData, "SkinGeometryData"), - self::safeB64Decode($clientData->SkinAnimationData, "SkinAnimationData"), - $clientData->PremiumSkin, - $clientData->PersonaSkin, - $clientData->CapeOnClassicSkin, - $clientData->CapeId, - null, - $clientData->ArmSize, - $clientData->SkinColor, - array_map(function(ClientDataPersonaSkinPiece $piece) : PersonaSkinPiece{ - return new PersonaSkinPiece($piece->PieceId, $piece->PieceType, $piece->PackId, $piece->IsDefault, $piece->ProductId); - }, $clientData->PersonaPieces), - array_map(function(ClientDataPersonaPieceTintColor $tint) : PersonaPieceTintColor{ - return new PersonaPieceTintColor($tint->PieceType, $tint->Colors); - }, $clientData->PieceTintColors) - ); - } -} \ No newline at end of file diff --git a/src/network/mcpe/protocol/types/login/JwtBodyRfc7519.php b/src/network/mcpe/protocol/types/login/JwtBodyRfc7519.php deleted file mode 100644 index b048e2d9f..000000000 --- a/src/network/mcpe/protocol/types/login/JwtBodyRfc7519.php +++ /dev/null @@ -1,39 +0,0 @@ -inputId = $inputId; - $this->inputMeta = $inputMeta; - $this->result = $result; - $this->blockName = $blockName; - } - - public function getInputId() : int{ - return $this->inputId; - } - - public function getInputMeta() : ?int{ - return $this->inputMeta; - } - - public function getResult() : ItemStack{ - return $this->result; - } - - public function getBlockName() : string{ - return $this->blockName; - } - - public static function decode(int $typeId, PacketSerializer $in) : self{ - $inputId = $in->getVarInt(); - $inputData = null; - if($typeId === CraftingDataPacket::ENTRY_FURNACE_DATA){ - $inputData = $in->getVarInt(); - } - $output = $in->getItemStackWithoutStackId(); - $block = $in->getString(); - - return new self($typeId, $inputId, $inputData, $output, $block); - } - - public function encode(PacketSerializer $out) : void{ - $out->putVarInt($this->inputId); - if($this->getTypeId() === CraftingDataPacket::ENTRY_FURNACE_DATA){ - $out->putVarInt($this->inputMeta); - } - $out->putItemStackWithoutStackId($this->result); - $out->putString($this->blockName); - } -} diff --git a/src/network/mcpe/protocol/types/recipe/MultiRecipe.php b/src/network/mcpe/protocol/types/recipe/MultiRecipe.php deleted file mode 100644 index 52b5276eb..000000000 --- a/src/network/mcpe/protocol/types/recipe/MultiRecipe.php +++ /dev/null @@ -1,73 +0,0 @@ -recipeId = $recipeId; - $this->recipeNetId = $recipeNetId; - } - - public function getRecipeId() : UuidInterface{ - return $this->recipeId; - } - - public function getRecipeNetId() : int{ - return $this->recipeNetId; - } - - public static function decode(int $typeId, PacketSerializer $in) : self{ - $uuid = $in->getUUID(); - $recipeNetId = $in->readGenericTypeNetworkId(); - return new self($typeId, $uuid, $recipeNetId); - } - - public function encode(PacketSerializer $out) : void{ - $out->putUUID($this->recipeId); - $out->writeGenericTypeNetworkId($this->recipeNetId); - } -} diff --git a/src/network/mcpe/protocol/types/recipe/PotionContainerChangeRecipe.php b/src/network/mcpe/protocol/types/recipe/PotionContainerChangeRecipe.php deleted file mode 100644 index eb0bb6532..000000000 --- a/src/network/mcpe/protocol/types/recipe/PotionContainerChangeRecipe.php +++ /dev/null @@ -1,51 +0,0 @@ -inputItemId = $inputItemId; - $this->ingredientItemId = $ingredientItemId; - $this->outputItemId = $outputItemId; - } - - public function getInputItemId() : int{ - return $this->inputItemId; - } - - public function getIngredientItemId() : int{ - return $this->ingredientItemId; - } - - public function getOutputItemId() : int{ - return $this->outputItemId; - } -} diff --git a/src/network/mcpe/protocol/types/recipe/PotionTypeRecipe.php b/src/network/mcpe/protocol/types/recipe/PotionTypeRecipe.php deleted file mode 100644 index 31628ac4c..000000000 --- a/src/network/mcpe/protocol/types/recipe/PotionTypeRecipe.php +++ /dev/null @@ -1,72 +0,0 @@ -inputItemId = $inputItemId; - $this->inputItemMeta = $inputItemMeta; - $this->ingredientItemId = $ingredientItemId; - $this->ingredientItemMeta = $ingredientItemMeta; - $this->outputItemId = $outputItemId; - $this->outputItemMeta = $outputItemMeta; - } - - public function getInputItemId() : int{ - return $this->inputItemId; - } - - public function getInputItemMeta() : int{ - return $this->inputItemMeta; - } - - public function getIngredientItemId() : int{ - return $this->ingredientItemId; - } - - public function getIngredientItemMeta() : int{ - return $this->ingredientItemMeta; - } - - public function getOutputItemId() : int{ - return $this->outputItemId; - } - - public function getOutputItemMeta() : int{ - return $this->outputItemMeta; - } -} diff --git a/src/network/mcpe/protocol/types/recipe/RecipeIngredient.php b/src/network/mcpe/protocol/types/recipe/RecipeIngredient.php deleted file mode 100644 index 1349e2634..000000000 --- a/src/network/mcpe/protocol/types/recipe/RecipeIngredient.php +++ /dev/null @@ -1,52 +0,0 @@ -id = $id; - $this->meta = $meta; - $this->count = $count; - } - - public function getId() : int{ - return $this->id; - } - - public function getMeta() : int{ - return $this->meta; - } - - public function getCount() : int{ - return $this->count; - } -} diff --git a/src/network/mcpe/protocol/types/recipe/RecipeWithTypeId.php b/src/network/mcpe/protocol/types/recipe/RecipeWithTypeId.php deleted file mode 100644 index 9171f52bc..000000000 --- a/src/network/mcpe/protocol/types/recipe/RecipeWithTypeId.php +++ /dev/null @@ -1,41 +0,0 @@ -typeId = $typeId; - } - - final public function getTypeId() : int{ - return $this->typeId; - } - - abstract public function encode(PacketSerializer $out) : void; -} diff --git a/src/network/mcpe/protocol/types/recipe/ShapedRecipe.php b/src/network/mcpe/protocol/types/recipe/ShapedRecipe.php deleted file mode 100644 index 55f10bdc5..000000000 --- a/src/network/mcpe/protocol/types/recipe/ShapedRecipe.php +++ /dev/null @@ -1,160 +0,0 @@ - 3){ - throw new \InvalidArgumentException("Expected 1, 2 or 3 input rows"); - } - $columns = null; - foreach($input as $rowNumber => $row){ - if($columns === null){ - $columns = count($row); - }elseif(count($row) !== $columns){ - throw new \InvalidArgumentException("Expected each row to be $columns columns, but have " . count($row) . " in row $rowNumber"); - } - } - $this->recipeId = $recipeId; - $this->input = $input; - $this->output = $output; - $this->blockName = $blockType; - $this->priority = $priority; - $this->uuid = $uuid; - $this->recipeNetId = $recipeNetId; - } - - public function getRecipeId() : string{ - return $this->recipeId; - } - - public function getWidth() : int{ - return count($this->input[0]); - } - - public function getHeight() : int{ - return count($this->input); - } - - /** - * @return RecipeIngredient[][] - */ - public function getInput() : array{ - return $this->input; - } - - /** - * @return ItemStack[] - */ - public function getOutput() : array{ - return $this->output; - } - - public function getUuid() : UuidInterface{ - return $this->uuid; - } - - public function getBlockName() : string{ - return $this->blockName; - } - - public function getPriority() : int{ - return $this->priority; - } - - public function getRecipeNetId() : int{ - return $this->recipeNetId; - } - - public static function decode(int $recipeType, PacketSerializer $in) : self{ - $recipeId = $in->getString(); - $width = $in->getVarInt(); - $height = $in->getVarInt(); - $input = []; - for($row = 0; $row < $height; ++$row){ - for($column = 0; $column < $width; ++$column){ - $input[$row][$column] = $in->getRecipeIngredient(); - } - } - - $output = []; - for($k = 0, $resultCount = $in->getUnsignedVarInt(); $k < $resultCount; ++$k){ - $output[] = $in->getItemStackWithoutStackId(); - } - $uuid = $in->getUUID(); - $block = $in->getString(); - $priority = $in->getVarInt(); - $recipeNetId = $in->readGenericTypeNetworkId(); - - return new self($recipeType, $recipeId, $input, $output, $uuid, $block, $priority, $recipeNetId); - } - - public function encode(PacketSerializer $out) : void{ - $out->putString($this->recipeId); - $out->putVarInt($this->getWidth()); - $out->putVarInt($this->getHeight()); - foreach($this->input as $row){ - foreach($row as $ingredient){ - $out->putRecipeIngredient($ingredient); - } - } - - $out->putUnsignedVarInt(count($this->output)); - foreach($this->output as $item){ - $out->putItemStackWithoutStackId($item); - } - - $out->putUUID($this->uuid); - $out->putString($this->blockName); - $out->putVarInt($this->priority); - $out->writeGenericTypeNetworkId($this->recipeNetId); - } -} diff --git a/src/network/mcpe/protocol/types/recipe/ShapelessRecipe.php b/src/network/mcpe/protocol/types/recipe/ShapelessRecipe.php deleted file mode 100644 index c97dd40bd..000000000 --- a/src/network/mcpe/protocol/types/recipe/ShapelessRecipe.php +++ /dev/null @@ -1,132 +0,0 @@ -recipeId = $recipeId; - $this->inputs = $inputs; - $this->outputs = $outputs; - $this->uuid = $uuid; - $this->blockName = $blockName; - $this->priority = $priority; - $this->recipeNetId = $recipeNetId; - } - - public function getRecipeId() : string{ - return $this->recipeId; - } - - /** - * @return RecipeIngredient[] - */ - public function getInputs() : array{ - return $this->inputs; - } - - /** - * @return ItemStack[] - */ - public function getOutputs() : array{ - return $this->outputs; - } - - public function getUuid() : UuidInterface{ - return $this->uuid; - } - - public function getBlockName() : string{ - return $this->blockName; - } - - public function getPriority() : int{ - return $this->priority; - } - - public function getRecipeNetId() : int{ - return $this->recipeNetId; - } - - public static function decode(int $recipeType, PacketSerializer $in) : self{ - $recipeId = $in->getString(); - $input = []; - for($j = 0, $ingredientCount = $in->getUnsignedVarInt(); $j < $ingredientCount; ++$j){ - $input[] = $in->getRecipeIngredient(); - } - $output = []; - for($k = 0, $resultCount = $in->getUnsignedVarInt(); $k < $resultCount; ++$k){ - $output[] = $in->getItemStackWithoutStackId(); - } - $uuid = $in->getUUID(); - $block = $in->getString(); - $priority = $in->getVarInt(); - $recipeNetId = $in->readGenericTypeNetworkId(); - - return new self($recipeType, $recipeId, $input, $output, $uuid, $block, $priority, $recipeNetId); - } - - public function encode(PacketSerializer $out) : void{ - $out->putString($this->recipeId); - $out->putUnsignedVarInt(count($this->inputs)); - foreach($this->inputs as $item){ - $out->putRecipeIngredient($item); - } - - $out->putUnsignedVarInt(count($this->outputs)); - foreach($this->outputs as $item){ - $out->putItemStackWithoutStackId($item); - } - - $out->putUUID($this->uuid); - $out->putString($this->blockName); - $out->putVarInt($this->priority); - $out->writeGenericTypeNetworkId($this->recipeNetId); - } -} diff --git a/src/network/mcpe/protocol/types/resourcepacks/BehaviorPackInfoEntry.php b/src/network/mcpe/protocol/types/resourcepacks/BehaviorPackInfoEntry.php deleted file mode 100644 index df0858045..000000000 --- a/src/network/mcpe/protocol/types/resourcepacks/BehaviorPackInfoEntry.php +++ /dev/null @@ -1,103 +0,0 @@ -packId = $packId; - $this->version = $version; - $this->sizeBytes = $sizeBytes; - $this->encryptionKey = $encryptionKey; - $this->subPackName = $subPackName; - $this->contentId = $contentId; - $this->hasScripts = $hasScripts; - } - - public function getPackId() : string{ - return $this->packId; - } - - public function getVersion() : string{ - return $this->version; - } - - public function getSizeBytes() : int{ - return $this->sizeBytes; - } - - public function getEncryptionKey() : string{ - return $this->encryptionKey; - } - - public function getSubPackName() : string{ - return $this->subPackName; - } - - public function getContentId() : string{ - return $this->contentId; - } - - public function hasScripts() : bool{ - return $this->hasScripts; - } - - public function write(PacketSerializer $out) : void{ - $out->putString($this->packId); - $out->putString($this->version); - $out->putLLong($this->sizeBytes); - $out->putString($this->encryptionKey); - $out->putString($this->subPackName); - $out->putString($this->contentId); - $out->putBool($this->hasScripts); - } - - public static function read(PacketSerializer $in) : self{ - $uuid = $in->getString(); - $version = $in->getString(); - $sizeBytes = $in->getLLong(); - $encryptionKey = $in->getString(); - $subPackName = $in->getString(); - $contentId = $in->getString(); - $hasScripts = $in->getBool(); - return new self($uuid, $version, $sizeBytes, $encryptionKey, $subPackName, $contentId, $hasScripts); - } -} diff --git a/src/network/mcpe/protocol/types/resourcepacks/ResourcePackInfoEntry.php b/src/network/mcpe/protocol/types/resourcepacks/ResourcePackInfoEntry.php deleted file mode 100644 index 9be7072ba..000000000 --- a/src/network/mcpe/protocol/types/resourcepacks/ResourcePackInfoEntry.php +++ /dev/null @@ -1,110 +0,0 @@ -packId = $packId; - $this->version = $version; - $this->sizeBytes = $sizeBytes; - $this->encryptionKey = $encryptionKey; - $this->subPackName = $subPackName; - $this->contentId = $contentId; - $this->hasScripts = $hasScripts; - $this->isRtxCapable = $isRtxCapable; - } - - public function getPackId() : string{ - return $this->packId; - } - - public function getVersion() : string{ - return $this->version; - } - - public function getSizeBytes() : int{ - return $this->sizeBytes; - } - - public function getEncryptionKey() : string{ - return $this->encryptionKey; - } - - public function getSubPackName() : string{ - return $this->subPackName; - } - - public function getContentId() : string{ - return $this->contentId; - } - - public function hasScripts() : bool{ - return $this->hasScripts; - } - - public function isRtxCapable() : bool{ return $this->isRtxCapable; } - - public function write(PacketSerializer $out) : void{ - $out->putString($this->packId); - $out->putString($this->version); - $out->putLLong($this->sizeBytes); - $out->putString($this->encryptionKey); - $out->putString($this->subPackName); - $out->putString($this->contentId); - $out->putBool($this->hasScripts); - $out->putBool($this->isRtxCapable); - } - - public static function read(PacketSerializer $in) : self{ - $uuid = $in->getString(); - $version = $in->getString(); - $sizeBytes = $in->getLLong(); - $encryptionKey = $in->getString(); - $subPackName = $in->getString(); - $contentId = $in->getString(); - $hasScripts = $in->getBool(); - $rtxCapable = $in->getBool(); - return new self($uuid, $version, $sizeBytes, $encryptionKey, $subPackName, $contentId, $hasScripts, $rtxCapable); - } -} diff --git a/src/network/mcpe/protocol/types/resourcepacks/ResourcePackStackEntry.php b/src/network/mcpe/protocol/types/resourcepacks/ResourcePackStackEntry.php deleted file mode 100644 index 1151d37d5..000000000 --- a/src/network/mcpe/protocol/types/resourcepacks/ResourcePackStackEntry.php +++ /dev/null @@ -1,67 +0,0 @@ -packId = $packId; - $this->version = $version; - $this->subPackName = $subPackName; - } - - public function getPackId() : string{ - return $this->packId; - } - - public function getVersion() : string{ - return $this->version; - } - - public function getSubPackName() : string{ - return $this->subPackName; - } - - public function write(PacketSerializer $out) : void{ - $out->putString($this->packId); - $out->putString($this->version); - $out->putString($this->subPackName); - } - - public static function read(PacketSerializer $in) : self{ - $packId = $in->getString(); - $version = $in->getString(); - $subPackName = $in->getString(); - return new self($packId, $version, $subPackName); - } -} diff --git a/src/network/mcpe/protocol/types/resourcepacks/ResourcePackType.php b/src/network/mcpe/protocol/types/resourcepacks/ResourcePackType.php deleted file mode 100644 index 94ab159fa..000000000 --- a/src/network/mcpe/protocol/types/resourcepacks/ResourcePackType.php +++ /dev/null @@ -1,41 +0,0 @@ -pieceType = $pieceType; - $this->colors = $colors; - } - - public function getPieceType() : string{ - return $this->pieceType; - } - - /** - * @return string[] - */ - public function getColors() : array{ - return $this->colors; - } -} diff --git a/src/network/mcpe/protocol/types/skin/PersonaSkinPiece.php b/src/network/mcpe/protocol/types/skin/PersonaSkinPiece.php deleted file mode 100644 index e198da964..000000000 --- a/src/network/mcpe/protocol/types/skin/PersonaSkinPiece.php +++ /dev/null @@ -1,77 +0,0 @@ -pieceId = $pieceId; - $this->pieceType = $pieceType; - $this->packId = $packId; - $this->isDefaultPiece = $isDefaultPiece; - $this->productId = $productId; - } - - public function getPieceId() : string{ - return $this->pieceId; - } - - public function getPieceType() : string{ - return $this->pieceType; - } - - public function getPackId() : string{ - return $this->packId; - } - - public function isDefaultPiece() : bool{ - return $this->isDefaultPiece; - } - - public function getProductId() : string{ - return $this->productId; - } -} diff --git a/src/network/mcpe/protocol/types/skin/SkinAnimation.php b/src/network/mcpe/protocol/types/skin/SkinAnimation.php deleted file mode 100644 index a7dc17679..000000000 --- a/src/network/mcpe/protocol/types/skin/SkinAnimation.php +++ /dev/null @@ -1,73 +0,0 @@ -image = $image; - $this->type = $type; - $this->frames = $frames; - $this->expressionType = $expressionType; - } - - /** - * Image of the animation. - */ - public function getImage() : SkinImage{ - return $this->image; - } - - /** - * The type of animation you are applying. - */ - public function getType() : int{ - return $this->type; - } - - /** - * The total amount of frames in an animation. - */ - public function getFrames() : float{ - return $this->frames; - } - - public function getExpressionType() : int{ return $this->expressionType; } -} diff --git a/src/network/mcpe/protocol/types/skin/SkinData.php b/src/network/mcpe/protocol/types/skin/SkinData.php deleted file mode 100644 index ccc958e89..000000000 --- a/src/network/mcpe/protocol/types/skin/SkinData.php +++ /dev/null @@ -1,182 +0,0 @@ -skinId = $skinId; - $this->playFabId = $playFabId; - $this->resourcePatch = $resourcePatch; - $this->skinImage = $skinImage; - $this->animations = $animations; - $this->capeImage = $capeImage ?? new SkinImage(0, 0, ""); - $this->geometryData = $geometryData; - $this->animationData = $animationData; - $this->premium = $premium; - $this->persona = $persona; - $this->personaCapeOnClassic = $personaCapeOnClassic; - $this->capeId = $capeId; - //this has to be unique or the client will do stupid things - $this->fullSkinId = $fullSkinId ?? Uuid::uuid4()->toString(); - $this->armSize = $armSize; - $this->skinColor = $skinColor; - $this->personaPieces = $personaPieces; - $this->pieceTintColors = $pieceTintColors; - $this->isVerified = $isVerified; - } - - public function getSkinId() : string{ - return $this->skinId; - } - - public function getPlayFabId() : string{ return $this->playFabId; } - - public function getResourcePatch() : string{ - return $this->resourcePatch; - } - - public function getSkinImage() : SkinImage{ - return $this->skinImage; - } - - /** - * @return SkinAnimation[] - */ - public function getAnimations() : array{ - return $this->animations; - } - - public function getCapeImage() : SkinImage{ - return $this->capeImage; - } - - public function getGeometryData() : string{ - return $this->geometryData; - } - - public function getAnimationData() : string{ - return $this->animationData; - } - - public function isPersona() : bool{ - return $this->persona; - } - - public function isPremium() : bool{ - return $this->premium; - } - - public function isPersonaCapeOnClassic() : bool{ - return $this->personaCapeOnClassic; - } - - public function getCapeId() : string{ - return $this->capeId; - } - - public function getFullSkinId() : string{ - return $this->fullSkinId; - } - - public function getArmSize() : string{ - return $this->armSize; - } - - public function getSkinColor() : string{ - return $this->skinColor; - } - - /** - * @return PersonaSkinPiece[] - */ - public function getPersonaPieces() : array{ - return $this->personaPieces; - } - - /** - * @return PersonaPieceTintColor[] - */ - public function getPieceTintColors() : array{ - return $this->pieceTintColors; - } - - public function isVerified() : bool{ - return $this->isVerified; - } - - /** - * @internal - */ - public function setVerified(bool $verified) : void{ - $this->isVerified = $verified; - } -} diff --git a/src/network/mcpe/protocol/types/skin/SkinImage.php b/src/network/mcpe/protocol/types/skin/SkinImage.php deleted file mode 100644 index fa797cd7f..000000000 --- a/src/network/mcpe/protocol/types/skin/SkinImage.php +++ /dev/null @@ -1,73 +0,0 @@ -height = $height; - $this->width = $width; - $this->data = $data; - } - - public static function fromLegacy(string $data) : SkinImage{ - switch(strlen($data)){ - case 64 * 32 * 4: - return new self(32, 64, $data); - case 64 * 64 * 4: - return new self(64, 64, $data); - case 128 * 128 * 4: - return new self(128, 128, $data); - } - - throw new \InvalidArgumentException("Unknown size"); - } - - public function getHeight() : int{ - return $this->height; - } - - public function getWidth() : int{ - return $this->width; - } - - public function getData() : string{ - return $this->data; - } -}