Fix Baby Shadows

This commit is contained in:
TheBrokenRail 2024-10-19 18:44:22 -04:00
parent fbb3152a70
commit f5da0f60e5
3 changed files with 33 additions and 2 deletions

View File

@ -1,4 +1,5 @@
#include <cmath>
#include <cxxabi.h>
#include <libreborn/libreborn.h>
#include <symbols/minecraft.h>
@ -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;

View File

@ -1,6 +1,7 @@
#include <optional>
#include <cstddef>
#include <algorithm>
#include <cxxabi.h>
#include <GLES/gl.h>
@ -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<const __cxxabiv1::__si_class_type_info *>(info);
if (a) {
explore(a->__base_type);
} else {
const __cxxabiv1::__vmi_class_type_info *b = dynamic_cast<const __cxxabiv1::__vmi_class_type_info *>(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<const __cxxabiv1::__si_class_type_info *>(info);
explore(info2);
}

View File

@ -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;