Merge remote-tracking branch 'upstream/1.20/dev' into feat/multi-loader-1.21

This commit is contained in:
IThundxr 2024-11-13 16:30:36 -05:00
commit 89d87555e6
Failed to generate hash of commit
4 changed files with 17 additions and 19 deletions

View file

@ -17,8 +17,6 @@ public final class BackendManagerImpl {
.supported(() -> true)
.register(Flywheel.rl("off"));
public static final Backend DEFAULT_BACKEND = findDefaultBackend();
private static Backend backend = OFF_BACKEND;
private BackendManagerImpl() {
@ -41,7 +39,7 @@ public final class BackendManagerImpl {
return backends;
}
private static Backend findDefaultBackend() {
public static Backend defaultBackend() {
var backendsByPriority = backendsByPriority();
if (backendsByPriority.isEmpty()) {
// This probably shouldn't happen, but fail gracefully.

View file

@ -42,7 +42,7 @@ public class FlwApiLinkImpl implements FlwApiLink {
@Override
public Backend getDefaultBackend() {
return BackendManagerImpl.DEFAULT_BACKEND;
return BackendManagerImpl.defaultBackend();
}
@Override

View file

@ -100,17 +100,7 @@ public class FabricFlwConfig implements FlwConfig {
readBackend(object);
readLimitUpdates(object);
readWorkerThreads(object);
readFlwBackend(object);
}
private void readFlwBackend(JsonObject object) {
var flwBackendJson = object.get("flw_backend");
if (flwBackendJson instanceof JsonObject flwBackendObject) {
backendConfig.fromJson(flwBackendObject);
} else {
FlwImpl.CONFIG_LOGGER.warn("'flw_backend' value must be an object");
}
readFlwBackends(object);
}
private void readBackend(JsonObject object) {
@ -174,6 +164,16 @@ public class FabricFlwConfig implements FlwConfig {
workerThreads = WORKER_THREADS_DEFAULT;
}
private void readFlwBackends(JsonObject object) {
var flwBackendsJson = object.get("flw_backends");
if (flwBackendsJson instanceof JsonObject flwBackendsObject) {
backendConfig.fromJson(flwBackendsObject);
} else {
FlwImpl.CONFIG_LOGGER.warn("'flw_backends' value must be an object");
}
}
public JsonObject toJson() {
JsonObject object = new JsonObject();
object.addProperty("backend", Backend.REGISTRY.getIdOrThrow(backend).toString());
@ -206,10 +206,10 @@ public class FabricFlwConfig implements FlwConfig {
}
private void readLightSmoothness(JsonObject object) {
var backendJson = object.get("lightSmoothness");
var lightSmoothnessJson = object.get("lightSmoothness");
String msg = null;
if (backendJson instanceof JsonPrimitive primitive && primitive.isString()) {
if (lightSmoothnessJson instanceof JsonPrimitive primitive && primitive.isString()) {
var value = primitive.getAsString();
for (var item : LightSmoothness.values()) {
@ -221,7 +221,7 @@ public class FabricFlwConfig implements FlwConfig {
}
msg = "Unknown 'lightSmoothness' value: " + value;
} else if (backendJson != null) {
} else if (lightSmoothnessJson != null) {
msg = "'lightSmoothness' value must be a string";
}

View file

@ -83,7 +83,7 @@ public class NeoForgeFlwConfig implements FlwConfig {
private ClientConfig(ModConfigSpec.Builder builder) {
backend = builder.comment("Select the backend to use.")
.define("backend", Backend.REGISTRY.getIdOrThrow(BackendManager.defaultBackend()).toString());
.define("backend", () -> Backend.REGISTRY.getIdOrThrow(BackendManager.defaultBackend()).toString(), o -> o != null && String.class.isAssignableFrom(o.getClass()));
limitUpdates = builder.comment("Enable or disable instance update limiting with distance.")
.define("limitUpdates", true);