Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
outercloudstudio committed Apr 7, 2024
2 parents e6c7dd1 + 7119838 commit 60ef4df
Show file tree
Hide file tree
Showing 211 changed files with 708 additions and 335 deletions.
6 changes: 2 additions & 4 deletions AmethystAPI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ add_compile_definitions(_ITERATOR_DEBUG_LEVEL=0)
set_property(GLOBAL PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")

file(GLOB_RECURSE SOURCES "src/*.cpp" "src/*.c" "src/*.asm")
file(GLOB_RECURSE HEADERS "src/*.h" "src/*.hpp")
file(GLOB_RECURSE HEADERS "src/*.hpp")

# Create AmethystAPI as a .lib
add_library(${PROJECT_NAME} STATIC
Expand All @@ -26,8 +26,7 @@ add_library(${PROJECT_NAME} STATIC
src/minecraft/src/common/world/item/Item.asm
src/minecraft/src/common/world/level/block/BlockLegacy.asm
src/minecraft/src-deps/minecraftrenderer/renderer/MaterialPtr.asm
)

)

# Amethyst Dependencies
target_include_directories(${PROJECT_NAME} PUBLIC
Expand All @@ -39,7 +38,6 @@ target_link_libraries(${PROJECT_NAME} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/lib/fmt.lib
)


# EnTT Compile options
target_compile_definitions(${PROJECT_NAME} PUBLIC ENTT_PACKED_PAGE=128)

Expand Down
2 changes: 1 addition & 1 deletion AmethystAPI/src/amethyst/Config.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "amethyst/Config.h"
#include "amethyst/Config.hpp"

Config::Config()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include "Json.hpp"
#include "amethyst/Log.h"
#include "amethyst/Log.hpp"
#include <string>
#include <vector>
using json = nlohmann::json;
Expand Down
2 changes: 1 addition & 1 deletion AmethystAPI/src/amethyst/Log.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "amethyst/Log.h"
#include "amethyst/Log.hpp"

namespace Log {
FILE* fp;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include "Utility.h"
#include "Utility.hpp"
#include <Windows.h>
#include <fmt/color.h>
#include <fmt/core.h>
Expand Down
2 changes: 1 addition & 1 deletion AmethystAPI/src/amethyst/Memory.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "amethyst/Memory.h"
#include "amethyst/Memory.hpp"
#include <libhat/Scanner.hpp>
#include <mutex>
#include <thread>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include "amethyst/Log.h"
#include "amethyst/Log.hpp"
#include <chrono>
#include <cstdint>
#include <psapi.h>
Expand Down
6 changes: 3 additions & 3 deletions AmethystAPI/src/amethyst/MinecraftVtables.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "amethyst/MinecraftVtables.h"
#include "minecraft/src/common/world/level/block/BlockLegacy.h"
#include "minecraft/src-client/common/client/renderer/RenderMaterialGroup.h"
#include "amethyst/MinecraftVtables.hpp"
#include "minecraft/src/common/world/level/block/BlockLegacy.hpp"
#include "minecraft/src-client/common/client/renderer/RenderMaterialGroup.hpp"

extern "C" void* Item_vtable = nullptr;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#include <amethyst/Memory.h>
#include <amethyst/Memory.hpp>

void InitializeVtablePtrs();
2 changes: 1 addition & 1 deletion AmethystAPI/src/amethyst/Utility.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "amethyst/Utility.h"
#include "amethyst/Utility.hpp"
#include <winrt/base.h>

std::string GetAmethystFolder()
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#pragma once
#include "amethyst/runtime/HookManager.h"
#include "amethyst/runtime/events/EventManager.h"
#include "amethyst/runtime/input/InputManager.h"
#include "amethyst/runtime/minecraft/MinecraftPackageInfo.h"
#include "amethyst/runtime/mod/Mod.h"
#include "amethyst/runtime/patchManager/PatchManager.h"
#include "minecraft/src-client/common/client/game/ClientInstance.h"
#include "minecraft/src-client/common/client/input/MinecraftInputHandler.h"
#include "minecraft/src-client/common/client/options/Options.h"
#include "amethyst/runtime/HookManager.hpp"
#include "amethyst/runtime/events/EventManager.hpp"
#include "amethyst/runtime/input/InputManager.hpp"
#include "amethyst/runtime/minecraft/MinecraftPackageInfo.hpp"
#include "amethyst/runtime/mod/Mod.hpp"
#include "amethyst/runtime/patchManager/PatchManager.hpp"
#include "minecraft/src-client/common/client/game/ClientInstance.hpp"
#include "minecraft/src-client/common/client/input/MinecraftInputHandler.hpp"
#include "minecraft/src-client/common/client/options/Options.hpp"

class AmethystContext {
public:
Expand Down
7 changes: 4 additions & 3 deletions AmethystAPI/src/amethyst/runtime/HookManager.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#include "HookManager.h"
#include "HookManager.hpp"

#include <ranges>

/*
Disables any hooks and un-caches any stored addresses
*/
void HookManager::Shutdown()
{
for (auto it = mHooks.rbegin(); it != mHooks.rend(); ++it) {
auto* hook = *it;
for (auto hook : std::ranges::reverse_view(mHooks)) {
*hook = {};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once
#include "amethyst-deps/safetyhook.hpp"
#include "amethyst/Log.h"
#include "amethyst/Memory.h"
#include "minecraft/src-deps/core/string/StringHash.h"
#include "amethyst/Log.hpp"
#include "amethyst/Memory.hpp"
#include "minecraft/src-deps/core/string/StringHash.hpp"
#include <unordered_map>
#include <vector>

Expand Down Expand Up @@ -62,8 +62,7 @@ class HookManager {
auto result = SigScanSafe(signature);

if (!result.has_value()) {
std::string error = fmt::format("Failed to find function: \"{}\"\nUsing signature: \"{}\"", function_id::name<Func>(), signature);
throw std::exception(error.c_str());
Assert("Failed to find function: \"{}\"\nUsing signature: \"{}\"", function_id::name<Func>(), signature);
}

mFuncHashToOriginalAddress[hash] = result.value();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma once
#include "Event.h"
#include "minecraft/src-client/common/client/game/ClientInstance.h"
#include "minecraft/src-client/common/client/gui/ScreenView.h"
#include "minecraft/src/common/world/item/registry/ItemRegistry.h"
#include "minecraft/src/common/world/level/block/definition/BlockDefinitionGroup.h"
#include "minecraft/src-client/common/client/renderer/game/LevelRenderer.h"
#include "amethyst/runtime/input/InputManager.h"
#include "Event.hpp"
#include "minecraft/src-client/common/client/game/ClientInstance.hpp"
#include "minecraft/src-client/common/client/gui/ScreenView.hpp"
#include "minecraft/src/common/world/item/registry/ItemRegistry.hpp"
#include "minecraft/src/common/world/level/block/definition/BlockDefinitionGroup.hpp"
#include "minecraft/src-client/common/client/renderer/game/LevelRenderer.hpp"
#include "amethyst/runtime/input/InputManager.hpp"

class FrameRenderObject;

Expand All @@ -16,7 +16,8 @@ namespace Amethyst {
Event<> onRequestLeaveGame;

Event<LevelRenderer*, ScreenContext*, FrameRenderObject*> onRenderLevel;
Event<ScreenView*, UIRenderContext*> onRenderUI;
Event<ScreenView*, UIRenderContext*> beforeRenderUI;
Event<ScreenView*, UIRenderContext*> afterRenderUI;
Event<> update;

Event<InputManager*> registerInputs;
Expand All @@ -32,7 +33,8 @@ namespace Amethyst {
{
onStartJoinGame.Shutdown();
onRequestLeaveGame.Shutdown();
onRenderUI.Shutdown();
beforeRenderUI.Shutdown();
afterRenderUI.Shutdown();
onRenderLevel.Shutdown();
update.Shutdown();
registerInputs.Shutdown();
Expand Down
4 changes: 2 additions & 2 deletions AmethystAPI/src/amethyst/runtime/input/InputManager.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <utility>

#include "amethyst/runtime/input/InputManager.h"
#include "amethyst/runtime/AmethystContext.h"
#include "amethyst/runtime/input/InputManager.hpp"
#include "amethyst/runtime/AmethystContext.hpp"

Amethyst::InputManager::InputManager(AmethystContext *amethyst) {
mAmethyst = amethyst;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once
#include <vector>
#include "minecraft/src-client/common/client/options/Options.h"
#include "amethyst/Log.h"
#include <minecraft/src-client/common/client/input/ClientInputHandler.h>
#include "minecraft/src-client/common/client/options/Options.hpp"
#include "amethyst/Log.hpp"
#include <minecraft/src-client/common/client/input/ClientInputHandler.hpp>

class AmethystContext;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "MinecraftPackageInfo.h"
#include "amethyst/Log.h"
#include "amethyst/Utility.h"
#include "MinecraftPackageInfo.hpp"
#include "amethyst/Log.hpp"
#include "amethyst/Utility.hpp"

Amethyst::MinecraftPackageInfo::MinecraftPackageInfo()
{
Expand All @@ -18,13 +18,13 @@ Amethyst::MinecraftPackageInfo::MinecraftPackageInfo()
package.Id().Version().Major,
package.Id().Version().Minor,
package.Id().Version().Build,
std::format(
"%i",
fmt::format(
"{}",
package.Id().Version().Revision
),
"",
std::format(
"%i.%i.%i.%i",
fmt::format(
"{}.{}.{}.{}",
package.Id().Version().Major,
package.Id().Version().Minor,
package.Id().Version().Build,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "minecraft/src-deps/core/semVer/SemVersion.h"
#include "minecraft/src-deps/core/semVer/SemVersion.hpp"
#include <string>
#include <winrt/Windows.ApplicationModel.h>

Expand Down
2 changes: 1 addition & 1 deletion AmethystAPI/src/amethyst/runtime/mod/Mod.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "Mod.h"
#include "Mod.hpp"
#include <fstream>

Mod::Mod(std::string modName)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once
#include "Json.hpp"
#include <Windows.h>
#include <amethyst/Log.h>
#include <amethyst/Utility.h>
#include <amethyst/Log.hpp>
#include <amethyst/Utility.hpp>
#include <filesystem>
#include <iostream>
#include <shlobj.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "PatchManager.h"
#include "amethyst/Log.h"
#include "amethyst/Memory.h"
#include "PatchManager.hpp"
#include "amethyst/Log.hpp"
#include "amethyst/Memory.hpp"

namespace Amethyst {
// Returns false if the patch failed to apply
Expand Down
2 changes: 1 addition & 1 deletion AmethystAPI/src/amethyst/ui/NinesliceHelper.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "amethyst/ui/NinesliceHelper.h"
#include "amethyst/ui/NinesliceHelper.hpp"

Amethyst::NinesliceHelper::NinesliceHelper(int textureWidth, int textureHeight, int ninesliceWidth, int ninesliceHeight)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include "minecraft/src/common/world/phys/Vec2.h"
#include "minecraft/src-client/common/client/renderer/screen/MinecraftUIRenderContext.h"
#include "minecraft/src/common/world/phys/Vec2.hpp"
#include "minecraft/src-client/common/client/renderer/screen/MinecraftUIRenderContext.hpp"
#include "glm/glm.hpp"

namespace Amethyst {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "minecraft/src-client/common/client/game/ClientInstance.h"
#include "minecraft/src-client/common/client/game/ClientInstance.hpp"

// void ClientInstance::requestLeaveGame(char switchScreen, char sync) {
// using function = void(__thiscall*)(ClientInstance*, char, char);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once
#include "minecraft/src-client/common/client/game/MinecraftGame.h"
#include "minecraft/src-client/common/client/gui/gui/GuiData.h"
#include "minecraft/src-client/common/client/player/LocalPlayer.h"
#include "minecraft/src/common/world/level/BlockSource.h"
#include "minecraft/src-client/common/client/game/MinecraftGame.hpp"
#include "minecraft/src-client/common/client/gui/gui/GuiData.hpp"
#include "minecraft/src-client/common/client/player/LocalPlayer.hpp"
#include "minecraft/src/common/world/level/BlockSource.hpp"
#include <cstdint>
#include "minecraft/src-deps/renderer/Camera.h"
#include "minecraft/src-deps/renderer/Camera.hpp"

class Minecraft;
class ClientInputHandler;
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include "minecraft/src-client/common/client/gui/ScreenView.h"
#include "minecraft/src-client/common/client/gui/ScreenView.hpp"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include "minecraft/src-client/common/client/renderer/screen/MinecraftUIRenderContext.h"
#include "minecraft/src-client/common/client/gui/gui/VisualTree.h"
#include "minecraft/src-client/common/client/renderer/screen/MinecraftUIRenderContext.hpp"
#include "minecraft/src-client/common/client/gui/gui/VisualTree.hpp"

// Not sure if this is correct..
using UIRenderContext = MinecraftUIRenderContext;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once
#include "minecraft/src-client/common/client/gui/controls/UIComponent.hpp"
#include <cstddef>
#include <cstdint>

class SliderComponent : public UIComponent {
public:
/* this + 16 */ std::byte padding16[48];
/* this + 64 */ float mPercentage;

// 1.20.71.1 - 40 53 48 83 EC ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 44 24 ? 48 8B D9 F3 0F 11 4C 24 ? 48 8B 49
int64_t _updateSliderFromStepSize(int64_t a2, int64_t a3);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "minecraft/src-client/common/client/gui/controls/TextComponent.hpp"

void TextComponent::setText(const std::string& text) {
using function = decltype(&TextComponent::setText);
static auto func = std::bit_cast<function>(SigScan("48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC ? 48 8D B9 ? ? ? ? 48 8B DA 48 83 7F"));
(this->*func)(text);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once
#include "minecraft/src-client/common/client/gui/controls/UIComponent.hpp"
#include <cstddef>
#include <cstdint>
#include <string>
#include <amethyst/Memory.hpp>

class TextComponent : public UIComponent {
public:
/* this + 16 */ std::byte padding16[288];
/* this + 304 */ std::string mLabel;

// 1.20.71.1 - 48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC ? 48 8D B9 ? ? ? ? 48 8B DA 48 83 7F
void setText(const std::string& text);
};

///* this + 464 */ bool mCachedTextDirty;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once
#include "minecraft/src-client/common/client/gui/controls/UIComponent.hpp"
#include <cstddef>
#include <cstdint>

class ToggleComponent : public UIComponent {
public:
/* this + 16 */ std::byte padding16[128];
/* this + 144 */ bool mChecked : 1;
/* this + 144 */ bool mHover : 1;

// 1.20.71.1 - 48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 83 EC ? 48 8B F9 0F B6 81
int64_t setChecked(int64_t checked, int64_t a3);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once
#include <cstdint>

class UIControl;

class UIComponent {
public:
/* this + 0 */ uintptr_t** vtable;
/* this + 8 */ UIControl& mOwner;
};
Loading

0 comments on commit 60ef4df

Please sign in to comment.