Skip to content

Commit

Permalink
feat: overhaul part 4
Browse files Browse the repository at this point in the history
  • Loading branch information
bruberu committed Jul 21, 2024
1 parent 5e0974d commit eb5b6a5
Show file tree
Hide file tree
Showing 26 changed files with 206 additions and 221 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package gregtech.api.capability.impl;

import gregtech.api.GTValues;
import gregtech.api.metatileentity.multiblock.MultiblockWithDisplayBase;
import gregtech.api.metatileentity.multiblock.RecipeMapMultiblockController;
import gregtech.api.recipes.RecipeMap;
import gregtech.api.recipes.recipeproperties.IRecipePropertyStorage;

import org.jetbrains.annotations.NotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
import gregtech.api.util.Position;
import gregtech.api.util.Size;
import gregtech.api.util.function.FloatConsumer;

import gregtech.api.util.function.FloatSupplier;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;

import java.util.function.Supplier;

public class UpdatedSliderWidget extends SliderWidget {

private FloatSupplier detector;
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/gregtech/api/nuclear/fission/FissionReactor.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public void computeGeometry() {
* Geometric factor calculation is done by (rough) numerical integration along a straight path between
* the two cells
*/
double resolution = ConfigHolder.machines.fissionReactorResolution;
double resolution = ConfigHolder.machines.nuclear.fissionReactorResolution;
for (int t = 0; t < resolution; t++) {
double x;
double y;
Expand Down Expand Up @@ -294,7 +294,7 @@ public void computeGeometry() {
* The fraction of fast neutrons is simply one minus the fraction of slow neutrons
*/
if (pathIsClear) {
mij /= ConfigHolder.machines.fissionReactorResolution;
mij /= resolution;
geometricMatrixSlowNeutrons[i][j] = (1.0 -
Math.exp(-mij * rodOne.getDistance(rodTwo))) /
rodOne.getDistance(rodTwo);
Expand Down Expand Up @@ -356,11 +356,11 @@ public void computeGeometry() {
(1 - sigmoid) * Math.pow(avgFuelRodDistance, -1);

maxPower = fuelRods.size() * (avgHighEnergyFissionFactor + avgLowEnergyFissionFactor) * fuelRodFactor *
ConfigHolder.machines.nuclearPowerMultiplier;
ConfigHolder.machines.nuclear.nuclearPowerMultiplier;
} else {
// The calculations break down for the geometry, so we just do this instead.
k = 0.00001;
maxPower = 0.1 * ConfigHolder.machines.nuclearPowerMultiplier;
maxPower = 0.1 * ConfigHolder.machines.nuclear.nuclearPowerMultiplier;
}
/*
* We give each control rod and coolant channel a weight depending on how many fuel rods they affect
Expand Down Expand Up @@ -475,7 +475,7 @@ public double makeCoolantFlow(int flowRate) {
}

double heatRemovedPerLiter = prop.getSpecificHeatCapacity() /
ConfigHolder.machines.fissionCoolantDivisor *
ConfigHolder.machines.nuclear.fissionCoolantDivisor *
(cooledTemperature - coolant.getFluid().getTemperature());
// Explained by:
// https://physics.stackexchange.com/questions/153434/heat-transfer-between-the-bulk-of-the-fluid-inside-the-pipe-and-the-pipe-externa
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ public ControlRod(double maxTemperature, boolean tipModeration, double thermalCo

/**
* Normalizes the weights of a list of control rods based on the true number of fuel rod pairs.
*
* @param effectiveControlRods The control rods to normalize.
* @param fuelRodNum The number of fuel rods in the reactor.
* @param fuelRodNum The number of fuel rods in the reactor.
*/
public static void normalizeWeights(List<ControlRod> effectiveControlRods, int fuelRodNum) {
for (ControlRod control_rod : effectiveControlRods) {
Expand All @@ -28,8 +29,9 @@ public static void normalizeWeights(List<ControlRod> effectiveControlRods, int f

/**
* Determines the effect of a list of control rods based on how far they are inserted into a reactor.
*
* @param effectiveControlRods The list of control rods to be analyzed.
* @param insertion How far the control rods are inserted into the reactor, from 0 to 1.
* @param insertion How far the control rods are inserted into the reactor, from 0 to 1.
* @return A number representing the reactivity change of the reactor from the control rods.
*/
public static double controlRodFactor(List<ControlRod> effectiveControlRods, double insertion) {
Expand Down Expand Up @@ -77,7 +79,8 @@ public boolean hasModeratorTip() {
}

/**
* Automatically calculates the control rod weight (its effect on reactivity) based on the number of fuel rod pairs that it is in the way of.
* Automatically calculates the control rod weight (its effect on reactivity) based on the number of fuel rod pairs
* that it is in the way of.
*/
public void computeWeightFromFuelRodMap() {
this.weight = relatedFuelRodPairs * 4; // 4 being a constant to help balance this out
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,4 @@ public ICoolantHandler getInputHandler() {
public ICoolantHandler getOutputHandler() {
return outputHandler;
}

}
48 changes: 25 additions & 23 deletions src/main/java/gregtech/api/recipes/RecipeMaps.java
Original file line number Diff line number Diff line change
Expand Up @@ -1484,14 +1484,15 @@ public final class RecipeMaps {
* </pre>
*/
@ZenProperty
public static final RecipeMap<PrimitiveRecipeBuilder> HEAT_EXCHANGER_RECIPES = new RecipeMapBuilder<>("heat_exchanger",
public static final RecipeMap<PrimitiveRecipeBuilder> HEAT_EXCHANGER_RECIPES = new RecipeMapBuilder<>(
"heat_exchanger",
new PrimitiveRecipeBuilder())
.itemInputs(1)
.fluidInputs(2)
.fluidOutputs(2)
.progressBar(GuiTextures.PROGRESS_BAR_ARROW_MULTIPLE, MoveType.HORIZONTAL)
.sound(GTSoundEvents.COOLING)
.build();
.itemInputs(1)
.fluidInputs(2)
.fluidOutputs(2)
.progressBar(GuiTextures.PROGRESS_BAR_ARROW_MULTIPLE, MoveType.HORIZONTAL)
.sound(GTSoundEvents.COOLING)
.build();

/**
* Example:
Expand All @@ -1505,34 +1506,35 @@ public final class RecipeMaps {
* </pre>
*/
@ZenProperty
public static final RecipeMap<SimpleRecipeBuilder> SPENT_FUEL_POOL_RECIPES = new RecipeMapBuilder<>("spent_fuel_pool",
public static final RecipeMap<SimpleRecipeBuilder> SPENT_FUEL_POOL_RECIPES = new RecipeMapBuilder<>(
"spent_fuel_pool",
new SimpleRecipeBuilder())
.itemInputs(1)
.itemOutputs(1)
.fluidInputs(1)
.fluidOutputs(1)
.progressBar(GuiTextures.PROGRESS_BAR_BATH, MoveType.HORIZONTAL)
.build();
.itemInputs(1)
.itemOutputs(1)
.fluidInputs(1)
.fluidOutputs(1)
.progressBar(GuiTextures.PROGRESS_BAR_BATH, MoveType.HORIZONTAL)
.build();

/**
* Example:
*
* <pre>
* GAS_CENTRIFUGE_RECIPES.recipeBuilder().duration(800).EUt(VA[HV])
* .fluidInputs(UraniumHexafluoride.getFluid(1000))
* .fluidOutputs(LowEnrichedUraniumHexafluoride.getFluid(100))
* .fluidOutputs(DepletedUraniumHexafluoride.getFluid(900))
* .buildAndRegister();
* .fluidInputs(UraniumHexafluoride.getFluid(1000))
* .fluidOutputs(LowEnrichedUraniumHexafluoride.getFluid(100))
* .fluidOutputs(DepletedUraniumHexafluoride.getFluid(900))
* .buildAndRegister();
* </pre>
*/
@ZenProperty
public static final RecipeMap<SimpleRecipeBuilder> GAS_CENTRIFUGE_RECIPES = new RecipeMapBuilder<>("gas_centrifuge",
new SimpleRecipeBuilder())
.fluidInputs(1)
.fluidOutputs(2)
.progressBar(GuiTextures.PROGRESS_BAR_MIXER, MoveType.CIRCULAR)
.sound(GTSoundEvents.CENTRIFUGE)
.build();
.fluidInputs(1)
.fluidOutputs(2)
.progressBar(GuiTextures.PROGRESS_BAR_MIXER, MoveType.CIRCULAR)
.sound(GTSoundEvents.CENTRIFUGE)
.build();

//////////////////////////////////////
// Fuel Recipe Maps //
Expand Down
34 changes: 17 additions & 17 deletions src/main/java/gregtech/api/unification/material/Material.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ public MaterialIconSet getMaterialIconSet() {
@ZenGetter("radioactive")
public boolean isRadioactive() {
if (materialInfo.element != null) return materialInfo.element.halfLifeSeconds >= 0;
for (MaterialStack material : materialInfo.componentList)
if (material.material.isRadioactive()) return true;
for (MaterialStack stack : materialInfo.componentList)
if (stack.material.isRadioactive()) return true;
return false;
}

Expand All @@ -298,8 +298,8 @@ public double getDecaysPerSecond() {
return 6e23 * (Math.log(2) * Math.exp(-Math.log(2) / materialInfo.element.halfLifeSeconds));
}
double decaysPerSecond = 0;
for (MaterialStack material : materialInfo.componentList)
decaysPerSecond += material.material.getDecaysPerSecond();
for (MaterialStack stack : materialInfo.componentList)
decaysPerSecond += stack.material.getDecaysPerSecond();
return decaysPerSecond;
}

Expand All @@ -308,9 +308,9 @@ public long getProtons() {
if (materialInfo.element != null) return materialInfo.element.getProtons();
if (materialInfo.componentList.isEmpty()) return Math.max(1, Elements.Tc.getProtons());
long totalProtons = 0, totalAmount = 0;
for (MaterialStack material : materialInfo.componentList) {
totalAmount += material.amount;
totalProtons += material.amount * material.material.getProtons();
for (MaterialStack stack : materialInfo.componentList) {
totalAmount += stack.amount;
totalProtons += stack.amount * stack.material.getProtons();
}
return totalProtons / totalAmount;
}
Expand All @@ -320,9 +320,9 @@ public long getNeutrons() {
if (materialInfo.element != null) return materialInfo.element.getNeutrons();
if (materialInfo.componentList.isEmpty()) return Elements.Tc.getNeutrons();
long totalNeutrons = 0, totalAmount = 0;
for (MaterialStack material : materialInfo.componentList) {
totalAmount += material.amount;
totalNeutrons += material.amount * material.material.getNeutrons();
for (MaterialStack stack : materialInfo.componentList) {
totalAmount += stack.amount;
totalNeutrons += stack.amount * stack.material.getNeutrons();
}
return totalNeutrons / totalAmount;
}
Expand All @@ -332,9 +332,9 @@ public long getMass() {
if (materialInfo.element != null) return materialInfo.element.getMass();
if (materialInfo.componentList.size() == 0) return Elements.Tc.getMass();
long totalMass = 0, totalAmount = 0;
for (MaterialStack material : materialInfo.componentList) {
totalAmount += material.amount;
totalMass += material.amount * material.material.getMass();
for (MaterialStack stack : materialInfo.componentList) {
totalAmount += stack.amount;
totalMass += stack.amount * stack.material.getMass();
}
return totalMass / totalAmount;
}
Expand Down Expand Up @@ -1086,10 +1086,10 @@ public Builder itemPipeProperties(int priority, float stacksPerSec) {
return this;
}

public Builder fissionFuelProperties(int maxTemperature, int duration, double slowNeutronCaptureCrossSection,
double fastNeutronCaptureCrossSection,
double slowNeutronFissionCrossSection,
double fastNeutronFissionCrossSection, double neutronGenerationTime) {
public Builder fissionFuel(int maxTemperature, int duration, double slowNeutronCaptureCrossSection,
double fastNeutronCaptureCrossSection,
double slowNeutronFissionCrossSection,
double fastNeutronFissionCrossSection, double neutronGenerationTime) {
properties.ensureSet(PropertyKey.DUST);
properties.setProperty(PropertyKey.FISSION_FUEL,
new FissionFuelProperty(maxTemperature, duration, slowNeutronCaptureCrossSection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ public static void register() {
public static Material Phosphorus;
public static Material Polonium;
public static Material Platinum;
public static Material Plutonium;
public static Material Plutonium238;
public static Material Plutonium239;
public static Material Plutonium240;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,6 @@ public static void register() {
.color(0x32F032).iconSet(METALLIC)
.flags(EXT_METAL)
.element(Elements.U)
// .fissionFuelProperties(1600, 40, 1.2, 0.1, 0.1, 0.5)
.build();

Uranium235 = new Material.Builder(117, gregtechId("uranium_235"))
Expand Down Expand Up @@ -1022,10 +1021,7 @@ public static void register() {
.build();

Uranium239 = new Material.Builder(132, gregtechId("uranium_239"))
.ingot(3)
.liquid(new FluidBuilder().temperature(1405))
.color(0x46FA46).iconSet(SHINY)
.flags(EXT_METAL)
.element(Elements.U239)
.build();

Expand Down Expand Up @@ -1076,5 +1072,10 @@ public static void register() {
.color(0xF03232).iconSet(METALLIC)
.element(Elements.Pu244)
.build();

Plutonium = new Material.Builder(141, gregtechId("plutonium"))
.color(0xF03232).iconSet(METALLIC)
.element(Elements.Pu)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,9 @@ public static void register() {
.build();

Salt = new Material.Builder(312, gregtechId("salt"))
.gem(1).ore(2, 1).fluid()
.gem(1).ore(2, 1)
.liquid(new FluidBuilder()
.translation("gregtech.fluid.molten"))
.color(0xFAFAFA).iconSet(FINE)
.flags(NO_SMASHING)
.components(Sodium, 1, Chlorine, 1)
Expand Down Expand Up @@ -1573,7 +1575,7 @@ public static void register() {
HighPressureSteam = new Material.Builder(454, gregtechId("high_pressure_steam"))
.gas(new FluidBuilder()
.temperature(500)
/* .customStill() */)
.customStill())
.color(0xC4C4C4)
.flags(DISABLE_DECOMPOSITION)
.components(Hydrogen, 2, Oxygen, 1)
Expand All @@ -1583,9 +1585,8 @@ public static void register() {
.dust(3)
.color(0xF03232).iconSet(DULL)
.flags(DISABLE_DECOMPOSITION)
.components(Plutonium239, 1, Oxygen, 2)
.build()
.setFormula("PuO2", true);
.components(Plutonium, 1, Oxygen, 2)
.build();

Zircaloy = new Material.Builder(456, gregtechId("zircaloy"))
.ingot()
Expand All @@ -1604,10 +1605,11 @@ public static void register() {
.setFormula("UO2", true);

Zircon = new Material.Builder(458, gregtechId("zircon"))
.ore()
.color(0x386F6F)
.gem().ore()
.color(0x6E0909)
.flags(DISABLE_DECOMPOSITION)
.components(Zirconium, 1, Silicon, 1, Oxygen, 4)
.iconSet(SHINY)
.build();

ZirconiumDioxide = new Material.Builder(459, gregtechId("zirconium_dioxide"))
Expand All @@ -1622,6 +1624,7 @@ public static void register() {
.color(0x689FBF)
.flags(DISABLE_DECOMPOSITION)
.components(Zirconium, 1, Chlorine, 4)
.iconSet(SHINY)
.build();

HafniumDioxide = new Material.Builder(461, gregtechId("hafnium_dioxide"))
Expand All @@ -1636,6 +1639,7 @@ public static void register() {
.color(0x69699A)
.flags(DISABLE_DECOMPOSITION)
.components(Hafnium, 1, Chlorine, 4)
.iconSet(SHINY)
.build();

Inconel = new Material.Builder(463, gregtechId("inconel"))
Expand All @@ -1645,21 +1649,20 @@ public static void register() {
.components(Nickel, 5, Chrome, 2, Iron, 2, Niobium, 1, Molybdenum, 1)
.blastTemp(1610, GasTier.MID, GTValues.VA[EV], 200)
.fluidPipeProperties(2010, 175, true, true, true, false)
.build()
.setFormula("Ni5Cr2Fe2NbMo", true);
.build();

HighEnrichedUraniumHexafluoride = new Material.Builder(464, gregtechId("high_enriched_uranium_hexafluoride"))
.gas()
.color(0x5BF93A)
.flags(DISABLE_DECOMPOSITION)
.components(Uranium235, 1, Fluorine, 6)
.build()
.setFormula("UF6", true);
.build();

BoronTrioxide = new Material.Builder(465, gregtechId("boron_trioxide"))
.dust()
.color(0xC1E9E1)
.components(Boron, 2, Oxygen, 3)
.iconSet(METALLIC)
.build();

BoronCarbide = new Material.Builder(466, gregtechId("boron_carbide"))
Expand All @@ -1668,6 +1671,7 @@ public static void register() {
.blast(2620)
.color(0xC1E9C1)
.components(Boron, 4, Carbon, 1)
.iconSet(METALLIC)
.build();
}
}
Loading

0 comments on commit eb5b6a5

Please sign in to comment.