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