mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-23 11:27:54 +01:00
Merge remote-tracking branch 'upstream/1.20/dev' into feat/multi-loader-1.21
This commit is contained in:
commit
89d87555e6
4 changed files with 17 additions and 19 deletions
|
@ -17,8 +17,6 @@ public final class BackendManagerImpl {
|
||||||
.supported(() -> true)
|
.supported(() -> true)
|
||||||
.register(Flywheel.rl("off"));
|
.register(Flywheel.rl("off"));
|
||||||
|
|
||||||
public static final Backend DEFAULT_BACKEND = findDefaultBackend();
|
|
||||||
|
|
||||||
private static Backend backend = OFF_BACKEND;
|
private static Backend backend = OFF_BACKEND;
|
||||||
|
|
||||||
private BackendManagerImpl() {
|
private BackendManagerImpl() {
|
||||||
|
@ -41,7 +39,7 @@ public final class BackendManagerImpl {
|
||||||
return backends;
|
return backends;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Backend findDefaultBackend() {
|
public static Backend defaultBackend() {
|
||||||
var backendsByPriority = backendsByPriority();
|
var backendsByPriority = backendsByPriority();
|
||||||
if (backendsByPriority.isEmpty()) {
|
if (backendsByPriority.isEmpty()) {
|
||||||
// This probably shouldn't happen, but fail gracefully.
|
// This probably shouldn't happen, but fail gracefully.
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class FlwApiLinkImpl implements FlwApiLink {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Backend getDefaultBackend() {
|
public Backend getDefaultBackend() {
|
||||||
return BackendManagerImpl.DEFAULT_BACKEND;
|
return BackendManagerImpl.defaultBackend();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -100,17 +100,7 @@ public class FabricFlwConfig implements FlwConfig {
|
||||||
readBackend(object);
|
readBackend(object);
|
||||||
readLimitUpdates(object);
|
readLimitUpdates(object);
|
||||||
readWorkerThreads(object);
|
readWorkerThreads(object);
|
||||||
readFlwBackend(object);
|
readFlwBackends(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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readBackend(JsonObject object) {
|
private void readBackend(JsonObject object) {
|
||||||
|
@ -174,6 +164,16 @@ public class FabricFlwConfig implements FlwConfig {
|
||||||
workerThreads = WORKER_THREADS_DEFAULT;
|
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() {
|
public JsonObject toJson() {
|
||||||
JsonObject object = new JsonObject();
|
JsonObject object = new JsonObject();
|
||||||
object.addProperty("backend", Backend.REGISTRY.getIdOrThrow(backend).toString());
|
object.addProperty("backend", Backend.REGISTRY.getIdOrThrow(backend).toString());
|
||||||
|
@ -206,10 +206,10 @@ public class FabricFlwConfig implements FlwConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readLightSmoothness(JsonObject object) {
|
private void readLightSmoothness(JsonObject object) {
|
||||||
var backendJson = object.get("lightSmoothness");
|
var lightSmoothnessJson = object.get("lightSmoothness");
|
||||||
String msg = null;
|
String msg = null;
|
||||||
|
|
||||||
if (backendJson instanceof JsonPrimitive primitive && primitive.isString()) {
|
if (lightSmoothnessJson instanceof JsonPrimitive primitive && primitive.isString()) {
|
||||||
var value = primitive.getAsString();
|
var value = primitive.getAsString();
|
||||||
|
|
||||||
for (var item : LightSmoothness.values()) {
|
for (var item : LightSmoothness.values()) {
|
||||||
|
@ -221,7 +221,7 @@ public class FabricFlwConfig implements FlwConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = "Unknown 'lightSmoothness' value: " + value;
|
msg = "Unknown 'lightSmoothness' value: " + value;
|
||||||
} else if (backendJson != null) {
|
} else if (lightSmoothnessJson != null) {
|
||||||
msg = "'lightSmoothness' value must be a string";
|
msg = "'lightSmoothness' value must be a string";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class NeoForgeFlwConfig implements FlwConfig {
|
||||||
|
|
||||||
private ClientConfig(ModConfigSpec.Builder builder) {
|
private ClientConfig(ModConfigSpec.Builder builder) {
|
||||||
backend = builder.comment("Select the backend to use.")
|
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.")
|
limitUpdates = builder.comment("Enable or disable instance update limiting with distance.")
|
||||||
.define("limitUpdates", true);
|
.define("limitUpdates", true);
|
||||||
|
|
Loading…
Reference in a new issue