Move checkTransmissionType to TransmissionType.

This commit is contained in:
Ben Spiers 2013-08-25 02:39:00 +01:00
parent d18c9645f9
commit 32c32fb106
16 changed files with 53 additions and 36 deletions

View file

@ -10,7 +10,6 @@ import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import mekanism.common.MekanismUtils;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
@ -109,7 +108,7 @@ public abstract class DynamicNetwork<A, N> implements ITransmitterNetwork<A, N>
{
TileEntity nodeTile = node.getTileEntity(((TileEntity)transmitter).worldObj);
if(MekanismUtils.checkTransmissionType(nodeTile, getTransmissionType()))
if(TransmissionType.checkTransmissionType(nodeTile, getTransmissionType()))
{
((ITransmitter<N>)nodeTile).removeFromNetwork();
newTransporters.add((ITransmitter<N>)nodeTile);
@ -154,7 +153,7 @@ public abstract class DynamicNetwork<A, N> implements ITransmitterNetwork<A, N>
public void loopAll(Object3D location)
{
if(MekanismUtils.checkTransmissionType(location.getTileEntity(worldObj), transmissionType))
if(TransmissionType.checkTransmissionType(location.getTileEntity(worldObj), transmissionType))
{
iterated.add(location);
}
@ -167,7 +166,7 @@ public abstract class DynamicNetwork<A, N> implements ITransmitterNetwork<A, N>
{
TileEntity tileEntity = obj.getTileEntity(worldObj);
if(MekanismUtils.checkTransmissionType(tileEntity, transmissionType))
if(TransmissionType.checkTransmissionType(tileEntity, transmissionType))
{
loopAll(obj);
}

View file

@ -8,7 +8,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
import mekanism.common.MekanismUtils;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.MinecraftForge;
@ -180,7 +179,7 @@ public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
{
TileEntity connectedBlockA = connectedBlocks[countOne];
if(MekanismUtils.checkTransmissionType(connectedBlockA, TransmissionType.GAS) && !dealtWith[countOne])
if(TransmissionType.checkTransmissionType(connectedBlockA, TransmissionType.GAS) && !dealtWith[countOne])
{
NetworkFinder finder = new NetworkFinder(((TileEntity)splitPoint).worldObj, getTransmissionType(), Object3D.get(connectedBlockA), Object3D.get((TileEntity)splitPoint));
List<Object3D> partNetwork = finder.exploreNetwork();
@ -189,7 +188,7 @@ public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
{
TileEntity connectedBlockB = connectedBlocks[countTwo];
if(MekanismUtils.checkTransmissionType(connectedBlockB, TransmissionType.GAS) && !dealtWith[countTwo])
if(TransmissionType.checkTransmissionType(connectedBlockB, TransmissionType.GAS) && !dealtWith[countTwo])
{
if(partNetwork.contains(Object3D.get(connectedBlockB)))
{
@ -204,7 +203,7 @@ public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
{
TileEntity nodeTile = node.getTileEntity(((TileEntity)splitPoint).worldObj);
if(MekanismUtils.checkTransmissionType(nodeTile, TransmissionType.GAS))
if(TransmissionType.checkTransmissionType(nodeTile, TransmissionType.GAS))
{
if(nodeTile != splitPoint)
{

View file

@ -3,7 +3,6 @@ package mekanism.api;
import java.util.HashSet;
import java.util.Set;
import mekanism.common.MekanismUtils;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
@ -27,7 +26,7 @@ public final class GasTransmission
{
TileEntity tube = Object3D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj);
if(MekanismUtils.checkTransmissionType(tube, TransmissionType.GAS))
if(TransmissionType.checkTransmissionType(tube, TransmissionType.GAS))
{
tubes[orientation.ordinal()] = tube;
}
@ -92,7 +91,7 @@ public final class GasTransmission
{
TileEntity pointer = Object3D.get(sender).getFromSide(facing).getTileEntity(sender.worldObj);
if(MekanismUtils.checkTransmissionType(pointer, TransmissionType.GAS))
if(TransmissionType.checkTransmissionType(pointer, TransmissionType.GAS))
{
return ((ITransmitter<GasNetwork>)pointer).getNetwork().emit(amount, type, sender);
}
@ -118,7 +117,7 @@ public final class GasTransmission
{
TileEntity sideTile = Object3D.get(pointer).getFromSide(side).getTileEntity(pointer.worldObj);
if(MekanismUtils.checkTransmissionType(sideTile, TransmissionType.GAS))
if(TransmissionType.checkTransmissionType(sideTile, TransmissionType.GAS))
{
networks.add(((ITransmitter<GasNetwork>)sideTile).getNetwork());
}

View file

@ -1,9 +1,29 @@
package mekanism.api;
import net.minecraft.tileentity.TileEntity;
public enum TransmissionType
{
ENERGY,
FLUID,
GAS,
ITEM;
public static boolean checkTransmissionType(TileEntity tileEntity, TransmissionType type)
{
return type.checkTransmissionType(tileEntity);
}
public boolean checkTransmissionType(TileEntity tileEntity)
{
if(tileEntity instanceof ITransmitter)
{
if(((ITransmitter<?>)tileEntity).getTransmissionType() == this)
{
return true;
}
}
return false;
}
}

View file

@ -59,7 +59,7 @@ public final class CableUtils
{
TileEntity cable = Object3D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj);
if(MekanismUtils.checkTransmissionType(cable, TransmissionType.ENERGY))
if(TransmissionType.checkTransmissionType(cable, TransmissionType.ENERGY))
{
cables[orientation.ordinal()] = cable;
}
@ -193,7 +193,7 @@ public final class CableUtils
{
TileEntity pointer = Object3D.get(sender).getFromSide(facing).getTileEntity(sender.worldObj);
if(MekanismUtils.checkTransmissionType(pointer, TransmissionType.ENERGY))
if(TransmissionType.checkTransmissionType(pointer, TransmissionType.ENERGY))
{
ITransmitter<EnergyNetwork> cable = (ITransmitter<EnergyNetwork>)pointer;
@ -226,7 +226,7 @@ public final class CableUtils
{
TileEntity sideTile = Object3D.get(pointer).getFromSide(side).getTileEntity(pointer.worldObj);
if(MekanismUtils.checkTransmissionType(sideTile, TransmissionType.ENERGY) && !ignored.contains(sideTile))
if(TransmissionType.checkTransmissionType(sideTile, TransmissionType.ENERGY) && !ignored.contains(sideTile))
{
networks.add(((ITransmitter<EnergyNetwork>)sideTile).getNetwork());
}

View file

@ -284,7 +284,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
{
TileEntity connectedBlockA = connectedBlocks[countOne];
if(MekanismUtils.checkTransmissionType(connectedBlockA, TransmissionType.ENERGY) && !dealtWith[countOne])
if(TransmissionType.checkTransmissionType(connectedBlockA, TransmissionType.ENERGY) && !dealtWith[countOne])
{
NetworkFinder finder = new NetworkFinder(((TileEntity)splitPoint).worldObj, getTransmissionType(), Object3D.get(connectedBlockA), Object3D.get((TileEntity)splitPoint));
List<Object3D> partNetwork = finder.exploreNetwork();
@ -293,7 +293,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
{
TileEntity connectedBlockB = connectedBlocks[countTwo];
if(MekanismUtils.checkTransmissionType(connectedBlockB, TransmissionType.ENERGY) && !dealtWith[countTwo])
if(TransmissionType.checkTransmissionType(connectedBlockB, TransmissionType.ENERGY) && !dealtWith[countTwo])
{
if(partNetwork.contains(Object3D.get(connectedBlockB)))
{
@ -308,7 +308,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
{
TileEntity nodeTile = node.getTileEntity(((TileEntity)splitPoint).worldObj);
if(MekanismUtils.checkTransmissionType(nodeTile, TransmissionType.ENERGY))
if(TransmissionType.checkTransmissionType(nodeTile, TransmissionType.ENERGY))
{
if(nodeTile != splitPoint)
{

View file

@ -207,7 +207,7 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
{
TileEntity connectedBlockA = connectedBlocks[countOne];
if(MekanismUtils.checkTransmissionType(connectedBlockA, TransmissionType.FLUID) && !dealtWith[countOne])
if(TransmissionType.checkTransmissionType(connectedBlockA, TransmissionType.FLUID) && !dealtWith[countOne])
{
NetworkFinder finder = new NetworkFinder(((TileEntity)splitPoint).worldObj, getTransmissionType(), Object3D.get(connectedBlockA), Object3D.get((TileEntity)splitPoint));
List<Object3D> partNetwork = finder.exploreNetwork();
@ -216,7 +216,7 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
{
TileEntity connectedBlockB = connectedBlocks[countTwo];
if(MekanismUtils.checkTransmissionType(connectedBlockB, TransmissionType.FLUID) && !dealtWith[countTwo])
if(TransmissionType.checkTransmissionType(connectedBlockB, TransmissionType.FLUID) && !dealtWith[countTwo])
{
if(partNetwork.contains(Object3D.get(connectedBlockB)))
{
@ -231,7 +231,7 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
{
TileEntity nodeTile = node.getTileEntity(((TileEntity)splitPoint).worldObj);
if(MekanismUtils.checkTransmissionType(nodeTile, TransmissionType.FLUID))
if(TransmissionType.checkTransmissionType(nodeTile, TransmissionType.FLUID))
{
if(nodeTile != splitPoint)
{

View file

@ -125,7 +125,7 @@ public class InventoryNetwork extends DynamicNetwork<IInventory, InventoryNetwor
{
TileEntity connectedBlockA = connectedBlocks[countOne];
if(MekanismUtils.checkTransmissionType(connectedBlockA, TransmissionType.ITEM) && !dealtWith[countOne])
if(TransmissionType.checkTransmissionType(connectedBlockA, TransmissionType.ITEM) && !dealtWith[countOne])
{
NetworkFinder finder = new NetworkFinder(((TileEntity)splitPoint).worldObj, getTransmissionType(), Object3D.get(connectedBlockA), Object3D.get((TileEntity)splitPoint));
List<Object3D> partNetwork = finder.exploreNetwork();
@ -134,7 +134,7 @@ public class InventoryNetwork extends DynamicNetwork<IInventory, InventoryNetwor
{
TileEntity connectedBlockB = connectedBlocks[countTwo];
if(MekanismUtils.checkTransmissionType(connectedBlockB, TransmissionType.ITEM) && !dealtWith[countTwo])
if(TransmissionType.checkTransmissionType(connectedBlockB, TransmissionType.ITEM) && !dealtWith[countTwo])
{
if(partNetwork.contains(Object3D.get(connectedBlockB)))
{
@ -149,7 +149,7 @@ public class InventoryNetwork extends DynamicNetwork<IInventory, InventoryNetwor
{
TileEntity nodeTile = node.getTileEntity(((TileEntity)splitPoint).worldObj);
if(MekanismUtils.checkTransmissionType(nodeTile, TransmissionType.ITEM))
if(TransmissionType.checkTransmissionType(nodeTile, TransmissionType.ITEM))
{
if(nodeTile != splitPoint)
{

View file

@ -25,7 +25,7 @@ public final class PipeUtils
{
TileEntity pipe = Object3D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj);
if(MekanismUtils.checkTransmissionType(pipe, TransmissionType.FLUID))
if(TransmissionType.checkTransmissionType(pipe, TransmissionType.FLUID))
{
pipes[orientation.ordinal()] = pipe;
}

View file

@ -69,7 +69,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn
if(getEnergy() > 0)
{
if(MekanismUtils.checkTransmissionType(tileEntity, TransmissionType.ENERGY))
if(TransmissionType.checkTransmissionType(tileEntity, TransmissionType.ENERGY))
{
setEnergy(getEnergy() - (Math.min(getEnergy(), tier.OUTPUT) - CableUtils.emitEnergyToNetwork(Math.min(getEnergy(), tier.OUTPUT), this, ForgeDirection.getOrientation(facing))));
return;

View file

@ -40,7 +40,7 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
for(TileEntity transporter : adjacentTransporters)
{
if(MekanismUtils.checkTransmissionType(transporter, getTransmissionType()) && ((ITransmitter<InventoryNetwork>)transporter).getNetwork(false) != null)
if(TransmissionType.checkTransmissionType(transporter, getTransmissionType()) && ((ITransmitter<InventoryNetwork>)transporter).getNetwork(false) != null)
{
connectedNets.add(((ITransmitter<InventoryNetwork>)transporter).getNetwork());
}
@ -99,7 +99,7 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
{
TileEntity tileEntity = Object3D.get(this).getFromSide(side).getTileEntity(worldObj);
if(MekanismUtils.checkTransmissionType(tileEntity, getTransmissionType()))
if(TransmissionType.checkTransmissionType(tileEntity, getTransmissionType()))
{
getNetwork().merge(((ITransmitter<InventoryNetwork>)tileEntity).getNetwork());
}

View file

@ -68,7 +68,7 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter<FluidNetwork
for(TileEntity pipe : adjacentPipes)
{
if(MekanismUtils.checkTransmissionType(pipe, getTransmissionType()) && ((ITransmitter<FluidNetwork>)pipe).getNetwork(false) != null)
if(TransmissionType.checkTransmissionType(pipe, getTransmissionType()) && ((ITransmitter<FluidNetwork>)pipe).getNetwork(false) != null)
{
connectedNets.add(((ITransmitter<FluidNetwork>)pipe).getNetwork());
}
@ -127,7 +127,7 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter<FluidNetwork
{
TileEntity tileEntity = Object3D.get(this).getFromSide(side).getTileEntity(worldObj);
if(MekanismUtils.checkTransmissionType(tileEntity, getTransmissionType()))
if(TransmissionType.checkTransmissionType(tileEntity, getTransmissionType()))
{
getNetwork().merge(((ITransmitter<FluidNetwork>)tileEntity).getNetwork());
}

View file

@ -36,7 +36,7 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter<GasNetwork>
for(TileEntity tube : adjacentTubes)
{
if(MekanismUtils.checkTransmissionType(tube, TransmissionType.GAS) && ((ITransmitter<GasNetwork>)tube).getNetwork(false) != null)
if(TransmissionType.checkTransmissionType(tube, TransmissionType.GAS) && ((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(MekanismUtils.checkTransmissionType(tileEntity, TransmissionType.GAS))
if(TransmissionType.checkTransmissionType(tileEntity, TransmissionType.GAS))
{
getNetwork().merge(((ITransmitter<GasNetwork>)tileEntity).getNetwork());
}

View file

@ -51,7 +51,7 @@ public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwor
for(TileEntity cable : adjacentCables)
{
if(MekanismUtils.checkTransmissionType(cable, TransmissionType.ENERGY) && ((ITransmitter<EnergyNetwork>)cable).getNetwork(false) != null)
if(TransmissionType.checkTransmissionType(cable, TransmissionType.ENERGY) && ((ITransmitter<EnergyNetwork>)cable).getNetwork(false) != null)
{
connectedNets.add(((ITransmitter<EnergyNetwork>)cable).getNetwork());
}
@ -110,7 +110,7 @@ public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwor
{
TileEntity tileEntity = Object3D.get(this).getFromSide(side).getTileEntity(worldObj);
if(MekanismUtils.checkTransmissionType(tileEntity, TransmissionType.ENERGY))
if(TransmissionType.checkTransmissionType(tileEntity, TransmissionType.ENERGY))
{
getNetwork().merge(((ITransmitter<EnergyNetwork>)tileEntity).getNetwork());
}

View file

@ -25,7 +25,7 @@ public final class TransporterUtils
{
TileEntity transporter = Object3D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj);
if(MekanismUtils.checkTransmissionType(transporter, TransmissionType.ITEM))
if(TransmissionType.checkTransmissionType(transporter, TransmissionType.ITEM))
{
transporters[orientation.ordinal()] = transporter;
}

View file

@ -101,7 +101,7 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
{
if(!worldObj.isRemote)
{
if(MekanismUtils.checkTransmissionType(tileEntity, TransmissionType.ENERGY))
if(TransmissionType.checkTransmissionType(tileEntity, TransmissionType.ENERGY))
{
setEnergy(getEnergy() - (Math.min(getEnergy(), output) - CableUtils.emitEnergyToNetwork(Math.min(getEnergy(), output), this, ForgeDirection.getOrientation(facing))));
return;