diff --git a/Minecraft.Client/EntityRenderDispatcher.cpp b/Minecraft.Client/EntityRenderDispatcher.cpp index 01972e56..c3d9bce1 100644 --- a/Minecraft.Client/EntityRenderDispatcher.cpp +++ b/Minecraft.Client/EntityRenderDispatcher.cpp @@ -163,6 +163,7 @@ EntityRenderDispatcher::EntityRenderDispatcher() renderers[eTYPE_BOAT] = new BoatRenderer(); renderers[eTYPE_FISHINGHOOK] = new FishingHookRenderer(); +// renderers[eTYPE_FISHINGHOOK] = new FishingHookRenderer(this); //TU25 renderers[eTYPE_HORSE] = new HorseRenderer(new ModelHorse(), .75f); diff --git a/Minecraft.Client/EntityRenderer.cpp b/Minecraft.Client/EntityRenderer.cpp index fa41dfa6..30de2d28 100644 --- a/Minecraft.Client/EntityRenderer.cpp +++ b/Minecraft.Client/EntityRenderer.cpp @@ -29,6 +29,107 @@ EntityRenderer::~EntityRenderer() delete tileRenderer; } +// TU25 +/* +bool EntityRenderer::shouldRender(shared_ptr entity, Culler* culler, double x, double y, double z) +{ + if (entity->shouldRenderAt(x, y, z)) + { + if (entity->ignoreFrustumCheck) + return true; + + AABB* boundingBox = entity->getBoundingBox(); + + return culler->isVisible(boundingBox); + } + + return false; +} + +void EntityRenderer::renderName(shared_ptr entity, double x, double y, double z) +{ + if (!this->shouldShowName(entity)) + return; + + wstring nameTag = entity->getDisplayName(); + + if (!msg.empty()) + { + Font* msg = this->getFont(); + + if (font != nullptr) + { + float dist = entity->distanceToSqr(entityRenderDispatcher->cameraEntity); + + if (dist < 64.0f * 64.0f) + renderNameTags(entity, nameTag, x, y, z, 64); + } + } +} + +bool EntityRenderer::shouldShowName(shared_ptr entity) +{ + if (!entity) + return false; + + if (entity->shouldShowName()) + { + if (entity->hasCustomName()) + return true; + } + + return false; +} + +int EntityRenderer::renderNameTags(shared_ptr entity, double x, double y, double z, const wstring& name, float opacity, double distance, int color) +{ +// if (!this->entityRenderDispatcher->allowNameTagRendering()) +// return 0; + + Font* font = getFont(); + + if (font == nullptr) + return 0; + + float fScale = 0.02666667f; + + glPushMatrix(); + glTranslatef((float)x, (float)y + entity->getHeadHeight() + 0.5f, (float)z); + glNormal3f(0.0f, 1.0f, 0.0f); + + glRotatef(-this->entityRenderDispatcher->playerRotY, 0.0f, 1.0f, 0.0f); + glRotatef(this->entityRenderDispatcher->playerRotX, 1.0f, 0.0f, 0.0f); + + glScalef(-fScale, -fScale, fScale); + + glDisable(GL_LIGHTING); + glDepthMask(false); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + Tesselator* t = Tesselator::getInstance(); + int width = font->width(name) / 2; + + glDisable(GL_TEXTURE_2D); + t->begin(); + t->color(0.0f, 0.0f, 0.0f, 0.25f * opacity); + t->vertex(-width - 1, -1, 0.0f); + t->vertex(-width - 1, 8, 0.0f); + t->vertex(width + 1, 8, 0.0f); + t->vertex(width + 1, -1, 0.0f); + t->end(); + glEnable(GL_TEXTURE_2D); + + font->draw(name, -width, 0, color); + + glEnable(GL_LIGHTING); + glDisable(GL_BLEND); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glPopMatrix(); + + return 1; +} +*/ void EntityRenderer::bindTexture(shared_ptr entity) { bindTexture(getTextureLocation(entity)); diff --git a/Minecraft.Client/FishingHookRenderer.cpp b/Minecraft.Client/FishingHookRenderer.cpp index d587ddb8..aaa9fed0 100644 --- a/Minecraft.Client/FishingHookRenderer.cpp +++ b/Minecraft.Client/FishingHookRenderer.cpp @@ -1,34 +1,42 @@ #include "stdafx.h" #include "FishingHookRenderer.h" #include "EntityRenderDispatcher.h" -#include "Options.h" #include "..\Minecraft.World\net.minecraft.world.entity.projectile.h" #include "..\Minecraft.World\net.minecraft.world.entity.player.h" #include "..\Minecraft.World\Vec3.h" #include "..\Minecraft.World\Mth.h" -#include "MultiPlayerLocalPlayer.h" ResourceLocation FishingHookRenderer::PARTICLE_LOCATION = ResourceLocation(TN_PARTICLES); +// TU25 +/* +FishingHookRenderer::FishingHookRenderer(EntityRenderDispatcher* dispatcher) : EntityRenderer() +{ + this->entityRenderDispatcher = dispatcher; +} +*/ + void FishingHookRenderer::render(shared_ptr _hook, double x, double y, double z, float rot, float a) { // 4J - dynamic cast required because we aren't using templates/generics in our version shared_ptr hook = dynamic_pointer_cast(_hook); + if (hook == nullptr) + return; + glPushMatrix(); glTranslatef(static_cast(x), static_cast(y), static_cast(z)); glEnable(GL_RESCALE_NORMAL); glScalef(1 / 2.0f, 1 / 2.0f, 1 / 2.0f); - int xi = 1; - int yi = 2; - bindTexture(hook); // 4J was L"/particles.png" + + bindTexture(hook); //TODO: Remove Tesselator *t = Tesselator::getInstance(); - float u0 = (xi * 8 + 0) / 128.0f; - float u1 = (xi * 8 + 8) / 128.0f; - float v0 = (yi * 8 + 0) / 128.0f; - float v1 = (yi * 8 + 8) / 128.0f; + float u0 = 8.0f / 128.0f; + float u1 = 16.0f / 128.0f; + float v0 = 16.0f / 128.0f; + float v1 = 24.0f / 128.0f; float r = 1.0f; @@ -48,7 +56,6 @@ void FishingHookRenderer::render(shared_ptr _hook, double x, double y, d glDisable(GL_RESCALE_NORMAL); glPopMatrix(); - if (hook->owner != nullptr) { float swing = hook->owner->getAttackAnim(a); @@ -64,7 +71,11 @@ void FishingHookRenderer::render(shared_ptr _hook, double x, double y, d double xp = hook->owner->xo + (hook->owner->x - hook->owner->xo) * a + vv->x; double yp = hook->owner->yo + (hook->owner->y - hook->owner->yo) * a + vv->y; double zp = hook->owner->zo + (hook->owner->z - hook->owner->zo) * a + vv->z; - double yOffset = hook->owner == dynamic_pointer_cast(Minecraft::GetInstance()->player) ? 0 : hook->owner->getHeadHeight(); + + double yOffset = hook->owner->getHeadHeight(); + double sneakOffset = 0.0; + if (hook->owner->isSneaking()) + sneakOffset = -0.1875; // 4J-PB - changing this to be per player //if (this->entityRenderDispatcher->options->thirdPersonView) @@ -73,13 +84,13 @@ void FishingHookRenderer::render(shared_ptr _hook, double x, double y, d float rr = (float) (hook->owner->yBodyRotO + (hook->owner->yBodyRot - hook->owner->yBodyRotO) * a) * PI / 180; double ss = Mth::sin((float) rr); double cc = Mth::cos((float) rr); - xp = hook->owner->xo + (hook->owner->x - hook->owner->xo) * a - cc * 0.35 - ss * 0.85; - yp = hook->owner->yo + yOffset + (hook->owner->y - hook->owner->yo) * a - 0.45; - zp = hook->owner->zo + (hook->owner->z - hook->owner->zo) * a - ss * 0.35 + cc * 0.85; + xp = hook->owner->xo + (hook->owner->x - hook->owner->xo) * a - cc * 0.35 - ss * 0.80; + yp = hook->owner->yo + yOffset + (hook->owner->y - hook->owner->yo) * a - 0.45 + sneakOffset; + zp = hook->owner->zo + (hook->owner->z - hook->owner->zo) * a - ss * 0.35 + cc * 0.80; } double xh = hook->xo + (hook->x - hook->xo) * a; - double yh = hook->yo + (hook->y - hook->yo) * a + 4 / 16.0f; + double yh = hook->yo + (hook->y - hook->yo) * a + 0.25; double zh = hook->zo + (hook->z - hook->zo) * a; double xa = static_cast(xp - xh); @@ -88,17 +99,25 @@ void FishingHookRenderer::render(shared_ptr _hook, double x, double y, d glDisable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); + t->begin(GL_LINE_STRIP); t->color(0x000000); + int steps = 16; for (int i = 0; i <= steps; i++) { - float aa = i / static_cast(steps); - t->vertex(static_cast(x + xa * aa), static_cast(y + ya * (aa * aa + aa) * 0.5 + 4 / 16.0f), static_cast(z + za * aa)); + float aa = static_cast(i) / static_cast(steps); + t->vertex( + static_cast(x + xa * aa), + static_cast(y + ya * (aa * aa + aa) * 0.5 + 0.25f), + static_cast(z + za * aa) + ); } t->end(); glEnable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); + + //EntityRenderer::render(_hook, x, y, z, rot, a); // TU25 } } diff --git a/Minecraft.Client/FishingHookRenderer.h b/Minecraft.Client/FishingHookRenderer.h index 8c58ea9b..daa80fa2 100644 --- a/Minecraft.Client/FishingHookRenderer.h +++ b/Minecraft.Client/FishingHookRenderer.h @@ -5,8 +5,8 @@ class FishingHookRenderer : public EntityRenderer { private: static ResourceLocation PARTICLE_LOCATION; - public: +// FishingHookRenderer(EntityRenderDispatcher* dispatcher); // TU25 virtual void render(shared_ptr _hook, double x, double y, double z, float rot, float a); virtual ResourceLocation *getTextureLocation(shared_ptr mob); }; \ No newline at end of file diff --git a/Minecraft.Client/Windows64/4JLibs/libs/4J_Input.lib b/Minecraft.Client/Windows64/4JLibs/libs/4J_Input.lib index 4423a5c5..65202f46 100644 Binary files a/Minecraft.Client/Windows64/4JLibs/libs/4J_Input.lib and b/Minecraft.Client/Windows64/4JLibs/libs/4J_Input.lib differ diff --git a/Minecraft.Client/Windows64/4JLibs/libs/4J_Input_d.lib b/Minecraft.Client/Windows64/4JLibs/libs/4J_Input_d.lib index 7969c263..2134dac5 100644 Binary files a/Minecraft.Client/Windows64/4JLibs/libs/4J_Input_d.lib and b/Minecraft.Client/Windows64/4JLibs/libs/4J_Input_d.lib differ diff --git a/Minecraft.Client/Windows64/4JLibs/libs/4J_Profile.lib b/Minecraft.Client/Windows64/4JLibs/libs/4J_Profile.lib index 00c65546..2a047236 100644 Binary files a/Minecraft.Client/Windows64/4JLibs/libs/4J_Profile.lib and b/Minecraft.Client/Windows64/4JLibs/libs/4J_Profile.lib differ diff --git a/Minecraft.Client/Windows64/4JLibs/libs/4J_Profile_d.lib b/Minecraft.Client/Windows64/4JLibs/libs/4J_Profile_d.lib index c1c1ffb2..742c7db0 100644 Binary files a/Minecraft.Client/Windows64/4JLibs/libs/4J_Profile_d.lib and b/Minecraft.Client/Windows64/4JLibs/libs/4J_Profile_d.lib differ diff --git a/Minecraft.Client/Windows64/4JLibs/libs/4J_Render_PC.lib b/Minecraft.Client/Windows64/4JLibs/libs/4J_Render_PC.lib index 0800ab94..a0c757ac 100644 Binary files a/Minecraft.Client/Windows64/4JLibs/libs/4J_Render_PC.lib and b/Minecraft.Client/Windows64/4JLibs/libs/4J_Render_PC.lib differ diff --git a/Minecraft.Client/Windows64/4JLibs/libs/4J_Render_PC_d.lib b/Minecraft.Client/Windows64/4JLibs/libs/4J_Render_PC_d.lib index 6b5c7098..495ca4c2 100644 Binary files a/Minecraft.Client/Windows64/4JLibs/libs/4J_Render_PC_d.lib and b/Minecraft.Client/Windows64/4JLibs/libs/4J_Render_PC_d.lib differ diff --git a/Minecraft.Client/Windows64/4JLibs/libs/4J_Storage.lib b/Minecraft.Client/Windows64/4JLibs/libs/4J_Storage.lib index 9b1285b3..75f0102f 100644 Binary files a/Minecraft.Client/Windows64/4JLibs/libs/4J_Storage.lib and b/Minecraft.Client/Windows64/4JLibs/libs/4J_Storage.lib differ diff --git a/Minecraft.Client/Windows64/4JLibs/libs/4J_Storage_d.lib b/Minecraft.Client/Windows64/4JLibs/libs/4J_Storage_d.lib index 656d24c6..67287ede 100644 Binary files a/Minecraft.Client/Windows64/4JLibs/libs/4J_Storage_d.lib and b/Minecraft.Client/Windows64/4JLibs/libs/4J_Storage_d.lib differ