diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/LaserRelayConnectionHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/LaserRelayConnectionHandler.java index 65507572f..1a7e1fe86 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/LaserRelayConnectionHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/LaserRelayConnectionHandler.java @@ -65,7 +65,7 @@ public class LaserRelayConnectionHandler{ WorldData.getDataForWorld(world).laserRelayNetworks.remove(network); for(ConnectionPair pair : network.connections){ if(!pair.contains(relay)){ - addConnection(pair.firstRelay, pair.secondRelay, world); + addConnection(pair.positions[0], pair.positions[1], world); } } //System.out.println("Removing a Relay from the Network!"); @@ -142,12 +142,11 @@ public class LaserRelayConnectionHandler{ public static class ConnectionPair{ - public final BlockPos firstRelay; - public final BlockPos secondRelay; + public final BlockPos[] positions = new BlockPos[2]; public ConnectionPair(BlockPos firstRelay, BlockPos secondRelay){ - this.firstRelay = firstRelay; - this.secondRelay = secondRelay; + this.positions[0] = firstRelay; + this.positions[1] = secondRelay; } public static ConnectionPair readFromNBT(NBTTagCompound compound){ @@ -165,18 +164,23 @@ public class LaserRelayConnectionHandler{ } public boolean contains(BlockPos relay){ - return (this.firstRelay != null && PosUtil.areSamePos(this.firstRelay, relay)) || (this.secondRelay != null && PosUtil.areSamePos(this.secondRelay, relay)); + for(BlockPos position : this.positions){ + if(position != null && PosUtil.areSamePos(position, relay)){ + return true; + } + } + return false; } @Override public String toString(){ - return (this.firstRelay == null ? "-" : this.firstRelay.toString())+" | "+(this.secondRelay == null ? "-" : this.secondRelay.toString()); + return (this.positions[0] == null ? "-" : this.positions[0].toString())+" | "+(this.positions[1] == null ? "-" : this.positions[1].toString()); } public NBTTagCompound writeToNBT(){ NBTTagCompound compound = new NBTTagCompound(); - for(int i = 0; i < 2; i++){ - BlockPos relay = i == 0 ? this.firstRelay : this.secondRelay; + for(int i = 0; i < this.positions.length; i++){ + BlockPos relay = this.positions[i]; compound.setInteger("x"+i, relay.getX()); compound.setInteger("y"+i, relay.getY()); compound.setInteger("z"+i, relay.getZ()); @@ -188,8 +192,8 @@ public class LaserRelayConnectionHandler{ public boolean equals(Object obj){ if(obj instanceof ConnectionPair){ ConnectionPair pair = (ConnectionPair)obj; - if(this.firstRelay == pair.firstRelay || (this.firstRelay != null && this.firstRelay.equals(pair.firstRelay))){ - if(this.secondRelay == pair.secondRelay && (this.secondRelay != null && this.secondRelay.equals(pair.secondRelay))){ + for(int i = 0; i < this.positions.length; i++){ + if(this.positions[i] == pair.positions[i] || (this.positions[i] != null && this.positions[i].equals(pair.positions[i]))){ return true; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java index f03314d50..0ddf4bb61 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java @@ -43,7 +43,7 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{ if(!list.hasNoTags()){ for(int i = 0; i < list.tagCount(); i++){ LaserRelayConnectionHandler.ConnectionPair pair = LaserRelayConnectionHandler.ConnectionPair.readFromNBT(list.getCompoundTagAt(i)); - LaserRelayConnectionHandler.addConnection(pair.firstRelay, pair.secondRelay, this.worldObj); + LaserRelayConnectionHandler.addConnection(pair.positions[0], pair.positions[1], this.worldObj); } } @@ -82,8 +82,8 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{ LaserRelayConnectionHandler.Network network = LaserRelayConnectionHandler.getNetworkFor(thisPos, this.worldObj); if(network != null){ for(LaserRelayConnectionHandler.ConnectionPair aPair : network.connections){ - if(aPair.contains(thisPos) && PosUtil.areSamePos(thisPos, aPair.firstRelay)){ - PacketParticle.renderParticlesFromAToB(aPair.firstRelay.getX(), aPair.firstRelay.getY(), aPair.firstRelay.getZ(), aPair.secondRelay.getX(), aPair.secondRelay.getY(), aPair.secondRelay.getZ(), ConfigBoolValues.LESS_PARTICLES.isEnabled() ? 1 : Util.RANDOM.nextInt(3)+1, 0.8F, this.isItem ? COLOR_ITEM : COLOR, 1F); + if(aPair.contains(thisPos) && PosUtil.areSamePos(thisPos, aPair.positions[0])){ + PacketParticle.renderParticlesFromAToB(aPair.positions[0].getX(), aPair.positions[0].getY(), aPair.positions[0].getZ(), aPair.positions[1].getX(), aPair.positions[1].getY(), aPair.positions[1].getZ(), ConfigBoolValues.LESS_PARTICLES.isEnabled() ? 1 : Util.RANDOM.nextInt(3)+1, 0.8F, this.isItem ? COLOR_ITEM : COLOR, 1F); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java index b8ebaf4f4..1549cfd0b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java @@ -64,9 +64,8 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay implements List alreadyChecked = new ArrayList(); //Go through all of the connections in the network for(LaserRelayConnectionHandler.ConnectionPair pair : network.connections){ - BlockPos[] relays = new BlockPos[]{pair.firstRelay, pair.secondRelay}; //Go through both relays in the connection - for(BlockPos relay : relays){ + for(BlockPos relay : pair.positions){ if(relay != null && !alreadyChecked.contains(relay)){ alreadyChecked.add(relay); //Get every side of the relay diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java index c9c3b8a43..7f9d5d87b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java @@ -55,8 +55,7 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay{ public List getItemHandlersInNetwork(LaserRelayConnectionHandler.Network network){ List handlers = new ArrayList(); for(LaserRelayConnectionHandler.ConnectionPair pair : network.connections){ - BlockPos[] relays = new BlockPos[]{pair.firstRelay, pair.secondRelay}; - for(BlockPos relay : relays){ + for(BlockPos relay : pair.positions){ if(relay != null){ TileEntity aRelayTile = this.worldObj.getTileEntity(relay); if(aRelayTile instanceof de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItem){