From 3e2a5bd268d21be8d386536a31549778a5ba34cf Mon Sep 17 00:00:00 2001 From: Calclavia Date: Wed, 7 Aug 2013 22:22:58 -0400 Subject: [PATCH] Added less draw calls for fast graphics --- src/resonantinduction/ClientProxy.java | 6 ++++++ src/resonantinduction/CommonProxy.java | 5 +++++ .../contractor/BlockEMContractor.java | 1 + .../contractor/TileEntityEMContractor.java | 18 ++++++++++++++---- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/resonantinduction/ClientProxy.java b/src/resonantinduction/ClientProxy.java index 5d412936..996aab0d 100644 --- a/src/resonantinduction/ClientProxy.java +++ b/src/resonantinduction/ClientProxy.java @@ -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) { diff --git a/src/resonantinduction/CommonProxy.java b/src/resonantinduction/CommonProxy.java index f4222e15..073f8831 100644 --- a/src/resonantinduction/CommonProxy.java +++ b/src/resonantinduction/CommonProxy.java @@ -66,4 +66,9 @@ public class CommonProxy implements IGuiHandler { renderElectricShock(world, start, target, 0.55f, 0.7f, 1f); } + + public boolean isFancy() + { + return false; + } } diff --git a/src/resonantinduction/contractor/BlockEMContractor.java b/src/resonantinduction/contractor/BlockEMContractor.java index d92a5714..a4f1cd1b 100644 --- a/src/resonantinduction/contractor/BlockEMContractor.java +++ b/src/resonantinduction/contractor/BlockEMContractor.java @@ -80,6 +80,7 @@ public class BlockEMContractor extends BlockBase implements ITileEntityProvider else { contractor.suck = !contractor.suck; + contractor.updatePath(); } return true; diff --git a/src/resonantinduction/contractor/TileEntityEMContractor.java b/src/resonantinduction/contractor/TileEntityEMContractor.java index c01fd646..b7935694 100644 --- a/src/resonantinduction/contractor/TileEntityEMContractor.java +++ b/src/resonantinduction/contractor/TileEntityEMContractor.java @@ -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) 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; } }