| 1 | package net.minecraft.client.renderer.entity;
|
| 2 |
|
| 3 | import net.minecraft.client.renderer.GlStateManager;
|
| 4 | import net.minecraft.client.renderer.OpenGlHelper;
|
| 5 | import net.minecraft.client.renderer.Tessellator;
|
| 6 | import net.minecraft.client.renderer.WorldRenderer;
|
| 7 | import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
| 8 | import net.minecraft.entity.item.EntityXPOrb;
|
| 9 | import net.minecraft.util.MathHelper;
|
| 10 | import net.minecraft.util.ResourceLocation;
|
| 11 |
|
| 12 | public class RenderXPOrb extends Render<EntityXPOrb>
|
| 13 | {
|
| 14 | private static final ResourceLocation experienceOrbTextures = new ResourceLocation("textures/entity/experience_orb.png");
|
| 15 |
|
| 16 | public RenderXPOrb(RenderManager renderManagerIn)
|
| 17 | {
|
| 18 | super(renderManagerIn);
|
| 19 | this.shadowSize = 0.15F;
|
| 20 | this.shadowOpaque = 0.75F;
|
| 21 | }
|
| 22 |
|
| 23 | /**
|
| 24 | * Renders the desired {@code T} type Entity.
|
| 25 | */
|
| 26 | public void doRender(EntityXPOrb entity, double x, double y, double z, float entityYaw, float partialTicks)
|
| 27 | {
|
| 28 | GlStateManager.pushMatrix();
|
| 29 | GlStateManager.translate((float)x, (float)y, (float)z);
|
| 30 | this.bindEntityTexture(entity);
|
| 31 | int i = entity.getTextureByXP();
|
| 32 | float f = (float)(i % 4 * 16 + 0) / 64.0F;
|
| 33 | float f1 = (float)(i % 4 * 16 + 16) / 64.0F;
|
| 34 | float f2 = (float)(i / 4 * 16 + 0) / 64.0F;
|
| 35 | float f3 = (float)(i / 4 * 16 + 16) / 64.0F;
|
| 36 | float f4 = 1.0F;
|
| 37 | float f5 = 0.5F;
|
| 38 | float f6 = 0.25F;
|
| 39 | int j = entity.getBrightnessForRender(partialTicks);
|
| 40 | int k = j % 65536;
|
| 41 | int l = j / 65536;
|
| 42 | OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)k / 1.0F, (float)l / 1.0F);
|
| 43 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
| 44 | float f8 = 255.0F;
|
| 45 | float f9 = ((float)entity.xpColor + partialTicks) / 2.0F;
|
| 46 | l = (int)((MathHelper.sin(f9 + 0.0F) + 1.0F) * 0.5F * 255.0F);
|
| 47 | int i1 = 255;
|
| 48 | int j1 = (int)((MathHelper.sin(f9 + 4.1887903F) + 1.0F) * 0.1F * 255.0F);
|
| 49 | GlStateManager.rotate(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
|
| 50 | GlStateManager.rotate(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
|
| 51 | float f7 = 0.3F;
|
| 52 | GlStateManager.scale(0.3F, 0.3F, 0.3F);
|
| 53 | Tessellator tessellator = Tessellator.getInstance();
|
| 54 | WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
| 55 | worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR_NORMAL);
|
| 56 | 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();
|
| 57 | 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();
|
| 58 | 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();
|
| 59 | 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();
|
| 60 | tessellator.draw();
|
| 61 | GlStateManager.disableBlend();
|
| 62 | GlStateManager.disableRescaleNormal();
|
| 63 | GlStateManager.popMatrix();
|
| 64 | super.doRender(entity, x, y, z, entityYaw, partialTicks);
|
| 65 | }
|
| 66 |
|
| 67 | /**
|
| 68 | * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
|
| 69 | */
|
| 70 | protected ResourceLocation getEntityTexture(EntityXPOrb entity)
|
| 71 | {
|
| 72 | return experienceOrbTextures;
|
| 73 | }
|
| 74 | }
|
| 75 |
|