From 834ecd4ee56180cedd5fdcf0b1fe976737063660 Mon Sep 17 00:00:00 2001 From: Calclavia Date: Fri, 2 Aug 2013 22:55:29 -0400 Subject: [PATCH] Made eletric shock semi-working --- .../textures/models/fadedSphere.png | Bin 3066 -> 3416 bytes src/resonantinduction/ClientProxy.java | 7 +- src/resonantinduction/base/Vector3.java | 2 +- src/resonantinduction/fx/FXElectricBolt.java | 300 ++++++++++-------- .../tesla/TileEntityTesla.java | 19 +- 5 files changed, 183 insertions(+), 145 deletions(-) diff --git a/resources/assets/resonantinduction/textures/models/fadedSphere.png b/resources/assets/resonantinduction/textures/models/fadedSphere.png index c1a45319d30da4dcee1972cff72b866cc6a8149e..f2f38796ddbbfd7171ad967d9246a6427a56d2dd 100755 GIT binary patch delta 734 zcmV<40wMkS7uXs$iBL{Q4GJ0x0000DNk~Le0000T0000T2nGNE09KP{4*&oF32;bR za{vGjU;qFQU;%n~MUAmGi3)!LgGod|RCwB~m+6k%Fbsspj%@Fd-JtLPlx;UY zXWPTZfSU{6S zS@;|}@pp~w;~EyFZPP8M2i)nZ3x;B_WvO?LR(5MuZC6TlA> zR>uf!CZN`!Qu0FRz;TVBwPhY(K=k-XxV#l~G(lzpb;Jf!yN*zO4ceGsqW2P&paQyA zt*QJfwBCWIkOGyRbd(x;RV*9Dlz9P@rI6q&yRPk7WzP<#cG!P}dt;Xj!$%htQ(o(TDi3)!KB}qg}6)ooVlzEA#kxgkV+PMn}I4>~8(jX(#SfLiBZ z0UWRbo`7fVE8t%GGtdB)Kr7ut1X#*xBUuBFKqh?;9D&?`&cMlwMWKJl8{h-j0xxm^ zXn}+35*dxa7z>t*!5Vl6zJNESf#~MSdk|m)G!Y;(HFy=1Pu)?@L5@dYFQ3$_Rf!~1 zq(aVH)1^wf%-ApPxN&(^bCmR=Su3KAUQ5>-``N1~z3KB_RGk57fFJ4N4D`U@O;ux# zshry@ZTtpyvTY;4BzirG8Il1guME;oOiKAoaS}U2_bl|kM!D49*}o8E5DQxW_cOU$ bzw_?^ts8V}hg$%M00000NkvXXu0mjf^-P|v diff --git a/src/resonantinduction/ClientProxy.java b/src/resonantinduction/ClientProxy.java index d64c83ecb..7b00ea1bb 100644 --- a/src/resonantinduction/ClientProxy.java +++ b/src/resonantinduction/ClientProxy.java @@ -3,7 +3,6 @@ */ package resonantinduction; -import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import resonantinduction.base.Vector3; @@ -11,6 +10,7 @@ import resonantinduction.fx.FXElectricBolt; import resonantinduction.render.BlockRenderingHandler; import resonantinduction.render.RenderTesla; import resonantinduction.tesla.TileEntityTesla; +import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.relauncher.Side; @@ -39,6 +39,9 @@ public class ClientProxy extends CommonProxy @Override public void renderElectricShock(World world, Vector3 start, Vector3 target, float r, float g, float b) { - Minecraft.getMinecraft().effectRenderer.addEffect(new FXElectricBolt(world, start, target).setColor(r, g, b)); + if (world.isRemote) + { + FMLClientHandler.instance().getClient().effectRenderer.addEffect(new FXElectricBolt(world, start, target).setColor(r, g, b)); + } } } diff --git a/src/resonantinduction/base/Vector3.java b/src/resonantinduction/base/Vector3.java index f1af51e85..324ca9da7 100644 --- a/src/resonantinduction/base/Vector3.java +++ b/src/resonantinduction/base/Vector3.java @@ -59,7 +59,7 @@ public class Vector3 public Vector3 difference(Vector3 compare) { - return new Vector3(compare.x - this.x, compare.y - this.y, compare.z - this.z); + return new Vector3(this.x - compare.x, this.y - compare.y, this.z - compare.z); } public double getMagnitudeSquared() diff --git a/src/resonantinduction/fx/FXElectricBolt.java b/src/resonantinduction/fx/FXElectricBolt.java index 969e6f5c5..b88a5a6c1 100644 --- a/src/resonantinduction/fx/FXElectricBolt.java +++ b/src/resonantinduction/fx/FXElectricBolt.java @@ -1,6 +1,3 @@ -/** - * - */ package resonantinduction.fx; import java.util.ArrayList; @@ -36,34 +33,76 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class FXElectricBolt extends EntityFX { - public static final ResourceLocation FADED_SPHERE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "fadedSphere.png"); + public static final ResourceLocation TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "fadedSphere.png"); public static final ResourceLocation PARTICLE_RESOURCE = new ResourceLocation("textures/particle/particles.png"); - /** Width of the bolt. */ - private final float boltWidth = 0.05f; - private final float complexity = 2; + /** The width of the electrical bolt. */ + private float boltWidth; + /** The maximum length of the bolt */ + public double boltLength; + /** Electric Bolt's start and end positions; */ private BoltPoint start; - private BoltPoint target; - private double boltLength; - private int segmentCount; - private int maxSplitID; - /** Random value, can use seed for the same bolt look */ - private Random random; + private BoltPoint end; /** An array of the segments of the bolt. */ private List segments = new ArrayList(); private final Map parentIDMap = new HashMap(); + /** Determines how complex the bolt is. */ + public float complexity; + public int segmentCount; + private int maxSplitID; + private Random rand; - public FXElectricBolt(World world, Vector3 start, Vector3 target) + public FXElectricBolt(World world, Vector3 startVec, Vector3 targetVec) { - super(world, start.x, start.y, start.z); - this.start = new BoltPoint(target); - this.target = new BoltPoint(target); + super(world, startVec.x, startVec.y, startVec.z); + + this.rand = new Random(); + this.start = new BoltPoint(startVec); + this.end = new BoltPoint(targetVec); + + /** By default, we do an electrical color */ + this.setColor(0.5f + (this.rand.nextFloat() * 0.1f), 0.6f + (this.rand.nextFloat() * 0.1f), 1); + this.segmentCount = 1; this.particleAge = (3 + this.rand.nextInt(3) - 1); - this.random = new Random(); - this.boltLength = start.distance(target); + this.particleMaxAge = (3 + this.rand.nextInt(3) - 1); + this.complexity = 2f; + this.boltWidth = 0.05f; + this.boltLength = this.start.distance(this.end); this.setUp(); } + /** + * Calculate all required segments of the entire bolt. + */ + private void setUp() + { + this.segments.add(new BoltSegment(this.start, this.end)); + this.recalculate(); + double offsetRatio = this.boltLength * this.complexity; + this.split(2, offsetRatio / 2, 0.7f, 0.1F, 20); + this.split(2, offsetRatio / 3, 0.5f, 0.1F, 25); + this.split(2, offsetRatio / 6, 0.5f, 0.1F, 55f / 2); + this.split(2, offsetRatio / 8, 0.5f, 0.1F, 60f / 2); + this.split(2, offsetRatio / 12, 0, 0.0F, 0.0F); + this.split(2, offsetRatio / 16, 0, 0.0F, 0.0F); + + this.recalculate(); + + Collections.sort(this.segments, new Comparator() + { + public int compare(BoltSegment bolt1, BoltSegment bolt2) + { + return Float.compare(bolt2.alpha, bolt1.alpha); + } + + @Override + public int compare(Object obj1, Object obj2) + { + return compare((BoltSegment) obj1, (BoltSegment) obj2); + } + }); + } + public FXElectricBolt setColor(float r, float g, float b) { this.particleRed = r; @@ -72,61 +111,50 @@ public class FXElectricBolt extends EntityFX return this; } - public void setUp() + /** + * Slits a large segment into multiple smaller ones. + * + * @param splitAmount - The amount of splits + * @param offset - The multiplier scale for the offset. + * @param splitChance - The chance of creating a split. + * @param splitLength - The length of each split. + * @param splitAngle - The angle of the split. + */ + public void split(int splitAmount, double offset, float splitChance, float splitLength, float splitAngle) { - this.segments.add(new BoltSegment(this.start, this.target)); - this.recalculate(); - double offsetRatio = this.boltLength * this.complexity; - this.split(offsetRatio / 8, 0.1f, 45); - - /* - * this.split(offsetRatio / 12, 0.1f, 90); this.split(offsetRatio / 18, 0.1f, 90); - * this.split(offsetRatio / 18, 0.1f, 90); - */ - - /** - * Finish up calculations - */ - this.recalculate(); - Collections.sort(this.segments, new Comparator() - { - public int compare(BoltSegment bolt1, BoltSegment bolt2) - { - return Float.compare(bolt2.alpha, bolt1.alpha); - } - - @Override - public int compare(Object obj, Object obj1) - { - return compare((BoltSegment) obj, (BoltSegment) obj1); - } - }); - } - - public void split(double offset, float length, float angle) - { - int splitAmount = 2; + /** Temporarily store old segments in a new array */ List oldSegments = this.segments; - this.segments = new ArrayList(); - + this.segments = new ArrayList(); + /** Previous segment */ BoltSegment prev = null; for (BoltSegment segment : oldSegments) { - Vector3 subSegment = segment.getDifference().scale(1 / splitAmount); + prev = segment.prev; + /** Length of each subsegment */ + Vector3 subSegment = segment.difference.clone().scale(1.0F / splitAmount); + /** + * Creates an array of new bolt points. The first and last points of the bolts are the + * respected start and end points of the current segment. + */ BoltPoint[] newPoints = new BoltPoint[splitAmount + 1]; + Vector3 startPoint = segment.start; newPoints[0] = segment.start; newPoints[splitAmount] = segment.end; + /** + * Create bolt points. + */ for (int i = 1; i < splitAmount; i++) { - Vector3 newOffset = segment.getDifference().getPerpendicular().rotate(random.nextFloat() * 360, segment.getDifference()).scale((this.random.nextFloat() / 2) * offset); - Vector3 basePoint = newPoints[0].clone().translate(subSegment.clone().scale(i)); + Vector3 newOffset = segment.difference.getPerpendicular().rotate((float) (this.rand.nextFloat() * 90), segment.difference).scale((this.rand.nextFloat() - 0.5F) * offset); + Vector3 basePoint = startPoint.clone().translate(subSegment.clone().scale(i)); + newPoints[i] = new BoltPoint(basePoint, newOffset); } - for (int i = 1; i < splitAmount; i++) + for (int i = 0; i < splitAmount; i++) { BoltSegment next = new BoltSegment(newPoints[i], newPoints[(i + 1)], segment.alpha, segment.id * splitAmount + i, segment.splitID); next.prev = prev; @@ -136,14 +164,16 @@ public class FXElectricBolt extends EntityFX prev.next = next; } - Vector3 splitrot = next.difference.xCrossProduct().rotate(this.rand.nextFloat() * 360.0F, next.difference); - Vector3 diff = next.difference.clone().rotate((this.rand.nextFloat() * 0.66F + 0.33F) * angle, splitrot).scale(length); - this.parentIDMap.put(this.maxSplitID, next.splitID); - // Loose transparency per split. - 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); - split.prev = prev; - this.maxSplitID++; - this.segments.add(split); + if ((i != 0) && (this.rand.nextFloat() < splitChance)) + { + Vector3 splitrot = next.difference.xCrossProduct().rotate(this.rand.nextFloat() * 360.0F, next.difference); + 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); + split.prev = prev; + this.segments.add(split); + } prev = next; this.segments.add(next); @@ -151,9 +181,12 @@ public class FXElectricBolt extends EntityFX if (segment.next != null) { - segment.next = prev; + segment.next.prev = prev; } } + + this.segmentCount *= splitAmount; + } private void recalculate() @@ -188,7 +221,7 @@ public class FXElectricBolt extends EntityFX { lastActiveSegment.put(lastSplitCalc, lastActiveSeg); lastSplitCalc = segment.splitID; - lastActiveSeg = lastActiveSegment.get(this.parentIDMap.get(segment.splitID)).intValue(); + lastActiveSeg = ((Integer) lastActiveSegment.get(this.parentIDMap.get(segment.splitID))).intValue(); } lastActiveSeg = segment.id; @@ -196,7 +229,7 @@ public class FXElectricBolt extends EntityFX lastActiveSegment.put(lastSplitCalc, lastActiveSeg); lastSplitCalc = 0; - lastActiveSeg = lastActiveSegment.get(0).intValue(); + lastActiveSeg = ((Integer) lastActiveSegment.get(0)).intValue(); BoltSegment segment; for (Iterator iterator = this.segments.iterator(); iterator.hasNext(); segment.recalculate()) @@ -230,97 +263,89 @@ public class FXElectricBolt extends EntityFX } @Override - public void renderParticle(Tessellator tessellator, float partialFrame, float cosYaw, float cosPitch, float sinYaw, float sinSinPitch, float cosSinPitch) + public void renderParticle(Tessellator tessellator, float partialframe, float cosYaw, float cosPitch, float sinYaw, float sinSinPitch, float cosSinPitch) { EntityPlayer player = Minecraft.getMinecraft().thePlayer; tessellator.draw(); - - /** - * Do rendering here. - */ GL11.glPushMatrix(); - GL11.glDepthMask(true); + + GL11.glDepthMask(false); GL11.glEnable(3042); - FMLClientHandler.instance().getClient().renderEngine.func_110577_a(FADED_SPHERE); + FMLClientHandler.instance().getClient().renderEngine.func_110577_a(TEXTURE); + /** + * Render the actual bolts. + */ tessellator.startDrawingQuads(); tessellator.setBrightness(15728880); - Vector3 playerVector = new Vector3(sinYaw * -cosPitch, -cosSinPitch / cosYaw, cosYaw * cosPitch); + float voltage = this.particleAge >= 0 ? ((float) this.particleAge / (float) this.particleMaxAge) : 0.0F; + + int renderlength = (int) ((this.particleAge + partialframe + (int) (this.boltLength * 3.0F)) / (int) (this.boltLength * 3.0F) * this.segmentCount); for (BoltSegment segment : this.segments) { - if (segment != null) + if (segment != null && segment.id <= renderlength) { - double renderWidth = this.boltWidth * ((new Vector3(player).distance(segment.start) / 5 + 1) * (1.0F + segment.alpha) * 0.5f); - Vector3 prevDiff = playerVector.crossProduct(segment.prevDiff).scale(renderWidth / segment.sinPrev); - Vector3 nextDiff = playerVector.crossProduct(segment.nextDiff).scale(renderWidth / segment.sinNext); + double renderWidth = this.boltWidth * ((new Vector3(player).distance(segment.start) / 5f + 1f) * (1 + segment.alpha) * 0.5f); + renderWidth = Math.min(this.boltWidth, Math.max(renderWidth, 0)); - Vector3 renderStart = segment.start; - Vector3 renderEnd = segment.end; - - float rxStart = (float) (renderStart.x - interpPosX); - float ryStart = (float) (renderStart.y - interpPosY); - float rzStart = (float) (renderStart.z - interpPosZ); - float rxEnd = (float) (renderEnd.x - interpPosX); - float ryEnd = (float) (renderEnd.y - interpPosY); - float rzEnd = (float) (renderEnd.z - interpPosZ); - - /* - * TODO: segment . alpha - */ - tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, 1); - -// System.out.println("SHOCK" + this.particleBlue); - - tessellator.addVertexWithUV(rxEnd - nextDiff.x, ryEnd - nextDiff.y, rzEnd - nextDiff.z, 0.5D, 0.0D); - tessellator.addVertexWithUV(rxStart - prevDiff.x, ryStart - prevDiff.y, rzStart - prevDiff.z, 0.5D, 0.0D); - tessellator.addVertexWithUV(rxStart + prevDiff.x, ryStart + prevDiff.y, rzStart + prevDiff.z, 0.5D, 1.0D); - tessellator.addVertexWithUV(rxEnd + nextDiff.x, ryEnd + nextDiff.y, rzEnd + nextDiff.z, 0.5D, 1.0D); - - /** - * Renders the bolt "ball". - */ - if (segment.prev == null) + 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 roundend = segment.start.clone().difference(segment.difference.clone().normalize().scale(renderWidth)); - float rx3 = (float) (roundend.x - interpPosX); - float ry3 = (float) (roundend.y - interpPosY); - float rz3 = (float) (roundend.z - interpPosZ); - tessellator.addVertexWithUV(rxStart - prevDiff.x, ryStart - prevDiff.y, rzStart - prevDiff.z, 0.5D, 0.0D); - tessellator.addVertexWithUV(rx3 - prevDiff.x, ry3 - prevDiff.y, rz3 - prevDiff.z, 0.0D, 0.0D); - tessellator.addVertexWithUV(rx3 + prevDiff.x, ry3 + prevDiff.y, rz3 + prevDiff.z, 0.0D, 1.0D); - tessellator.addVertexWithUV(rxStart + prevDiff.x, ryStart + prevDiff.y, rzStart + prevDiff.z, 0.5D, 1.0D); - } + 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); + float ry1 = (float) (startVec.y - interpPosY); + float rz1 = (float) (startVec.z - interpPosZ); + float rx2 = (float) (endVec.x - interpPosX); + float ry2 = (float) (endVec.y - interpPosY); + float rz2 = (float) (endVec.z - interpPosZ); - if (segment.next == null) - { - Vector3 roundend = segment.end.clone().translate(segment.difference.clone().normalize().scale(renderWidth)); - float rx3 = (float) (roundend.x - interpPosX); - float ry3 = (float) (roundend.y - interpPosY); - float rz3 = (float) (roundend.z - interpPosZ); - tessellator.addVertexWithUV(rx3 - nextDiff.x, ry3 - nextDiff.y, rz3 - nextDiff.z, 0.0D, 0.0D); - tessellator.addVertexWithUV(rxEnd - nextDiff.x, ryEnd - nextDiff.y, rzEnd - nextDiff.z, 0.5D, 0.0D); - tessellator.addVertexWithUV(rxEnd + nextDiff.x, ryEnd + nextDiff.y, rzEnd + nextDiff.z, 0.5D, 1.0D); - tessellator.addVertexWithUV(rx3 + nextDiff.x, ry3 + nextDiff.y, rz3 + nextDiff.z, 0.0D, 1.0D); + tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, (1.0F - voltage * 0.5f) * segment.alpha); + tessellator.addVertexWithUV(rx2 - diffNext.x, ry2 - diffNext.y, rz2 - diffNext.z, 0.5D, 0.0D); + tessellator.addVertexWithUV(rx1 - diffPrev.x, ry1 - diffPrev.y, rz1 - diffPrev.z, 0.5D, 0.0D); + tessellator.addVertexWithUV(rx1 + diffPrev.x, ry1 + diffPrev.y, rz1 + diffPrev.z, 0.5D, 1.0D); + tessellator.addVertexWithUV(rx2 + diffNext.x, ry2 + diffNext.y, rz2 + diffNext.z, 0.5D, 1.0D); + + if (segment.next == null) + { + Vector3 roundEnd = segment.end.clone().translate(segment.difference.clone().normalize().scale(renderWidth)); + float rx3 = (float) (roundEnd.x - interpPosX); + float ry3 = (float) (roundEnd.y - interpPosY); + float rz3 = (float) (roundEnd.z - interpPosZ); + tessellator.addVertexWithUV(rx3 - diffNext.x, ry3 - diffNext.y, rz3 - diffNext.z, 0.0D, 0.0D); + tessellator.addVertexWithUV(rx2 - diffNext.x, ry2 - diffNext.y, rz2 - diffNext.z, 0.5D, 0.0D); + tessellator.addVertexWithUV(rx2 + diffNext.x, ry2 + diffNext.y, rz2 + diffNext.z, 0.5D, 1.0D); + tessellator.addVertexWithUV(rx3 + diffNext.x, ry3 + diffNext.y, rz3 + diffNext.z, 0.0D, 1.0D); + } + + if (segment.prev == null) + { + Vector3 roundEnd = segment.start.clone().difference(segment.difference.clone().normalize().scale(renderWidth)); + float rx3 = (float) (roundEnd.x - interpPosX); + float ry3 = (float) (roundEnd.y - interpPosY); + float rz3 = (float) (roundEnd.z - interpPosZ); + tessellator.addVertexWithUV(rx1 - diffPrev.x, ry1 - diffPrev.y, rz1 - diffPrev.z, 0.5D, 0.0D); + tessellator.addVertexWithUV(rx3 - diffPrev.x, ry3 - diffPrev.y, rz3 - diffPrev.z, 0.0D, 0.0D); + tessellator.addVertexWithUV(rx3 + diffPrev.x, ry3 + diffPrev.y, rz3 + diffPrev.z, 0.0D, 1.0D); + tessellator.addVertexWithUV(rx1 + diffPrev.x, ry1 + diffPrev.y, rz1 + diffPrev.z, 0.5D, 1.0D); + } } } } tessellator.draw(); + GL11.glDisable(3042); - GL11.glDepthMask(false); + GL11.glDepthMask(true); GL11.glPopMatrix(); FMLClientHandler.instance().getClient().renderEngine.func_110577_a(PARTICLE_RESOURCE); - tessellator.startDrawingQuads(); - } - @Override - public boolean shouldRenderInPass(int pass) - { - return true;//pass == 2; + tessellator.startDrawingQuads(); } public class BoltPoint extends Vector3 @@ -354,7 +379,7 @@ public class FXElectricBolt extends EntityFX /** * All differences are cached. */ - private Vector3 difference; + public Vector3 difference; public Vector3 prevDiff; public Vector3 nextDiff; public double sinPrev; @@ -405,10 +430,5 @@ public class FXElectricBolt extends EntityFX this.sinNext = 1; } } - - public Vector3 getDifference() - { - return difference; - } } -} +} \ No newline at end of file diff --git a/src/resonantinduction/tesla/TileEntityTesla.java b/src/resonantinduction/tesla/TileEntityTesla.java index 78d51a2e8..2d77b2ed3 100644 --- a/src/resonantinduction/tesla/TileEntityTesla.java +++ b/src/resonantinduction/tesla/TileEntityTesla.java @@ -4,11 +4,14 @@ package resonantinduction.tesla; import java.util.HashSet; +import java.util.List; import java.util.Set; import net.minecraft.block.BlockFurnace; +import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraft.util.AxisAlignedBB; import resonantinduction.ITesla; import resonantinduction.ResonantInduction; import resonantinduction.base.TileEntityBase; @@ -34,8 +37,9 @@ public class TileEntityTesla extends TileEntityBase implements ITesla { super.updateEntity(); - if (this.ticks % 2 == 0 && this.getEnergyStored() > 0 && this.doTransfer) + if (this.ticks % 2 == 0 /* &&this.getEnergyStored() > 0 && this.doTransfer */) { + Set transferTeslaCoils = new HashSet(); for (ITesla tesla : TeslaGrid.instance().get()) @@ -53,12 +57,23 @@ 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).translate(new Vector3(0.5)), new Vector3((TileEntity) tesla).translate(new Vector3(0.5))); this.transfer(-transferEnergy); + ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(this).translate(new Vector3(0.5)), new Vector3((TileEntity) tesla).translate(new Vector3(0.5))); } } } + /* + * int radius = 10; List entities = + * this.worldObj.getEntitiesWithinAABBExcludingEntity(null, + * AxisAlignedBB.getAABBPool().getAABB(this.xCoord - radius, this.yCoord - radius, + * this.zCoord - radius, this.xCoord + radius, this.yCoord + radius, this.zCoord + radius)); + * + * for (Entity entity : entities) { + * ResonantInduction.proxy.renderElectricShock(this.worldObj, new + * Vector3(this).translate(new Vector3(0.5)), new Vector3(entity)); } + */ + /** * Draws power from furnace below it. *