|
1 | 1 | package com.rae.formicapi; |
2 | 2 |
|
3 | 3 | import com.rae.formicapi.config.FormicAPIConfigs; |
| 4 | +import com.rae.formicapi.data.managers.FloatMapDataLoader; |
| 5 | +import com.rae.formicapi.data.managers.TwoDTabulatedFunctionLoader; |
| 6 | +import com.rae.formicapi.data.providers.TwoDTabulatedFunctionProvider; |
| 7 | +import com.rae.formicapi.math.data.StepMode; |
| 8 | +import com.rae.formicapi.thermal_utilities.EOSLibrary; |
| 9 | +import com.rae.formicapi.thermal_utilities.eos.CubicEOS; |
| 10 | +import com.rae.formicapi.thermal_utilities.helper.WaterCubicEOS; |
| 11 | +import com.rae.formicapi.thermal_utilities.helper.WaterTableBased; |
| 12 | +import net.minecraft.data.DataGenerator; |
| 13 | +import net.minecraft.data.PackOutput; |
| 14 | +import net.minecraft.resources.ResourceLocation; |
| 15 | +import net.minecraft.world.level.block.Block; |
4 | 16 | import net.minecraftforge.common.MinecraftForge; |
| 17 | +import net.minecraftforge.data.event.GatherDataEvent; |
| 18 | +import net.minecraftforge.event.AddReloadListenerEvent; |
| 19 | +import net.minecraftforge.eventbus.api.EventPriority; |
5 | 20 | import net.minecraftforge.eventbus.api.IEventBus; |
6 | 21 | import net.minecraftforge.fml.ModLoadingContext; |
7 | 22 | import net.minecraftforge.fml.common.Mod; |
8 | 23 | import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; |
| 24 | +import net.minecraftforge.registries.ForgeRegistries; |
9 | 25 | import org.apache.logging.log4j.LogManager; |
10 | 26 | import org.apache.logging.log4j.Logger; |
11 | 27 |
|
12 | 28 | @Mod(FormicAPI.MODID) |
13 | 29 | public class FormicAPI { |
14 | 30 | public static final String MODID = "formicapi"; |
15 | 31 | public static final Logger LOGGER = LogManager.getLogger(MODID); |
| 32 | + public static final TwoDTabulatedFunctionLoader WATER_PH_T = new TwoDTabulatedFunctionLoader(MODID,"water/pressure_enthalpy_to_temperature"); |
| 33 | + public static final TwoDTabulatedFunctionLoader WATER_PS_T = new TwoDTabulatedFunctionLoader(MODID,"water/pressure_entropy_to_temperature"); |
| 34 | + |
16 | 35 | public FormicAPI() { |
17 | 36 | IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); |
18 | 37 | IEventBus forgeEventBus = MinecraftForge.EVENT_BUS; |
19 | 38 | ModLoadingContext modLoadingContext = ModLoadingContext.get(); |
20 | 39 | FormicAPIConfigs.registerConfigs(modLoadingContext); |
| 40 | + modEventBus.addListener(EventPriority.NORMAL,this::gatherData); |
| 41 | + forgeEventBus.addListener(FormicAPI::onAddReloadListeners); |
| 42 | + |
21 | 43 |
|
22 | 44 | } |
| 45 | + public static void onAddReloadListeners(AddReloadListenerEvent event) |
| 46 | + { |
| 47 | + event.addListener(FormicAPI.WATER_PH_T); |
| 48 | + event.addListener(FormicAPI.WATER_PS_T); |
| 49 | + } |
| 50 | + |
| 51 | + public void gatherData(GatherDataEvent event) { |
| 52 | + DataGenerator generator = event.getGenerator(); |
| 53 | + PackOutput output = generator.getPackOutput(); |
| 54 | + |
| 55 | + /*generator.addProvider(event.includeServer(), new TwoDTabulatedFunctionProvider( |
| 56 | + output, resource("water/pressure_enthalpy_to_temperature"), |
| 57 | + WaterCubicEOS::get_T |
| 58 | + ,1e2f,0, 3e7f, 2e7f,300,1000,StepMode.LOGARITHMIC, StepMode.LINEAR, true |
| 59 | + ));*/ |
| 60 | + |
| 61 | + /*generator.addProvider( |
| 62 | + true, new TwoDTabulatedFunctionProvider( |
| 63 | + output, resource("water/pressure_enthalpy_to_entropy"), |
| 64 | + (P, H) -> { |
| 65 | + //get H from the |
| 66 | + float T = WaterCubicEOS.get_T(P,H); |
| 67 | + CubicEOS EOS = EOSLibrary.getPRWaterEOS(); |
| 68 | + return (float) EOS.getEntropy(T, P, WaterCubicEOS.get_x(H,T,P)); |
| 69 | + } |
| 70 | + ,1e2f,0, 3e7f, 2e7f,30,100,StepMode.LOGARITHMIC, StepMode.LINEAR, true |
| 71 | +
|
| 72 | + ) |
| 73 | + );*/ |
| 74 | + generator.addProvider( |
| 75 | + event.includeServer(), new TwoDTabulatedFunctionProvider( |
| 76 | + output, resource("water/pressure_entropy_to_temperature"), |
| 77 | + (P, S) -> { |
| 78 | + //get H from the |
| 79 | + float initialH = 0; |
| 80 | + float initialT = WaterCubicEOS.get_T(P, initialH); |
| 81 | + float x = WaterCubicEOS.get_x(P, initialH, initialT); |
| 82 | + return WaterCubicEOS.getT(initialT, x, P, S); |
| 83 | + } |
| 84 | + ,1e2f,1e-3f, 2e7f, 10e3f,30,100,StepMode.LOGARITHMIC, StepMode.LINEAR, true |
| 85 | + |
| 86 | + ) |
| 87 | + ); |
| 88 | + /*generator.addProvider(event.includeServer(), new TwoDTabulatedFunctionProvider( |
| 89 | + output, new ResourceLocation(MODID, "water/pressure_entropy_to_temperature"), |
| 90 | + (h, p)-> WaterCubicEOS.get_T(p, h) |
| 91 | + ,1e2f,0, 1e7f, 5e7f,1000,1000,StepMode.LOGARITHMIC, StepMode.LINEAR, true |
| 92 | + ));*/ |
| 93 | + } |
| 94 | + public static ResourceLocation resource(String name) { |
| 95 | + return new ResourceLocation(MODID,name); |
| 96 | + } |
| 97 | + |
23 | 98 | } |
0 commit comments