From fcbd4cad4332663ceaa06c0d9c634ec013c38947 Mon Sep 17 00:00:00 2001 From: Calclavia Date: Thu, 1 Aug 2013 23:55:07 -0400 Subject: [PATCH] Aidan, go merge again :) --- src/resonantinduction/CommonProxy.java | 4 ++++ src/resonantinduction/fx/FXElectricBolt.java | 11 +++++++---- src/resonantinduction/tesla/TileEntityTesla.java | 3 ++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/resonantinduction/CommonProxy.java b/src/resonantinduction/CommonProxy.java index 26d4a010f..d1f81579f 100644 --- a/src/resonantinduction/CommonProxy.java +++ b/src/resonantinduction/CommonProxy.java @@ -36,4 +36,8 @@ public class CommonProxy implements IGuiHandler } + public void renderElectricShock(World world, Vector3 start, Vector3 target) + { + renderElectricShock(world, start, target, 0.55f, 0.7f, 1f); + } } diff --git a/src/resonantinduction/fx/FXElectricBolt.java b/src/resonantinduction/fx/FXElectricBolt.java index f48a612dc..177a312cc 100644 --- a/src/resonantinduction/fx/FXElectricBolt.java +++ b/src/resonantinduction/fx/FXElectricBolt.java @@ -4,6 +4,7 @@ package resonantinduction.fx; import java.util.HashSet; +import java.util.Random; import java.util.Set; import net.minecraft.client.Minecraft; @@ -40,6 +41,8 @@ public class FXElectricBolt extends EntityFX private double boltLength; private int segmentCount; + private Random random; + private Set segments = new HashSet(); public FXElectricBolt(World world, Vector3 start, Vector3 target) @@ -47,9 +50,9 @@ public class FXElectricBolt extends EntityFX super(world, start.x, start.y, start.z); this.start = new BoltPoint(target); this.target = new BoltPoint(target); - + this.particleAge = (3 + this.rand.nextInt(3) - 1); + this.random = new Random(); this.boltLength = start.distance(target); - this.setUp(); } @@ -85,7 +88,7 @@ public class FXElectricBolt extends EntityFX for (int i = 1; i < splitAmount; i++) { - Vector3 newOffset = segment.getDifference().getPerpendicular(); + Vector3 newOffset = segment.getDifference().getPerpendicular().rotate(random.nextFloat() * 360, segment.getDifference()).scale((this.random.nextFloat() / 2) * offset); } } } @@ -119,7 +122,7 @@ public class FXElectricBolt extends EntityFX GL11.glEnable(3042); Vector3 playerVector = new Vector3(sinYaw * -cosPitch, -cosSinPitch / cosYaw, cosYaw * cosPitch); - int renderLength = (int) (this.particleAge + partialFrame + this.boltLength * 3) / (int) (this.boltLength * 3) * this.segmentCount; + int renderLength = (int) ((this.particleAge + partialFrame + this.boltLength * 3) / (this.boltLength * 3 * this.segmentCount)); for (BoltSegment segment : this.segments) { diff --git a/src/resonantinduction/tesla/TileEntityTesla.java b/src/resonantinduction/tesla/TileEntityTesla.java index 1e167e224..7ad1303a7 100644 --- a/src/resonantinduction/tesla/TileEntityTesla.java +++ b/src/resonantinduction/tesla/TileEntityTesla.java @@ -40,7 +40,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla for (ITesla tesla : TeslaGrid.instance().get()) { - if (new Vector3((TileEntity) tesla).distance(new Vector3(this)) < this.getRange()) + if (tesla != this && new Vector3((TileEntity) tesla).distance(new Vector3(this)) < this.getRange()) { transferTeslaCoils.add(tesla); } @@ -53,6 +53,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla for (ITesla tesla : transferTeslaCoils) { tesla.transfer(transferEnergy * (1 - (this.worldObj.rand.nextFloat() * 0.1f))); + ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(this), new Vector3((TileEntity) tesla)); this.transfer(-transferEnergy); } }