From 9acb4d64dbf641601ac7085a41fdec78cb8f94c9 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 23 Feb 2023 21:45:12 +0000 Subject: [PATCH] Added generated constants for available BedrockData files this makes it easier to detect unused files, detect removed files, and also avoid typos in usages. --- .github/workflows/main.yml | 3 + build/generate-bedrockdata-path-consts.php | 128 ++++++++++++++++++ src/data/bedrock/BedrockDataFiles.php | 54 ++++++++ .../bedrock/LegacyBiomeIdToStringIdMap.php | 3 +- .../bedrock/LegacyEntityIdToStringIdMap.php | 3 +- src/network/mcpe/cache/StaticPacketCache.php | 6 +- .../mcpe/convert/GlobalItemTypeDictionary.php | 4 +- src/network/mcpe/convert/ItemTranslator.php | 4 +- .../mcpe/convert/RuntimeBlockMapping.php | 6 +- 9 files changed, 197 insertions(+), 14 deletions(-) create mode 100644 build/generate-bedrockdata-path-consts.php create mode 100644 src/data/bedrock/BedrockDataFiles.php diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ad9fc56ec..029676a3f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -186,6 +186,9 @@ jobs: - name: Regenerate KnownTranslation APIs run: php build/generate-known-translation-apis.php + - name: Regenerate BedrockData available files constants + run: php build/generate-bedrockdata-path-consts.php + - name: Verify code is unchanged run: | git diff diff --git a/build/generate-bedrockdata-path-consts.php b/build/generate-bedrockdata-path-consts.php new file mode 100644 index 000000000..31e23c9b6 --- /dev/null +++ b/build/generate-bedrockdata-path-consts.php @@ -0,0 +1,128 @@ + $fileName){ + fwrite($output, "\tpublic const " . constantify($fileName) . " = BEDROCK_DATA_PATH . '/$fileName';\n"); +} + +fwrite($output, "}\n"); +fclose($output); + +echo "Done. Don't forget to run CS fixup after generating code.\n"; diff --git a/src/data/bedrock/BedrockDataFiles.php b/src/data/bedrock/BedrockDataFiles.php new file mode 100644 index 000000000..731c91120 --- /dev/null +++ b/src/data/bedrock/BedrockDataFiles.php @@ -0,0 +1,54 @@ +