Work on Mechanical Pipes
This commit is contained in:
parent
a601def4f6
commit
cf0ad408dd
9 changed files with 157 additions and 115 deletions
|
@ -30,14 +30,9 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork>
|
|||
public boolean prevTransfer;
|
||||
|
||||
public float gasScale;
|
||||
public float prevScale;
|
||||
|
||||
/** Sent from server to client, actual stored buffer scale. Used by server as last-update scale. */
|
||||
public float definedScale;
|
||||
|
||||
public Gas refGas = null;
|
||||
|
||||
public GasStack gasStored;
|
||||
public int prevStored;
|
||||
|
||||
public GasNetwork(ITransmitter<GasNetwork>... varPipes)
|
||||
{
|
||||
|
@ -57,17 +52,11 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork>
|
|||
{
|
||||
if(net != null)
|
||||
{
|
||||
if(net.refGas != null && net.gasScale > gasScale)
|
||||
if(net.gasScale > gasScale)
|
||||
{
|
||||
refGas = net.refGas;
|
||||
gasScale = net.gasScale;
|
||||
}
|
||||
|
||||
if(net.definedScale > definedScale)
|
||||
{
|
||||
definedScale = net.definedScale;
|
||||
}
|
||||
|
||||
if(net.gasStored != null)
|
||||
{
|
||||
if(gasStored == null)
|
||||
|
@ -207,18 +196,19 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork>
|
|||
transferDelay--;
|
||||
}
|
||||
|
||||
if(Math.abs(getScale()-definedScale) > 0.01 || (getScale() != prevScale && (getScale() == 0 || getScale() == 1)))
|
||||
int stored = gasStored != null ? gasStored.amount : 0;
|
||||
|
||||
if(stored != prevStored)
|
||||
{
|
||||
needsUpdate = true;
|
||||
}
|
||||
|
||||
prevScale = getScale();
|
||||
prevStored = stored;
|
||||
|
||||
if(didTransfer != prevTransfer || needsUpdate)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new GasTransferEvent(this, gasStored != null ? gasStored.getGas().getID() : -1, didTransfer, getScale()));
|
||||
MinecraftForge.EVENT_BUS.post(new GasTransferEvent(this, gasStored, didTransfer));
|
||||
needsUpdate = false;
|
||||
definedScale = getScale();
|
||||
}
|
||||
|
||||
prevTransfer = didTransfer;
|
||||
|
@ -240,19 +230,19 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork>
|
|||
{
|
||||
super.clientTick();
|
||||
|
||||
gasScale = Math.max(gasScale, definedScale);
|
||||
gasScale = Math.max(gasScale, getScale());
|
||||
|
||||
if(didTransfer && gasScale < 1)
|
||||
{
|
||||
gasScale = Math.max(definedScale, Math.min(1, gasScale+0.02F));
|
||||
gasScale = Math.max(getScale(), Math.min(1, gasScale+0.02F));
|
||||
}
|
||||
else if(!didTransfer && gasScale > 0)
|
||||
{
|
||||
gasScale = Math.max(definedScale, Math.max(0, gasScale-0.02F));
|
||||
gasScale = Math.max(getScale(), Math.max(0, gasScale-0.02F));
|
||||
|
||||
if(gasScale == 0)
|
||||
{
|
||||
refGas = null;
|
||||
gasStored = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -334,16 +324,14 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork>
|
|||
{
|
||||
public final GasNetwork gasNetwork;
|
||||
|
||||
public final int transferType;
|
||||
public final GasStack transferType;
|
||||
public final boolean didTransfer;
|
||||
public final float gasScale;
|
||||
|
||||
public GasTransferEvent(GasNetwork network, int type, boolean did, float scale)
|
||||
public GasTransferEvent(GasNetwork network, GasStack type, boolean did)
|
||||
{
|
||||
gasNetwork = network;
|
||||
transferType = type;
|
||||
didTransfer = did;
|
||||
gasScale = scale;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -362,9 +350,7 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork>
|
|||
protected GasNetwork create(ITransmitter<GasNetwork>... varTransmitters)
|
||||
{
|
||||
GasNetwork network = new GasNetwork(varTransmitters);
|
||||
network.refGas = refGas;
|
||||
network.gasScale = gasScale;
|
||||
network.definedScale = definedScale;
|
||||
|
||||
if(gasStored != null)
|
||||
{
|
||||
|
@ -384,9 +370,7 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork>
|
|||
protected GasNetwork create(Collection<ITransmitter<GasNetwork>> collection)
|
||||
{
|
||||
GasNetwork network = new GasNetwork(collection);
|
||||
network.refGas = refGas;
|
||||
network.gasScale = gasScale;
|
||||
network.definedScale = definedScale;
|
||||
|
||||
if(gasStored != null)
|
||||
{
|
||||
|
|
|
@ -166,8 +166,13 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
|||
|
||||
if(TransmissionType.checkTransmissionType(nodeTile, getTransmissionType(), (TileEntity)transmitter))
|
||||
{
|
||||
((ITransmitter<N>)nodeTile).removeFromTransmitterNetwork();
|
||||
newTransporters.add((ITransmitter<N>)nodeTile);
|
||||
ITransmitter<N> trans = (ITransmitter<N>)nodeTile;
|
||||
|
||||
if(trans.getTransmitterNetwork(false) == null || isValidMerger(nodeTile))
|
||||
{
|
||||
((ITransmitter<N>)nodeTile).removeFromTransmitterNetwork();
|
||||
newTransporters.add((ITransmitter<N>)nodeTile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,7 +208,7 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
|||
{
|
||||
TileEntity connectedBlockA = connectedBlocks[count];
|
||||
|
||||
if(TransmissionType.checkTransmissionType(connectedBlockA, getTransmissionType()) && !dealtWith[count])
|
||||
if(TransmissionType.checkTransmissionType(connectedBlockA, getTransmissionType()) && isValidMerger(connectedBlockA) && !dealtWith[count])
|
||||
{
|
||||
NetworkFinder finder = new NetworkFinder(((TileEntity)splitPoint).worldObj, getTransmissionType(), Object3D.get(connectedBlockA), Object3D.get((TileEntity)splitPoint));
|
||||
List<Object3D> partNetwork = finder.exploreNetwork();
|
||||
|
@ -217,7 +222,7 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
|||
|
||||
TileEntity connectedBlockB = connectedBlocks[check];
|
||||
|
||||
if(TransmissionType.checkTransmissionType(connectedBlockB, getTransmissionType()) && !dealtWith[check])
|
||||
if(TransmissionType.checkTransmissionType(connectedBlockB, getTransmissionType()) && isValidMerger(connectedBlockB) && !dealtWith[check])
|
||||
{
|
||||
if(partNetwork.contains(Object3D.get(connectedBlockB)))
|
||||
{
|
||||
|
@ -259,6 +264,11 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isValidMerger(TileEntity tileEntity)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNetworksCreated(List<N> networks) {}
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ public class RenderPartTransmitter implements IIconRegister
|
|||
Fluid fluid = pipe.getTransmitterNetwork().refFluid;
|
||||
float scale = pipe.currentScale;
|
||||
|
||||
if(scale > 0 && fluid != null)
|
||||
if(scale > 0.01 && fluid != null)
|
||||
{
|
||||
push();
|
||||
|
||||
|
@ -315,7 +315,7 @@ public class RenderPartTransmitter implements IIconRegister
|
|||
|
||||
public void renderContents(PartPressurizedTube tube, Vector3 pos)
|
||||
{
|
||||
if(tube.getTransmitterNetwork().refGas == null || tube.getTransmitterNetwork().gasScale == 0)
|
||||
if(tube.getTransmitterNetwork().gasStored == null || tube.getTransmitterNetwork().gasScale == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -366,7 +366,7 @@ public class RenderPartTransmitter implements IIconRegister
|
|||
public void renderGasSide(ForgeDirection side, PartPressurizedTube tube)
|
||||
{
|
||||
boolean connected = PartTransmitter.connectionMapContainsSide(tube.getAllCurrentConnections(), side);
|
||||
renderTransparency(tube.getTransmitterNetwork().refGas.getIcon(), tube.getModelForSide(side, true), new ColourRGBA(1.0, 1.0, 1.0, tube.currentScale));
|
||||
renderTransparency(tube.getTransmitterNetwork().gasStored.getGas().getIcon(), tube.getModelForSide(side, true), new ColourRGBA(1.0, 1.0, 1.0, tube.currentScale));
|
||||
}
|
||||
|
||||
public void renderPart(Icon icon, CCModel cc, double x, double y, double z)
|
||||
|
|
|
@ -113,7 +113,7 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
|
|||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
Gas gasType = tileEntity.getTransmitterNetwork().refGas;
|
||||
Gas gasType = tileEntity.getTransmitterNetwork().gasStored != null ? tileEntity.getTransmitterNetwork().gasStored.getGas() : null;
|
||||
float scale = tileEntity.getTransmitterNetwork().gasScale;
|
||||
|
||||
if(scale > 0 && gasType != null && gasType.getIcon() != null)
|
||||
|
|
|
@ -35,14 +35,11 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
|
|||
public boolean prevTransfer;
|
||||
|
||||
public float fluidScale;
|
||||
public float prevScale;
|
||||
|
||||
/** Sent from server to client, actual stored buffer scale. Used by server as last-update scale. */
|
||||
public float definedScale;
|
||||
|
||||
public Fluid refFluid = null;
|
||||
public Fluid refFluid;
|
||||
|
||||
public FluidStack fluidStored;
|
||||
public int prevStored;
|
||||
|
||||
public FluidNetwork(ITransmitter<FluidNetwork>... varPipes)
|
||||
{
|
||||
|
@ -62,17 +59,11 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
|
|||
{
|
||||
if(net != null)
|
||||
{
|
||||
if(net.refFluid != null && net.fluidScale > fluidScale)
|
||||
if(net.fluidScale > fluidScale)
|
||||
{
|
||||
refFluid = net.refFluid;
|
||||
fluidScale = net.fluidScale;
|
||||
}
|
||||
|
||||
if(net.definedScale > definedScale)
|
||||
{
|
||||
definedScale = net.definedScale;
|
||||
}
|
||||
|
||||
if(net.fluidStored != null)
|
||||
{
|
||||
if(fluidStored == null)
|
||||
|
@ -211,18 +202,19 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
|
|||
transferDelay--;
|
||||
}
|
||||
|
||||
if(Math.abs(getScale()-definedScale) > 0.01 || (getScale() != prevScale && (getScale() == 0 || getScale() == 1)))
|
||||
int stored = fluidStored != null ? fluidStored.amount : 0;
|
||||
|
||||
if(stored != prevStored)
|
||||
{
|
||||
needsUpdate = true;
|
||||
}
|
||||
|
||||
prevScale = getScale();
|
||||
prevStored = stored;
|
||||
|
||||
if(didTransfer != prevTransfer || needsUpdate)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new FluidTransferEvent(this, fluidStored != null ? fluidStored.getFluid().getID() : -1, didTransfer, getScale()));
|
||||
MinecraftForge.EVENT_BUS.post(new FluidTransferEvent(this, fluidStored, didTransfer));
|
||||
needsUpdate = false;
|
||||
definedScale = getScale();
|
||||
}
|
||||
|
||||
prevTransfer = didTransfer;
|
||||
|
@ -239,24 +231,41 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidMerger(TileEntity tileEntity)
|
||||
{
|
||||
ITransmitter<FluidNetwork> transmitter = (ITransmitter<FluidNetwork>)tileEntity;
|
||||
|
||||
if(fluidStored == null || transmitter.getTransmitterNetwork(false) == null || transmitter.getTransmitterNetwork().fluidStored == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(fluidStored.getFluid() == transmitter.getTransmitterNetwork().fluidStored.getFluid())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientTick()
|
||||
{
|
||||
super.clientTick();
|
||||
|
||||
fluidScale = Math.max(fluidScale, definedScale);
|
||||
fluidScale = Math.max(fluidScale, getScale());
|
||||
|
||||
if(didTransfer && fluidScale < 1)
|
||||
{
|
||||
fluidScale = Math.max(definedScale, Math.min(1, fluidScale+0.02F));
|
||||
fluidScale = Math.max(getScale(), Math.min(1, fluidScale+0.02F));
|
||||
}
|
||||
else if(!didTransfer && fluidScale > 0)
|
||||
{
|
||||
fluidScale = Math.max(definedScale, Math.max(0, fluidScale-0.02F));
|
||||
fluidScale = Math.max(getScale(), Math.max(0, fluidScale-0.02F));
|
||||
|
||||
if(fluidScale == 0)
|
||||
{
|
||||
refFluid = null;
|
||||
fluidStored = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -340,16 +349,14 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
|
|||
{
|
||||
public final FluidNetwork fluidNetwork;
|
||||
|
||||
public final int fluidType;
|
||||
public final FluidStack fluidType;
|
||||
public final boolean didTransfer;
|
||||
public final float fluidScale;
|
||||
|
||||
public FluidTransferEvent(FluidNetwork network, int type, boolean did, float scale)
|
||||
public FluidTransferEvent(FluidNetwork network, FluidStack type, boolean did)
|
||||
{
|
||||
fluidNetwork = network;
|
||||
fluidType = type;
|
||||
didTransfer = did;
|
||||
fluidScale = scale;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -368,9 +375,7 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
|
|||
protected FluidNetwork create(ITransmitter<FluidNetwork>... varTransmitters)
|
||||
{
|
||||
FluidNetwork network = new FluidNetwork(varTransmitters);
|
||||
network.refFluid = refFluid;
|
||||
network.fluidScale = fluidScale;
|
||||
network.definedScale = definedScale;
|
||||
|
||||
if(fluidStored != null)
|
||||
{
|
||||
|
@ -390,9 +395,7 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
|
|||
protected FluidNetwork create(Collection<ITransmitter<FluidNetwork>> collection)
|
||||
{
|
||||
FluidNetwork network = new FluidNetwork(collection);
|
||||
network.refFluid = refFluid;
|
||||
network.fluidScale = fluidScale;
|
||||
network.definedScale = definedScale;
|
||||
|
||||
if(fluidStored != null)
|
||||
{
|
||||
|
|
|
@ -1324,7 +1324,7 @@ public class Mekanism
|
|||
public void onGasTransferred(GasTransferEvent event)
|
||||
{
|
||||
try {
|
||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTransmitterUpdate().setParams(PacketType.GAS, event.gasNetwork.transmitters.iterator().next(), event.transferType, event.didTransfer, event.gasScale));
|
||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTransmitterUpdate().setParams(PacketType.GAS, event.gasNetwork.transmitters.iterator().next(), event.transferType, event.didTransfer));
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
|
||||
|
@ -1332,7 +1332,7 @@ public class Mekanism
|
|||
public void onLiquidTransferred(FluidTransferEvent event)
|
||||
{
|
||||
try {
|
||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTransmitterUpdate().setParams(PacketType.FLUID, event.fluidNetwork.transmitters.iterator().next(), event.fluidType, event.didTransfer, event.fluidScale));
|
||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTransmitterUpdate().setParams(PacketType.FLUID, event.fluidNetwork.transmitters.iterator().next(), event.fluidType, event.didTransfer));
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package mekanism.common.multipart;
|
|||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.transmitters.ITransmitter;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.client.render.PartTransmitterIcons;
|
||||
|
@ -56,14 +56,14 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork> implements
|
|||
cacheFluid = null;
|
||||
}
|
||||
|
||||
if(isActive)
|
||||
{
|
||||
IFluidHandler[] connectedAcceptors = PipeUtils.getConnectedAcceptors(tile());
|
||||
|
||||
for(IFluidHandler container : connectedAcceptors)
|
||||
{
|
||||
ForgeDirection side = ForgeDirection.getOrientation(Arrays.asList(connectedAcceptors).indexOf(container));
|
||||
|
||||
IFluidHandler[] connectedAcceptors = PipeUtils.getConnectedAcceptors(tile());
|
||||
|
||||
for(ForgeDirection side : getConnections(ConnectionType.PULL))
|
||||
{
|
||||
if(connectedAcceptors[side.ordinal()] != null)
|
||||
{
|
||||
IFluidHandler container = connectedAcceptors[side.ordinal()];
|
||||
|
||||
if(container != null)
|
||||
{
|
||||
FluidStack received = container.drain(side, 100, false);
|
||||
|
@ -73,7 +73,7 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork> implements
|
|||
container.drain(side.getOpposite(), getTransmitterNetwork().emit(received, true), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,27 +146,51 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork> implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnectable(TileEntity tileEntity)
|
||||
public boolean canConnect(ForgeDirection side)
|
||||
{
|
||||
if(!super.canConnect(side))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntity tileEntity = Object3D.get(tile()).getFromSide(side).getTileEntity(world());
|
||||
|
||||
if(tileEntity instanceof ITransmitter && TransmissionType.checkTransmissionType(tileEntity, getTransmissionType()))
|
||||
{
|
||||
ITransmitter<FluidNetwork> transmitter = (ITransmitter<FluidNetwork>)tileEntity;
|
||||
|
||||
if(world().isRemote && transmitter.getTransmitterNetwork(false) == null)
|
||||
{
|
||||
if(!connectionMapContainsSide(currentTransmitterConnections, side))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(getTransmitterNetwork(false) == null || transmitter.getTransmitterNetwork(false) == null)
|
||||
{
|
||||
return true;
|
||||
if(transmitter.getTransmitterNetwork(false) == null || transmitter.getTransmitterNetwork(false).fluidStored == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(getTransmitterNetwork().fluidStored == null || transmitter.getTransmitterNetwork().fluidStored == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(getTransmitterNetwork().fluidStored.getFluid() == transmitter.getTransmitterNetwork().fluidStored.getFluid())
|
||||
|
||||
if(getTransmitterNetwork(false) != null && transmitter.getTransmitterNetwork(false) != null)
|
||||
{
|
||||
return true;
|
||||
if(getTransmitterNetwork().fluidStored.getFluid() == transmitter.getTransmitterNetwork().fluidStored.getFluid())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -185,7 +209,7 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork> implements
|
|||
@Override
|
||||
public Icon getCenterIcon()
|
||||
{
|
||||
return pipeIcons.getCenterIcon(isActive ? 1 : 0);
|
||||
return pipeIcons.getCenterIcon(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -228,7 +252,7 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork> implements
|
|||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
if(!isActive)
|
||||
if(this.getConnectionType(from) == ConnectionType.NORMAL)
|
||||
{
|
||||
return getTransmitterNetwork().emit(resource, doFill);
|
||||
}
|
||||
|
@ -263,7 +287,12 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork> implements
|
|||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||
{
|
||||
return new FluidTankInfo[] {dummyTank.getInfo()};
|
||||
if(getConnectionType(from) != ConnectionType.NONE)
|
||||
{
|
||||
return new FluidTankInfo[] {dummyTank.getInfo()};
|
||||
}
|
||||
|
||||
return new FluidTankInfo[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -289,16 +318,6 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork> implements
|
|||
{
|
||||
return getTransmitterNetwork().getFlow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSneakRightClick(EntityPlayer player, int side)
|
||||
{
|
||||
isActive = !isActive;
|
||||
refreshTransmitterNetwork();
|
||||
sendDesc = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity()
|
||||
|
|
|
@ -37,9 +37,10 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
|
|||
public static IndexedCuboid6[] largeSides = new IndexedCuboid6[7];
|
||||
public int delayTicks;
|
||||
public ForgeDirection testingSide = null;
|
||||
|
||||
public byte currentAcceptorConnections = 0x00;
|
||||
public byte currentTransmitterConnections = 0x00;
|
||||
public boolean isActive = false;
|
||||
|
||||
public boolean sendDesc = false;
|
||||
public boolean redstonePowered = false;
|
||||
public ConnectionType[] connectionTypes = {ConnectionType.NORMAL,
|
||||
|
@ -271,6 +272,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
|
|||
|
||||
public abstract boolean isValidAcceptor(TileEntity tile, ForgeDirection side);
|
||||
|
||||
@Override
|
||||
public boolean canConnectMutual(ForgeDirection side)
|
||||
{
|
||||
if(!canConnect(side)) return false;
|
||||
|
@ -279,6 +281,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
|
|||
return (!(tile instanceof IBlockableConnection) || ((IBlockableConnection)tile).canConnect(side.getOpposite()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection side)
|
||||
{
|
||||
if(world().isBlockIndirectlyGettingPowered(x(), y(), z()))
|
||||
|
@ -297,7 +300,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
|
|||
{
|
||||
currentTransmitterConnections = packet.readByte();
|
||||
currentAcceptorConnections = packet.readByte();
|
||||
isActive = packet.readBoolean();
|
||||
|
||||
for(int i=0; i<6; i++)
|
||||
{
|
||||
connectionTypes[i] = ConnectionType.values()[packet.readInt()];
|
||||
|
@ -310,7 +313,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
|
|||
{
|
||||
packet.writeByte(currentTransmitterConnections);
|
||||
packet.writeByte(currentAcceptorConnections);
|
||||
packet.writeBoolean(isActive);
|
||||
|
||||
for(int i=0; i<6; i++)
|
||||
{
|
||||
packet.writeInt(connectionTypes[i].ordinal());
|
||||
|
@ -373,6 +376,21 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
|
|||
return ConnectionType.NORMAL;
|
||||
return connectionTypes[side.ordinal()];
|
||||
}
|
||||
|
||||
public List<ForgeDirection> getConnections(ConnectionType type)
|
||||
{
|
||||
List<ForgeDirection> sides = new ArrayList<ForgeDirection>();
|
||||
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if(getConnectionType(side) == type)
|
||||
{
|
||||
sides.add(side);
|
||||
}
|
||||
}
|
||||
|
||||
return sides;
|
||||
}
|
||||
|
||||
public CCModel getModelForSide(ForgeDirection side, boolean internal)
|
||||
{
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.io.DataOutputStream;
|
|||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasNetwork;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.transmitters.ITransmitter;
|
||||
import mekanism.common.EnergyNetwork;
|
||||
import mekanism.common.FluidNetwork;
|
||||
|
@ -25,14 +26,12 @@ public class PacketTransmitterUpdate implements IMekanismPacket
|
|||
|
||||
public double power;
|
||||
|
||||
public int gasType;
|
||||
public GasStack gasStack;
|
||||
public boolean didGasTransfer;
|
||||
|
||||
public int fluidType;
|
||||
public FluidStack fluidStack;
|
||||
public boolean didFluidTransfer;
|
||||
|
||||
public float scale;
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
|
@ -51,14 +50,12 @@ public class PacketTransmitterUpdate implements IMekanismPacket
|
|||
power = (Double)data[2];
|
||||
break;
|
||||
case GAS:
|
||||
gasType = (Integer)data[2];
|
||||
gasStack = (GasStack)data[2];
|
||||
didGasTransfer = (Boolean)data[3];
|
||||
scale = (Float)data[4];
|
||||
break;
|
||||
case FLUID:
|
||||
fluidType = (Integer)data[2];
|
||||
fluidStack = (FluidStack)data[2];
|
||||
didFluidTransfer = (Boolean)data[3];
|
||||
scale = (Float)data[4];
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -99,18 +96,23 @@ public class PacketTransmitterUpdate implements IMekanismPacket
|
|||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
Gas gasType = GasRegistry.getGas(dataStream.readInt());
|
||||
int amount = dataStream.readInt();
|
||||
didGasTransfer = dataStream.readBoolean();
|
||||
scale = dataStream.readFloat();
|
||||
|
||||
if(tileEntity != null)
|
||||
{
|
||||
if(gasType != null)
|
||||
{
|
||||
((ITransmitter<GasNetwork>)tileEntity).getTransmitterNetwork().refGas = gasType;
|
||||
((ITransmitter<GasNetwork>)tileEntity).getTransmitterNetwork().gasStored = new GasStack(gasType, amount);
|
||||
}
|
||||
else {
|
||||
if(((ITransmitter<GasNetwork>)tileEntity).getTransmitterNetwork().gasStored != null)
|
||||
{
|
||||
((ITransmitter<GasNetwork>)tileEntity).getTransmitterNetwork().gasStored.amount = amount;
|
||||
}
|
||||
}
|
||||
|
||||
((ITransmitter<GasNetwork>)tileEntity).getTransmitterNetwork().didTransfer = didGasTransfer;
|
||||
((ITransmitter<GasNetwork>)tileEntity).getTransmitterNetwork().definedScale = scale;
|
||||
}
|
||||
}
|
||||
else if(transmitterType == 3)
|
||||
|
@ -119,8 +121,14 @@ public class PacketTransmitterUpdate implements IMekanismPacket
|
|||
|
||||
int type = dataStream.readInt();
|
||||
Fluid fluidType = type != -1 ? FluidRegistry.getFluid(type) : null;
|
||||
int amount = dataStream.readInt();
|
||||
FluidStack stack = null;
|
||||
didFluidTransfer = dataStream.readBoolean();
|
||||
scale = dataStream.readFloat();
|
||||
|
||||
if(fluidType != null)
|
||||
{
|
||||
stack = new FluidStack(fluidType, amount);
|
||||
}
|
||||
|
||||
if(tileEntity != null)
|
||||
{
|
||||
|
@ -129,8 +137,8 @@ public class PacketTransmitterUpdate implements IMekanismPacket
|
|||
((ITransmitter<FluidNetwork>)tileEntity).getTransmitterNetwork().refFluid = fluidType;
|
||||
}
|
||||
|
||||
((ITransmitter<FluidNetwork>)tileEntity).getTransmitterNetwork().fluidStored = stack;
|
||||
((ITransmitter<FluidNetwork>)tileEntity).getTransmitterNetwork().didTransfer = didFluidTransfer;
|
||||
((ITransmitter<FluidNetwork>)tileEntity).getTransmitterNetwork().definedScale = scale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -150,14 +158,14 @@ public class PacketTransmitterUpdate implements IMekanismPacket
|
|||
dataStream.writeDouble(power);
|
||||
break;
|
||||
case GAS:
|
||||
dataStream.writeInt(gasType);
|
||||
dataStream.writeInt(gasStack != null ? gasStack.getGas().getID() : -1);
|
||||
dataStream.writeInt(gasStack != null ? gasStack.amount : 0);
|
||||
dataStream.writeBoolean(didGasTransfer);
|
||||
dataStream.writeFloat(scale);
|
||||
break;
|
||||
case FLUID:
|
||||
dataStream.writeInt(fluidType);
|
||||
dataStream.writeInt(fluidStack != null ? fluidStack.getFluid().getID() : -1);
|
||||
dataStream.writeInt(fluidStack != null ? fluidStack.amount : 0);
|
||||
dataStream.writeBoolean(didFluidTransfer);
|
||||
dataStream.writeFloat(scale);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue