diff --git a/src/main/java/ca/spottedleaf/moonrise/common/util/ConfigHolder.java b/src/main/java/ca/spottedleaf/moonrise/common/util/ConfigHolder.java index a4965292..d2f97ef8 100644 --- a/src/main/java/ca/spottedleaf/moonrise/common/util/ConfigHolder.java +++ b/src/main/java/ca/spottedleaf/moonrise/common/util/ConfigHolder.java @@ -1,5 +1,6 @@ package ca.spottedleaf.moonrise.common.util; +import ca.spottedleaf.moonrise.common.PlatformHooks; import ca.spottedleaf.moonrise.common.config.adapter.TypeAdapterRegistry; import ca.spottedleaf.moonrise.common.config.config.YamlConfig; import ca.spottedleaf.moonrise.common.config.moonrise.MoonriseConfig; @@ -13,7 +14,7 @@ public final class ConfigHolder { private static final Logger LOGGER = LoggerFactory.getLogger(ConfigHolder.class); - private static final File CONFIG_FILE = new File(System.getProperty("Moonrise.ConfigFile", "config/moonrise.yml")); + private static final File CONFIG_FILE = new File(System.getProperty(PlatformHooks.get().getBrand() + ".ConfigFile", "config/moonrise.yml")); private static final TypeAdapterRegistry CONFIG_ADAPTERS = new TypeAdapterRegistry(); private static final YamlConfig CONFIG; static { @@ -25,7 +26,7 @@ public final class ConfigHolder { throw new RuntimeException(ex); } } - private static final String CONFIG_HEADER = """ + private static final String CONFIG_HEADER = String.format(""" This is the configuration file for Moonrise. Each configuration option is prefixed with a comment to explain what it does. Additional changes to this file @@ -33,10 +34,10 @@ public final class ConfigHolder { Below are the Moonrise startup flags. Note that startup flags must be placed in the JVM arguments, not program arguments. - -DMoonrise.ConfigFile= - Override the config file location. Might be useful for multiple game versions. - -DMoonrise.WorkerThreadCount= - Override the auto configured worker thread counts (worker-threads). - -DMoonrise.MaxViewDistance= - Overrides the maximum view distance, should only use for debugging purposes. - """; + -D%1$s.ConfigFile= - Override the config file location. Might be useful for multiple game versions. + -D%1$s.WorkerThreadCount= - Override the auto configured worker thread counts (worker-threads). + -D%1$s.MaxViewDistance= - Overrides the maximum view distance, should only use for debugging purposes. + """, PlatformHooks.get().getBrand()); static { reloadConfig(); diff --git a/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java b/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java index 3285f265..c125c70a 100644 --- a/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java +++ b/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java @@ -19,7 +19,7 @@ public final class MoonriseCommon { @Override public void accept(Thread thread) { thread.setDaemon(true); - thread.setName("Moonrise Common Worker #" + this.idGenerator.getAndIncrement()); + thread.setName(PlatformHooks.get().getBrand() + " Common Worker #" + this.idGenerator.getAndIncrement()); thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(final Thread thread, final Throwable throwable) { @@ -44,7 +44,7 @@ public static void adjustWorkerThreads(final int configWorkerThreads, final int } else { defaultWorkerThreads = defaultWorkerThreads / 2; } - defaultWorkerThreads = Integer.getInteger("Moonrise.WorkerThreadCount", Integer.valueOf(defaultWorkerThreads)); + defaultWorkerThreads = Integer.getInteger(PlatformHooks.get().getBrand() + ".WorkerThreadCount", Integer.valueOf(defaultWorkerThreads)); int workerThreads = configWorkerThreads; diff --git a/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseConstants.java b/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseConstants.java index ffffad18..559c959a 100644 --- a/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseConstants.java +++ b/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseConstants.java @@ -1,8 +1,10 @@ package ca.spottedleaf.moonrise.common.util; +import ca.spottedleaf.moonrise.common.PlatformHooks; + public final class MoonriseConstants { - public static final int MAX_VIEW_DISTANCE = Integer.getInteger("Moonrise.MaxViewDistance", 32); + public static final int MAX_VIEW_DISTANCE = Integer.getInteger(PlatformHooks.get().getBrand() + ".MaxViewDistance", 32); private MoonriseConstants() {} diff --git a/src/main/java/ca/spottedleaf/moonrise/mixin/blockstate_propertyaccess/BooleanPropertyMixin.java b/src/main/java/ca/spottedleaf/moonrise/mixin/blockstate_propertyaccess/BooleanPropertyMixin.java index 797edbcb..cf61f642 100644 --- a/src/main/java/ca/spottedleaf/moonrise/mixin/blockstate_propertyaccess/BooleanPropertyMixin.java +++ b/src/main/java/ca/spottedleaf/moonrise/mixin/blockstate_propertyaccess/BooleanPropertyMixin.java @@ -6,6 +6,7 @@ import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraft.world.level.block.state.properties.Property; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.Inject; @@ -17,6 +18,9 @@ protected BooleanPropertyMixin(String string, Class class_) { super(string, class_); } + @Unique + private static final Boolean[] BY_ID = new Boolean[]{ Boolean.FALSE, Boolean.TRUE }; + @Override public final int moonrise$getIdFor(final Boolean value) { return value.booleanValue() ? 1 : 0; @@ -33,6 +37,6 @@ protected BooleanPropertyMixin(String string, Class class_) { ) ) private void init(final CallbackInfo ci) { - this.moonrise$setById(new Boolean[]{ Boolean.FALSE, Boolean.TRUE }); + this.moonrise$setById(BY_ID); } } diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java index e65da01d..93335de8 100644 --- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java +++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java @@ -1057,7 +1057,7 @@ public void onMove() { @Override public void onRemove(final Entity.RemovalReason reason) { final Entity entity = this.entity; - EntityLookup.this.checkThread(entity, "Cannot remove entity off-main"); // Paper - rewrite chunk system + EntityLookup.this.checkThread(entity, "Cannot remove entity off-main"); final Visibility tickingState = EntityLookup.getEntityStatus(entity); EntityLookup.this.removeEntity(entity);