Skip to content

Commit

Permalink
Add configs for most of the tank capacities' in various multiblocks
Browse files Browse the repository at this point in the history
  • Loading branch information
pupnewfster committed Jan 22, 2023
1 parent 0b40f2d commit 2a93818
Show file tree
Hide file tree
Showing 11 changed files with 151 additions and 61 deletions.
Expand Up @@ -11,9 +11,11 @@
import mekanism.common.config.value.CachedLongValue;
import mekanism.common.config.value.CachedResourceLocationListValue;
import mekanism.generators.common.content.fission.FissionReactorMultiblockData;
import mekanism.generators.common.content.fusion.FusionReactorMultiblockData;
import mekanism.generators.common.tile.TileEntityHeatGenerator;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.fluids.FluidType;
import net.minecraftforge.fml.config.ModConfig.Type;

public class GeneratorsConfig extends BaseMekanismConfig {
Expand Down Expand Up @@ -42,7 +44,10 @@ public class GeneratorsConfig extends BaseMekanismConfig {
public final CachedIntValue turbineBladesPerCoil;
public final CachedDoubleValue turbineVentGasFlow;
public final CachedDoubleValue turbineDisperserGasFlow;
public final CachedFloatingLongValue turbineEnergyCapacityPerVolume;
public final CachedLongValue turbineGasPerTank;
public final CachedIntValue condenserRate;

public final CachedFloatingLongValue energyPerFusionFuel;
public final CachedFloatingLongValue windGenerationMin;
public final CachedFloatingLongValue windGenerationMax;
Expand All @@ -60,13 +65,20 @@ public class GeneratorsConfig extends BaseMekanismConfig {
public final CachedDoubleValue fissionPostMeltdownDamage;
public final CachedDoubleValue defaultBurnRate;
public final CachedLongValue burnPerAssembly;
public final CachedLongValue maxFuelPerAssembly;
public final CachedIntValue fissionCooledCoolantPerTank;
public final CachedLongValue fissionHeatedCoolantPerTank;

public final CachedLongValue hohlraumMaxGas;
public final CachedLongValue hohlraumFillRate;

public final CachedDoubleValue fusionThermocoupleEfficiency;
public final CachedDoubleValue fusionCasingThermalConductivity;
public final CachedDoubleValue fusionWaterHeatingRatio;
public final CachedLongValue fusionFuelCapacity;
public final CachedFloatingLongValue fusionEnergyCapacity;
public final CachedIntValue fusionWaterPerInjection;
public final CachedLongValue fusionSteamPerInjection;

GeneratorsConfig() {
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
Expand Down Expand Up @@ -106,6 +118,12 @@ public class GeneratorsConfig extends BaseMekanismConfig {
.defineInRange("turbineVentGasFlow", 32_000D, 0.1, 1_024_000));
turbineDisperserGasFlow = CachedDoubleValue.wrap(this, builder.comment("The rate at which steam is dispersed into the turbine.")
.defineInRange("turbineDisperserGasFlow", 1_280D, 0.1, 1_024_000));
turbineEnergyCapacityPerVolume = CachedFloatingLongValue.define(this, builder, "Amount of energy (J) that each block of the turbine contributes to the total energy capacity. Max = volume * energyCapacityPerVolume",
"energyCapacityPerVolume", FloatingLong.createConst(16_000_000L), CachedFloatingLongValue.greaterZeroLessThan(FloatingLong.createConst(1_000_000_000_000L)));
//Note: We use maxVolume as it still is a large number, and we have no reason to go higher even if some things we technically could
int maxTurbine = 17 * 17 * 18;
turbineGasPerTank = CachedLongValue.wrap(this, builder.comment("Amount of gas (mB) that each block of the turbine's steam cavity contributes to the volume. Max = volume * gasPerTank")
.defineInRange("gasPerTank", 64 * FluidType.BUCKET_VOLUME, 1, Long.MAX_VALUE / maxTurbine));
condenserRate = CachedIntValue.wrap(this, builder.comment("The rate at which steam is condensed in the turbine.")
.defineInRange("condenserRate", 64_000, 1, 2_000_000));
builder.pop();
Expand Down Expand Up @@ -134,6 +152,15 @@ public class GeneratorsConfig extends BaseMekanismConfig {
.defineInRange("casingThermalConductivity", 0.1D, 0.001D, 1D));
fusionWaterHeatingRatio = CachedDoubleValue.wrap(this, builder.comment("The fraction of the heat from the casing that is dissipated to water when water cooling is in use. Will impact max heat, and steam generation.")
.defineInRange("waterHeatingRatio", 0.3D, 0D, 1D));
fusionFuelCapacity = CachedLongValue.wrap(this, builder.comment("Amount of fuel (mB) that the fusion reactor can store.")
.defineInRange("fuelCapacity", (long) FluidType.BUCKET_VOLUME, 2, 1_000 * FluidType.BUCKET_VOLUME));
fusionEnergyCapacity = CachedFloatingLongValue.define(this, builder, "Amount of energy (J) the fusion reactor can store.",
"energyCapacity", FloatingLong.createConst(1_000_000_000), CachedFloatingLongValue.POSITIVE);
int baseMaxWater = 1_000 * FluidType.BUCKET_VOLUME;
fusionWaterPerInjection = CachedIntValue.wrap(this, builder.comment("Amount of water (mB) per injection rate that the fusion reactor can store. Max = injectionRate * waterPerInjection")
.defineInRange("waterPerInjection", 1_000 * FluidType.BUCKET_VOLUME, 1, Integer.MAX_VALUE / FusionReactorMultiblockData.MAX_INJECTION));
fusionSteamPerInjection = CachedLongValue.wrap(this, builder.comment("Amount of steam (mB) per injection rate that the fusion reactor can store. Max = injectionRate * steamPerInjection")
.defineInRange("steamPerInjection", 100 * baseMaxWater, 1, Long.MAX_VALUE / FusionReactorMultiblockData.MAX_INJECTION));
builder.pop();

builder.comment("Hohlraum Settings").push(HOHLRAUM_CATEGORY);
Expand Down Expand Up @@ -164,6 +191,13 @@ public class GeneratorsConfig extends BaseMekanismConfig {
.defineInRange("defaultBurnRate", 0.1D, 0.001D, 1D));
burnPerAssembly = CachedLongValue.wrap(this, builder.comment("The burn rate increase each fuel assembly provides. Max Burn Rate = fuelAssemblies * burnPerAssembly")
.defineInRange("burnPerAssembly", 1L, 1, 1_000_000));
maxFuelPerAssembly = CachedLongValue.wrap(this, builder.comment("Amount of fuel (mB) that each assembly contributes to the fuel and waste capacity. Max = fuelAssemblies * maxFuelPerAssembly")
.defineInRange("maxFuelPerAssembly", 8 * FluidType.BUCKET_VOLUME, 1, Long.MAX_VALUE / 4_096));
int maxVolume = 18 * 18 * 18;
fissionCooledCoolantPerTank = CachedIntValue.wrap(this, builder.comment("Amount of cooled coolant (mB) that each block of the fission reactor contributes to the volume. Max = volume * cooledCoolantPerTank")
.defineInRange("cooledCoolantPerTank", 100 * FluidType.BUCKET_VOLUME, 1, Integer.MAX_VALUE / maxVolume));
fissionHeatedCoolantPerTank = CachedLongValue.wrap(this, builder.comment("Amount of heated coolant (mB) that each block of the fission reactor contributes to the volume. Max = volume * heatedCoolantPerTank")
.defineInRange("heatedCoolantPerTank", 1_000 * FluidType.BUCKET_VOLUME, 1_000, Long.MAX_VALUE / maxVolume));
builder.pop();

builder.pop();
Expand Down
Expand Up @@ -4,6 +4,7 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.function.LongSupplier;
import mekanism.api.Action;
import mekanism.api.AutomationType;
import mekanism.api.Coord4D;
Expand Down Expand Up @@ -57,20 +58,16 @@ public class FissionReactorMultiblockData extends MultiblockData implements IVal

private static final double waterConductivity = 0.5;

private static final int COOLANT_PER_VOLUME = 100_000;
private static final long HEATED_COOLANT_PER_VOLUME = 1_000_000;
private static final long FUEL_PER_ASSEMBLY = 8_000;

public static final double MIN_DAMAGE_TEMPERATURE = 1_200;
public static final double MAX_DAMAGE_TEMPERATURE = 1_800;
public static final double MAX_DAMAGE = 100;

private static final double EXPLOSION_CHANCE = 1D / (512_000);
private static final double EXPLOSION_CHANCE = 1D / 512_000;

public final Set<FormedAssembly> assemblies = new LinkedHashSet<>();
@ContainerSync
@ContainerSync(setter = "setAssemblies")
@SyntheticComputerMethod(getter = "getFuelAssemblies")
public int fuelAssemblies = 1;
private int fuelAssemblies = 1;
@ContainerSync
@SyntheticComputerMethod(getter = "getFuelSurfaceArea")
public int surfaceArea;
Expand Down Expand Up @@ -117,6 +114,10 @@ public class FissionReactorMultiblockData extends MultiblockData implements IVal
@ContainerSync
private boolean forceDisable;

private int cooledCoolantCapacity;
private long heatedCoolantCapacity;
private long fuelCapacity;

private AABB hotZone;

public float prevCoolantScale;
Expand All @@ -128,16 +129,17 @@ public FissionReactorMultiblockData(TileEntityFissionReactorCasing tile) {
super(tile);
//Default biome temp to the ambient temperature at the block we are at
biomeAmbientTemp = HeatAPI.getAmbientTemp(tile.getLevel(), tile.getTilePos());
fluidCoolantTank = VariableCapacityFluidTank.input(this, () -> getVolume() * COOLANT_PER_VOLUME,
LongSupplier fuelCapacitySupplier = () -> fuelCapacity;
fluidCoolantTank = VariableCapacityFluidTank.input(this, () -> cooledCoolantCapacity,
fluid -> MekanismTags.Fluids.WATER_LOOKUP.contains(fluid.getFluid()) && gasCoolantTank.isEmpty(), this);
fluidTanks.add(fluidCoolantTank);
gasCoolantTank = MultiblockChemicalTankBuilder.GAS.input(this, () -> (long) getVolume() * COOLANT_PER_VOLUME,
gasCoolantTank = MultiblockChemicalTankBuilder.GAS.input(this, () -> cooledCoolantCapacity,
gas -> gas.has(CooledCoolant.class) && fluidCoolantTank.isEmpty(), this);
fuelTank = MultiblockChemicalTankBuilder.GAS.input(this, () -> fuelAssemblies * FUEL_PER_ASSEMBLY, gas -> gas == MekanismGases.FISSILE_FUEL.getChemical(),
fuelTank = MultiblockChemicalTankBuilder.GAS.input(this, fuelCapacitySupplier, gas -> gas == MekanismGases.FISSILE_FUEL.getChemical(),
ChemicalAttributeValidator.ALWAYS_ALLOW, createSaveAndComparator());
heatedCoolantTank = MultiblockChemicalTankBuilder.GAS.output(this, () -> getVolume() * HEATED_COOLANT_PER_VOLUME,
heatedCoolantTank = MultiblockChemicalTankBuilder.GAS.output(this, () -> heatedCoolantCapacity,
gas -> gas == MekanismGases.STEAM.get() || gas.has(HeatedCoolant.class), this);
wasteTank = MultiblockChemicalTankBuilder.GAS.output(this, () -> fuelAssemblies * FUEL_PER_ASSEMBLY,
wasteTank = MultiblockChemicalTankBuilder.GAS.output(this, fuelCapacitySupplier,
gas -> gas == MekanismGases.NUCLEAR_WASTE.getChemical(), ChemicalAttributeValidator.ALWAYS_ALLOW, this);
Collections.addAll(gasTanks, fuelTank, heatedCoolantTank, wasteTank, gasCoolantTank);
heatCapacitor = VariableHeatCapacitor.create(MekanismGeneratorsConfig.generators.fissionCasingHeatCapacity.get(),
Expand Down Expand Up @@ -467,6 +469,22 @@ public long getDamagePercent() {
return Math.round((reactorDamage / FissionReactorMultiblockData.MAX_DAMAGE) * 100);
}

public void setAssemblies(int assemblies) {
if (this.fuelAssemblies != assemblies) {
this.fuelAssemblies = assemblies;
this.fuelCapacity = assemblies * MekanismGeneratorsConfig.generators.maxFuelPerAssembly.get();
}
}

@Override
public void setVolume(int volume) {
if (getVolume() != volume) {
super.setVolume(volume);
cooledCoolantCapacity = volume * MekanismGeneratorsConfig.generators.fissionCooledCoolantPerTank.get();
heatedCoolantCapacity = volume * MekanismGeneratorsConfig.generators.fissionHeatedCoolantPerTank.get();
}
}

@Override
protected int getMultiblockRedstoneLevel() {
return MekanismUtils.redstoneLevelFromContents(fuelTank.getStored(), fuelTank.getCapacity());
Expand Down
Expand Up @@ -106,7 +106,7 @@ public FormationResult postcheck(FissionReactorMultiblockData structure, Long2Ob
structure.assemblies.add(assembly.build());
}

structure.fuelAssemblies = assemblyCount;
structure.setAssemblies(assemblyCount);
structure.surfaceArea = surfaceArea;

return FormationResult.SUCCESS;
Expand Down
Expand Up @@ -4,7 +4,6 @@
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.function.LongSupplier;
import mekanism.api.Action;
import mekanism.api.AutomationType;
import mekanism.api.NBTConstants;
Expand All @@ -19,7 +18,7 @@
import mekanism.api.math.MathUtils;
import mekanism.common.capabilities.Capabilities;
import mekanism.common.capabilities.chemical.multiblock.MultiblockChemicalTankBuilder;
import mekanism.common.capabilities.energy.BasicEnergyContainer;
import mekanism.common.capabilities.energy.VariableCapacityEnergyContainer;
import mekanism.common.capabilities.fluid.VariableCapacityFluidTank;
import mekanism.common.capabilities.heat.ITileHeatHandler;
import mekanism.common.capabilities.heat.VariableHeatCapacitor;
Expand Down Expand Up @@ -54,18 +53,13 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.phys.AABB;
import net.minecraftforge.fluids.FluidType;
import org.jetbrains.annotations.NotNull;

public class FusionReactorMultiblockData extends MultiblockData {

public static final String HEAT_TAB = "heat";
public static final String FUEL_TAB = "fuel";
public static final String STATS_TAB = "stats";
private static final FloatingLong MAX_ENERGY = FloatingLong.createConst(1_000_000_000);
private static final int MAX_WATER = 1_000 * FluidType.BUCKET_VOLUME;
private static final long MAX_STEAM = MAX_WATER * 100L;
private static final long MAX_FUEL = FluidType.BUCKET_VOLUME;

public static final int MAX_INJECTION = 98;//this is the effective cap in the GUI, as text field is limited to 2 chars
//Reaction characteristics
Expand Down Expand Up @@ -132,6 +126,9 @@ public class FusionReactorMultiblockData extends MultiblockData {
private boolean clientBurning;
private double clientTemp;

private int maxWater;
private long maxSteam;

private AABB deathZone;

public FusionReactorMultiblockData(TileEntityFusionReactorBlock tile) {
Expand All @@ -141,13 +138,15 @@ public FusionReactorMultiblockData(TileEntityFusionReactorBlock tile) {
lastPlasmaTemperature = biomeAmbientTemp;
lastCaseTemperature = biomeAmbientTemp;
plasmaTemperature = biomeAmbientTemp;
LongSupplier maxFuel = () -> MAX_FUEL;
gasTanks.add(deuteriumTank = MultiblockChemicalTankBuilder.GAS.input(this, maxFuel, GeneratorTags.Gases.DEUTERIUM_LOOKUP::contains, this));
gasTanks.add(tritiumTank = MultiblockChemicalTankBuilder.GAS.input(this, maxFuel, GeneratorTags.Gases.TRITIUM_LOOKUP::contains, this));
gasTanks.add(fuelTank = MultiblockChemicalTankBuilder.GAS.input(this, maxFuel, GeneratorTags.Gases.FUSION_FUEL_LOOKUP::contains, createSaveAndComparator()));
gasTanks.add(deuteriumTank = MultiblockChemicalTankBuilder.GAS.input(this, MekanismGeneratorsConfig.generators.fusionFuelCapacity,
GeneratorTags.Gases.DEUTERIUM_LOOKUP::contains, this));
gasTanks.add(tritiumTank = MultiblockChemicalTankBuilder.GAS.input(this, MekanismGeneratorsConfig.generators.fusionFuelCapacity,
GeneratorTags.Gases.TRITIUM_LOOKUP::contains, this));
gasTanks.add(fuelTank = MultiblockChemicalTankBuilder.GAS.input(this, MekanismGeneratorsConfig.generators.fusionFuelCapacity,
GeneratorTags.Gases.FUSION_FUEL_LOOKUP::contains, createSaveAndComparator()));
gasTanks.add(steamTank = MultiblockChemicalTankBuilder.GAS.output(this, this::getMaxSteam, gas -> gas == MekanismGases.STEAM.getChemical(), this));
fluidTanks.add(waterTank = VariableCapacityFluidTank.input(this, this::getMaxWater, fluid -> MekanismTags.Fluids.WATER_LOOKUP.contains(fluid.getFluid()), this));
energyContainers.add(energyContainer = BasicEnergyContainer.output(MAX_ENERGY, this));
energyContainers.add(energyContainer = VariableCapacityEnergyContainer.output(MekanismGeneratorsConfig.generators.fusionEnergyCapacity, this));
heatCapacitors.add(heatCapacitor = VariableHeatCapacitor.create(caseHeatCapacity, FusionReactorMultiblockData::getInverseConductionCoefficient,
() -> inverseInsulation, () -> biomeAmbientTemp, this));
inventorySlots.add(reactorSlot = ReactorInventorySlot.at(stack -> stack.getItem() instanceof ItemHohlraum, this, 80, 39));
Expand Down Expand Up @@ -368,6 +367,8 @@ public int getInjectionRate() {
public void setInjectionRate(int rate) {
if (injectionRate != rate) {
injectionRate = rate;
maxWater = injectionRate * MekanismGeneratorsConfig.generators.fusionWaterPerInjection.get();
maxSteam = injectionRate * MekanismGeneratorsConfig.generators.fusionSteamPerInjection.get();
if (getWorld() != null && !isRemote()) {
if (!waterTank.isEmpty()) {
waterTank.setStackSize(Math.min(waterTank.getFluidAmount(), waterTank.getCapacity()), Action.EXECUTE);
Expand All @@ -381,11 +382,11 @@ public void setInjectionRate(int rate) {
}

public int getMaxWater() {
return MAX_WATER * injectionRate;
return maxWater;
}

public long getMaxSteam() {
return MAX_STEAM * injectionRate;
return maxSteam;
}

public boolean isBurning() {
Expand Down
Expand Up @@ -17,7 +17,6 @@
import mekanism.common.capabilities.energy.VariableCapacityEnergyContainer;
import mekanism.common.capabilities.fluid.VariableCapacityFluidTank;
import mekanism.common.config.MekanismConfig;
import mekanism.common.content.evaporation.EvaporationMultiblockData;
import mekanism.common.integration.computer.SpecialComputerMethodWrapper.ComputerChemicalTankWrapper;
import mekanism.common.integration.computer.annotation.ComputerMethod;
import mekanism.common.integration.computer.annotation.SyntheticComputerMethod;
Expand All @@ -39,12 +38,11 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.material.Fluids;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidType;
import org.jetbrains.annotations.NotNull;

public class TurbineMultiblockData extends MultiblockData {

public static final long GAS_PER_TANK = EvaporationMultiblockData.FLUID_PER_TANK;

public static final float ROTATION_THRESHOLD = 0.001F;
public static final Object2FloatMap<UUID> clientRotationMap = new Object2FloatOpenHashMap<>();

Expand Down Expand Up @@ -94,7 +92,7 @@ public class TurbineMultiblockData extends MultiblockData {
public TurbineMultiblockData(TileEntityTurbineCasing tile) {
super(tile);
gasTanks.add(gasTank = new TurbineGasTank(this, createSaveAndComparator()));
ventTank = VariableCapacityFluidTank.output(this, () -> isFormed() ? condensers * MekanismGeneratorsConfig.generators.condenserRate.get() : 1_000,
ventTank = VariableCapacityFluidTank.output(this, () -> isFormed() ? condensers * MekanismGeneratorsConfig.generators.condenserRate.get() : FluidType.BUCKET_VOLUME,
fluid -> MekanismTags.Fluids.WATER_LOOKUP.contains(fluid.getFluid()), this);
ventTanks = Collections.singletonList(ventTank);
energyContainer = VariableCapacityEnergyContainer.create(this::getEnergyCapacity, automationType -> isFormed(),
Expand Down Expand Up @@ -213,7 +211,7 @@ public int getDispersers() {
}

public long getSteamCapacity() {
return lowerVolume * GAS_PER_TANK;
return lowerVolume * MekanismGeneratorsConfig.generators.turbineGasPerTank.get();
}

@NotNull
Expand All @@ -223,8 +221,10 @@ public FloatingLong getEnergyCapacity() {

@Override
public void setVolume(int volume) {
super.setVolume(volume);
energyCapacity = FloatingLong.createConst(getVolume() * 16_000_000L); //16 MJ energy capacity per volume
if (getVolume() != volume) {
super.setVolume(volume);
energyCapacity = MekanismGeneratorsConfig.generators.turbineEnergyCapacityPerVolume.get().multiply(volume).copyAsConst();
}
}

@Override
Expand Down

0 comments on commit 2a93818

Please sign in to comment.