Rendering cleanup

Replaces the reflexive instantiation of the Renderes with a factory
method.

Some optimizations to the renderers to no longer push the whole OpenGL state to the stack.

General cleanup of duplicate code, etc
This commit is contained in:
yueh
2015-09-16 18:03:07 +02:00
parent 824ec1eccb
commit d5dfc31210
69 changed files with 435 additions and 343 deletions
+11 -16
View File
@@ -61,6 +61,7 @@ import appeng.core.features.IAEFeature;
import appeng.core.features.IFeatureHandler;
import appeng.helpers.AEGlassMaterial;
import appeng.helpers.ICustomCollision;
import appeng.tile.AEBaseTile;
import appeng.util.LookDirection;
import appeng.util.Platform;
@@ -132,27 +133,21 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
return this.renderInfo;
}
try
{
final BaseBlockRender renderer = this.getRenderer().newInstance();
this.renderInfo = new BlockRenderInfo( renderer );
final BaseBlockRender<? extends AEBaseBlock, ? extends AEBaseTile> renderer = this.getRenderer();
this.renderInfo = new BlockRenderInfo( renderer );
return this.renderInfo;
}
catch( final InstantiationException e )
{
throw new IllegalStateException( "Failed to create a new instance of an illegal class " + this.getRenderer(), e );
}
catch( final IllegalAccessException e )
{
throw new IllegalStateException( "Failed to create a new instance of " + this.getRenderer() + " because of permissions.", e );
}
return this.renderInfo;
}
/**
* Factory method to create a new render instance.
*
* @return the newly created instance.
*/
@SideOnly( Side.CLIENT )
protected Class<? extends BaseBlockRender> getRenderer()
protected BaseBlockRender<? extends AEBaseBlock, ? extends AEBaseTile> getRenderer()
{
return BaseBlockRender.class;
return new BaseBlockRender<AEBaseBlock, AEBaseTile>();
}
IIcon unmappedGetIcon( final IBlockAccess w, final int x, final int y, final int z, final int s )