From 7969fb21275f393316d9df91934952cd98801cdb Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Thu, 23 Nov 2023 23:54:36 -0500 Subject: [PATCH] 3D Chest Model --- images/CMakeLists.txt | 8 +++ images/chest.png | Bin 0 -> 5940 bytes images/chest.png~ | Bin 0 -> 6041 bytes launcher/src/client/available-feature-flags | 1 + mods/src/misc/misc.c | 61 ++++++++++++++++++++ symbols/include/symbols/minecraft.h | 18 ++++++ 6 files changed, 88 insertions(+) create mode 100644 images/chest.png create mode 100644 images/chest.png~ diff --git a/images/CMakeLists.txt b/images/CMakeLists.txt index 9edf6b43..c5dc5c71 100644 --- a/images/CMakeLists.txt +++ b/images/CMakeLists.txt @@ -9,6 +9,14 @@ if(NOT MCPI_HEADLESS_MODE) ) endif() +# Chest Model +if(NOT MCPI_HEADLESS_MODE) + install( + FILES "chest.png" + DESTINATION "${MCPI_INSTALL_DIR}/data/images/item" + ) +endif() + # Icon install( FILES "icon.png" diff --git a/images/chest.png b/images/chest.png new file mode 100644 index 0000000000000000000000000000000000000000..5866e93acefb9d1e0df8a09e2bda0f9cdc3fb554 GIT binary patch literal 5940 zcmeHKdpMNq79U+?Pl*(wY}3RcHRgV0+%oQiTp}jhH#6Tbjk%Z^j7#qAZc4QqC8CIm zm{MumBo(^pwo^&FLW$EZDn%tZ-=Nz$`+3gObI$&+nP+CcZ@s_ud)NA{^)9~kzTU3d zaAPE!P3XIfAAKMCX-)_Tmiqy52#Hk8<41uAdAtNffC@ej22->P zeeY_YMa+0VG{;0EYQT6cVSTGMEm`NOvwQ0=&;RT=%)C2v^oAg{cw4ET>=G5$ek|J6 zH)F5QybN!fz1|B>-TbH7T=O(TPr=}@E4^USV_K1XR+-o$$L9L`X_Yz)NEXG#vsBit zEVs6Gy_4=W!)tCzO@KRROm5E9KKisbqNP8(u*M)t%zWdzle}IpoY88$B|39o#=669 z%}qud=d_ufa|=Fyif*#UwBSjIvhkPU1u&RK8h`0hU-zX;KV}5wk-vH?)orrloS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8nZoa+vygC;CK61&CvPRQQ=F62k zLqbiH-W&)RwLdlVa+`VeL1i`3^AHYuq}pRzRFmG_R*&-T7)5bad{cYbs*;;eX!#+b zpzpEjvJn39V~rP!B87p+e_zF4uVkzemgKaRE)Nl+j#LF7ZzMrx!Fpv=nVNHXsOOS&!rIKXcns zVf(;-_2GuV4dmqd7MoLZZ0qMnj3mc+D!T%At7eERG=qz&FO!0=A2qb8(J(S%yey~x zGBsFm*kynnu`Ma*mEba9v3%gH0JZtuZ*x>nl0b!EGGbrX8<+Zb$8d?sXjKc&d?+M8 zdusDLt%HgWhie;W3orHe&lk3+;|g2kc}OuuS>DpILS4@C)(t0FmAJ&^iV}i@xiaX^ zMKAba7f!lX5aak`%bM19{&2Gisiyx&8OKXqIGc>i036a-okY YliZM6T3fOL`pW=wXLvhTI)$hI3q>jwZ~y=R literal 0 HcmV?d00001 diff --git a/images/chest.png~ b/images/chest.png~ new file mode 100644 index 0000000000000000000000000000000000000000..d9429e8e070d722b316a058b523022cb5c43bbfa GIT binary patch literal 6041 zcmeHKd0bOh7Je*>1Vv<3krHFAB4iIFc@ks`%0Lj=5f@&P7l@F>B#=N@0z$2zwaQ>y z0i{?$vh>3=49+db!e_nz;3_rBaM zfdR{Bpyr|g0GQ#s!aE4Ls*uBd+EnCxy(2vxxtvc9iI4?Ba5Qv@A&sqhSS~ z2LOtjg1{)#M)dU27Kg;FufBKv(kuM4$5WTSoSs#Fn78Gt&R^UQq;}(zWh)3jVjo1X zx%D|#k9)v&(u2?ccF_d>t1B{_u1H|O_d({M|Iw+wA#w`*>~+e?b&*2 z$FPm@&cMZc>5wRexhFSSQGMsi*}ASczi+yaW`yi0EuIxBaC09G zx{jKUF6lQ~es%X${7duc_j?Mh`%Rd+kynrS`^E!+UIyRGE6~@=>vcj%8ilDl=qn67 zEI(hiuS5|I<)E#j4&=Km*)V6HnPIk>)hU#my4f?)BGDq=Y052C_VRn7oe^BkLo&X8@2%!WbkRbCi55X|bd zKG7GGkE<&n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)b*M;$ck&|JE^YuTeX*rf9$5V&XafUN)bwyoHj zxlf#`Z+CY)RO{jEl(Va6J7#a3bvhuyqdNB7##&9!v`d2GHL$xpdA7|(f5B?t(%_aa3@<7AAry+Hex^#NwmqRI@qYMUMStrfkVRlzLIyF?;lC3?0? ztCl2O-9>k&E*;Jv!AbRO7sZzA33;Yw!=7X7zL@E1XIk^qvBoz1f%%UTQar6nPEiVG zD(8Dt_pNVk6QFy{cZFwGs&TT0sZ)UZ=iacA@@Pa(w`&xeSN8PiUmsUet)7)NHEn%r&CP5^dPN&72KTq4o;7*IVAr-i3Hvq6N-z5G`1MDOa_$qr z+Wv@-0`15YV0t&?geddp9jQ z{$gSvT!f8i=s3R9SnYLhrOS!LcGGVb`gPWZk)Xyf)ot^zui?1xV8?GO=j#QoZuo80 z@kD3D*VYoKS@;7kbkgLZ_f=HGZ#$#vB$I&#Qq|ZhvE42#^l8r3V8y{N9M zEe!d@D38HAp1-`}Mr3!Xg>3lw7gWt{Hf4{~@85cp51x5Eka%;FR9n~a?S@x}s#WfB z-E}<+e4S3Ow_fAZCh6&VS|67`I=*>(ui@&UJh^p3Szk_B%)OEx`9S~b+R}UNt;UY} z^^uJpv(E;(jrf#NqCX4E8{e?^GMyH)v18DukEFyuRPSyG+kHjT6T9&m^=%QKQZ}Es zbfd*lTA}%SehnsXW>n#qRvpa6D~DdB$vw($ereymG$Kk@4TuSxYjT=*_P5a9U*J|_ zXNiibO!(>2?aL(=8}0+(p;PULo0Cw5&Yh8-#d+I05C;HRze2J%g!cYC{Q)1m)wNA+ z?7So+eKh>}n)ISew|_ku${5KjgWy^E?w*B?0bruOe$omKIWd?X3@r=&=CoQTuIsgCw literal 0 HcmV?d00001 diff --git a/launcher/src/client/available-feature-flags b/launcher/src/client/available-feature-flags index 128202c6..5fcacab1 100644 --- a/launcher/src/client/available-feature-flags +++ b/launcher/src/client/available-feature-flags @@ -49,3 +49,4 @@ TRUE Generate Caves FALSE Disable Block Tinting TRUE Disable Hostile AI In Creative Mode TRUE Load Custom Skins +TRUE 3D Chest Model diff --git a/mods/src/misc/misc.c b/mods/src/misc/misc.c index 6cf41211..815065bf 100644 --- a/mods/src/misc/misc.c +++ b/mods/src/misc/misc.c @@ -415,6 +415,52 @@ static unsigned char *PathfinderMob_findAttackTarget_injection(unsigned char *mo return target; } +// 3D Chests +static int32_t Tile_getRenderShape_injection(unsigned char *tile) { + if (tile == *Tile_chest) { + // Don't Render "Simple" Chest Model + return -1; + } else { + // Call Original Method + unsigned char *tile_vtable = *(unsigned char **) tile; + Tile_getRenderShape_t Tile_getRenderShape = *(Tile_getRenderShape_t *) (tile_vtable + Tile_getRenderShape_vtable_offset); + return (*Tile_getRenderShape)(tile); + } +} +static unsigned char *ChestTileEntity_injection(unsigned char *tile_entity) { + // Call Original Method + (*ChestTileEntity)(tile_entity); + + // Enable Renderer + *(int32_t *) (tile_entity + TileEntity_renderer_id_property_offset) = 1; + + // Return + return tile_entity; +} +static bool is_rendering_chest = 0; +static void ModelPart_render_injection(unsigned char *model_part, float scale) { + // Start + is_rendering_chest = 1; + + // Call Original Method + (*ModelPart_render)(model_part, scale); + + // Stop + is_rendering_chest = 0; +} +static void Tesselator_vertexUV_injection(unsigned char *tesselator, float x, float y, float z, float u, float v) { + // Fix Chest Texture + if (is_rendering_chest) { + v /= 2; + } + + // Call Original Method + (*Tesselator_vertexUV)(tesselator, x, y, z, u, v); +} +static bool ChestTileEntity_shouldSave_injection(__attribute__((unused)) unsigned char *tile_entity) { + return 1; +} + // Init static void nop() { } @@ -557,6 +603,21 @@ void init_misc() { overwrite_call((void *) 0x83b8c, (void *) PathfinderMob_findAttackTarget_injection); } + // 3D Chests + if (feature_has("3D Chest Model", server_disabled)) { + overwrite_call((void *) 0x5e830, (void *) Tile_getRenderShape_injection); + overwrite_calls((void *) ChestTileEntity, (void *) ChestTileEntity_injection); + overwrite_call((void *) 0x6655c, (void *) ModelPart_render_injection); + overwrite_call((void *) 0x66568, (void *) ModelPart_render_injection); + overwrite_call((void *) 0x66574, (void *) ModelPart_render_injection); + overwrite_calls((void *) Tesselator_vertexUV, (void *) Tesselator_vertexUV_injection); + unsigned char chest_model_patch[4] = {0x13, 0x20, 0xa0, 0xe3}; // "mov r2, #0x13" + patch((void *) 0x66fc8, chest_model_patch); + unsigned char chest_color_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; // "nop" + patch((void *) 0x66404, chest_color_patch); + } + patch_address((void *) 0x115b48, (void *) ChestTileEntity_shouldSave_injection); + // Init C++ And Logging _init_misc_cpp(); _init_misc_logging(); diff --git a/symbols/include/symbols/minecraft.h b/symbols/include/symbols/minecraft.h index 0ef788db..7b8a2eea 100644 --- a/symbols/include/symbols/minecraft.h +++ b/symbols/include/symbols/minecraft.h @@ -45,6 +45,7 @@ static unsigned char **Item_egg = (unsigned char **) 0x17bbd0; // Item static unsigned char **Item_dye_powder = (unsigned char **) 0x17bbe0; // Item static unsigned char **Item_camera = (unsigned char **) 0x17bc14; // Item +static unsigned char **Tile_chest = (unsigned char **) 0x181d60; // Tile static unsigned char **Tile_water = (unsigned char **) 0x181b3c; // Tile static unsigned char **Tile_lava = (unsigned char **) 0x181cc8; // Tile static unsigned char **Tile_calmWater = (unsigned char **) 0x181b40; // Tile @@ -132,6 +133,9 @@ static uint32_t Tile_use_vtable_offset = 0x98; typedef int32_t (*Tile_getColor_t)(unsigned char *tile, unsigned char *level_source, int32_t x, int32_t y, int32_t z); static uint32_t Tile_getColor_vtable_offset = 0xb8; +typedef int32_t (*Tile_getRenderShape_t)(unsigned char *tile); +static uint32_t Tile_getRenderShape_vtable_offset = 0xc; + static uint32_t Tile_id_property_offset = 0x8; // int32_t static uint32_t Tile_category_property_offset = 0x3c; // int32_t @@ -830,6 +834,17 @@ static EntityRenderDispatcher_assign_t EntityRenderDispatcher_assign = (EntityRe // TileEntity static uint32_t TileEntity_id_property_offset = 0x18; // int32_t +static uint32_t TileEntity_renderer_id_property_offset = 0x24; // int32_t + +// ChestTileEntity + +typedef unsigned char *(*ChestTileEntity_t)(unsigned char *tile_entity); +static ChestTileEntity_t ChestTileEntity = (ChestTileEntity_t) 0xcfa78; + +// ModelPart + +typedef void (*ModelPart_render_t)(unsigned char *model_part, float scale); +static ModelPart_render_t ModelPart_render = (ModelPart_render_t) 0x416dc; // ItemRenderer @@ -853,6 +868,9 @@ static Tesselator_colorABGR_t Tesselator_colorABGR = (Tesselator_colorABGR_t) 0x typedef void (*Tesselator_color_t)(unsigned char *tesselator, int32_t r, int32_t g, int32_t b, int32_t a); static Tesselator_color_t Tesselator_color = (Tesselator_color_t) 0x52a48; +typedef void (*Tesselator_vertexUV_t)(unsigned char *tesselator, float x, float y, float z, float u, float v); +static Tesselator_vertexUV_t Tesselator_vertexUV = (Tesselator_vertexUV_t) 0x52d40; + // SoundEngine typedef void (*SoundEngine_init_t)(unsigned char *sound_engine, unsigned char *minecraft, unsigned char *options);