Skip to content

Commit

Permalink
Misc changes reviewing 1.21.2 update for Paper
Browse files Browse the repository at this point in the history
  • Loading branch information
Spottedleaf committed Oct 21, 2024
1 parent 03784b8 commit 7f6852a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<MoonriseConfig> CONFIG;
static {
Expand All @@ -25,18 +26,18 @@ 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
other than modifying the options, such as adding comments, will be overwritten when Moonrise loads the config.
Below are the Moonrise startup flags. Note that startup flags must be placed in the JVM arguments, not
program arguments.
-DMoonrise.ConfigFile=<file> - Override the config file location. Might be useful for multiple game versions.
-DMoonrise.WorkerThreadCount=<number> - Override the auto configured worker thread counts (worker-threads).
-DMoonrise.MaxViewDistance=<number> - Overrides the maximum view distance, should only use for debugging purposes.
""";
-D%1$s.ConfigFile=<file> - Override the config file location. Might be useful for multiple game versions.
-D%1$s.WorkerThreadCount=<number> - Override the auto configured worker thread counts (worker-threads).
-D%1$s.MaxViewDistance=<number> - Overrides the maximum view distance, should only use for debugging purposes.
""", PlatformHooks.get().getBrand());

static {
reloadConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,6 +18,9 @@ protected BooleanPropertyMixin(String string, Class<Boolean> 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;
Expand All @@ -33,6 +37,6 @@ protected BooleanPropertyMixin(String string, Class<Boolean> class_) {
)
)
private void init(final CallbackInfo ci) {
this.moonrise$setById(new Boolean[]{ Boolean.FALSE, Boolean.TRUE });
this.moonrise$setById(BY_ID);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7f6852a

Please sign in to comment.