Storage monitors now use display lists.
This commit is contained in:
parent
fafa79e657
commit
722d065c2c
1 changed files with 124 additions and 88 deletions
|
@ -6,6 +6,7 @@ import java.io.IOException;
|
|||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
|
@ -112,6 +113,8 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
|
|||
else
|
||||
configuredItem = null;
|
||||
|
||||
updateList = true;
|
||||
|
||||
return stuff;
|
||||
}
|
||||
|
||||
|
@ -150,11 +153,11 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
|
|||
}
|
||||
|
||||
protected PartStorageMonitor(Class myClass, ItemStack is) {
|
||||
super( myClass, is,true );
|
||||
super( myClass, is, true );
|
||||
}
|
||||
|
||||
public PartStorageMonitor(ItemStack is) {
|
||||
super( PartStorageMonitor.class, is,true );
|
||||
super( PartStorageMonitor.class, is, true );
|
||||
frontBright = CableBusTextures.PartStorageMonitor_Bright;
|
||||
frontColored = CableBusTextures.PartStorageMonitor_Colored;
|
||||
frontDark = CableBusTextures.PartStorageMonitor_Dark;
|
||||
|
@ -167,10 +170,28 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
|
|||
return true;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private boolean updateList;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private Integer dspList;
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected void finalize() throws Throwable
|
||||
{
|
||||
super.finalize();
|
||||
if ( dspList != null )
|
||||
GLAllocation.deleteDisplayLists( dspList );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderDynamic(double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
if ( dspList == null )
|
||||
dspList = GLAllocation.generateDisplayLists( 1 );
|
||||
|
||||
Tessellator tess = Tessellator.instance;
|
||||
if ( Platform.isDrawing( tess ) )
|
||||
return;
|
||||
|
@ -182,9 +203,26 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
|
|||
if ( ais != null )
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated( x + 0.5, y + 0.5, z + 0.5 );
|
||||
|
||||
if ( updateList )
|
||||
{
|
||||
updateList = false;
|
||||
GL11.glNewList( dspList, GL11.GL_COMPILE_AND_EXECUTE );
|
||||
tesrRenderScreen( tess, ais );
|
||||
GL11.glEndList();
|
||||
}
|
||||
else
|
||||
GL11.glCallList( dspList );
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
private void tesrRenderScreen(Tessellator tess, IAEItemStack ais)
|
||||
{
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
ForgeDirection d = side;
|
||||
GL11.glTranslated( x + 0.5, y + 0.5, z + 0.5 );
|
||||
GL11.glTranslated( d.offsetX * 0.76, d.offsetY * 0.76, d.offsetZ * 0.76 );
|
||||
|
||||
if ( d == ForgeDirection.UP )
|
||||
|
@ -273,8 +311,6 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
|
|||
fr.drawString( msg, 0, 0, 0 );
|
||||
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue