Merge branch 'GenuineSounds-patch-1'

This commit is contained in:
Christian 2012-06-25 15:41:20 -04:00
commit aa2388e76e
1 changed files with 56 additions and 40 deletions

View File

@ -10,9 +10,14 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.client; package cpw.mods.ironchest.client;
import static org.lwjgl.opengl.GL11.GL_COMPILE;
import static org.lwjgl.opengl.GL11.glColor4f; import static org.lwjgl.opengl.GL11.glColor4f;
import static org.lwjgl.opengl.GL11.glDisable; import static org.lwjgl.opengl.GL11.glDisable;
import static org.lwjgl.opengl.GL11.glEnable; import static org.lwjgl.opengl.GL11.glEnable;
import static org.lwjgl.opengl.GL11.glEndList;
import static org.lwjgl.opengl.GL11.glGenLists;
import static org.lwjgl.opengl.GL11.glCallList;
import static org.lwjgl.opengl.GL11.glNewList;
import static org.lwjgl.opengl.GL11.glPopMatrix; import static org.lwjgl.opengl.GL11.glPopMatrix;
import static org.lwjgl.opengl.GL11.glPushMatrix; import static org.lwjgl.opengl.GL11.glPushMatrix;
import static org.lwjgl.opengl.GL11.glRotatef; import static org.lwjgl.opengl.GL11.glRotatef;
@ -20,6 +25,8 @@ import static org.lwjgl.opengl.GL11.glScalef;
import static org.lwjgl.opengl.GL11.glTranslatef; import static org.lwjgl.opengl.GL11.glTranslatef;
import java.util.Random; import java.util.Random;
import java.util.Map;
import java.util.HashMap;
import net.minecraft.src.Block; import net.minecraft.src.Block;
import net.minecraft.src.EntityItem; import net.minecraft.src.EntityItem;
@ -37,11 +44,12 @@ import cpw.mods.ironchest.IronChestType;
import cpw.mods.ironchest.TileEntityIronChest; import cpw.mods.ironchest.TileEntityIronChest;
public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer { public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
private static Map<ItemStack, Integer> renderList = new HashMap<ItemStack, Integer>();
private Random random; private Random random;
private RenderBlocks renderBlocks; private RenderBlocks renderBlocks;
private static float[][] shifts = { { 0.3F, 0.45F, 0.3F }, { 0.7F, 0.45F, 0.3F }, { 0.3F, 0.45F, 0.7F }, { 0.7F, 0.45F, 0.7F }, private static float[][] shifts = { { 0.3F, 0.45F, 0.3F }, { 0.7F, 0.45F, 0.3F }, { 0.3F, 0.45F, 0.7F }, { 0.7F, 0.45F, 0.7F },
{ 0.3F, 0.1F, 0.3F }, { 0.7F, 0.1F, 0.3F }, { 0.3F, 0.1F, 0.7F }, { 0.7F, 0.1F, 0.7F }, { 0.5F, 0.32F, 0.5F }, }; { 0.3F, 0.1F, 0.3F }, { 0.7F, 0.1F, 0.3F }, { 0.3F, 0.1F, 0.7F }, { 0.7F, 0.1F, 0.7F }, { 0.5F, 0.32F, 0.5F }, };
public TileEntityIronChestRenderer() { public TileEntityIronChestRenderer() {
model = new ModelChest(); model = new ModelChest();
@ -112,7 +120,7 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
glDisable(2896 /* GL_LIGHTING */); glDisable(2896 /* GL_LIGHTING */);
glEnable(32826 /* GL_RESCALE_NORMAL_EXT */); glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);
glTranslatef((float) x, (float) y, (float) z); glTranslatef((float) x, (float) y, (float) z);
EntityItem customitem=new EntityItem(tileEntityRenderer.worldObj); EntityItem customitem=new EntityItem(tileEntityRenderer.worldObj);
for (ItemStack item : tile.getTopItemStacks()) { for (ItemStack item : tile.getTopItemStacks()) {
if (shift > shifts.length) { if (shift > shifts.length) {
break; break;
@ -146,48 +154,56 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
glTranslatef(minishiftX, minishiftY, minishiftZ); glTranslatef(minishiftX, minishiftY, minishiftZ);
} }
if (customRenderer != null) { if (renderList.get(item) == null) {
customitem.item=item; int render = glGenLists(1);
bindTextureByName("/terrain.png"); renderList.put(item, render);
ForgeHooksClient.overrideTexture(item.getItem()); glNewList(render, GL_COMPILE);
customRenderer.renderItem(IItemRenderer.ItemRenderType.ENTITY, item, renderBlocks, customitem); if (customRenderer != null) {
} else if (item.itemID < Block.blocksList.length && Block.blocksList[item.itemID]!=null && RenderBlocks.renderItemIn3d(Block.blocksList[item.itemID].getRenderType())) { customitem.item=item;
bindTextureByName("/terrain.png"); bindTextureByName("/terrain.png");
ForgeHooksClient.overrideTexture(Block.blocksList[item.itemID]); ForgeHooksClient.overrideTexture(item.getItem());
renderBlocks.renderBlockAsItem(Block.blocksList[item.itemID], item.getItemDamage(), 1.0F); customRenderer.renderItem(IItemRenderer.ItemRenderType.ENTITY, item, renderBlocks, customitem);
} else { } else if (item.itemID < Block.blocksList.length && Block.blocksList[item.itemID]!=null && RenderBlocks.renderItemIn3d(Block.blocksList[item.itemID].getRenderType())) {
int i = item.getIconIndex();
if (item.itemID >= Block.blocksList.length || Block.blocksList[item.itemID]==null) {
bindTextureByName("/gui/items.png");
ForgeHooksClient.overrideTexture(Item.itemsList[item.itemID]);
} else {
bindTextureByName("/terrain.png"); bindTextureByName("/terrain.png");
ForgeHooksClient.overrideTexture(Block.blocksList[item.itemID]); ForgeHooksClient.overrideTexture(Block.blocksList[item.itemID]);
renderBlocks.renderBlockAsItem(Block.blocksList[item.itemID], item.getItemDamage(), 1.0F);
} else {
int i = item.getIconIndex();
if (item.itemID >= Block.blocksList.length || Block.blocksList[item.itemID]==null) {
bindTextureByName("/gui/items.png");
ForgeHooksClient.overrideTexture(Item.itemsList[item.itemID]);
} else {
bindTextureByName("/terrain.png");
ForgeHooksClient.overrideTexture(Block.blocksList[item.itemID]);
}
Tessellator tessellator = Tessellator.instance;
float f5 = (float) ((i % 16) * 16 + 0) / 256F;
float f8 = (float) ((i % 16) * 16 + 16) / 256F;
float f10 = (float) ((i / 16) * 16 + 0) / 256F;
float f12 = (float) ((i / 16) * 16 + 16) / 256F;
float f13 = 1.0F;
float f14 = 0.5F;
float f15 = 0.25F;
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
tessellator.addVertexWithUV(0.0F - f14, 0.0F - f15, 0.0D, f5, f12);
tessellator.addVertexWithUV(f13 - f14, 0.0F - f15, 0.0D, f8, f12);
tessellator.addVertexWithUV(f13 - f14, 1.0F - f15, 0.0D, f8, f10);
tessellator.addVertexWithUV(0.0F - f14, 1.0F - f15, 0.0D, f5, f10);
tessellator.draw();
glScalef(-1.0F, 1.0F, 1.0F);
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
tessellator.addVertexWithUV(0.0F - f14, 0.0F - f15, 0.0D, f5, f12);
tessellator.addVertexWithUV(f13 - f14, 0.0F - f15, 0.0D, f8, f12);
tessellator.addVertexWithUV(f13 - f14, 1.0F - f15, 0.0D, f8, f10);
tessellator.addVertexWithUV(0.0F - f14, 1.0F - f15, 0.0D, f5, f10);
tessellator.draw();
} }
Tessellator tessellator = Tessellator.instance; } else {
float f5 = (float) ((i % 16) * 16 + 0) / 256F; glCallList(renderList.get(item));
float f8 = (float) ((i % 16) * 16 + 16) / 256F;
float f10 = (float) ((i / 16) * 16 + 0) / 256F;
float f12 = (float) ((i / 16) * 16 + 16) / 256F;
float f13 = 1.0F;
float f14 = 0.5F;
float f15 = 0.25F;
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
tessellator.addVertexWithUV(0.0F - f14, 0.0F - f15, 0.0D, f5, f12);
tessellator.addVertexWithUV(f13 - f14, 0.0F - f15, 0.0D, f8, f12);
tessellator.addVertexWithUV(f13 - f14, 1.0F - f15, 0.0D, f8, f10);
tessellator.addVertexWithUV(0.0F - f14, 1.0F - f15, 0.0D, f5, f10);
tessellator.draw();
glScalef(-1.0F, 1.0F, 1.0F);
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
tessellator.addVertexWithUV(0.0F - f14, 0.0F - f15, 0.0D, f5, f12);
tessellator.addVertexWithUV(f13 - f14, 0.0F - f15, 0.0D, f8, f12);
tessellator.addVertexWithUV(f13 - f14, 1.0F - f15, 0.0D, f8, f10);
tessellator.addVertexWithUV(0.0F - f14, 1.0F - f15, 0.0D, f5, f10);
tessellator.draw();
} }
glEndList();
glPopMatrix(); glPopMatrix();
} }
glPopMatrix(); glPopMatrix();