diff --git a/src/main/java/org/betterx/bclib/BCLib.java b/src/main/java/org/betterx/bclib/BCLib.java index dbf56276..7cabae04 100644 --- a/src/main/java/org/betterx/bclib/BCLib.java +++ b/src/main/java/org/betterx/bclib/BCLib.java @@ -70,6 +70,8 @@ public class BCLib implements ModInitializer { PlacementModifiers.ensureStaticInitialization(); Configs.save(); + WorldsTogether.FORCE_SERVER_TO_BETTERX_PRESET = Configs.SERVER_CONFIG.forceBetterXPreset(); + if (false && isDevEnvironment()) { BCLBiome theYellow = BCLBiomeBuilder .start(makeID("the_yellow")) diff --git a/src/main/java/org/betterx/bclib/config/ServerConfig.java b/src/main/java/org/betterx/bclib/config/ServerConfig.java index aaa6758c..92ae389d 100644 --- a/src/main/java/org/betterx/bclib/config/ServerConfig.java +++ b/src/main/java/org/betterx/bclib/config/ServerConfig.java @@ -55,6 +55,11 @@ public class ServerConfig extends NamedPathConfig { "excludeMods", AutoSync.SYNC_CATEGORY ); + public static final ConfigToken FORCE_BETTERX_PRESET = ConfigToken.Boolean( + true, + "forceBetterXPreset", + AutoSync.SYNC_CATEGORY + ); public ServerConfig() { @@ -85,4 +90,8 @@ public class ServerConfig extends NamedPathConfig { return get(SEND_ALL_MOD_INFO) /*&& isAllowingAutoSync()*/; } + public boolean forceBetterXPreset() { + return get(FORCE_BETTERX_PRESET); + } + } diff --git a/src/main/java/org/betterx/worlds/together/WorldsTogether.java b/src/main/java/org/betterx/worlds/together/WorldsTogether.java index 28f4a65f..a74adba5 100644 --- a/src/main/java/org/betterx/worlds/together/WorldsTogether.java +++ b/src/main/java/org/betterx/worlds/together/WorldsTogether.java @@ -12,6 +12,7 @@ import net.fabricmc.loader.api.FabricLoader; public class WorldsTogether { public static boolean SURPRESS_EXPERIMENTAL_DIALOG = false; + public static boolean FORCE_SERVER_TO_BETTERX_PRESET = false; public static final String MOD_ID = "worlds_together"; public static final Logger LOGGER = new Logger(MOD_ID); public static final boolean RUNS_TERRABLENDER = FabricLoader.getInstance() diff --git a/src/main/java/org/betterx/bclib/mixin/common/DedicatedServerPropertiesMixin.java b/src/main/java/org/betterx/worlds/together/mixin/common/DedicatedServerPropertiesMixin.java similarity index 64% rename from src/main/java/org/betterx/bclib/mixin/common/DedicatedServerPropertiesMixin.java rename to src/main/java/org/betterx/worlds/together/mixin/common/DedicatedServerPropertiesMixin.java index 8642a0c0..a7dee9c1 100644 --- a/src/main/java/org/betterx/bclib/mixin/common/DedicatedServerPropertiesMixin.java +++ b/src/main/java/org/betterx/worlds/together/mixin/common/DedicatedServerPropertiesMixin.java @@ -1,5 +1,6 @@ -package org.betterx.bclib.mixin.common; +package org.betterx.worlds.together.mixin.common; +import org.betterx.worlds.together.WorldsTogether; import org.betterx.worlds.together.worldPreset.WorldPresets; import net.minecraft.server.dedicated.DedicatedServerProperties; @@ -10,9 +11,13 @@ import org.spongepowered.asm.mixin.injection.ModifyArg; @Mixin(DedicatedServerProperties.class) public class DedicatedServerPropertiesMixin { - //Make sure the default server properties use our Default World Preset + //Make sure the default server properties use our Default World Preset by default (read from "level-type") @ModifyArg(method = "", index = 3, at = @At(value = "INVOKE", target = "Lnet/minecraft/server/dedicated/DedicatedServerProperties$WorldGenProperties;(Ljava/lang/String;Lcom/google/gson/JsonObject;ZLjava/lang/String;)V")) - private String bcl_init(String levelType) { - return WorldPresets.getDEFAULT().location().toString(); + protected String wt_defaultPreset(String string) { + if (WorldsTogether.FORCE_SERVER_TO_BETTERX_PRESET) { + return WorldPresets.getDEFAULT().location().toString(); + } + + return string; } } diff --git a/src/main/resources/bclib.mixins.common.json b/src/main/resources/bclib.mixins.common.json index 7e1f5ebb..8b7bf1aa 100644 --- a/src/main/resources/bclib.mixins.common.json +++ b/src/main/resources/bclib.mixins.common.json @@ -15,7 +15,6 @@ "ChunkGeneratorsMixin", "ComposterBlockAccessor", "CraftingMenuMixin", - "DedicatedServerPropertiesMixin", "DiggerItemMixin", "EnchantingTableBlockMixin", "ItemStackMixin", diff --git a/src/main/resources/together.mixins.common.json b/src/main/resources/together.mixins.common.json index 01a9360e..75e009db 100644 --- a/src/main/resources/together.mixins.common.json +++ b/src/main/resources/together.mixins.common.json @@ -5,6 +5,7 @@ "compatibilityLevel": "JAVA_17", "mixins": [ "BuiltinRegistriesMixin", + "DedicatedServerPropertiesMixin", "DiggerItemAccessor", "MainMixin", "MinecraftServerMixin",