Made EM Contractor render straight beams, less lag
This commit is contained in:
parent
3e2a5bd268
commit
ceca58d5f9
4 changed files with 50 additions and 41 deletions
|
@ -90,11 +90,11 @@ public class ClientProxy extends CommonProxy
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderElectricShock(World world, Vector3 start, Vector3 target, float r, float g, float b)
|
||||
public void renderElectricShock(World world, Vector3 start, Vector3 target, float r, float g, float b, boolean split)
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new FXElectricBolt(world, start, target).setColor(r, g, b));
|
||||
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new FXElectricBolt(world, start, target, split).setColor(r, g, b));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,16 +52,26 @@ public class CommonProxy implements IGuiHandler
|
|||
return false;
|
||||
}
|
||||
|
||||
public void renderElectricShock(World world, Vector3 start, Vector3 target, float r, float g, float b)
|
||||
public void renderElectricShock(World world, Vector3 start, Vector3 target, float r, float g, float b, boolean split)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void renderElectricShock(World world, Vector3 start, Vector3 target, float r, float g, float b)
|
||||
{
|
||||
this.renderElectricShock(world, start, target, r, g, b, true);
|
||||
}
|
||||
|
||||
public void renderElectricShock(World world, Vector3 start, Vector3 target, Vector3 color)
|
||||
{
|
||||
this.renderElectricShock(world, start, target, (float) color.x, (float) color.y, (float) color.z);
|
||||
}
|
||||
|
||||
public void renderElectricShock(World world, Vector3 start, Vector3 target, Vector3 color, boolean split)
|
||||
{
|
||||
this.renderElectricShock(world, start, target, (float) color.x, (float) color.y, (float) color.z, split);
|
||||
}
|
||||
|
||||
public void renderElectricShock(World world, Vector3 start, Vector3 target)
|
||||
{
|
||||
renderElectricShock(world, start, target, 0.55f, 0.7f, 1f);
|
||||
|
@ -71,4 +81,5 @@ public class CommonProxy implements IGuiHandler
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -138,8 +138,8 @@ 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;
|
||||
final int renderFrequency = ResonantInduction.proxy.isFancy() ? 1 + this.worldObj.rand.nextInt(2) : 10 + this.worldObj.rand.nextInt(2);
|
||||
final boolean renderBeam = this.ticks % renderFrequency == 0 && this.linked != null && !this.linked.isInvalid() && this.linked.suck != this.suck;
|
||||
|
||||
if (!this.suck)
|
||||
{
|
||||
|
@ -147,21 +147,17 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements IPacke
|
|||
{
|
||||
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]);
|
||||
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], false);
|
||||
}
|
||||
|
||||
if (this.pathfinder != null)
|
||||
{
|
||||
Vector3 lastTurn = null;
|
||||
ForgeDirection lastDirection = null;
|
||||
|
||||
for (int i = 0; i < this.pathfinder.results.size(); i++)
|
||||
{
|
||||
Vector3 result = this.pathfinder.results.get(i).clone();
|
||||
|
||||
if (TileEntityEMContractor.canBePath(this.worldObj, result))
|
||||
{
|
||||
// TODO: RENDER BEAMS ONLY ON CHANGE. SAVE CALCULATIONS!
|
||||
if (i - 1 >= 0)
|
||||
{
|
||||
Vector3 prevResult = this.pathfinder.results.get(i - 1).clone();
|
||||
|
@ -171,13 +167,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements IPacke
|
|||
|
||||
if (renderBeam)
|
||||
{
|
||||
ResonantInduction.proxy.renderElectricShock(this.worldObj, prevResult.clone().translate(0.5), result.clone().translate(0.5), TileEntityTesla.dyeColors[dyeID]);
|
||||
}
|
||||
|
||||
if (lastTurn == null || direction != lastDirection)
|
||||
{
|
||||
lastTurn = result;
|
||||
lastDirection = direction;
|
||||
ResonantInduction.proxy.renderElectricShock(this.worldObj, prevResult.clone().translate(0.5), result.clone().translate(0.5), TileEntityTesla.dyeColors[dyeID], false);
|
||||
}
|
||||
|
||||
AxisAlignedBB bounds = AxisAlignedBB.getAABBPool().getAABB(result.x, result.y, result.z, result.x + 1, result.y + 1, result.z + 1);
|
||||
|
@ -203,7 +193,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements IPacke
|
|||
{
|
||||
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]);
|
||||
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], false);
|
||||
}
|
||||
|
||||
this.pathfinder = null;
|
||||
|
@ -214,7 +204,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements IPacke
|
|||
{
|
||||
if (renderBeam)
|
||||
{
|
||||
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(this).translate(0.5), new Vector3(entityItem), TileEntityTesla.dyeColors[dyeID]);
|
||||
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(this).translate(0.5), new Vector3(entityItem), TileEntityTesla.dyeColors[dyeID], false);
|
||||
}
|
||||
|
||||
this.moveEntity(entityItem, this.getDirection(), new Vector3(this));
|
||||
|
|
|
@ -60,7 +60,7 @@ public class FXElectricBolt extends EntityFX
|
|||
private int maxSplitID;
|
||||
private Random rand;
|
||||
|
||||
public FXElectricBolt(World world, Vector3 startVec, Vector3 targetVec)
|
||||
public FXElectricBolt(World world, Vector3 startVec, Vector3 targetVec, boolean doSplits)
|
||||
{
|
||||
super(world, startVec.x, startVec.y, startVec.z);
|
||||
|
||||
|
@ -79,16 +79,24 @@ public class FXElectricBolt extends EntityFX
|
|||
this.complexity = 2f;
|
||||
this.boltWidth = 0.05f;
|
||||
this.boltLength = this.start.distance(this.end);
|
||||
this.setUp();
|
||||
this.setUp(doSplits);
|
||||
}
|
||||
|
||||
public FXElectricBolt(World world, Vector3 startVec, Vector3 targetVec)
|
||||
{
|
||||
this(world, startVec, targetVec, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate all required segments of the entire bolt.
|
||||
*/
|
||||
private void setUp()
|
||||
private void setUp(boolean doSplits)
|
||||
{
|
||||
this.segments.add(new BoltSegment(this.start, this.end));
|
||||
this.recalculate();
|
||||
|
||||
if (doSplits)
|
||||
{
|
||||
double offsetRatio = this.boltLength * this.complexity;
|
||||
this.split(2, offsetRatio / 10, 0.7f, 0.1f, 20 / 2);
|
||||
this.split(2, offsetRatio / 15, 0.5f, 0.1f, 25 / 2);
|
||||
|
@ -96,7 +104,6 @@ public class FXElectricBolt extends EntityFX
|
|||
this.split(2, offsetRatio / 38, 0.5f, 0.1f, 30 / 2);
|
||||
this.split(2, offsetRatio / 55, 0, 0, 0);
|
||||
this.split(2, offsetRatio / 70, 0, 0, 0);
|
||||
|
||||
this.recalculate();
|
||||
|
||||
Collections.sort(this.segments, new Comparator()
|
||||
|
@ -113,6 +120,7 @@ public class FXElectricBolt extends EntityFX
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public FXElectricBolt setColor(float r, float g, float b)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue