Fix StackOverflowException on getNetwork.

This commit is contained in:
Ben Spiers 2013-08-21 20:26:47 +01:00
parent 19cea5b35c
commit e598527656
19 changed files with 99 additions and 45 deletions

View file

@ -182,7 +182,7 @@ public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
{ {
TileEntity connectedBlockA = connectedBlocks[countOne]; TileEntity connectedBlockA = connectedBlocks[countOne];
if(MekanismUtils.checkNetwork(connectedBlockA, GasNetwork.class) && !dealtWith[countOne]) if(MekanismUtils.checkTransmissionType(connectedBlockA, TransmissionType.GAS) && !dealtWith[countOne])
{ {
NetworkFinder finder = new NetworkFinder(((TileEntity)splitPoint).worldObj, Object3D.get(connectedBlockA), Object3D.get((TileEntity)splitPoint)); NetworkFinder finder = new NetworkFinder(((TileEntity)splitPoint).worldObj, Object3D.get(connectedBlockA), Object3D.get((TileEntity)splitPoint));
List<Object3D> partNetwork = finder.exploreNetwork(); List<Object3D> partNetwork = finder.exploreNetwork();
@ -191,7 +191,7 @@ public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
{ {
TileEntity connectedBlockB = connectedBlocks[countTwo]; TileEntity connectedBlockB = connectedBlocks[countTwo];
if(MekanismUtils.checkNetwork(connectedBlockB, GasNetwork.class) && !dealtWith[countTwo]) if(MekanismUtils.checkTransmissionType(connectedBlockB, TransmissionType.GAS) && !dealtWith[countTwo])
{ {
if(partNetwork.contains(Object3D.get(connectedBlockB))) if(partNetwork.contains(Object3D.get(connectedBlockB)))
{ {
@ -206,7 +206,7 @@ public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
{ {
TileEntity nodeTile = node.getTileEntity(((TileEntity)splitPoint).worldObj); TileEntity nodeTile = node.getTileEntity(((TileEntity)splitPoint).worldObj);
if(MekanismUtils.checkNetwork(nodeTile, GasNetwork.class)) if(MekanismUtils.checkTransmissionType(nodeTile, TransmissionType.GAS))
{ {
if(nodeTile != splitPoint) if(nodeTile != splitPoint)
{ {
@ -236,7 +236,7 @@ public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
{ {
TileEntity nodeTile = node.getTileEntity(((TileEntity)tube).worldObj); TileEntity nodeTile = node.getTileEntity(((TileEntity)tube).worldObj);
if(MekanismUtils.checkNetwork(nodeTile, GasNetwork.class)) if(MekanismUtils.checkTransmissionType(nodeTile, TransmissionType.GAS))
{ {
((ITransmitter<GasNetwork>)nodeTile).removeFromNetwork(); ((ITransmitter<GasNetwork>)nodeTile).removeFromNetwork();
newTubes.add((ITransmitter<GasNetwork>)nodeTile); newTubes.add((ITransmitter<GasNetwork>)nodeTile);
@ -271,7 +271,7 @@ public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
public void loopAll(Object3D location) public void loopAll(Object3D location)
{ {
if(MekanismUtils.checkNetwork(location.getTileEntity(worldObj), GasNetwork.class)) if(MekanismUtils.checkTransmissionType(location.getTileEntity(worldObj), TransmissionType.GAS))
{ {
iterated.add(location); iterated.add(location);
} }
@ -284,7 +284,7 @@ public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
{ {
TileEntity tileEntity = obj.getTileEntity(worldObj); TileEntity tileEntity = obj.getTileEntity(worldObj);
if(MekanismUtils.checkNetwork(tileEntity, GasNetwork.class)) if(MekanismUtils.checkTransmissionType(tileEntity, TransmissionType.GAS))
{ {
loopAll(obj); loopAll(obj);
} }

View file

@ -27,7 +27,7 @@ public final class GasTransmission
{ {
TileEntity tube = Object3D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj); TileEntity tube = Object3D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj);
if(MekanismUtils.checkNetwork(tube, GasNetwork.class)) if(MekanismUtils.checkTransmissionType(tube, TransmissionType.GAS))
{ {
tubes[orientation.ordinal()] = tube; tubes[orientation.ordinal()] = tube;
} }
@ -92,7 +92,7 @@ public final class GasTransmission
{ {
TileEntity pointer = Object3D.get(sender).getFromSide(facing).getTileEntity(sender.worldObj); TileEntity pointer = Object3D.get(sender).getFromSide(facing).getTileEntity(sender.worldObj);
if(MekanismUtils.checkNetwork(pointer, GasNetwork.class)) if(MekanismUtils.checkTransmissionType(pointer, TransmissionType.GAS))
{ {
return ((ITransmitter<GasNetwork>)pointer).getNetwork().emit(amount, type, sender); return ((ITransmitter<GasNetwork>)pointer).getNetwork().emit(amount, type, sender);
} }
@ -118,7 +118,7 @@ public final class GasTransmission
{ {
TileEntity sideTile = Object3D.get(pointer).getFromSide(side).getTileEntity(pointer.worldObj); TileEntity sideTile = Object3D.get(pointer).getFromSide(side).getTileEntity(pointer.worldObj);
if(MekanismUtils.checkNetwork(sideTile, GasNetwork.class)) if(MekanismUtils.checkTransmissionType(sideTile, TransmissionType.GAS))
{ {
networks.add(((ITransmitter<GasNetwork>)sideTile).getNetwork()); networks.add(((ITransmitter<GasNetwork>)sideTile).getNetwork());
} }

View file

@ -4,6 +4,13 @@ import net.minecraft.tileentity.TileEntity;
public interface ITransmitter<N> public interface ITransmitter<N>
{ {
/**
* Get the transmitter's transmission type
*
* @return TransmissionType this transmitter uses
*/
public TransmissionType getTransmissionType();
/** /**
* Gets the network currently in use by this transmitter segment. * Gets the network currently in use by this transmitter segment.
* @return network this transmitter is using * @return network this transmitter is using

View file

@ -0,0 +1,9 @@
package mekanism.api;
public enum TransmissionType
{
ENERGY,
FLUID,
GAS,
ITEM;
}

View file

@ -13,6 +13,7 @@ import mekanism.api.ICableOutputter;
import mekanism.api.IStrictEnergyAcceptor; import mekanism.api.IStrictEnergyAcceptor;
import mekanism.api.ITransmitter; import mekanism.api.ITransmitter;
import mekanism.api.Object3D; import mekanism.api.Object3D;
import mekanism.api.TransmissionType;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.block.IElectrical; import universalelectricity.core.block.IElectrical;
@ -58,7 +59,7 @@ public final class CableUtils
{ {
TileEntity cable = Object3D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj); TileEntity cable = Object3D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj);
if(MekanismUtils.checkNetwork(cable, EnergyNetwork.class)) if(MekanismUtils.checkTransmissionType(cable, TransmissionType.ENERGY))
{ {
cables[orientation.ordinal()] = cable; cables[orientation.ordinal()] = cable;
} }
@ -192,7 +193,7 @@ public final class CableUtils
{ {
TileEntity pointer = Object3D.get(sender).getFromSide(facing).getTileEntity(sender.worldObj); TileEntity pointer = Object3D.get(sender).getFromSide(facing).getTileEntity(sender.worldObj);
if(MekanismUtils.checkNetwork(pointer, EnergyNetwork.class)) if(MekanismUtils.checkTransmissionType(pointer, TransmissionType.ENERGY))
{ {
ITransmitter<EnergyNetwork> cable = (ITransmitter<EnergyNetwork>)pointer; ITransmitter<EnergyNetwork> cable = (ITransmitter<EnergyNetwork>)pointer;
@ -225,7 +226,7 @@ public final class CableUtils
{ {
TileEntity sideTile = Object3D.get(pointer).getFromSide(side).getTileEntity(pointer.worldObj); TileEntity sideTile = Object3D.get(pointer).getFromSide(side).getTileEntity(pointer.worldObj);
if(MekanismUtils.checkNetwork(sideTile, EnergyNetwork.class) && !ignored.contains(sideTile)) if(MekanismUtils.checkTransmissionType(sideTile, TransmissionType.ENERGY) && !ignored.contains(sideTile))
{ {
networks.add(((ITransmitter<EnergyNetwork>)sideTile).getNetwork()); networks.add(((ITransmitter<EnergyNetwork>)sideTile).getNetwork());
} }

View file

@ -283,7 +283,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
{ {
TileEntity connectedBlockA = connectedBlocks[countOne]; TileEntity connectedBlockA = connectedBlocks[countOne];
if(MekanismUtils.checkNetwork(connectedBlockA, EnergyNetwork.class) && !dealtWith[countOne]) if(MekanismUtils.checkTransmissionType(connectedBlockA, TransmissionType.ENERGY) && !dealtWith[countOne])
{ {
NetworkFinder finder = new NetworkFinder(((TileEntity)splitPoint).worldObj, Object3D.get(connectedBlockA), Object3D.get((TileEntity)splitPoint)); NetworkFinder finder = new NetworkFinder(((TileEntity)splitPoint).worldObj, Object3D.get(connectedBlockA), Object3D.get((TileEntity)splitPoint));
List<Object3D> partNetwork = finder.exploreNetwork(); List<Object3D> partNetwork = finder.exploreNetwork();
@ -292,7 +292,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
{ {
TileEntity connectedBlockB = connectedBlocks[countTwo]; TileEntity connectedBlockB = connectedBlocks[countTwo];
if(MekanismUtils.checkNetwork(connectedBlockB, EnergyNetwork.class) && !dealtWith[countTwo]) if(MekanismUtils.checkTransmissionType(connectedBlockB, TransmissionType.ENERGY) && !dealtWith[countTwo])
{ {
if(partNetwork.contains(Object3D.get(connectedBlockB))) if(partNetwork.contains(Object3D.get(connectedBlockB)))
{ {
@ -307,7 +307,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
{ {
TileEntity nodeTile = node.getTileEntity(((TileEntity)splitPoint).worldObj); TileEntity nodeTile = node.getTileEntity(((TileEntity)splitPoint).worldObj);
if(MekanismUtils.checkNetwork(nodeTile, EnergyNetwork.class)) if(MekanismUtils.checkTransmissionType(nodeTile, TransmissionType.ENERGY))
{ {
if(nodeTile != splitPoint) if(nodeTile != splitPoint)
{ {
@ -373,7 +373,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
public void loopAll(Object3D location) public void loopAll(Object3D location)
{ {
if(MekanismUtils.checkNetwork(location.getTileEntity(worldObj), EnergyNetwork.class)) if(MekanismUtils.checkTransmissionType(location.getTileEntity(worldObj), TransmissionType.ENERGY))
{ {
iterated.add(location); iterated.add(location);
} }
@ -386,7 +386,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
{ {
TileEntity tileEntity = obj.getTileEntity(worldObj); TileEntity tileEntity = obj.getTileEntity(worldObj);
if(MekanismUtils.checkNetwork(tileEntity, EnergyNetwork.class)) if(MekanismUtils.checkTransmissionType(tileEntity, TransmissionType.ENERGY))
{ {
loopAll(obj); loopAll(obj);
} }

View file

@ -12,6 +12,7 @@ import java.util.Set;
import mekanism.api.DynamicNetwork; import mekanism.api.DynamicNetwork;
import mekanism.api.ITransmitter; import mekanism.api.ITransmitter;
import mekanism.api.Object3D; import mekanism.api.Object3D;
import mekanism.api.TransmissionType;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
@ -184,7 +185,7 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
{ {
TileEntity connectedBlockA = connectedBlocks[countOne]; TileEntity connectedBlockA = connectedBlocks[countOne];
if(MekanismUtils.checkNetwork(connectedBlockA, FluidNetwork.class) && !dealtWith[countOne]) if(MekanismUtils.checkTransmissionType(connectedBlockA, TransmissionType.FLUID) && !dealtWith[countOne])
{ {
NetworkFinder finder = new NetworkFinder(((TileEntity)splitPoint).worldObj, Object3D.get(connectedBlockA), Object3D.get((TileEntity)splitPoint)); NetworkFinder finder = new NetworkFinder(((TileEntity)splitPoint).worldObj, Object3D.get(connectedBlockA), Object3D.get((TileEntity)splitPoint));
List<Object3D> partNetwork = finder.exploreNetwork(); List<Object3D> partNetwork = finder.exploreNetwork();
@ -193,7 +194,7 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
{ {
TileEntity connectedBlockB = connectedBlocks[countTwo]; TileEntity connectedBlockB = connectedBlocks[countTwo];
if(MekanismUtils.checkNetwork(connectedBlockB, FluidNetwork.class) && !dealtWith[countTwo]) if(MekanismUtils.checkTransmissionType(connectedBlockB, TransmissionType.FLUID) && !dealtWith[countTwo])
{ {
if(partNetwork.contains(Object3D.get(connectedBlockB))) if(partNetwork.contains(Object3D.get(connectedBlockB)))
{ {
@ -208,7 +209,7 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
{ {
TileEntity nodeTile = node.getTileEntity(((TileEntity)splitPoint).worldObj); TileEntity nodeTile = node.getTileEntity(((TileEntity)splitPoint).worldObj);
if(MekanismUtils.checkNetwork(nodeTile, FluidNetwork.class)) if(MekanismUtils.checkTransmissionType(nodeTile, TransmissionType.FLUID))
{ {
if(nodeTile != splitPoint) if(nodeTile != splitPoint)
{ {
@ -239,7 +240,7 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
{ {
TileEntity nodeTile = node.getTileEntity(((TileEntity)pipe).worldObj); TileEntity nodeTile = node.getTileEntity(((TileEntity)pipe).worldObj);
if(MekanismUtils.checkNetwork(nodeTile, FluidNetwork.class)) if(MekanismUtils.checkTransmissionType(nodeTile, TransmissionType.FLUID))
{ {
((ITransmitter<FluidNetwork>)nodeTile).removeFromNetwork(); ((ITransmitter<FluidNetwork>)nodeTile).removeFromNetwork();
newPipes.add((ITransmitter<FluidNetwork>)nodeTile); newPipes.add((ITransmitter<FluidNetwork>)nodeTile);
@ -274,7 +275,7 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
public void loopAll(Object3D location) public void loopAll(Object3D location)
{ {
if(MekanismUtils.checkNetwork(location.getTileEntity(worldObj), FluidNetwork.class)) if(MekanismUtils.checkTransmissionType(location.getTileEntity(worldObj), TransmissionType.FLUID))
{ {
iterated.add(location); iterated.add(location);
} }
@ -287,7 +288,7 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
{ {
TileEntity tileEntity = obj.getTileEntity(worldObj); TileEntity tileEntity = obj.getTileEntity(worldObj);
if(MekanismUtils.checkNetwork(tileEntity, FluidNetwork.class)) if(MekanismUtils.checkTransmissionType(tileEntity, TransmissionType.FLUID))
{ {
loopAll(obj); loopAll(obj);
} }

View file

@ -11,6 +11,7 @@ import java.util.Set;
import mekanism.api.DynamicNetwork; import mekanism.api.DynamicNetwork;
import mekanism.api.ITransmitter; import mekanism.api.ITransmitter;
import mekanism.api.Object3D; import mekanism.api.Object3D;
import mekanism.api.TransmissionType;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -126,7 +127,7 @@ public class InventoryNetwork extends DynamicNetwork<IInventory, InventoryNetwor
{ {
TileEntity connectedBlockA = connectedBlocks[countOne]; TileEntity connectedBlockA = connectedBlocks[countOne];
if(MekanismUtils.checkNetwork(connectedBlockA, InventoryNetwork.class) && !dealtWith[countOne]) if(MekanismUtils.checkTransmissionType(connectedBlockA, TransmissionType.ITEM) && !dealtWith[countOne])
{ {
NetworkFinder finder = new NetworkFinder(((TileEntity)splitPoint).worldObj, Object3D.get(connectedBlockA), Object3D.get((TileEntity)splitPoint)); NetworkFinder finder = new NetworkFinder(((TileEntity)splitPoint).worldObj, Object3D.get(connectedBlockA), Object3D.get((TileEntity)splitPoint));
List<Object3D> partNetwork = finder.exploreNetwork(); List<Object3D> partNetwork = finder.exploreNetwork();
@ -135,7 +136,7 @@ public class InventoryNetwork extends DynamicNetwork<IInventory, InventoryNetwor
{ {
TileEntity connectedBlockB = connectedBlocks[countTwo]; TileEntity connectedBlockB = connectedBlocks[countTwo];
if(MekanismUtils.checkNetwork(connectedBlockB, InventoryNetwork.class) && !dealtWith[countTwo]) if(MekanismUtils.checkTransmissionType(connectedBlockB, TransmissionType.ITEM) && !dealtWith[countTwo])
{ {
if(partNetwork.contains(Object3D.get(connectedBlockB))) if(partNetwork.contains(Object3D.get(connectedBlockB)))
{ {
@ -150,7 +151,7 @@ public class InventoryNetwork extends DynamicNetwork<IInventory, InventoryNetwor
{ {
TileEntity nodeTile = node.getTileEntity(((TileEntity)splitPoint).worldObj); TileEntity nodeTile = node.getTileEntity(((TileEntity)splitPoint).worldObj);
if(MekanismUtils.checkNetwork(nodeTile, InventoryNetwork.class)) if(MekanismUtils.checkTransmissionType(nodeTile, TransmissionType.ITEM))
{ {
if(nodeTile != splitPoint) if(nodeTile != splitPoint)
{ {
@ -181,7 +182,7 @@ public class InventoryNetwork extends DynamicNetwork<IInventory, InventoryNetwor
{ {
TileEntity nodeTile = node.getTileEntity(((TileEntity)transmitter).worldObj); TileEntity nodeTile = node.getTileEntity(((TileEntity)transmitter).worldObj);
if(MekanismUtils.checkNetwork(nodeTile, InventoryNetwork.class)) if(MekanismUtils.checkTransmissionType(nodeTile, TransmissionType.ITEM))
{ {
((ITransmitter<InventoryNetwork>)nodeTile).removeFromNetwork(); ((ITransmitter<InventoryNetwork>)nodeTile).removeFromNetwork();
newTransporters.add((ITransmitter<InventoryNetwork>)nodeTile); newTransporters.add((ITransmitter<InventoryNetwork>)nodeTile);
@ -216,7 +217,7 @@ public class InventoryNetwork extends DynamicNetwork<IInventory, InventoryNetwor
public void loopAll(Object3D location) public void loopAll(Object3D location)
{ {
if(MekanismUtils.checkNetwork(location.getTileEntity(worldObj), InventoryNetwork.class)) if(MekanismUtils.checkTransmissionType(location.getTileEntity(worldObj), TransmissionType.ITEM))
{ {
iterated.add(location); iterated.add(location);
} }
@ -229,7 +230,7 @@ public class InventoryNetwork extends DynamicNetwork<IInventory, InventoryNetwor
{ {
TileEntity tileEntity = obj.getTileEntity(worldObj); TileEntity tileEntity = obj.getTileEntity(worldObj);
if(MekanismUtils.checkNetwork(tileEntity, InventoryNetwork.class)) if(MekanismUtils.checkTransmissionType(tileEntity, TransmissionType.ITEM))
{ {
loopAll(obj); loopAll(obj);
} }

View file

@ -5,6 +5,7 @@ import java.util.ArrayList;
import mekanism.api.EnumColor; import mekanism.api.EnumColor;
import mekanism.api.ITransmitter; import mekanism.api.ITransmitter;
import mekanism.api.TransmitterNetworkRegistry; import mekanism.api.TransmitterNetworkRegistry;
import mekanism.api.TransmissionType;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
@ -29,7 +30,7 @@ public class ItemEnergyMeter extends ItemEnergized
{ {
TileEntity tileEntity = world.getBlockTileEntity(x, y, z); TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if(MekanismUtils.checkNetwork(tileEntity, EnergyNetwork.class)) if(MekanismUtils.checkTransmissionType(tileEntity, TransmissionType.ENERGY))
{ {
if(getEnergy(stack) >= ENERGY_PER_USE) if(getEnergy(stack) >= ENERGY_PER_USE)
{ {

View file

@ -16,6 +16,7 @@ import mekanism.api.IConfigurable;
import mekanism.api.ITransmitter; import mekanism.api.ITransmitter;
import mekanism.api.ITransmitterNetwork; import mekanism.api.ITransmitterNetwork;
import mekanism.api.Object3D; import mekanism.api.Object3D;
import mekanism.api.TransmissionType;
import mekanism.common.IFactory.RecipeType; import mekanism.common.IFactory.RecipeType;
import mekanism.common.IRedstoneControl.RedstoneControl; import mekanism.common.IRedstoneControl.RedstoneControl;
import mekanism.common.PacketHandler.Transmission; import mekanism.common.PacketHandler.Transmission;
@ -960,11 +961,11 @@ public final class MekanismUtils
return false; return false;
} }
public static boolean checkNetwork(TileEntity tileEntity, Class<? extends ITransmitterNetwork> networkClass) public static boolean checkTransmissionType(TileEntity tileEntity, TransmissionType type)
{ {
if(tileEntity instanceof ITransmitter) if(tileEntity instanceof ITransmitter)
{ {
if(((ITransmitter)tileEntity).getNetwork().getClass() == networkClass) if(((ITransmitter<?>)tileEntity).getTransmissionType() == type)
{ {
return true; return true;
} }

View file

@ -4,6 +4,7 @@ import java.util.Arrays;
import mekanism.api.ITransmitter; import mekanism.api.ITransmitter;
import mekanism.api.Object3D; import mekanism.api.Object3D;
import mekanism.api.TransmissionType;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.FluidTankInfo;
@ -24,7 +25,7 @@ public final class PipeUtils
{ {
TileEntity pipe = Object3D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj); TileEntity pipe = Object3D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj);
if(MekanismUtils.checkNetwork(pipe, FluidNetwork.class)) if(MekanismUtils.checkTransmissionType(pipe, TransmissionType.FLUID))
{ {
pipes[orientation.ordinal()] = pipe; pipes[orientation.ordinal()] = pipe;
} }

View file

@ -15,6 +15,7 @@ import java.util.HashSet;
import mekanism.api.ICableOutputter; import mekanism.api.ICableOutputter;
import mekanism.api.IStrictEnergyAcceptor; import mekanism.api.IStrictEnergyAcceptor;
import mekanism.api.Object3D; import mekanism.api.Object3D;
import mekanism.api.TransmissionType;
import mekanism.common.IRedstoneControl.RedstoneControl; import mekanism.common.IRedstoneControl.RedstoneControl;
import mekanism.common.Tier.EnergyCubeTier; import mekanism.common.Tier.EnergyCubeTier;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -74,7 +75,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn
if(electricityStored > 0) if(electricityStored > 0)
{ {
if(MekanismUtils.checkNetwork(tileEntity, EnergyNetwork.class)) if(MekanismUtils.checkTransmissionType(tileEntity, TransmissionType.ENERGY))
{ {
setEnergy(electricityStored - (Math.min(electricityStored, tier.OUTPUT) - CableUtils.emitEnergyToNetwork(Math.min(electricityStored, tier.OUTPUT), this, ForgeDirection.getOrientation(facing)))); setEnergy(electricityStored - (Math.min(electricityStored, tier.OUTPUT) - CableUtils.emitEnergyToNetwork(Math.min(electricityStored, tier.OUTPUT), this, ForgeDirection.getOrientation(facing))));
return; return;

View file

@ -5,6 +5,7 @@ import java.util.HashSet;
import mekanism.api.ITransmitter; import mekanism.api.ITransmitter;
import mekanism.api.Object3D; import mekanism.api.Object3D;
import mekanism.api.TransmissionType;
import mekanism.common.PacketHandler.Transmission; import mekanism.common.PacketHandler.Transmission;
import mekanism.common.network.PacketDataRequest; import mekanism.common.network.PacketDataRequest;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -22,6 +23,12 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
/** This transporter's active state. */ /** This transporter's active state. */
public boolean isActive = false; public boolean isActive = false;
@Override
public TransmissionType getTransmissionType()
{
return TransmissionType.ITEM;
}
@Override @Override
public InventoryNetwork getNetwork(boolean createIfNull) public InventoryNetwork getNetwork(boolean createIfNull)
{ {
@ -33,7 +40,7 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
for(TileEntity transporter : adjacentTransporters) for(TileEntity transporter : adjacentTransporters)
{ {
if(MekanismUtils.checkNetwork(transporter, InventoryNetwork.class) && ((ITransmitter<InventoryNetwork>)transporter).getNetwork(false) != null) if(MekanismUtils.checkTransmissionType(transporter, getTransmissionType()) && ((ITransmitter<InventoryNetwork>)transporter).getNetwork(false) != null)
{ {
connectedNets.add(((ITransmitter<InventoryNetwork>)transporter).getNetwork()); connectedNets.add(((ITransmitter<InventoryNetwork>)transporter).getNetwork());
} }
@ -92,7 +99,7 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
{ {
TileEntity tileEntity = Object3D.get(this).getFromSide(side).getTileEntity(worldObj); TileEntity tileEntity = Object3D.get(this).getFromSide(side).getTileEntity(worldObj);
if(MekanismUtils.checkNetwork(tileEntity, InventoryNetwork.class)) if(MekanismUtils.checkTransmissionType(tileEntity, getTransmissionType()))
{ {
getNetwork().merge(((ITransmitter<InventoryNetwork>)tileEntity).getNetwork()); getNetwork().merge(((ITransmitter<InventoryNetwork>)tileEntity).getNetwork());
} }

View file

@ -6,6 +6,7 @@ import java.util.HashSet;
import mekanism.api.ITransmitter; import mekanism.api.ITransmitter;
import mekanism.api.Object3D; import mekanism.api.Object3D;
import mekanism.api.TransmissionType;
import mekanism.common.PacketHandler.Transmission; import mekanism.common.PacketHandler.Transmission;
import mekanism.common.network.PacketDataRequest; import mekanism.common.network.PacketDataRequest;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -51,6 +52,12 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter<FluidNetwork
} }
} }
@Override
public TransmissionType getTransmissionType()
{
return TransmissionType.FLUID;
}
@Override @Override
public FluidNetwork getNetwork(boolean createIfNull) public FluidNetwork getNetwork(boolean createIfNull)
{ {
@ -61,7 +68,7 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter<FluidNetwork
for(TileEntity pipe : adjacentPipes) for(TileEntity pipe : adjacentPipes)
{ {
if(MekanismUtils.checkNetwork(pipe, FluidNetwork.class) && ((ITransmitter<FluidNetwork>)pipe).getNetwork(false) != null) if(MekanismUtils.checkTransmissionType(pipe, getTransmissionType()) && ((ITransmitter<FluidNetwork>)pipe).getNetwork(false) != null)
{ {
connectedNets.add(((ITransmitter<FluidNetwork>)pipe).getNetwork()); connectedNets.add(((ITransmitter<FluidNetwork>)pipe).getNetwork());
} }
@ -120,7 +127,7 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter<FluidNetwork
{ {
TileEntity tileEntity = Object3D.get(this).getFromSide(side).getTileEntity(worldObj); TileEntity tileEntity = Object3D.get(this).getFromSide(side).getTileEntity(worldObj);
if(MekanismUtils.checkNetwork(tileEntity, FluidNetwork.class)) if(MekanismUtils.checkTransmissionType(tileEntity, getTransmissionType()))
{ {
getNetwork().merge(((ITransmitter<FluidNetwork>)tileEntity).getNetwork()); getNetwork().merge(((ITransmitter<FluidNetwork>)tileEntity).getNetwork());
} }

View file

@ -8,6 +8,7 @@ import mekanism.api.GasTransmission;
import mekanism.api.ITransmitter; import mekanism.api.ITransmitter;
import mekanism.api.ITubeConnection; import mekanism.api.ITubeConnection;
import mekanism.api.Object3D; import mekanism.api.Object3D;
import mekanism.api.TransmissionType;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
@ -19,6 +20,12 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter<GasNetwork>
/** The scale of the gas (0F -> 1F) currently inside this tube. */ /** The scale of the gas (0F -> 1F) currently inside this tube. */
public float gasScale; public float gasScale;
@Override
public TransmissionType getTransmissionType()
{
return TransmissionType.ITEM;
}
@Override @Override
public GasNetwork getNetwork(boolean createIfNull) public GasNetwork getNetwork(boolean createIfNull)
{ {
@ -29,7 +36,7 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter<GasNetwork>
for(TileEntity tube : adjacentTubes) for(TileEntity tube : adjacentTubes)
{ {
if(MekanismUtils.checkNetwork(tube, GasNetwork.class) && ((ITransmitter<GasNetwork>)tube).getNetwork(false) != null) if(MekanismUtils.checkTransmissionType(tube, TransmissionType.GAS) && ((ITransmitter<GasNetwork>)tube).getNetwork(false) != null)
{ {
connectedNets.add(((ITransmitter<GasNetwork>)tube).getNetwork()); connectedNets.add(((ITransmitter<GasNetwork>)tube).getNetwork());
} }
@ -88,7 +95,7 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter<GasNetwork>
{ {
TileEntity tileEntity = Object3D.get(this).getFromSide(side).getTileEntity(worldObj); TileEntity tileEntity = Object3D.get(this).getFromSide(side).getTileEntity(worldObj);
if(MekanismUtils.checkNetwork(tileEntity, GasNetwork.class)) if(MekanismUtils.checkTransmissionType(tileEntity, TransmissionType.GAS))
{ {
getNetwork().merge(((ITransmitter<GasNetwork>)tileEntity).getNetwork()); getNetwork().merge(((ITransmitter<GasNetwork>)tileEntity).getNetwork());
} }

View file

@ -3,6 +3,7 @@ package mekanism.common;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import mekanism.api.ITransmitter; import mekanism.api.ITransmitter;
import mekanism.api.TransmissionType;
import mekanism.api.TransmitterNetworkRegistry; import mekanism.api.TransmitterNetworkRegistry;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
@ -38,7 +39,7 @@ public abstract class TileEntityTransmitter<N> extends TileEntity implements ITr
@Override @Override
public boolean areNetworksEqual(TileEntity tileEntity) public boolean areNetworksEqual(TileEntity tileEntity)
{ {
return tileEntity instanceof ITransmitter && getNetwork().getClass() == ((ITransmitter)tileEntity).getNetwork().getClass(); return tileEntity instanceof ITransmitter && getTransmissionType() == ((ITransmitter)tileEntity).getTransmissionType();
} }
@Override @Override

View file

@ -4,6 +4,7 @@ import java.util.HashSet;
import mekanism.api.ITransmitter; import mekanism.api.ITransmitter;
import mekanism.api.Object3D; import mekanism.api.Object3D;
import mekanism.api.TransmissionType;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
@ -24,6 +25,12 @@ public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwor
powerHandler.configure(0, 100, 0, 100); powerHandler.configure(0, 100, 0, 100);
} }
@Override
public TransmissionType getTransmissionType()
{
return TransmissionType.ENERGY;
}
@Override @Override
public boolean canUpdate() public boolean canUpdate()
{ {
@ -40,7 +47,7 @@ public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwor
for(TileEntity cable : adjacentCables) for(TileEntity cable : adjacentCables)
{ {
if(MekanismUtils.checkNetwork(cable, EnergyNetwork.class) && ((ITransmitter<EnergyNetwork>)cable).getNetwork(false) != null) if(MekanismUtils.checkTransmissionType(cable, TransmissionType.ENERGY) && ((ITransmitter<EnergyNetwork>)cable).getNetwork(false) != null)
{ {
connectedNets.add(((ITransmitter<EnergyNetwork>)cable).getNetwork()); connectedNets.add(((ITransmitter<EnergyNetwork>)cable).getNetwork());
} }
@ -99,7 +106,7 @@ public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwor
{ {
TileEntity tileEntity = Object3D.get(this).getFromSide(side).getTileEntity(worldObj); TileEntity tileEntity = Object3D.get(this).getFromSide(side).getTileEntity(worldObj);
if(MekanismUtils.checkNetwork(tileEntity, EnergyNetwork.class)) if(MekanismUtils.checkTransmissionType(tileEntity, TransmissionType.ENERGY))
{ {
getNetwork().merge(((ITransmitter<EnergyNetwork>)tileEntity).getNetwork()); getNetwork().merge(((ITransmitter<EnergyNetwork>)tileEntity).getNetwork());
} }

View file

@ -4,6 +4,7 @@ import java.util.Arrays;
import mekanism.api.ITransmitter; import mekanism.api.ITransmitter;
import mekanism.api.Object3D; import mekanism.api.Object3D;
import mekanism.api.TransmissionType;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.ISidedInventory;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
@ -24,7 +25,7 @@ public final class TransporterUtils
{ {
TileEntity transporter = Object3D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj); TileEntity transporter = Object3D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj);
if(MekanismUtils.checkNetwork(transporter, InventoryNetwork.class)) if(MekanismUtils.checkTransmissionType(transporter, TransmissionType.ITEM))
{ {
transporters[orientation.ordinal()] = transporter; transporters[orientation.ordinal()] = transporter;
} }

View file

@ -12,6 +12,7 @@ import java.util.EnumSet;
import mekanism.api.ICableOutputter; import mekanism.api.ICableOutputter;
import mekanism.api.Object3D; import mekanism.api.Object3D;
import mekanism.api.TransmissionType;
import mekanism.client.IHasSound; import mekanism.client.IHasSound;
import mekanism.common.CableUtils; import mekanism.common.CableUtils;
import mekanism.common.EnergyNetwork; import mekanism.common.EnergyNetwork;
@ -104,7 +105,7 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
if(electricityStored > 0) if(electricityStored > 0)
{ {
if(MekanismUtils.checkNetwork(tileEntity, EnergyNetwork.class)) if(MekanismUtils.checkTransmissionType(tileEntity, TransmissionType.ENERGY))
{ {
setEnergy(electricityStored - (Math.min(electricityStored, output) - CableUtils.emitEnergyToNetwork(Math.min(electricityStored, output), this, ForgeDirection.getOrientation(facing)))); setEnergy(electricityStored - (Math.min(electricityStored, output) - CableUtils.emitEnergyToNetwork(Math.min(electricityStored, output), this, ForgeDirection.getOrientation(facing))));
} }