tcr/java/src/game/renderer/entity/RenderXpOrb.java

86 lines
3.5 KiB
Java
Raw Normal View History

2025-03-11 00:23:54 +01:00
package game.renderer.entity;
2025-03-18 10:24:05 +01:00
import org.lwjgl.opengl.GL11;
2025-03-18 10:14:37 +01:00
import org.lwjgl.opengl.GL13;
2025-03-11 00:23:54 +01:00
import game.entity.item.EntityXp;
import game.renderer.DefaultVertexFormats;
import game.renderer.GlState;
import game.renderer.RenderBuffer;
import game.renderer.Tessellator;
import game.util.ExtMath;
2025-03-11 00:23:54 +01:00
public class RenderXpOrb extends Render<EntityXp>
{
private static final String experienceOrbTextures = "textures/entity/experience_orb.png";
public RenderXpOrb(RenderManager renderManagerIn)
{
super(renderManagerIn);
// this.shadowSize = 0.15F;
// this.shadowOpaque = 0.75F;
}
/**
* Renders the desired {@code T} type Entity.
*/
public void doRender(EntityXp entity, double x, double y, double z, float partialTicks)
{
2025-03-18 10:24:05 +01:00
GL11.glPushMatrix();
GL11.glTranslatef((float)x, (float)y, (float)z);
2025-03-11 00:23:54 +01:00
this.bindEntityTexture(entity);
int i = entity.getXpValue();
float f = (float)(i % 4 * 16 + 0) / 64.0F;
float f1 = (float)(i % 4 * 16 + 16) / 64.0F;
float f2 = (float)(i / 4 * 16 + 0) / 64.0F;
float f3 = (float)(i / 4 * 16 + 16) / 64.0F;
float f4 = 1.0F;
float f5 = 0.5F;
float f6 = 0.25F;
int j = entity.getBrightnessForRender(partialTicks);
int k = j % 65536;
int l = j / 65536;
2025-03-18 10:24:05 +01:00
GL13.glMultiTexCoord2f(GL13.GL_TEXTURE1, (float)k / 1.0F, (float)l / 1.0F);
2025-03-11 00:23:54 +01:00
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
float f8 = 255.0F;
float f9 = ((float)entity.xpColor + partialTicks) / 2.0F;
l = (int)((ExtMath.sin(f9 + 0.0F) + 1.0F) * 0.5F * 255.0F);
int i1 = 255;
int j1 = (int)((ExtMath.sin(f9 + 4.1887903F) + 1.0F) * 0.1F * 255.0F);
2025-03-18 10:24:05 +01:00
GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
2025-03-11 00:23:54 +01:00
float f7 = 0.3F;
2025-03-18 10:24:05 +01:00
GL11.glScalef(0.3F, 0.3F, 0.3F);
2025-03-11 00:23:54 +01:00
// Tessellator tessellator = Tessellator.getInstance();
RenderBuffer worldrenderer = Tessellator.getBuffer();
2025-03-19 23:49:49 +01:00
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR_NORMAL);
2025-03-11 00:23:54 +01:00
worldrenderer.pos((double)(0.0F - f5), (double)(0.0F - f6), 0.0D).tex((double)f, (double)f3).color(l, 255, j1, 128).normal(0.0F, 1.0F, 0.0F).endVertex();
worldrenderer.pos((double)(f4 - f5), (double)(0.0F - f6), 0.0D).tex((double)f1, (double)f3).color(l, 255, j1, 128).normal(0.0F, 1.0F, 0.0F).endVertex();
worldrenderer.pos((double)(f4 - f5), (double)(1.0F - f6), 0.0D).tex((double)f1, (double)f2).color(l, 255, j1, 128).normal(0.0F, 1.0F, 0.0F).endVertex();
worldrenderer.pos((double)(0.0F - f5), (double)(1.0F - f6), 0.0D).tex((double)f, (double)f2).color(l, 255, j1, 128).normal(0.0F, 1.0F, 0.0F).endVertex();
Tessellator.draw();
GlState.disableBlend();
GlState.disableRescaleNormal();
2025-03-18 10:24:05 +01:00
GL11.glPopMatrix();
2025-03-11 00:23:54 +01:00
super.doRender(entity, x, y, z, partialTicks);
}
/**
* Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
*/
protected String getEntityTexture(EntityXp entity)
{
return experienceOrbTextures;
}
// protected boolean canRenderName(EntityXp entity)
// {
// return entity.hasCustomName() || super.canRenderName(entity);
// }
protected void renderLivingLabel(EntityXp entityIn, String str, double x, double y, double z, int maxDistance) {
super.renderLivingLabel(entityIn, str, x, y - 0.5, z, maxDistance);
}
}