From bdfda349852517150b5a11ea1f1f2150f4b983fd Mon Sep 17 00:00:00 2001 From: Boblet Date: Mon, 25 Apr 2022 16:51:14 +0200 Subject: [PATCH 1/2] some heatex fixes --- .../com/hbm/inventory/fluid/FluidType.java | 29 ++++++++++--- .../java/com/hbm/inventory/fluid/Fluids.java | 12 +++--- .../tileentity/machine/rbmk/RBMKDials.java | 2 +- .../machine/rbmk/TileEntityRBMKBoiler.java | 2 +- .../machine/rbmk/TileEntityRBMKHeater.java | 5 ++- src/main/java/com/hbm/util/HeatUtil.java | 43 +++++++++++++++++++ 6 files changed, 78 insertions(+), 15 deletions(-) create mode 100644 src/main/java/com/hbm/util/HeatUtil.java diff --git a/src/main/java/com/hbm/inventory/fluid/FluidType.java b/src/main/java/com/hbm/inventory/fluid/FluidType.java index d7fa2ef07..db655e5ca 100644 --- a/src/main/java/com/hbm/inventory/fluid/FluidType.java +++ b/src/main/java/com/hbm/inventory/fluid/FluidType.java @@ -18,8 +18,11 @@ public class FluidType { //The numeric ID of the fluid private int id; + //The internal name + private String stringId; //Approximate HEX Color of the fluid, used for pipe rendering private int color; + //The color for containers, not the liquid itself. Used for canisters. private int containerColor = 0xffffff; //Unlocalized string ID of the fluid private String unlocalized; @@ -28,11 +31,20 @@ public class FluidType { public int flammability; public int reactivity; public EnumSymbol symbol; - public int temperature; - public double heatCap; + + public static final int ROOM_TEMPERATURE = 20; + public static final double DEFAULT_HEATCAP = 0.01D; + public static final double DEFAULT_COMPRESSION = 1D; + + /** How hot this fluid is. Simple enough. */ + public int temperature = ROOM_TEMPERATURE; + /** How much heat energy each mB requires to be heated by 1°C. Total heat energy = heatCap * delta-T. */ + public double heatCap = DEFAULT_HEATCAP; + /** How much "stuff" there is in one mB. 1mB of water turns into 100mB of steam, therefore steam has a compression of 0.01. Compression is only used for translating fluids into other fluids, heat calculations should ignore this. */ + public double compression = DEFAULT_COMPRESSION; + public Set containers = new HashSet(); public List traits = new ArrayList(); - private String stringId; private ResourceLocation texture; @@ -67,6 +79,11 @@ public class FluidType { return this; } + public FluidType setCompression(double compression) { + this.compression = compression; + return this; + } + public FluidType addContainers(int color, ExtContainer... containers) { this.containerColor = color; Collections.addAll(this.containers, containers); @@ -145,8 +162,10 @@ public class FluidType { public void addInfo(List info) { - if(temperature < 0) info.add(EnumChatFormatting.BLUE + "" + temperature + "°C"); - if(temperature > 0) info.add(EnumChatFormatting.RED + "" + temperature + "°C"); + if(temperature != ROOM_TEMPERATURE) { + if(temperature < 0) info.add(EnumChatFormatting.BLUE + "" + temperature + "°C"); + if(temperature > 0) info.add(EnumChatFormatting.RED + "" + temperature + "°C"); + } if(isAntimatter()) info.add(EnumChatFormatting.DARK_RED + "Antimatter"); if(traits.contains(FluidTrait.CORROSIVE_2)) info.add(EnumChatFormatting.GOLD + "Strongly Corrosive"); diff --git a/src/main/java/com/hbm/inventory/fluid/Fluids.java b/src/main/java/com/hbm/inventory/fluid/Fluids.java index f4697e7de..22d9b1972 100644 --- a/src/main/java/com/hbm/inventory/fluid/Fluids.java +++ b/src/main/java/com/hbm/inventory/fluid/Fluids.java @@ -112,10 +112,10 @@ public class Fluids { NONE = new FluidType( "NONE", 0x888888, 0, 0, 0, EnumSymbol.NONE); WATER = new FluidType( "WATER", 0x3333FF, 0, 0, 0, EnumSymbol.NONE); - STEAM = new FluidType( "STEAM", 0xe5e5e5, 3, 0, 0, EnumSymbol.NONE).setTemp(100); - HOTSTEAM = new FluidType( "HOTSTEAM", 0xE7D6D6, 4, 0, 0, EnumSymbol.NONE).setTemp(300); - SUPERHOTSTEAM = new FluidType( "SUPERHOTSTEAM", 0xE7B7B7, 4, 0, 0, EnumSymbol.NONE).setTemp(450); - ULTRAHOTSTEAM = new FluidType( "ULTRAHOTSTEAM", 0xE39393, 4, 0, 0, EnumSymbol.NONE).setTemp(600); + STEAM = new FluidType( "STEAM", 0xe5e5e5, 3, 0, 0, EnumSymbol.NONE).setTemp(100).setCompression(0.01D); + HOTSTEAM = new FluidType( "HOTSTEAM", 0xE7D6D6, 4, 0, 0, EnumSymbol.NONE).setTemp(300).setCompression(0.1D); + SUPERHOTSTEAM = new FluidType( "SUPERHOTSTEAM", 0xE7B7B7, 4, 0, 0, EnumSymbol.NONE).setTemp(450).setCompression(1D); + ULTRAHOTSTEAM = new FluidType( "ULTRAHOTSTEAM", 0xE39393, 4, 0, 0, EnumSymbol.NONE).setTemp(600).setCompression(10D); COOLANT = new FluidType( "COOLANT", 0xd8fcff, 1, 0, 0, EnumSymbol.NONE).setHeatCap(0.25D); LAVA = new FluidType( "LAVA", 0xFF3300, 4, 0, 0, EnumSymbol.NOWATER).setTemp(1200); DEUTERIUM = new FluidTypeCombustible( "DEUTERIUM", 0x0000FF, 3, 4, 0, EnumSymbol.NONE).setCombustionEnergy(FuelGrade.HIGH, 10_000).setHeatEnergy(5_000); @@ -158,7 +158,7 @@ public class Fluids { WASTEGAS = new FluidType( "WASTEGAS", 0xB8B8B8, 2, 0, 1, EnumSymbol.RADIATION).addTraits(FluidTrait.NO_CONTAINER); GASOLINE = new FluidTypeCombustible( "GASOLINE", 0x445772, 1, 2, 0, EnumSymbol.NONE).setCombustionEnergy(FuelGrade.HIGH, 1_000_000).setHeatEnergy(400_000).addContainers(0x2F7747, ExtContainer.CANISTER); COALGAS = new FluidTypeCombustible( "COALGAS", 0x445772, 1, 2, 0, EnumSymbol.NONE).setCombustionEnergy(FuelGrade.MEDIUM, 150_000).setHeatEnergy(75_000); - SPENTSTEAM = new FluidType( "SPENTSTEAM", 0x445772, 2, 0, 0, EnumSymbol.NONE).addTraits(FluidTrait.NO_CONTAINER); + SPENTSTEAM = new FluidType( "SPENTSTEAM", 0x445772, 2, 0, 0, EnumSymbol.NONE).addTraits(FluidTrait.NO_CONTAINER).setCompression(1D); FRACKSOL = new FluidType( "FRACKSOL", 0x798A6B, 1, 3, 3, EnumSymbol.ACID).addTraits(FluidTrait.CORROSIVE).addContainers(0x4F887F, ExtContainer.CANISTER); PLASMA_DT = new FluidType( "PLASMA_DT", 0xF7AFDE, 0, 4, 0, EnumSymbol.RADIATION).setTemp(3250).addTraits(FluidTrait.NO_CONTAINER, FluidTrait.NO_ID); PLASMA_HD = new FluidType( "PLASMA_HD", 0xF0ADF4, 0, 4, 0, EnumSymbol.RADIATION).setTemp(2500).addTraits(FluidTrait.NO_CONTAINER, FluidTrait.NO_ID); @@ -186,7 +186,7 @@ public class Fluids { GASOLINE_LEADED = new FluidTypeCombustible( "GASOLINE_LEADED", 0x445772, 1, 2, 0, EnumSymbol.NONE).setCombustionEnergy(FuelGrade.HIGH, 1_500_000).setHeatEnergy(((FluidTypeFlammable)GASOLINE).getHeatEnergy()); COALGAS_LEADED = new FluidTypeCombustible( "COALGAS_LEADED", 0x445772, 1, 2, 0, EnumSymbol.NONE).setCombustionEnergy(FuelGrade.MEDIUM, 250_000).setHeatEnergy(((FluidTypeFlammable)COALGAS).getHeatEnergy()); SULFURIC_ACID = new FluidType( "SULFURIC_ACID", 0xB0AA64, 3, 0, 2, EnumSymbol.ACID).addTraits(FluidTrait.CORROSIVE); - COOLANT_HOT = new FluidType( "COOLANT_HOT", 0x99525E, 1, 0, 0, EnumSymbol.NONE).setTemp(600).setHeatCap(STEAM.heatCap); + COOLANT_HOT = new FluidType( "COOLANT_HOT", 0x99525E, 1, 0, 0, EnumSymbol.NONE).setTemp(600).setHeatCap(COOLANT.heatCap); MUG = new FluidType( "MUG", 0x4B2D28, 0, 0, 0, EnumSymbol.NONE).setHeatCap(1D); MUG_HOT = new FluidType( "MUG_HOT", 0x6B2A20, 0, 0, 0, EnumSymbol.NONE).setHeatCap(MUG.heatCap).setTemp(500); diff --git a/src/main/java/com/hbm/tileentity/machine/rbmk/RBMKDials.java b/src/main/java/com/hbm/tileentity/machine/rbmk/RBMKDials.java index c632fc364..ba6bd2f36 100644 --- a/src/main/java/com/hbm/tileentity/machine/rbmk/RBMKDials.java +++ b/src/main/java/com/hbm/tileentity/machine/rbmk/RBMKDials.java @@ -109,7 +109,7 @@ public class RBMKDials { } /** - * How many heat units are consumed per steam unit (scaled per type) produced. + * How many heat units are consumed per mB water used. * @param world * @return >0 */ diff --git a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKBoiler.java b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKBoiler.java index f73271f66..b89800e81 100644 --- a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKBoiler.java +++ b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKBoiler.java @@ -57,7 +57,7 @@ public class TileEntityRBMKBoiler extends TileEntityRBMKSlottedBase implements I steam.setFill(steam.getMaxFill()); } - this.heat -= waterUsed * feed.getTankType().heatCap; + this.heat -= waterUsed * RBMKDials.getBoilerHeatConsumption(worldObj); } fillFluidInit(steam.getTankType()); diff --git a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKHeater.java b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKHeater.java index 1ee65fb2c..44c0db5e1 100644 --- a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKHeater.java +++ b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKHeater.java @@ -48,12 +48,13 @@ public class TileEntityRBMKHeater extends TileEntityRBMKSlottedBase implements I if(heatProvided > 0) { - int converted = (int)Math.floor(heatProvided / RBMKDials.getBoilerHeatConsumption(worldObj)); + double capacity = feed.getTankType().heatCap; + int converted = (int)Math.floor(heatProvided / capacity); converted = Math.min(converted, feed.getFill()); converted = Math.min(converted, steam.getMaxFill() - steam.getFill()); feed.setFill(feed.getFill() - converted); steam.setFill(steam.getFill() + converted); - this.heat -= converted * RBMKDials.getBoilerHeatConsumption(worldObj); + this.heat -= converted * capacity; } fillFluidInit(steam.getTankType()); diff --git a/src/main/java/com/hbm/util/HeatUtil.java b/src/main/java/com/hbm/util/HeatUtil.java new file mode 100644 index 000000000..711d3bc6b --- /dev/null +++ b/src/main/java/com/hbm/util/HeatUtil.java @@ -0,0 +1,43 @@ +package com.hbm.util; + +import com.hbm.inventory.FluidTank; +import com.hbm.inventory.fluid.FluidType; + +public class HeatUtil { + + /** + * Returns the amount of mB (with decimals!) of the supplied fluid that can be saturated with the given amount of heat + * @param toHeat The type of fluid that should be saturated + * @param heat The amount of heat used + * @return The amount of fluid that can be fully heated + */ + public static double getHeatableAmount(FluidType toHeat, double heat) { + return heat / (toHeat.heatCap * toHeat.temperature); + } + + /** + * @param fluid + * @param amount + * @return The total heat energy stored in the given fluid (with a delta from the fluid's temp to 0°C) + */ + public static double getHeatEnergy(FluidType fluid, int amount) { + return fluid.heatCap * fluid.temperature * amount; + } + + public static double getAmountAtStandardPressure(FluidType type, int pressurizedAmount) { + return pressurizedAmount * type.compression; + } + + public static double getAmountPressurized(FluidType type, int depressurizedAmount) { + return depressurizedAmount / type.compression; + } + + //brain mush, will do math later + /*public static double boilTo(FluidTank cold, FluidTank hot, double heat) { + int pressurizedFluid = cold.getFill(); + int pressurizedSpace = hot.getMaxFill() - hot.getFill(); + + //how much heat energy our input tank has + double initialHeat = getHeatEnergy(cold.getTankType(), pressurizedFluid); + }*/ +} From 2e3e47fce7d23afd33d6a13e1c7db8069c1c2ada Mon Sep 17 00:00:00 2001 From: Bob Date: Mon, 25 Apr 2022 21:27:47 +0200 Subject: [PATCH 2/2] mug recipe --- .../java/com/hbm/inventory/recipes/LiquefactionRecipes.java | 1 + src/main/java/com/hbm/lib/RefStrings.java | 2 +- src/main/resources/mcmod.info | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/hbm/inventory/recipes/LiquefactionRecipes.java b/src/main/java/com/hbm/inventory/recipes/LiquefactionRecipes.java index 36a3fe87b..9cfdac1cd 100644 --- a/src/main/java/com/hbm/inventory/recipes/LiquefactionRecipes.java +++ b/src/main/java/com/hbm/inventory/recipes/LiquefactionRecipes.java @@ -29,6 +29,7 @@ public class LiquefactionRecipes { recipes.put(KEY_OIL_TAR, new FluidStack(75, Fluids.BITUMEN)); recipes.put(KEY_CRACK_TAR, new FluidStack(100, Fluids.BITUMEN)); recipes.put(KEY_COAL_TAR, new FluidStack(50, Fluids.BITUMEN)); + recipes.put(KEY_LOG, new FluidStack(100, Fluids.MUG)); //general utility recipes because why not recipes.put(new ComparableStack(Blocks.netherrack), new FluidStack(250, Fluids.LAVA)); recipes.put(new ComparableStack(Blocks.cobblestone), new FluidStack(250, Fluids.LAVA)); diff --git a/src/main/java/com/hbm/lib/RefStrings.java b/src/main/java/com/hbm/lib/RefStrings.java index 7a6c469aa..b4f3f9502 100644 --- a/src/main/java/com/hbm/lib/RefStrings.java +++ b/src/main/java/com/hbm/lib/RefStrings.java @@ -3,7 +3,7 @@ package com.hbm.lib; public class RefStrings { public static final String MODID = "hbm"; public static final String NAME = "Hbm's Nuclear Tech Mod"; - public static final String VERSION = "1.0.27 BETA (4214)"; + public static final String VERSION = "1.0.27 BETA (4215)"; //HBM's Beta Naming Convention: //V T (X) //V -> next release version diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 72b22a978..5105203b2 100755 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -3,7 +3,7 @@ "modid": "hbm", "name": "Hbm's Nuclear Tech", "description": "A mod that adds weapons, nuclear themed stuff and machines", - "version":"1.0.27_X4214", + "version":"1.0.27_X4215", "mcversion": "1.7.10", "url": "", "updateUrl": "",