Update to fix issues with lag, MUCH faster now.

This commit is contained in:
Brian Wiegand 2012-07-07 23:24:48 -07:00
parent 682d65b829
commit 4012b39b16
1 changed files with 29 additions and 24 deletions

View File

@ -10,7 +10,7 @@
******************************************************************************/
package cpw.mods.ironchest.client;
import static org.lwjgl.opengl.GL11.GL_COMPILE;
import static org.lwjgl.opengl.GL11.GL_COMPILE_AND_EXECUTE;
import static org.lwjgl.opengl.GL11.glColor4f;
import static org.lwjgl.opengl.GL11.glDisable;
import static org.lwjgl.opengl.GL11.glEnable;
@ -45,11 +45,14 @@ import cpw.mods.ironchest.TileEntityIronChest;
public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
private static Map<ItemStack, Integer> renderList = new HashMap<ItemStack, Integer>();
private Random random;
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 },
{ 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 }, };
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 }, };
public static boolean CACHE_RENDER = true;
public TileEntityIronChestRenderer() {
model = new ModelChest();
@ -70,7 +73,6 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
type = IronChestType.values()[typ];
}
bindTextureByName(type.getModelTexture());
glPushMatrix();
glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
@ -101,7 +103,6 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
glDisable(32826 /* GL_RESCALE_NORMAL_EXT */);
glPopMatrix();
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
if (type.isTransparent()) {
random.setSeed(254L);
float shiftX;
@ -153,11 +154,12 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
float minishiftZ = ((random.nextFloat() * 2.0F - 1.0F) * spread) / localScale;
glTranslatef(minishiftX, minishiftY, minishiftZ);
}
if (renderList.get(item) == null) {
if (renderList.get(item) == null || !CACHE_RENDER) { // Added support for using only old system.
if (CACHE_RENDER) {
int render = glGenLists(1);
renderList.put(item, render);
glNewList(render, GL_COMPILE);
glNewList(render, GL_COMPILE_AND_EXECUTE);
}
if (customRenderer != null) {
customitem.item = item;
bindTextureByName("/terrain.png");
@ -200,10 +202,13 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
tessellator.addVertexWithUV(0.0F - f14, 1.0F - f15, 0.0D, f5, f10);
tessellator.draw();
}
} else {
glCallList(renderList.get(item));
}
if (CACHE_RENDER)
glEndList();
} else {
Integer integer = renderList.get(item);
if (integer != null) // Added null check for auto-unboxing JUST in case.
glCallList(integer.intValue());
}
glPopMatrix();
}
glPopMatrix();