Finished up pump and drain tile code

Need to finish the blocks which i'll do later. As well i still need to
set the forgeDirection for input output for both tiles.
This commit is contained in:
Rseifert 2013-04-04 01:25:44 -04:00
parent 4ef06dc48a
commit 21e340dd9d
5 changed files with 88 additions and 5 deletions

View file

@ -1,6 +1,5 @@
package fluidmech.common;
import fluidmech.common.block.BlockPumpMachine;
import fluidmech.common.block.BlockReleaseValve;
import fluidmech.common.block.BlockSink;
import fluidmech.common.block.BlockTank;
@ -22,6 +21,7 @@ import fluidmech.common.machines.mech.TileEntityRod;
import fluidmech.common.machines.pipes.BlockPipe;
import fluidmech.common.machines.pipes.TileEntityPipe;
import fluidmech.common.machines.pipes.TileEntityPipeWindow;
import fluidmech.common.pump.BlockPumpMachine;
import fluidmech.common.pump.TileEntityStarterPump;
import hydraulic.api.ColorCode;
import hydraulic.helpers.FluidHelper;

View file

@ -0,0 +1,14 @@
package fluidmech.common.pump;
import net.minecraft.block.material.Material;
import universalelectricity.prefab.block.BlockAdvanced;
public class BlockDrain extends BlockAdvanced
{
public BlockDrain(int id)
{
super(id, Material.iron);
}
}

View file

@ -1,4 +1,4 @@
package fluidmech.common.block;
package fluidmech.common.pump;
import hydraulic.helpers.MetaGroup;
@ -17,7 +17,6 @@ import universalelectricity.prefab.block.BlockAdvanced;
import fluidmech.client.render.BlockRenderHelper;
import fluidmech.common.FluidMech;
import fluidmech.common.TabFluidMech;
import fluidmech.common.pump.TileEntityStarterPump;
public class BlockPumpMachine extends BlockAdvanced
{

View file

@ -1,9 +1,11 @@
package fluidmech.common.pump;
import hydraulic.fluidnetwork.IFluidNetworkPart;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.ITankContainer;
import net.minecraftforge.liquids.LiquidContainerData;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidStack;
import net.minecraftforge.liquids.LiquidTank;
@ -25,7 +27,31 @@ public class TileEntityConstructionPump extends TileEntityElectricityRunnable im
@Override
public void updateEntity()
{
if (!worldObj.isRemote && this.wattsReceived >= this.WATTS_PER_TICK)
{
if (this.ticks % 10 == 0)
{
boolean called = false;
TileEntity inputTile = VectorHelper.getTileEntityFromSide(worldObj, new Vector3(this), inputSide);
TileEntity outputTile = VectorHelper.getTileEntityFromSide(worldObj, new Vector3(this), outputSide);
if (inputTile instanceof IFluidNetworkPart)
{
if (outputTile instanceof ITankContainer)
{
for (ITankContainer tank : ((IFluidNetworkPart) inputTile).getNetwork().fluidTanks)
{
if (tank instanceof TileEntityDrain)
{
((TileEntityDrain) tank).requestLiquid(this, new LiquidStack(-1, LiquidContainerRegistry.BUCKET_VOLUME));
called = true;
}
}
}
}
}
}
}
@Override

View file

@ -12,12 +12,13 @@ import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.ITankContainer;
import net.minecraftforge.liquids.LiquidStack;
import universalelectricity.core.vector.Vector3;
import universalelectricity.core.vector.VectorHelper;
public class TileEntityDrain extends TileEntityFluidDevice
public class TileEntityDrain extends TileEntityFluidDevice implements ITankContainer
{
private ForgeDirection face = ForgeDirection.UNKNOWN;
private boolean drainSources = true;
@ -58,7 +59,8 @@ public class TileEntityDrain extends TileEntityFluidDevice
{
for (Entry<TileEntityConstructionPump, LiquidStack> pump : requestMap.entrySet())
{
if (pump.getValue().isLiquidEqual(stack))
LiquidStack requestStack = pump.getValue();
if (requestStack != null && (requestStack.isLiquidEqual(stack) || requestStack.itemID == -1))
{
if (((ITankContainer) entity).fill(0, stack, false) >= stack.amount)
{
@ -151,4 +153,46 @@ public class TileEntityDrain extends TileEntityFluidDevice
}
}
}
@Override
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill)
{
// TODO Auto-generated method stub
return 0;
}
@Override
public int fill(int tankIndex, LiquidStack resource, boolean doFill)
{
// TODO Auto-generated method stub
return 0;
}
@Override
public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
{
// TODO Auto-generated method stub
return null;
}
@Override
public LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain)
{
// TODO Auto-generated method stub
return null;
}
@Override
public ILiquidTank[] getTanks(ForgeDirection direction)
{
// TODO Auto-generated method stub
return null;
}
@Override
public ILiquidTank getTank(ForgeDirection direction, LiquidStack type)
{
// TODO Auto-generated method stub
return null;
}
}