Allow server to disable the forced preset override

This commit is contained in:
Frank 2022-07-03 19:51:18 +02:00
parent 910314a1e8
commit e670fea21a
6 changed files with 22 additions and 5 deletions

View file

@ -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()

View file

@ -0,0 +1,23 @@
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;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;
@Mixin(DedicatedServerProperties.class)
public class DedicatedServerPropertiesMixin {
//Make sure the default server properties use our Default World Preset by default (read from "level-type")
@ModifyArg(method = "<init>", index = 3, at = @At(value = "INVOKE", target = "Lnet/minecraft/server/dedicated/DedicatedServerProperties$WorldGenProperties;<init>(Ljava/lang/String;Lcom/google/gson/JsonObject;ZLjava/lang/String;)V"))
protected String wt_defaultPreset(String string) {
if (WorldsTogether.FORCE_SERVER_TO_BETTERX_PRESET) {
return WorldPresets.getDEFAULT().location().toString();
}
return string;
}
}