From 792860ee0d747bd7f5c4ec55575551ef3424a8e7 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sat, 13 Jan 2024 15:29:45 +0800 Subject: [PATCH] feat: v2 --- .clang-format | 46 + .clang-tidy | 145 +++ .clangd | 15 + .gitattributes | 127 +++ .github/ISSUE_TEMPLATE/bug_report.yml | 55 + .github/ISSUE_TEMPLATE/feature_request.yml | 28 + .github/PULL_REQUEST_TEMPLATE.md | 18 + .github/workflows/build.yml | 63 +- .github/workflows/release.yml | 56 + .gitignore | 563 +++++++++- LICENSE | 165 --- README.md | 26 +- bdsversion | 2 - manifest.json | 5 + scripts/after_build.lua | 118 +++ scripts/format_all.py | 36 - scripts/localbdslibrary.lua | 43 - src/DLLMain.cpp | 27 - src/DataExtractor.cpp | 992 ------------------ src/DataExtractor.h | 180 ---- src/DllMain.cpp | 32 + src/Plugin.cpp | 733 +++++++++++++ src/Plugin.h | 28 + src/ll/base/Concepts.h | 100 -- src/ll/base/FixedString.h | 16 - src/ll/base/Hash.h | 67 -- src/ll/base/Macro.h | 26 - src/ll/base/Meta.h | 115 -- src/ll/base/StdInt.h | 35 - src/ll/memory/Closure.cpp | 39 - src/ll/memory/Closure.h | 96 -- src/ll/memory/Hook.cpp | 20 - src/ll/memory/Hook.h | 230 ---- src/ll/memory/Memory.cpp | 92 -- src/ll/memory/Memory.h | 170 --- src/ll/memory/PatchHelper.cpp | 3 - src/ll/memory/PatchHelper.h | 92 -- src/ll/utils/Hash.h | 47 - src/ll/utils/StringUtils.cpp | 255 ----- src/ll/utils/StringUtils.h | 238 ----- src/ll/utils/WinUtils.cpp | 49 - src/ll/utils/WinUtils.h | 13 - src/mc/ActorDefinitionIdentifier.h | 118 --- src/mc/CreativeItemRegistry.h | 9 - src/mc/IDataOutput.h | 39 - src/mc/Minecraft.h | 21 - src/mc/MinecraftCommands.h | 108 -- src/mc/_HeaderOutputPredefine.h | 154 --- src/mc/common/ARVRPlatform.h | 5 - src/mc/common/AbilitiesIndex.h | 27 - src/mc/common/AbilitiesLayer.h | 5 - src/mc/common/ActiveDirectoryAction.h | 5 - src/mc/common/ActorDamageCause.h | 42 - src/mc/common/ActorType.h | 158 --- src/mc/common/AddRemove.h | 12 - src/mc/common/AddTickingAreaStatus.h | 5 - src/mc/common/AdjustmentEffect.h | 5 - src/mc/common/AdvanceFrameResult.h | 5 - src/mc/common/AgentActionType.h | 24 - src/mc/common/AgentAnimation.h | 5 - src/mc/common/AgentTravelType.h | 5 - src/mc/common/AllExperiments.h | 5 - src/mc/common/AnimationComponentGroupType.h | 5 - src/mc/common/AnimationLoopMode.h | 5 - src/mc/common/AnimationMode.h | 12 - src/mc/common/AnvilDamage.h | 5 - src/mc/common/ApiId.h | 5 - src/mc/common/AppFocusState.h | 5 - src/mc/common/ArmorMaterialType.h | 5 - src/mc/common/ArmorSlot.h | 5 - src/mc/common/ArmorTextureType.h | 5 - src/mc/common/AssertDialogResponse.h | 5 - src/mc/common/AttachableSlotIndex.h | 5 - src/mc/common/AttachmentType.h | 5 - src/mc/common/AttributeBuffType.h | 5 - src/mc/common/AttributeModifierOperation.h | 12 - src/mc/common/AttributeOperands.h | 11 - src/mc/common/AutomaticID.h | 25 - src/mc/common/BaseGameVersion.h | 90 -- src/mc/common/BatteryStatus.h | 5 - src/mc/common/BedSleepingResult.h | 5 - src/mc/common/BehaviorStatus.h | 5 - src/mc/common/BigDripleafTilt.h | 5 - src/mc/common/BlendVersion.h | 10 - src/mc/common/BlockActorType.h | 59 -- src/mc/common/BlockColor.h | 5 - src/mc/common/BlockProperty.h | 56 - src/mc/common/BlockRenderLayer.h | 5 - src/mc/common/BlockShape.h | 5 - src/mc/common/BlockSlot.h | 12 - src/mc/common/BlockSupportType.h | 5 - src/mc/common/BlockTintType.h | 5 - src/mc/common/BoneAnimationRelativeMode.h | 5 - src/mc/common/BoneTransformType.h | 5 - src/mc/common/BookEditAction.h | 5 - src/mc/common/BossBarColor.h | 13 - src/mc/common/BossBarOverlay.h | 11 - src/mc/common/Brightness.h | 33 - src/mc/common/BucketFillType.h | 5 - src/mc/common/BuildPlatform.h | 20 - src/mc/common/BurnOdds.h | 5 - src/mc/common/CameraShakeAction.h | 9 - src/mc/common/CameraShakeType.h | 8 - src/mc/common/CanClimbIntoNode.h | 5 - src/mc/common/CanJumpIntoNode.h | 5 - src/mc/common/CauldronLiquidType.h | 5 - src/mc/common/CaveVinesVariant.h | 5 - src/mc/common/ChalkboardSize.h | 5 - src/mc/common/ChatRestrictionLevel.h | 8 - src/mc/common/ChemistryTableType.h | 5 - src/mc/common/ChiselType.h | 5 - src/mc/common/CircuitComponentType.h | 23 - src/mc/common/ClassroomSetting.h | 5 - src/mc/common/ClientInputLockCategory.h | 9 - src/mc/common/ClientInputLockType.h | 5 - src/mc/common/ClientPlayMode.h | 16 - src/mc/common/CloseStatusCode.h | 5 - src/mc/common/Color.h | 290 ----- src/mc/common/ColoredTorchColor.h | 5 - src/mc/common/CommandOutputType.h | 11 - src/mc/common/CompactionStatus.h | 5 - src/mc/common/CompoundTagUpdaterResult.h | 9 - src/mc/common/CompoundType.h | 5 - src/mc/common/Compressibility.h | 8 - src/mc/common/CoordinatorResult.h | 5 - src/mc/common/CopperType.h | 5 - src/mc/common/CoralColor.h | 5 - src/mc/common/CraftingDataEntryType.h | 16 - src/mc/common/CrashDumpLogStringID.h | 5 - src/mc/common/CreativeItemCategory.h | 5 - src/mc/common/CurrentCmdVersion.h | 42 - src/mc/common/DataItemType.h | 16 - src/mc/common/DataLoadHelperType.h | 9 - src/mc/common/DaylightCycle.h | 9 - src/mc/common/DeviceSunsetTier.h | 5 - src/mc/common/Difficulty.h | 15 - src/mc/common/DirtType.h | 5 - src/mc/common/DiskStatus.h | 5 - src/mc/common/DoublePlantType.h | 5 - src/mc/common/DripstoneThickness.h | 5 - src/mc/common/DwellerRole.h | 5 - .../DynamicPropertyDefinePropertyError.h | 5 - src/mc/common/EasingType.h | 5 - src/mc/common/EduControlPanelUpdateType.h | 5 - src/mc/common/EduShareMethodType.h | 5 - src/mc/common/EduShareUriType.h | 5 - src/mc/common/EducationEditionOffer.h | 9 - src/mc/common/EggCount.h | 5 - src/mc/common/ElementType.h | 5 - src/mc/common/EncryptedProxyReadMode.h | 5 - src/mc/common/EquipmentFilter.h | 5 - src/mc/common/EquipmentSlot.h | 28 - src/mc/common/ErrorInfo.h | 19 - src/mc/common/Exclude.h | 12 - src/mc/common/ExpressionOp.h | 5 - src/mc/common/FacingID.h | 25 - src/mc/common/FeatureRefTraits.h | 11 - src/mc/common/FertilizerType.h | 5 - src/mc/common/FileReadResult.h | 5 - src/mc/common/FilterParamOption.h | 5 - src/mc/common/FilterParamRequirement.h | 5 - src/mc/common/FilterParamType.h | 5 - src/mc/common/FilterSubject.h | 5 - src/mc/common/FlameOdds.h | 5 - src/mc/common/Flip.h | 5 - src/mc/common/FlowerPlacementType.h | 5 - src/mc/common/FlowerType.h | 5 - src/mc/common/FocusImpact.h | 5 - src/mc/common/FullscreenMode.h | 5 - src/mc/common/FunctionQueueOrder.h | 5 - src/mc/common/FunctionState.h | 5 - src/mc/common/GameType.h | 13 - src/mc/common/GameplayHandlerResult.h | 12 - src/mc/common/HandSlot.h | 5 - src/mc/common/HandlerResult.h | 5 - src/mc/common/HardcodedSpawnAreaType.h | 15 - src/mc/common/HashedString.h | 145 --- src/mc/common/HatchLevel.h | 5 - src/mc/common/HorseFlags.h | 5 - src/mc/common/IDType.h | 12 - src/mc/common/InHandUpdateType.h | 5 - src/mc/common/InMemoryAccessMode.h | 5 - src/mc/common/Include.h | 12 - src/mc/common/InitializationMethod.h | 5 - src/mc/common/InputMode.h | 11 - src/mc/common/IntegrityTokenResult.h | 21 - src/mc/common/InteractionResult.h | 12 - src/mc/common/InventorySourceType.h | 12 - src/mc/common/InventoryTransactionError.h | 15 - src/mc/common/InvertableFilter.h | 9 - src/mc/common/ItemColor.h | 5 - src/mc/common/JigsawJointType.h | 5 - src/mc/common/JumpType.h | 5 - src/mc/common/KeyFrameLerpStyle.h | 5 - src/mc/common/KnownPackType.h | 8 - src/mc/common/LabTableReactionType.h | 5 - src/mc/common/LastClickedSource.h | 5 - src/mc/common/LavaFlammable.h | 5 - src/mc/common/LeafSize.h | 5 - src/mc/common/LessonAction.h | 5 - src/mc/common/LevelSoundEvent.h | 437 -------- src/mc/common/LeverDirection.h | 5 - src/mc/common/LimboEntitiesVersion.h | 5 - src/mc/common/LoadingState.h | 5 - src/mc/common/LocatorStateChangeRequest.h | 5 - src/mc/common/LogArea.h | 5 - src/mc/common/LogAreaID.h | 53 - src/mc/common/LogLevel.h | 11 - src/mc/common/ManifestOrigin.h | 5 - src/mc/common/ManifestType.h | 5 - src/mc/common/MapType.h | 5 - src/mc/common/MaterialType.h | 60 -- src/mc/common/MinecartType.h | 5 - src/mc/common/MinecraftPacketIds.h | 213 ---- src/mc/common/Mirror.h | 10 - src/mc/common/MobSpawnMethod.h | 5 - src/mc/common/ModalFormCancelReason.h | 8 - src/mc/common/MolangCompileResult.h | 5 - src/mc/common/MonsterEggStoneType.h | 5 - src/mc/common/MoonPhases.h | 5 - src/mc/common/MovePredictionType.h | 5 - src/mc/common/MultiNoiseLegacyMode.h | 5 - src/mc/common/MultiplayerSettingsPacketType.h | 5 - src/mc/common/MushroomOuterType.h | 5 - src/mc/common/NewInteractionModel.h | 9 - src/mc/common/NewLeavesType.h | 5 - src/mc/common/NewLogType.h | 5 - src/mc/common/NodeType.h | 23 - src/mc/common/ObjectiveSortOrder.h | 12 - src/mc/common/OceanTempCategory.h | 5 - src/mc/common/OldLeavesType.h | 5 - src/mc/common/OldLogType.h | 5 - src/mc/common/OpCode.h | 5 - src/mc/common/OpenCodeMethod.h | 5 - src/mc/common/OperationGraphResult.h | 12 - src/mc/common/OperationMode.h | 5 - src/mc/common/OptionID.h | 5 - src/mc/common/OptionOwnerType.h | 5 - src/mc/common/OptionResetFlags.h | 5 - src/mc/common/Optional.h | 12 - src/mc/common/OptionalComponentWrapper.h | 12 - src/mc/common/OptionalGlobalT.h | 12 - src/mc/common/OsVersion.h | 5 - src/mc/common/OwnerPtrFactory.h | 17 - src/mc/common/OwnerPtrT.h | 12 - src/mc/common/POIType.h | 5 - .../common/PackAccessAssetGenerationResult.h | 5 - src/mc/common/PacketPriority.h | 11 - src/mc/common/PaletteColor.h | 5 - src/mc/common/ParticleType.h | 93 -- src/mc/common/PathCompletionType.h | 9 - src/mc/common/PermissionIPv6.h | 5 - src/mc/common/PermissionLAN.h | 5 - src/mc/common/PhotoType.h | 5 - src/mc/common/PillarAxis.h | 5 - src/mc/common/PistonState.h | 5 - src/mc/common/PlatformType.h | 5 - src/mc/common/PlayStatus.h | 16 - src/mc/common/PortalAxis.h | 5 - src/mc/common/PostProcessSettings.h | 5 - src/mc/common/ProfanityFilterContext.h | 5 - src/mc/common/ProjectileAnchor.h | 5 - src/mc/common/Projection.h | 5 - src/mc/common/PurchasePath.h | 5 - src/mc/common/QueueRequestResult.h | 5 - src/mc/common/RawInputType.h | 5 - src/mc/common/RedefinitionMode.h | 5 - src/mc/common/Ref.h | 289 ----- src/mc/common/RepairItemResult.h | 18 - src/mc/common/ReplayCorrectionResult.h | 5 - src/mc/common/ReplayStateMode.h | 5 - src/mc/common/RespawnAnimation.h | 5 - src/mc/common/Result.h | 78 -- src/mc/common/ResultCode.h | 9 - src/mc/common/Rotation.h | 11 - src/mc/common/SandType.h | 5 - src/mc/common/SandstoneType.h | 5 - src/mc/common/SaplingType.h | 5 - src/mc/common/ScalarOptional.h | 12 - src/mc/common/ScorePacketType.h | 5 - src/mc/common/ScoreboardIdentityPacketType.h | 5 - src/mc/common/SeagrassType.h | 5 - src/mc/common/SemVersion.h | 129 --- src/mc/common/SemanticConstraint.h | 12 - src/mc/common/ServerAuthMovementMode.h | 9 - src/mc/common/ServerConnectivityTestResult.h | 5 - src/mc/common/SettingsScreenMode.h | 5 - src/mc/common/ShapeType.h | 8 - src/mc/common/SharePtrRefTraits.h | 14 - src/mc/common/SharedPtr.h | 99 -- src/mc/common/Side.h | 5 - src/mc/common/SignTextSide.h | 5 - src/mc/common/SimulationType.h | 5 - src/mc/common/SkeletalHierarchyIndex.h | 5 - src/mc/common/SoftEnumUpdateType.h | 9 - src/mc/common/SolidityCheckType.h | 5 - src/mc/common/SpawnPositionType.h | 5 - src/mc/common/SpongeType.h | 5 - src/mc/common/StackRefResultT.h | 12 - src/mc/common/StalkThickness.h | 5 - src/mc/common/StoneBrickType.h | 5 - src/mc/common/StoneSlabType.h | 5 - src/mc/common/StoneSlabType2.h | 5 - src/mc/common/StoneSlabType3.h | 5 - src/mc/common/StoneSlabType4.h | 5 - src/mc/common/StoneType.h | 5 - src/mc/common/StorageVersion.h | 17 - .../common/StructureBlockPaletteLoadResult.h | 5 - src/mc/common/StructureDeleteResult.h | 5 - src/mc/common/StructureLoadResult.h | 5 - src/mc/common/SubClientId.h | 12 - src/mc/common/TagRegistry.h | 12 - src/mc/common/TallGrassType.h | 5 - src/mc/common/TargetSelectionMethod.h | 8 - src/mc/common/TaskGroupState.h | 5 - src/mc/common/TaskQueuePortStatus.h | 5 - src/mc/common/TaskRunResult.h | 5 - src/mc/common/TeleportAnalysis.h | 5 - src/mc/common/TempEPtrBase.h | 41 - src/mc/common/TextPacketType.h | 18 - src/mc/common/ThermalState.h | 5 - src/mc/common/ThreadLocalObject.h | 20 - src/mc/common/TickingAreaLoadMode.h | 5 - src/mc/common/TickingQueueType.h | 5 - src/mc/common/TorchFacing.h | 5 - src/mc/common/TrackerType.h | 5 - src/mc/common/TransactionStatus.h | 5 - src/mc/common/TransportLayer.h | 5 - src/mc/common/TravelType.h | 5 - src/mc/common/UIScalingRules.h | 5 - src/mc/common/UploadError.h | 5 - src/mc/common/UseAnimation.h | 5 - src/mc/common/UserGeneratedUriSource.h | 5 - src/mc/common/VRControllerType.h | 5 - src/mc/common/ValueOrRef.h | 16 - src/mc/common/VanillaBiomeTypes.h | 25 - src/mc/common/VerticalHalfEnum.h | 5 - src/mc/common/ViewT.h | 12 - src/mc/common/WSConnectionResult.h | 5 - src/mc/common/WallConnectionType.h | 5 - src/mc/common/WatchdogTerminateReason.h | 5 - src/mc/common/WeakPtr.h | 101 -- src/mc/common/WeakRefT.h | 12 - src/mc/common/WeirdoDirection.h | 5 - src/mc/common/WitherBossPreAIStepResult.h | 5 - src/mc/common/WoodType.h | 5 - src/mc/common/WorldTransferResultType.h | 16 - src/mc/common/WorldVersion.h | 8 - src/mc/common/XTaskQueueDispatchMode.h | 5 - src/mc/common/XTaskQueuePort.h | 5 - src/mc/common/optional_ref.h | 115 -- src/mc/common/referenced_ptr.h | 12 - src/mc/common/typeid_t.h | 54 - src/mc/item/Item.h | 424 -------- src/mc/item/ItemInstance.h | 57 - src/mc/item/ItemRegistryManager.h | 73 -- src/mc/item/ItemRegistryRef.h | 230 ---- src/mc/item/ItemStack.h | 134 --- src/mc/item/ItemStackBase.h | 606 ----------- src/mc/math/AABB.h | 148 --- src/mc/math/BlockPos.h | 68 -- src/mc/math/Vec2.h | 45 - src/mc/math/Vec3.h | 79 -- src/mc/math/vector/Vecs.h | 16 - src/mc/math/vector/boolN.h | 21 - src/mc/math/vector/component/BoolN.h | 109 -- src/mc/math/vector/component/FloatN.h | 104 -- src/mc/math/vector/component/IntN.h | 63 -- .../vector/component/base/CommutativeGroup.h | 129 --- src/mc/math/vector/component/base/Field.h | 185 ---- .../math/vector/component/base/VectorBase.h | 165 --- src/mc/math/vector/component/base/vecN.h | 189 ---- src/mc/math/vector/doubleN.h | 21 - src/mc/math/vector/floatN.h | 21 - src/mc/math/vector/intN.h | 21 - src/mc/math/vector/longlongN.h | 21 - src/mc/nbt/ByteArrayTag.h | 53 - src/mc/nbt/ByteTag.h | 59 -- src/mc/nbt/CompoundTag.h | 214 ---- src/mc/nbt/CompoundTagVariant.h | 93 -- src/mc/nbt/DoubleTag.h | 51 - src/mc/nbt/EndTag.h | 36 - src/mc/nbt/FloatTag.h | 55 - src/mc/nbt/Int64Tag.h | 52 - src/mc/nbt/IntArrayTag.h | 53 - src/mc/nbt/IntTag.h | 55 - src/mc/nbt/ListTag.h | 126 --- src/mc/nbt/NbtIo.h | 16 - src/mc/nbt/ShortTag.h | 51 - src/mc/nbt/StringTag.h | 55 - src/mc/nbt/Tag.h | 98 -- src/mc/nbt/TagMemoryChunk.cpp | 22 - src/mc/nbt/TagMemoryChunk.h | 38 - src/mc/network/BinaryStream.h | 46 - src/mc/network/CraftingDataPacket.h | 43 - src/mc/network/IPacketHandlerDispatcher.h | 12 - src/mc/network/NetworkPeer.h | 91 -- src/mc/network/Packet.h | 76 -- src/mc/network/ReadOnlyBinaryStream.h | 123 --- src/mc/network/serialize.h | 11 - src/mc/util/ItemColorUtil.h | 39 - src/mc/util/Spawner.h | 44 - src/mc/util/json/Value.h | 394 ------- src/mc/util/json/ValueType.h | 18 - src/mc/world/ActorFactory.h | 27 - src/mc/world/Biome.h | 178 ---- src/mc/world/BiomeRegistry.h | 61 -- src/mc/world/Block.h | 611 ----------- src/mc/world/BlockLegacy.h | 637 ----------- src/mc/world/BlockPalette.h | 46 - src/mc/world/BlockSource.h | 9 - src/mc/world/BlockTypeRegistry.h | 239 ----- src/mc/world/Dimension.h | 19 - src/mc/world/Direction.h | 54 - src/mc/world/Experiments.h | 72 -- src/mc/world/ItemTag.h | 13 - src/mc/world/Level.h | 36 - src/mc/world/LevelData.h | 24 - src/mc/world/Material.h | 93 -- src/mc/world/Mob.h | 40 - src/mc/world/VanillaBlockTags.h | 95 -- src/mc/world/VanillaItemTags.h | 195 ---- xmake.lua | 202 ++-- 423 files changed, 2033 insertions(+), 16007 deletions(-) create mode 100644 .clang-format create mode 100644 .clang-tidy create mode 100644 .clangd create mode 100644 .gitattributes create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/release.yml delete mode 100644 bdsversion create mode 100644 manifest.json create mode 100644 scripts/after_build.lua delete mode 100644 scripts/format_all.py delete mode 100644 scripts/localbdslibrary.lua delete mode 100644 src/DLLMain.cpp delete mode 100644 src/DataExtractor.cpp delete mode 100644 src/DataExtractor.h create mode 100644 src/DllMain.cpp create mode 100644 src/Plugin.cpp create mode 100644 src/Plugin.h delete mode 100644 src/ll/base/Concepts.h delete mode 100644 src/ll/base/FixedString.h delete mode 100644 src/ll/base/Hash.h delete mode 100644 src/ll/base/Macro.h delete mode 100644 src/ll/base/Meta.h delete mode 100644 src/ll/base/StdInt.h delete mode 100644 src/ll/memory/Closure.cpp delete mode 100644 src/ll/memory/Closure.h delete mode 100644 src/ll/memory/Hook.cpp delete mode 100644 src/ll/memory/Hook.h delete mode 100644 src/ll/memory/Memory.cpp delete mode 100644 src/ll/memory/Memory.h delete mode 100644 src/ll/memory/PatchHelper.cpp delete mode 100644 src/ll/memory/PatchHelper.h delete mode 100644 src/ll/utils/Hash.h delete mode 100644 src/ll/utils/StringUtils.cpp delete mode 100644 src/ll/utils/StringUtils.h delete mode 100644 src/ll/utils/WinUtils.cpp delete mode 100644 src/ll/utils/WinUtils.h delete mode 100644 src/mc/ActorDefinitionIdentifier.h delete mode 100644 src/mc/CreativeItemRegistry.h delete mode 100644 src/mc/IDataOutput.h delete mode 100644 src/mc/Minecraft.h delete mode 100644 src/mc/MinecraftCommands.h delete mode 100644 src/mc/_HeaderOutputPredefine.h delete mode 100644 src/mc/common/ARVRPlatform.h delete mode 100644 src/mc/common/AbilitiesIndex.h delete mode 100644 src/mc/common/AbilitiesLayer.h delete mode 100644 src/mc/common/ActiveDirectoryAction.h delete mode 100644 src/mc/common/ActorDamageCause.h delete mode 100644 src/mc/common/ActorType.h delete mode 100644 src/mc/common/AddRemove.h delete mode 100644 src/mc/common/AddTickingAreaStatus.h delete mode 100644 src/mc/common/AdjustmentEffect.h delete mode 100644 src/mc/common/AdvanceFrameResult.h delete mode 100644 src/mc/common/AgentActionType.h delete mode 100644 src/mc/common/AgentAnimation.h delete mode 100644 src/mc/common/AgentTravelType.h delete mode 100644 src/mc/common/AllExperiments.h delete mode 100644 src/mc/common/AnimationComponentGroupType.h delete mode 100644 src/mc/common/AnimationLoopMode.h delete mode 100644 src/mc/common/AnimationMode.h delete mode 100644 src/mc/common/AnvilDamage.h delete mode 100644 src/mc/common/ApiId.h delete mode 100644 src/mc/common/AppFocusState.h delete mode 100644 src/mc/common/ArmorMaterialType.h delete mode 100644 src/mc/common/ArmorSlot.h delete mode 100644 src/mc/common/ArmorTextureType.h delete mode 100644 src/mc/common/AssertDialogResponse.h delete mode 100644 src/mc/common/AttachableSlotIndex.h delete mode 100644 src/mc/common/AttachmentType.h delete mode 100644 src/mc/common/AttributeBuffType.h delete mode 100644 src/mc/common/AttributeModifierOperation.h delete mode 100644 src/mc/common/AttributeOperands.h delete mode 100644 src/mc/common/AutomaticID.h delete mode 100644 src/mc/common/BaseGameVersion.h delete mode 100644 src/mc/common/BatteryStatus.h delete mode 100644 src/mc/common/BedSleepingResult.h delete mode 100644 src/mc/common/BehaviorStatus.h delete mode 100644 src/mc/common/BigDripleafTilt.h delete mode 100644 src/mc/common/BlendVersion.h delete mode 100644 src/mc/common/BlockActorType.h delete mode 100644 src/mc/common/BlockColor.h delete mode 100644 src/mc/common/BlockProperty.h delete mode 100644 src/mc/common/BlockRenderLayer.h delete mode 100644 src/mc/common/BlockShape.h delete mode 100644 src/mc/common/BlockSlot.h delete mode 100644 src/mc/common/BlockSupportType.h delete mode 100644 src/mc/common/BlockTintType.h delete mode 100644 src/mc/common/BoneAnimationRelativeMode.h delete mode 100644 src/mc/common/BoneTransformType.h delete mode 100644 src/mc/common/BookEditAction.h delete mode 100644 src/mc/common/BossBarColor.h delete mode 100644 src/mc/common/BossBarOverlay.h delete mode 100644 src/mc/common/Brightness.h delete mode 100644 src/mc/common/BucketFillType.h delete mode 100644 src/mc/common/BuildPlatform.h delete mode 100644 src/mc/common/BurnOdds.h delete mode 100644 src/mc/common/CameraShakeAction.h delete mode 100644 src/mc/common/CameraShakeType.h delete mode 100644 src/mc/common/CanClimbIntoNode.h delete mode 100644 src/mc/common/CanJumpIntoNode.h delete mode 100644 src/mc/common/CauldronLiquidType.h delete mode 100644 src/mc/common/CaveVinesVariant.h delete mode 100644 src/mc/common/ChalkboardSize.h delete mode 100644 src/mc/common/ChatRestrictionLevel.h delete mode 100644 src/mc/common/ChemistryTableType.h delete mode 100644 src/mc/common/ChiselType.h delete mode 100644 src/mc/common/CircuitComponentType.h delete mode 100644 src/mc/common/ClassroomSetting.h delete mode 100644 src/mc/common/ClientInputLockCategory.h delete mode 100644 src/mc/common/ClientInputLockType.h delete mode 100644 src/mc/common/ClientPlayMode.h delete mode 100644 src/mc/common/CloseStatusCode.h delete mode 100644 src/mc/common/Color.h delete mode 100644 src/mc/common/ColoredTorchColor.h delete mode 100644 src/mc/common/CommandOutputType.h delete mode 100644 src/mc/common/CompactionStatus.h delete mode 100644 src/mc/common/CompoundTagUpdaterResult.h delete mode 100644 src/mc/common/CompoundType.h delete mode 100644 src/mc/common/Compressibility.h delete mode 100644 src/mc/common/CoordinatorResult.h delete mode 100644 src/mc/common/CopperType.h delete mode 100644 src/mc/common/CoralColor.h delete mode 100644 src/mc/common/CraftingDataEntryType.h delete mode 100644 src/mc/common/CrashDumpLogStringID.h delete mode 100644 src/mc/common/CreativeItemCategory.h delete mode 100644 src/mc/common/CurrentCmdVersion.h delete mode 100644 src/mc/common/DataItemType.h delete mode 100644 src/mc/common/DataLoadHelperType.h delete mode 100644 src/mc/common/DaylightCycle.h delete mode 100644 src/mc/common/DeviceSunsetTier.h delete mode 100644 src/mc/common/Difficulty.h delete mode 100644 src/mc/common/DirtType.h delete mode 100644 src/mc/common/DiskStatus.h delete mode 100644 src/mc/common/DoublePlantType.h delete mode 100644 src/mc/common/DripstoneThickness.h delete mode 100644 src/mc/common/DwellerRole.h delete mode 100644 src/mc/common/DynamicPropertyDefinePropertyError.h delete mode 100644 src/mc/common/EasingType.h delete mode 100644 src/mc/common/EduControlPanelUpdateType.h delete mode 100644 src/mc/common/EduShareMethodType.h delete mode 100644 src/mc/common/EduShareUriType.h delete mode 100644 src/mc/common/EducationEditionOffer.h delete mode 100644 src/mc/common/EggCount.h delete mode 100644 src/mc/common/ElementType.h delete mode 100644 src/mc/common/EncryptedProxyReadMode.h delete mode 100644 src/mc/common/EquipmentFilter.h delete mode 100644 src/mc/common/EquipmentSlot.h delete mode 100644 src/mc/common/ErrorInfo.h delete mode 100644 src/mc/common/Exclude.h delete mode 100644 src/mc/common/ExpressionOp.h delete mode 100644 src/mc/common/FacingID.h delete mode 100644 src/mc/common/FeatureRefTraits.h delete mode 100644 src/mc/common/FertilizerType.h delete mode 100644 src/mc/common/FileReadResult.h delete mode 100644 src/mc/common/FilterParamOption.h delete mode 100644 src/mc/common/FilterParamRequirement.h delete mode 100644 src/mc/common/FilterParamType.h delete mode 100644 src/mc/common/FilterSubject.h delete mode 100644 src/mc/common/FlameOdds.h delete mode 100644 src/mc/common/Flip.h delete mode 100644 src/mc/common/FlowerPlacementType.h delete mode 100644 src/mc/common/FlowerType.h delete mode 100644 src/mc/common/FocusImpact.h delete mode 100644 src/mc/common/FullscreenMode.h delete mode 100644 src/mc/common/FunctionQueueOrder.h delete mode 100644 src/mc/common/FunctionState.h delete mode 100644 src/mc/common/GameType.h delete mode 100644 src/mc/common/GameplayHandlerResult.h delete mode 100644 src/mc/common/HandSlot.h delete mode 100644 src/mc/common/HandlerResult.h delete mode 100644 src/mc/common/HardcodedSpawnAreaType.h delete mode 100644 src/mc/common/HashedString.h delete mode 100644 src/mc/common/HatchLevel.h delete mode 100644 src/mc/common/HorseFlags.h delete mode 100644 src/mc/common/IDType.h delete mode 100644 src/mc/common/InHandUpdateType.h delete mode 100644 src/mc/common/InMemoryAccessMode.h delete mode 100644 src/mc/common/Include.h delete mode 100644 src/mc/common/InitializationMethod.h delete mode 100644 src/mc/common/InputMode.h delete mode 100644 src/mc/common/IntegrityTokenResult.h delete mode 100644 src/mc/common/InteractionResult.h delete mode 100644 src/mc/common/InventorySourceType.h delete mode 100644 src/mc/common/InventoryTransactionError.h delete mode 100644 src/mc/common/InvertableFilter.h delete mode 100644 src/mc/common/ItemColor.h delete mode 100644 src/mc/common/JigsawJointType.h delete mode 100644 src/mc/common/JumpType.h delete mode 100644 src/mc/common/KeyFrameLerpStyle.h delete mode 100644 src/mc/common/KnownPackType.h delete mode 100644 src/mc/common/LabTableReactionType.h delete mode 100644 src/mc/common/LastClickedSource.h delete mode 100644 src/mc/common/LavaFlammable.h delete mode 100644 src/mc/common/LeafSize.h delete mode 100644 src/mc/common/LessonAction.h delete mode 100644 src/mc/common/LevelSoundEvent.h delete mode 100644 src/mc/common/LeverDirection.h delete mode 100644 src/mc/common/LimboEntitiesVersion.h delete mode 100644 src/mc/common/LoadingState.h delete mode 100644 src/mc/common/LocatorStateChangeRequest.h delete mode 100644 src/mc/common/LogArea.h delete mode 100644 src/mc/common/LogAreaID.h delete mode 100644 src/mc/common/LogLevel.h delete mode 100644 src/mc/common/ManifestOrigin.h delete mode 100644 src/mc/common/ManifestType.h delete mode 100644 src/mc/common/MapType.h delete mode 100644 src/mc/common/MaterialType.h delete mode 100644 src/mc/common/MinecartType.h delete mode 100644 src/mc/common/MinecraftPacketIds.h delete mode 100644 src/mc/common/Mirror.h delete mode 100644 src/mc/common/MobSpawnMethod.h delete mode 100644 src/mc/common/ModalFormCancelReason.h delete mode 100644 src/mc/common/MolangCompileResult.h delete mode 100644 src/mc/common/MonsterEggStoneType.h delete mode 100644 src/mc/common/MoonPhases.h delete mode 100644 src/mc/common/MovePredictionType.h delete mode 100644 src/mc/common/MultiNoiseLegacyMode.h delete mode 100644 src/mc/common/MultiplayerSettingsPacketType.h delete mode 100644 src/mc/common/MushroomOuterType.h delete mode 100644 src/mc/common/NewInteractionModel.h delete mode 100644 src/mc/common/NewLeavesType.h delete mode 100644 src/mc/common/NewLogType.h delete mode 100644 src/mc/common/NodeType.h delete mode 100644 src/mc/common/ObjectiveSortOrder.h delete mode 100644 src/mc/common/OceanTempCategory.h delete mode 100644 src/mc/common/OldLeavesType.h delete mode 100644 src/mc/common/OldLogType.h delete mode 100644 src/mc/common/OpCode.h delete mode 100644 src/mc/common/OpenCodeMethod.h delete mode 100644 src/mc/common/OperationGraphResult.h delete mode 100644 src/mc/common/OperationMode.h delete mode 100644 src/mc/common/OptionID.h delete mode 100644 src/mc/common/OptionOwnerType.h delete mode 100644 src/mc/common/OptionResetFlags.h delete mode 100644 src/mc/common/Optional.h delete mode 100644 src/mc/common/OptionalComponentWrapper.h delete mode 100644 src/mc/common/OptionalGlobalT.h delete mode 100644 src/mc/common/OsVersion.h delete mode 100644 src/mc/common/OwnerPtrFactory.h delete mode 100644 src/mc/common/OwnerPtrT.h delete mode 100644 src/mc/common/POIType.h delete mode 100644 src/mc/common/PackAccessAssetGenerationResult.h delete mode 100644 src/mc/common/PacketPriority.h delete mode 100644 src/mc/common/PaletteColor.h delete mode 100644 src/mc/common/ParticleType.h delete mode 100644 src/mc/common/PathCompletionType.h delete mode 100644 src/mc/common/PermissionIPv6.h delete mode 100644 src/mc/common/PermissionLAN.h delete mode 100644 src/mc/common/PhotoType.h delete mode 100644 src/mc/common/PillarAxis.h delete mode 100644 src/mc/common/PistonState.h delete mode 100644 src/mc/common/PlatformType.h delete mode 100644 src/mc/common/PlayStatus.h delete mode 100644 src/mc/common/PortalAxis.h delete mode 100644 src/mc/common/PostProcessSettings.h delete mode 100644 src/mc/common/ProfanityFilterContext.h delete mode 100644 src/mc/common/ProjectileAnchor.h delete mode 100644 src/mc/common/Projection.h delete mode 100644 src/mc/common/PurchasePath.h delete mode 100644 src/mc/common/QueueRequestResult.h delete mode 100644 src/mc/common/RawInputType.h delete mode 100644 src/mc/common/RedefinitionMode.h delete mode 100644 src/mc/common/Ref.h delete mode 100644 src/mc/common/RepairItemResult.h delete mode 100644 src/mc/common/ReplayCorrectionResult.h delete mode 100644 src/mc/common/ReplayStateMode.h delete mode 100644 src/mc/common/RespawnAnimation.h delete mode 100644 src/mc/common/Result.h delete mode 100644 src/mc/common/ResultCode.h delete mode 100644 src/mc/common/Rotation.h delete mode 100644 src/mc/common/SandType.h delete mode 100644 src/mc/common/SandstoneType.h delete mode 100644 src/mc/common/SaplingType.h delete mode 100644 src/mc/common/ScalarOptional.h delete mode 100644 src/mc/common/ScorePacketType.h delete mode 100644 src/mc/common/ScoreboardIdentityPacketType.h delete mode 100644 src/mc/common/SeagrassType.h delete mode 100644 src/mc/common/SemVersion.h delete mode 100644 src/mc/common/SemanticConstraint.h delete mode 100644 src/mc/common/ServerAuthMovementMode.h delete mode 100644 src/mc/common/ServerConnectivityTestResult.h delete mode 100644 src/mc/common/SettingsScreenMode.h delete mode 100644 src/mc/common/ShapeType.h delete mode 100644 src/mc/common/SharePtrRefTraits.h delete mode 100644 src/mc/common/SharedPtr.h delete mode 100644 src/mc/common/Side.h delete mode 100644 src/mc/common/SignTextSide.h delete mode 100644 src/mc/common/SimulationType.h delete mode 100644 src/mc/common/SkeletalHierarchyIndex.h delete mode 100644 src/mc/common/SoftEnumUpdateType.h delete mode 100644 src/mc/common/SolidityCheckType.h delete mode 100644 src/mc/common/SpawnPositionType.h delete mode 100644 src/mc/common/SpongeType.h delete mode 100644 src/mc/common/StackRefResultT.h delete mode 100644 src/mc/common/StalkThickness.h delete mode 100644 src/mc/common/StoneBrickType.h delete mode 100644 src/mc/common/StoneSlabType.h delete mode 100644 src/mc/common/StoneSlabType2.h delete mode 100644 src/mc/common/StoneSlabType3.h delete mode 100644 src/mc/common/StoneSlabType4.h delete mode 100644 src/mc/common/StoneType.h delete mode 100644 src/mc/common/StorageVersion.h delete mode 100644 src/mc/common/StructureBlockPaletteLoadResult.h delete mode 100644 src/mc/common/StructureDeleteResult.h delete mode 100644 src/mc/common/StructureLoadResult.h delete mode 100644 src/mc/common/SubClientId.h delete mode 100644 src/mc/common/TagRegistry.h delete mode 100644 src/mc/common/TallGrassType.h delete mode 100644 src/mc/common/TargetSelectionMethod.h delete mode 100644 src/mc/common/TaskGroupState.h delete mode 100644 src/mc/common/TaskQueuePortStatus.h delete mode 100644 src/mc/common/TaskRunResult.h delete mode 100644 src/mc/common/TeleportAnalysis.h delete mode 100644 src/mc/common/TempEPtrBase.h delete mode 100644 src/mc/common/TextPacketType.h delete mode 100644 src/mc/common/ThermalState.h delete mode 100644 src/mc/common/ThreadLocalObject.h delete mode 100644 src/mc/common/TickingAreaLoadMode.h delete mode 100644 src/mc/common/TickingQueueType.h delete mode 100644 src/mc/common/TorchFacing.h delete mode 100644 src/mc/common/TrackerType.h delete mode 100644 src/mc/common/TransactionStatus.h delete mode 100644 src/mc/common/TransportLayer.h delete mode 100644 src/mc/common/TravelType.h delete mode 100644 src/mc/common/UIScalingRules.h delete mode 100644 src/mc/common/UploadError.h delete mode 100644 src/mc/common/UseAnimation.h delete mode 100644 src/mc/common/UserGeneratedUriSource.h delete mode 100644 src/mc/common/VRControllerType.h delete mode 100644 src/mc/common/ValueOrRef.h delete mode 100644 src/mc/common/VanillaBiomeTypes.h delete mode 100644 src/mc/common/VerticalHalfEnum.h delete mode 100644 src/mc/common/ViewT.h delete mode 100644 src/mc/common/WSConnectionResult.h delete mode 100644 src/mc/common/WallConnectionType.h delete mode 100644 src/mc/common/WatchdogTerminateReason.h delete mode 100644 src/mc/common/WeakPtr.h delete mode 100644 src/mc/common/WeakRefT.h delete mode 100644 src/mc/common/WeirdoDirection.h delete mode 100644 src/mc/common/WitherBossPreAIStepResult.h delete mode 100644 src/mc/common/WoodType.h delete mode 100644 src/mc/common/WorldTransferResultType.h delete mode 100644 src/mc/common/WorldVersion.h delete mode 100644 src/mc/common/XTaskQueueDispatchMode.h delete mode 100644 src/mc/common/XTaskQueuePort.h delete mode 100644 src/mc/common/optional_ref.h delete mode 100644 src/mc/common/referenced_ptr.h delete mode 100644 src/mc/common/typeid_t.h delete mode 100644 src/mc/item/Item.h delete mode 100644 src/mc/item/ItemInstance.h delete mode 100644 src/mc/item/ItemRegistryManager.h delete mode 100644 src/mc/item/ItemRegistryRef.h delete mode 100644 src/mc/item/ItemStack.h delete mode 100644 src/mc/item/ItemStackBase.h delete mode 100644 src/mc/math/AABB.h delete mode 100644 src/mc/math/BlockPos.h delete mode 100644 src/mc/math/Vec2.h delete mode 100644 src/mc/math/Vec3.h delete mode 100644 src/mc/math/vector/Vecs.h delete mode 100644 src/mc/math/vector/boolN.h delete mode 100644 src/mc/math/vector/component/BoolN.h delete mode 100644 src/mc/math/vector/component/FloatN.h delete mode 100644 src/mc/math/vector/component/IntN.h delete mode 100644 src/mc/math/vector/component/base/CommutativeGroup.h delete mode 100644 src/mc/math/vector/component/base/Field.h delete mode 100644 src/mc/math/vector/component/base/VectorBase.h delete mode 100644 src/mc/math/vector/component/base/vecN.h delete mode 100644 src/mc/math/vector/doubleN.h delete mode 100644 src/mc/math/vector/floatN.h delete mode 100644 src/mc/math/vector/intN.h delete mode 100644 src/mc/math/vector/longlongN.h delete mode 100644 src/mc/nbt/ByteArrayTag.h delete mode 100644 src/mc/nbt/ByteTag.h delete mode 100644 src/mc/nbt/CompoundTag.h delete mode 100644 src/mc/nbt/CompoundTagVariant.h delete mode 100644 src/mc/nbt/DoubleTag.h delete mode 100644 src/mc/nbt/EndTag.h delete mode 100644 src/mc/nbt/FloatTag.h delete mode 100644 src/mc/nbt/Int64Tag.h delete mode 100644 src/mc/nbt/IntArrayTag.h delete mode 100644 src/mc/nbt/IntTag.h delete mode 100644 src/mc/nbt/ListTag.h delete mode 100644 src/mc/nbt/NbtIo.h delete mode 100644 src/mc/nbt/ShortTag.h delete mode 100644 src/mc/nbt/StringTag.h delete mode 100644 src/mc/nbt/Tag.h delete mode 100644 src/mc/nbt/TagMemoryChunk.cpp delete mode 100644 src/mc/nbt/TagMemoryChunk.h delete mode 100644 src/mc/network/BinaryStream.h delete mode 100644 src/mc/network/CraftingDataPacket.h delete mode 100644 src/mc/network/IPacketHandlerDispatcher.h delete mode 100644 src/mc/network/NetworkPeer.h delete mode 100644 src/mc/network/Packet.h delete mode 100644 src/mc/network/ReadOnlyBinaryStream.h delete mode 100644 src/mc/network/serialize.h delete mode 100644 src/mc/util/ItemColorUtil.h delete mode 100644 src/mc/util/Spawner.h delete mode 100644 src/mc/util/json/Value.h delete mode 100644 src/mc/util/json/ValueType.h delete mode 100644 src/mc/world/ActorFactory.h delete mode 100644 src/mc/world/Biome.h delete mode 100644 src/mc/world/BiomeRegistry.h delete mode 100644 src/mc/world/Block.h delete mode 100644 src/mc/world/BlockLegacy.h delete mode 100644 src/mc/world/BlockPalette.h delete mode 100644 src/mc/world/BlockSource.h delete mode 100644 src/mc/world/BlockTypeRegistry.h delete mode 100644 src/mc/world/Dimension.h delete mode 100644 src/mc/world/Direction.h delete mode 100644 src/mc/world/Experiments.h delete mode 100644 src/mc/world/ItemTag.h delete mode 100644 src/mc/world/Level.h delete mode 100644 src/mc/world/LevelData.h delete mode 100644 src/mc/world/Material.h delete mode 100644 src/mc/world/Mob.h delete mode 100644 src/mc/world/VanillaBlockTags.h delete mode 100644 src/mc/world/VanillaItemTags.h diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..4a24aec43 --- /dev/null +++ b/.clang-format @@ -0,0 +1,46 @@ +BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: BlockIndent +AlignArrayOfStructures: Left +AlignConsecutiveDeclarations: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false +AlignConsecutiveAssignments: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: true + PadOperators: true +AlignConsecutiveMacros: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowAllArgumentsOnNextLine: false +AlignOperands: AlignAfterOperator +AlignConsecutiveBitFields: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false +AllowShortLambdasOnASingleLine: All +AllowShortBlocksOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: AllIfsAndElse +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakTemplateDeclarations: 'Yes' +BinPackArguments: false +BinPackParameters: false +BreakBeforeBraces: Custom +BreakBeforeBinaryOperators: NonAssignment +ColumnLimit: 120 +CommentPragmas: '^ IWYU pragma:' +ConstructorInitializerIndentWidth: 0 +IndentWidth: 4 +Language: Cpp +MaxEmptyLinesToKeep: 2 +PackConstructorInitializers: CurrentLine +PointerAlignment: Left +TabWidth: 4 +UseTab: Never +SortIncludes: CaseSensitive diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000..915eee83b --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,145 @@ +# Generated from CLion Inspection settings +--- +Checks: '-*, +bugprone-argument-comment, +bugprone-assert-side-effect, +bugprone-bad-signal-to-kill-thread, +bugprone-branch-clone, +bugprone-copy-constructor-init, +bugprone-dangling-handle, +bugprone-dynamic-static-initializers, +bugprone-fold-init-type, +bugprone-forward-declaration-namespace, +bugprone-forwarding-reference-overload, +bugprone-inaccurate-erase, +bugprone-incorrect-roundings, +bugprone-integer-division, +bugprone-lambda-function-name, +bugprone-macro-parentheses, +bugprone-macro-repeated-side-effects, +bugprone-misplaced-operator-in-strlen-in-alloc, +bugprone-misplaced-pointer-arithmetic-in-alloc, +bugprone-misplaced-widening-cast, +bugprone-move-forwarding-reference, +bugprone-multiple-statement-macro, +bugprone-no-escape, +bugprone-not-null-terminated-result, +bugprone-parent-virtual-call, +bugprone-posix-return, +bugprone-reserved-identifier, +bugprone-sizeof-container, +bugprone-sizeof-expression, +bugprone-spuriously-wake-up-functions, +bugprone-string-constructor, +bugprone-string-integer-assignment, +bugprone-string-literal-with-embedded-nul, +bugprone-suspicious-enum-usage, +bugprone-suspicious-include, +bugprone-suspicious-memory-comparison, +bugprone-suspicious-memset-usage, +bugprone-suspicious-missing-comma, +bugprone-suspicious-semicolon, +bugprone-suspicious-string-compare, +bugprone-swapped-arguments, +bugprone-terminating-continue, +bugprone-throw-keyword-missing, +bugprone-too-small-loop-variable, +bugprone-undefined-memory-manipulation, +bugprone-undelegated-constructor, +bugprone-unhandled-self-assignment, +bugprone-unused-raii, +bugprone-unused-return-value, +bugprone-use-after-move, +bugprone-virtual-near-miss, +cert-dcl21-cpp, +cert-dcl58-cpp, +cert-err34-c, +cert-err52-cpp, +cert-err60-cpp, +cert-flp30-c, +cert-msc50-cpp, +cert-msc51-cpp, +cert-str34-c, +cppcoreguidelines-interfaces-global-init, +cppcoreguidelines-narrowing-conversions, +cppcoreguidelines-pro-type-member-init, +cppcoreguidelines-slicing, +google-default-arguments, +google-explicit-constructor, +google-runtime-operator, +hicpp-exception-baseclass, +hicpp-multiway-paths-covered, +misc-misplaced-const, +misc-new-delete-overloads, +misc-non-copyable-objects, +misc-throw-by-value-catch-by-reference, +misc-unconventional-assign-operator, +misc-uniqueptr-reset-release, +modernize-avoid-bind, +modernize-concat-nested-namespaces, +modernize-deprecated-headers, +modernize-deprecated-ios-base-aliases, +modernize-loop-convert, +modernize-make-shared, +modernize-make-unique, +modernize-pass-by-value, +modernize-raw-string-literal, +modernize-redundant-void-arg, +modernize-replace-auto-ptr, +modernize-replace-disallow-copy-and-assign-macro, +modernize-replace-random-shuffle, +modernize-return-braced-init-list, +modernize-shrink-to-fit, +modernize-unary-static-assert, +modernize-use-auto, +modernize-use-bool-literals, +modernize-use-emplace, +modernize-use-equals-default, +modernize-use-equals-delete, +modernize-use-nodiscard, +modernize-use-noexcept, +modernize-use-nullptr, +modernize-use-override, +modernize-use-transparent-functors, +modernize-use-uncaught-exceptions, +mpi-buffer-deref, +mpi-type-mismatch, +openmp-use-default-none, +performance-faster-string-find, +performance-for-range-copy, +performance-implicit-conversion-in-loop, +performance-inefficient-algorithm, +performance-inefficient-string-concatenation, +performance-inefficient-vector-operation, +performance-move-const-arg, +performance-move-constructor-init, +performance-no-automatic-move, +performance-noexcept-move-constructor, +performance-trivially-destructible, +performance-type-promotion-in-math-fn, +performance-unnecessary-copy-initialization, +performance-unnecessary-value-param, +portability-simd-intrinsics, +readability-avoid-const-params-in-decls, +readability-const-return-type, +readability-container-size-empty, +readability-convert-member-functions-to-static, +readability-delete-null-pointer, +readability-deleted-default, +readability-inconsistent-declaration-parameter-name, +readability-make-member-function-const, +readability-misleading-indentation, +readability-misplaced-array-index, +readability-non-const-parameter, +readability-redundant-control-flow, +readability-redundant-declaration, +readability-redundant-function-ptr-dereference, +readability-redundant-smartptr-get, +readability-redundant-string-cstr, +readability-redundant-string-init, +readability-simplify-subscript-expr, +readability-static-accessed-through-instance, +readability-static-definition-in-anonymous-namespace, +readability-string-compare, +readability-uniqueptr-delete-release, +readability-use-anyofallof' diff --git a/.clangd b/.clangd new file mode 100644 index 000000000..797c8f303 --- /dev/null +++ b/.clangd @@ -0,0 +1,15 @@ +Diagnostics: + Suppress: + - "-Wmicrosoft-enum-forward-reference" + - "-Wc++11-narrowing" + - "-Wc++2b-extensions" + - "-Wmicrosoft-cast" +CompileFlags: + Add: + - "-ferror-limit=0" + - "-D__FUNCTION__=\"dummy\"" + - "-Yumc/_HeaderOutputPredefine.h" + - "-FImc/_HeaderOutputPredefine.h" # clangd bug can't find pch file + Remove: + - "/Yu_HeaderOutputPredefine.h" + - "/FI_HeaderOutputPredefine.h" diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..8327acb82 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,127 @@ +## https://github.com/gitattributes/gitattributes/blob/master/Common.gitattributes +# Common settings that generally should always be used with your language specific settings + +# Auto detect text files and perform LF normalization +* text=auto + +# +# The above will handle all files NOT found below +# + +# Documents +*.bibtex text diff=bibtex +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain +*.md text diff=markdown +*.mdx text diff=markdown +*.tex text diff=tex +*.adoc text +*.textile text +*.mustache text +*.csv text eol=crlf +*.tab text +*.tsv text +*.txt text +*.sql text +*.epub diff=astextplain + +# Graphics +*.png binary +*.jpg binary +*.jpeg binary +*.gif binary +*.tif binary +*.tiff binary +*.ico binary +# SVG treated as text by default. +*.svg text +# If you want to treat it as binary, +# use the following line instead. +# *.svg binary +*.eps binary + +# Scripts +*.bash text eol=lf +*.fish text eol=lf +*.sh text eol=lf +*.zsh text eol=lf +# These are explicitly windows files and should use crlf +*.bat text eol=crlf +*.cmd text eol=crlf +*.ps1 text eol=crlf + +# Serialisation +*.json text +*.toml text +*.xml text +*.yaml text +*.yml text + +# Archives +*.7z binary +*.gz binary +*.tar binary +*.tgz binary +*.zip binary + +# Text files where line endings should be preserved +*.patch -text + +# +# Exclude files from exporting +# + +.gitattributes export-ignore +.gitignore export-ignore +.gitkeep export-ignore + + +## https://github.com/gitattributes/gitattributes/blob/master/C%2B%2B.gitattributes +# Sources +*.c text diff=cpp +*.cc text diff=cpp +*.cxx text diff=cpp +*.cpp text diff=cpp +*.cpi text diff=cpp +*.c++ text diff=cpp +*.hpp text diff=cpp +*.h text diff=cpp +*.h++ text diff=cpp +*.hh text diff=cpp + +# Compiled Object files +*.slo binary +*.lo binary +*.o binary +*.obj binary + +# Precompiled Headers +*.gch binary +*.pch binary + +# Compiled Dynamic libraries +*.so binary +*.dylib binary +*.dll binary + +# Compiled Static libraries +*.lai binary +*.la binary +*.a binary +*.lib binary + +# Executables +*.exe binary +*.out binary +*.app binary + + +## Project specific diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 000000000..1c3513b43 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,55 @@ +name: Bug Report +description: Create a report to help us improve +title: "[Bug]: " +labels: ["bug"] +body: + - type: textarea + attributes: + label: Describe the bug + description: A clear and concise description of what the bug is. + validations: + required: true + + - type: textarea + attributes: + label: To Reproduce + description: Steps to reproduce the behavior. + validations: + required: true + + - type: textarea + attributes: + label: Expected behavior + description: A clear and concise description of what you expected to happen. + validations: + required: true + + - type: textarea + attributes: + label: Screenshots + description: If applicable, add screenshots to help explain your problem. + + - type: input + attributes: + label: Platform + description: The platform you are using. (e.g. Windows 10) + + - type: input + attributes: + label: BDS Version + description: The version of BDS you are using. (e.g. 1.20.32.1) + + - type: input + attributes: + label: LeviLamina Version + description: The version of LeviLamina you are using. (e.g. 1.0.0) + + - type: input + attributes: + label: Version + description: The version of the plugin you are using. (e.g. 1.0.0) + + - type: textarea + attributes: + label: Additional context + description: Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 000000000..b0f4b33d1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,28 @@ +name: Feature request +description: Suggest an idea for this project +title: "[Feature]: " +labels: ["enhancement"] +body: + - type: textarea + attributes: + label: Is your feature request related to a problem? Please describe. + description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + validations: + required: true + + - type: textarea + attributes: + label: Describe the solution you'd like + description: A clear and concise description of what you want to happen. + validations: + required: true + + - type: textarea + attributes: + label: Describe alternatives you've considered + description: A clear and concise description of any alternative solutions or features you've considered. + + - type: textarea + attributes: + label: Additional context + description: Add any other context or screenshots about the feature request here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..58da31318 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,18 @@ +## What does this PR do? + + + +## Which issues does this PR resolve? + + + +## Checklist before merging + +Thank you for your contribution to the repository. +Before submitting this PR, please make sure: + +- [ ] Your code builds clean without any errors or warnings +- [ ] Your code follows [LeviLamina C++ Style Guide](https://github.com/LiteLDev/LeviLamina/wiki/CPP-Style-Guide) +- [ ] You have tested all functions +- [ ] You have not used code without license +- [ ] You have added statement for third-party code diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d3388e0d8..60e9a2cb7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,78 +1,27 @@ on: - push: - branches: - - master - - dev - paths: - - .github/workflows/build.yml - - scripts/localbdslibrary.lua - - src/** - - xmake.lua pull_request: - branches: - - master - - dev - paths: - - .github/workflows/build.yml - - scripts/localbdslibrary.lua - - src/** - - xmake.lua + push: workflow_dispatch: - + jobs: build: runs-on: windows-latest steps: - uses: actions/checkout@v4 - - - name: Read bdsversion file - id: read-bdsversion - run: | - $content = Get-Content -Path .\bdsversion -Raw - $type = ($content | Select-String -Pattern 'type=(.*)' | ForEach-Object { $_.Matches.Groups[1].Value }).Trim() - $version = ($content | Select-String -Pattern 'version=(.*)' | ForEach-Object { $_.Matches.Groups[1].Value }).Trim() - echo "::set-output name=version_type::$type" - echo "::set-output name=version_number::$version" - printf '%s\n' "$type" - printf '%s\n' "$version" - uses: xmake-io/github-action-setup-xmake@v1 - - - uses: actions/cache@v3 - name: xmake cache - with: - path: | - ~/AppData/Local/.xmake - .xmake - build/bds/lib - key: | - xmake-dataextractor-windows-x64-${{ github.sha }} - restore-keys: | - xmake-dataextractor-windows-x64- - - - uses: actions/cache@v3 - name: bdslib cache - with: - path: | - build/bds/lib - key: | - bdslib-${{ steps.read-bdsversion.outputs.version_type }}-${{ steps.read-bdsversion.outputs.version_number }} - + - run: | xmake repo -u - run: | - xmake bds-lib -b --${{ steps.read-bdsversion.outputs.version_type }}=${{ steps.read-bdsversion.outputs.version_number }} - - - run: | - xmake f -a x64 -m release -p windows -v -y --ccache=n + xmake f -a x64 -m release -p windows -v -y - run: | xmake -w -y - uses: actions/upload-artifact@v3 with: - name: DataExtractor-Windows-X64-${{ github.sha }} + name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }} path: | - build/windows/x64/release/DataExtractor.dll - build/windows/x64/release/DataExtractor.pdb \ No newline at end of file + bin/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..42bf5e20f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,56 @@ +on: + release: + types: + - published + +jobs: + build: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - uses: xmake-io/github-action-setup-xmake@v1 + + - run: | + xmake repo -u + + - run: | + xmake f -a x64 -m release -p windows -v -y + + - run: | + xmake -w -y + + - uses: actions/upload-artifact@v3 + with: + name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }} + path: | + bin/ + + upload-to-release: + needs: + - build + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/download-artifact@v3 + with: + name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }} + path: release/ + + - run: | + cp LICENSE README.md release/ + + - name: Archive release + run: | + cd release + zip -r ../${{ github.event.repository.name }}-windows-x64.zip * + cd .. + + - uses: softprops/action-gh-release@v1 + with: + append_body: true + files: | + ${{ github.event.repository.name }}-windows-x64.zip diff --git a/.gitignore b/.gitignore index d7a39428a..0c599a2f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,17 +1,562 @@ -# Xmake cache -.xmake/ +# https://github.com/github/gitignore/blob/main/C++.gitignore +# Prerequisites +*.d -.cmake/ +# Compiled Object files +*.slo +*.lo +*.o +*.obj -# vs studio cache +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + + +# https://github.com/github/gitignore/blob/main/CMake.gitignore +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps + + +# https://github.com/github/gitignore/blob/main/Global/Ninja.gitignore +.ninja_deps +.ninja_log + + +# https://github.com/github/gitignore/blob/main/VisualStudio.gitignore +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory .vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl -vsxmake2022/ +# Microsoft Fakes +FakesAssemblies/ -# unuse out folder +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml + + +# https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + + +# https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ out/ -build/ +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + + +# XMake +/.xmake/ +/build/ +/CMakeLists.txt + -# MacOS Cache -.DS_Store +# Project specific ignores +/.idea/ +/.vscode/ +/bin/ +/include +/vsxmake2022 diff --git a/LICENSE b/LICENSE index 0a041280b..e69de29bb 100644 --- a/LICENSE +++ b/LICENSE @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/README.md b/README.md index 26bfb4b32..e23dc6636 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,17 @@ # DataExtractor -This is a BDS mod which allows generating useful data used in AllayMC Project -(such as block_attributes and item_data) from BDS server. +This is a BDS mod which allows generating useful data used in AllayMC Project from BDS server. ## How to use? 1. Install windows version BedrockServer. see [here](https://www.minecraft.net/en-us/download/server/bedrock). 2. Set the property `block-network-ids-are-hashes` in file `server.properties` to `false`. -3. Download PeEditor. see [here](https://github.com/LiteLDev/PeEditor),then move `PeEditor.exe` in the same path as BDS -run `PeEditor -m -n`. -4. Download PreLoader. see [here](https://github.com/LiteLDev/PreLoader),then move `PreLoader.dll` in the same path as BDS. -5. Download the latest release and put it in the `plugins` folder. -6. Run `bedrock_server_mod.exe`, then enter the game, teleport to pos `0 64 0`, type `ext` in the chat, the output files will create in `data/*`. +3. Install latest levilamina loader. For how to install it, please see [here](https://github.com/LiteLDev/LeviLamina?tab=readme-ov-file#install) +4. Download the latest release and put ```DataExtractor.dll``` and ```manifest.json``` it into `plugin/DataExtractor` folder (you may need to create it if it doesn't exist). +5. Run `bedrock_server_mod.exe`, type `/ext` in the chat, the output files will create in `data/*`. ## I want to build it myself! -1. Clone project source `git clone https://github.com/AllayMC/DataExtractor`. -2. You need to install [Visual Studio 2022](https://visualstudio.microsoft.com/)'s C++ desktop application development and SDK for Windows 10 or above, as well as `xmake` build tool. -3. Before on first build, please run `xmake require` to install all packages and -it will download the `PeEditor.exe`,after that a window will pop, -please select the symbol file(`.pdb`) corresponding to the BDS version. -4. Use `xmake project -k vsxmake -m "release"` to generate the vsproject files -5. Install the xmake extension for Visual Studio, open it in `extensions/XMake`, select `mode release`, `platform windows`, `architecture x64`, and click Build. - -## Note -1. If you are updating your BDS version, before build this plugin, you also need to update `bedrock_server_api.lib` and `bedrock_server_var.lib` in the `DataExtractor\build\bds\lib` folder. To generate these files, please run `PeEditor.exe -l` in the same path as BDS. -2. If you add new files, you can use `xmake project -k vsxmake -m "release"` to regenerate the vsproject files. +See [here](https://levilamina.liteldev.com/tutorials/create_your_first_plugin) for how to build levilamina plugin ## Special thanks -Thanks to [LeviLamina](https://github.com/LiteLDev/LeviLamina) for their great work! -Thanks to [bds-data-scraper](https://github.com/Creeperface01/bds-data-scraper) for providing me some ideas about how to get the block types! \ No newline at end of file +Thanks to [LeviLamina](https://github.com/LiteLDev/LeviLamina) for their great work! \ No newline at end of file diff --git a/bdsversion b/bdsversion deleted file mode 100644 index a392c8efe..000000000 --- a/bdsversion +++ /dev/null @@ -1,2 +0,0 @@ -type=release -version=1.20.50.03 \ No newline at end of file diff --git a/manifest.json b/manifest.json new file mode 100644 index 000000000..6fe90740a --- /dev/null +++ b/manifest.json @@ -0,0 +1,5 @@ +{ + "name": "DataExtractor-v2", + "entry": "DataExtractor-v2.dll", + "type": "native" +} \ No newline at end of file diff --git a/scripts/after_build.lua b/scripts/after_build.lua new file mode 100644 index 000000000..9475b5ac7 --- /dev/null +++ b/scripts/after_build.lua @@ -0,0 +1,118 @@ +function beautify_json(value, indent) + import("core.base.json") + local json_text = "" + local stack = {} + + local function escape_str(s) + return string.gsub(s, '[%c\\"]', function(c) + local replacements = {['\b'] = '\\b', ['\f'] = '\\f', ['\n'] = '\\n', ['\r'] = '\\r', ['\t'] = '\\t', ['"'] = '\\"', ['\\'] = '\\\\'} + return replacements[c] or string.format('\\u%04x', c:byte()) + end) + end + + local function is_null(v) + return v == json.null + end + + local function is_empty_table(t) + if type(t) ~= 'table' then return false end + for _ in pairs(t) do + return false + end + return true + end + + local function is_array(t) + return type(t) == 'table' and json.is_marked_as_array(t) or #t > 0 + end + + local function serialize(val, level) + local spaces = string.rep(" ", level * indent) + + if type(val) == "table" and not stack[val] then + if is_empty_table(val) then + json_text = json_text .. (is_array(val) and "[]" or "{}") + return + end + + stack[val] = true + local isArray = is_array(val) + json_text = json_text .. (isArray and "[\n" or "{\n") + + local keys = isArray and {} or {} + for k in pairs(val) do + table.insert(keys, k) + end + if not isArray then + table.sort(keys) + end + + for _, k in ipairs(keys) do + local v = val[k] + json_text = json_text .. spaces .. (isArray and "" or '"' .. escape_str(tostring(k)) .. '": ') + serialize(v, level + 1) + json_text = json_text .. ",\n" + end + + json_text = string.sub(json_text, 1, -3) .. "\n" .. string.rep(" ", (level - 1) * indent) .. (isArray and "]" or "}") + stack[val] = nil + elseif type(val) == "string" then + json_text = json_text .. '"' .. escape_str(val) .. '"' + elseif type(val) == "number" then + if val % 1 == 0 then + json_text = json_text .. tostring(math.floor(val)) + else + json_text = json_text .. tostring(val) + end + elseif type(val) == "boolean" then + json_text = json_text .. tostring(val) + elseif is_null(val) then + json_text = json_text .. "null" + else + error("Invalid value type: " .. type(val)) + end + end + serialize(value, 1) + return json_text +end + +function string_formatter(str, variables) + return str:gsub("%${(.-)}", function(var) + return variables[var] or "${" .. var .. "}" + end) +end + +function pack_plugin(target,plugin_define) + import("lib.detect.find_file") + + local manifest_path = find_file("manifest.json", os.projectdir()) + if manifest_path then + local manifest = io.readfile(manifest_path) + local bindir = path.join(os.projectdir(), "bin") + local outputdir = path.join(bindir, plugin_define.pluginName) + local targetfile = path.join(outputdir, plugin_define.pluginFile) + local pdbfile = path.join(outputdir, path.basename(plugin_define.pluginFile) .. ".pdb") + local manifestfile = path.join(outputdir, "manifest.json") + local oritargetfile = target:targetfile() + local oripdbfile = path.join(path.directory(oritargetfile), path.basename(oritargetfile) .. ".pdb") + + os.mkdir(outputdir) + os.cp(oritargetfile, targetfile) + if os.isfile(oripdbfile) then + os.cp(oripdbfile, pdbfile) + end + + formattedmanifest = string_formatter(manifest, plugin_define) + io.writefile(manifestfile,formattedmanifest) + cprint("${bright green}[Plugin Packer]: ${reset}plugin already generated to " .. outputdir) + else + cprint("${bright yellow}warn: ${reset}not found manifest.json in root dir!") + end +end + + +return { + pack_plugin = pack_plugin, + beautify_json = beautify_json, + string_formatter = string_formatter +} diff --git a/scripts/format_all.py b/scripts/format_all.py deleted file mode 100644 index dca87537e..000000000 --- a/scripts/format_all.py +++ /dev/null @@ -1,36 +0,0 @@ -# execute clang-format at src with multi-threading - -import os -import subprocess -import multiprocessing -import re - - -def format_file(file): - # with open(file, "rb") as f: - # content = f.read() - # content = re.sub( - # rb"(? - -void PluginInit(); - -BOOL APIENTRY DllMain(HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved) { - switch (ul_reason_for_call) { - case DLL_PROCESS_ATTACH: - PluginInit(); - break; - - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} - -extern "C" -{ -_declspec(dllexport) -void onPostInit() { - PluginInit(); -} -} diff --git a/src/DataExtractor.cpp b/src/DataExtractor.cpp deleted file mode 100644 index 135398432..000000000 --- a/src/DataExtractor.cpp +++ /dev/null @@ -1,992 +0,0 @@ -#include "DataExtractor.h" - -using json = nlohmann::json; -using namespace std; - -static Minecraft* mc = nullptr; -static Dimension* overworld = nullptr; -static MinecraftCommands* commands = nullptr; -static unsigned int blockStateCounter = 0; -static AABB ZERO_AABB = AABB(Vec3(0, 0, 0), Vec3(0, 0, 0)); - -#pragma region HOOK -LL_AUTO_TYPED_INSTANCE_HOOK( - PlayerChatEventHook, - ll::memory::HookPriority::Normal, - ServerNetworkHandler, - "?handle@ServerNetworkHandler@@UEAAXAEBVNetworkIdentifier@@AEBVTextPacket@@@Z", - void, - void* networkIdentifier,//通过空指针的魔法,ä¸ç”¨å£°æ˜Žç±»åž‹å°±èƒ½è°ƒç”¨ - void* textPk -) { - std::string originMessage = ll::memory::dAccess(textPk, 88);//通过LLæ供的memory库直接基于å移é‡åŠ¨æ€è®¿é—®è¿™ä¸ªåœ°å€æ‰€åœ¨çš„内容 - origin(networkIdentifier, textPk); - if (originMessage == "ext") { - extractData(); - } - return; -} - -// Dimension -LL_AUTO_TYPED_INSTANCE_HOOK( - DimensionService, - ll::memory::HookPriority::Normal, - Dimension, - "?init@Dimension@@UEAAXXZ", - void*, - Dimension* a1 -) { - if (a1->getHeight() > 256) { - std::cout << "INJECT DIMENSION INSTANCE" << std::endl; - overworld = a1; - } - return origin(a1); -} - -//Recipe packet -LL_AUTO_TYPED_INSTANCE_HOOK( - CraftingDataPacketHook, - ll::memory::HookPriority::Normal, - CraftingDataPacket, - "?write@CraftingDataPacket@@UEBAXAEAVBinaryStream@@@Z", - void, - BinaryStream& stream -) { - origin(stream); - const std::string& data = stream.getAndReleaseData(); - std::string datacopy = data; - stream.writeString(data, nullptr, nullptr); - auto out = ofstream("data/crafting_data_packet.bin", ofstream::out | ofstream::binary | ofstream::trunc); - out << datacopy; - out.close(); - Logger logger; - logger.info("create crafting_data_packet.bin success!"); -} - -// Minecraft -LL_AUTO_TYPED_INSTANCE_HOOK( - MinecraftHook, - HookPriority::Normal, - Minecraft, - "?initAsDedicatedServer@Minecraft@@QEAAXXZ", - void -) { - mc = this; - origin(); - std::cout << "INJECT MINECRAFT INSTANCE" << std::endl; -} - -// MinecraftCommands -LL_AUTO_TYPED_INSTANCE_HOOK( - MinecraftCommandsHook, - HookPriority::Normal, - MinecraftCommands, - "?initCoreEnums@MinecraftCommands@@QEAAXVItemRegistryRef@@AEBVIWorldRegistriesProvider@@AEBVActorFactory@" - "@AEBVExperiments@@AEBVBaseGameVersion@@@Z", - void, - void* a2, - int64 a3, - int64 a4, - void* a5, - void* a6 -) { - commands = this; - origin(a2, a3, a4, a5, a6); - std::cout << "INJECT MINECRAFTCOMMANDS INSTANCE" << std::endl; -} -#pragma endregion HOOK - -#pragma region TOOL_FUNCTION -static bool folderExists(std::string folderName) { - struct stat info {}; - if (stat(folderName.c_str(), &info) != 0) { - return false; - } - else if (info.st_mode & S_IFDIR) { - return true; - } - else { - return false; - } -} - -static void createFolder(std::string folderName) { - Logger logger; - int result = _mkdir(folderName.c_str()); - if (result != 0) { - logger.error("Failed to create folder."); - } - else { - logger.info("Folder " + string(folderName) + " created successfully."); - } -} - -static void saveFile(string const& name, vector& blocks) { - sort(blocks.begin(), blocks.end(), [](string const& a, string const& b) { return a < b; }); - auto out = ofstream("block_categories/" + name + ".txt", ofstream::out | ofstream::trunc); - for (string& b : blocks) { - out << b << endl; - } - out.close(); -} - -static bool gzip_compress(const std::string& original_str, std::string& str) { - z_stream d_stream = { 0 }; - if (Z_OK != deflateInit2(&d_stream, Z_BEST_COMPRESSION, Z_DEFLATED, MAX_WBITS + 16, 9, Z_DEFAULT_STRATEGY)) { - return false; - } - unsigned long len = compressBound(original_str.size()); - auto* buf = (unsigned char*)malloc(len); - if (!buf) { - return false; - } - d_stream.next_in = (unsigned char*)(original_str.c_str()); - d_stream.avail_in = original_str.size(); - d_stream.next_out = buf; - d_stream.avail_out = len; - deflate(&d_stream, Z_SYNC_FLUSH); - deflateEnd(&d_stream); - str.assign((char*)buf, d_stream.total_out); - free(buf); - return true; -} - -static void writeNBT(const string& fileName, CompoundTag* tag) { - void* vtbl; - auto tmp = BigEndianStringByteOutput(); - vtbl = *(void**)&tmp; - string result = ""; - void* iDataOutput[2] = { vtbl, &result }; - NbtIo::write(tag, (IDataOutput&)iDataOutput); - string v; - gzip_compress(result, v); - auto out = ofstream(fileName, ofstream::out | ofstream::binary | ofstream::trunc); - out << v; - out.close(); -} - -static void writeJSON(const string& fileName, const nlohmann::json& json) { - auto out = ofstream(fileName, ofstream::out | ofstream::trunc); - out << json.dump(4); - out.close(); -} - -static void writeJSON(const string& fileName, const Json::Value& json) { - auto out = ofstream(fileName, ofstream::out | ofstream::trunc); - out << json.toStyledString(); - out.close(); -} - -static std::unique_ptr createCompound() { - return std::make_unique(); -} - -static std::unique_ptr createListTag() { - return std::make_unique(); -} - -static std::string aabbToStr(const AABB& aabb) { - stringstream aabbStr; - aabbStr << aabb.min.x << "," << aabb.min.y << "," << aabb.min.z << "," << aabb.max.x << "," << aabb.max.y << "," << aabb.max.z; - return aabbStr.str(); -} -#pragma endregion TOOL_FUNCTION - -void PluginInit() { - Logger logger; - logger.info("DataExtractor plugin loaded!"); - if (!folderExists("data")) { - createFolder("data"); - } -} - -void extractData() { - dumpCreativeItemData(); - dumpBlockAttributesData(); - dumpItemData(); - dumpEntityData(); - dumpPalette(); - dumpBlockIdToItemIdMap(); - dumpBiomeData(); - dumpPropertyTypeData(); - dumpItemTags(); - dumpBlockTags(); - //dumpCommandArgData(); - //dumpAvailableCommand(); -} - -void dumpCreativeItemData() { - Logger logger; - - logger.info("Extracting creative items..."); - - auto global = createCompound(); - unsigned int index = 0; - CreativeItemRegistry::forEachCreativeItemInstance([&logger, &index, &global](const ItemInstance& itemInstance) { - if (itemInstance.getName().empty()) { - logger.warn("Failed to extract creative item - " + itemInstance.getName() + ", index: " + to_string(index)); - return true; - } - logger.text("Extracting creative item - " + itemInstance.getName() + ", index: " + to_string(index)); - auto obj = createCompound(); - obj->putInt64("index", index); - obj->putString("name", itemInstance.getItem()->getFullItemName()); - obj->putInt("damage", itemInstance.getAuxValue()); - if (itemInstance.isBlock()) { - obj->putInt("blockStateHash", itemInstance.getBlock()->computeRawSerializationIdHashForNetwork()); - } - auto nbt = itemInstance.save(); - if (nbt->contains("tag")) { - obj->put("tag", nbt->getCompound("tag")->copy()); - } - global->put(to_string(index), obj->copy()); - index++; - }); - writeNBT("data/creative_items.nbt", global.get()); - global.release(); - logger.info(R"(Creative items data has been saved to "data/creative_items.nbt")"); -} - -std::unique_ptr generateNBTFromBlockState(const Block& block) { - Logger logger; - auto nbt = createCompound(); - try { - auto& legacy = block.getLegacyBlock(); - auto name = legacy.getNamespace() + ":" + legacy.getRawNameId(); - logger.text("Extracting block state - " + name + ":" + to_string(block.getRuntimeId())); - const Material& material = legacy.getMaterial(); - auto sid = block.getSerializationId().clone(); - nbt->putString("name", sid->getString("name")); - nbt->putString("descriptionId", block.getDescriptionId()); - nbt->putString("blockEntityName", string(magic_enum::enum_name(block.getBlockEntityType()))); - nbt->putCompound("states", sid->getCompound("states")->clone()); - nbt->putFloat("thickness", block.getThickness()); - nbt->putFloat("friction", block.getFriction()); - nbt->putFloat("hardness", block.getDestroySpeed()); - nbt->putFloat("explosionResistance", block.getExplosionResistance()); - nbt->putFloat("translucency", material.getTranslucency()); - nbt->putInt("version", sid->getInt("version")); - nbt->putInt("runtimeId", block.getRuntimeId()); - nbt->putInt("blockStateHash", ((name != "minecraft:unknown") ? block.computeRawSerializationIdHashForNetwork() : -2)); - nbt->putInt("burnChance", block.getFlameOdds()); - nbt->putInt("burnAbility", block.getBurnOdds()); - nbt->putInt("lightDampening", (int)block.getLight().value);//挡光 - nbt->putInt("lightEmission", (int)block.getLightEmission().value);//å‘å…‰ - mce::Color color = block.getMapColor(overworld->getBlockSourceFromMainChunkSource(), BlockPos(0, 10, 0)); - auto colornbt = createCompound(); - colornbt->putInt("r", (int)(color.r * 255)); - colornbt->putInt("g", (int)(color.g * 255)); - colornbt->putInt("b", (int)(color.b * 255)); - colornbt->putInt("a", (int)(color.a * 255)); - colornbt->putString("hexString", color.toHexString()); - nbt->putCompound("color", colornbt->clone()); - AABB tmp = AABB(0, 0, 0, 0, 0, 0); - block.getCollisionShapeForCamera(tmp, *(IConstBlockSource*)&overworld->getBlockSourceFromMainChunkSource(), BlockPos(0, 0, 0)); - nbt->putString("aabbVisual", aabbToStr(tmp)); - AABB tmp2 = AABB(0, 0, 0, 0, 0, 0); - class optional_ref nullRef {}; - block.getCollisionShape(tmp2, *(IConstBlockSource*)&overworld->getBlockSourceFromMainChunkSource(), BlockPos(0, 0, 0), nullRef); - nbt->putString("aabbCollision", aabbToStr(tmp2)); - - nbt->putBoolean("hasCollision", tmp2 != ZERO_AABB); - nbt->putBoolean("hasBlockEntity", block.getBlockEntityType() != BlockActorType::Undefined); - nbt->putBoolean("isAir", block.isAir()); - nbt->putBoolean("isBounceBlock", block.isAir()); - nbt->putBoolean("isButtonBlock", block.isButtonBlock()); - nbt->putBoolean("isCropBlock", block.isCropBlock()); - nbt->putBoolean("isDoorBlock", block.isDoorBlock()); - nbt->putBoolean("isFenceBlock", block.isFenceBlock()); - nbt->putBoolean("isFenceGateBlock", block.isFenceGateBlock()); - nbt->putBoolean("isThinFenceBlock", block.isThinFenceBlock()); - nbt->putBoolean("isFallingBlock", block.isFallingBlock()); - nbt->putBoolean("isStemBlock", block.isStemBlock()); - nbt->putBoolean("isSlabBlock", block.isSlabBlock()); - nbt->putBoolean("isLiquid", material.isLiquid()); - nbt->putBoolean("isAlwaysDestroyable", material.isAlwaysDestroyable());//是å¦å¯ä»¥è¢«ç©ºæ‰‹ç ´å且获å–æ–¹å— - nbt->putBoolean("isLavaFlammable", block.isLavaFlammable());//是å¦å¯ç‡ƒ - nbt->putBoolean("isUnbreakable", block.isUnbreakable());//是å¦ä¸å¯ç ´å - nbt->putBoolean("isPowerSource", block.isSignalSource()); - //nbt->putBoolean("breaksFallingBlocks", block.breaksFallingBlocks(BaseGameVersion()));未知作用 - nbt->putBoolean("isWaterBlocking", block.isWaterBlocking());//是å¦èƒ½é˜»æŒ¡æ°´ - nbt->putBoolean("isMotionBlockingBlock", block.isMotionBlockingBlock());//是å¦èƒ½é˜»æŒ¡ç§»åŠ¨ - nbt->putBoolean("hasComparatorSignal", block.hasComparatorSignal());//是å¦èƒ½äº§ç”Ÿæ¯”è¾ƒå™¨ä¿¡å· - nbt->putBoolean("pushesUpFallingBlocks", block.pushesUpFallingBlocks());//æ´»å¡žç±»æ–¹å— - //nbt->putBoolean("waterSpreadCausesSpawn", block.waterSpreadCausesSpawn());未知作用 - nbt->putBoolean("canContainLiquid", block.getLegacyBlock().canContainLiquid()); - //nbt->putBoolean("canBeMovingBlock", material.getBlocksMotion());å’ŒisMotionBlockingBlock一个作用 - //nbt->putBoolean("blocksPrecipitation", material.getBlocksPrecipitation());未知作用 - nbt->putBoolean("superHot", material.isSuperHot());//å¯ä»¥å¯¼è‡´ç€ç«çš„æ–¹å— - //nbt->putBoolean("canBeBrokenFromFalling", block.canBeBrokenFromFalling());未知作用 - nbt->putBoolean("isSolid", block.isSolid()); - //nbt->putBoolean("isSolidBlocking", material.isSolidBlocking());未知作用 - nbt->putBoolean("isContainerBlock", block.isContainerBlock()); - - } - catch (exception& e) { - logger.error("Exception caught : " + string(e.what())); - } - - return nbt; -} - -void dumpBlockAttributesData() { - Logger logger; - logger.info("Extracting block states' attributes..."); - const auto& palette = mc->getLevel()->getBlockPalette(); - int airCount = 0; - auto array = json::array(); - - auto tag = createCompound(); - auto list = createListTag(); - blockStateCounter = 0; - while (true) { - const auto& block = palette.getBlock(blockStateCounter); - //HACK: 用于确定最大size - if (block.getName().getString() == "minecraft:air") { - airCount++; - if (airCount == 2) { - blockStateCounter--; - break; - } - } - auto obj2 = generateNBTFromBlockState(block); - list->add(obj2->copy()); - blockStateCounter++; - } - tag->put("block", list->copyList()); - logger.info("Successfully extract " + to_string(blockStateCounter) + " block states' attributes!"); - writeNBT("data/block_attributes.nbt", tag.get()); - logger.info(R"(Block attribute data have been saved to "data/block_attributes.nbt")"); - tag.release(); - list.release(); -} - - -std::unique_ptr generateNBTFromItem(const Item& item) { - Logger logger; - std::unique_ptr nbt = createCompound(); - logger.info("Extracting item - " + item.getFullItemName()); - nbt->putShort("id", item.getId()); - try { - if (!item.getLegacyBlock().expired() && item.getLegacyBlock().get() != nullptr) - nbt->putString("blockId", item.getLegacyBlock()->getNamespace() + ":" + item.getLegacyBlock()->getRawNameId()); - } - catch (exception& e) { - logger.warn("Exception occur when trying to get block for item " + item.getFullItemName()); - } - nbt->putBoolean("isComponentBased", item.isComponentBased()); - nbt->putString("name", item.getFullItemName()); - nbt->putShort("maxDamage", item.getMaxDamage());//最大è€ä¹… - nbt->putBoolean("isArmor", item.isArmor()); - nbt->putBoolean("isBlockPlanterItem", item.isBlockPlanterItem()); - nbt->putBoolean("isDamageable", item.isDamageable()); - nbt->putBoolean("isDye", item.isDye()); - nbt->putString("itemColorName", ItemColorUtil::getName(item.getItemColor())); - nbt->putInt("itemColorRGB", ItemColorUtil::getRGBColor(item.getItemColor())); - nbt->putBoolean("isFertilizer", item.isFertilizer()); - nbt->putBoolean("isThrowable", item.isThrowable()); - nbt->putBoolean("isFood", item.isFood()); - nbt->putBoolean("isUseable", item.isUseable()); - nbt->putBoolean("isElytra", item.isElytra()); - nbt->putBoolean("canBeDepleted", item.canBeDepleted()); - nbt->putBoolean("canDestroyInCreative", item.canDestroyInCreative()); - nbt->putBoolean("canUseOnSimTick", item.canUseOnSimTick()); - nbt->putBoolean("canBeCharged", item.canBeCharged()); - nbt->putString("creativeGroup", item.getCreativeGroup()); - nbt->putInt("creativeCategory", (int)item.getCreativeCategory()); - nbt->putInt("armorValue", item.getArmorValue()); - nbt->putInt("attackDamage", item.getAttackDamage()); - nbt->putInt("toughnessValue", item.getToughnessValue()); - nbt->putFloat("viewDamping", item.getViewDamping()); - nbt->putInt("cooldownTime", item.getCooldownTime()); - nbt->putString("cooldownType", item.getCooldownType().getString()); - nbt->putInt("maxStackSize", (int)ItemStack(item, 1, 0, 0).getMaxStackSize()); - CompoundTag descriptionId; - std::set uniqueStr; - for (int i = 0; i <= 256; ++i) { - try { - if (item.isValidAuxValue(i)) { - const auto itemstack = ItemStack(item, 1, i);//ignore some invaild aux exception - if (!uniqueStr.contains(itemstack.getDescriptionId())) { - uniqueStr.insert(itemstack.getDescriptionId()); - descriptionId.putString(to_string(i), itemstack.getDescriptionId()); - } - } - } - catch (...) {} - } - nbt->putCompound("descriptionId", descriptionId); - return nbt; -} - -void dumpItemData() { - Logger logger; - auto tag = createCompound(); - auto list = createListTag(); - short counter = 0; - for (short id = -2000; id <= 2000; id++) { - const WeakPtr item = ItemRegistryManager::getItemRegistry().getItem(id); - if (item.expired()) { - continue; - } - std::unique_ptr obj2 = generateNBTFromItem(*item); - list->add(obj2->copy()); - obj2.release(); - counter++; - } - tag->put("item", list->copyList()); - list.release(); - logger.info("Successfully extract " + to_string(counter) + " items' data!"); - writeNBT("data/item_data.nbt", tag.get()); - tag.release(); - logger.info(R"(Items' data have been saved to "data/item_data.nbt")"); -} - -void dumpEntityAABB(const Level* level, const pair& pair, - nlohmann::basic_json>& obj) { - Logger logger; - Mob* actor = level->getSpawner().spawnMob(overworld->getBlockSourceFromMainChunkSource(), *pair.second, nullptr, Vec3(0, 64, 0), false, true, false); - if (actor == nullptr) { - logger.warn("Failed to spawn entity: " + pair.first); - logger.warn("It is possible to solve this problem by adding a ticking area around 0 64 0"); - logger.warn("AABB data for this entity will be missing!"); - } - else { - auto& aabb = actor->getAABB(); - stringstream aabbStr; - aabbStr << aabb.min.x << "," << aabb.min.y << "," << aabb.min.z << "," << aabb.max.x - << "," << aabb.max.y << "," << aabb.max.z; - obj["aabb"] = aabbStr.str(); - //todo: nbt - actor->kill(); - } -} - -void dumpEntityData() { - Logger logger; - - auto level = mc->getLevel(); - auto& exp = level->getLevelData().getExperiments(); - auto& actorFactory = level->getActorFactory(); - auto list = actorFactory.buildSummonEntityTypeEnum(exp); - - auto global = json::object(); - for (auto& pair : list) { - if (global.contains(pair.second->getCanonicalName())) - continue; - logger.info("Extracting entity - " + pair.second->getCanonicalName()); - - auto obj = json::object(); - obj["canonicalName"] = pair.second->getCanonicalName(); - obj["initEvent"] = pair.second->getInitEvent(); - obj["legacyActorType"] = static_cast<__int32>(pair.second->_getLegacyActorType()); - - dumpEntityAABB(level, pair, obj); - - global[pair.second->getCanonicalName()] = obj; - } - writeJSON("data/entity_data.json", global); - logger.info("Entities' data have been saved to \"data/entity_data.json\""); -} - -void dumpPalette() { - Logger logger; - - logger.info("Extracting block palette..."); - - auto& palette = mc->getLevel()->getBlockPalette(); - - auto global = createCompound(); - auto blocks = createListTag(); - for (int i = 0; i <= blockStateCounter; ++i) { - blocks->add(palette.getBlock(i).getSerializationId().clone()); - } - global->put("blocks", blocks->copyList()); - writeNBT("data/block_palette.nbt", global.get()); - global.release(); - blocks.release(); - logger.info(R"(Block palette table has been saved to "data/block_palette.nbt"))"); -} - -void dumpBlockIdToItemIdMap() { - Logger logger; - logger.info("Extracting block id to item id map..."); - auto nbt = createCompound(); - json json; - - int i = -2000; - while (i <= 2000) { - auto item = ItemRegistryManager::getItemRegistry().getItem(static_cast(i)); - i++; - if (item.expired() || item.get() == nullptr) { - continue; - } - logger.text("Extracting block id to item id map:" + item.get()->getFullItemName()); - string item_id = item->getFullItemName(); - auto& block = item->getLegacyBlock(); - string block_id; - bool hasBlock = !block.expired() && block.get() != nullptr; - if (hasBlock) - block_id = block->getNamespace() + ":" + block->getRawNameId(); - //HACK: 这是一个BDSçš„bug, 我们需è¦æ‰‹åŠ¨ä¿®å¤ - //TODO: 删除这个HACK当BDSä¿®å¤äº†ä¹‹åŽ - if (item_id.ends_with("_hanging_sign") || item_id == "minecraft:bamboo_door" || item_id == "minecraft:cherry_door") { - hasBlock = true; - block_id = item_id; - } - if (hasBlock) { - nbt->putString(block_id, item_id); - json[block_id] = item_id; - logger.info(block_id + " -> " + item_id); - } - } - - writeNBT("data/block_id_to_item_id_map.nbt", nbt.get()); - nbt.release(); - writeJSON("data/block_id_to_item_id_map.json", json); - logger.info(R"(Block id to item id map has been saved to "data/block_id_to_item_id_map.json", "data/block_id_to_item_id_map.nbt"))"); -} - - -void dumpBiomeData() { - Logger logger; - BiomeRegistry const& registry = mc->getLevel()->getBiomeRegistry(); - auto biomeInfoMap = json::object(); - auto biomes = createCompound(); - registry.forEachBiome([&biomes, ®istry, &logger, &biomeInfoMap](Biome& biome) { - string name = ll::memory::dAccess(&biome, 8).getString(); - int id = ll::memory::dAccess(&biome, 136); - logger.info("Extracting biome data - " + name); - auto tag = createCompound(); - TagRegistry, IDType>& tagRegistry = const_cast, struct IDType>&>(registry.getTagRegistry()); - biome.writePacketData(*tag, tagRegistry); - biomes->put(name, tag->copy()); - - auto obj = json::object(); - obj["id"] = id; - obj["type"] = string(magic_enum::enum_name(biome.getBiomeType())); - biomeInfoMap[name] = obj; - }); - writeNBT("data/biome_definitions.nbt", biomes.get()); - biomes.release(); - writeJSON("data/biome_id_and_type.json", biomeInfoMap); - logger.info(R"(Biome definitions has been saved to "data/biome_definitions.nbt" and "data/biome_id_and_type.json")"); -} - -void dumpCommandArgData() { - //Logger logger; - - //CommandRegistry& registry = commands->getRegistry(); - //auto global = json::object(); - //registry.forEachNonTerminal([&logger, &global,®istry](auto symbol) { - // //buggy toString - // string sym = registry.symbolToString(symbol); - // logger.info("Extracting command arg type - " + sym); - // auto obj = json::object(); - // obj["value"] = symbol.value(); - // obj["index"] = symbol.toIndex(); - // global[sym] = obj; - // }); - //writeJSON("data/command_arg_types.json", global); - //logger.info("Command arg type data have been saved to \"data/command_arg_types.json\""); -} - -void dumpAvailableCommand() { - /*Logger logger; - - CommandRegistry& registry = commands->getRegistry(); - auto aCmdPk = registry.serializeAvailableCommands(); - logger.info("Extracting available command data..."); - - auto global = json::object(); - - logger.info("Extracting all enums..."); - global["allEnums"] = aCmdPk.mEnumValues; - logger.info("Extracting all suffix..."); - global["allSuffix"] = aCmdPk.mPostfixes; - - logger.info("Extracting enum data array..."); - auto enumDataArray = json::array(); - for (auto& enumData : aCmdPk.mEnums) { - auto obj = json::object(); - - obj["name"] = enumData.name; - obj["valueIndices"] = enumData.valueIndices; - - enumDataArray.push_back(obj); - } - global["enumDatas"] = enumDataArray; - - logger.info("Extracting chained subcommand value array..."); - global["chainedSubcommandValues"] = aCmdPk.mSubcommandValues; - - logger.info("Extracting chained subcommand array..."); - auto chainedSubcommandArray = json::array(); - for (auto& chainedSubcommand : aCmdPk.mSubcommands) { - auto chainedSubcommandDataObj = json::object(); - - chainedSubcommandDataObj["name"] = chainedSubcommand.name; - - auto valueIndices = json::array(); - for (auto& valueIndice : chainedSubcommand.valueIndices) { - auto valueIndicesObj = json::object(); - valueIndicesObj["index"] = valueIndice.index; - valueIndicesObj["value"] = valueIndice.value; - - valueIndices.push_back(valueIndicesObj); - } - - chainedSubcommandDataObj["valueIndices"] = valueIndices; - - chainedSubcommandArray.push_back(chainedSubcommandDataObj); - } - global["chainedSubcommands"] = chainedSubcommandArray; - - logger.info("Extracting command data array..."); - auto commandDataArray = json::array(); - for (auto& commandData : aCmdPk.mCommands) { - auto obj = json::object(); - - obj["name"] = commandData.name; - obj["description"] = commandData.description; - obj["flag"] = commandData.flag.value; - obj["perm"] = commandData.perm; - auto overloads = json::array(); - for (auto& overload : commandData.overloads) { - auto overloadData = json::object(); - auto overloadParams = json::array(); - - for (auto& paramData : overload.datas) { - auto paramObj = json::object(); - - paramObj["description"] = paramData.desc; - paramObj["sym"] = paramData.sym; - paramObj["optional"] = paramData.optional; - paramObj["paramOptions"] = paramData.paramOptions; - overloadParams.push_back(paramObj); - } - - overloadData["datas"] = overloadParams; - overloadData["chained"] = overload.chained; - - overloads.push_back(overloadData); - } - obj["overloads"] = overloads; - obj["chainedOffsets"] = commandData.chainedOffsets; - obj["aliasIndex"] = commandData.aliasEnumIndex; - - commandDataArray.push_back(obj); - } - global["commandData"] = commandDataArray; - - logger.info("Extracting soft enum data array..."); - auto softEnumDataArray = json::array(); - for (auto& softEnumData : aCmdPk.mSoftEnums) { - auto softEnumDataObj = json::object(); - - softEnumDataObj["name"] = softEnumData.name; - softEnumDataObj["values"] = softEnumData.values; - - softEnumDataArray.push_back(softEnumDataObj); - } - global["softEnumData"] = softEnumDataArray; - - logger.info("Extracting constrained value data array..."); - auto constrainedValueDataArray = json::array(); - for (auto& constrainedValueData : aCmdPk.mConstraints) { - auto constrainedValueDataObj = json::object(); - - constrainedValueDataObj["enumIndex"] = constrainedValueData.enumValueIndex; - constrainedValueDataObj["enumNameIndex"] = constrainedValueData.enumNameIndex; - constrainedValueDataObj["indices"] = constrainedValueData.indices; - - constrainedValueDataArray.push_back(constrainedValueDataObj); - } - global["constrainedValueData"] = constrainedValueDataArray; - writeJSON("data/available_commands.json", global); - logger.info("Available commands' data has been saved to \"data/available_commands.json\"");*/ -} - -struct PropertyType { - std::string serializationName; - std::string valueType; - std::set values; - std::string blockName; - - bool operator==(const PropertyType& other) const { - return serializationName == other.serializationName && valueType == other.valueType && values.size() == other.values.size(); - } -}; - -void dumpPropertyTypeData() { - Logger logger; - logger.info("Extracting property type data..."); - - std::map>> blockToBlockStateData; - - auto& palette = mc->getLevel()->getBlockPalette(); - for (int i = 0; i <= blockStateCounter; ++i) { - const Block& block = palette.getBlock(i); - auto name = block.getLegacyBlock().getRawNameId(); - if (!blockToBlockStateData.contains(name)) { - blockToBlockStateData[name] = std::vector>(); - } - auto& blockStates = blockToBlockStateData[name]; - auto nbt = block.getSerializationId().clone(); - if (nbt->contains("states") && !nbt->getCompound("states")->isEmpty()) { - blockStates.push_back(nbt->getCompound("states")->clone()); - } - } - - std::map> blockToPropertyTypeMap; - - for (auto& entry : blockToBlockStateData) { - auto& states = entry.second; - std::map propertyTypeMap; - - for (auto& state : states) { - for (auto& valueEntry : state->rawView()) { - if (!propertyTypeMap.contains(valueEntry.first)) { - PropertyType p; - p.serializationName = valueEntry.first; - p.blockName = entry.first; - propertyTypeMap[p.serializationName] = p; - } - auto& propertyType = propertyTypeMap[valueEntry.first]; - switch (valueEntry.second.get()->getId()) { - case Tag::Type::Byte: - if (propertyType.valueType.empty()) { - propertyType.valueType = "BOOLEAN"; - } - propertyType.values.insert(state->getBoolean(valueEntry.first) ? "true" : "false"); - break; - case Tag::Type::Int: - if (propertyType.valueType.empty()) { - propertyType.valueType = "INTEGER"; - } - propertyType.values.insert(to_string(state->getInt(valueEntry.first))); - break; - case Tag::Type::String: - if (propertyType.valueType.empty()) { - propertyType.valueType = "ENUM"; - } - propertyType.values.insert(state->getString(valueEntry.first)); - break; - default: - if (propertyType.valueType.empty()) { - propertyType.valueType = "UNKNOWN"; - } - logger.warn("Unknown tag type when dumping property type data: " + valueEntry.first); - break; - } - } - } - blockToPropertyTypeMap[entry.first] = propertyTypeMap; - } - - std::set differentSizePropertyTypes; - std::map> specialBlockTypes; - std::map tmpLookUp; - - for (auto& entry : blockToPropertyTypeMap) { - for (auto& entryInside : entry.second) { - auto& propertyName = entryInside.first; - auto& propertyType = entryInside.second; - if (!tmpLookUp.contains(propertyName)) { - tmpLookUp[propertyName] = propertyType; - } - else if (tmpLookUp[propertyName] != propertyType && !differentSizePropertyTypes.contains(propertyName)) { - //å–值范围ä¸åŒçš„åŒåæ–¹å—属性 - logger.warn("Property type \"" + propertyName + "\" has different size in different blocks!"); - differentSizePropertyTypes.insert(propertyName); - auto fullBlockName = "minecraft:" + entry.first; - if (!specialBlockTypes.contains(fullBlockName)) { - specialBlockTypes[fullBlockName] = std::map(); - } - } - } - } - - std::map globalPropertyTypeMap; - - for (auto& entry : blockToPropertyTypeMap) { - for (auto& entryInside : entry.second) { - auto& propertyName = entryInside.first; - auto& propertyType = entryInside.second; - auto keyName = std::string(propertyName); - string::size_type pos = 0; - while ((pos = keyName.find(':', pos)) != string::npos) - { - keyName.replace(pos, 1, "_"); - pos++; - } - if (!differentSizePropertyTypes.contains(propertyName)) { - globalPropertyTypeMap[keyName] = propertyType; - } - else { - auto newKey = keyName + "_" + to_string(propertyType.values.size()); - auto fullBlockName = "minecraft:" + entry.first; - specialBlockTypes[fullBlockName][keyName] = newKey; - globalPropertyTypeMap[newKey] = propertyType; - } - } - } - - auto globalJson = json::object(); - auto propertyTypes = json::object(); - - for (auto& propertyTypeEntry : globalPropertyTypeMap) { - if (propertyTypeEntry.second.serializationName.empty()) { - continue; - } - auto obj = json::object(); - - obj["serializationName"] = propertyTypeEntry.second.serializationName; - obj["valueType"] = propertyTypeEntry.second.valueType; - if (propertyTypeEntry.second.valueType == "INTEGER") { - //æŽ’åº propertyTypeEntry.second.values 中的值 - std::vector values; - for (auto& value : propertyTypeEntry.second.values) { - values.push_back(stoi(value)); - } - std::sort(values.begin(), values.end()); - obj["values"] = values; - } - else if (propertyTypeEntry.second.valueType == "BOOLEAN") { - //转æ¢æˆbool - std::vector values{ false, true }; - obj["values"] = values; - } - else { - obj["values"] = propertyTypeEntry.second.values; - } - - propertyTypes[propertyTypeEntry.first] = obj; - } - globalJson["propertyTypes"] = propertyTypes; - globalJson["differentSizePropertyTypes"] = differentSizePropertyTypes; - globalJson["specialBlockTypes"] = specialBlockTypes; - writeJSON("data/block_property_types.json", globalJson); - logger.info("Block property type data have been saved to \"data/block_property_types.json\""); -} - -void dumpItemTags() { -#define DUMP(C) \ - do { \ - auto items = ItemRegistryManager::getItemRegistry().lookupByTag(VanillaItemTags::##C); \ - auto arr = nlohmann::json::array(); \ - for (auto item : items) { \ - arr.push_back(item->getFullItemName()); \ - } \ - res[VanillaItemTags::##C.getString()] = arr; \ - } while (false) - nlohmann::json res = nlohmann::json::object(); - DUMP(Armor); - DUMP(Arrows); - DUMP(Banners); - DUMP(Boat); - DUMP(Boats); - DUMP(BookshelfBooks); - DUMP(ChainmailTier); - DUMP(ChestBoat); - DUMP(Coals); - DUMP(Cooked); - DUMP(CrimsonStems); - DUMP(DecoratedPotSherds); - DUMP(DiamondTier); - DUMP(Digger); - DUMP(Door); - DUMP(Fishes); - DUMP(Food); - DUMP(GoldenTier); - DUMP(HangingActor); - DUMP(HangingSign); - DUMP(Hatchet); - DUMP(Hoe); - DUMP(HorseArmor); - DUMP(IronTier); - DUMP(LeatherTier); - DUMP(LecternBooks); - DUMP(Logs); - DUMP(LogsThatBurn); - DUMP(MangroveLogs); - DUMP(Meat); - DUMP(Minecart); - DUMP(MusicDiscs); - DUMP(NetheriteTier); - DUMP(Pickaxe); - DUMP(PiglinLoved); - DUMP(PiglinRepellents); - DUMP(Planks); - DUMP(Sand); - DUMP(Shovel); - DUMP(Sign); - DUMP(SoulFireBaseBlocks); - DUMP(SpawnEgg); - DUMP(StoneBricks); - DUMP(StoneCraftingMaterials); - DUMP(StoneTier); - DUMP(StoneToolMaterials); - DUMP(Sword); - DUMP(Tool); - DUMP(TransformMaterials); - DUMP(TransformTemplates); - DUMP(TransformableItems); - DUMP(Trident); - DUMP(TrimMaterials); - DUMP(TrimTemplates); - DUMP(TrimmableArmors); - DUMP(VibrationDamper); - DUMP(WarpedStems); - DUMP(WoodenSlabs); - DUMP(WoodenTier); - DUMP(Wool); -#undef DUMP - writeJSON("data/item_tags.json", res); -} - -void dumpBlockTags() { - nlohmann::json res = nlohmann::json::object(); -#define DUMP(TAG) \ - do { \ - auto arr = nlohmann::json::array(); \ - BlockTypeRegistry::forEachBlock([&arr](const BlockLegacy &b) { \ - if (b.hasTag(VanillaBlockTags::##TAG)) { \ - arr.push_back(b.getRawNameId()); \ - } \ - return true; \ - }); \ - res[VanillaBlockTags::##TAG.getString()] = arr; \ - } while (false) - DUMP(Acacia); - DUMP(Birch); - DUMP(Crop); - DUMP(DarkOak); - DUMP(DiamondDiggable); - DUMP(Dirt); - DUMP(FertilizeArea); - DUMP(GoldDiggable); - DUMP(Grass); - DUMP(Gravel); - DUMP(IronDiggable); - DUMP(Jungle); - DUMP(Log); - DUMP(Metal); - DUMP(MobSpawner); - DUMP(NotFeatureReplaceable); - DUMP(Oak); - DUMP(Plant); - DUMP(Pumpkin); - DUMP(Rail); - DUMP(Sand); - DUMP(Snow); - DUMP(Spruce); - DUMP(Stone); - DUMP(StoneDiggable); - DUMP(TextSign); - DUMP(Water); - DUMP(Wood); - DUMP(WoodDiggable); -#undef DUMP - writeJSON("data/block_tags.json", res); -} \ No newline at end of file diff --git a/src/DataExtractor.h b/src/DataExtractor.h deleted file mode 100644 index 5492a6ace..000000000 --- a/src/DataExtractor.h +++ /dev/null @@ -1,180 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "zlib.h" -#include "magic_enum.hpp" -#include -#include - -//ll header -#include "ll/memory/Hook.h" -#include "ll/memory/Memory.h" - -//mc header -#include "mc/Minecraft.h" -#include "mc/MinecraftCommands.h" -#include "mc/IDataOutput.h" -#include "mc/common/HashedString.h" -#include "mc/world/Dimension.h" -#include "mc/math/AABB.h" -#include "mc/math/Vec3.h" -#include "mc/network/CraftingDataPacket.h" -#include "mc/network/BinaryStream.h" -#include "mc/network/ReadOnlyBinaryStream.h" -#include "mc/nbt/NbtIo.h" -#include "mc/CreativeItemRegistry.h" -#include "mc/item/ItemInstance.h" -#include "mc/item/ItemStack.h" -#include "mc/item/Item.h" -#include "mc/item/ItemRegistryManager.h" -#include "mc/item/ItemRegistryRef.h" -#include "mc/nbt/CompoundTag.h" -#include "mc/util/ItemColorUtil.h" -#include "mc/world/Level.h" -#include "mc/world/BlockPalette.h" -#include "mc/world/BlockLegacy.h" -#include "mc/world/Block.h" -#include "mc/world/Experiments.h" -#include "mc/world/LevelData.h" -#include "mc/world/ActorFactory.h" -#include "mc/ActorDefinitionIdentifier.h" -#include "mc/world/BiomeRegistry.h" -#include "mc/world/Biome.h" -#include "mc/world/ItemTag.h" -#include "mc/world/VanillaItemTags.h" -#include "mc/world/VanillaBlockTags.h" -#include "mc/world/BlockTypeRegistry.h" -#include "mc/world/BlockSource.h" -#include "mc/world/Mob.h" -#include "mc/world/Material.h" -#include "mc/util/Spawner.h" -#include "mc/common/Brightness.h" -#include "mc/math/BlockPos.h" -#include "mc/util/json/Value.h" - -class ServerNetworkHandler { -public: - // symbol: ?handle@ServerNetworkHandler@@UEAAXAEBVNetworkIdentifier@@AEBVTextPacket@@@Z - // Ö»ÊÇÇ°ÏòÉùÃ÷ÕâÁ½¸öÀà×÷Ϊ²ÎÊý£¬²»ÐèÒªµ¼ÈëËüÃÇ - MCVAPI void handle(class NetworkIdentifier const&, class TextPacket const&); -}; -struct BiomeTagIDType; -struct BiomeTagSetIDType; -class GetCollisionShapeInterface { -public: - // prevent constructor by default - GetCollisionShapeInterface& operator=(GetCollisionShapeInterface const&); - GetCollisionShapeInterface(GetCollisionShapeInterface const&); - GetCollisionShapeInterface(); -}; - -class BigEndianStringByteOutput { - void writeBigEndianBytes(std::byte* bytes, size_t count) { - auto right = bytes + count - 1; - if (right >= bytes) { - auto left = bytes; - do { - auto tmp = *left; - *left = *right; - *right-- = tmp; - } while (left++ < right); - } - writeBytes(bytes, count); - } - -public: - virtual ~BigEndianStringByteOutput() = default; - ; - virtual void* writeString(std::string_view string_span) { - void* (*rv)(void*, std::string_view); - *((void**)&rv) = LL_RESOLVE_SYMBOL("?writeString@BytesDataOutput@@UEAAXV?$basic_string_view@DU?$char_traits@D@std@@@std@@@Z"); - return (*rv)((void*)this, std::move(string_span)); - } - - virtual void* writeLongString(std::string_view string_span) { - void* (*rv)(void*, std::string_view); - *((void**)&rv) = LL_RESOLVE_SYMBOL("?writeLongString@BytesDataOutput@@UEAAXV?$basic_string_view@DU?$char_traits@D@std@@@std@@@Z"); - return (*rv)((void*)this, std::move(string_span)); - } - virtual void writeFloat(float data) { - writeBigEndianBytes((std::byte*)&data, 4); - } - virtual void writeDouble(double data) { - writeBigEndianBytes((std::byte*)&data, 8); - } - virtual void writeByte(std::byte data) { - writeBytes(&data, 1); - } - virtual void writeShort(short data) { - writeBigEndianBytes((std::byte*)&data, 2); - } - virtual void writeInt(int data) { - writeBigEndianBytes((std::byte*)&data, 4); - } - virtual void writeLongLong(long long data) { - writeBigEndianBytes((std::byte*)&data, 8); - } - virtual void* writeBytes(std::byte* bytes, size_t count) { - void* (*rv)(void*, std::byte*, size_t); - *((void**)&rv) = LL_RESOLVE_SYMBOL("?writeBytes@StringByteOutput@@UEAAXPEBX_K@Z"); - return (*rv)((void*)this, bytes, count); - } -}; - -class Logger { -public: - void error(const std::string& error) { - std::cout << "\033[0;1;31m" << error << "\033[0m" << std::endl; - } - - void warn(const std::string& warn) { - std::cout << "\033[0;1;33m" << warn << "\033[0m" << std::endl; - } - - void info(const std::string& info) { - std::cout << "\033[0;1;32m" << info << "\033[0m" << std::endl; - } - - void text(const std::string& info) { - std::cout << "\033[0;1;37m" << info << "\033[0m" << std::endl; - } -}; -void extractData(); - -void dumpBlockAttributesData(); - -void dumpItemData(); - -void dumpEntityData(); - -void dumpCreativeItemData(); - -void dumpPalette(); - -void dumpBlockIdToItemIdMap(); - -void dumpBiomeData(); - -void dumpCommandArgData(); - -void dumpAvailableCommand(); - -void dumpItemTags(); - -void dumpBlockTags(); - -void dumpEntityAABB(const Level* level, const std::pair& pair, - nlohmann::basic_json>& obj); - -void dumpPropertyTypeData(); - -static void writeJSON(const std::string& fileName, const Json::Value& json); - -static void writeJSON(const std::string& fileName, const nlohmann::json& json); - -static bool folderExists(std::string folderName); - -static void createFolder(std::string folderName); \ No newline at end of file diff --git a/src/DllMain.cpp b/src/DllMain.cpp new file mode 100644 index 000000000..b2d0c6894 --- /dev/null +++ b/src/DllMain.cpp @@ -0,0 +1,32 @@ +#include + +#include + +#include "Plugin.h" + +namespace plugin { + +// The global plugin instance. +std::unique_ptr plugin = nullptr; + +extern "C" { +_declspec(dllexport) bool ll_plugin_load(ll::plugin::NativePlugin& self) { + plugin = std::make_unique(self); + + return true; +} + +/// @warning Unloading the plugin may cause a crash if the plugin has not released all of its +/// resources. If you are unsure, keep this function commented out. +// _declspec(dllexport) bool ll_plugin_unload(ll::plugin::Plugin&) { +// plugin.reset(); +// +// return true; +// } + +_declspec(dllexport) bool ll_plugin_enable(ll::plugin::NativePlugin&) { return plugin->enable(); } + +_declspec(dllexport) bool ll_plugin_disable(ll::plugin::NativePlugin&) { return plugin->disable(); } +} + +} // namespace plugin diff --git a/src/Plugin.cpp b/src/Plugin.cpp new file mode 100644 index 000000000..f19de8077 --- /dev/null +++ b/src/Plugin.cpp @@ -0,0 +1,733 @@ +// Basic +#include +#include +#include + +// Compress +#include "zlib.h" + +// LL +#include "Plugin.h" +#include +#include +#include + +// MC +// Item +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// Block +#include +#include +#include +// Level +#include +#include +#include +#include +#include +#include +#include +// Color +#include +#include +// Math +#include +#include +// Command +#include +// NBT +#include +#include + + +static bool folderExists(std::string folderName) { + struct stat info {}; + if (stat(folderName.c_str(), &info) != 0) { + return false; + } else if (info.st_mode & S_IFDIR) { + return true; + } else { + return false; + } +} + +static void createFolder(const ll::Logger& logger, const std::string folderName) { + int result = _mkdir(folderName.c_str()); + if (result != 0) { + logger.error("Failed to create folder."); + } else { + logger.info("Folder " + std::string(folderName) + " created successfully."); + } +} + +static bool gzip_compress(const std::string& original_str, std::string& str) { + z_stream d_stream = {0}; + if (Z_OK != deflateInit2(&d_stream, Z_BEST_COMPRESSION, Z_DEFLATED, MAX_WBITS + 16, 9, Z_DEFAULT_STRATEGY)) { + return false; + } + unsigned long len = compressBound(original_str.size()); + auto* buf = (unsigned char*)malloc(len); + if (!buf) { + return false; + } + d_stream.next_in = (unsigned char*)(original_str.c_str()); + d_stream.avail_in = original_str.size(); + d_stream.next_out = buf; + d_stream.avail_out = len; + deflate(&d_stream, Z_SYNC_FLUSH); + deflateEnd(&d_stream); + str.assign((char*)buf, d_stream.total_out); + free(buf); + return true; +} + +static void writeNBT(const std::string& fileName, const CompoundTag& tag) { + std::string compressed; + gzip_compress(tag.toBinaryNbt(false), compressed); + auto out = std::ofstream(fileName, std::ofstream::out | std::ofstream::binary | std::ofstream::trunc); + out << compressed; + out.close(); +} + +static void writeJSON(const std::string& fileName, const nlohmann::json& json) { + auto out = std::ofstream(fileName, std::ofstream::out | std::ofstream::trunc); + out << json.dump(4); + out.close(); +} + +static void writeJSON(const std::string& fileName, const Json::Value& json) { + auto out = std::ofstream(fileName, std::ofstream::out | std::ofstream::trunc); + out << json.toStyledString(); + out.close(); +} + +static std::string aabbToStr(const AABB& aabb) { + std::stringstream aabbStr; + aabbStr << aabb.min.x << "," << aabb.min.y << "," << aabb.min.z << "," << aabb.max.x << "," << aabb.max.y << "," + << aabb.max.z; + return aabbStr.str(); +} + +namespace plugin { + +void dumpCreativeItemData(ll::Logger& logger) { + logger.info("Extracting creative items..."); + + auto global = CompoundTag(); + unsigned int index = 0; + CreativeItemRegistry::forEachCreativeItemInstance([&logger, &index, &global](const ItemInstance& itemInstance) { + if (itemInstance.getName().empty()) { + logger.warn( + "Failed to extract creative item - " + itemInstance.getName() + ", index: " + std::to_string(index) + ); + return true; + } + logger.info("Extracting creative item - " + itemInstance.getName() + ", index: " + std::to_string(index)); + auto obj = CompoundTag(); + obj.putInt64("index", index); + obj.putString("name", itemInstance.getItem()->getFullItemName()); + obj.putInt("damage", itemInstance.getAuxValue()); + if (itemInstance.isBlock()) { + obj.putInt("blockStateHash", itemInstance.getBlock()->computeRawSerializationIdHashForNetwork()); + } + auto nbt = itemInstance.save(); + if (nbt->contains("tag")) { + obj.put("tag", nbt->getCompound("tag")->copy()); + } + global.put(std::to_string(index), obj.copy()); + index++; + }); + writeNBT("data/creative_items.nbt", global); + logger.info(R"(Creative items data has been saved to "data/creative_items.nbt")"); +} + +static AABB ZERO_AABB = AABB(Vec3(0, 0, 0), Vec3(0, 0, 0)); + +void extractBlock(ListTag& dest, const Block& block, ll::Logger& logger) { + auto nbt = CompoundTag(); + try { + auto& legacy = block.getLegacyBlock(); + auto name = legacy.getNamespace() + ":" + legacy.getRawNameId(); + logger.info("Extracting block state - " + name + ":" + std::to_string(block.getRuntimeId())); + const Material& material = legacy.getMaterial(); + auto sid = block.getSerializationId().clone(); + nbt.putString("name", sid->getString("name")); + nbt.putString("descriptionId", block.getDescriptionId()); + nbt.putString("blockEntityName", std::string(magic_enum::enum_name(block.getBlockEntityType()))); + nbt.putCompound("states", sid->getCompound("states")->clone()); + nbt.putFloat("thickness", block.getThickness()); + nbt.putFloat("friction", block.getFriction()); + nbt.putFloat("hardness", block.getDestroySpeed()); + nbt.putFloat("explosionResistance", block.getExplosionResistance()); + nbt.putFloat("translucency", material.getTranslucency()); + nbt.putInt("version", sid->getInt("version")); + nbt.putInt("runtimeId", block.getRuntimeId()); + nbt.putInt( + "blockStateHash", + ((name != "minecraft:unknown") ? block.computeRawSerializationIdHashForNetwork() : -2) + ); + nbt.putInt("burnChance", block.getFlameOdds()); + nbt.putInt("burnAbility", block.getBurnOdds()); + nbt.putInt("lightDampening", (int)block.getLight().value); // ���� + nbt.putInt("lightEmission", (int)block.getLightEmission().value); // ���� + mce::Color color = block.getMapColor( + ll::service::getLevel()->getDimension(DimensionType(0))->getBlockSourceFromMainChunkSource(), + BlockPos(0, 10, 0) + ); + auto colornbt = CompoundTag(); + colornbt.putInt("r", (int)(color.r * 255)); + colornbt.putInt("g", (int)(color.g * 255)); + colornbt.putInt("b", (int)(color.b * 255)); + colornbt.putInt("a", (int)(color.a * 255)); + colornbt.putString("hexString", color.toHexString()); + nbt.putCompound("color", colornbt); + AABB tmp = AABB(0, 0, 0, 0, 0, 0); + block.getCollisionShapeForCamera( + tmp, + *(IConstBlockSource*)&ll::service::getLevel() + ->getDimension(DimensionType(0)) + ->getBlockSourceFromMainChunkSource(), + BlockPos(0, 0, 0) + ); + nbt.putString("aabbVisual", aabbToStr(tmp)); + AABB tmp2 = AABB(0, 0, 0, 0, 0, 0); + class optional_ref nullRef {}; + block.getCollisionShape( + tmp2, + *(IConstBlockSource*)&ll::service::getLevel() + ->getDimension(DimensionType(0)) + ->getBlockSourceFromMainChunkSource(), + BlockPos(0, 0, 0), + nullRef + ); + nbt.putString("aabbCollision", aabbToStr(tmp2)); + nbt.putBoolean("hasCollision", tmp2 != ZERO_AABB); + nbt.putBoolean("hasBlockEntity", block.getBlockEntityType() != BlockActorType::Undefined); + nbt.putBoolean("isAir", block.isAir()); + nbt.putBoolean("isBounceBlock", block.isAir()); + nbt.putBoolean("isButtonBlock", block.isButtonBlock()); + nbt.putBoolean("isCropBlock", block.isCropBlock()); + nbt.putBoolean("isDoorBlock", block.isDoorBlock()); + nbt.putBoolean("isFenceBlock", block.isFenceBlock()); + nbt.putBoolean("isFenceGateBlock", block.isFenceGateBlock()); + nbt.putBoolean("isThinFenceBlock", block.isThinFenceBlock()); + nbt.putBoolean("isFallingBlock", block.isFallingBlock()); + nbt.putBoolean("isStemBlock", block.isStemBlock()); + nbt.putBoolean("isSlabBlock", block.isSlabBlock()); + nbt.putBoolean("isLiquid", material.isLiquid()); + nbt.putBoolean("isAlwaysDestroyable", material.isAlwaysDestroyable()); // �Ƿ���Ա������ƻ��һ�ȡ���� + nbt.putBoolean("isLavaFlammable", block.isLavaFlammable()); // �Ƿ��ȼ + nbt.putBoolean("isUnbreakable", block.isUnbreakable()); // �Ƿñ²»¿ï¿½ï¿½Æ»ï¿½ + nbt.putBoolean("isPowerSource", block.isSignalSource()); + // nbt->putBoolean("breaksFallingBlocks", block.breaksFallingBlocks(BaseGameVersion()));δ֪���� + nbt.putBoolean("isWaterBlocking", block.isWaterBlocking()); // �Ƿ����赲ˮ + nbt.putBoolean("isMotionBlockingBlock", block.isMotionBlockingBlock()); // �Ƿ����赲�ƶ� + nbt.putBoolean("hasComparatorSignal", block.hasComparatorSignal()); // �Ƿ��ܲ����Ƚ����ź� + nbt.putBoolean("pushesUpFallingBlocks", block.pushesUpFallingBlocks()); // �����෽�� + // nbt->putBoolean("waterSpreadCausesSpawn", block.waterSpreadCausesSpawn());δ֪���� + nbt.putBoolean("canContainLiquid", block.getLegacyBlock().canContainLiquid()); + // nbt->putBoolean("canBeMovingBlock", material.getBlocksMotion());��isMotionBlockingBlockһ������ + // nbt->putBoolean("blocksPrecipitation", material.getBlocksPrecipitation());δ֪���� + nbt.putBoolean("superHot", material.isSuperHot()); // ���Ե����Ż�ķ��� + // nbt->putBoolean("canBeBrokenFromFalling", block.canBeBrokenFromFalling());δ֪���� + nbt.putBoolean("isSolid", block.isSolid()); + // nbt->putBoolean("isSolidBlocking", material.isSolidBlocking());δ֪���� + nbt.putBoolean("isContainerBlock", block.isContainerBlock()); + + } catch (std::exception& e) { + logger.error("Exception caught : " + std::string(e.what())); + } + + dest.add(nbt); +} + +static unsigned int blockStateCounter = 0; + +void dumpBlockAttributesData(ll::Logger& logger) { + logger.info("Extracting block states' attributes..."); + const auto& palette = ll::service::getLevel()->getBlockPalette(); + int airCount = 0; + auto array = nlohmann::json::array(); + + auto tag = CompoundTag(); + auto list = ListTag(); + blockStateCounter = 0; + while (true) { + const auto& block = palette.getBlock(blockStateCounter); + // HACK: ����ȷ�����size + if (block.getName().getString() == "minecraft:air") { + airCount++; + if (airCount == 2) { + blockStateCounter--; + break; + } + } + extractBlock(list, block, logger); + blockStateCounter++; + } + tag.put("block", list.copyList()); + logger.info("Successfully extract " + std::to_string(blockStateCounter) + " block states' attributes!"); + writeNBT("data/block_attributes.nbt", tag); + logger.info(R"(Block attribute data have been saved to "data/block_attributes.nbt")"); +} + +void extractItem(ListTag& dest, const Item& item, ll::Logger& logger) { + auto nbt = CompoundTag(); + logger.info("Extracting item - " + item.getFullItemName()); + nbt.putShort("id", item.getId()); + try { + if (!item.getLegacyBlock().expired() && item.getLegacyBlock().get() != nullptr) + nbt.putString( + "blockId", + item.getLegacyBlock()->getNamespace() + ":" + item.getLegacyBlock()->getRawNameId() + ); + } catch (std::exception& e) { + logger.warn("Exception occur when trying to get block for item " + item.getFullItemName()); + } + nbt.putBoolean("isComponentBased", item.isComponentBased()); + nbt.putString("name", item.getFullItemName()); + nbt.putShort("maxDamage", item.getMaxDamage()); // ����;� + nbt.putBoolean("isArmor", item.isArmor()); + nbt.putBoolean("isBlockPlanterItem", item.isBlockPlanterItem()); + nbt.putBoolean("isDamageable", item.isDamageable()); + nbt.putBoolean("isDye", item.isDye()); + nbt.putString("itemColorName", ItemColorUtil::getName(item.getItemColor())); + nbt.putInt("itemColorRGB", ItemColorUtil::getRGBColor(item.getItemColor())); + nbt.putBoolean("isFertilizer", item.isFertilizer()); + nbt.putBoolean("isThrowable", item.isThrowable()); + nbt.putBoolean("isFood", item.isFood()); + nbt.putBoolean("isUseable", item.isUseable()); + nbt.putBoolean("isElytra", item.isElytra()); + nbt.putBoolean("canBeDepleted", item.canBeDepleted()); + nbt.putBoolean("canDestroyInCreative", item.canDestroyInCreative()); + nbt.putBoolean("canUseOnSimTick", item.canUseOnSimTick()); + nbt.putBoolean("canBeCharged", item.canBeCharged()); + nbt.putString("creativeGroup", item.getCreativeGroup()); + nbt.putInt("creativeCategory", (int)item.getCreativeCategory()); + nbt.putInt("armorValue", item.getArmorValue()); + nbt.putInt("attackDamage", item.getAttackDamage()); + nbt.putInt("toughnessValue", item.getToughnessValue()); + nbt.putFloat("viewDamping", item.getViewDamping()); + nbt.putInt("cooldownTime", item.getCooldownTime()); + nbt.putString("cooldownType", item.getCooldownType().getString()); + // ��Щ��ƷgetMaxStackSize����255����ʱ�����ԭ�� + nbt.putInt("maxStackSize", item.getMaxStackSize(item.buildDescriptor(0, nullptr))); + CompoundTag descriptionId; + std::set uniqueStr; + for (int i = 0; i <= 256; ++i) { + try { + if (item.isValidAuxValue(i)) { + const auto itemstack = ItemStack(item, 1, i); // ignore some invaild aux exception + if (!uniqueStr.contains(itemstack.getDescriptionId())) { + uniqueStr.insert(itemstack.getDescriptionId()); + descriptionId.putString(std::to_string(i), itemstack.getDescriptionId()); + } + } + } catch (...) {} + } + nbt.putCompound("descriptionId", descriptionId); + dest.add(nbt); +} + +void dumpItemData(ll::Logger& logger) { + auto tag = CompoundTag(); + auto list = ListTag(); + short counter = 0; + for (auto& kv : ItemRegistryManager::getItemRegistry().getNameToItemMap()) { + auto item = kv.second; + extractItem(list, *item, logger); + counter++; + } + tag.put("item", list); + logger.info("Successfully extract " + std::to_string(counter) + " items' data!"); + writeNBT("data/item_data.nbt", tag); + logger.info(R"(Items' data have been saved to "data/item_data.nbt")"); +} + +void dumpPalette(ll::Logger& logger) { + logger.info("Extracting block palette..."); + + auto& palette = ll::service::getLevel()->getBlockPalette(); + + auto global = CompoundTag(); + auto blocks = ListTag(); + for (int i = 0; i <= blockStateCounter; ++i) { + blocks.add(palette.getBlock(i).getSerializationId().clone()); + } + global.put("blocks", blocks); + writeNBT("data/block_palette.nbt", global); + logger.info(R"(Block palette table has been saved to "data/block_palette.nbt"))"); +} + +void dumpCommandArgData(ll::Logger& logger) { + CommandRegistry& registry = ll::service::getCommandRegistry(); + auto global = nlohmann::json::object(); + for (auto& symbol : registry.mCommandSymbols) { + // symbol�����⣬���û�����쳣 + if (!registry.isValid(symbol)) { + continue; + } + std::string sym = registry.symbolToString(symbol); + logger.info("Extracting command arg type - " + sym); + auto obj = nlohmann::json::object(); + obj["value"] = symbol.value(); + obj["index"] = symbol.toIndex(); + global[sym] = obj; + } + writeJSON("data/command_arg_types.json", global); + logger.info("Command arg type data have been saved to \"data/command_arg_types.json\""); +} + +void dumpBiomeData(ll::Logger& logger) { + BiomeRegistry& registry = ll::service::getLevel()->getBiomeRegistry(); + auto biomeInfoMap = nlohmann::json::object(); + auto biomes = CompoundTag(); + TagRegistry, IDType>& tagReg = registry.getTagRegistry(); + registry.forEachBiome([&biomes, ®istry, &logger, &tagReg, &biomeInfoMap](Biome& biome) { + auto& name = biome.getName(); + int id = biome.getId(); + logger.info("Extracting biome data - " + name); + auto tag = CompoundTag(); + biome.writePacketData(tag, tagReg); + biomes.put(name, tag); + auto obj = nlohmann::json::object(); + obj["id"] = id; + obj["type"] = std::string(magic_enum::enum_name(biome.getBiomeType())); + biomeInfoMap[name] = obj; + }); + writeNBT("data/biome_definitions.nbt", biomes); + writeJSON("data/biome_id_and_type.json", biomeInfoMap); + logger.info(R"(Biome definitions has been saved to "data/biome_definitions.nbt" and "data/biome_id_and_type.json")" + ); +} + +struct PropertyType { + std::string serializationName; + std::string valueType; + std::set values; + std::string blockName; + + bool operator==(const PropertyType& other) const { + return serializationName == other.serializationName && valueType == other.valueType + && values.size() == other.values.size(); + } +}; + + +void dumpPropertyTypeData(ll::Logger& logger) { + logger.info("Extracting property type data..."); + + std::map>> blockToBlockStateData; + + auto& palette = ll::service::getLevel()->getBlockPalette(); + for (int i = 0; i <= blockStateCounter; ++i) { + const Block& block = palette.getBlock(i); + auto name = block.getLegacyBlock().getRawNameId(); + if (!blockToBlockStateData.contains(name)) { + blockToBlockStateData[name] = std::vector>(); + } + auto& blockStates = blockToBlockStateData[name]; + auto nbt = block.getSerializationId().clone(); + if (nbt->contains("states") && !nbt->getCompound("states")->isEmpty()) { + blockStates.push_back(nbt->getCompound("states")->clone()); + } + } + + std::map> blockToPropertyTypeMap; + + for (auto& entry : blockToBlockStateData) { + auto& states = entry.second; + std::map propertyTypeMap; + + for (auto& state : states) { + for (auto& valueEntry : state->rawView()) { + if (!propertyTypeMap.contains(valueEntry.first)) { + PropertyType p; + p.serializationName = valueEntry.first; + p.blockName = entry.first; + propertyTypeMap[p.serializationName] = p; + } + auto& propertyType = propertyTypeMap[valueEntry.first]; + switch (valueEntry.second.getId()) { + case Tag::Type::Byte: + if (propertyType.valueType.empty()) { + propertyType.valueType = "BOOLEAN"; + } + propertyType.values.insert(state->getBoolean(valueEntry.first) ? "true" : "false"); + break; + case Tag::Type::Int: + if (propertyType.valueType.empty()) { + propertyType.valueType = "INTEGER"; + } + propertyType.values.insert(std::to_string(state->getInt(valueEntry.first))); + break; + case Tag::Type::String: + if (propertyType.valueType.empty()) { + propertyType.valueType = "ENUM"; + } + propertyType.values.insert(state->getString(valueEntry.first)); + break; + default: + if (propertyType.valueType.empty()) { + propertyType.valueType = "UNKNOWN"; + } + logger.warn("Unknown tag type when dumping property type data: " + valueEntry.first); + break; + } + } + } + blockToPropertyTypeMap[entry.first] = propertyTypeMap; + } + + std::set differentSizePropertyTypes; + std::map> specialBlockTypes; + std::map tmpLookUp; + + for (auto& entry : blockToPropertyTypeMap) { + for (auto& entryInside : entry.second) { + auto& propertyName = entryInside.first; + auto& propertyType = entryInside.second; + if (!tmpLookUp.contains(propertyName)) { + tmpLookUp[propertyName] = propertyType; + } else if (tmpLookUp[propertyName] != propertyType && !differentSizePropertyTypes.contains(propertyName)) { + // ȡֵ��Χ��ͬ��ͬ���������� + logger.warn("Property type \"" + propertyName + "\" has different size in different blocks!"); + differentSizePropertyTypes.insert(propertyName); + auto fullBlockName = "minecraft:" + entry.first; + if (!specialBlockTypes.contains(fullBlockName)) { + specialBlockTypes[fullBlockName] = std::map(); + } + } + } + } + + std::map globalPropertyTypeMap; + + for (auto& entry : blockToPropertyTypeMap) { + for (auto& entryInside : entry.second) { + auto& propertyName = entryInside.first; + auto& propertyType = entryInside.second; + auto keyName = std::string(propertyName); + std::string::size_type pos = 0; + while ((pos = keyName.find(':', pos)) != std::string::npos) { + keyName.replace(pos, 1, "_"); + pos++; + } + if (!differentSizePropertyTypes.contains(propertyName)) { + globalPropertyTypeMap[keyName] = propertyType; + } else { + auto newKey = keyName + "_" + std::to_string(propertyType.values.size()); + auto fullBlockName = "minecraft:" + entry.first; + specialBlockTypes[fullBlockName][keyName] = newKey; + globalPropertyTypeMap[newKey] = propertyType; + } + } + } + + auto globalJson = nlohmann::json::object(); + auto propertyTypes = nlohmann::json::object(); + + for (auto& propertyTypeEntry : globalPropertyTypeMap) { + if (propertyTypeEntry.second.serializationName.empty()) { + continue; + } + auto obj = nlohmann::json::object(); + + obj["serializationName"] = propertyTypeEntry.second.serializationName; + obj["valueType"] = propertyTypeEntry.second.valueType; + if (propertyTypeEntry.second.valueType == "INTEGER") { + // ���� propertyTypeEntry.second.values �е�ֵ + std::vector values; + for (auto& value : propertyTypeEntry.second.values) { + values.push_back(stoi(value)); + } + std::sort(values.begin(), values.end()); + obj["values"] = values; + } else if (propertyTypeEntry.second.valueType == "BOOLEAN") { + // ת����bool + std::vector values{false, true}; + obj["values"] = values; + } else { + obj["values"] = propertyTypeEntry.second.values; + } + + propertyTypes[propertyTypeEntry.first] = obj; + } + globalJson["propertyTypes"] = propertyTypes; + globalJson["differentSizePropertyTypes"] = differentSizePropertyTypes; + globalJson["specialBlockTypes"] = specialBlockTypes; + writeJSON("data/block_property_types.json", globalJson); + logger.info("Block property type data have been saved to \"data/block_property_types.json\""); +} + +void dumpItemTags(ll::Logger& logger) { + logger.info("Extracting item tags..."); + nlohmann::json res = nlohmann::json::object(); +#define DUMP(TAG) \ + do { \ + auto items = ItemRegistryManager::getItemRegistry().lookupByTag(VanillaItemTags::##TAG); \ + auto arr = nlohmann::json::array(); \ + for (auto item : items) { \ + arr.push_back(item->getFullItemName()); \ + } \ + res[VanillaItemTags::##TAG.getString()] = arr; \ + logger.info(VanillaItemTags::##TAG.getString()); \ + } while (false) + DUMP(Armor); + DUMP(Arrows); + DUMP(Banners); + DUMP(Boat); + DUMP(Boats); + DUMP(BookshelfBooks); + DUMP(ChainmailTier); + DUMP(ChestBoat); + DUMP(Coals); + DUMP(Cooked); + DUMP(CrimsonStems); + DUMP(DecoratedPotSherds); + DUMP(DiamondTier); + DUMP(Digger); + DUMP(Door); + DUMP(Fishes); + DUMP(Food); + DUMP(GoldenTier); + DUMP(HangingActor); + DUMP(HangingSign); + DUMP(Hatchet); + DUMP(Hoe); + DUMP(HorseArmor); + DUMP(IronTier); + DUMP(LeatherTier); + DUMP(LecternBooks); + DUMP(Logs); + DUMP(LogsThatBurn); + DUMP(MangroveLogs); + DUMP(Meat); + DUMP(Minecart); + DUMP(MusicDiscs); + DUMP(NetheriteTier); + DUMP(Pickaxe); + DUMP(PiglinLoved); + DUMP(PiglinRepellents); + DUMP(Planks); + DUMP(Sand); + DUMP(Shovel); + DUMP(Sign); + DUMP(SoulFireBaseBlocks); + DUMP(SpawnEgg); + DUMP(StoneBricks); + DUMP(StoneCraftingMaterials); + DUMP(StoneTier); + DUMP(StoneToolMaterials); + DUMP(Sword); + DUMP(Tool); + DUMP(TransformMaterials); + DUMP(TransformTemplates); + DUMP(TransformableItems); + DUMP(Trident); + DUMP(TrimMaterials); + DUMP(TrimTemplates); + DUMP(TrimmableArmors); + DUMP(VibrationDamper); + DUMP(WarpedStems); + DUMP(WoodenSlabs); + DUMP(WoodenTier); + DUMP(Wool); +#undef DUMP + writeJSON("data/item_tags.json", res); +} + +void dumpBlockTags(ll::Logger& logger) { + logger.info("Extracting block tags..."); + nlohmann::json res = nlohmann::json::object(); +#define DUMP(TAG) \ + do { \ + auto arr = nlohmann::json::array(); \ + BlockTypeRegistry::forEachBlock([&arr](const BlockLegacy& b) { \ + if (b.hasTag(VanillaBlockTags::##TAG)) { \ + arr.push_back(b.getRawNameId()); \ + } \ + return true; \ + }); \ + res[VanillaBlockTags::##TAG.getString()] = arr; \ + logger.info(VanillaBlockTags::##TAG.getString()); \ + } while (false) + DUMP(Acacia); + DUMP(Birch); + DUMP(Crop); + DUMP(DarkOak); + DUMP(DiamondDiggable); + DUMP(Dirt); + DUMP(FertilizeArea); + DUMP(GoldDiggable); + DUMP(Grass); + DUMP(Gravel); + DUMP(IronDiggable); + DUMP(Jungle); + DUMP(Log); + DUMP(Metal); + DUMP(MobSpawner); + DUMP(NotFeatureReplaceable); + DUMP(Oak); + DUMP(Plant); + DUMP(Pumpkin); + DUMP(Rail); + DUMP(Sand); + DUMP(Snow); + DUMP(Spruce); + DUMP(Stone); + DUMP(StoneDiggable); + DUMP(TextSign); + DUMP(Water); + DUMP(Wood); + DUMP(WoodDiggable); +#undef DUMP + writeJSON("data/block_tags.json", res); +} + +void ext(ll::Logger& logger) { + if (!folderExists("data")) { + createFolder(logger, "data"); + } + dumpBiomeData(logger); + // dumpCommandArgData(logger); + dumpCreativeItemData(logger); + dumpBlockAttributesData(logger); + dumpItemData(logger); + dumpPalette(logger); +} + +Plugin::Plugin(ll::plugin::NativePlugin& self) : mSelf(self) { mSelf.getLogger().info("loading..."); } + +bool Plugin::disable() { + mSelf.getLogger().info("disabling..."); + return true; +} + +bool Plugin::enable() { + auto& logger = mSelf.getLogger(); + mSelf.getLogger().info("enabling..."); + + auto cmdReg = ll::service::getCommandRegistry(); + auto command = DynamicCommand::createCommand(cmdReg, "ext", "ext data", CommandPermissionLevel::Any); + command->addOverload(); + command->setCallback( + [&logger](DynamicCommand const&, CommandOrigin const& origin, CommandOutput& output, std::unordered_map&) { + ext(logger); + } + ); + DynamicCommand::setup(cmdReg, std::move(command)); + + return true; +} + +} // namespace plugin diff --git a/src/Plugin.h b/src/Plugin.h new file mode 100644 index 000000000..6fb905684 --- /dev/null +++ b/src/Plugin.h @@ -0,0 +1,28 @@ +#pragma once + +#include + +namespace plugin { + +class Plugin { +public: + explicit Plugin(ll::plugin::NativePlugin& self); + + Plugin(Plugin&&) = delete; + Plugin(const Plugin&) = delete; + Plugin& operator=(Plugin&&) = delete; + Plugin& operator=(const Plugin&) = delete; + + ~Plugin() = default; + + /// @return True if the plugin is enabled successfully. + bool enable(); + + /// @return True if the plugin is disabled successfully. + bool disable(); + +private: + ll::plugin::NativePlugin& mSelf; +}; + +} // namespace plugin diff --git a/src/ll/base/Concepts.h b/src/ll/base/Concepts.h deleted file mode 100644 index 449d792fe..000000000 --- a/src/ll/base/Concepts.h +++ /dev/null @@ -1,100 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -namespace ll::concepts { - -template -static constexpr bool is_one_of_v = (std::is_same_v || ...); - -template -struct is_one_of : std::bool_constant> {}; - -template -concept IsOneOf = is_one_of_v; - -template -static constexpr bool is_all_same_v = (std::is_same_v && ...); - -template -struct is_all_same : std::bool_constant> {}; - -template -concept IsAllSame = is_all_same_v; - -template -static constexpr bool is_string_v = std::convertible_to; - -template -concept IsString = is_string_v; - -template class Z> -concept ConceptFor = Z::value; - -template -concept Formattable = - requires(T const& v, std::format_context ctx) { std::formatter>().format(v, ctx); }; - -template -concept IsExpected = requires(T e) { - typename std::remove_cvref_t::value_type; - typename std::remove_cvref_t::error_type; - typename std::remove_cvref_t::unexpected_type; - e.has_value(); - e.error(); - requires std::is_same_v::value_type> || requires(T e) { e.value(); }; -}; - -template -concept IsOptional = !IsExpected && requires(T o) { - o.value(); - o.has_value(); - o.operator*(); - typename std::remove_cvref_t::value_type; -}; - -template -concept Rangeable = requires(T t) { - { t.begin() } -> std::same_as::iterator>; - { t.end() } -> std::same_as::iterator>; -}; - -template -concept Associative = Rangeable && requires { - typename std::remove_cvref_t::key_type; - typename std::remove_cvref_t::mapped_type; -}; - -template -concept TupleLike = !Rangeable && requires(T t) { - std::tuple_size>::value; - std::get<0>(t); -}; - -template -concept ArrayLike = Rangeable && !requires { typename std::remove_cvref_t::mapped_type; }; - -template class Z> -inline constexpr bool is_specialization_of_v = false; - -template