package net.minecraft.client.gui; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.awt.image.BufferedImage; import java.util.Iterator; import net.minecraft.block.material.MapColor; import net.minecraft.client.renderer.RenderEngine; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.settings.GameSettings; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.storage.MapCoord; import net.minecraft.world.storage.MapData; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class MapItemRenderer { private int[] intArray = new int[16384]; private int bufferedImage; private GameSettings gameSettings; private FontRenderer fontRenderer; public MapItemRenderer(FontRenderer par1FontRenderer, GameSettings par2GameSettings, RenderEngine par3RenderEngine) { this.gameSettings = par2GameSettings; this.fontRenderer = par1FontRenderer; this.bufferedImage = par3RenderEngine.allocateAndSetupTexture(new BufferedImage(128, 128, 2)); for (int i = 0; i < 16384; ++i) { this.intArray[i] = 0; } } public void renderMap(EntityPlayer par1EntityPlayer, RenderEngine par2RenderEngine, MapData par3MapData) { for (int i = 0; i < 16384; ++i) { byte b0 = par3MapData.colors[i]; if (b0 / 4 == 0) { this.intArray[i] = (i + i / 128 & 1) * 8 + 16 << 24; } else { int j = MapColor.mapColorArray[b0 / 4].colorValue; int k = b0 & 3; short short1 = 220; if (k == 2) { short1 = 255; } if (k == 0) { short1 = 180; } int l = (j >> 16 & 255) * short1 / 255; int i1 = (j >> 8 & 255) * short1 / 255; int j1 = (j & 255) * short1 / 255; if (this.gameSettings.anaglyph) { int k1 = (l * 30 + i1 * 59 + j1 * 11) / 100; int l1 = (l * 30 + i1 * 70) / 100; int i2 = (l * 30 + j1 * 70) / 100; l = k1; i1 = l1; j1 = i2; } this.intArray[i] = -16777216 | l << 16 | i1 << 8 | j1; } } par2RenderEngine.createTextureFromBytes(this.intArray, 128, 128, this.bufferedImage); byte b1 = 0; byte b2 = 0; Tessellator tessellator = Tessellator.instance; float f = 0.0F; GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.bufferedImage); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_ALPHA_TEST); tessellator.startDrawingQuads(); tessellator.addVertexWithUV((double)((float)(b1 + 0) + f), (double)((float)(b2 + 128) - f), -0.009999999776482582D, 0.0D, 1.0D); tessellator.addVertexWithUV((double)((float)(b1 + 128) - f), (double)((float)(b2 + 128) - f), -0.009999999776482582D, 1.0D, 1.0D); tessellator.addVertexWithUV((double)((float)(b1 + 128) - f), (double)((float)(b2 + 0) + f), -0.009999999776482582D, 1.0D, 0.0D); tessellator.addVertexWithUV((double)((float)(b1 + 0) + f), (double)((float)(b2 + 0) + f), -0.009999999776482582D, 0.0D, 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_BLEND); par2RenderEngine.resetBoundTexture(); par2RenderEngine.bindTexture("/misc/mapicons.png"); int j2 = 0; for (Iterator iterator = par3MapData.playersVisibleOnMap.values().iterator(); iterator.hasNext(); ++j2) { MapCoord mapcoord = (MapCoord)iterator.next(); GL11.glPushMatrix(); GL11.glTranslatef((float)b1 + (float)mapcoord.centerX / 2.0F + 64.0F, (float)b2 + (float)mapcoord.centerZ / 2.0F + 64.0F, -0.02F); GL11.glRotatef((float)(mapcoord.iconRotation * 360) / 16.0F, 0.0F, 0.0F, 1.0F); GL11.glScalef(4.0F, 4.0F, 3.0F); GL11.glTranslatef(-0.125F, 0.125F, 0.0F); float f1 = (float)(mapcoord.iconSize % 4 + 0) / 4.0F; float f2 = (float)(mapcoord.iconSize / 4 + 0) / 4.0F; float f3 = (float)(mapcoord.iconSize % 4 + 1) / 4.0F; float f4 = (float)(mapcoord.iconSize / 4 + 1) / 4.0F; tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-1.0D, 1.0D, (double)((float)j2 * 0.001F), (double)f1, (double)f2); tessellator.addVertexWithUV(1.0D, 1.0D, (double)((float)j2 * 0.001F), (double)f3, (double)f2); tessellator.addVertexWithUV(1.0D, -1.0D, (double)((float)j2 * 0.001F), (double)f3, (double)f4); tessellator.addVertexWithUV(-1.0D, -1.0D, (double)((float)j2 * 0.001F), (double)f1, (double)f4); tessellator.draw(); GL11.glPopMatrix(); } GL11.glPushMatrix(); GL11.glTranslatef(0.0F, 0.0F, -0.04F); GL11.glScalef(1.0F, 1.0F, 1.0F); GL11.glPopMatrix(); } }