diff --git a/common/mekanism/api/DynamicNetwork.java b/common/mekanism/api/DynamicNetwork.java
index 4e7cb6712..5da57ca6d 100644
--- a/common/mekanism/api/DynamicNetwork.java
+++ b/common/mekanism/api/DynamicNetwork.java
@@ -1,7 +1,6 @@
package mekanism.api;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -9,7 +8,6 @@ import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
-
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
@@ -108,7 +106,7 @@ public abstract class DynamicNetwork implements ITransmitterNetwork
{
TileEntity nodeTile = node.getTileEntity(((TileEntity)transmitter).worldObj);
- if(TransmissionType.checkTransmissionType(nodeTile, getTransmissionType()))
+ if(TransmissionType.checkTransmissionType(nodeTile, getTransmissionType(), (TileEntity) transmitter))
{
((ITransmitter)nodeTile).removeFromNetwork();
newTransporters.add((ITransmitter)nodeTile);
@@ -147,7 +145,10 @@ public abstract class DynamicNetwork implements ITransmitterNetwork
if(ignore != null)
{
- toIgnore = Arrays.asList(ignore);
+ for (int i = 0; i < ignore.length; i++)
+ {
+ this.toIgnore.add(ignore[i]);
+ }
}
}
@@ -157,6 +158,10 @@ public abstract class DynamicNetwork implements ITransmitterNetwork
{
iterated.add(location);
}
+ else
+ {
+ toIgnore.add(location);
+ }
for(ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
{
@@ -166,7 +171,7 @@ public abstract class DynamicNetwork implements ITransmitterNetwork
{
TileEntity tileEntity = obj.getTileEntity(worldObj);
- if(TransmissionType.checkTransmissionType(tileEntity, transmissionType))
+ if(TransmissionType.checkTransmissionType(tileEntity, transmissionType, location.getTileEntity(worldObj)))
{
loopAll(obj);
}
diff --git a/common/mekanism/api/GasNetwork.java b/common/mekanism/api/GasNetwork.java
index 7884dec9a..8a948e5a3 100644
--- a/common/mekanism/api/GasNetwork.java
+++ b/common/mekanism/api/GasNetwork.java
@@ -179,7 +179,7 @@ public class GasNetwork extends DynamicNetwork
{
TileEntity connectedBlockA = connectedBlocks[countOne];
- if(TransmissionType.checkTransmissionType(connectedBlockA, TransmissionType.GAS) && !dealtWith[countOne])
+ if(TransmissionType.checkTransmissionType(connectedBlockA, TransmissionType.GAS, (TileEntity) splitPoint) && !dealtWith[countOne])
{
NetworkFinder finder = new NetworkFinder(((TileEntity)splitPoint).worldObj, getTransmissionType(), Object3D.get(connectedBlockA), Object3D.get((TileEntity)splitPoint));
List partNetwork = finder.exploreNetwork();
@@ -188,7 +188,7 @@ public class GasNetwork extends DynamicNetwork
{
TileEntity connectedBlockB = connectedBlocks[countTwo];
- if(TransmissionType.checkTransmissionType(connectedBlockB, TransmissionType.GAS) && !dealtWith[countTwo])
+ if(TransmissionType.checkTransmissionType(connectedBlockB, TransmissionType.GAS, (TileEntity) splitPoint) && !dealtWith[countTwo])
{
if(partNetwork.contains(Object3D.get(connectedBlockB)))
{
diff --git a/common/mekanism/api/GasTransmission.java b/common/mekanism/api/GasTransmission.java
index 4979e8729..ecaf5aa19 100644
--- a/common/mekanism/api/GasTransmission.java
+++ b/common/mekanism/api/GasTransmission.java
@@ -2,7 +2,6 @@ package mekanism.api;
import java.util.HashSet;
import java.util.Set;
-
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
@@ -26,7 +25,7 @@ public final class GasTransmission
{
TileEntity tube = Object3D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj);
- if(TransmissionType.checkTransmissionType(tube, TransmissionType.GAS))
+ if(TransmissionType.checkTransmissionType(tube, TransmissionType.GAS, tileEntity))
{
tubes[orientation.ordinal()] = tube;
}
@@ -70,7 +69,7 @@ public final class GasTransmission
{
TileEntity connection = Object3D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj);
- if(connection instanceof ITubeConnection)
+ if(connection instanceof ITubeConnection && (!(connection instanceof IGasTransmitter) || TransmissionType.checkTransmissionType(connection, TransmissionType.GAS, tileEntity)))
{
connections[orientation.ordinal()] = (ITubeConnection)connection;
}
@@ -91,7 +90,7 @@ public final class GasTransmission
{
TileEntity pointer = Object3D.get(sender).getFromSide(facing).getTileEntity(sender.worldObj);
- if(TransmissionType.checkTransmissionType(pointer, TransmissionType.GAS))
+ if(TransmissionType.checkTransmissionType(pointer, TransmissionType.GAS, sender))
{
return ((ITransmitter)pointer).getNetwork().emit(amount, type, sender);
}
@@ -117,7 +116,7 @@ public final class GasTransmission
{
TileEntity sideTile = Object3D.get(pointer).getFromSide(side).getTileEntity(pointer.worldObj);
- if(TransmissionType.checkTransmissionType(sideTile, TransmissionType.GAS))
+ if(TransmissionType.checkTransmissionType(sideTile, TransmissionType.GAS, pointer))
{
networks.add(((ITransmitter)sideTile).getNetwork());
}
diff --git a/common/mekanism/api/IGasTransmitter.java b/common/mekanism/api/IGasTransmitter.java
new file mode 100644
index 000000000..8cef22933
--- /dev/null
+++ b/common/mekanism/api/IGasTransmitter.java
@@ -0,0 +1,8 @@
+package mekanism.api;
+
+import net.minecraft.tileentity.TileEntity;
+
+public interface IGasTransmitter extends ITransmitter
+{
+ public boolean canTransferGasToTube(TileEntity tile);
+}
diff --git a/common/mekanism/api/TransmissionType.java b/common/mekanism/api/TransmissionType.java
index e4faad1de..93e62aa33 100644
--- a/common/mekanism/api/TransmissionType.java
+++ b/common/mekanism/api/TransmissionType.java
@@ -8,22 +8,40 @@ public enum TransmissionType
FLUID,
GAS,
ITEM;
-
- public static boolean checkTransmissionType(TileEntity tileEntity, TransmissionType type)
+
+ public static boolean checkTransmissionType(TileEntity sideTile, TransmissionType type)
{
- return type.checkTransmissionType(tileEntity);
+ return checkTransmissionType(sideTile, type, null);
+ }
+
+ public static boolean checkTransmissionType(TileEntity sideTile, TransmissionType type, TileEntity currentPipe)
+ {
+ return type.checkTransmissionType(sideTile, currentPipe);
}
- public boolean checkTransmissionType(TileEntity tileEntity)
+ public boolean checkTransmissionType(TileEntity sideTile, TileEntity currentTile)
{
- if(tileEntity instanceof ITransmitter)
+ if (sideTile == null)
+ {
+ return false;
+ }
+
+ if (sideTile instanceof ITransmitter)
{
- if(((ITransmitter>)tileEntity).getTransmissionType() == this)
+ if(((ITransmitter>)sideTile).getTransmissionType() != this)
{
- return true;
+ return false;
}
}
- return false;
+ if (this == GAS && currentTile instanceof IGasTransmitter)
+ {
+ if (!((IGasTransmitter)currentTile).canTransferGasToTube(sideTile))
+ {
+ return false;
+ }
+ }
+
+ return true;
}
}
diff --git a/common/mekanism/common/TileEntityPressurizedTube.java b/common/mekanism/common/TileEntityPressurizedTube.java
index 3db994597..6ded026f9 100644
--- a/common/mekanism/common/TileEntityPressurizedTube.java
+++ b/common/mekanism/common/TileEntityPressurizedTube.java
@@ -1,10 +1,10 @@
package mekanism.common;
import java.util.HashSet;
-
import mekanism.api.EnumGas;
import mekanism.api.GasNetwork;
import mekanism.api.GasTransmission;
+import mekanism.api.IGasTransmitter;
import mekanism.api.ITransmitter;
import mekanism.api.ITubeConnection;
import mekanism.api.Object3D;
@@ -12,7 +12,7 @@ import mekanism.api.TransmissionType;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
-public class TileEntityPressurizedTube extends TileEntityTransmitter implements ITubeConnection
+public class TileEntityPressurizedTube extends TileEntityTransmitter implements ITubeConnection, IGasTransmitter
{
/** The gas currently displayed in this tube. */
public EnumGas refGas = null;
@@ -36,7 +36,7 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter
for(TileEntity tube : adjacentTubes)
{
- if(TransmissionType.checkTransmissionType(tube, TransmissionType.GAS) && ((ITransmitter)tube).getNetwork(false) != null)
+ if(TransmissionType.checkTransmissionType(tube, TransmissionType.GAS, this) && ((ITransmitter)tube).getNetwork(false) != null)
{
connectedNets.add(((ITransmitter)tube).getNetwork());
}
@@ -95,7 +95,7 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter
{
TileEntity tileEntity = Object3D.get(this).getFromSide(side).getTileEntity(worldObj);
- if(TransmissionType.checkTransmissionType(tileEntity, TransmissionType.GAS))
+ if(TransmissionType.checkTransmissionType(tileEntity, TransmissionType.GAS, this))
{
getNetwork().merge(((ITransmitter)tileEntity).getNetwork());
}
@@ -153,4 +153,10 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter
{
return getNetwork().getFlow();
}
+
+ @Override
+ public boolean canTransferGasToTube(TileEntity tile)
+ {
+ return tile != null && tile.getClass().equals(this.getClass());
+ }
}