Skip to content

Commit fe3ad36

Browse files
updating from 1.20.1 version
1 parent 461cd26 commit fe3ad36

40 files changed

Lines changed: 149712 additions & 1331 deletions

build.gradle

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,19 @@ plugins {
22
id 'idea'
33
id 'maven-publish'
44
id 'java-library'
5-
id 'org.jreleaser' version '1.17.0'
65
id 'net.neoforged.moddev' version '2.0.78'
76

87
}
98

10-
11-
import org.slf4j.event.Level
12-
13-
import java.nio.file.Files
14-
import java.nio.file.Paths
15-
16-
def loadEnv() {
17-
def envFile = rootProject.file(".env")
18-
if (envFile.exists()) {
19-
envFile.eachLine { line ->
20-
def matcher = line =~ /^\s*([\w\.]+)\s*=\s*(.*)\s*$/
21-
if (matcher.matches()) {
22-
def key = matcher[0][1]
23-
def value = matcher[0][2]
24-
System.setProperty(key, value)
25-
}
26-
}
27-
}
28-
}
29-
loadEnv()
309
version = minecraft_version + "-" + mod_version
3110
group = mod_group_id
3211

3312
base {
3413
archivesName = mod_id
3514
}
3615

16+
jarJar.enable()
17+
3718
// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
3819
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
3920

@@ -100,7 +81,7 @@ neoForge {
10081
// Recommended logging level for the console
10182
// You can set various levels here.
10283
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
103-
logLevel = Level.WARN
84+
//logLevel = Level.WARN
10485

10586

10687
}
@@ -171,7 +152,9 @@ dependencies {
171152
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.0'
172153
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.0'
173154
//x chart to plot things
174-
implementation("org.knowm.xchart:xchart:3.2.2")
155+
jarJar(implementation("org.knowm.xchart:xchart:3.2.2")){
156+
jarJar.ranged(it, '[3.2.2,)')
157+
}
175158

176159
}
177160

@@ -208,6 +191,9 @@ tasks.test {
208191
useJUnitPlatform()
209192
debug = true;
210193
}
194+
195+
jar.finalizedBy('reobfJar')
196+
tasks.jarJar.finalizedBy('reobfJarJar')
211197
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing:
212198
// tasks.named('publish').configure {
213199
// dependsOn 'reobfJar'
@@ -216,7 +202,11 @@ tasks.test {
216202
publishing {
217203
publications {
218204
mavenJava(MavenPublication) {
205+
artifactId = "FormicAPI" // ✅ no spaces or invalid chars
206+
219207
from components.java
208+
fg.component(it)
209+
jarJar.component(it)
220210
}
221211
}
222212
}

gradle.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ minecraft_version=1.21.1
1515
# as they do not follow standard versioning conventions.
1616
minecraft_version_range=[1.21.1, 1.22)
1717
# The Neo version must agree with the Minecraft version to get a valid artifact
18-
neo_version=21.1.138
18+
neo_version=21.1.152
1919
# The Neo version range can use any version of Neo as bounds
2020
neo_version_range=[21.1.0,)
2121
# The loader version range can only use the major version of FML as bounds
@@ -28,11 +28,11 @@ mod_id=formicapi
2828
mod_name=Formic API
2929
mod_license=MIT
3030

31-
mod_version=1.3
31+
mod_version=1.6.8
3232

33-
create_version = 6.0.4-55
33+
create_version = 6.0.6-106
3434
flywheel_version = 1.0.2
35-
ponder_version = 1.0.46
35+
ponder_version = 1.0.59
3636
registrate_version = MC1.21-1.3.0+62
3737
jei_version=19.10.0.126
3838

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package com.rae.formicapi;
2+
3+
import com.mojang.brigadier.CommandDispatcher;
4+
import com.mojang.brigadier.arguments.FloatArgumentType;
5+
import com.mojang.brigadier.context.CommandContext;
6+
import com.rae.formicapi.thermal_utilities.Plotting;
7+
import net.minecraft.Util;
8+
import net.minecraft.commands.CommandSourceStack;
9+
import net.minecraft.commands.Commands;
10+
import net.minecraft.network.chat.Component;
11+
12+
import java.util.stream.DoubleStream;
13+
14+
public class CommandsInit {
15+
16+
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
17+
dispatcher.register(Commands.literal("plotIsentropes")
18+
.then(Commands.argument("sMin", FloatArgumentType.floatArg(0))
19+
.then(Commands.argument("sMax", FloatArgumentType.floatArg(0))
20+
.then(Commands.argument("sStep", FloatArgumentType.floatArg(0))
21+
.then(Commands.argument("pMin", FloatArgumentType.floatArg(0))
22+
.then(Commands.argument("pMax", FloatArgumentType.floatArg(0))
23+
.executes(CommandsInit::execute)
24+
)
25+
)
26+
)
27+
)
28+
)
29+
);
30+
}
31+
32+
private static int execute(CommandContext<CommandSourceStack> ctx) {
33+
float sMin = FloatArgumentType.getFloat(ctx, "sMin");
34+
float sMax = FloatArgumentType.getFloat(ctx, "sMax");
35+
float sStep = FloatArgumentType.getFloat(ctx, "sStep");
36+
37+
float pMin = FloatArgumentType.getFloat(ctx, "pMin");
38+
float pMax = FloatArgumentType.getFloat(ctx, "pMax");
39+
40+
// Parse comma-separated entropy values, e.g., "3.5,4.0,4.5"
41+
double[] entropies = DoubleStream.iterate(
42+
sMin,
43+
s -> s <= sMax + 1e-6,
44+
s -> s + sStep
45+
).toArray();
46+
//DistExecutor.unsafeRunWhenOn(
47+
// Dist.CLIENT,() -> () ->
48+
49+
Util.backgroundExecutor().execute(() -> {
50+
//Plotting.plotSaturationPressurePT("Water Saturation Pressure (P–H)", pMin, pMax);
51+
//Plotting.plotSaturationPressurePH("Water Saturation Pressure (P–H)", pMin, pMax);
52+
53+
Plotting.plotIsentropesPH(
54+
"Water Isentropes (P–H)",
55+
entropies,
56+
pMin,
57+
pMax
58+
);
59+
60+
Plotting.plotIsentropesPT(
61+
"Water Isentropes (P–T)",
62+
entropies,
63+
pMin,
64+
pMax
65+
);
66+
67+
68+
});
69+
70+
ctx.getSource().sendSuccess( () -> Component.literal("Isentrope plot generated!"),
71+
true
72+
);
73+
74+
return 1;
75+
}
76+
77+
78+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,36 @@
11
package com.rae.formicapi;
22

3+
import com.rae.formicapi.thermal_utilities.FullTableBased;
4+
import net.minecraft.resources.ResourceLocation;
5+
import net.neoforged.bus.api.IEventBus;
6+
import net.neoforged.fml.ModContainer;
37
import net.neoforged.fml.common.Mod;
8+
import net.neoforged.neoforge.common.NeoForge;
9+
import net.neoforged.neoforge.event.AddReloadListenerEvent;
410
import org.apache.logging.log4j.LogManager;
511
import org.apache.logging.log4j.Logger;
612

713
@Mod(FormicAPI.MODID)
814
public class FormicAPI {
915
public static final String MODID = "formicapi";
1016
public static final Logger LOGGER = LogManager.getLogger(MODID);
17+
18+
public FormicAPI(IEventBus modEventBus, ModContainer modContainer) {
19+
IEventBus forgeEventBus = NeoForge.EVENT_BUS;
20+
21+
forgeEventBus.addListener(FormicAPI::onAddReloadListeners);
22+
23+
24+
}
25+
26+
public static void onAddReloadListeners(AddReloadListenerEvent event)
27+
{
28+
FullTableBased.addReloadListeners(event);
29+
}
30+
31+
32+
public static ResourceLocation resource(String name) {
33+
return ResourceLocation.fromNamespaceAndPath(MODID,name);
34+
}
35+
1136
}

src/main/java/com/rae/formicapi/FormicApiLang.java

Lines changed: 26 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,27 @@
99
import net.createmod.catnip.lang.LangBuilder;
1010
import net.createmod.catnip.lang.LangNumberFormat;
1111
import net.minecraft.network.chat.Component;
12-
import net.minecraft.network.chat.MutableComponent;
13-
import net.minecraft.world.item.ItemStack;
14-
import net.minecraft.world.level.block.state.BlockState;
15-
import net.neoforged.neoforge.fluids.FluidStack;
1612

17-
18-
import java.util.ArrayList;
19-
import java.util.List;
13+
import java.util.Map;
14+
import java.util.TreeMap;
2015

2116
public class FormicApiLang extends Lang {
2217
//blatant copy of CreateLang
23-
/**
24-
* legacy-ish. Use CROWNSLang.translate and other builder methods where possible
25-
*/
26-
public static MutableComponent translateDirect(String key, Object... args) {
27-
Object[] args1 = LangBuilder.resolveBuilders(args);
28-
return Component.translatable(FormicAPI.MODID + "." + key, args1);
29-
}
30-
31-
public static List<Component> translatedOptions(String prefix, String... keys) {
32-
List<Component> result = new ArrayList<>(keys.length);
33-
for (String key : keys)
34-
result.add(translate((prefix != null ? prefix + "." : "") + key).component());
35-
return result;
18+
static TreeMap<Double, String> MULTIPLE_SYMBOLS = new TreeMap<>();
19+
static {
20+
MULTIPLE_SYMBOLS.put(1e18, "E");
21+
MULTIPLE_SYMBOLS.put(1e15, "P");
22+
MULTIPLE_SYMBOLS.put(1e12, "T");
23+
MULTIPLE_SYMBOLS.put(1e9, "G");
24+
MULTIPLE_SYMBOLS.put(1e6, "M");
25+
MULTIPLE_SYMBOLS.put(1e3, "k");
26+
MULTIPLE_SYMBOLS.put(1.0, "");
27+
MULTIPLE_SYMBOLS.put(1e-3, "m");
28+
MULTIPLE_SYMBOLS.put(1e-6, "µ");
29+
MULTIPLE_SYMBOLS.put(1e-9, "n");
30+
MULTIPLE_SYMBOLS.put(1e-12,"p");
31+
MULTIPLE_SYMBOLS.put(1e-15,"f");
32+
MULTIPLE_SYMBOLS.put(1e-18,"a");
3633
}
3734

3835
//
@@ -41,57 +38,34 @@ public static LangBuilder builder() {
4138
return new LangBuilder(FormicAPI.MODID);
4239
}
4340

44-
public static LangBuilder blockName(BlockState state) {
45-
return builder().add(state.getBlock()
46-
.getName());
47-
}
48-
49-
public static LangBuilder itemName(ItemStack stack) {
50-
return builder().add(stack.getHoverName()
51-
.copy());
52-
}
53-
54-
public static LangBuilder fluidName(FluidStack stack) {
55-
return builder().add(stack.getDisplayName()
56-
.copy());
57-
}
58-
59-
public static LangBuilder number(double d) {
60-
return builder().text(LangNumberFormat.format(d));
41+
public static LangBuilder numberWithSymbol(double d) {
42+
Map.Entry<Double, String> entry = MULTIPLE_SYMBOLS.floorEntry(d);
43+
if (entry == null) {
44+
builder().text(LangNumberFormat.format(d)+ " ");
45+
}
46+
return builder().text(LangNumberFormat.format(d/entry.getKey())+" "+entry.getValue());
6147
}
6248

6349
public static LangBuilder translate(String langKey, Object... args) {
6450
return builder().translate(langKey, args);
6551
}
6652

67-
public static LangBuilder text(String text) {
68-
return builder().text(text);
69-
}
70-
71-
@Deprecated // Use while implementing and replace all references with Lang.translate
72-
public static LangBuilder temporaryText(String text) {
73-
return builder().text(text);
74-
}
75-
7653
public static LangBuilder formatTemperature(float temperature) {
7754
Temperature unit = FormicAPIConfigs.CLIENT.units.temperature.get();
7855
return CreateLang.builder().add(Component.literal("T = "))
79-
.add(number(unit.convert(temperature)))
80-
.text(" ")
56+
.text(LangNumberFormat.format(unit.convert(temperature))+ " ")
8157
.add(unit.getSymbol());
8258
}
8359
public static LangBuilder formatPressure(float pressure) {
8460
Pressure unit = FormicAPIConfigs.CLIENT.units.pressure.get();
8561
return CreateLang.builder().add(Component.literal("P = "))
86-
.add(number(unit.convert(pressure)))
87-
.text(" ")
62+
.add(numberWithSymbol(unit.convert(pressure)))
8863
.add(unit.getSymbol());
8964
}
9065
public static LangBuilder formatRadiationFlux(float radiationFlux) {
9166
RadiationFlux unit = FormicAPIConfigs.CLIENT.units.radiationFlux.get();
9267
return CreateLang.builder().add(Component.literal("activity : "))
93-
.add(number(unit.convert(radiationFlux)))
94-
.text(" ")
68+
.add(numberWithSymbol(unit.convert(radiationFlux)))
9569
.add(unit.getSymbol());
9670
}
9771

src/main/java/com/rae/formicapi/config/FormicAPICfgClient.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@
88
public class FormicAPICfgClient extends ConfigBase {
99

1010

11-
public final FormicAPIUnits units = nested(0, FormicAPIUnits::new, Comments.units);
11+
public final UnitConfig units = nested(0, UnitConfig::new, Comments.units);
1212
@Override
1313
public @NotNull String getName() {
1414
return FormicAPI.MODID +".client";
1515
}
1616

1717
private static class Comments {
1818
static String units = "Units used";
19-
static String nuclear = "Graphic config for nuclear";
20-
static String nuclearParticle = "Radiation Particles";
21-
2219
}
2320

2421
}

src/main/java/com/rae/formicapi/config/FormicAPIUnits.java renamed to src/main/java/com/rae/formicapi/config/UnitConfig.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44
import com.rae.formicapi.units.RadiationFlux;
55
import com.rae.formicapi.units.Temperature;
66
import net.createmod.catnip.config.ConfigBase;
7+
import org.jetbrains.annotations.NotNull;
78

8-
public class FormicAPIUnits extends ConfigBase {
9+
public class UnitConfig extends ConfigBase {
910
public final ConfigEnum<Temperature> temperature = e(Temperature.CELSIUS,"temperature", Comments.temperature);
1011
public final ConfigEnum<Pressure> pressure = e(Pressure.ATMOSPHERES,"pressure", Comments.pressure);
11-
public final ConfigEnum<RadiationFlux> radiationFlux = e(RadiationFlux.MEGA_BECQUERELS,"radiation_flux", Comments.radiationFlux);
12+
public final ConfigEnum<RadiationFlux> radiationFlux = e(RadiationFlux.BECQUERELS,"radiation_flux", Comments.radiationFlux);
1213

1314

1415
@Override
15-
public String getName() {
16+
public @NotNull String getName() {
1617
return "units";
1718
}
1819
private static class Comments {

0 commit comments

Comments
 (0)