Added basic fluid merging

This commit is contained in:
Calclavia 2014-01-05 14:50:43 +08:00
parent ba6a56ab7e
commit d6df9bb0a3
2 changed files with 36 additions and 4 deletions

View file

@ -31,6 +31,7 @@ import resonantinduction.machine.crusher.ItemDust;
import resonantinduction.machine.furnace.BlockAdvancedFurnace;
import resonantinduction.machine.furnace.TileAdvancedFurnace;
import resonantinduction.machine.liquid.BlockFluidMixture;
import resonantinduction.machine.liquid.TileFluidMixture;
import resonantinduction.transport.battery.BlockBattery;
import resonantinduction.transport.battery.ItemBlockBattery;
import resonantinduction.transport.battery.TileBattery;
@ -236,6 +237,7 @@ public class ResonantInduction
GameRegistry.registerTileEntity(TileTesla.class, blockTesla.getUnlocalizedName());
GameRegistry.registerTileEntity(TileEMLevitator.class, blockEMContractor.getUnlocalizedName());
GameRegistry.registerTileEntity(TileBattery.class, blockBattery.getUnlocalizedName());
GameRegistry.registerTileEntity(TileFluidMixture.class, blockFluidMixture.getUnlocalizedName());
ResonantInduction.proxy.registerRenderers();

View file

@ -1,9 +1,7 @@
package resonantinduction.machine.liquid;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.fluids.FluidStack;
@ -15,7 +13,39 @@ import calclavia.lib.prefab.tile.TileAdvanced;
*/
public class TileFluidMixture extends TileAdvanced
{
public final Set<FluidStack> fluids = new HashSet<FluidStack>();
public final TreeSet<FluidStack> fluids = new TreeSet<FluidStack>();
@Override
public boolean canUpdate()
{
return false;
}
public void mix(FluidStack fluid)
{
if (fluids.contains(fluid))
{
for (FluidStack checkFluid : fluids)
{
if (fluid.equals(checkFluid))
{
checkFluid.amount += fluid.amount;
}
}
}
else
{
fluids.add(fluid);
}
}
/**
* @return The color of the liquid based on the fluidStacks stored.
*/
public int getColor()
{
return 0xFFFFFF;
}
@Override
public void readFromNBT(NBTTagCompound nbt)