A few attempts to get multipart working. @unpairedbracket, I don’t know what the hell I’m doing, you’re gonna need to go over this.

This commit is contained in:
Aidan Brady 2013-12-02 22:14:21 -05:00
parent 5d8e21b776
commit 50b7870388
24 changed files with 195 additions and 429 deletions

View file

@ -17,7 +17,7 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.Event;
import cpw.mods.fml.common.FMLCommonHandler;
public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork, Gas>
{
public int transferDelay = 0;
@ -27,13 +27,13 @@ public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
public float gasScale;
public Gas refGas = null;
public GasNetwork(ITransmitter<GasNetwork>... varPipes)
public GasNetwork(ITransmitter<GasNetwork, Gas>... varPipes)
{
transmitters.addAll(Arrays.asList(varPipes));
register();
}
public GasNetwork(Collection<ITransmitter<GasNetwork>> collection)
public GasNetwork(Collection<ITransmitter<GasNetwork, Gas>> collection)
{
transmitters.addAll(collection);
register();
@ -181,15 +181,15 @@ public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
@Override
public synchronized void refresh()
{
Set<ITransmitter<GasNetwork>> iterTubes = (Set<ITransmitter<GasNetwork>>)transmitters.clone();
Iterator<ITransmitter<GasNetwork>> it = iterTubes.iterator();
Set<ITransmitter<GasNetwork, Gas>> iterTubes = (Set<ITransmitter<GasNetwork, Gas>>)transmitters.clone();
Iterator<ITransmitter<GasNetwork, Gas>> it = iterTubes.iterator();
possibleAcceptors.clear();
acceptorDirections.clear();
while(it.hasNext())
{
ITransmitter<GasNetwork> conductor = (ITransmitter<GasNetwork>)it.next();
ITransmitter<GasNetwork, Gas> conductor = (ITransmitter<GasNetwork, Gas>)it.next();
if(conductor == null || ((TileEntity)conductor).isInvalid())
{
@ -201,7 +201,7 @@ public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
}
}
for(ITransmitter<GasNetwork> pipe : transmitters)
for(ITransmitter<GasNetwork, Gas> pipe : transmitters)
{
IGasAcceptor[] acceptors = GasTransmission.getConnectedAcceptors((TileEntity)pipe);
@ -251,7 +251,7 @@ public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
}
@Override
protected GasNetwork create(ITransmitter<GasNetwork>... varTransmitters)
protected GasNetwork create(ITransmitter<GasNetwork, Gas>... varTransmitters)
{
GasNetwork network = new GasNetwork(varTransmitters);
network.refGas = refGas;
@ -260,7 +260,7 @@ public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
}
@Override
protected GasNetwork create(Collection<ITransmitter<GasNetwork>> collection)
protected GasNetwork create(Collection<ITransmitter<GasNetwork, Gas>> collection)
{
GasNetwork network = new GasNetwork(collection);
network.refGas = refGas;

View file

@ -97,7 +97,7 @@ public final class GasTransmission
if(TransmissionType.checkTransmissionType(pointer, TransmissionType.GAS, sender))
{
return ((ITransmitter<GasNetwork>)pointer).getTransmitterNetwork().emit(stack, sender);
return ((ITransmitter<GasNetwork, Gas>)pointer).getTransmitterNetwork().emit(stack, sender);
}
return 0;

View file

@ -3,7 +3,7 @@ package mekanism.api.gas;
import mekanism.api.transmitters.ITransmitter;
import net.minecraft.tileentity.TileEntity;
public interface IGasTransmitter extends ITransmitter<GasNetwork, EnumGas>
public interface IGasTransmitter extends ITransmitter<GasNetwork, Gas>
{
public boolean canTransferGasToTube(TileEntity tile);
}

View file

@ -20,9 +20,9 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.Event;
import cpw.mods.fml.common.FMLCommonHandler;
public abstract class DynamicNetwork<A, N> implements ITransmitterNetwork<A, N>, IClientTicker
public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N, D>, D> implements ITransmitterNetwork<A, N, D>, IClientTicker
{
public HashSet<ITransmitter<N>> transmitters = new HashSet<ITransmitter<N>>();
public HashSet<ITransmitter<N, D>> transmitters = new HashSet<ITransmitter<N, D>>();
public HashSet<A> possibleAcceptors = new HashSet<A>();
public HashMap<A, ForgeDirection> acceptorDirections = new HashMap<A, ForgeDirection>();
@ -35,19 +35,19 @@ public abstract class DynamicNetwork<A, N> implements ITransmitterNetwork<A, N>,
protected boolean needsUpdate = false;
protected abstract ITransmitterNetwork<A, N> create(ITransmitter<N>... varTransmitters);
protected abstract ITransmitterNetwork<A, N, D> create(ITransmitter<N, D>... varTransmitters);
protected abstract ITransmitterNetwork<A, N> create(Collection<ITransmitter<N>> collection);
protected abstract ITransmitterNetwork<A, N, D> create(Collection<ITransmitter<N, D>> collection);
protected abstract ITransmitterNetwork<A, N> create(Set<N> networks);
protected abstract ITransmitterNetwork<A, N, D> create(Set<N> networks);
public void addAllTransmitters(Set<ITransmitter<N>> newTransmitters)
public void addAllTransmitters(Set<ITransmitter<N, D>> newTransmitters)
{
transmitters.addAll(newTransmitters);
}
@Override
public void removeTransmitter(ITransmitter<N> transmitter)
public void removeTransmitter(ITransmitter<N, D> transmitter)
{
transmitters.remove(transmitter);
@ -61,7 +61,7 @@ public abstract class DynamicNetwork<A, N> implements ITransmitterNetwork<A, N>,
public void register()
{
try {
ITransmitter<N> aTransmitter = transmitters.iterator().next();
ITransmitter<N, D> aTransmitter = transmitters.iterator().next();
if(aTransmitter instanceof TileEntity)
{
@ -137,13 +137,13 @@ public abstract class DynamicNetwork<A, N> implements ITransmitterNetwork<A, N>,
}
@Override
public synchronized void fixMessedUpNetwork(ITransmitter<N> transmitter)
public synchronized void fixMessedUpNetwork(ITransmitter<N, D> transmitter)
{
if(transmitter instanceof TileEntity)
{
NetworkFinder finder = new NetworkFinder(((TileEntity)transmitter).getWorldObj(), getTransmissionType(), Object3D.get((TileEntity)transmitter));
List<Object3D> partNetwork = finder.exploreNetwork();
Set<ITransmitter<N>> newTransporters = new HashSet<ITransmitter<N>>();
Set<ITransmitter<N, D>> newTransporters = new HashSet<ITransmitter<N, D>>();
for(Object3D node : partNetwork)
{
@ -151,12 +151,12 @@ public abstract class DynamicNetwork<A, N> implements ITransmitterNetwork<A, N>,
if(TransmissionType.checkTransmissionType(nodeTile, getTransmissionType(), (TileEntity)transmitter))
{
((ITransmitter<N>)nodeTile).removeFromTransmitterNetwork();
newTransporters.add((ITransmitter<N>)nodeTile);
((ITransmitter<N, D>)nodeTile).removeFromTransmitterNetwork();
newTransporters.add((ITransmitter<N, D>)nodeTile);
}
}
ITransmitterNetwork<A, N> newNetwork = create(newTransporters);
ITransmitterNetwork<A, N, D> newNetwork = create(newTransporters);
newNetwork.refresh();
newNetwork.setFixed(true);
deregister();
@ -164,7 +164,7 @@ public abstract class DynamicNetwork<A, N> implements ITransmitterNetwork<A, N>,
}
@Override
public synchronized void split(ITransmitter<N> splitPoint)
public synchronized void split(ITransmitter<N, D> splitPoint)
{
if(splitPoint instanceof TileEntity)
{
@ -205,7 +205,7 @@ public abstract class DynamicNetwork<A, N> implements ITransmitterNetwork<A, N>,
}
}
Set<ITransmitter<N>> newNetCables = new HashSet<ITransmitter<N>>();
Set<ITransmitter<N, D>> newNetCables = new HashSet<ITransmitter<N, D>>();
for(Object3D node : finder.iterated)
{
@ -215,12 +215,12 @@ public abstract class DynamicNetwork<A, N> implements ITransmitterNetwork<A, N>,
{
if(nodeTile != splitPoint)
{
newNetCables.add((ITransmitter<N>)nodeTile);
newNetCables.add((ITransmitter<N, D>)nodeTile);
}
}
}
ITransmitterNetwork<A, N> newNetwork = create(newNetCables);
ITransmitterNetwork<A, N, D> newNetwork = create(newNetCables);
newNetwork.refresh();
}
}

View file

@ -64,13 +64,14 @@ public interface ITransmitter<N extends DynamicNetwork<?, N, D>, D>
* and the tile in the given direction isn't prevented from connecting.
*/
public boolean canConnectMutual(ForgeDirection side);
/**
* Update a client-side transmitter. This tells the client how much the
* transmitter is transmitting.
* @param data Should represent what the transmitter can transmit.
*/
public void clientUpdate(D data);
public boolean areTransmitterNetworksEqual(TileEntity tileEntity);
public int getTransmitterNetworkSize();
public int getTransmitterNetworkAcceptorSize();
public String getTransmitterNetworkNeeded();
public String getTransmitterNetworkFlow();
}

View file

@ -1,41 +0,0 @@
package mekanism.client;
import java.util.List;
import mekanism.api.transmitters.ITransmitter;
import mekanism.api.transmitters.TransmissionType;
import mekanism.api.transmitters.DynamicNetwork.NetworkFinder;
import mekanism.api.Object3D;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class EnergyClientUpdate
{
public NetworkFinder finder;
public World worldObj;
public double energyScale;
public EnergyClientUpdate(TileEntity head, double power)
{
worldObj = head.worldObj;
energyScale = power;
finder = new NetworkFinder(head.worldObj, TransmissionType.ENERGY, Object3D.get(head));
}
public void clientUpdate()
{
List<Object3D> found = finder.exploreNetwork();
System.out.println(energyScale);
for(Object3D object : found)
{
TileEntity tileEntity = object.getTileEntity(worldObj);
if(tileEntity instanceof ITransmitter && ((ITransmitter<?, ?>)tileEntity).getTransmissionType() == TransmissionType.ENERGY)
{
((ITransmitter<?, Double>)tileEntity).clientUpdate(energyScale);
}
}
}
}

View file

@ -1,42 +0,0 @@
package mekanism.client;
import java.util.List;
import mekanism.api.transmitters.ITransmitter;
import mekanism.api.transmitters.TransmissionType;
import mekanism.api.transmitters.DynamicNetwork.NetworkFinder;
import mekanism.api.Object3D;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
public class FluidClientUpdate
{
public NetworkFinder finder;
public World worldObj;
public FluidStack fluidStack;
public FluidClientUpdate(TileEntity head, FluidStack fluid)
{
worldObj = head.worldObj;
fluidStack = fluid;
finder = new NetworkFinder(head.worldObj, TransmissionType.FLUID, Object3D.get(head));
}
public void clientUpdate()
{
List<Object3D> found = finder.exploreNetwork();
for(Object3D object : found)
{
TileEntity tileEntity = object.getTileEntity(worldObj);
if(tileEntity instanceof ITransmitter && ((ITransmitter<?,?>)tileEntity).getTransmissionType() == TransmissionType.FLUID)
{
((ITransmitter<?, FluidStack>)tileEntity).clientUpdate(fluidStack);
}
}
}
}

View file

@ -1,42 +0,0 @@
package mekanism.client;
import java.util.List;
import mekanism.api.gas.EnumGas;
import mekanism.api.transmitters.ITransmitter;
import mekanism.api.transmitters.TransmissionType;
import mekanism.api.transmitters.DynamicNetwork.NetworkFinder;
import mekanism.api.Object3D;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class GasClientUpdate
{
public NetworkFinder finder;
public World worldObj;
public EnumGas gasType;
public GasClientUpdate(TileEntity head, EnumGas type)
{
worldObj = head.worldObj;
gasType = type;
finder = new NetworkFinder(head.worldObj, TransmissionType.GAS, Object3D.get(head));
}
public void clientUpdate()
{
List<Object3D> found = finder.exploreNetwork();
for(Object3D object : found)
{
TileEntity tileEntity = object.getTileEntity(worldObj);
if(tileEntity instanceof ITransmitter && ((ITransmitter<?, ?>)tileEntity).getTransmissionType() == TransmissionType.GAS)
{
((ITransmitter<?,EnumGas>)tileEntity).clientUpdate(gasType);
}
}
}
}

View file

@ -3,6 +3,21 @@ package mekanism.client.render;
import java.util.HashMap;
import java.util.Map;
import mekanism.api.transmitters.TransmissionType;
import mekanism.client.render.MekanismRenderer.DisplayInteger;
import mekanism.client.render.MekanismRenderer.Model3D;
import mekanism.common.multipart.PartMechanicalPipe;
import mekanism.common.multipart.PartPressurizedTube;
import mekanism.common.multipart.PartTransmitter;
import mekanism.common.multipart.PartUniversalCable;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import org.lwjgl.opengl.GL11;
import codechicken.lib.colour.Colour;
@ -16,21 +31,6 @@ import codechicken.lib.render.TextureUtils;
import codechicken.lib.render.TextureUtils.IIconRegister;
import codechicken.lib.vec.Translation;
import codechicken.lib.vec.Vector3;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import mekanism.api.transmitters.TransmissionType;
import mekanism.client.render.MekanismRenderer.DisplayInteger;
import mekanism.client.render.MekanismRenderer.Model3D;
import mekanism.common.multipart.PartLogisticalTransporter;
import mekanism.common.multipart.PartMechanicalPipe;
import mekanism.common.multipart.PartPressurizedTube;
import mekanism.common.multipart.PartTransmitter;
import mekanism.common.multipart.PartUniversalCable;
public class RenderPartTransmitter implements IIconRegister
{
@ -39,7 +39,6 @@ public class RenderPartTransmitter implements IIconRegister
public static Icon[] uniCableTextures = new Icon[2];
public static Icon[] mechPipeTextures = new Icon[2];
public static Icon[] pressTubeTextures = new Icon[2];
public static Icon[] logiTransporterTextures = new Icon[2];
public static Icon liquidEnergyTexture;
public static Icon sideTexture;
public static Map<TransmissionType, Icon[]> typeMap = new HashMap<TransmissionType, Icon[]>();
@ -69,7 +68,6 @@ public class RenderPartTransmitter implements IIconRegister
typeMap.put(TransmissionType.ENERGY, uniCableTextures);
typeMap.put(TransmissionType.FLUID, mechPipeTextures);
typeMap.put(TransmissionType.GAS, pressTubeTextures);
typeMap.put(TransmissionType.ITEM, logiTransporterTextures);
}
public static RenderPartTransmitter getInstance()
@ -131,7 +129,7 @@ public class RenderPartTransmitter implements IIconRegister
MekanismRenderer.glowOn();
}
CCRenderState.changeTexture((MekanismRenderer.getLiquidTexture()));
CCRenderState.changeTexture((MekanismRenderer.getBlocksTexture()));
GL11.glTranslated(pos.x, pos.y, pos.z);
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
@ -296,11 +294,6 @@ public class RenderPartTransmitter implements IIconRegister
System.out.println("specific");
}
public void renderContents(PartLogisticalTransporter transmitter, Vector3 pos)
{
System.out.println("specific");
}
public void renderStatic(PartTransmitter<?, ?> transmitter)
{
TextureUtils.bindAtlas(0);
@ -357,8 +350,6 @@ public class RenderPartTransmitter implements IIconRegister
pressTubeTextures[1] = pressTubeTextures[0];
mechPipeTextures[0] = register.registerIcon("mekanism:models/MechanicalPipe");
mechPipeTextures[1] = register.registerIcon("mekanism:models/MechanicalPipeActive");
logiTransporterTextures[0] = register.registerIcon("mekanism:models/LogisticalTransporter");
logiTransporterTextures[1] = register.registerIcon("mekanism:models/LogisticalTransporterActive");
liquidEnergyTexture = register.registerIcon("mekanism:LiquidEnergy");
}

View file

@ -26,7 +26,7 @@ import universalelectricity.core.electricity.ElectricityPack;
import cofh.api.energy.IEnergyHandler;
import cpw.mods.fml.common.FMLCommonHandler;
public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork, Double>
{
private double lastPowerScale = 0;
private double joulesTransmitted = 0;
@ -34,13 +34,13 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
public double clientEnergyScale = 0;
public EnergyNetwork(ITransmitter<EnergyNetwork>... varCables)
public EnergyNetwork(ITransmitter<EnergyNetwork, Double>... varCables)
{
transmitters.addAll(Arrays.asList(varCables));
register();
}
public EnergyNetwork(Collection<ITransmitter<EnergyNetwork>> collection)
public EnergyNetwork(Collection<ITransmitter<EnergyNetwork, Double>> collection)
{
transmitters.addAll(collection);
register();
@ -277,15 +277,15 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
@Override
public synchronized void refresh()
{
Set<ITransmitter<EnergyNetwork>> iterCables = (Set<ITransmitter<EnergyNetwork>>)transmitters.clone();
Iterator<ITransmitter<EnergyNetwork>> it = iterCables.iterator();
Set<ITransmitter<EnergyNetwork, Double>> iterCables = (Set<ITransmitter<EnergyNetwork, Double>>)transmitters.clone();
Iterator<ITransmitter<EnergyNetwork, Double>> it = iterCables.iterator();
possibleAcceptors.clear();
acceptorDirections.clear();
while(it.hasNext())
{
ITransmitter<EnergyNetwork> conductor = (ITransmitter<EnergyNetwork>)it.next();
ITransmitter<EnergyNetwork, Double> conductor = (ITransmitter<EnergyNetwork, Double>)it.next();
if(conductor == null || ((TileEntity)conductor).isInvalid())
{
@ -297,7 +297,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
}
}
for(ITransmitter<EnergyNetwork> cable : iterCables)
for(ITransmitter<EnergyNetwork, Double> cable : iterCables)
{
TileEntity[] acceptors = CableUtils.getConnectedEnergyAcceptors((TileEntity)cable);
@ -389,7 +389,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
}
@Override
protected EnergyNetwork create(ITransmitter<EnergyNetwork>... varTransmitters)
protected EnergyNetwork create(ITransmitter<EnergyNetwork, Double>... varTransmitters)
{
EnergyNetwork network = new EnergyNetwork(varTransmitters);
network.clientEnergyScale = clientEnergyScale;
@ -400,7 +400,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
}
@Override
protected EnergyNetwork create(Collection<ITransmitter<EnergyNetwork>> collection)
protected EnergyNetwork create(Collection<ITransmitter<EnergyNetwork, Double>> collection)
{
EnergyNetwork network = new EnergyNetwork(collection);
network.clientEnergyScale = clientEnergyScale;

View file

@ -9,7 +9,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
import mekanism.api.gas.GasNetwork;
import mekanism.api.transmitters.DynamicNetwork;
import mekanism.api.transmitters.ITransmitter;
import mekanism.api.transmitters.TransmissionType;
@ -24,7 +23,7 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler;
import cpw.mods.fml.common.FMLCommonHandler;
public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork, FluidStack>
{
public int transferDelay = 0;
@ -34,13 +33,13 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
public float fluidScale;
public Fluid refFluid = null;
public FluidNetwork(ITransmitter<FluidNetwork>... varPipes)
public FluidNetwork(ITransmitter<FluidNetwork, FluidStack>... varPipes)
{
transmitters.addAll(Arrays.asList(varPipes));
register();
}
public FluidNetwork(Collection<ITransmitter<FluidNetwork>> collection)
public FluidNetwork(Collection<ITransmitter<FluidNetwork, FluidStack>> collection)
{
transmitters.addAll(collection);
register();
@ -201,7 +200,7 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
@Override
public synchronized void refresh()
{
Set<ITransmitter<FluidNetwork>> iterPipes = (Set<ITransmitter<FluidNetwork>>)transmitters.clone();
Set<ITransmitter<FluidNetwork, FluidStack>> iterPipes = (Set<ITransmitter<FluidNetwork, FluidStack>>)transmitters.clone();
Iterator it = iterPipes.iterator();
possibleAcceptors.clear();
@ -209,7 +208,7 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
while(it.hasNext())
{
ITransmitter<FluidNetwork> conductor = (ITransmitter<FluidNetwork>)it.next();
ITransmitter<FluidNetwork, FluidStack> conductor = (ITransmitter<FluidNetwork, FluidStack>)it.next();
if(conductor == null || ((TileEntity)conductor).isInvalid())
{
@ -221,7 +220,7 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
}
}
for(ITransmitter<FluidNetwork> pipe : iterPipes)
for(ITransmitter<FluidNetwork, FluidStack> pipe : iterPipes)
{
if(pipe instanceof TileEntityMechanicalPipe && ((TileEntityMechanicalPipe)pipe).isActive) continue;
@ -273,7 +272,7 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
}
@Override
protected FluidNetwork create(ITransmitter<FluidNetwork>... varTransmitters)
protected FluidNetwork create(ITransmitter<FluidNetwork, FluidStack>... varTransmitters)
{
FluidNetwork network = new FluidNetwork(varTransmitters);
network.refFluid = refFluid;
@ -282,7 +281,7 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
}
@Override
protected FluidNetwork create(Collection<ITransmitter<FluidNetwork>> collection)
protected FluidNetwork create(Collection<ITransmitter<FluidNetwork, FluidStack>> collection)
{
FluidNetwork network = new FluidNetwork(collection);
network.refFluid = refFluid;

View file

@ -1,145 +0,0 @@
package mekanism.common;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import mekanism.api.transmitters.DynamicNetwork;
import mekanism.api.transmitters.ITransmitter;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.util.TransporterUtils;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
public class InventoryNetwork extends DynamicNetwork<IInventory, InventoryNetwork, ItemStack>
{
public InventoryNetwork(ITransmitter<InventoryNetwork, ItemStack>... varTransporters)
{
transmitters.addAll(Arrays.asList(varTransporters));
register();
}
public InventoryNetwork(Collection<ITransmitter<InventoryNetwork, ItemStack>> collection)
{
transmitters.addAll(collection);
register();
}
public InventoryNetwork(Set<InventoryNetwork> networks)
{
for(InventoryNetwork net : networks)
{
if(net != null)
{
addAllTransmitters(net.transmitters);
net.deregister();
}
}
refresh();
register();
}
@Override
public Set<IInventory> getAcceptors(Object... data)
{
return null;
}
@Override
public void refresh()
{
Set<ITransmitter<InventoryNetwork, ItemStack>> iterTransmitters = (Set<ITransmitter<InventoryNetwork, ItemStack>>)transmitters.clone();
Iterator it = iterTransmitters.iterator();
possibleAcceptors.clear();
acceptorDirections.clear();
while(it.hasNext())
{
ITransmitter<InventoryNetwork, ItemStack> conductor = (ITransmitter<InventoryNetwork, ItemStack>)it.next();
if(conductor == null || ((TileEntity)conductor).isInvalid())
{
it.remove();
transmitters.remove(conductor);
}
else {
conductor.setTransmitterNetwork(this);
}
}
for(ITransmitter<InventoryNetwork, ItemStack> transmitter : iterTransmitters)
{
IInventory[] inventories = TransporterUtils.getConnectedInventories((TileEntity)transmitter);
for(IInventory inventory : inventories)
{
if(inventory != null && !(inventory instanceof ITransmitter))
{
possibleAcceptors.add(inventory);
acceptorDirections.put(inventory, ForgeDirection.getOrientation(Arrays.asList(inventories).indexOf(inventory)));
}
}
}
}
@Override
public void merge(InventoryNetwork network)
{
if(network != null && network != this)
{
Set<InventoryNetwork> networks = new HashSet<InventoryNetwork>();
networks.add(this);
networks.add(network);
InventoryNetwork newNetwork = new InventoryNetwork(networks);
newNetwork.refresh();
}
}
@Override
public String toString()
{
return "[InventoryNetwork] " + transmitters.size() + " transmitters, " + possibleAcceptors.size() + " acceptors.";
}
@Override
protected InventoryNetwork create(ITransmitter<InventoryNetwork, ItemStack>... varTransmitters)
{
return new InventoryNetwork(varTransmitters);
}
@Override
protected InventoryNetwork create(Collection<ITransmitter<InventoryNetwork, ItemStack>> collection)
{
return new InventoryNetwork(collection);
}
@Override
protected InventoryNetwork create(Set<InventoryNetwork> networks)
{
return new InventoryNetwork(networks);
}
@Override
public TransmissionType getTransmissionType()
{
return TransmissionType.ITEM;
}
@Override
public String getFlow()
{
return "Undefined for Inventory networks";
}
@Override
public String getNeeded()
{
return "Undefined for Inventory Networks";
}
}

View file

@ -60,6 +60,7 @@ import mekanism.common.item.ItemPortableTeleporter;
import mekanism.common.item.ItemProxy;
import mekanism.common.item.ItemRobit;
import mekanism.common.item.ItemWalkieTalkie;
import mekanism.common.multipart.ItemPartTransmitter;
import mekanism.common.network.PacketConfigurationUpdate;
import mekanism.common.network.PacketConfiguratorState;
import mekanism.common.network.PacketDataRequest;
@ -206,6 +207,7 @@ public class Mekanism
public static Item NetworkReader;
public static Item WalkieTalkie;
public static Item ItemProxy;
public static Item PartTransmitter;
//Blocks
public static Block BasicBlock;
@ -568,6 +570,7 @@ public class Mekanism
NetworkReader = new ItemNetworkReader(configuration.getItem("NetworkReader", 11222).getInt()).setUnlocalizedName("NetworkReader");
//OPEN 11223
WalkieTalkie = new ItemWalkieTalkie(configuration.getItem("WalkieTalkie", 11224).getInt()).setUnlocalizedName("WalkieTalkie");
PartTransmitter = new ItemPartTransmitter(configuration.getItem("MultipartTransmitter", 11223).getInt()).setUnlocalizedName("MultipartTransmitter");
configuration.save();
//Registrations

View file

@ -16,8 +16,6 @@ public class MultipartMekanism implements IPartFactory
return new PartMechanicalPipe();
if(name == "mekanism:pressurized_tube")
return new PartPressurizedTube();
if(name == "mekanism:logistical_transporter")
return new PartLogisticalTransporter();
return null;
}

View file

@ -1,45 +0,0 @@
package mekanism.common.multipart;
import java.util.Set;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import mekanism.api.transmitters.ITransmitter;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.InventoryNetwork;
public class PartLogisticalTransporter extends PartTransmitter<InventoryNetwork, ItemStack>
{
@Override
public String getType()
{
return "mekanism:logistical_transporter";
}
@Override
public TransmissionType getTransmissionType()
{
return TransmissionType.ITEM;
}
@Override
public boolean isValidAcceptor(TileEntity tile, ForgeDirection side)
{
return tile instanceof IInventory;
}
@Override
public InventoryNetwork createNetworkFromSingleTransmitter(ITransmitter<InventoryNetwork, ItemStack> transmitter)
{
return new InventoryNetwork(transmitter);
}
@Override
public InventoryNetwork createNetworkByMergingSet(Set<InventoryNetwork> networks)
{
return new InventoryNetwork(networks);
}
}

View file

@ -161,4 +161,31 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork, FluidStack
}
}
}
@Override
public void chunkLoad() {}
@Override
public int getTransmitterNetworkSize()
{
return getTransmitterNetwork().getSize();
}
@Override
public int getTransmitterNetworkAcceptorSize()
{
return getTransmitterNetwork().getAcceptorSize();
}
@Override
public String getTransmitterNetworkNeeded()
{
return getTransmitterNetwork().getNeeded();
}
@Override
public String getTransmitterNetworkFlow()
{
return getTransmitterNetwork().getFlow();
}
}

View file

@ -2,7 +2,7 @@ package mekanism.common.multipart;
import java.util.Set;
import mekanism.api.gas.EnumGas;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasNetwork;
import mekanism.api.gas.IGasAcceptor;
import mekanism.api.transmitters.ITransmitter;
@ -10,7 +10,7 @@ import mekanism.api.transmitters.TransmissionType;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
public class PartPressurizedTube extends PartTransmitter<GasNetwork, EnumGas>
public class PartPressurizedTube extends PartTransmitter<GasNetwork, Gas>
{
@Override
public String getType()
@ -31,7 +31,7 @@ public class PartPressurizedTube extends PartTransmitter<GasNetwork, EnumGas>
}
@Override
public GasNetwork createNetworkFromSingleTransmitter(ITransmitter<GasNetwork, EnumGas> transmitter)
public GasNetwork createNetworkFromSingleTransmitter(ITransmitter<GasNetwork, Gas> transmitter)
{
return new GasNetwork(transmitter);
}
@ -41,4 +41,35 @@ public class PartPressurizedTube extends PartTransmitter<GasNetwork, EnumGas>
{
return new GasNetwork(networks);
}
@Override
public void chunkLoad()
{
// TODO Auto-generated method stub
}
@Override
public int getTransmitterNetworkSize()
{
return getTransmitterNetwork().getSize();
}
@Override
public int getTransmitterNetworkAcceptorSize()
{
return getTransmitterNetwork().getAcceptorSize();
}
@Override
public String getTransmitterNetworkNeeded()
{
return getTransmitterNetwork().getNeeded();
}
@Override
public String getTransmitterNetworkFlow()
{
return getTransmitterNetwork().getFlow();
}
}

View file

@ -70,8 +70,6 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?,N, D>, D> exten
return new PartMechanicalPipe();
case GAS:
return new PartPressurizedTube();
case ITEM:
return new PartLogisticalTransporter();
default:
return null;
}
@ -412,12 +410,6 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?,N, D>, D> exten
return Collections.singletonList(new ItemStack(Mekanism.PartTransmitter, 1, getTransmissionType().ordinal()));
}
@Override
public void clientUpdate(D data)
{
transmitting = data;
}
@Override
public void preRemove()
{

View file

@ -104,12 +104,6 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork, Double>
RenderPartTransmitter.getInstance().renderContents(this, pos);
}
@Override
public void clientUpdate(Double level)
{
setLevel = level;
}
@Override
public void update()
{
@ -123,4 +117,33 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork, Double>
}
}
}
@Override
public void chunkLoad()
{
}
@Override
public int getTransmitterNetworkSize()
{
return getTransmitterNetwork().getSize();
}
@Override
public int getTransmitterNetworkAcceptorSize()
{
return getTransmitterNetwork().getAcceptorSize();
}
@Override
public String getTransmitterNetworkNeeded()
{
return getTransmitterNetwork().getNeeded();
}
@Override
public String getTransmitterNetworkFlow()
{
return getTransmitterNetwork().getFlow();
}
}

View file

@ -31,7 +31,7 @@ import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TileEntityMechanicalPipe extends TileEntityTransmitter<FluidNetwork> implements IFluidHandler
public class TileEntityMechanicalPipe extends TileEntityTransmitter<FluidNetwork, FluidStack> implements IFluidHandler
{
/** The fake tank used for fluid transfer calculations. */
public FluidTank dummyTank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
@ -55,9 +55,9 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter<FluidNetwork
for(TileEntity pipe : adjacentPipes)
{
if(TransmissionType.checkTransmissionType(pipe, getTransmissionType()) && ((ITransmitter<FluidNetwork>)pipe).getTransmitterNetwork(false) != null)
if(TransmissionType.checkTransmissionType(pipe, getTransmissionType()) && ((ITransmitter<FluidNetwork, FluidStack>)pipe).getTransmitterNetwork(false) != null)
{
connectedNets.add(((ITransmitter<FluidNetwork>)pipe).getTransmitterNetwork());
connectedNets.add(((ITransmitter<FluidNetwork, FluidStack>)pipe).getTransmitterNetwork());
}
}
@ -124,7 +124,7 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter<FluidNetwork
if(TransmissionType.checkTransmissionType(tileEntity, getTransmissionType()))
{
getTransmitterNetwork().merge(((ITransmitter<FluidNetwork>)tileEntity).getTransmitterNetwork());
getTransmitterNetwork().merge(((ITransmitter<FluidNetwork, FluidStack>)tileEntity).getTransmitterNetwork());
}
}

View file

@ -3,6 +3,7 @@ package mekanism.common.tileentity;
import java.util.HashSet;
import mekanism.api.Object3D;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasNetwork;
import mekanism.api.gas.GasTransmission;
import mekanism.api.gas.IGasTransmitter;
@ -10,13 +11,10 @@ import mekanism.api.gas.ITubeConnection;
import mekanism.api.transmitters.ITransmitter;
import mekanism.api.transmitters.TransmissionType;
import mekanism.api.transmitters.TransmitterNetworkRegistry;
import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission;
import mekanism.common.network.PacketDataRequest;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
public class TileEntityPressurizedTube extends TileEntityTransmitter<GasNetwork> implements ITubeConnection, IGasTransmitter
public class TileEntityPressurizedTube extends TileEntityTransmitter<GasNetwork, Gas> implements ITubeConnection, IGasTransmitter
{
@Override
public TransmissionType getTransmissionType()
@ -34,9 +32,9 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter<GasNetwork>
for(TileEntity tube : adjacentTubes)
{
if(TransmissionType.checkTransmissionType(tube, TransmissionType.GAS, this) && ((ITransmitter<GasNetwork>)tube).getTransmitterNetwork(false) != null)
if(TransmissionType.checkTransmissionType(tube, TransmissionType.GAS, this) && ((ITransmitter<GasNetwork, Gas>)tube).getTransmitterNetwork(false) != null)
{
connectedNets.add(((ITransmitter<GasNetwork>)tube).getTransmitterNetwork());
connectedNets.add(((ITransmitter<GasNetwork, Gas>)tube).getTransmitterNetwork());
}
}
@ -103,7 +101,7 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter<GasNetwork>
if(TransmissionType.checkTransmissionType(tileEntity, TransmissionType.GAS, this))
{
getTransmitterNetwork().merge(((ITransmitter<GasNetwork>)tileEntity).getTransmitterNetwork());
getTransmitterNetwork().merge(((ITransmitter<GasNetwork, Gas>)tileEntity).getTransmitterNetwork());
}
}

View file

@ -2,6 +2,8 @@ package mekanism.common.tileentity;
import java.util.ArrayList;
import mekanism.api.Object3D;
import mekanism.api.transmitters.DynamicNetwork;
import mekanism.api.transmitters.ITransmitter;
import mekanism.api.transmitters.TransmitterNetworkRegistry;
import mekanism.common.IConfigurable;
@ -9,6 +11,7 @@ import mekanism.common.ITileNetwork;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.ForgeDirection;
import com.google.common.io.ByteArrayDataInput;
@ -16,7 +19,7 @@ import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public abstract class TileEntityTransmitter<N> extends TileEntity implements ITransmitter<N>, ITileNetwork, IConfigurable
public abstract class TileEntityTransmitter<N extends DynamicNetwork<?, N, D>, D> extends TileEntity implements ITransmitter<N, D>, ITileNetwork, IConfigurable
{
public N theNetwork;
@ -75,6 +78,21 @@ public abstract class TileEntityTransmitter<N> extends TileEntity implements ITr
}
}
@Override
public boolean canConnectMutual(ForgeDirection side)
{
if(!canConnect(side)) return false;
TileEntity tile = Object3D.get(this).getFromSide(side).getTileEntity(worldObj);
return (!(tile instanceof ITransmitter) || ((ITransmitter<?, ?>)tile).canConnect(side.getOpposite()));
}
@Override
public boolean canConnect(ForgeDirection side)
{
return true;
}
@Override
public boolean areTransmitterNetworksEqual(TileEntity tileEntity)
{

View file

@ -22,7 +22,7 @@ import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.core.grid.IElectricityNetwork;
import cofh.api.energy.IEnergyHandler;
public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwork> implements IEnergySink, IEnergyHandler, IElectrical
public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwork, Double> implements IEnergySink, IEnergyHandler, IElectrical
{
/** A fake UE ElectricityNetwork used to accept power from EU machines */
public IElectricityNetwork ueNetwork;
@ -45,9 +45,9 @@ public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwor
for(TileEntity cable : adjacentCables)
{
if(TransmissionType.checkTransmissionType(cable, TransmissionType.ENERGY) && ((ITransmitter<EnergyNetwork>)cable).getTransmitterNetwork(false) != null)
if(TransmissionType.checkTransmissionType(cable, TransmissionType.ENERGY) && ((ITransmitter<EnergyNetwork, Double>)cable).getTransmitterNetwork(false) != null)
{
connectedNets.add(((ITransmitter<EnergyNetwork>)cable).getTransmitterNetwork());
connectedNets.add(((ITransmitter<EnergyNetwork, Double>)cable).getTransmitterNetwork());
}
}
@ -123,7 +123,7 @@ public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwor
if(TransmissionType.checkTransmissionType(tileEntity, TransmissionType.ENERGY))
{
getTransmitterNetwork().merge(((ITransmitter<EnergyNetwork>)tileEntity).getTransmitterNetwork());
getTransmitterNetwork().merge(((ITransmitter<EnergyNetwork, Double>)tileEntity).getTransmitterNetwork());
}
}

View file

@ -193,7 +193,7 @@ public final class CableUtils
if(TransmissionType.checkTransmissionType(pointer, TransmissionType.ENERGY))
{
ITransmitter<EnergyNetwork> cable = (ITransmitter<EnergyNetwork>)pointer;
ITransmitter<EnergyNetwork, Double> cable = (ITransmitter<EnergyNetwork, Double>)pointer;
ArrayList<TileEntity> ignored = new ArrayList<TileEntity>();
ignored.add(sender);