public class IHLFluid extends Fluid
{
private Type type;
private ItemStack cell;
private static List<Fluid> fluidInstances = new ArrayList();
private static Map<String, IHLFluid> localFluidRegistry = new HashMap();
private static Map<String, String> condensationMap = new HashMap();
public static final int maxGaseousStateVapoursDensity = 40;
public IHLFluid(Type type1) {
super(type1.fluidRegistryName);
type=type1;
this.setTemperature(type.temperature);
this.setDensity(type.density);
this.setGaseous(type.isGaseous);
this.setUnlocalizedName(type.fluidRegistryName.replaceFirst("fluid", ""));
Fluid instance = this;
if (!FluidRegistry.registerFluid(instance))
{
instance = FluidRegistry.getFluid(type.fluidRegistryName);
}
localFluidRegistry.put(type1.fluidRegistryName, this);
ItemStack filledCell = FluidContainerRegistry.fillFluidContainer(new FluidStack(instance, FluidContainerRegistry.BUCKET_VOLUME),Ic2Items.cell);
if(filledCell==null)
{
cell = new ItemStack(new IHLItemCell(type.cellName,type.fluidRegistryName).setCreativeTab(IHLCreativeTab.tab));
OreDictionary.registerOre("cell"+type.fluidName.replaceFirst("fluid", ""), cell);
}
else
{
cell=filledCell;
}
if(instance.getBlock()==null)
{
instance.setBlock(new BlockFluidRubberTreeSap(instance, type.blockMaterial, "fluid"+type.fluidName.replaceFirst("fluid", "")).setBlockName("block"+type.fluidName).setCreativeTab(IHLCreativeTab.tab));
}
if(type.haveBucket)
{
Item bucket = new ItemBucket(block).setTextureName(IHLModInfo.MODID+":bucket_"+type.fluidName).setUnlocalizedName("bucket_"+type.fluidName).setCreativeTab(IHLCreativeTab.tab);
GameRegistry.registerItem(bucket, "bucket_"+type.fluidName);
FluidContainerRegistry.registerFluidContainer(instance, new ItemStack(bucket), new ItemStack(Items.bucket));
}
fluidInstances.add(instance);
}
public static void init()
{
Type[] var1 = Type.values();
for(int i=0;i<var1.length;i++)
{
new IHLFluid(var1[i]);
}
condensationMap.put("steam", "ic2distilledwater");
condensationMap.put("ic2steam", "ic2distilledwater");
condensationMap.put("ic2superheatedsteam", "ic2distilledwater");
condensationMap.put("vapour.sulfuricacid", "sulfuricacid");
}
public static void registerIcons()
{
Iterator<Fluid> ii = fluidInstances.iterator();
while(ii.hasNext())
{
Fluid instance = ii.next();
instance.setIcons(instance.getBlock().getBlockTextureFromSide(0), instance.getBlock().getBlockTextureFromSide(1));
}
}
public static ItemStack getCell(String fluidname)
{
return localFluidRegistry.get(fluidname).cell.copy();
}
public static int getMeltingPoint(Fluid fluid)
{
if(localFluidRegistry.get(fluid.getName())!=null)
{
IHLFluid ihlfluid = localFluidRegistry.get(fluid.getName());
return ihlfluid.type.meltingPoint;
}
else
{
if(fluid.isGaseous())
{
return fluid.getTemperature()>100?fluid.getTemperature()-100:0;
}
else
{
return fluid.getTemperature();
}
}
}
public static int getBoilingPoint(Fluid fluid)
{
if(localFluidRegistry.get(fluid.getName())!=null)
{
IHLFluid ihlfluid = localFluidRegistry.get(fluid.getName());
return ihlfluid.type.boilingPoint;
}
else
{
if(fluid.getName()=="steam" || fluid.getName()=="ic2steam" || fluid.getName()=="ic2superheatedsteam")
{
return 373;
}
else if(fluid.isGaseous())
{
return fluid.getTemperature();
}
else
{
return fluid.getTemperature()+100;
}
}
}
public enum Type
{
fluidRubberTreeSap("fluidRubberTreeSap","itemCellRubberTreeSap", 293, 273, 393, 1200, true),
SpruceResin("SpruceResin", 293, 273, 533, 1070, true),
CablingColophony("CablingColophony", 363, 363, 533, 1070),
Glyceryl("Glyceryl", 293, 291, 583, 1261),
SeedOil("SeedOil", 293, 256, 583, 920),
AquaRegia("AquaRegia", 293, 231, 356, 1060),
SodiumPeroxide("SodiumPeroxide", 950, 950, 2223, 1800),
OsmiumTetroxide("OsmiumTetroxide", 313, 313, 403, 9),
OleicAcid("OleicAcid", 293, 288, 633, 895),
Limemilk("Limemilk", 293, 253, 373, 1020),
NickelSulfateDissolvedInWater("NickelSulfateDissolvedInWater", 293, 253, 373, 1220, "solution.nickelsulfate"),
BlueVitriolDissolvedInWater("BlueVitriolDissolvedInWater", 293, 253, 373, 1180, "solution.bluevitriol"),
MoltenSteel("MoltenSteel", 1800, 1800, 3134, 7800, "molten.steel", Material.lava),
MoltenBronze("MoltenBronze", 940, 940, 2840, 8000, "molten.bronze", Material.lava),
VapourSulfuricAcid("VapourSulfuricAcid", 610, 283, 610, 4, "vapour.sulfuricacid"),
SulfuricAnhydride("SulfuricAnhydride", 45, 17, 45, 2, "sulfuricanhydride"),
SulfuricAcid("SulfuricAcid", 293, 283, 610, 1836),
NitricAcid("NitricAcid", 293, 231, 356, 1100);
Type(String fluidName1, int temperature1, int meltingPoint1, int boilingPoint1, int density1)
{
fluidName=fluidName1;
fluidRegistryName=fluidName.toLowerCase();
temperature=temperature1;
density=density1;
cellName="itemCell"+fluidName;
haveBucket=false;
isGaseous=density1<maxGaseousStateVapoursDensity;
boilingPoint=boilingPoint1;
meltingPoint=meltingPoint1;
}
Type(String fluidName1, int temperature1, int meltingPoint1, int boilingPoint1, int density1, String fluidRegistryName1)
{
fluidName=fluidName1;
fluidRegistryName=fluidRegistryName1;
temperature=temperature1;
density=density1;
cellName="itemCell"+fluidName;
haveBucket=false;
isGaseous=density1<maxGaseousStateVapoursDensity;
boilingPoint=boilingPoint1;
meltingPoint=meltingPoint1;
}
Type(String fluidName1, int temperature1, int meltingPoint1, int boilingPoint1, int density1, String fluidRegistryName1, Material blockMaterial1)
{
fluidName=fluidName1;
fluidRegistryName=fluidRegistryName1;
temperature=temperature1;
density=density1;
cellName="itemCell"+fluidName;
haveBucket=false;
isGaseous=density1<maxGaseousStateVapoursDensity;
blockMaterial=blockMaterial1;
boilingPoint=boilingPoint1;
meltingPoint=meltingPoint1;
}
Type(String fluidName1, String cellName1, int temperature1, int meltingPoint1, int boilingPoint1, int density1)
{
fluidName=fluidName1;
fluidRegistryName=fluidName.toLowerCase();
temperature=temperature1;
density=density1;
cellName=cellName1;
haveBucket=false;
isGaseous=density1<maxGaseousStateVapoursDensity;
boilingPoint=boilingPoint1;
meltingPoint=meltingPoint1;
}
Type(String fluidName1, String cellName1, int temperature1, int meltingPoint1, int boilingPoint1, int density1, boolean haveBucket1)
{
fluidName=fluidName1;
fluidRegistryName=fluidName.toLowerCase();
temperature=temperature1;
density=density1;
cellName=cellName1;
haveBucket=haveBucket1;
isGaseous=density1<maxGaseousStateVapoursDensity;
boilingPoint=boilingPoint1;
meltingPoint=meltingPoint1;
}
Type(String fluidName1, int temperature1, int meltingPoint1, int boilingPoint1, int density1, boolean haveBucket1)
{
fluidName=fluidName1;
fluidRegistryName=fluidName.toLowerCase();
temperature=temperature1;
density=density1;
cellName="itemCell"+fluidName;
haveBucket=haveBucket1;
isGaseous=density1<maxGaseousStateVapoursDensity;
boilingPoint=boilingPoint1;
meltingPoint=meltingPoint1;
}
Type(String fluidName1, int density1, int meltingPoint1, int boilingPoint1)
{
fluidName=fluidName1;
fluidRegistryName=fluidName.toLowerCase();
temperature=20;
density=density1;
cellName="cell"+fluidName;
haveBucket=false;
isGaseous=density1<maxGaseousStateVapoursDensity;
boilingPoint=boilingPoint1;
meltingPoint=meltingPoint1;
}
String fluidName;
String fluidRegistryName;
String cellName;
int temperature;
int density;
boolean isGaseous;
boolean haveBucket;
Material blockMaterial = Material.water;
int meltingPoint;
int boilingPoint;
}
public static FluidStack getCondensationResult(FluidStack condensatedGas)
{
String fluidname = condensationMap.get(condensatedGas.getFluid().getName());
Fluid fluid = FluidRegistry.getFluid(fluidname);
if(fluid!=null)
{
int quantity=Math.round(condensatedGas.amount*getCondensationConversionRate(condensatedGas.getFluid()));
if(quantity>0)
{
return new FluidStack(fluid,quantity);
}
}
return null;
}
public static float getCondensationConversionRate(Fluid gas)
{
String fluidname = condensationMap.get(gas.getName());
Fluid fluid = FluidRegistry.getFluid(fluidname);
if(fluid!=null)
{
float rate = (float)gas.getDensity()/(float)fluid.getDensity();
if(gas.getDensity()<0)
{
//IC2 steam density -800, 100 mb steam from 1 mb water
rate=(-8000F/(float)gas.getDensity())/(float)fluid.getDensity();
}
return rate;
}
return 0F;
}
}
Display More