From fb58861207882475bdb0fe00820c3e8b92a0469d Mon Sep 17 00:00:00 2001 From: DarkGuardsman Date: Fri, 8 Nov 2013 03:55:55 -0500 Subject: [PATCH] Started up on redoing arch's gas system Not that it was bad archadia but we have the fluid system which i'm using. Though to help out a bit i took your gas and made it extend the fluid class. This way you can create gas fluid faster. As well i started to create an enum to store all the gases with extended element data. Later on this will allow use to do advanced features like gas increasing pressure when heated. --- .../common/science/ChemicalCompound.java | 30 +++++++++++++ .../common/science/FormulaHelper.java | 21 ++++++--- .../common/science/HeatingData.java | 5 +-- src/dark/core/prefab/gas/EnumGas.java | 45 +++++++++++++++++++ src/dark/core/prefab/gas/Gas.java | 17 +++++++ 5 files changed, 110 insertions(+), 8 deletions(-) create mode 100644 src/com/builtbroken/common/science/ChemicalCompound.java create mode 100644 src/dark/core/prefab/gas/EnumGas.java create mode 100644 src/dark/core/prefab/gas/Gas.java diff --git a/src/com/builtbroken/common/science/ChemicalCompound.java b/src/com/builtbroken/common/science/ChemicalCompound.java new file mode 100644 index 000000000..6bfb8032b --- /dev/null +++ b/src/com/builtbroken/common/science/ChemicalCompound.java @@ -0,0 +1,30 @@ +package com.builtbroken.common.science; + +public enum ChemicalCompound +{ + /** http://encyclopedia.airliquide.com/encyclopedia.asp?GasID=8#GeneralData */ + BUTANE("butane", "C4H10", MatterPhase.gas, 58.12f, 2.48f, new HeatingData(133f, 274f, 1379.23f, 6634.23f, 88f)); + + /** Formula */ + public final String formula; + /** IUPAC ID */ + public final String compoundName; + /** g/mol */ + public final float molarMass; + /** g/cm³ */ + public final float density; + + public final MatterPhase defaultPhase; + + public final HeatingData heatingData; + + private ChemicalCompound(String name, String formula, MatterPhase phase, float molarMass, float density, HeatingData data) + { + this.compoundName = name; + this.formula = formula; + this.molarMass = molarMass; + this.density = density; + this.defaultPhase = phase; + this.heatingData = data; + } +} diff --git a/src/com/builtbroken/common/science/FormulaHelper.java b/src/com/builtbroken/common/science/FormulaHelper.java index ff928f58c..d7d7f0c3a 100644 --- a/src/com/builtbroken/common/science/FormulaHelper.java +++ b/src/com/builtbroken/common/science/FormulaHelper.java @@ -1,13 +1,13 @@ package com.builtbroken.common.science; /** Helper class that does the work of basic formulas. - * + * * @Note: Unless stated other wise the formulas don't care what the units are as long as the match * up. Eg pressure can be in any unit as long as all pressures for the method are the same unit - * + * * @Note: Some of these methods are very simple but they remove the confusion involved in rewriting * the code for each use - * + * * @author Robert Seifert */ public class FormulaHelper { @@ -15,7 +15,7 @@ public class FormulaHelper public static final float ACCELERATION_MOON = 1.622f; /** Gay-Lussac's Law (P1/T1 = P2/T2) - * + * * @param pressure - original pressure * @param temp - original tempature * @param newTemp - new tempature @@ -40,8 +40,19 @@ public class FormulaHelper return mass * acceleration; } + /** Gets the number of moles of the object from the mass of the object, and the materials + * molarMass + * + * @param molarMass - mass of one mole of the material + * @param objectMass - mass of the object made of the material + * @return number of moles of the material */ + public static float moles(float molarMass, float objectMass) + { + return objectMass / molarMass; + } + /** Calculates change from original value to new value - * + * * @param a - original value * @param b - new value * @return change in value from original to new */ diff --git a/src/com/builtbroken/common/science/HeatingData.java b/src/com/builtbroken/common/science/HeatingData.java index 1b118be04..61e00439d 100644 --- a/src/com/builtbroken/common/science/HeatingData.java +++ b/src/com/builtbroken/common/science/HeatingData.java @@ -2,7 +2,7 @@ package com.builtbroken.common.science; /** Used to store values related to temperature and heat of a material. Temperatures are in kelvin, * and heat in joules - * + * * @author DarkGuardsman */ public class HeatingData { @@ -14,8 +14,7 @@ public class HeatingData public float fisionHeat; /** (kJ/mol) Energy per gram needed to make the final leap from liquid to gas */ public float vaporHeat; - /** (j/kg K) Rate at which the material heats at in its default matter stage. This does change - * per phase */ + /** (j/kg K) Heating rate, at constant volume if gas */ public float specificHeat; /** How much the material expands */ public float thermalExpasion; diff --git a/src/dark/core/prefab/gas/EnumGas.java b/src/dark/core/prefab/gas/EnumGas.java new file mode 100644 index 000000000..73db19221 --- /dev/null +++ b/src/dark/core/prefab/gas/EnumGas.java @@ -0,0 +1,45 @@ +package dark.core.prefab.gas; + +import com.builtbroken.common.science.ChemElement; +import com.builtbroken.common.science.ChemicalCompound; + +/** Enum of gases used to create all the gas fluids + * + * @author DarkGuardsman */ +public enum EnumGas +{ + C2O("Carbon DiOxide"), + O2("Oxygen"), + C4H10(ChemicalCompound.BUTANE), + METHANE("Methane"), + NATURAL_GAS("Natural Gas"), + PROPANE("Propane"); + /** Name used when creating this as a fluid */ + final String fluidName; + /** Name used to display to the players */ + final String name; + /** Object data reference that was used to create this gas, can be a ChemicalCompound, Element, + * or Fluid */ + final Object data; + + private EnumGas(String name) + { + this.fluidName = "gas:" + name.replace(" ", "").toLowerCase(); + this.name = name; + data = null; + } + + private EnumGas(ChemicalCompound compound) + { + this.fluidName = "gas:" + compound.compoundName.replace(" ", "").toLowerCase(); + this.name = compound.compoundName; + data = compound; + } + + private EnumGas(ChemElement element) + { + this.fluidName = "gas:" + element.elementName.replace(" ", "").toLowerCase(); + this.name = element.elementName; + data = element; + } +} diff --git a/src/dark/core/prefab/gas/Gas.java b/src/dark/core/prefab/gas/Gas.java new file mode 100644 index 000000000..377e5664e --- /dev/null +++ b/src/dark/core/prefab/gas/Gas.java @@ -0,0 +1,17 @@ +package dark.core.prefab.gas; + +import net.minecraftforge.fluids.Fluid; + +/** These is an extension of the Fluid system forcing it to be a gas on creation + * + * @author Archadia, DarkGuardsman */ +public class Gas extends Fluid +{ + + public Gas(String name) + { + super(name); + this.isGaseous = true; + this.density = -1000; + } +}