Fix canTransferGas()
Tested and working.
This commit is contained in:
parent
0951acf142
commit
8e667efd7b
|
@ -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<A, N> implements ITransmitterNetwork<A, N>
|
|||
{
|
||||
TileEntity nodeTile = node.getTileEntity(((TileEntity)transmitter).worldObj);
|
||||
|
||||
if(TransmissionType.checkTransmissionType(nodeTile, getTransmissionType()))
|
||||
if(TransmissionType.checkTransmissionType(nodeTile, getTransmissionType(), (TileEntity) transmitter))
|
||||
{
|
||||
((ITransmitter<N>)nodeTile).removeFromNetwork();
|
||||
newTransporters.add((ITransmitter<N>)nodeTile);
|
||||
|
@ -147,7 +145,10 @@ public abstract class DynamicNetwork<A, N> implements ITransmitterNetwork<A, N>
|
|||
|
||||
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<A, N> implements ITransmitterNetwork<A, N>
|
|||
{
|
||||
iterated.add(location);
|
||||
}
|
||||
else
|
||||
{
|
||||
toIgnore.add(location);
|
||||
}
|
||||
|
||||
for(ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
|
@ -166,7 +171,7 @@ public abstract class DynamicNetwork<A, N> implements ITransmitterNetwork<A, N>
|
|||
{
|
||||
TileEntity tileEntity = obj.getTileEntity(worldObj);
|
||||
|
||||
if(TransmissionType.checkTransmissionType(tileEntity, transmissionType))
|
||||
if(TransmissionType.checkTransmissionType(tileEntity, transmissionType, location.getTileEntity(worldObj)))
|
||||
{
|
||||
loopAll(obj);
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
|
|||
{
|
||||
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<Object3D> partNetwork = finder.exploreNetwork();
|
||||
|
@ -188,7 +188,7 @@ public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
|
|||
{
|
||||
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)))
|
||||
{
|
||||
|
|
|
@ -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<GasNetwork>)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<GasNetwork>)sideTile).getNetwork());
|
||||
}
|
||||
|
|
8
common/mekanism/api/IGasTransmitter.java
Normal file
8
common/mekanism/api/IGasTransmitter.java
Normal file
|
@ -0,0 +1,8 @@
|
|||
package mekanism.api;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public interface IGasTransmitter extends ITransmitter<GasNetwork>
|
||||
{
|
||||
public boolean canTransferGasToTube(TileEntity tile);
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<GasNetwork> implements ITubeConnection
|
||||
public class TileEntityPressurizedTube extends TileEntityTransmitter<GasNetwork> implements ITubeConnection, IGasTransmitter
|
||||
{
|
||||
/** The gas currently displayed in this tube. */
|
||||
public EnumGas refGas = null;
|
||||
|
@ -36,7 +36,7 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter<GasNetwork>
|
|||
|
||||
for(TileEntity tube : adjacentTubes)
|
||||
{
|
||||
if(TransmissionType.checkTransmissionType(tube, TransmissionType.GAS) && ((ITransmitter<GasNetwork>)tube).getNetwork(false) != null)
|
||||
if(TransmissionType.checkTransmissionType(tube, TransmissionType.GAS, this) && ((ITransmitter<GasNetwork>)tube).getNetwork(false) != null)
|
||||
{
|
||||
connectedNets.add(((ITransmitter<GasNetwork>)tube).getNetwork());
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter<GasNetwork>
|
|||
{
|
||||
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<GasNetwork>)tileEntity).getNetwork());
|
||||
}
|
||||
|
@ -153,4 +153,10 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter<GasNetwork>
|
|||
{
|
||||
return getNetwork().getFlow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTransferGasToTube(TileEntity tile)
|
||||
{
|
||||
return tile != null && tile.getClass().equals(this.getClass());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue