From dbed6dea080f9408858e4ea675e1a999660ea1b7 Mon Sep 17 00:00:00 2001 From: Calclavia Date: Fri, 2 Aug 2013 00:12:58 -0400 Subject: [PATCH] Some work on eletric bolt --- src/resonantinduction/fx/FXElectricBolt.java | 41 +++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/src/resonantinduction/fx/FXElectricBolt.java b/src/resonantinduction/fx/FXElectricBolt.java index 230b1683..0505a46b 100644 --- a/src/resonantinduction/fx/FXElectricBolt.java +++ b/src/resonantinduction/fx/FXElectricBolt.java @@ -3,11 +3,14 @@ */ package resonantinduction.fx; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; -import java.util.HashSet; +import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Random; -import java.util.Set; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.EntityFX; @@ -45,7 +48,7 @@ public class FXElectricBolt extends EntityFX private Random random; - private Set segments = new HashSet(); + private List segments = new ArrayList(); private int maxSplitID; private final Map parentIDMap = new HashMap(); @@ -71,15 +74,38 @@ public class FXElectricBolt extends EntityFX public void setUp() { 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 o1, BoltSegment o2) + { + return Float.compare(o2.weight, o1.weight); + } + + @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; - Set oldSegments = this.segments; + List oldSegments = this.segments; this.segments.clear(); BoltSegment prev = null; @@ -236,7 +262,7 @@ public class FXElectricBolt extends EntityFX { this.start = start; this.end = end; - this.difference = this.end.difference(this.start); + this.recalculate(); } public BoltSegment(BoltPoint start, BoltPoint end, float weight, int id, int splitID) @@ -247,6 +273,11 @@ public class FXElectricBolt extends EntityFX this.splitID = splitID; } + public void recalculate() + { + this.difference = this.end.difference(this.start); + } + public Vector3 getDifference() { return difference;