Finished multipart pipes
This commit is contained in:
parent
62be2b5b1d
commit
d5859ba566
5 changed files with 57 additions and 38 deletions
|
@ -105,19 +105,6 @@ public abstract class PartFramedConnection<M extends Enum, C extends IConnector<
|
|||
return subParts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item)
|
||||
{
|
||||
if (!world().isRemote)
|
||||
{
|
||||
// TODO: Remove; for debugging.
|
||||
for (int i = 0; i < connections.length; i++)
|
||||
System.out.println("TEST" + connections[i]);
|
||||
}
|
||||
|
||||
return super.activate(player, part, item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rendering and block bounds.
|
||||
*/
|
||||
|
@ -282,7 +269,7 @@ public abstract class PartFramedConnection<M extends Enum, C extends IConnector<
|
|||
{
|
||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), side);
|
||||
|
||||
if (CompatibilityModule.canConnect(tileEntity, side.getOpposite()) && canConnectBothSides(tileEntity, side))
|
||||
if (canConnectTo(tileEntity) && canConnectBothSides(tileEntity, side))
|
||||
{
|
||||
connections |= 1 << side.ordinal();
|
||||
}
|
||||
|
@ -343,17 +330,20 @@ public abstract class PartFramedConnection<M extends Enum, C extends IConnector<
|
|||
{
|
||||
TileEntity[] connections = new TileEntity[6];
|
||||
|
||||
for (byte i = 0; i < 6; i++)
|
||||
if (world() != null && tile() != null)
|
||||
{
|
||||
ForgeDirection side = ForgeDirection.getOrientation(i);
|
||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), side);
|
||||
|
||||
if (isCurrentlyConnected(side))
|
||||
for (byte i = 0; i < 6; i++)
|
||||
{
|
||||
connections[i] = tileEntity;
|
||||
}
|
||||
}
|
||||
ForgeDirection side = ForgeDirection.getOrientation(i);
|
||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), side);
|
||||
|
||||
if (isCurrentlyConnected(side))
|
||||
{
|
||||
connections[i] = tileEntity;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return connections;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ public class MultipartMechanical implements IPartFactory
|
|||
public MultipartMechanical()
|
||||
{
|
||||
MultiPartRegistry.registerParts(this, PART_TYPES);
|
||||
MultipartGenerator.registerPassThroughInterface("resonantinduction.api.fluid.IFluidConnector");
|
||||
MultipartGenerator.registerPassThroughInterface("resonantinduction.api.fluid.IFluidPipe");
|
||||
MultipartGenerator.registerTrait("resonantinduction.mechanical.network.IMechanical", "resonantinduction.mechanical.trait.TraitMechanical");
|
||||
MultipartGenerator.registerTrait("resonantinduction.mechanical.network.IMechanicalConnector", "resonantinduction.mechanical.trait.TraitMechanicalConnector");
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public abstract class FluidNetwork extends Network<IFluidNetwork, IFluidConnecto
|
|||
{
|
||||
part.setNetwork(this);
|
||||
}
|
||||
|
||||
|
||||
this.buildPart(part);
|
||||
}
|
||||
this.rebuildHandler();
|
||||
|
@ -115,6 +115,7 @@ public abstract class FluidNetwork extends Network<IFluidNetwork, IFluidConnecto
|
|||
{
|
||||
FluidStack before = this.getTank().getFluid();
|
||||
FluidStack drain = this.getTank().drain(resource.amount, doDrain);
|
||||
|
||||
if (before != this.getTank().getFluid() || this.getTank().getFluid() == null || this.getTank().getFluid().amount != before.amount)
|
||||
{
|
||||
this.rebuildHandler();
|
||||
|
|
|
@ -11,12 +11,12 @@ import net.minecraftforge.fluids.FluidStack;
|
|||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import resonantinduction.api.fluid.IFluidConnector;
|
||||
import resonantinduction.api.fluid.IFluidNetwork;
|
||||
import resonantinduction.api.fluid.IFluidPipe;
|
||||
import resonantinduction.core.prefab.part.PartFramedConnection;
|
||||
import resonantinduction.mechanical.Mechanical;
|
||||
import resonantinduction.mechanical.fluid.network.PipeNetwork;
|
||||
import resonantinduction.mechanical.fluid.tank.TileTank;
|
||||
import codechicken.microblock.IHollowConnect;
|
||||
import codechicken.multipart.JIconHitEffects;
|
||||
import codechicken.multipart.JNormalOcclusion;
|
||||
|
@ -24,7 +24,7 @@ import codechicken.multipart.TSlottedPart;
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PartPipe extends PartFramedConnection<EnumPipeMaterial, IFluidConnector, IFluidNetwork> implements IFluidConnector, TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects
|
||||
public class PartPipe extends PartFramedConnection<EnumPipeMaterial, IFluidPipe, IFluidNetwork> implements IFluidPipe, TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects
|
||||
{
|
||||
protected FluidTank tank = new FluidTank(1 * FluidContainerRegistry.BUCKET_VOLUME);
|
||||
private boolean isExtracting = false;
|
||||
|
@ -49,15 +49,19 @@ public class PartPipe extends PartFramedConnection<EnumPipeMaterial, IFluidConne
|
|||
@Override
|
||||
public void update()
|
||||
{
|
||||
if (isExtracting)
|
||||
if (!world().isRemote)
|
||||
{
|
||||
for (int i = 0; i < this.getConnections().length; i++)
|
||||
if (isExtracting)
|
||||
{
|
||||
Object obj = this.getConnections()[i];
|
||||
|
||||
if (obj instanceof IFluidHandler)
|
||||
for (int i = 0; i < this.getConnections().length; i++)
|
||||
{
|
||||
((IFluidHandler) obj).drain(ForgeDirection.getOrientation(i).getOpposite(), FluidContainerRegistry.BUCKET_VOLUME, true);
|
||||
Object obj = this.getConnections()[i];
|
||||
|
||||
if (obj instanceof IFluidHandler)
|
||||
{
|
||||
FluidStack drain = ((IFluidHandler) obj).drain(ForgeDirection.getOrientation(i).getOpposite(), getMaxFlowRate(), true);
|
||||
fill(null, drain, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +70,7 @@ public class PartPipe extends PartFramedConnection<EnumPipeMaterial, IFluidConne
|
|||
@Override
|
||||
public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item)
|
||||
{
|
||||
if (!world().isRemote)
|
||||
if (!world().isRemote && player.isSneaking())
|
||||
{
|
||||
isExtracting = !isExtracting;
|
||||
player.addChatMessage("Pipe extraction mode: " + isExtracting);
|
||||
|
@ -117,13 +121,13 @@ public class PartPipe extends PartFramedConnection<EnumPipeMaterial, IFluidConne
|
|||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
return this.getNetwork().drain(this, from, resource, doDrain);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return this.getNetwork().drain(this, from, maxDrain, doDrain);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -166,9 +170,33 @@ public class PartPipe extends PartFramedConnection<EnumPipeMaterial, IFluidConne
|
|||
}
|
||||
|
||||
@Override
|
||||
protected IFluidConnector getConnector(TileEntity tile)
|
||||
protected IFluidPipe getConnector(TileEntity tile)
|
||||
{
|
||||
return tile instanceof IFluidConnector ? (IFluidConnector) tile : null;
|
||||
return tile instanceof IFluidPipe ? (IFluidPipe) tile : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPressureIn(ForgeDirection side)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWrongPressure(ForgeDirection side, int pressure)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxPressure()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxFlowRate()
|
||||
{
|
||||
return FluidContainerRegistry.BUCKET_VOLUME;
|
||||
}
|
||||
|
||||
}
|
|
@ -73,7 +73,7 @@ public abstract class TileFluidNetwork extends TileAdvanced implements IFluidCon
|
|||
{
|
||||
if (this.updateFluidRender)
|
||||
{
|
||||
if (!FluidUtility.matchExact(prevStack, this.getInternalTank().getFluid()))
|
||||
//if (!FluidUtility.matchExact(prevStack, this.getInternalTank().getFluid()))
|
||||
{
|
||||
this.sendTankUpdate();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue