Fixes 1896: Only update a monitor if the text would change

This commit is contained in:
yueh 2015-09-23 20:02:46 +02:00 committed by thatsIch
parent 03073081f8
commit c96cf10c86

View file

@ -79,6 +79,7 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
{ {
private static final IWideReadableNumberConverter NUMBER_CONVERTER = ReadableNumberConverter.INSTANCE; private static final IWideReadableNumberConverter NUMBER_CONVERTER = ReadableNumberConverter.INSTANCE;
private IAEItemStack configuredItem; private IAEItemStack configuredItem;
private String lastHumanReadableText;
private boolean isLocked; private boolean isLocked;
private IStackWatcher myWatcher; private IStackWatcher myWatcher;
@SideOnly( Side.CLIENT ) @SideOnly( Side.CLIENT )
@ -177,6 +178,7 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
final TileEntity te = this.tile; final TileEntity te = this.tile;
final ItemStack eq = player.getCurrentEquippedItem(); final ItemStack eq = player.getCurrentEquippedItem();
if( Platform.isWrench( player, eq, te.getPos() ) ) if( Platform.isWrench( player, eq, te.getPos() ) )
{ {
this.isLocked = !this.isLocked; this.isLocked = !this.isLocked;
@ -249,6 +251,7 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
protected void finalize() throws Throwable protected void finalize() throws Throwable
{ {
super.finalize(); super.finalize();
if( this.dspList != null ) if( this.dspList != null )
{ {
GLAllocation.deleteDisplayLists( this.dspList ); GLAllocation.deleteDisplayLists( this.dspList );
@ -273,6 +276,7 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
} }
final IAEItemStack ais = (IAEItemStack) this.getDisplayed(); final IAEItemStack ais = (IAEItemStack) this.getDisplayed();
if( ais != null ) if( ais != null )
{ {
GL11.glPushMatrix(); GL11.glPushMatrix();
@ -313,44 +317,42 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
final AEPartLocation d = this.side; final AEPartLocation d = this.side;
GL11.glTranslated( d.xOffset * 0.77, d.yOffset * 0.77, d.zOffset * 0.77 ); GL11.glTranslated( d.xOffset * 0.77, d.yOffset * 0.77, d.zOffset * 0.77 );
if( d == AEPartLocation.UP ) switch( d ) {
{ case UP:
GL11.glScalef( 1.0f, -1.0f, 1.0f ); GL11.glScalef( 1.0f, -1.0f, 1.0f );
GL11.glRotatef( 90.0f, 1.0f, 0.0f, 0.0f ); GL11.glRotatef( 90.0f, 1.0f, 0.0f, 0.0f );
GL11.glRotatef( this.getSpin() * 90.0F, 0, 0, 1 ); GL11.glRotatef( this.getSpin() * 90.0F, 0, 0, 1 );
} break;
if( d == AEPartLocation.DOWN ) case DOWN:
{
GL11.glScalef( 1.0f, -1.0f, 1.0f ); GL11.glScalef( 1.0f, -1.0f, 1.0f );
GL11.glRotatef( -90.0f, 1.0f, 0.0f, 0.0f ); GL11.glRotatef( -90.0f, 1.0f, 0.0f, 0.0f );
GL11.glRotatef( this.getSpin() * -90.0F, 0, 0, 1 ); GL11.glRotatef( this.getSpin() * -90.0F, 0, 0, 1 );
} break;
if( d == AEPartLocation.EAST ) case EAST:
{
GL11.glScalef( -1.0f, -1.0f, -1.0f ); GL11.glScalef( -1.0f, -1.0f, -1.0f );
GL11.glRotatef( -90.0f, 0.0f, 1.0f, 0.0f ); GL11.glRotatef( -90.0f, 0.0f, 1.0f, 0.0f );
} break;
if( d == AEPartLocation.WEST ) case WEST:
{
GL11.glScalef( -1.0f, -1.0f, -1.0f ); GL11.glScalef( -1.0f, -1.0f, -1.0f );
GL11.glRotatef( 90.0f, 0.0f, 1.0f, 0.0f ); GL11.glRotatef( 90.0f, 0.0f, 1.0f, 0.0f );
} break;
if( d == AEPartLocation.NORTH ) case NORTH:
{
GL11.glScalef( -1.0f, -1.0f, -1.0f ); GL11.glScalef( -1.0f, -1.0f, -1.0f );
} break;
if( d == AEPartLocation.SOUTH ) case SOUTH:
{
GL11.glScalef( -1.0f, -1.0f, -1.0f ); GL11.glScalef( -1.0f, -1.0f, -1.0f );
GL11.glRotatef( 180.0f, 0.0f, 1.0f, 0.0f ); GL11.glRotatef( 180.0f, 0.0f, 1.0f, 0.0f );
break;
default:
break;
} }
// GL11.glPushMatrix();
try try
{ {
final ItemStack sis = ais.getItemStack(); final ItemStack sis = ais.getItemStack();
@ -380,8 +382,6 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
GL11.glEnable( GL12.GL_RESCALE_NORMAL ); GL11.glEnable( GL12.GL_RESCALE_NORMAL );
} }
// GL11.glPopMatrix();
GL11.glTranslatef( 0.0f, 0.14f, -0.24f ); GL11.glTranslatef( 0.0f, 0.14f, -0.24f );
GL11.glScalef( 1.0f / 62.0f, 1.0f / 62.0f, 1.0f / 62.0f ); GL11.glScalef( 1.0f / 62.0f, 1.0f / 62.0f, 1.0f / 62.0f );
@ -423,9 +423,16 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
this.configuredItem.setStackSize( fullStack.getStackSize() ); this.configuredItem.setStackSize( fullStack.getStackSize() );
} }
final long stackSize = this.configuredItem.getStackSize();
final String humanReadableText = NUMBER_CONVERTER.toWideReadableForm( stackSize );
if( !humanReadableText.equals( this.lastHumanReadableText ) )
{
this.lastHumanReadableText = humanReadableText;
this.getHost().markForUpdate(); this.getHost().markForUpdate();
} }
} }
}
@Override @Override
public boolean showNetworkInfo( MovingObjectPosition where ) public boolean showNetworkInfo( MovingObjectPosition where )