Fixed electrical shock render not showing up sometimes

This commit is contained in:
Calclavia 2013-08-07 22:14:08 -04:00
parent c083670b55
commit 0fd548153f
3 changed files with 50 additions and 44 deletions

@ -1 +1 @@
Subproject commit b3efc76d869dc6d9a104c9338cc1cf8c32e307b8
Subproject commit 96bd0b818bfaacd0d82a335e297297bedd835b67

View file

@ -142,7 +142,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements IPacke
{
if (this.linked != null && !this.linked.isInvalid())
{
if (this.ticks % (2 + this.worldObj.rand.nextInt(2)) == 0)
if (this.ticks % (1 + this.worldObj.rand.nextInt(2)) == 0)
{
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]);
}
@ -165,7 +165,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements IPacke
Vector3 difference = prevResult.clone().difference(result);
final ForgeDirection direction = difference.toForgeDirection();
if (this.ticks % (2 + this.worldObj.rand.nextInt(2)) == 0)
if (this.ticks % (1 + this.worldObj.rand.nextInt(2)) == 0)
{
ResonantInduction.proxy.renderElectricShock(this.worldObj, prevResult.clone().translate(0.5), result.clone().translate(0.5), TileEntityTesla.dyeColors[dyeID]);
}

View file

@ -159,7 +159,7 @@ public class FXElectricBolt extends EntityFX
*/
for (int i = 1; i < splitAmount; i++)
{
Vector3 newOffset = segment.difference.getPerpendicular().rotate(this.rand.nextFloat() * 360, segment.difference).clone().scale((this.rand.nextFloat() - 0.5F) * offset);
Vector3 newOffset = segment.difference.getPerpendicular().rotate(this.rand.nextFloat() * 360, segment.difference).scale((this.rand.nextFloat() - 0.5F) * offset);
Vector3 basePoint = startPoint.clone().translate(subSegment.clone().scale(i));
newPoints[i] = new BoltPoint(basePoint, newOffset);
@ -178,7 +178,7 @@ public class FXElectricBolt extends EntityFX
if ((i != 0) && (this.rand.nextFloat() < splitChance))
{
Vector3 splitrot = next.difference.xCrossProduct().rotate(this.rand.nextFloat() * 360, next.difference);
Vector3 diff = next.difference.clone().rotate((this.rand.nextFloat() * 0.66F + 0.33F) * splitAngle, splitrot).clone().scale(splitLength);
Vector3 diff = next.difference.clone().rotate((this.rand.nextFloat() * 0.66F + 0.33F) * splitAngle, splitrot).scale(splitLength);
this.maxSplitID += 1;
this.parentIDMap.put(this.maxSplitID, next.splitID);
BoltSegment split = new BoltSegment(newPoints[i], new BoltPoint(newPoints[(i + 1)].base, newPoints[(i + 1)].offset.clone().translate(diff)), segment.alpha / 2f, next.id, this.maxSplitID);
@ -303,8 +303,12 @@ public class FXElectricBolt extends EntityFX
if (segment != null && segment.id <= renderlength)
{
double renderWidth = this.boltWidth * ((new Vector3(player).distance(segment.start) / 5f + 1f) * (1 + segment.alpha) * 0.5f);
Vector3 diffPrev = playerVector.clone().crossProduct(segment.prevDiff).scale(renderWidth / segment.sinPrev);
Vector3 diffNext = playerVector.clone().crossProduct(segment.nextDiff).scale(renderWidth / segment.sinNext);
renderWidth = Math.min(this.boltWidth, Math.max(renderWidth, 0));
if (segment.difference.getMagnitude() > 0 && segment.difference.getMagnitude() != Double.NaN && segment.difference.getMagnitude() != Double.POSITIVE_INFINITY && renderWidth > 0 && renderWidth != Double.NaN && renderWidth != Double.POSITIVE_INFINITY)
{
Vector3 diffPrev = playerVector.crossProduct(segment.prevDiff).scale(renderWidth / segment.sinPrev);
Vector3 diffNext = playerVector.crossProduct(segment.nextDiff).scale(renderWidth / segment.sinNext);
Vector3 startVec = segment.start;
Vector3 endVec = segment.end;
float rx1 = (float) (startVec.x - interpPosX);
@ -323,6 +327,7 @@ public class FXElectricBolt extends EntityFX
/**
* Render the bolts balls.
*/
if (segment.next == null)
{
Vector3 roundEnd = segment.end.clone().translate(segment.difference.clone().normalize().scale(renderWidth));
@ -348,6 +353,7 @@ public class FXElectricBolt extends EntityFX
}
}
}
}
tessellator.draw();
@ -419,7 +425,7 @@ public class FXElectricBolt extends EntityFX
Vector3 prevDiffNorm = this.prev.difference.clone().normalize();
Vector3 diffNorm = this.difference.clone().normalize();
this.prevDiff = diffNorm.clone().translate(prevDiffNorm).normalize();
this.sinPrev = Math.sin(diffNorm.clone().anglePreNorm(prevDiffNorm.clone().scale(-1)) / 2);
this.sinPrev = Math.sin(diffNorm.anglePreNorm(prevDiffNorm.clone().scale(-1)) / 2);
}
else
{
@ -432,7 +438,7 @@ public class FXElectricBolt extends EntityFX
Vector3 nextDiffNorm = this.next.difference.clone().normalize();
Vector3 diffNorm = this.difference.clone().normalize();
this.nextDiff = diffNorm.clone().translate(nextDiffNorm).normalize();
this.sinNext = Math.sin(diffNorm.clone().anglePreNorm(nextDiffNorm.clone().scale(-1)) / 2);
this.sinNext = Math.sin(diffNorm.anglePreNorm(nextDiffNorm.clone().scale(-1)) / 2);
}
else
{