From f5da0f60e5857e7ecfda35ae3d5eef44330ff0db Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Sat, 19 Oct 2024 18:44:22 -0400 Subject: [PATCH] Fix Baby Shadows --- mods/src/misc/graphics.cpp | 14 ++++++++++++-- mods/src/shading/tesselator.cpp | 20 ++++++++++++++++++++ symbols/src/entity/Mob.def | 1 + 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/mods/src/misc/graphics.cpp b/mods/src/misc/graphics.cpp index 42e2ff9458..95bef6a3a7 100644 --- a/mods/src/misc/graphics.cpp +++ b/mods/src/misc/graphics.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -181,7 +182,10 @@ static void render_shadow_tile(Tile *tile, const float x, const float y, const f t.vertexUV(x1, y0, z1, u1, v1); t.vertexUV(x1, y0, z0, u1, v0); } -static void render_shadow(const EntityRenderer *self, Entity *entity, float x, float y, float z, const float a) { +static const __cxxabiv1::__class_type_info *get_type_info(void *vtable) { + return *(((__cxxabiv1::__class_type_info **) Cow_vtable_base) - 1);; +} +static void render_shadow(const EntityRenderer *self, Entity *entity, const float x, const float y, const float z, const float a) { // Calculate Power float pow = 0; if (self->shadow_radius > 0) { @@ -200,7 +204,13 @@ static void render_shadow(const EntityRenderer *self, Entity *entity, float x, f glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); Level *level = EntityRenderer::entityRenderDispatcher->level; glDepthMask(false); - const float r = self->shadow_radius; + float r = self->shadow_radius; + if (entity->isMob()) { + Mob *mob = (Mob *) entity; + if (mob->isBaby()) { + r *= 0.5f; + } + } const float ex = entity->old_x + (entity->x - entity->old_x) * a; float ey = entity->old_y + (entity->y - entity->old_y) * a + entity->getShadowHeightOffs() - entity->height_offset; const float ez = entity->old_z + (entity->z - entity->old_z) * a; diff --git a/mods/src/shading/tesselator.cpp b/mods/src/shading/tesselator.cpp index 632193de6b..42367a5361 100644 --- a/mods/src/shading/tesselator.cpp +++ b/mods/src/shading/tesselator.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include @@ -189,6 +190,21 @@ static void Tesselator_normal_injection(__attribute__((unused)) Tesselator *self CustomTesselator::instance.normal = xx | (yy << 8) | (zz << 16); } +static void explore(const __cxxabiv1::__class_type_info *info) { + INFO("Test: %s", info->name()); + const __cxxabiv1::__si_class_type_info *a = dynamic_cast(info); + if (a) { + explore(a->__base_type); + } else { + const __cxxabiv1::__vmi_class_type_info *b = dynamic_cast(info); + if (b) { + for (unsigned int i = 0; i < b->__base_count; i++) { + explore(b->__base_info[i].__base_type); + } + } + } +} + // Init void _init_custom_tesselator() { multidraw_vertex_size = sizeof(CustomVertex); @@ -200,4 +216,8 @@ void _init_custom_tesselator() { overwrite_call((void *) Tesselator_vertex->backup, (void *) Tesselator_vertex_injection, true); overwrite_call((void *) Tesselator_normal->backup, (void *) Tesselator_normal_injection, true); overwrite_call((void *) Common_drawArrayVT->backup, (void *) drawArrayVT_injection, true); + + const std::type_info *info = *(((std::type_info **) Cow_vtable_base) - 1); + const __cxxabiv1::__si_class_type_info *info2 = dynamic_cast(info); + explore(info2); } \ No newline at end of file diff --git a/symbols/src/entity/Mob.def b/symbols/src/entity/Mob.def index e72f91c9ed..8cb08126b6 100644 --- a/symbols/src/entity/Mob.def +++ b/symbols/src/entity/Mob.def @@ -11,6 +11,7 @@ virtual-method void updateAi() = 0x1cc; virtual-method float getWalkingSpeedModifier() = 0x1e8; virtual-method void aiStep() = 0x180; virtual-method int getMaxHealth() = 0x168; +virtual-method bool isBaby() = 0x1a8; method bool getSharedFlag(int flag) = 0x81fd8; method void setSharedFlag(int flag, bool value) = 0x81ef8;