the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 93 lines 2.8 kB view raw
1#include "stdafx.h" 2#include "ExperienceOrbRenderer.h" 3#include "..\Minecraft.World\net.minecraft.world.entity.h" 4#include "..\Minecraft.World\net.minecraft.world.level.tile.h" 5#include "..\Minecraft.World\net.minecraft.world.item.h" 6#include "Tesselator.h" 7#include "EntityRenderDispatcher.h" 8#include "..\Minecraft.World\Mth.h" 9#include "..\Minecraft.World\JavaMath.h" 10 11ResourceLocation ExperienceOrbRenderer::XP_ORB_LOCATION = ResourceLocation(TN_ITEM_EXPERIENCE_ORB); 12 13ExperienceOrbRenderer::ExperienceOrbRenderer() 14{ 15 shadowRadius = 0.15f; 16 shadowStrength = 0.75f; 17} 18 19void ExperienceOrbRenderer::render(shared_ptr<Entity> _orb, double x, double y, double z, float rot, float a) 20{ 21 shared_ptr<ExperienceOrb> orb = dynamic_pointer_cast<ExperienceOrb>(_orb); 22 glPushMatrix(); 23 glTranslatef((float) x, (float) y, (float) z); 24 25 int icon = orb->getIcon(); 26 bindTexture(orb); // 4J was L"/item/xporb.png" 27 28 float u0 = ((icon % 4) * 16 + 0) / 64.0f; 29 float u1 = ((icon % 4) * 16 + 16) / 64.0f; 30 float v0 = ((icon / 4) * 16 + 0) / 64.0f; 31 float v1 = ((icon / 4) * 16 + 16) / 64.0f; 32 33 34 float r = 1.0f; 35 float xo = 0.5f; 36 float yo = 0.25f; 37 38 if (SharedConstants::TEXTURE_LIGHTING) 39 { 40 int col = orb->getLightColor(a); 41 int u = col % 65536; 42 int v = col / 65536; 43 glMultiTexCoord2f(GL_TEXTURE1, u / 1.0f, v / 1.0f); 44 glColor4f(1, 1, 1, 1); 45 } 46 else 47 { 48 float br = orb->getBrightness(a); 49 glColor4f(br, br, br, 1); 50 } 51 float br = 255.0f; 52 float rr = (orb->tickCount + a) / 2; 53 int rc = (int) ((Mth::sin(rr + 0 * PI * 2 / 3) + 1) * 0.5f * br); 54 int gc = (int) (br); 55 int bc = (int) ((Mth::sin(rr + 2 * PI * 2 / 3) + 1) * 0.1f * br); 56 int col = rc << 16 | gc << 8 | bc; 57 glRotatef(180 - entityRenderDispatcher->playerRotY, 0, 1, 0); 58 glRotatef(-entityRenderDispatcher->playerRotX, 1, 0, 0); 59 float s = 0.3f; 60 glScalef(s, s, s); 61 Tesselator *t = Tesselator::getInstance(); 62 t->begin(); 63 t->color(col, 128); 64 t->normal(0, 1, 0); 65 t->vertexUV(0 - xo, 0 - yo, 0, u0, v1); 66 t->vertexUV(r - xo, 0 - yo, 0, u1, v1); 67 t->vertexUV(r - xo, 1 - yo, 0, u1, v0); 68 t->vertexUV(0 - xo, 1 - yo, 0, u0, v0); 69 t->end(); 70 71 glDisable(GL_BLEND); 72 glDisable(GL_RESCALE_NORMAL); 73 glPopMatrix(); 74} 75 76ResourceLocation *ExperienceOrbRenderer::getTextureLocation(shared_ptr<Entity> mob) 77{ 78 return &XP_ORB_LOCATION; 79} 80 81void ExperienceOrbRenderer::blit(int x, int y, int sx, int sy, int w, int h) 82{ 83 float blitOffset = 0; 84 float us = 1 / 256.0f; 85 float vs = 1 / 256.0f; 86 Tesselator *t = Tesselator::getInstance(); 87 t->begin(); 88 t->vertexUV(x + 0, y + h, blitOffset, (sx + 0) * us, (sy + h) * vs); 89 t->vertexUV(x + w, y + h, blitOffset, (sx + w) * us, (sy + h) * vs); 90 t->vertexUV(x + w, y + 0, blitOffset, (sx + w) * us, (sy + 0) * vs); 91 t->vertexUV(x + 0, y + 0, blitOffset, (sx + 0) * us, (sy + 0) * vs); 92 t->end(); 93}