From a895016cd1e2532f32d839ca1dd51274e4790e0c Mon Sep 17 00:00:00 2001 From: MatthewBeshay <92357869+MatthewBeshay@users.noreply.github.com> Date: Wed, 8 Apr 2026 23:11:39 +1000 Subject: [PATCH] refactor: pull DLC enums out into their own header --- targets/app/common/DLC/DLCManager.h | 74 ++++++++++--------- targets/minecraft/client/Minecraft.cpp | 2 +- .../server/network/PlayerConnection.cpp | 2 +- .../minecraft/world/entity/player/Player.cpp | 2 +- .../minecraft/world/level/dlc/DLCConstants.h | 47 ++++++++++++ 5 files changed, 88 insertions(+), 39 deletions(-) create mode 100644 targets/minecraft/world/level/dlc/DLCConstants.h diff --git a/targets/app/common/DLC/DLCManager.h b/targets/app/common/DLC/DLCManager.h index 41c534a5e..0adc2a57d 100644 --- a/targets/app/common/DLC/DLCManager.h +++ b/targets/app/common/DLC/DLCManager.h @@ -3,50 +3,52 @@ #include #include #include + +#include "minecraft/world/level/dlc/DLCConstants.h" + class DLCPack; class DLCSkinFile; class DLCManager { public: - enum EDLCType { - e_DLCType_Skin = 0, - e_DLCType_Cape, - e_DLCType_Texture, - e_DLCType_UIData, - e_DLCType_PackConfig, - e_DLCType_TexturePack, - e_DLCType_LocalisationData, - e_DLCType_GameRules, - e_DLCType_Audio, - e_DLCType_ColourTable, - e_DLCType_GameRulesHeader, + // Re-export the file-scope enums as nested type aliases so existing + // app-side call sites that use DLCManager::EDLCType / + // DLCManager::e_DLCType_Texture continue to compile. minecraft/-side + // call sites should use the namespaced names from DLCConstants.h + // directly. + using EDLCType = ::minecraft::dlc::EDLCType; + using EDLCParameterType = ::minecraft::dlc::EDLCParameterType; - e_DLCType_Max, - e_DLCType_All, - }; + static constexpr EDLCType e_DLCType_Skin = ::minecraft::dlc::e_DLCType_Skin; + static constexpr EDLCType e_DLCType_Cape = ::minecraft::dlc::e_DLCType_Cape; + static constexpr EDLCType e_DLCType_Texture = ::minecraft::dlc::e_DLCType_Texture; + static constexpr EDLCType e_DLCType_UIData = ::minecraft::dlc::e_DLCType_UIData; + static constexpr EDLCType e_DLCType_PackConfig = ::minecraft::dlc::e_DLCType_PackConfig; + static constexpr EDLCType e_DLCType_TexturePack = ::minecraft::dlc::e_DLCType_TexturePack; + static constexpr EDLCType e_DLCType_LocalisationData = ::minecraft::dlc::e_DLCType_LocalisationData; + static constexpr EDLCType e_DLCType_GameRules = ::minecraft::dlc::e_DLCType_GameRules; + static constexpr EDLCType e_DLCType_Audio = ::minecraft::dlc::e_DLCType_Audio; + static constexpr EDLCType e_DLCType_ColourTable = ::minecraft::dlc::e_DLCType_ColourTable; + static constexpr EDLCType e_DLCType_GameRulesHeader = ::minecraft::dlc::e_DLCType_GameRulesHeader; + static constexpr EDLCType e_DLCType_Max = ::minecraft::dlc::e_DLCType_Max; + static constexpr EDLCType e_DLCType_All = ::minecraft::dlc::e_DLCType_All; - // If you add to the Enum,then you need to add the array of type names - // These are the names used in the XML for the parameters - enum EDLCParameterType { - e_DLCParamType_Invalid = -1, + static constexpr EDLCParameterType e_DLCParamType_Invalid = ::minecraft::dlc::e_DLCParamType_Invalid; + static constexpr EDLCParameterType e_DLCParamType_DisplayName = ::minecraft::dlc::e_DLCParamType_DisplayName; + static constexpr EDLCParameterType e_DLCParamType_ThemeName = ::minecraft::dlc::e_DLCParamType_ThemeName; + static constexpr EDLCParameterType e_DLCParamType_Free = ::minecraft::dlc::e_DLCParamType_Free; + static constexpr EDLCParameterType e_DLCParamType_Credit = ::minecraft::dlc::e_DLCParamType_Credit; + static constexpr EDLCParameterType e_DLCParamType_Cape = ::minecraft::dlc::e_DLCParamType_Cape; + static constexpr EDLCParameterType e_DLCParamType_Box = ::minecraft::dlc::e_DLCParamType_Box; + static constexpr EDLCParameterType e_DLCParamType_Anim = ::minecraft::dlc::e_DLCParamType_Anim; + static constexpr EDLCParameterType e_DLCParamType_PackId = ::minecraft::dlc::e_DLCParamType_PackId; + static constexpr EDLCParameterType e_DLCParamType_NetherParticleColour = ::minecraft::dlc::e_DLCParamType_NetherParticleColour; + static constexpr EDLCParameterType e_DLCParamType_EnchantmentTextColour = ::minecraft::dlc::e_DLCParamType_EnchantmentTextColour; + static constexpr EDLCParameterType e_DLCParamType_EnchantmentTextFocusColour = ::minecraft::dlc::e_DLCParamType_EnchantmentTextFocusColour; + static constexpr EDLCParameterType e_DLCParamType_DataPath = ::minecraft::dlc::e_DLCParamType_DataPath; + static constexpr EDLCParameterType e_DLCParamType_PackVersion = ::minecraft::dlc::e_DLCParamType_PackVersion; + static constexpr EDLCParameterType e_DLCParamType_Max = ::minecraft::dlc::e_DLCParamType_Max; - e_DLCParamType_DisplayName = 0, - e_DLCParamType_ThemeName, - e_DLCParamType_Free, // identify free skins - e_DLCParamType_Credit, // legal credits for DLC - e_DLCParamType_Cape, - e_DLCParamType_Box, - e_DLCParamType_Anim, - e_DLCParamType_PackId, - e_DLCParamType_NetherParticleColour, - e_DLCParamType_EnchantmentTextColour, - e_DLCParamType_EnchantmentTextFocusColour, - e_DLCParamType_DataPath, - e_DLCParamType_PackVersion, - - e_DLCParamType_Max, - - }; const static char* wchTypeNamesA[e_DLCParamType_Max]; private: diff --git a/targets/minecraft/client/Minecraft.cpp b/targets/minecraft/client/Minecraft.cpp index 035b855e3..e16d15b87 100644 --- a/targets/minecraft/client/Minecraft.cpp +++ b/targets/minecraft/client/Minecraft.cpp @@ -18,7 +18,7 @@ #include "Timer.h" #include "User.h" #include "app/common/Audio/SoundEngine.h" -#include "app/common/DLC/DLCManager.h" +#include "minecraft/world/level/dlc/DLCConstants.h" #include "minecraft/network/INetworkService.h" #include "minecraft/network/platform/NetworkPlayerInterface.h" #include "app/common/Tutorial/Tutorial.h" diff --git a/targets/minecraft/server/network/PlayerConnection.cpp b/targets/minecraft/server/network/PlayerConnection.cpp index b016c42fd..3b2ca8a31 100644 --- a/targets/minecraft/server/network/PlayerConnection.cpp +++ b/targets/minecraft/server/network/PlayerConnection.cpp @@ -13,7 +13,7 @@ #include "minecraft/GameEnums.h" #include "minecraft/Console_Debug_enum.h" -#include "app/common/DLC/DLCManager.h" +#include "minecraft/world/level/dlc/DLCConstants.h" #include "app/common/DLC/DLCSkinFile.h" #include "minecraft/network/INetworkService.h" #include "minecraft/network/platform/NetworkPlayerInterface.h" diff --git a/targets/minecraft/world/entity/player/Player.cpp b/targets/minecraft/world/entity/player/Player.cpp index 464a2cab6..1baeb7927 100644 --- a/targets/minecraft/world/entity/player/Player.cpp +++ b/targets/minecraft/world/entity/player/Player.cpp @@ -25,7 +25,7 @@ #include "minecraft/GameEnums.h" #include "app/common/App_structs.h" #include "minecraft/Minecraft_Macros.h" -#include "app/common/DLC/DLCManager.h" +#include "minecraft/world/level/dlc/DLCConstants.h" #include "app/common/DLC/DLCSkinFile.h" #include "java/JavaMath.h" #include "java/Random.h" diff --git a/targets/minecraft/world/level/dlc/DLCConstants.h b/targets/minecraft/world/level/dlc/DLCConstants.h new file mode 100644 index 000000000..fdf8a5f56 --- /dev/null +++ b/targets/minecraft/world/level/dlc/DLCConstants.h @@ -0,0 +1,47 @@ +#pragma once + +// DLC type and parameter enums extracted from app/common/DLC/DLCManager +// so minecraft/ consumers can reference them without including the app +// header. DLCManager re-exports these as nested aliases for backward +// compatibility with app-side call sites. + +namespace minecraft::dlc { + +enum EDLCType { + e_DLCType_Skin = 0, + e_DLCType_Cape, + e_DLCType_Texture, + e_DLCType_UIData, + e_DLCType_PackConfig, + e_DLCType_TexturePack, + e_DLCType_LocalisationData, + e_DLCType_GameRules, + e_DLCType_Audio, + e_DLCType_ColourTable, + e_DLCType_GameRulesHeader, + + e_DLCType_Max, + e_DLCType_All, +}; + +enum EDLCParameterType { + e_DLCParamType_Invalid = -1, + + e_DLCParamType_DisplayName = 0, + e_DLCParamType_ThemeName, + e_DLCParamType_Free, // identify free skins + e_DLCParamType_Credit, // legal credits for DLC + e_DLCParamType_Cape, + e_DLCParamType_Box, + e_DLCParamType_Anim, + e_DLCParamType_PackId, + e_DLCParamType_NetherParticleColour, + e_DLCParamType_EnchantmentTextColour, + e_DLCParamType_EnchantmentTextFocusColour, + e_DLCParamType_DataPath, + e_DLCParamType_PackVersion, + + e_DLCParamType_Max, +}; + +} // namespace minecraft::dlc