mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 03:25:18 +00:00
Add game test to GlobalLootModifierTest which validates the smelting modifiers. Removed FakePlayer system, it's broken and needs a major rewrite.
111 lines
7.5 KiB
Diff
111 lines
7.5 KiB
Diff
--- a/net/minecraft/server/Main.java
|
|
+++ b/net/minecraft/server/Main.java
|
|
@@ -80,6 +_,15 @@
|
|
OptionSpec<Void> optionspec12 = optionparser.accepts("jfrProfile");
|
|
OptionSpec<Path> optionspec13 = optionparser.accepts("pidFile").withRequiredArg().withValuesConvertedBy(new PathConverter());
|
|
OptionSpec<String> optionspec14 = optionparser.nonOptions();
|
|
+ optionparser.accepts("allowUpdates").withRequiredArg().ofType(Boolean.class).defaultsTo(Boolean.TRUE); // Forge: allow mod updates to proceed
|
|
+ optionparser.accepts("gameDir").withRequiredArg().ofType(File.class).defaultsTo(new File(".")); //Forge: Consume this argument, we use it in the launcher, and the client side.
|
|
+ final OptionSpec<net.minecraft.core.BlockPos> spawnPosOpt;
|
|
+ boolean gametestEnabled = Boolean.getBoolean("forge.gameTestServer");
|
|
+ if (gametestEnabled) {
|
|
+ spawnPosOpt = optionparser.accepts("spawnPos").withRequiredArg().withValuesConvertedBy(new net.minecraftforge.gametest.BlockPosValueConverter()).defaultsTo(new net.minecraft.core.BlockPos(0, 60, 0));
|
|
+ } else {
|
|
+ spawnPosOpt = null;
|
|
+ }
|
|
|
|
try {
|
|
OptionSet optionset = optionparser.parse(p_129699_);
|
|
@@ -87,6 +_,13 @@
|
|
optionparser.printHelpOn(System.err);
|
|
return;
|
|
}
|
|
+ Path path2 = Paths.get("eula.txt");
|
|
+ Eula eula = new Eula(path2);
|
|
+
|
|
+ if (!eula.hasAgreedToEULA()) {
|
|
+ LOGGER.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info.");
|
|
+ return;
|
|
+ }
|
|
|
|
Path path = optionset.valueOf(optionspec13);
|
|
if (path != null) {
|
|
@@ -102,25 +_,24 @@
|
|
Bootstrap.validate();
|
|
Util.startTimerHackThread();
|
|
Path path1 = Paths.get("server.properties");
|
|
+ if (!optionset.has(optionspec1)) net.minecraftforge.server.loading.ServerModLoader.load(); // Load mods before we load almost anything else anymore. Single spot now. Only loads if they haven't passed the initserver param
|
|
DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(path1);
|
|
dedicatedserversettings.forceSave();
|
|
- Path path2 = Paths.get("eula.txt");
|
|
- Eula eula = new Eula(path2);
|
|
if (optionset.has(optionspec1)) {
|
|
LOGGER.info("Initialized '{}' and '{}'", path1.toAbsolutePath(), path2.toAbsolutePath());
|
|
return;
|
|
}
|
|
|
|
- if (!eula.hasAgreedToEULA()) {
|
|
- LOGGER.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info.");
|
|
- return;
|
|
- }
|
|
-
|
|
File file1 = new File(optionset.valueOf(optionspec8));
|
|
Services services = Services.create(new YggdrasilAuthenticationService(Proxy.NO_PROXY), file1);
|
|
String s = Optional.ofNullable(optionset.valueOf(optionspec9)).orElse(dedicatedserversettings.getProperties().levelName);
|
|
+ if (s == null || s.isEmpty() || new File(file1, s).getAbsolutePath().equals(new File(s).getAbsolutePath())) {
|
|
+ LOGGER.error("Invalid world directory specified, must not be null, empty or the same directory as your universe! " + s);
|
|
+ return;
|
|
+ }
|
|
LevelStorageSource levelstoragesource = LevelStorageSource.createDefault(file1.toPath());
|
|
LevelStorageSource.LevelStorageAccess levelstoragesource$levelstorageaccess = levelstoragesource.validateAndCreateAccess(s);
|
|
+ levelstoragesource$levelstorageaccess.readAdditionalLevelSaveData();
|
|
LevelSummary levelsummary = levelstoragesource$levelstorageaccess.getSummary();
|
|
if (levelsummary != null) {
|
|
if (levelsummary.requiresManualConversion()) {
|
|
@@ -166,6 +_,8 @@
|
|
worlddimensions = dedicatedserverproperties.createDimensions(p_248079_.datapackWorldgen());
|
|
}
|
|
|
|
+ //Forge: Do a write-read-cycle to inject modded dimensions on first start of a dedicated server into its generated world dimensions list.
|
|
+ worlddimensions = WorldDimensions.CODEC.encoder().encodeStart(dynamicops, worlddimensions).flatMap((writtenPayloadWithModdedDimensions) -> WorldDimensions.CODEC.decoder().parse(dynamicops, writtenPayloadWithModdedDimensions)).resultOrPartial(LOGGER::error).orElse(worlddimensions);
|
|
WorldDimensions.Complete worlddimensions$complete = worlddimensions.bake(registry);
|
|
Lifecycle lifecycle = worlddimensions$complete.lifecycle().add(p_248079_.datapackWorldgen().allRegistriesLifecycle());
|
|
return new WorldLoader.DataLoadOutput<>(new PrimaryLevelData(levelsettings, worldoptions, worlddimensions$complete.specialWorldProperty(), lifecycle), worlddimensions$complete.dimensionsRegistryAccess());
|
|
@@ -186,21 +_,32 @@
|
|
|
|
WorldData worlddata = worldstem.worldData();
|
|
levelstoragesource$levelstorageaccess.saveDataTag(registryaccess$frozen, worlddata);
|
|
- final DedicatedServer dedicatedserver = MinecraftServer.spin((p_296433_) -> {
|
|
- DedicatedServer dedicatedserver1 = new DedicatedServer(p_296433_, levelstoragesource$levelstorageaccess, packrepository, worldstem, dedicatedserversettings, DataFixers.getDataFixer(), services, LoggerChunkProgressListener::new);
|
|
+ final MinecraftServer dedicatedserver = MinecraftServer.spin((p_129697_) -> {
|
|
+ MinecraftServer dedicatedserver1;
|
|
+ if (gametestEnabled) {
|
|
+ net.minecraftforge.gametest.ForgeGameTestHooks.registerGametests();
|
|
+ var testBatches = net.minecraft.gametest.framework.GameTestRunner.groupTestsIntoBatches(net.minecraft.gametest.framework.GameTestRegistry.getAllTestFunctions());
|
|
+ var spawnPos = optionset.valueOf(spawnPosOpt);
|
|
+ dedicatedserver1 = new net.minecraft.gametest.framework.GameTestServer(p_129697_, levelstoragesource$levelstorageaccess, packrepository, worldstem, testBatches, spawnPos);
|
|
+ } else {
|
|
+ dedicatedserver1 = new DedicatedServer(p_129697_, levelstoragesource$levelstorageaccess, packrepository, worldstem, dedicatedserversettings, DataFixers.getDataFixer(), services, LoggerChunkProgressListener::new);
|
|
+ }
|
|
dedicatedserver1.setPort(optionset.valueOf(optionspec10));
|
|
dedicatedserver1.setDemo(optionset.has(optionspec2));
|
|
dedicatedserver1.setId(optionset.valueOf(optionspec11));
|
|
boolean flag1 = !optionset.has(optionspec) && !optionset.valuesOf(optionspec14).contains("nogui");
|
|
- if (flag1 && !GraphicsEnvironment.isHeadless()) {
|
|
- dedicatedserver1.showGui();
|
|
+ if (dedicatedserver1 instanceof DedicatedServer dedicatedServer && flag1 && !GraphicsEnvironment.isHeadless()) {
|
|
+ dedicatedServer.showGui();
|
|
}
|
|
|
|
return dedicatedserver1;
|
|
});
|
|
Thread thread = new Thread("Server Shutdown Thread") {
|
|
public void run() {
|
|
+ // FORGE: Halting as GameTestServer will cause issues as it always calls System#exit on both crash and normal exit, so skip it
|
|
+ if (!(dedicatedserver instanceof net.minecraft.gametest.framework.GameTestServer))
|
|
dedicatedserver.halt(true);
|
|
+ org.apache.logging.log4j.LogManager.shutdown(); // we're manually managing the logging shutdown on the server. Make sure we do it here at the end.
|
|
}
|
|
};
|
|
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER));
|