Rendering looks cool :)

This commit is contained in:
Aidan C. Brady 2013-12-17 15:36:25 -05:00
parent ed2a5233ae
commit 350ad4c22e
5 changed files with 79 additions and 50 deletions

View file

@ -125,7 +125,7 @@ public class RenderPartTransmitter implements IIconRegister
public void renderContents(PartMechanicalPipe pipe, Vector3 pos) public void renderContents(PartMechanicalPipe pipe, Vector3 pos)
{ {
Fluid fluid = pipe.getTransmitterNetwork().refFluid; Fluid fluid = pipe.getTransmitterNetwork().refFluid;
float scale = pipe.getTransmitterNetwork().fluidScale; float scale = pipe.currentScale;
if(scale > 0 && fluid != null) if(scale > 0 && fluid != null)
{ {
@ -359,7 +359,7 @@ public class RenderPartTransmitter implements IIconRegister
public void renderGasSide(ForgeDirection side, PartPressurizedTube tube) public void renderGasSide(ForgeDirection side, PartPressurizedTube tube)
{ {
boolean connected = PartTransmitter.connectionMapContainsSide(tube.getAllCurrentConnections(), side); 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.getTransmitterNetwork().gasScale)); renderTransparency(tube.getTransmitterNetwork().refGas.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) public void renderPart(Icon icon, CCModel cc, double x, double y, double z)

View file

@ -3,6 +3,7 @@ package mekanism.common.multipart;
import java.util.Arrays; import java.util.Arrays;
import java.util.Set; import java.util.Set;
import mekanism.api.gas.Gas;
import mekanism.api.transmitters.ITransmitter; import mekanism.api.transmitters.ITransmitter;
import mekanism.api.transmitters.TransmissionType; import mekanism.api.transmitters.TransmissionType;
import mekanism.client.render.PartTransmitterIcons; import mekanism.client.render.PartTransmitterIcons;
@ -32,9 +33,61 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork> implements
public static PartTransmitterIcons pipeIcons; public static PartTransmitterIcons pipeIcons;
public float currentScale;
public FluidStack cacheFluid; public FluidStack cacheFluid;
public FluidStack lastWrite; public FluidStack lastWrite;
@Override
public void update()
{
if(!world().isRemote)
{
if(cacheFluid != null)
{
if(getTransmitterNetwork().fluidStored == null)
{
getTransmitterNetwork().fluidStored = cacheFluid;
}
else {
getTransmitterNetwork().fluidStored.amount += cacheFluid.amount;
}
cacheFluid = null;
}
if(isActive)
{
IFluidHandler[] connectedAcceptors = PipeUtils.getConnectedAcceptors(tile());
for(IFluidHandler container : connectedAcceptors)
{
ForgeDirection side = ForgeDirection.getOrientation(Arrays.asList(connectedAcceptors).indexOf(container));
if(container != null)
{
FluidStack received = container.drain(side, 100, false);
if(received != null && received.amount != 0)
{
container.drain(side.getOpposite(), getTransmitterNetwork().emit(received, true), true);
}
}
}
}
}
else {
float targetScale = getTransmitterNetwork().fluidScale;
if(Math.abs(currentScale - targetScale) > 0.01)
{
currentScale = (9 * currentScale + targetScale) / 10;
}
}
super.update();
}
@Override @Override
public void onChunkUnload() public void onChunkUnload()
{ {
@ -220,48 +273,6 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork> implements
{ {
return new FluidTankInfo[] {dummyTank.getInfo()}; return new FluidTankInfo[] {dummyTank.getInfo()};
} }
@Override
public void update()
{
if(!world().isRemote)
{
if(cacheFluid != null)
{
if(getTransmitterNetwork().fluidStored == null)
{
getTransmitterNetwork().fluidStored = cacheFluid;
}
else {
getTransmitterNetwork().fluidStored.amount += cacheFluid.amount;
}
cacheFluid = null;
}
if(isActive)
{
IFluidHandler[] connectedAcceptors = PipeUtils.getConnectedAcceptors(tile());
for(IFluidHandler container : connectedAcceptors)
{
ForgeDirection side = ForgeDirection.getOrientation(Arrays.asList(connectedAcceptors).indexOf(container));
if(container != null)
{
FluidStack received = container.drain(side, 100, false);
if(received != null && received.amount != 0)
{
container.drain(side.getOpposite(), getTransmitterNetwork().emit(received, true), true);
}
}
}
}
super.update();
}
}
@Override @Override
public int getTransmitterNetworkSize() public int getTransmitterNetworkSize()

View file

@ -23,14 +23,14 @@ public class PartPressurizedTube extends PartTransmitter<GasNetwork>
{ {
public static PartTransmitterIcons tubeIcons; public static PartTransmitterIcons tubeIcons;
public float currentScale;
public GasStack cacheGas; public GasStack cacheGas;
public GasStack lastWrite; public GasStack lastWrite;
@Override @Override
public void update() public void update()
{ {
super.update();
if(!world().isRemote) if(!world().isRemote)
{ {
if(cacheGas != null) if(cacheGas != null)
@ -46,6 +46,16 @@ public class PartPressurizedTube extends PartTransmitter<GasNetwork>
cacheGas = null; cacheGas = null;
} }
} }
else {
float targetScale = getTransmitterNetwork().gasScale;
if(Math.abs(currentScale - targetScale) > 0.01)
{
currentScale = (9 * currentScale + targetScale) / 10;
}
}
super.update();
} }
@Override @Override

View file

@ -104,7 +104,11 @@ public class PacketTransmitterUpdate implements IMekanismPacket
if(tileEntity != null) if(tileEntity != null)
{ {
((ITransmitter<GasNetwork>)tileEntity).getTransmitterNetwork().refGas = gasType; if(gasType != null)
{
((ITransmitter<GasNetwork>)tileEntity).getTransmitterNetwork().refGas = gasType;
}
((ITransmitter<GasNetwork>)tileEntity).getTransmitterNetwork().didTransfer = didGasTransfer; ((ITransmitter<GasNetwork>)tileEntity).getTransmitterNetwork().didTransfer = didGasTransfer;
((ITransmitter<GasNetwork>)tileEntity).getTransmitterNetwork().definedScale = scale; ((ITransmitter<GasNetwork>)tileEntity).getTransmitterNetwork().definedScale = scale;
} }
@ -120,7 +124,11 @@ public class PacketTransmitterUpdate implements IMekanismPacket
if(tileEntity != null) if(tileEntity != null)
{ {
((ITransmitter<FluidNetwork>)tileEntity).getTransmitterNetwork().refFluid = fluidType; if(fluidType != null)
{
((ITransmitter<FluidNetwork>)tileEntity).getTransmitterNetwork().refFluid = fluidType;
}
((ITransmitter<FluidNetwork>)tileEntity).getTransmitterNetwork().didTransfer = didFluidTransfer; ((ITransmitter<FluidNetwork>)tileEntity).getTransmitterNetwork().didTransfer = didFluidTransfer;
((ITransmitter<FluidNetwork>)tileEntity).getTransmitterNetwork().definedScale = scale; ((ITransmitter<FluidNetwork>)tileEntity).getTransmitterNetwork().definedScale = scale;
} }

View file

@ -459,7 +459,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
return new FluidTankInfo[] {fluidTank.getInfo()}; return new FluidTankInfo[] {fluidTank.getInfo()};
} }
return null; return new FluidTankInfo[0];
} }
@Override @Override