diff options
author | RecursivePineapple <recursive_pineapple@proton.me> | 2024-08-09 07:50:20 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-09 18:50:20 +0700 |
commit | 8d73b8b2efdc2f7964b55ca9affeca237b0f9b20 (patch) | |
tree | ee0a7a214fa473e406823db5d13017878f47902b /src/main/java/gregtech | |
parent | d1722a2db33c652cf1129ec98d48fd4ff6c22b64 (diff) | |
download | GT5-Unofficial-8d73b8b2efdc2f7964b55ca9affeca237b0f9b20.tar.gz GT5-Unofficial-8d73b8b2efdc2f7964b55ca9affeca237b0f9b20.tar.bz2 GT5-Unofficial-8d73b8b2efdc2f7964b55ca9affeca237b0f9b20.zip |
Created LHECoolantRegistry from LHE coolant logic (#2756)
* Removed coolant logic from LHE & XL LHE
* Added LHECoolantRegistry, which replaces the coolant checking logic
Diffstat (limited to 'src/main/java/gregtech')
3 files changed, 139 insertions, 43 deletions
diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index f515a21a45..4c23d22802 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -62,6 +62,7 @@ import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.objects.ItemData; import gregtech.api.objects.XSTR; import gregtech.api.recipe.RecipeMaps; +import gregtech.api.registries.LHECoolantRegistry; import gregtech.api.threads.GT_Runnable_MachineBlockUpdate; import gregtech.api.util.GT_Assemblyline_Server; import gregtech.api.util.GT_Forestry_Compat; @@ -358,6 +359,9 @@ public class GT_Mod implements IGT_Mod { if (Mods.HoloInventory.isModLoaded()) { HoloInventory.init(); } + + LHECoolantRegistry.registerBaseCoolants(); + GregTech_API.sLoadFinished = true; GT_Log.out.println("GT_Mod: Load-Phase finished!"); GT_Log.ore.println("GT_Mod: Load-Phase finished!"); diff --git a/src/main/java/gregtech/api/registries/LHECoolantRegistry.java b/src/main/java/gregtech/api/registries/LHECoolantRegistry.java new file mode 100644 index 0000000000..7944132572 --- /dev/null +++ b/src/main/java/gregtech/api/registries/LHECoolantRegistry.java @@ -0,0 +1,108 @@ +package gregtech.api.registries; + +import java.util.HashMap; +import java.util.Map; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class LHECoolantRegistry { + + private static final Map<String, LHECoolantInfo> lheCoolants = new HashMap<>(); + + /** + * Registers a coolant for use in Large Heat Exchangers and Whakawhiti Weras. + * See the constants in {@link #registerBaseCoolants()} as a reference for what the multipliers should be. + * The multipliers are used in + * {@link gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_HeatExchanger#checkProcessing()} + * and {@link gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_HeatExchanger#onRunningTick()}. + * + * @param coldFluidName The fluid name of the resulting cold coolant + * @param hotFluidName The fluid name of the input hot coolant + * @param steamMultiplier The steam multiplier + * @param superheatedThreshold The super heated threshold multiplier - see the constants in + * {@link #registerBaseCoolants()} for a reference + */ + public static void registerCoolant(String coldFluidName, String hotFluidName, double steamMultiplier, + double superheatedThreshold) { + var coolant = new LHECoolantInfo(coldFluidName, hotFluidName, steamMultiplier, superheatedThreshold); + + lheCoolants.put(coldFluidName, coolant); + lheCoolants.put(hotFluidName, coolant); + } + + public static LHECoolantInfo getCoolant(String fluidName) { + return lheCoolants.get(fluidName); + } + + public static LHECoolantInfo getCoolant(Fluid fluid) { + return lheCoolants.get(fluid.getName()); + } + + public static void registerBaseCoolants() { + // I have no idea where these constants originally came from, but I've preserved the comments from + // GT_MetaTileEntity_HeatExchanger + + registerCoolant( + "ic2pahoehoelava", + "lava", + 1.0 / 5.0, // lava is not boosted + 1.0 / 4.0 // unchanged + ); + + registerCoolant( + "ic2coolant", + "ic2hotcoolant", + 1.0 / 2.0, // was boosted x2 on top of x5 -> total x10 -> nerf with this code back to 5x + 1.0 / 5.0 // 10x smaller since the Hot Things production in reactor is the same + ); + + registerCoolant( + "molten.solarsaltcold", + "molten.solarsalthot", + 2.5, // Solar Salt to Steam ratio is 5x higher than Hot Coolant's ratio + 1.0 / 25.0 // Given that, multiplier is 5x higher and threshold is 5x lower + ); + } + + public static class LHECoolantInfo { + + public final String coldFluidName, hotFluidName; + public final double steamMultiplier, superheatedThreshold; + + private Fluid coldFluid, hotFluid; + + public LHECoolantInfo(String coldFluidName, String hotFluidName, double steamMultiplier, + double superheatedThreshold) { + this.coldFluidName = coldFluidName; + this.hotFluidName = hotFluidName; + this.steamMultiplier = steamMultiplier; + this.superheatedThreshold = superheatedThreshold; + } + + public Fluid getColdFluid() { + if (coldFluid == null) { + coldFluid = FluidRegistry.getFluid(coldFluidName); + } + + return coldFluid; + } + + public Fluid getHotFluid() { + if (hotFluid == null) { + hotFluid = FluidRegistry.getFluid(hotFluidName); + } + + return hotFluid; + } + + public FluidStack getColdFluid(int amount) { + return new FluidStack(getColdFluid(), amount); + } + + public FluidStack getHotFluid(int amount) { + return new FluidStack(getHotFluid(), amount); + } + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java index 70e8079b5b..46c9c712ce 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java @@ -15,6 +15,8 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGE import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import javax.annotation.Nonnull; + import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; @@ -23,8 +25,6 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.NotNull; - import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -42,6 +42,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; import gregtech.api.recipe.check.CheckRecipeResult; import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.registries.LHECoolantRegistry; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; @@ -180,7 +181,7 @@ public class GT_MetaTileEntity_HeatExchanger extends } @Override - @NotNull + @Nonnull public CheckRecipeResult checkProcessing() { if (mInputHotFluidHatch.getFluid() == null) return CheckRecipeResultRegistry.NO_RECIPE; @@ -191,9 +192,6 @@ public class GT_MetaTileEntity_HeatExchanger extends int shs_reduction_per_config = 150; // reduce threshold 150L/s per circuitry level (1-25) float steam_output_multiplier = 20f; // default: multiply output by 4 * 10 (boosted x5) float penalty = 0.0f; // penalty to apply to output based on circuitry level (1-25). - boolean do_lava = false; - boolean do_coolant = false; - boolean do_solarSalt = false; // Do we have an integrated circuit with a valid configuration? if (mInventory[1] != null && mInventory[1].getUnlocalizedName() @@ -202,52 +200,38 @@ public class GT_MetaTileEntity_HeatExchanger extends if (circuit_config >= 1 && circuit_config <= 25) { // If so, apply the penalty and reduce the threshold. penalty = (circuit_config - 1) * penalty_per_config; - superheated_threshold -= (shs_reduction_per_config * (circuit_config - 1)); + superheated_threshold -= shs_reduction_per_config * (circuit_config - 1); } } + efficiency -= penalty; - // If we're working with lava, adjust the threshold and multipliers accordingly. - if (GT_ModHandler.isLava(mInputHotFluidHatch.getFluid())) { - steam_output_multiplier /= 5f; // lava is not boosted - superheated_threshold /= 4f; // unchanged - do_lava = true; - } else if (mInputHotFluidHatch.getFluid() - .isFluidEqual(FluidRegistry.getFluidStack("ic2hotcoolant", 1))) { - steam_output_multiplier /= 2f; // was boosted x2 on top of x5 -> total x10 -> - // nerf with this code back to 5x - superheated_threshold /= 5f; // 10x smaller since the Hot Things production in - // reactor is the same. - do_coolant = true; - } else if (mInputHotFluidHatch.getFluid() - .isFluidEqual(FluidRegistry.getFluidStack("molten.solarsalthot", 1))) { - steam_output_multiplier *= 2.5f; // Solar Salt:Steam value is 5x higher than Hot - // Coolant's value - superheated_threshold /= 25f; // Given that, multiplier is 5x higher and - // threshold is 5x lower - do_solarSalt = true; - } else { - // If we're working with neither, fail out - superheated_threshold = 0; - return CheckRecipeResultRegistry.NO_RECIPE; - } + var coolant = LHECoolantRegistry.getCoolant( + mInputHotFluidHatch.getFluid() + .getFluid()); + + if (coolant == null) { + superheated_threshold = 0; + return CheckRecipeResultRegistry.NO_RECIPE; + } else { + steam_output_multiplier *= coolant.steamMultiplier; + superheated_threshold *= coolant.superheatedThreshold; + } + + // set the internal superheated flag if we have + // enough hot fluid. Used in the onRunningTick method. + superheated = fluidAmountToConsume >= superheated_threshold; + + // Don't consume too much hot fluid per second + fluidAmountToConsume = Math.min(fluidAmountToConsume, superheated_threshold * 2); - superheated = fluidAmountToConsume >= superheated_threshold; // set the internal superheated flag if we have - // enough hot fluid. Used in the - // onRunningTick method. - fluidAmountToConsume = Math.min(fluidAmountToConsume, superheated_threshold * 2); // Don't consume too much hot - // fluid per second mInputHotFluidHatch.drain(fluidAmountToConsume, true); + mOutputColdFluidHatch.fill(coolant.getColdFluid(fluidAmountToConsume), true); + this.mMaxProgresstime = 20; this.mEUt = (int) (fluidAmountToConsume * steam_output_multiplier * efficiency); - if (do_lava) { - mOutputColdFluidHatch.fill(FluidRegistry.getFluidStack("ic2pahoehoelava", fluidAmountToConsume), true); - } else if (do_coolant) { - mOutputColdFluidHatch.fill(FluidRegistry.getFluidStack("ic2coolant", fluidAmountToConsume), true); - } else { - mOutputColdFluidHatch.fill(FluidRegistry.getFluidStack("molten.solarsaltcold", fluidAmountToConsume), true); - } this.mEfficiencyIncrease = 80; + return CheckRecipeResultRegistry.SUCCESSFUL; } |