Added less draw calls for fast graphics

This commit is contained in:
Calclavia 2013-08-07 22:22:58 -04:00
parent 0fd548153f
commit 3e2a5bd268
4 changed files with 26 additions and 4 deletions

View file

@ -83,6 +83,12 @@ public class ClientProxy extends CommonProxy
return false;
}
@Override
public boolean isFancy()
{
return FMLClientHandler.instance().getClient().gameSettings.fancyGraphics;
}
@Override
public void renderElectricShock(World world, Vector3 start, Vector3 target, float r, float g, float b)
{

View file

@ -66,4 +66,9 @@ public class CommonProxy implements IGuiHandler
{
renderElectricShock(world, start, target, 0.55f, 0.7f, 1f);
}
public boolean isFancy()
{
return false;
}
}

View file

@ -80,6 +80,7 @@ public class BlockEMContractor extends BlockBase implements ITileEntityProvider
else
{
contractor.suck = !contractor.suck;
contractor.updatePath();
}
return true;

View file

@ -138,14 +138,18 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements IPacke
}
}
int renderFrequency = ResonantInduction.proxy.isFancy() ? 1 + this.worldObj.rand.nextInt(2) : 10 + this.worldObj.rand.nextInt(2);
boolean renderBeam = this.ticks % renderFrequency == 0 && this.linked != null && !this.linked.isInvalid() && this.linked.suck != this.suck;
if (!this.suck)
{
if (this.linked != null && !this.linked.isInvalid())
{
if (this.ticks % (1 + this.worldObj.rand.nextInt(2)) == 0)
if (renderBeam)
{
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(this).translate(0.5), new Vector3(this).translate(new Vector3(this.getDirection())).translate(0.5), TileEntityTesla.dyeColors[dyeID]);
}
if (this.pathfinder != null)
{
Vector3 lastTurn = null;
@ -165,7 +169,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements IPacke
Vector3 difference = prevResult.clone().difference(result);
final ForgeDirection direction = difference.toForgeDirection();
if (this.ticks % (1 + this.worldObj.rand.nextInt(2)) == 0)
if (renderBeam)
{
ResonantInduction.proxy.renderElectricShock(this.worldObj, prevResult.clone().translate(0.5), result.clone().translate(0.5), TileEntityTesla.dyeColors[dyeID]);
}
@ -197,7 +201,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements IPacke
}
else
{
if (this.linked != null && !this.linked.isInvalid())
if (renderBeam)
{
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(this).translate(0.5), new Vector3(this).translate(new Vector3(this.getDirection())).translate(0.5), TileEntityTesla.dyeColors[dyeID]);
}
@ -208,7 +212,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements IPacke
{
for (EntityItem entityItem : (List<EntityItem>) worldObj.getEntitiesWithinAABB(EntityItem.class, operationBounds))
{
if (this.worldObj.isRemote && this.ticks % 5 == 0)
if (renderBeam)
{
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(this).translate(0.5), new Vector3(entityItem), TileEntityTesla.dyeColors[dyeID]);
}
@ -329,6 +333,8 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements IPacke
entityItem.motionX = Math.max(-MAX_SPEED, entityItem.motionX - ACCELERATION);
}
break;
default:
break;
}
@ -360,6 +366,8 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements IPacke
case EAST:
item = new EntityItem(worldObj, xCoord + 1.2, yCoord + 0.5, zCoord + 0.5, toSend);
break;
default:
break;
}
item.motionX = 0;
@ -408,6 +416,8 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements IPacke
operationBounds = AxisAlignedBB.getBoundingBox(xCoord + 1, yCoord, zCoord, xCoord + 1 + MAX_REACH, yCoord + 1, zCoord + 1);
suckBounds = AxisAlignedBB.getBoundingBox(xCoord + 1, yCoord, zCoord, xCoord + 1.1, yCoord + 1, zCoord + 1);
break;
default:
break;
}
}