-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added ability for coolants to store more than 1 HU
- Loading branch information
1 parent
7663b0d
commit 6dc3308
Showing
5 changed files
with
167 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/main/java/com/recursive_pineapple/nuclear_horizons/reactors/fluids/CoolantRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.recursive_pineapple.nuclear_horizons.reactors.fluids; | ||
|
||
import java.util.HashMap; | ||
import java.util.Objects; | ||
|
||
import net.minecraftforge.fluids.Fluid; | ||
|
||
public class CoolantRegistry { | ||
|
||
private static final HashMap<Fluid, Coolant> coolantsByColdFluid = new HashMap<>(); | ||
private static final HashMap<Fluid, Coolant> coolantsByHotFluid = new HashMap<>(); | ||
private static final HashMap<Fluid, Coolant> coolantsByFluid = new HashMap<>(); | ||
|
||
private CoolantRegistry() { | ||
|
||
} | ||
|
||
/** | ||
* Registers a coolant that can be used to cool a nuclear reactor | ||
* @param cold The cold input coolant | ||
* @param hot The heated output coolant | ||
* @param specificHeatCapacity The amount of HU that can be stored in one mB of coolant | ||
*/ | ||
public static void registerCoolant(Fluid cold, Fluid hot, int specificHeatCapacity) { | ||
Objects.requireNonNull(cold); | ||
Objects.requireNonNull(hot); | ||
if(specificHeatCapacity <= 0) throw new IllegalArgumentException("specificHeatCapacity"); | ||
|
||
Coolant coolant = new Coolant(cold, hot, specificHeatCapacity); | ||
|
||
coolantsByColdFluid.put(cold, coolant); | ||
coolantsByHotFluid.put(hot, coolant); | ||
coolantsByFluid.put(cold, coolant); | ||
coolantsByFluid.put(hot, coolant); | ||
} | ||
|
||
public static boolean isColdCoolant(Fluid fluid) { | ||
return coolantsByColdFluid.containsKey(fluid); | ||
} | ||
|
||
public static boolean isHotCoolant(Fluid fluid) { | ||
return coolantsByHotFluid.containsKey(fluid); | ||
} | ||
|
||
public static Coolant getCoolantInfo(Fluid fluid) { | ||
return coolantsByFluid.get(fluid); | ||
} | ||
|
||
public static class Coolant { | ||
public final Fluid cold, hot; | ||
public final int specificHeatCapacity; | ||
|
||
public Coolant(Fluid cold, Fluid hot, int specificHeatCapacity) { | ||
this.cold = cold; | ||
this.hot = hot; | ||
this.specificHeatCapacity = specificHeatCapacity; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.