Some more work on fluid

This commit is contained in:
Calclavia 2014-01-05 15:12:33 +08:00
parent d6df9bb0a3
commit 6355b98943
3 changed files with 39 additions and 5 deletions

@ -1 +1 @@
Subproject commit 4c126b0b3f1e9f811e9e579736f47275ee1cfc99
Subproject commit 4954119c1db1ff27fcbbfbaff79b27547394a4ae

View file

@ -2,10 +2,14 @@ package resonantinduction.machine.liquid;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidFinite;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import resonantinduction.ResonantInduction;
/**
* @author Calclavia
@ -19,6 +23,28 @@ public class BlockFluidMixture extends BlockFluidFinite implements ITileEntityPr
this.setTextureName("water_flow");
}
@Override
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
{
// If this item can be smelted into another fluid, add it to the mixture.
}
/* IFluidBlock */
@Override
public FluidStack drain(World world, int x, int y, int z, boolean doDrain)
{
TileFluidMixture tileFluid = (TileFluidMixture) world.getBlockTileEntity(x, y, z);
FluidStack stack = new FluidStack(ResonantInduction.MIXTURE, (int) (FluidContainerRegistry.BUCKET_VOLUME * this.getFilledPercentage(world, x, y, z)));
tileFluid.writeFluidToNBT(stack.tag);
return stack;
}
@Override
public boolean canDrain(World world, int x, int y, int z)
{
return true;
}
@Override
public TileEntity createNewTileEntity(World world)
{

View file

@ -51,7 +51,18 @@ public class TileFluidMixture extends TileAdvanced
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
readFluidFromNBT(nbt);
}
@Override
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
writeFluidToNBT(nbt);
}
public void readFluidFromNBT(NBTTagCompound nbt)
{
fluids.clear();
NBTTagList nbtList = nbt.getTagList("fluids");
@ -63,11 +74,8 @@ public class TileFluidMixture extends TileAdvanced
}
}
@Override
public void writeToNBT(NBTTagCompound nbt)
public void writeFluidToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
NBTTagList nbtList = new NBTTagList();
for (FluidStack fluid : fluids)