Skip to content

Commit 0be599c

Browse files
committed
Update to 1.4.1 runtime, add CI/CD
1 parent 4682a50 commit 0be599c

5 files changed

Lines changed: 133 additions & 14 deletions

File tree

.github/workflows/build.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Publish Version
2+
3+
on:
4+
workflow_dispatch:
5+
6+
env:
7+
MOD_NAME: BetterInventory
8+
9+
jobs:
10+
build:
11+
runs-on: windows-latest
12+
13+
steps:
14+
# Clone the current repository
15+
- name: Checkout code
16+
uses: actions/checkout@v2
17+
18+
# Clone AmethystAPI into /amethyst
19+
- name: Checkout Amethyst
20+
uses: actions/checkout@v2
21+
with:
22+
repository: 'FrederoxDev/Amethyst'
23+
path: 'amethyst'
24+
25+
# Install required tools
26+
- name: Install NASM and GH
27+
run: |
28+
choco install nasm -y
29+
choco install gh -y
30+
shell: cmd
31+
32+
- name: Setup Visual studio
33+
uses: microsoft/setup-msbuild@v2
34+
35+
# Bump up the version number
36+
- name: Extract and increment version number
37+
id: increment_version
38+
run: |
39+
$filePath = "CMakeLists.txt"
40+
$version_line = Select-String -Path $filePath -Pattern 'set\(MOD_VERSION "(.*)"\)'
41+
if ($version_line -match 'set\(MOD_VERSION "(\d+)\.(\d+)\.(\d+)"\)') {
42+
$major = [int]$matches[1]
43+
$minor = [int]$matches[2]
44+
$patch = [int]$matches[3]
45+
46+
# Increment the minor version
47+
$new_patch = $patch + 1
48+
$new_version = "$major.$minor.$new_patch"
49+
50+
# Update the CMakeLists.txt file
51+
(Get-Content $filePath) -replace 'set\(MOD_VERSION ".*"\)', "set(MOD_VERSION `"$new_version`")" | Set-Content $filePath
52+
53+
echo "NEW_VERSION=$new_version" >> $env:GITHUB_ENV
54+
echo "FILE_PATH=$filePath" >> $env:GITHUB_ENV
55+
} else {
56+
Write-Error "Version line not found or does not match the expected format."
57+
exit 1
58+
}
59+
shell: pwsh
60+
61+
- name: Push bumped version
62+
run: |
63+
git config user.name "github-actions[bot]"
64+
git config user.email "github-actions[bot]@users.noreply.github.com"
65+
git add $env:FILE_PATH
66+
git commit -m "Bump version to $env:NEW_VERSION"
67+
git push
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
shell: pwsh
71+
72+
- name: Build Mod
73+
run: |
74+
mkdir build
75+
cd build
76+
cmake -DCI_CD_BUILD=ON ..
77+
msbuild ${{ env.MOD_NAME }}.sln
78+
79+
- name: Package Build
80+
run: |
81+
$version = $env:NEW_VERSION
82+
$sourcePath = "dist/${{ env.MOD_NAME }}@$version"
83+
$zipPath = "dist/${{ env.MOD_NAME }}@$version.zip"
84+
85+
if (-Not (Test-Path -Path $sourcePath)) {
86+
Write-Error "Source path does not exist: $sourcePath"
87+
exit 1
88+
}
89+
90+
Add-Type -AssemblyName System.IO.Compression.FileSystem
91+
[System.IO.Compression.ZipFile]::CreateFromDirectory($sourcePath, $zipPath)
92+
shell: pwsh
93+
94+
- name: Create GitHub Release
95+
id: create_release
96+
run: |
97+
$tag_name = "v$env:NEW_VERSION"
98+
$release_name = "Release $env:NEW_VERSION"
99+
gh release create $tag_name --title "$release_name" --notes "Automated release" --target main --repo ${{ github.repository }} --draft=false --prerelease=false
100+
shell: pwsh
101+
env:
102+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103+
104+
- name: Upload Release Asset
105+
run: |
106+
$asset_path = "dist/${{ env.MOD_NAME }}@$env:NEW_VERSION.zip"
107+
$asset_label = "${{ env.MOD_NAME }}@$env:NEW_VERSION.zip"
108+
gh release upload "v$env:NEW_VERSION" "$asset_path#$asset_label" --repo ${{ github.repository }}
109+
shell: pwsh
110+
env:
111+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,19 @@ include(FetchContent)
66
set(MOD_VERSION "1.6.0")
77

88
# Amethyst Minecraft Folder
9-
set(AmethystFolder "$ENV{localappdata}/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/AC/Amethyst/")
9+
set(AmethystFolder "$ENV{localappdata}/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/amethyst/")
1010

1111
# Configure to build within the Amethyst Folder
1212
configure_file(mod.json.in "${AmethystFolder}/mods/${PROJECT_NAME}@${MOD_VERSION}/mod.json" @ONLY)
1313
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${AmethystFolder}/mods/${PROJECT_NAME}@${MOD_VERSION}")
1414

1515
# Compiler Options
1616
set(CMAKE_CXX_STANDARD 23)
17-
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1817
set(CMAKE_CONFIGURATION_TYPES "RelWithDebInfo" CACHE STRING "Build configurations" FORCE)
18+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
19+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /await")
20+
21+
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1922
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: RelWithDebInfo" FORCE)
2023

2124
# Make the Mod

src/ShulkerRenderer.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#include "ShulkerRenderer.h"
2+
#include <minecraft/src-client/common/client/renderer/screen/MinecraftUIRenderContext.hpp>
3+
#include <minecraft/src-deps/core/math/Color.hpp>
4+
#include <minecraft/src-client/common/client/game/ClientInstance.hpp>
25

36
extern ItemStack shulkerInventory[SHULKER_CACHE_SIZE][27];
47

@@ -31,11 +34,8 @@ int countNewlines(const std::string& str) {
3134
void ShulkerRenderer::Render(UIRenderContext* ctx, HoverRenderer* hoverRenderer, int index) {
3235
// Only load inventory resources once
3336
if (!hasLoadedTexture) {
34-
ResourceLocation backgroundResource("textures/ui/purpleBorder");
35-
mBackgroundTexture = ctx->getTexture(&backgroundResource, true);
36-
37-
ResourceLocation itemSlotResource("textures/gui/gui");
38-
mItemSlotTexture = ctx->getTexture(&itemSlotResource, true);
37+
mBackgroundTexture = ctx->getTexture("textures/ui/purpleBorder", true);
38+
mItemSlotTexture = ctx->getTexture("textures/gui/gui", true);
3939

4040
hasLoadedTexture = true;
4141
}

src/dllmain.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,17 @@ static void HoverRenderer__renderHoverBox(HoverRenderer* self, MinecraftUIRender
102102
_HoverRenderer__renderHoverBox.thiscall(self, ctx, client, aabb, someFloat);
103103
}
104104

105-
ModFunction void Initialize(AmethystContext* ctx) {
106-
ctx->mHookManager.RegisterFunction<&Item::appendFormattedHovertext>("40 55 53 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 F1 4C 89 44 24 ? 4C 8B F2 48 8B D9");
107-
ctx->mHookManager.CreateHook<&Item::appendFormattedHovertext>(_Item_appendFormattedHoverText, &Item_appendFormattedHovertext);
105+
ModFunction void Initialize(AmethystContext& ctx) {
106+
Amethyst::InitializeAmethystMod(ctx);
108107

109-
ctx->mHookManager.RegisterFunction<&ShulkerBoxBlockItem::appendFormattedHovertext>("40 53 55 56 57 41 56 41 57 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 44 24 ? 4D 8B F9 48 8B DA");
110-
ctx->mHookManager.CreateHook<&ShulkerBoxBlockItem::appendFormattedHovertext>(_Shulker_appendFormattedHoverText, &Shulker_appendFormattedHovertext);
108+
auto& hooks = Amethyst::GetHookManager();
111109

112-
ctx->mHookManager.RegisterFunction<&HoverRenderer::_renderHoverBox>("48 8B C4 48 89 58 ? 48 89 70 ? 48 89 78 ? 4C 89 70 ? 55 48 8D 68 ? 48 81 EC ? ? ? ? 0F 29 70 ? 0F 29 78 ? 44 0F 29 40 ? 49 8B D9");
113-
ctx->mHookManager.CreateHook<&HoverRenderer::_renderHoverBox>(_HoverRenderer__renderHoverBox, &HoverRenderer__renderHoverBox);
110+
hooks.RegisterFunction<&Item::appendFormattedHovertext>("40 55 53 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 F1 4C 89 44 24 ? 4C 8B F2 48 8B D9");
111+
hooks.CreateHook<&Item::appendFormattedHovertext>(_Item_appendFormattedHoverText, &Item_appendFormattedHovertext);
112+
113+
hooks.RegisterFunction<&ShulkerBoxBlockItem::appendFormattedHovertext>("40 53 55 56 57 41 56 41 57 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 44 24 ? 4D 8B F9 48 8B DA");
114+
hooks.CreateHook<&ShulkerBoxBlockItem::appendFormattedHovertext>(_Shulker_appendFormattedHoverText, &Shulker_appendFormattedHovertext);
115+
116+
hooks.RegisterFunction<&HoverRenderer::_renderHoverBox>("48 8B C4 48 89 58 ? 48 89 70 ? 48 89 78 ? 4C 89 70 ? 55 48 8D 68 ? 48 81 EC ? ? ? ? 0F 29 70 ? 0F 29 78 ? 44 0F 29 40 ? 49 8B D9");
117+
hooks.CreateHook<&HoverRenderer::_renderHoverBox>(_HoverRenderer__renderHoverBox, &HoverRenderer__renderHoverBox);
114118
}

src/dllmain.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <amethyst/runtime/AmethystContext.hpp>
2929
#include <typeindex>
3030
#include <minecraft/src/common/world/level/Level.hpp>
31+
#include <amethyst/runtime/ModContext.hpp>
3132

3233
#include "ShulkerRenderer.h"
3334

0 commit comments

Comments
 (0)