From ebc1e90f802bda015140e0c3cc39d3c6e338b9c0 Mon Sep 17 00:00:00 2001 From: Calclavia Date: Sat, 4 Jan 2014 00:39:21 +0800 Subject: [PATCH] Fixed flat wires casting without check --- .../wire/flat/PartFlatWire.java | 39 +++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/src/main/java/resonantinduction/wire/flat/PartFlatWire.java b/src/main/java/resonantinduction/wire/flat/PartFlatWire.java index 2c33055e..8517e793 100644 --- a/src/main/java/resonantinduction/wire/flat/PartFlatWire.java +++ b/src/main/java/resonantinduction/wire/flat/PartFlatWire.java @@ -351,9 +351,14 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal if (this.canConnectTo(tp)) { - // We found a wire, merge networks! this.connections[absDir] = tp; - this.getNetwork().merge(((PartFlatWire) tp).getNetwork()); + + if (tp instanceof PartFlatWire) + { + // We found a wire, merge networks! + this.getNetwork().merge(((PartFlatWire) tp).getNetwork()); + } + calculatedSides[absDir] = true; continue; } @@ -628,18 +633,23 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal if (canConnectTo(tp)) { - boolean b = ((PartFlatWire) tp).connectCorner(this, Rotation.rotationTo(absDir ^ 1, side ^ 1)); - - if (b) + if (tp instanceof PartFlatWire) { - // let them connect to us - if (!renderThisCorner((PartFlatWire) tp)) - { - return 1; - } + boolean b = ((PartFlatWire) tp).connectCorner(this, Rotation.rotationTo(absDir ^ 1, side ^ 1)); - return 2; + if (b) + { + // let them connect to us + if (!renderThisCorner((PartFlatWire) tp)) + { + return 1; + } + + return 2; + } } + + return 2; } } return 0; @@ -674,7 +684,12 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal if (this.canConnectTo(tp)) { - return ((PartFlatWire) tp).connectStraight(this, (r + 2) % 4); + if (tp instanceof PartFlatWire) + { + return ((PartFlatWire) tp).connectStraight(this, (r + 2) % 4); + } + + return true; } } else