mirror of
https://github.com/TeamMidnightDust/MidnightLib.git
synced 2025-12-17 01:35:10 +01:00
fix: crash on servers
- This makes overriding the screen less flexible, but out of all options, this was the best way to do it. Previously, the `@EnvType` annotation took care of keeping this out of the server code, but NeoForge decided to break perfectly functional behaviour once again, requiring me to remove the annotations 🫠
This commit is contained in:
@@ -37,7 +37,7 @@ public abstract class MidnightConfig {
|
|||||||
private static final Pattern DECIMAL_ONLY = Pattern.compile("-?(\\d+\\.?\\d*|\\d*\\.?\\d+|\\.)");
|
private static final Pattern DECIMAL_ONLY = Pattern.compile("-?(\\d+\\.?\\d*|\\d*\\.?\\d+|\\.)");
|
||||||
private static final Pattern HEXADECIMAL_ONLY = Pattern.compile("(-?[#0-9a-fA-F]*)");
|
private static final Pattern HEXADECIMAL_ONLY = Pattern.compile("(-?[#0-9a-fA-F]*)");
|
||||||
private static final Gson gson = new GsonBuilder()
|
private static final Gson gson = new GsonBuilder()
|
||||||
.excludeFieldsWithModifiers(Modifier.TRANSIENT).excludeFieldsWithModifiers(Modifier.PRIVATE)
|
.excludeFieldsWithModifiers(Modifier.TRANSIENT).excludeFieldsWithModifiers(Modifier.PRIVATE).excludeFieldsWithModifiers(Modifier.FINAL)
|
||||||
.addSerializationExclusionStrategy(new ExclusionStrategy() {
|
.addSerializationExclusionStrategy(new ExclusionStrategy() {
|
||||||
public boolean shouldSkipClass(Class<?> clazz) { return false; }
|
public boolean shouldSkipClass(Class<?> clazz) { return false; }
|
||||||
public boolean shouldSkipField(FieldAttributes fieldAttributes) { return fieldAttributes.getAnnotation(Entry.class) == null; }
|
public boolean shouldSkipField(FieldAttributes fieldAttributes) { return fieldAttributes.getAnnotation(Entry.class) == null; }
|
||||||
@@ -70,13 +70,12 @@ public abstract class MidnightConfig {
|
|||||||
MidnightConfig instance = createInstance(modid, config);
|
MidnightConfig instance = createInstance(modid, config);
|
||||||
|
|
||||||
for (Field field : config.getFields()) {
|
for (Field field : config.getFields()) {
|
||||||
EntryInfo info = new EntryInfo(field, modid);
|
|
||||||
//noinspection ConstantValue
|
//noinspection ConstantValue
|
||||||
if ((field.isAnnotationPresent(Entry.class) || field.isAnnotationPresent(Comment.class))
|
if ((field.isAnnotationPresent(Entry.class) || field.isAnnotationPresent(Comment.class))
|
||||||
&& !field.isAnnotationPresent(Server.class)
|
&& !field.isAnnotationPresent(Server.class)
|
||||||
&& !field.isAnnotationPresent(Hidden.class)
|
&& !field.isAnnotationPresent(Hidden.class)
|
||||||
&& PlatformFunctions.isClientEnv())
|
&& PlatformFunctions.isClientEnv())
|
||||||
instance.addClientEntry(field, info);
|
instance.addClientEntry(field, new EntryInfo(field, modid));
|
||||||
}
|
}
|
||||||
instance.loadValuesFromJson();
|
instance.loadValuesFromJson();
|
||||||
}
|
}
|
||||||
@@ -212,10 +211,10 @@ public abstract class MidnightConfig {
|
|||||||
public void onTabInit(String tabName, MidnightConfigListWidget list, MidnightConfigScreen screen) {
|
public void onTabInit(String tabName, MidnightConfigListWidget list, MidnightConfigScreen screen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Screen getScreen(Screen parent, String modid) {
|
public static MidnightConfigScreen getScreen(Screen parent, String modid) {
|
||||||
return configInstances.get(modid).getScreen(parent);
|
return configInstances.get(modid).getScreen(parent);
|
||||||
}
|
}
|
||||||
public Screen getScreen(Screen parent) {
|
public MidnightConfigScreen getScreen(Screen parent) {
|
||||||
return new MidnightConfigScreen(parent, modid);
|
return new MidnightConfigScreen(parent, modid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,11 @@ loom {
|
|||||||
configName = "Test Minecraft Client"
|
configName = "Test Minecraft Client"
|
||||||
source sourceSets.test
|
source sourceSets.test
|
||||||
}
|
}
|
||||||
|
testServer {
|
||||||
|
server()
|
||||||
|
configName = "Test Minecraft Server"
|
||||||
|
source sourceSets.test
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ yarn_mappings=1.21.9+build.1
|
|||||||
enabled_platforms=fabric,neoforge
|
enabled_platforms=fabric,neoforge
|
||||||
|
|
||||||
archives_base_name=midnightlib
|
archives_base_name=midnightlib
|
||||||
mod_version=1.8.2
|
mod_version=1.8.3
|
||||||
maven_group=eu.midnightdust
|
maven_group=eu.midnightdust
|
||||||
release_type=release
|
release_type=release
|
||||||
curseforge_id=488090
|
curseforge_id=488090
|
||||||
@@ -15,7 +15,7 @@ modrinth_id=codAaoxh
|
|||||||
fabric_loader_version=0.17.2
|
fabric_loader_version=0.17.2
|
||||||
fabric_api_version=0.133.14+1.21.9
|
fabric_api_version=0.133.14+1.21.9
|
||||||
|
|
||||||
neoforge_version=21.9.3-beta
|
neoforge_version=21.9.9-beta
|
||||||
yarn_mappings_patch_neoforge_version = 1.21+build.4
|
yarn_mappings_patch_neoforge_version = 1.21+build.4
|
||||||
|
|
||||||
mod_menu_version = 9.0.0
|
mod_menu_version = 9.0.0
|
||||||
@@ -39,6 +39,20 @@ loom {
|
|||||||
client()
|
client()
|
||||||
name = "Test Minecraft Client"
|
name = "Test Minecraft Client"
|
||||||
|
|
||||||
|
mods {
|
||||||
|
create('midnightlib') {
|
||||||
|
sourceSet sourceSets.main
|
||||||
|
}
|
||||||
|
create('modid') { // test mod
|
||||||
|
sourceSet sourceSets.test
|
||||||
|
}
|
||||||
|
}
|
||||||
|
source sourceSets.test
|
||||||
|
}
|
||||||
|
testServer {
|
||||||
|
server()
|
||||||
|
name = "Test Minecraft Server"
|
||||||
|
|
||||||
mods {
|
mods {
|
||||||
create('midnightlib') {
|
create('midnightlib') {
|
||||||
sourceSet sourceSets.main
|
sourceSet sourceSets.main
|
||||||
|
|||||||
Reference in New Issue
Block a user