Fix server side loading, tweak mods command.

Signed-off-by: cpw <cpw+github@weeksfamily.ca>
This commit is contained in:
cpw 2019-06-22 12:31:27 -04:00
parent 83a0dc2ef9
commit 256bd01e0c
No known key found for this signature in database
GPG Key ID: 8EB3DF749553B1B7
6 changed files with 17 additions and 5 deletions

View File

@ -358,7 +358,7 @@ project(':forge') {
installer 'cpw.mods:modlauncher:2.1.+' installer 'cpw.mods:modlauncher:2.1.+'
installer 'cpw.mods:grossjava9hacks:1.1.+' installer 'cpw.mods:grossjava9hacks:1.1.+'
installer 'net.minecraftforge:accesstransformers:0.16.+:shadowed' installer 'net.minecraftforge:accesstransformers:0.16.+:shadowed'
installer 'net.minecraftforge:eventbus:0.9.+:service' installer 'net.minecraftforge:eventbus:0.10.+:service'
installer 'net.minecraftforge:forgespi:0.13.+' installer 'net.minecraftforge:forgespi:0.13.+'
installer 'net.minecraftforge:coremods:0.5.+' installer 'net.minecraftforge:coremods:0.5.+'
installer 'net.minecraftforge:unsafe:0.2.+' installer 'net.minecraftforge:unsafe:0.2.+'

View File

@ -38,7 +38,7 @@ public class MinecraftForge
* ORE_GEN_BUS for ore gen events * ORE_GEN_BUS for ore gen events
* EVENT_BUS for everything else * EVENT_BUS for everything else
*/ */
public static final IEventBus EVENT_BUS = BusBuilder.builder().build(); public static final IEventBus EVENT_BUS = BusBuilder.builder().startShutdown().build();
static final ForgeInternalHandler INTERNAL_HANDLER = new ForgeInternalHandler(); static final ForgeInternalHandler INTERNAL_HANDLER = new ForgeInternalHandler();
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogManager.getLogger();

View File

@ -40,6 +40,7 @@ import java.util.function.BiConsumer;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
import static net.minecraftforge.fml.Logging.LOADING; import static net.minecraftforge.fml.Logging.LOADING;
@ -187,4 +188,8 @@ public class ModList
public void forEachModContainer(BiConsumer<String, ModContainer> modContainerConsumer) { public void forEachModContainer(BiConsumer<String, ModContainer> modContainerConsumer) {
indexedMods.forEach(modContainerConsumer); indexedMods.forEach(modContainerConsumer);
} }
public <T> Stream<T> applyForEachModContainer(Function<ModContainer, T> function) {
return indexedMods.values().stream().map(function);
}
} }

View File

@ -61,9 +61,7 @@ public class ClientModLoader
try { try {
ModLoader.get().gatherAndInitializeMods(); ModLoader.get().gatherAndInitializeMods();
} catch (LoadingFailedException e) { } catch (LoadingFailedException e) {
MinecraftForge.EVENT_BUS.shutdown();
error = e; error = e;
TEMP_printLoadingExceptions(e);
} }
ResourcePackLoader.loadResourcePacks(defaultResourcePacks); ResourcePackLoader.loadResourcePacks(defaultResourcePacks);
mcResourceManager.addReloadListener(ClientModLoader::onreload); mcResourceManager.addReloadListener(ClientModLoader::onreload);
@ -126,6 +124,10 @@ public class ClientModLoader
} else { } else {
ClientHooks.logMissingTextureErrors(); ClientHooks.logMissingTextureErrors();
} }
if (error != null) {
// We can finally start the forge eventbus up
MinecraftForge.EVENT_BUS.start();
}
} }
public static boolean isLoading() public static boolean isLoading()

View File

@ -20,6 +20,7 @@
package net.minecraftforge.fml.server; package net.minecraftforge.fml.server;
import net.minecraft.server.dedicated.DedicatedServer; import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.LogicalSidedProvider; import net.minecraftforge.fml.LogicalSidedProvider;
import net.minecraftforge.fml.ModLoader; import net.minecraftforge.fml.ModLoader;
import net.minecraftforge.fml.ModLoadingWarning; import net.minecraftforge.fml.ModLoadingWarning;
@ -41,6 +42,7 @@ public class ServerModLoader
SidedProvider.setServer(()->dedicatedServer); SidedProvider.setServer(()->dedicatedServer);
LogicalSidedProvider.setServer(()->dedicatedServer); LogicalSidedProvider.setServer(()->dedicatedServer);
LanguageHook.loadForgeAndMCLangs(); LanguageHook.loadForgeAndMCLangs();
ModLoader.get().gatherAndInitializeMods();
ModLoader.get().loadMods(); ModLoader.get().loadMods();
} }
@ -51,6 +53,7 @@ public class ServerModLoader
LOGGER.warn(LOADING, "Mods loaded with {} warnings", warnings.size()); LOGGER.warn(LOADING, "Mods loaded with {} warnings", warnings.size());
warnings.forEach(warning -> LOGGER.warn(LOADING, warning.formatToString())); warnings.forEach(warning -> LOGGER.warn(LOADING, warning.formatToString()));
} }
MinecraftForge.EVENT_BUS.start();
server.getServerStatusResponse().setForgeData(new FMLStatusPing()); //gathers NetworkRegistry data server.getServerStatusResponse().setForgeData(new FMLStatusPing()); //gathers NetworkRegistry data
} }
} }

View File

@ -35,7 +35,9 @@ public class CommandModList {
.requires(cs->cs.hasPermissionLevel(0)) //permission .requires(cs->cs.hasPermissionLevel(0)) //permission
.executes(ctx -> { .executes(ctx -> {
ctx.getSource().sendFeedback(new TranslationTextComponent("commands.forge.mods.list", ctx.getSource().sendFeedback(new TranslationTextComponent("commands.forge.mods.list",
ModList.get().getMods().stream().map(ModInfo::getModId).collect(Collectors.joining(","))), ModList.get().applyForEachModContainer(
mc->String.format("%s:%s(%s)", mc.getModId(), mc.getModInfo().getVersion().toString(), mc.getCurrentState())).
collect(Collectors.joining(","))),
true); true);
return 0; return 0;
} }