Skip to content

Commit

Permalink
incomplete changes to wstring and add items. probably still can run o…
Browse files Browse the repository at this point in the history
…ther mods
  • Loading branch information
devingDev committed Oct 2, 2024
1 parent f55727f commit 3d48cdb
Show file tree
Hide file tree
Showing 16 changed files with 366 additions and 13 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
"functional": "c",
"numeric": "c",
"thread": "c",
"customitem.h": "c"
"customitem.h": "c",
"resourcelocation.h": "c",
"item.h": "c",
"wstring.h": "c"
}
}
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions")


include_directories(
${CMAKE_SOURCE_DIR}/common/
${CMAKE_SOURCE_DIR}/common/include/
${CMAKE_SOURCE_DIR}/ZeroM-base/include/
${CMAKE_SOURCE_DIR}/GameMod/include/
${CMAKE_SOURCE_DIR}/PluginReload/include/
Expand Down
4 changes: 3 additions & 1 deletion GameMod/CMakeLists.txt.default
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions -nostdlib -std
include_directories(
./
"${CMAKE_CURRENT_SOURCE_DIR}/include/"
"${CMAKE_CURRENT_SOURCE_DIR}/../common/"
"${CMAKE_CURRENT_SOURCE_DIR}/../common/include"

)

add_executable(${PROJECT_NAME}
src/main.c
src/gamemod.c

../common/src/resourcelocation.c
)

target_link_libraries(${PROJECT_NAME}
Expand Down
4 changes: 3 additions & 1 deletion ZeroM-base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions")

include_directories(
${CMAKE_SOURCE_DIR}/include/
${CMAKE_SOURCE_DIR}/../common/
${CMAKE_SOURCE_DIR}/../common/include/
${CMAKE_SOURCE_DIR}/../GameMod/include/
${CMAKE_SOURCE_DIR}/../PluginReload/include/

Expand Down Expand Up @@ -49,6 +49,8 @@ add_executable(${PROJECT_NAME}
src/hash.c
src/gamemodloader.c
src/customitem.c

../common/src/resourcelocation.c
)

target_include_directories(${PROJECT_NAME} PRIVATE $ENV{VITASDK}/arm-vita-eabi/include/)
Expand Down
8 changes: 7 additions & 1 deletion ZeroM-base/include/customitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@

#include "item.h"


typedef struct{

}TextureAtlasVTable;
typedef struct{

TextureAtlasVTable* vtbl;
} TextureAtlas;



void addCustomItemsTest();
void addHooksCustomItem();

Expand Down
2 changes: 1 addition & 1 deletion ZeroM-base/include/hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ extern int* playerAdd;
extern Player* player;

extern int* serverplayerAdd;
extern Player* serverplayer;
extern ServerPlayer* serverplayer;



Expand Down
71 changes: 66 additions & 5 deletions ZeroM-base/src/customitem.c
Original file line number Diff line number Diff line change
@@ -1,27 +1,88 @@
#include "customitem.h"
#include <taihen.h>
#include "hooks.h"
#include "item.h"
#include "resourcelocation.h"


void addCustomItemsTest(){

}


void (*ResourceLocationCreate)(ResourceLocation* loc, wchar_t* str1, wchar_t* str2) = NULL;
void ResourceLocationCreateHelper(ResourceLocation* loc, wchar_t* str1, wchar_t* str2){
ResourceLocationCreate(loc, str1, str2);
//code::Func<void, 0x810706, ResourceLocation*, const mstd::wstring&, const mstd::wstring&>()(this, str1, str2);
}

void (*registerItem)(int, const ResourceLocation* loc, Item* Item) = NULL;
static void registerItemHelper(int id, const ResourceLocation* loc, Item* item) {
registerItem(id, loc, item);
//code::Func<void, 812244E4, int, const ResourceLocation&, Item*>()(id, loc, item);
}

// add item test
tai_hook_ref_t* MinecraftWorld_RunStaticCtors_ref;
void MinecraftWorld_RunStaticCtors(void){
logInfo("MinecraftWorld_RunStaticCtors begin");
TAI_NEXT(MinecraftWorld_RunStaticCtors, *MinecraftWorld_RunStaticCtors_ref);
logInfo("MinecraftWorld_RunStaticCtors");


ResourceLocation loc;
ResourceLocationCreate(&loc, L"modded", L"custom_item");
Item item;
int ret = module_get_offset(info.modid, 0, (0xD21F00), &item.vtbl);
logInfo("item vtbl %08X ", item.vtbl);
item.iconName = L"custom_texture_name";

registerItemHelper(1, &loc, &item);


//mc::ResourceLocation loc(L"modded", L"custom_item");
//mc::TestItem* testItem = new mc::TestItem();
//testItem->iconName = L"custom_texture_name"; //sets the custom item's texture to your custom icon

// Set Item Id to 1, so we can get it from the Creative Inventory, see AddCreativeMenuItem.h to use a custom ID
//mc::Item::registerItem(1, loc, testItem);


logInfo("MinecraftWorld_RunStaticCtors end");
}



TextureAtlas* AtlasPTRs[2];
int currentAtlas = 0;
//typedef int (*function_t)(TextureAtlas* textureAtlas, uint32_t unknown, uint32_t x, uint32_t y, wchar_t * iconName);
//function_t TextureAtlas__addIcon;

void (* TextureAtlas__addIcon)(TextureAtlas* textureAtlas, uint32_t unknown, uint32_t x, uint32_t y, wchar_t * iconName) = NULL;
void addIconHelper(TextureAtlas* textureAtlas, uint32_t x, uint32_t y, wchar_t * iconName){
TextureAtlas__addIcon(textureAtlas, 0, x, y, iconName);
}

tai_hook_ref_t* TextureAtlas__loadUVs_ref;
void TextureAtlas__loadUVs(int* atlasAddr){
logInfo("TextureAtlas__loadUVs begin %08X", atlasAddr);
TAI_NEXT(TextureAtlas__loadUVs, *TextureAtlas__loadUVs_ref, atlasAddr);
logInfo("TextureAtlas__loadUVs %08X", atlasAddr);


AtlasPTRs[currentAtlas] = (TextureAtlas*)atlasAddr;
currentAtlas++;

if(currentAtlas == 2){
addIconHelper(AtlasPTRs[1], 6, 16, L"custom_texture_name");
}

logInfo("TextureAtlas__loadUVs end %08X", atlasAddr);
}

void addHooksCustomItem(){

MinecraftWorld_RunStaticCtors_ref = add_taiHookFunctionOffset(0x2c904a, MinecraftWorld_RunStaticCtors);
TextureAtlas__loadUVs_ref = add_taiHookFunctionOffset(0x89b47a, TextureAtlas__loadUVs);
int ret = module_get_offset(info.modid, 0, (0x89A2F8|1), &TextureAtlas__addIcon);
ret = module_get_offset(info.modid, 0, (0x810706|1), &ResourceLocationCreate);
ret = module_get_offset(info.modid, 0, (0x2244E4|1), &registerItem);

//MinecraftWorld_RunStaticCtors_ref = add_taiHookFunctionOffset(0x2C904A, MinecraftWorld_RunStaticCtors);
//TextureAtlas__loadUVs_ref = add_taiHookFunctionOffset(0x89B47A, TextureAtlas__loadUVs);
}
2 changes: 1 addition & 1 deletion ZeroM-base/src/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void Player_new(int *a, int *b,int *c){
logInfo("Player_new_REF end %08X", a);
}
int* serverplayerAdd;
Player* serverplayer;
ServerPlayer* serverplayer;
tai_hook_ref_t* ServerPlayer_new_REF;
void ServerPlayer_new(int *a, int *b, int *c, int *d, int *e){
logInfo("ServerPlayer_new_REF begin %08X", a);
Expand Down
7 changes: 7 additions & 0 deletions ZeroM-base/src/user.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ int ZeroM_thread(unsigned int args, void* argp){
logInfo("\n\n=====[DUMP BEGIN]=====");
print_bytes((void*)player, 0xA90);
logInfo("\n=====[DUMP END]=====\n\n");
logInfo("\nlocal : %08X \n\n", player);

logInfo(" serverplayer %08X", serverplayer);
wchar_t name[32];
serverplayer->__vftable->LivingEntity__kill(serverplayer);
//serverplayer->__vftable->Player__getName(serverplayer, name);
logInfo("name %ls\n\n", name);

}

Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions GameMod/include/item.h → common/include/item.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#ifndef ITEM_H
#define ITEM_H
#include <stdint.h>
#include <wchar.h>


#define undefRet int
Expand Down Expand Up @@ -60,5 +62,13 @@ typedef struct{

} ItemVtable;

typedef struct{
ItemVtable* vtbl;
uint8_t pad[0x4 * 0x13];
wchar_t* iconName;
uint32_t field_0x70;

} Item;


#endif
Loading

0 comments on commit 3d48cdb

Please sign in to comment.