From 502d2820ebd9bf7e1ec9ba3957ee1be3aad377d7 Mon Sep 17 00:00:00 2001 From: Outer Cloud Studio Date: Sun, 31 Mar 2024 00:47:13 -0500 Subject: [PATCH 1/7] Fix compilation errors --- AmethystAPI/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/AmethystAPI/CMakeLists.txt b/AmethystAPI/CMakeLists.txt index 79828589..22e4044d 100644 --- a/AmethystAPI/CMakeLists.txt +++ b/AmethystAPI/CMakeLists.txt @@ -9,6 +9,7 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${AmethystFolder}/lib") # C++ Compile Options set(CMAKE_CXX_STANDARD 23) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /await") set(CMAKE_CONFIGURATION_TYPES "RelWithDebInfo" CACHE STRING "Build configurations" FORCE) set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: RelWithDebInfo" FORCE) From 35c399ea30996ab78b2cfc2137cae40c319d7038 Mon Sep 17 00:00:00 2001 From: Outer Cloud Studio Date: Sun, 31 Mar 2024 00:47:20 -0500 Subject: [PATCH 2/7] Experiments with sound --- AmethystRuntime/src/hooks/Hooks.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AmethystRuntime/src/hooks/Hooks.cpp b/AmethystRuntime/src/hooks/Hooks.cpp index 45cef0a1..cceeee3e 100644 --- a/AmethystRuntime/src/hooks/Hooks.cpp +++ b/AmethystRuntime/src/hooks/Hooks.cpp @@ -46,7 +46,7 @@ void* VanillaItems_registerItems( const ItemRegistryRef itemRegistry, const BaseGameVersion* baseGameVersion, const Experiments* experiments, - void* enableExperimentalGameplay) + void* enableExperimentalGameplay) { Amethyst::EventManager* events = AmethystRuntime::getEventManager(); @@ -94,7 +94,7 @@ void CreateModFunctionHooks() { hookManager->RegisterFunction<&ClientInstance::onStartJoinGame>("40 55 53 56 57 41 54 41 55 41 56 41 57 48 8D 6C 24 ? 48 81 EC ? ? ? ? 45 8B F1"); hookManager->RegisterFunction<&ClientInstance::requestLeaveGame>("48 89 5C 24 ? 48 89 74 24 ? 55 57 41 54 41 56 41 57 48 8D 6C 24 ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 45 ? 45 0F B6 F0 44 0F B6 FA"); hookManager->RegisterFunction<&ClientInstance::_ClientInstance>("48 89 5C 24 ? 55 56 57 41 54 41 55 41 56 41 57 48 8D 6C 24 ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 45 ? 49 8B F9 49 8B D8 4C 8B E2"); - + //hookManager->RegisterFunction<&VanillaItems::registerItems>("40 55 53 56 57 41 54 41 56 41 57 48 8D AC 24 ? ? ? ? B8 ? ? ? ? E8 ? ? ? ? 48 2B E0 0F 29 B4 24"); //hookManager->RegisterFunction<&BlockDefinitionGroup::registerBlocks>("48 89 5C 24 ? 48 89 6C 24 ? 56 57 41 54 41 56 41 57 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 84 24 ? ? ? ? 4C 8B F9"); //hookManager->RegisterFunction<&LevelRenderer::renderLevel>("48 89 5C 24 ? 48 89 74 24 ? 55 57 41 56 48 8D AC 24 ? ? ? ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 ? ? ? ? 49 8B F0 48 8B DA 4C 8B F1"); From 0e62f113eb7ef3c59c3305aedcc153908af22f6a Mon Sep 17 00:00:00 2001 From: Outer Cloud Studio Date: Sun, 31 Mar 2024 00:47:42 -0500 Subject: [PATCH 3/7] Revert "Experiments with sound" This reverts commit 35c399ea30996ab78b2cfc2137cae40c319d7038. --- AmethystRuntime/src/hooks/Hooks.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AmethystRuntime/src/hooks/Hooks.cpp b/AmethystRuntime/src/hooks/Hooks.cpp index cceeee3e..45cef0a1 100644 --- a/AmethystRuntime/src/hooks/Hooks.cpp +++ b/AmethystRuntime/src/hooks/Hooks.cpp @@ -46,7 +46,7 @@ void* VanillaItems_registerItems( const ItemRegistryRef itemRegistry, const BaseGameVersion* baseGameVersion, const Experiments* experiments, - void* enableExperimentalGameplay) + void* enableExperimentalGameplay) { Amethyst::EventManager* events = AmethystRuntime::getEventManager(); @@ -94,7 +94,7 @@ void CreateModFunctionHooks() { hookManager->RegisterFunction<&ClientInstance::onStartJoinGame>("40 55 53 56 57 41 54 41 55 41 56 41 57 48 8D 6C 24 ? 48 81 EC ? ? ? ? 45 8B F1"); hookManager->RegisterFunction<&ClientInstance::requestLeaveGame>("48 89 5C 24 ? 48 89 74 24 ? 55 57 41 54 41 56 41 57 48 8D 6C 24 ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 45 ? 45 0F B6 F0 44 0F B6 FA"); hookManager->RegisterFunction<&ClientInstance::_ClientInstance>("48 89 5C 24 ? 55 56 57 41 54 41 55 41 56 41 57 48 8D 6C 24 ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 45 ? 49 8B F9 49 8B D8 4C 8B E2"); - + //hookManager->RegisterFunction<&VanillaItems::registerItems>("40 55 53 56 57 41 54 41 56 41 57 48 8D AC 24 ? ? ? ? B8 ? ? ? ? E8 ? ? ? ? 48 2B E0 0F 29 B4 24"); //hookManager->RegisterFunction<&BlockDefinitionGroup::registerBlocks>("48 89 5C 24 ? 48 89 6C 24 ? 56 57 41 54 41 56 41 57 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 84 24 ? ? ? ? 4C 8B F9"); //hookManager->RegisterFunction<&LevelRenderer::renderLevel>("48 89 5C 24 ? 48 89 74 24 ? 55 57 41 56 48 8D AC 24 ? ? ? ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 ? ? ? ? 49 8B F0 48 8B DA 4C 8B F1"); From 324a2a0af837389a96843a4f8f5449cfe45be644 Mon Sep 17 00:00:00 2001 From: Outer Cloud Studio Date: Sun, 31 Mar 2024 15:26:00 -0500 Subject: [PATCH 4/7] Fix cmake in amethyst runtime --- AmethystRuntime/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/AmethystRuntime/CMakeLists.txt b/AmethystRuntime/CMakeLists.txt index 6a00fa4b..fa7ea673 100644 --- a/AmethystRuntime/CMakeLists.txt +++ b/AmethystRuntime/CMakeLists.txt @@ -8,6 +8,7 @@ set(MOD_TARGET_VERSION_PATCH 7101) # C++ Build Settings +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /await") set(CMAKE_CONFIGURATION_TYPES "RelWithDebInfo" CACHE STRING "Build configurations" FORCE) set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo" FORCE) set(CMAKE_CXX_STANDARD 23) From e6c7dd1cae8554e614cfde6e3bffb67b4ed1f8f0 Mon Sep 17 00:00:00 2001 From: Outer Cloud Studio Date: Sun, 7 Apr 2024 03:13:21 -0500 Subject: [PATCH 5/7] Add ContentLog --- .../src-deps/core/debug/log/ContentLog.cpp | 9 +++ .../src-deps/core/debug/log/ContentLog.hpp | 59 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLog.cpp create mode 100644 AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLog.hpp diff --git a/AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLog.cpp b/AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLog.cpp new file mode 100644 index 00000000..25887b83 --- /dev/null +++ b/AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLog.cpp @@ -0,0 +1,9 @@ +#include "ContentLog.hpp" + +template +int ContentLog::Log(bool doNotRepeat, LogLevel logLevel, LogArea logArea, Strings... strings) +{ + using function = int (ContentLog::*)(bool, LogLevel, LogArea, Strings...); + auto func = std::bit_cast(SigScan("44 89 4C 24 ? 48 83 EC")); + return (this->*func)(doNotRepeat, logLevel, logArea, strings...); +} \ No newline at end of file diff --git a/AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLog.hpp b/AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLog.hpp new file mode 100644 index 00000000..d01aedb0 --- /dev/null +++ b/AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLog.hpp @@ -0,0 +1,59 @@ +#include + +enum class LogLevel : unsigned int { + Verbose = 0, + Inform = 1, + Warning = 2, + Error = 3, + _COUNT = 4, +}; + +// Note the old ones we found from 1.19 are out of date +enum class LogArea : unsigned int { + Actor = 0, + Addon = 1, + AI = 2, + Animation = 3, + AutomatedTests = 4, + BiomeRegistry = 5, + Blocks = 6, + Camera = 7, + Commands = 8, + Components = 9, + Dialogue = 10, + Effects = 11, + Entity = 12, + FeatureRegistry = 13, + Geometry = 14, + Item = 15, + Json = 16, + LevelStorage = 17, + Lightning = 18, + Localization = 19, + Log = 20, + Molang = 21, + Messaging = 22, + Recipes = 23, + Rendering = 24, + RuntimeCamera = 25, + Scripting = 26, + Sound = 27, + Store = 28, + Structure = 29, + Texture = 30, + TexturUI = 31, + Volumes = 32, + LootTable = 33, + Packs = 34, + _COUNT = 35, +}; + +// Constructor Signature "48 89 5C 24 ? 48 89 4C 24 ? 57 48 83 EC ? 48 8B F9 48 8D 05 ? ? ? ? 48 89 01 48 89 4C 24 ? 48 83 C1 ? 48 8D 54 24 ? E8 ? ? ? ? 90 48 8D 05 ? ? ? ? 48 89 07 C6 47" + +class ContentLog { +public: + uintptr_t** vtable; + + template + int Log(bool doNotRepeat, LogLevel logLevel, LogArea logArea, Strings... strings); +}; \ No newline at end of file From db93ebb0d975be144c013fd95a81562664fed6de Mon Sep 17 00:00:00 2001 From: Outer Cloud Studio Date: Sun, 7 Apr 2024 03:41:38 -0500 Subject: [PATCH 6/7] Make it work --- .../src/minecraft/src-deps/core/debug/log/ContentLog.cpp | 9 --------- .../src/minecraft/src-deps/core/debug/log/ContentLog.hpp | 8 +++++++- 2 files changed, 7 insertions(+), 10 deletions(-) delete mode 100644 AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLog.cpp diff --git a/AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLog.cpp b/AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLog.cpp deleted file mode 100644 index 25887b83..00000000 --- a/AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLog.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "ContentLog.hpp" - -template -int ContentLog::Log(bool doNotRepeat, LogLevel logLevel, LogArea logArea, Strings... strings) -{ - using function = int (ContentLog::*)(bool, LogLevel, LogArea, Strings...); - auto func = std::bit_cast(SigScan("44 89 4C 24 ? 48 83 EC")); - return (this->*func)(doNotRepeat, logLevel, logArea, strings...); -} \ No newline at end of file diff --git a/AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLog.hpp b/AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLog.hpp index d01aedb0..9dfb9885 100644 --- a/AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLog.hpp +++ b/AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLog.hpp @@ -1,4 +1,6 @@ +#pragma once #include +#include "amethyst/Memory.hpp" enum class LogLevel : unsigned int { Verbose = 0, @@ -55,5 +57,9 @@ class ContentLog { uintptr_t** vtable; template - int Log(bool doNotRepeat, LogLevel logLevel, LogArea logArea, Strings... strings); + int Log(bool doNotRepeat, LogLevel logLevel, LogArea logArea, Strings... strings) { + using function = int (ContentLog::*)(bool, LogLevel, LogArea, Strings...); + auto func = std::bit_cast(SigScan("44 89 4C 24 ? 48 83 EC")); + return (this->*func)(doNotRepeat, logLevel, logArea, strings...); + } }; \ No newline at end of file From 5f2af544020e3366ca145ebd21d0cdbc63767e1f Mon Sep 17 00:00:00 2001 From: Outer Cloud Studio Date: Sun, 7 Apr 2024 10:49:26 -0500 Subject: [PATCH 7/7] Fix requested changes --- .../src-deps/core/debug/log/ContentLog.hpp | 56 ++----------------- .../core/debug/log/ContentLogTypes.hpp | 49 ++++++++++++++++ 2 files changed, 54 insertions(+), 51 deletions(-) create mode 100644 AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLogTypes.hpp diff --git a/AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLog.hpp b/AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLog.hpp index 9dfb9885..febb1a1f 100644 --- a/AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLog.hpp +++ b/AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLog.hpp @@ -1,64 +1,18 @@ #pragma once #include #include "amethyst/Memory.hpp" - -enum class LogLevel : unsigned int { - Verbose = 0, - Inform = 1, - Warning = 2, - Error = 3, - _COUNT = 4, -}; - -// Note the old ones we found from 1.19 are out of date -enum class LogArea : unsigned int { - Actor = 0, - Addon = 1, - AI = 2, - Animation = 3, - AutomatedTests = 4, - BiomeRegistry = 5, - Blocks = 6, - Camera = 7, - Commands = 8, - Components = 9, - Dialogue = 10, - Effects = 11, - Entity = 12, - FeatureRegistry = 13, - Geometry = 14, - Item = 15, - Json = 16, - LevelStorage = 17, - Lightning = 18, - Localization = 19, - Log = 20, - Molang = 21, - Messaging = 22, - Recipes = 23, - Rendering = 24, - RuntimeCamera = 25, - Scripting = 26, - Sound = 27, - Store = 28, - Structure = 29, - Texture = 30, - TexturUI = 31, - Volumes = 32, - LootTable = 33, - Packs = 34, - _COUNT = 35, -}; - -// Constructor Signature "48 89 5C 24 ? 48 89 4C 24 ? 57 48 83 EC ? 48 8B F9 48 8D 05 ? ? ? ? 48 89 01 48 89 4C 24 ? 48 83 C1 ? 48 8D 54 24 ? E8 ? ? ? ? 90 48 8D 05 ? ? ? ? 48 89 07 C6 47" +#include "ContentLogTypes.hpp" class ContentLog { public: uintptr_t** vtable; + // 1.20.72.1 - 48 89 5C 24 ? 48 89 4C 24 ? 57 48 83 EC ? 48 8B F9 48 8D 05 ? ? ? ? 48 89 01 48 89 4C 24 ? 48 83 C1 ? 48 8D 54 24 ? E8 ? ? ? ? 90 48 8D 05 ? ? ? ? 48 89 07 C6 47 + ContentLog() {}; + template int Log(bool doNotRepeat, LogLevel logLevel, LogArea logArea, Strings... strings) { - using function = int (ContentLog::*)(bool, LogLevel, LogArea, Strings...); + using function = decltype(&ContentLog::Log); auto func = std::bit_cast(SigScan("44 89 4C 24 ? 48 83 EC")); return (this->*func)(doNotRepeat, logLevel, logArea, strings...); } diff --git a/AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLogTypes.hpp b/AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLogTypes.hpp new file mode 100644 index 00000000..7734dbb3 --- /dev/null +++ b/AmethystAPI/src/minecraft/src-deps/core/debug/log/ContentLogTypes.hpp @@ -0,0 +1,49 @@ +#pragma once + +enum class LogLevel : unsigned int { + Verbose = 0, + Inform = 1, + Warning = 2, + Error = 3, + _COUNT = 4, +}; + +// Note the old ones we found from 1.19 are out of date +enum class LogArea : unsigned int { + Actor = 0, + Addon = 1, + AI = 2, + Animation = 3, + AutomatedTests = 4, + BiomeRegistry = 5, + Blocks = 6, + Camera = 7, + Commands = 8, + Components = 9, + Dialogue = 10, + Effects = 11, + Entity = 12, + FeatureRegistry = 13, + Geometry = 14, + Item = 15, + Json = 16, + LevelStorage = 17, + Lightning = 18, + Localization = 19, + Log = 20, + Molang = 21, + Messaging = 22, + Recipes = 23, + Rendering = 24, + RuntimeCamera = 25, + Scripting = 26, + Sound = 27, + Store = 28, + Structure = 29, + Texture = 30, + TexturUI = 31, + Volumes = 32, + LootTable = 33, + Packs = 34, + _COUNT = 35, +}; \ No newline at end of file