From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- Minecraft.Client/ExperienceOrbRenderer.cpp | 91 ++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 Minecraft.Client/ExperienceOrbRenderer.cpp (limited to 'Minecraft.Client/ExperienceOrbRenderer.cpp') diff --git a/Minecraft.Client/ExperienceOrbRenderer.cpp b/Minecraft.Client/ExperienceOrbRenderer.cpp new file mode 100644 index 00000000..1771f833 --- /dev/null +++ b/Minecraft.Client/ExperienceOrbRenderer.cpp @@ -0,0 +1,91 @@ +#include "stdafx.h" +#include "ExperienceOrbRenderer.h" +#include "..\Minecraft.World\net.minecraft.world.entity.h" +#include "..\Minecraft.World\net.minecraft.world.level.tile.h" +#include "..\Minecraft.World\net.minecraft.world.item.h" +#include "Tesselator.h" +#include "EntityRenderDispatcher.h" +#include "..\Minecraft.World\Mth.h" +#include "..\Minecraft.World\JavaMath.h" + +ExperienceOrbRenderer::ExperienceOrbRenderer() +{ + // 4J In class Java initialisors + tileRenderer = new TileRenderer(); + setColor = true; + + this->shadowRadius = 0.15f; + this->shadowStrength = 0.75f; +} + + +void ExperienceOrbRenderer::render(shared_ptr _orb, double x, double y, double z, float rot, float a) +{ + shared_ptr orb = dynamic_pointer_cast(_orb); + glPushMatrix(); + glTranslatef((float) x, (float) y, (float) z); + + int icon = orb->getIcon(); + bindTexture(TN_ITEM_EXPERIENCE_ORB); // 4J was L"/item/xporb.png" + Tesselator *t = Tesselator::getInstance(); + + float u0 = ((icon % 4) * 16 + 0) / 64.0f; + float u1 = ((icon % 4) * 16 + 16) / 64.0f; + float v0 = ((icon / 4) * 16 + 0) / 64.0f; + float v1 = ((icon / 4) * 16 + 16) / 64.0f; + + + float r = 1.0f; + float xo = 0.5f; + float yo = 0.25f; + + if (SharedConstants::TEXTURE_LIGHTING) + { + int col = orb->getLightColor(a); + int u = col % 65536; + int v = col / 65536; + glMultiTexCoord2f(GL_TEXTURE1, u / 1.0f, v / 1.0f); + glColor4f(1, 1, 1, 1); + } + else + { + float br = orb->getBrightness(a); + glColor4f(br, br, br, 1); + } + float br = 255.0f; + float rr = (orb->tickCount + a) / 2; + int rc = (int) ((Mth::sin(rr + 0 * PI * 2 / 3) + 1) * 0.5f * br); + int gc = (int) (br); + int bc = (int) ((Mth::sin(rr + 2 * PI * 2 / 3) + 1) * 0.1f * br); + int col = rc << 16 | gc << 8 | bc; + glRotatef(180 - entityRenderDispatcher->playerRotY, 0, 1, 0); + glRotatef(-entityRenderDispatcher->playerRotX, 1, 0, 0); + float s = 0.3f; + glScalef(s, s, s); + t->begin(); + t->color(col, 128); + t->normal(0, 1, 0); + t->vertexUV(0 - xo, 0 - yo, 0, u0, v1); + t->vertexUV(r - xo, 0 - yo, 0, u1, v1); + t->vertexUV(r - xo, 1 - yo, 0, u1, v0); + t->vertexUV(0 - xo, 1 - yo, 0, u0, v0); + t->end(); + + glDisable(GL_BLEND); + glDisable(GL_RESCALE_NORMAL); + glPopMatrix(); +} + +void ExperienceOrbRenderer::blit(int x, int y, int sx, int sy, int w, int h) +{ + float blitOffset = 0; + float us = 1 / 256.0f; + float vs = 1 / 256.0f; + Tesselator *t = Tesselator::getInstance(); + t->begin(); + t->vertexUV(x + 0, y + h, blitOffset, (sx + 0) * us, (sy + h) * vs); + t->vertexUV(x + w, y + h, blitOffset, (sx + w) * us, (sy + h) * vs); + t->vertexUV(x + w, y + 0, blitOffset, (sx + w) * us, (sy + 0) * vs); + t->vertexUV(x + 0, y + 0, blitOffset, (sx + 0) * us, (sy + 0) * vs); + t->end(); +} \ No newline at end of file -- cgit v1.2.3