Worked on damaged pipes dumping other mods fluids

This commit is contained in:
DarkGuardsman 2013-12-30 22:39:31 -05:00
parent 8c70ae0042
commit a685a5192d
2 changed files with 19 additions and 12 deletions

View file

@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import universalelectricity.api.vector.Vector3;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
@ -20,6 +22,7 @@ import net.minecraftforge.fluids.FluidTankInfo;
import com.builtbroken.assemblyline.blocks.BlockHydraulic;
import com.builtbroken.common.Pair;
import com.builtbroken.minecraft.fluid.FluidHelper;
import com.builtbroken.minecraft.helpers.ColorCode;
import com.builtbroken.minecraft.helpers.ColorCode.IColorCoded;
@ -128,23 +131,16 @@ public class BlockPipe extends BlockHydraulic
public void breakBlock(World world, int x, int y, int z, int par5, int par6)
{
TileEntity entity = world.getBlockTileEntity(x, y, z);
super.breakBlock(world, x, y, z, par5, par6);
if (entity instanceof TileEntityPipe)
{
FluidTankInfo tank = ((TileEntityPipe) entity).getTankInfo()[0];
if (tank != null && tank.fluid != null && tank.fluid.getFluid() != null && tank.fluid.amount > 0)
{
if (tank.fluid.getFluid().getName().equalsIgnoreCase("water"))
{
world.setBlock(x, y, z, Block.waterStill.blockID);
}
if (tank.fluid.getFluid().getName().equalsIgnoreCase("lava"))
{
world.setBlock(x, y, z, Block.lavaStill.blockID);
}
((TileEntityPipe) entity).getTileNetwork().drainNetworkTank(world, FluidHelper.fillBlock(world, new Vector3(x, y, z), tank.fluid, true), true);
}
}
super.breakBlock(world, x, y, z, par5, par6);
}
@Override

View file

@ -10,6 +10,7 @@ import universalelectricity.api.vector.Vector3;
import com.builtbroken.assemblyline.api.fluid.INetworkPipe;
import com.builtbroken.assemblyline.fluid.network.NetworkPipes;
import com.builtbroken.assemblyline.fluid.prefab.TileEntityFluidNetworkTile;
import com.builtbroken.minecraft.fluid.FluidHelper;
import com.builtbroken.minecraft.helpers.ColorCode;
import com.builtbroken.minecraft.helpers.ColorCode.IColorCoded;
import com.builtbroken.minecraft.tilenetwork.ITileConnector;
@ -164,7 +165,14 @@ public class TileEntityPipe extends TileEntityFluidNetworkTile implements IColor
{
if (damageAllowed)
{
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, yCoord, 0, 0);
if (this.tank.getFluid() != null && this.tank.getFluid() != null)
{
this.getTileNetwork().drainNetworkTank(this.worldObj, FluidHelper.fillBlock(this.worldObj, new Vector3(this), this.tank.getFluid(), true), true);
}
else
{
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, yCoord, 0, 0);
}
return true;
}
return false;
@ -173,7 +181,10 @@ public class TileEntityPipe extends TileEntityFluidNetworkTile implements IColor
@Override
public void sendTankUpdate(int index)
{
//TODO only send tank update for pipes that need to visually render the fluid, eg glass, stone, wood
if (this.getBlockMetadata() == FluidPartsMaterial.WOOD.ordinal() || this.getBlockMetadata() == FluidPartsMaterial.STONE.ordinal())
{
super.sendTankUpdate(index);
}
}
@Override