Started toying with the idea of molten fluids
This commit is contained in:
parent
f8a9f54e4d
commit
158e3b0dd6
5 changed files with 118 additions and 102 deletions
|
@ -4,7 +4,7 @@ package com.builtbroken.common.science;
|
|||
* parts but each element should have a listed names, symbol, and atomic mass. Atomic number should
|
||||
* be the placement # in the list. Var ZERO should not be used as its designed to offset the
|
||||
* placement of all elements by one. As well is returned instead of null.
|
||||
*
|
||||
*
|
||||
* @Source http://www.periodictable.com/Properties/A/SpecificHeat.an.html
|
||||
* @source http://www.chemicalelements.com/
|
||||
* @source http://www.lenntech.com/periodic/periodic-chart.htm
|
||||
|
@ -13,17 +13,17 @@ public enum ChemElement
|
|||
{
|
||||
/** Placeholder so that hydrogen starts as number one */
|
||||
ZERO("ZERO", "ZERO", 0, 0, null, null),
|
||||
Hydrogen("Hydrogen", "H", 1.00794f, 0.08988f, ElementProperty.nonmetal, MatterPhase.gas, 14.01f, 20.28f, 0.558f, 0.558f, 14300f),
|
||||
Helium("Helium", "He", 4.002602f, 0.1785f, ElementProperty.inertGas, MatterPhase.gas, 0, 4.22f, 0.02f, 0.083f, 5193.1f),
|
||||
Lithium("Lithium", "Li", 6.941f, 0.53f, ElementProperty.inertGas, MatterPhase.gas, 543.69f, 1615f, 3f, 147f, 3570f),
|
||||
Beryllium("Beryllium", "Be", 9.012182f, 1.8477f, ElementProperty.inertGas, MatterPhase.gas, 1560f, 2743f, 7.95f, 297f, 1820f),
|
||||
Boron("Boron", "B", 10.811f, 2.46f, ElementProperty.inertGas, MatterPhase.gas, 2348f, 4273f, 50f, 507f, 1030f),
|
||||
Carbon("Carbon", "C", 12.0107f, 2.26f, ElementProperty.inertGas, MatterPhase.gas, 3823f, 4300f, 105f, 715f, 710f),
|
||||
Nitrogen("Nitrogen", "N", 14.0067f, 1.251f, ElementProperty.inertGas, MatterPhase.gas, 63.05f, 77.36f, 0.36f, 2.79f, 1040),
|
||||
Oxygen("Oxygen", "O", 15.9994f, 1.429f, ElementProperty.inertGas, MatterPhase.gas, 54.8f, 90.2f, 0.222f, 3.41f, 919f),
|
||||
Fluorine("Fluorine", "F", 18.9994f, 1.696f, ElementProperty.inertGas, MatterPhase.gas, 53.5f, 85.03f, 0.26f, 3.27f, 824f),
|
||||
Neon("Neon", "Ne", 20.1797f, 0.9f, ElementProperty.inertGas, MatterPhase.gas, 24.56f, 27.07f, 0.34f, 1.75f, 1030f),
|
||||
Sodium("Sodium", "Na", 22.98976928f, 0.968f, ElementProperty.alkaliMetal, MatterPhase.solid, 370.87f, 1156f, 2.6f, 97.7f, 1230f),
|
||||
Hydrogen("Hydrogen", "H", 1.00794f, 0.08988f, ElementProperty.nonmetal, MatterPhase.gas, new HeatingData(14.01f, 20.28f, 0.558f, 0.558f, 14300f)),
|
||||
Helium("Helium", "He", 4.002602f, 0.1785f, ElementProperty.inertGas, MatterPhase.gas, new HeatingData(0, 4.22f, 0.02f, 0.083f, 5193.1f)),
|
||||
Lithium("Lithium", "Li", 6.941f, 0.53f, ElementProperty.inertGas, MatterPhase.gas, new HeatingData(543.69f, 1615f, 3f, 147f, 3570f)),
|
||||
Beryllium("Beryllium", "Be", 9.012182f, 1.8477f, ElementProperty.inertGas, MatterPhase.gas, new HeatingData(1560f, 2743f, 7.95f, 297f, 1820f)),
|
||||
Boron("Boron", "B", 10.811f, 2.46f, ElementProperty.inertGas, MatterPhase.gas, new HeatingData(2348f, 4273f, 50f, 507f, 1030f)),
|
||||
Carbon("Carbon", "C", 12.0107f, 2.26f, ElementProperty.inertGas, MatterPhase.gas, new HeatingData(3823f, 4300f, 105f, 715f, 710f)),
|
||||
Nitrogen("Nitrogen", "N", 14.0067f, 1.251f, ElementProperty.inertGas, MatterPhase.gas, new HeatingData(63.05f, 77.36f, 0.36f, 2.79f, 1040)),
|
||||
Oxygen("Oxygen", "O", 15.9994f, 1.429f, ElementProperty.inertGas, MatterPhase.gas, new HeatingData(54.8f, 90.2f, 0.222f, 3.41f, 919f)),
|
||||
Fluorine("Fluorine", "F", 18.9994f, 1.696f, ElementProperty.inertGas, MatterPhase.gas, new HeatingData(53.5f, 85.03f, 0.26f, 3.27f, 824f)),
|
||||
Neon("Neon", "Ne", 20.1797f, 0.9f, ElementProperty.inertGas, MatterPhase.gas, new HeatingData(24.56f, 27.07f, 0.34f, 1.75f, 1030f)),
|
||||
Sodium("Sodium", "Na", 22.98976928f, 0.968f, ElementProperty.alkaliMetal, MatterPhase.solid, new HeatingData(370.87f, 1156f, 2.6f, 97.7f, 1230f)),
|
||||
|
||||
Magnesium("Magnesium", "Mg", 24.305f, 1.738f, ElementProperty.alkalineEarthMetal, MatterPhase.solid),
|
||||
aluminium("aluminium", "Al", 26.9815386f, 2.7f, ElementProperty.otherMetal, MatterPhase.solid),
|
||||
|
@ -178,17 +178,7 @@ public enum ChemElement
|
|||
|
||||
public MatterPhase normalPhase;
|
||||
|
||||
public float meltingPointKelvin;
|
||||
public float boilingPointKelvin;
|
||||
/** kJ/mol */
|
||||
public float heatOfFusion;
|
||||
/** kJ/mol */
|
||||
public float heatOfVaporization;
|
||||
/** J/(kg K) */
|
||||
public float specificHeat;
|
||||
/** W/(m K) */
|
||||
public float thermalConductivity;
|
||||
public float thermalExpansion;
|
||||
public HeatingData heatData;
|
||||
|
||||
private ChemElement(String[] name, String symbol, float atomicMass, float density, ElementProperty type, MatterPhase defaultPhase)
|
||||
{
|
||||
|
@ -206,21 +196,11 @@ public enum ChemElement
|
|||
this.density = density;
|
||||
}
|
||||
|
||||
private ChemElement(String[] name, String symbol, float atomicMass, float density, ElementProperty type, MatterPhase defaultPhase, float meltingPoint, float boilingPoint, float fisionHeat, float vaporHeat, float specificHeat)
|
||||
{
|
||||
this(name[0], symbol, atomicMass, density, type, defaultPhase, meltingPoint, boilingPoint, fisionHeat, vaporHeat, specificHeat);
|
||||
this.elementNames = name;
|
||||
}
|
||||
|
||||
private ChemElement(String name, String symbol, float atomicMass, float density, ElementProperty type, MatterPhase defaultPhase, float meltingPoint, float boilingPoint, float fisionHeat, float vaporHeat, float specificHeat)
|
||||
private ChemElement(String name, String symbol, float atomicMass, float density, ElementProperty type, MatterPhase defaultPhase, HeatingData heatData)
|
||||
{
|
||||
this(name, symbol, atomicMass, density, type, defaultPhase);
|
||||
this.heatData = heatData;
|
||||
|
||||
this.meltingPointKelvin = meltingPoint;
|
||||
this.boilingPointKelvin = boilingPoint;
|
||||
this.heatOfFusion = fisionHeat;
|
||||
this.heatOfVaporization = vaporHeat;
|
||||
this.specificHeat = specificHeat;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
27
src/com/builtbroken/common/science/HeatingData.java
Normal file
27
src/com/builtbroken/common/science/HeatingData.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
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
|
||||
{
|
||||
|
||||
public float meltingPoint, boilingPoint, fisionHeat, vaporHeat, specificHeat, thermalExpasion, thermalConductivity;
|
||||
|
||||
public HeatingData(float meltingPoint, float boilingPoint, float fisionHeat, float vaporHeat, float specificHeat)
|
||||
{
|
||||
this.meltingPoint = meltingPoint;
|
||||
this.boilingPoint = boilingPoint;
|
||||
this.fisionHeat = fisionHeat;
|
||||
this.vaporHeat = vaporHeat;
|
||||
this.specificHeat = specificHeat;
|
||||
}
|
||||
|
||||
public HeatingData(float meltingPoint, float boilingPoint, float fisionHeat, float vaporHeat, float specificHeat, float thermalExpansion, float thermalConductivity)
|
||||
{
|
||||
this(meltingPoint, boilingPoint, fisionHeat, vaporHeat, specificHeat);
|
||||
this.thermalConductivity = thermalConductivity;
|
||||
this.thermalExpasion = thermalExpansion;
|
||||
}
|
||||
}
|
65
src/dark/api/fluid/FluidMasterList.java
Normal file
65
src/dark/api/fluid/FluidMasterList.java
Normal file
|
@ -0,0 +1,65 @@
|
|||
package dark.api.fluid;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import com.builtbroken.common.Pair;
|
||||
|
||||
public class FluidMasterList
|
||||
{
|
||||
public static HashMap<String, Float> moltenFluids = new HashMap();
|
||||
/** Map containing items to FluidStack for melting down. Anything not in the list will be turned
|
||||
* into slag. */
|
||||
public static HashMap<Pair<Integer, Integer>, FluidStack> meltDownMap = new HashMap();
|
||||
|
||||
public static final Fluid WATER = FluidRegistry.WATER;
|
||||
public static final Fluid LAVA = FluidRegistry.LAVA;
|
||||
|
||||
static
|
||||
{
|
||||
//http://www.engineeringtoolbox.com/melting-temperature-metals-d_860.html
|
||||
moltenFluids.put("lava", 1200f);
|
||||
moltenFluids.put("molten-iron", 1200f);
|
||||
moltenFluids.put("molten-gold", 1063f);
|
||||
moltenFluids.put("molten-silver", 1000f);
|
||||
}
|
||||
|
||||
/** Registers a fluid, by fluid name, as a molten fluids so pipes will interact with it different
|
||||
*
|
||||
* @param name - fluid name
|
||||
* @param heatValue - temperature of the fluid */
|
||||
public static void registerMoltenFluid(String name, float heatValue)
|
||||
{
|
||||
if (name != null && heatValue > 0)
|
||||
{
|
||||
moltenFluids.put(name, heatValue);
|
||||
}
|
||||
}
|
||||
|
||||
/** Try to only register very simple items as a reverse recipe system will be used to get to the
|
||||
* items used to craft the object
|
||||
*
|
||||
* @param id - item id
|
||||
* @param meta - item meta
|
||||
* @param stack - fluid stack to return */
|
||||
public static void registerMeltDown(int id, int meta, FluidStack stack)
|
||||
{
|
||||
if (id > 0 && stack != null)
|
||||
{
|
||||
meltDownMap.put(new Pair<Integer, Integer>(id, meta), stack);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isMolten(Fluid fluid)
|
||||
{
|
||||
return fluid != null && moltenFluids.containsKey(fluid.getName());
|
||||
}
|
||||
|
||||
public static float getHeatPerPass(Fluid fluid)
|
||||
{
|
||||
return moltenFluids.get(fluid.getName());
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ public interface INetworkPart extends ITileConnector
|
|||
public NetworkTileEntities getTileNetwork();
|
||||
|
||||
/** Sets the networkPart's primary network */
|
||||
public void setTileNetwork(NetworkTileEntities fluidNetwok);
|
||||
public void setTileNetwork(NetworkTileEntities fluidNetwork);
|
||||
|
||||
public boolean mergeDamage(String result);
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class FluidHelper
|
|||
}
|
||||
|
||||
/** Gets the block's fluid if it has one
|
||||
*
|
||||
*
|
||||
* @param world - world we are working in
|
||||
* @param vector - 3D location in world
|
||||
* @return @Fluid that the block is */
|
||||
|
@ -101,10 +101,10 @@ public class FluidHelper
|
|||
}
|
||||
|
||||
/** Drains a block of fluid
|
||||
*
|
||||
*
|
||||
* @Note sets the block with a client update only. Doesn't tick the block allowing for better
|
||||
* placement of fluid that can flow infinitely
|
||||
*
|
||||
*
|
||||
* @param doDrain - do the action
|
||||
* @return FluidStack drained from the block */
|
||||
public static FluidStack drainBlock(World world, Vector3 node, boolean doDrain)
|
||||
|
@ -113,7 +113,7 @@ public class FluidHelper
|
|||
}
|
||||
|
||||
/** Drains a block of fluid
|
||||
*
|
||||
*
|
||||
* @param doDrain - do the action
|
||||
* @param update - block update flag to use
|
||||
* @return FluidStack drained from the block */
|
||||
|
@ -212,9 +212,9 @@ public class FluidHelper
|
|||
}
|
||||
|
||||
/** Helper method to fill a location with a fluid
|
||||
*
|
||||
*
|
||||
* Note: This does not update the block to prevent the liquid from flowing
|
||||
*
|
||||
*
|
||||
* @return */
|
||||
public static int fillBlock(World world, Vector3 node, FluidStack stack, boolean doFill)
|
||||
{
|
||||
|
@ -248,7 +248,7 @@ public class FluidHelper
|
|||
}
|
||||
|
||||
/** Fills all instances of IFluidHandler surrounding the origin
|
||||
*
|
||||
*
|
||||
* @param stack - FluidStack that will be filled into the tanks
|
||||
* @param doFill - Actually perform the action or simulate action
|
||||
* @param ignore - ForgeDirections to ignore
|
||||
|
@ -281,7 +281,7 @@ public class FluidHelper
|
|||
}
|
||||
|
||||
/** Fills an instance of IFluidHandler in the given direction
|
||||
*
|
||||
*
|
||||
* @param stack - FluidStack to fill the tank will
|
||||
* @param doFill - Actually perform the action or simulate action
|
||||
* @param direction - direction to fill in from the origin
|
||||
|
@ -359,7 +359,7 @@ public class FluidHelper
|
|||
}
|
||||
|
||||
/** Drains an item of fluid and fills the tank with what was drained
|
||||
*
|
||||
*
|
||||
* @param consumeItem - should it consume the item. Used mainly for creative mode players. This
|
||||
* does effect the return of the method
|
||||
* @return Item stack that would be returned if the item was drain of its fluid. Water bucket ->
|
||||
|
@ -381,7 +381,7 @@ public class FluidHelper
|
|||
}
|
||||
|
||||
/** Fills an item with fluid from the tank
|
||||
*
|
||||
*
|
||||
* @param consumeItem - should it consume the item. Used mainly for creative mode players. This
|
||||
* does effect the return of the method
|
||||
* @return Item stack that would be returned if the item was filled with fluid. empty bucket ->
|
||||
|
@ -438,60 +438,4 @@ public class FluidHelper
|
|||
return stackList;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Fluid restriction handler for color codes
|
||||
*/
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onLiquidRegistered(FluidRegisterEvent event)
|
||||
{
|
||||
if (event != null && event.fluidName != null)
|
||||
{
|
||||
Fluid fluid = FluidRegistry.getFluid(event.fluidName);
|
||||
if (event.fluidName.equalsIgnoreCase("Fuel") && !restrictedStacks.containsKey(ColorCode.YELLOW))
|
||||
{
|
||||
restrictedStacks.put(ColorCode.YELLOW, fluid);
|
||||
}
|
||||
else if (event.fluidName.equalsIgnoreCase("Oil") && !restrictedStacks.containsKey(ColorCode.BLACK))
|
||||
{
|
||||
restrictedStacks.put(ColorCode.BLACK, fluid);
|
||||
}
|
||||
else if (event.fluidName.equalsIgnoreCase("Milk") && !restrictedStacks.containsKey(ColorCode.WHITE))
|
||||
{
|
||||
restrictedStacks.put(ColorCode.WHITE, fluid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Checks too see if a color has a restricted stack */
|
||||
public static boolean hasRestrictedStack(int meta)
|
||||
{
|
||||
return restrictedStacks.containsKey(ColorCode.get(meta));
|
||||
}
|
||||
|
||||
public static boolean hasRestrictedStack(Fluid stack)
|
||||
{
|
||||
return stack != null && restrictedStacks.inverse().containsKey(stack);
|
||||
}
|
||||
|
||||
/** gets the liquid stack that is restricted to this color */
|
||||
public static Fluid getStackForColor(ColorCode color)
|
||||
{
|
||||
return restrictedStacks.get(color);
|
||||
}
|
||||
|
||||
/** checks to see if the liquidStack is valid for the given color */
|
||||
public static boolean isValidLiquid(ColorCode color, Fluid stack)
|
||||
{
|
||||
if (stack == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!FluidHelper.hasRestrictedStack(color.ordinal()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return FluidHelper.hasRestrictedStack(color.ordinal()) && FluidHelper.getStackForColor(color).equals(stack);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue