Transmitter code cleanup - killed the now-unused merge() method and separated data handlers from ITransmitterNetwork itself. Also added new pipe textures.

This commit is contained in:
Aidan C. Brady 2014-07-09 15:31:57 -04:00
parent f405a9e2f0
commit ee87d8cef5
18 changed files with 45 additions and 94 deletions

View file

@ -346,19 +346,6 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork>
}
}
@Override
public synchronized void merge(GasNetwork network)
{
if(network != null && network != this)
{
Set<GasNetwork> networks = new HashSet();
networks.add(this);
networks.add(network);
GasNetwork newNetwork = create(networks);
newNetwork.fullRefresh();
}
}
public static class GasTransferEvent extends Event
{
public final GasNetwork gasNetwork;
@ -471,19 +458,19 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork>
}
@Override
public String getNeeded()
public String getNeededInfo()
{
return Integer.toString(getGasNeeded());
}
@Override
public String getStored()
public String getStoredInfo()
{
return gasStored != null ? gasStored.getGas().getLocalizedName() + " (" + gasStored.amount + ")" : "None";
}
@Override
public String getFlow()
public String getFlowInfo()
{
return Integer.toString(prevTransferAmount) + "/t";
}

View file

@ -21,7 +21,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.Event;
public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implements ITransmitterNetwork<A, N>, IClientTicker
public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implements ITransmitterNetwork<A, N>, IClientTicker, INetworkDataHandler
{
public LinkedHashSet<IGridTransmitter<N>> transmitters = new LinkedHashSet<IGridTransmitter<N>>();

View file

@ -0,0 +1,10 @@
package mekanism.api.transmitters;
public interface INetworkDataHandler
{
public String getNeededInfo();
public String getStoredInfo();
public String getFlowInfo();
}

View file

@ -11,12 +11,6 @@ public interface ITransmitterNetwork<A, N extends DynamicNetwork<A, N>>
public int getAcceptorSize();
public String getNeeded();
public String getStored();
public String getFlow();
public Set<A> getAcceptors(Object... data);
public void removeTransmitter(IGridTransmitter<N> transmitter);
@ -29,8 +23,6 @@ public interface ITransmitterNetwork<A, N extends DynamicNetwork<A, N>>
public void split(IGridTransmitter<N> splitPoint);
public void merge(N network);
public void fixMessedUpNetwork(IGridTransmitter<N> transmitter);
public void register();

View file

@ -357,19 +357,6 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
}
}
@Override
public synchronized void merge(EnergyNetwork network)
{
if(network != null && network != this)
{
Set<EnergyNetwork> networks = new HashSet<EnergyNetwork>();
networks.add(this);
networks.add(network);
EnergyNetwork newNetwork = create(networks);
newNetwork.fullRefresh();
}
}
public static class EnergyTransferEvent extends Event
{
public final EnergyNetwork energyNetwork;
@ -473,20 +460,20 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
}
@Override
public String getNeeded()
public String getNeededInfo()
{
return MekanismUtils.getEnergyDisplay(getEnergyNeeded());
}
@Override
public String getStored()
public String getStoredInfo()
{
return MekanismUtils.getEnergyDisplay(electricityStored);
}
@Override
public String getFlow()
public String getFlowInfo()
{
return MekanismUtils.getEnergyDisplay(20*joulesTransmitted) + " per second";
return MekanismUtils.getEnergyDisplay(joulesTransmitted) + "/t";
}
}

View file

@ -359,19 +359,6 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
}
}
@Override
public synchronized void merge(FluidNetwork network)
{
if(network != null && network != this)
{
Set<FluidNetwork> networks = new HashSet<FluidNetwork>();
networks.add(this);
networks.add(network);
FluidNetwork newNetwork = create(networks);
newNetwork.fullRefresh();
}
}
public static class FluidTransferEvent extends Event
{
public final FluidNetwork fluidNetwork;
@ -486,20 +473,20 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
}
@Override
public String getNeeded()
public String getNeededInfo()
{
return "Fluid needed: " + (float)getFluidNeeded()/1000F + " buckets";
return (float)getFluidNeeded()/1000F + " buckets";
}
@Override
public String getStored()
public String getStoredInfo()
{
return fluidStored == null ? "None" : fluidStored.getFluid().getLocalizedName() + ", " + fluidStored.amount + "mB";
return fluidStored != null ? fluidStored.getFluid().getLocalizedName(fluidStored) + " (" + fluidStored.amount + " mB)" : "None";
}
@Override
public String getFlow()
public String getFlowInfo()
{
return Integer.toString(prevTransferAmount) + "mB/t";
return Integer.toString(prevTransferAmount) + " mB/t";
}
}

View file

@ -139,11 +139,11 @@ public final class Tier
{
case 4:
return BASIC;
case 9:
case 5:
return ADVANCED;
case 10:
case 6:
return ELITE;
case 11:
case 7:
return ULTIMATE;
default:
return BASIC;

View file

@ -37,10 +37,10 @@ public class ItemNetworkReader extends ItemEnergized
player.addChatMessage(new ChatComponentText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------"));
player.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Transmitters: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getSize()));
player.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Acceptors: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getAcceptorSize()));
player.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Needed: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getNeeded()));
player.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Buffer: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getStored()));
player.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Throughput: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getFlow()));
player.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Capacity: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getCapacity() + "/tick"));
player.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Needed: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getNeededInfo()));
player.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Buffer: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getStoredInfo()));
player.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Throughput: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getFlowInfo()));
player.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Capacity: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getCapacity()));
player.addChatMessage(new ChatComponentText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------"));
}
}

View file

@ -30,7 +30,7 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork> implements
/** The fake tank used for fluid transfer calculations. */
public FluidTank dummyTank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
public static TransmitterIcons pipeIcons = new TransmitterIcons(2, 1);
public static TransmitterIcons pipeIcons = new TransmitterIcons(4, 1);
public float currentScale;
@ -198,14 +198,15 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork> implements
public static void registerIcons(IIconRegister register)
{
pipeIcons.registerCenterIcons(register, new String[] {"MechanicalPipe", "MechanicalPipeActive"});
pipeIcons.registerCenterIcons(register, new String[] {"MechanicalPipeBasic", "MechanicalPipeAdvanced",
"MechanicalPipeElite", "MechanicalPipeUltimate"});
pipeIcons.registerSideIcons(register, new String[] {"MechanicalPipeSide"});
}
@Override
public IIcon getCenterIcon()
{
return pipeIcons.getCenterIcon(0);
return pipeIcons.getCenterIcon(tier.ordinal());
}
@Override
@ -221,7 +222,10 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork> implements
}
@Override
public TransmitterType getTransmitter() { return tier.type; }
public TransmitterType getTransmitter()
{
return tier.type;
}
@Override
public boolean isValidAcceptor(TileEntity tile, ForgeDirection side)
@ -312,13 +316,13 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork> implements
@Override
public String getTransmitterNetworkNeeded()
{
return getTransmitterNetwork().getNeeded();
return getTransmitterNetwork().getNeededInfo();
}
@Override
public String getTransmitterNetworkFlow()
{
return getTransmitterNetwork().getFlow();
return getTransmitterNetwork().getFlowInfo();
}
@Override

View file

@ -232,13 +232,13 @@ public class PartPressurizedTube extends PartTransmitter<GasNetwork> implements
@Override
public String getTransmitterNetworkNeeded()
{
return getTransmitterNetwork().getNeeded();
return getTransmitterNetwork().getNeededInfo();
}
@Override
public String getTransmitterNetworkFlow()
{
return getTransmitterNetwork().getFlow();
return getTransmitterNetwork().getFlowInfo();
}
@Override

View file

@ -38,22 +38,6 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?, N>> extends Pa
@Override
public void refreshTransmitterNetwork()
{
byte possibleTransmitters = getPossibleTransmitterConnections();
byte possibleAcceptors = getPossibleAcceptorConnections();
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{
if(connectionMapContainsSide(possibleTransmitters, side))
{
TileEntity tileEntity = Coord4D.get(tile()).getFromSide(side).getTileEntity(world());
if(TransmissionType.checkTransmissionType(tileEntity, getTransmissionType()))
{
((DynamicNetwork<?,N>)getTransmitterNetwork()).merge(((IGridTransmitter<N>)tileEntity).getTransmitterNetwork());
}
}
}
((DynamicNetwork<?,N>)getTransmitterNetwork()).refresh(this);
((DynamicNetwork<?,N>)getTransmitterNetwork()).refresh();
}

View file

@ -256,13 +256,13 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
@Override
public String getTransmitterNetworkNeeded()
{
return getTransmitterNetwork().getNeeded();
return getTransmitterNetwork().getNeededInfo();
}
@Override
public String getTransmitterNetworkFlow()
{
return getTransmitterNetwork().getFlow();
return getTransmitterNetwork().getFlowInfo();
}
@Override

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB