Skip to content

Commit 3e61416

Browse files
Init
1 parent abe682b commit 3e61416

19 files changed

Lines changed: 291 additions & 2 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,3 +398,5 @@ FodyWeavers.xsd
398398

399399
# JetBrains Rider
400400
*.sln.iml
401+
/out
402+
/.idea

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "lib/Lantern"]
2+
path = lib/Lantern
3+
url = https://github.com/LanternLCE/Lantern.git

CMakeLists.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
cmake_minimum_required(VERSION 3.30)
2+
project(LanternExampleMod)
3+
set (CMAKE_CXX_STANDARD 20)
4+
5+
set(SRC_FILES
6+
pch.h
7+
pch.cpp
8+
framework.h
9+
TestMod.cpp
10+
TestMod.h
11+
LanternExampleMod.cpp
12+
LanternExampleMod.h
13+
14+
Hooks/FJ/L10N.cpp
15+
Hooks/FJ/L10N.h
16+
Hooks/Minecraft.World/item/Item.cpp
17+
Hooks/Minecraft.World/item/Item.h
18+
Hooks/Minecraft.World/item/SwordItem.cpp
19+
Hooks/Minecraft.World/item/SwordItem.h
20+
)
21+
22+
include(GenerateExportHeader)
23+
add_subdirectory(lib/Lantern)
24+
include_directories(lib/Lantern/lantern lib/Lantern/lantern/lib/detours .)
25+
link_directories(out/build/lib/Lantern out/build/lib/Lantern/lib/detours)
26+
27+
add_library(LanternExampleMod SHARED ${SRC_FILES})
28+
target_link_libraries(LanternExampleMod PRIVATE lib_detours ${CMAKE_SOURCE_DIR}/out/build/lib/Lantern/Lantern.lib)

Hooks/FJ/L10N.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "pch.h"
2+
#include "L10N.h"
3+
4+
wchar_t* L10N::GetString(uint32_t id)
5+
{
6+
return L10N_GetString(id);
7+
}
8+

Hooks/FJ/L10N.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma once
2+
#include <Psapi.h>
3+
#include <iostream>
4+
#include <cstdio>
5+
#include <cstdint>
6+
#include "Util/Logger.h"
7+
#include "Util/HookHelper.h"
8+
9+
class L10N {
10+
public:
11+
/// <summary>
12+
/// Gets a string from the LOC string table
13+
/// </summary>
14+
/// <param name="id">The ID of the string</param>
15+
/// <returns></returns>
16+
static wchar_t* GetString(uint32_t id);
17+
};
18+
19+
CREATE_FUNC(L10N_GetString, 0x14078ee20, wchar_t*, uint32_t id);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "pch.h"
2+
#include "Item.h"
3+
4+
void Item::registerItem(int id, std::wstring* str_id, Item* item)
5+
{
6+
LOGW("Registering item ", *str_id, " (", L10N::GetString(item->descriptionId), ") with ID ", id);
7+
Item_registerItem(id, str_id, item);
8+
}

Hooks/Minecraft.World/item/Item.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#pragma once
2+
#include <Psapi.h>
3+
#include <iostream>
4+
#include <cstdio>
5+
#include <cstdint>
6+
#include "Util/Logger.h"
7+
#include "Util/HookHelper.h"
8+
#include "Hooks/FJ/L10N.h"
9+
10+
class Item {
11+
public:
12+
VTable vftable;
13+
uint64_t* unk1;
14+
uint64_t* unk2;
15+
int maxStackSize;
16+
int uses;
17+
uint64_t* unk4;
18+
uint64_t* unk5;
19+
bool handEquipped;
20+
uint8_t unk6[7];
21+
uint64_t* unk7;
22+
std::wstring unk8;
23+
uint32_t descriptionId;
24+
uint32_t useDescriptionId;
25+
std::wstring name;
26+
bool unk12;
27+
28+
class Tier {
29+
public:
30+
int level;
31+
int uses;
32+
float speed;
33+
float attackDamageBonus;
34+
int enchantmentValue;
35+
int unk;
36+
};
37+
38+
/// <summary>
39+
/// Registers an Item
40+
/// </summary>
41+
/// <param name="id">The numerical ID of the item</param>
42+
/// <param name="str_id">The string ID of the item</param>
43+
/// <param name="item">An instance of the Item</param>
44+
static void registerItem(int id, std::wstring* str_id, Item* item);
45+
};
46+
47+
CREATE_FUNC(Item_registerItem, 0x140313f10, void, int param_1, std::wstring* param_2, Item* param_3);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include "pch.h"
2+
#include "SwordItem.h"
3+
4+
SwordItem* SwordItem::SwordItem_C1(SwordItem* self, Item::Tier* tier)
5+
{
6+
// Log that it was called
7+
LOGW(L"SwordItem ctor called");
8+
// Here we modify the attack damage bonus to be an insane amount. (FLT_MAX)
9+
// For some reason it also modifies a few other items... maybe they use the same constructor?
10+
tier->attackDamageBonus = FLT_MAX;
11+
// separate var incase we want to modify/view the value after it's created before we return.
12+
// this calls the original function to continue initializing.
13+
SwordItem* si = SwordItem_SwordItem_C1(self, tier);
14+
// Then we return the result
15+
return si;
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#pragma once
2+
#include <Psapi.h>
3+
#include <iostream>
4+
#include <cstdio>
5+
#include <cstdint>
6+
#include "Util/Logger.h"
7+
#include "Util/HookHelper.h"
8+
#include "Item.h"
9+
10+
class SwordItem : Item {
11+
public:
12+
// Fake constructor, static so it can be used when registering the hook.
13+
static SwordItem* SwordItem_C1(SwordItem* self, Item::Tier* tier);
14+
};
15+
16+
// "Create" funcs down here
17+
CREATE_FUNC(SwordItem_SwordItem_C1, 0x1404b5100, SwordItem*, SwordItem* self, Item::Tier* tier);

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2025 Lantern
3+
Copyright (c) 2025 LanternLCE
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)