Modify lex's data handler to use proper mod lifecycle event mechanisms
instead. New Lifecycle Event for requesting data harvesting. Mods will be constructed, the registry will fire, and then a new Data event will fire. Submit new data tag files to the data gatherer if you wish. The game will shutdown after this. No other mod elements will happen. Signed-off-by: cpw <cpw+github@weeksfamily.ca>
This commit is contained in:
parent
37a896fe1b
commit
d821514372
8 changed files with 147 additions and 83 deletions
|
@ -7,21 +7,19 @@
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
@@ -21,8 +22,12 @@
|
@@ -21,8 +22,10 @@
|
||||||
OptionSpec<Void> optionspec6 = optionparser.accepts("all", "Include all generators");
|
OptionSpec<Void> optionspec6 = optionparser.accepts("all", "Include all generators");
|
||||||
OptionSpec<String> optionspec7 = optionparser.accepts("output", "Output folder").withRequiredArg().defaultsTo("generated");
|
OptionSpec<String> optionspec7 = optionparser.accepts("output", "Output folder").withRequiredArg().defaultsTo("generated");
|
||||||
OptionSpec<String> optionspec8 = optionparser.accepts("input", "Input folder").withRequiredArg();
|
OptionSpec<String> optionspec8 = optionparser.accepts("input", "Input folder").withRequiredArg();
|
||||||
+ OptionSpec<File> gameDir = optionparser.accepts("gameDir").withRequiredArg().ofType(File.class).defaultsTo(new File("."));
|
+ OptionSpec<File> gameDir = optionparser.accepts("gameDir").withRequiredArg().ofType(File.class).defaultsTo(new File(".")).required();
|
||||||
+ OptionSpec<String> mod = optionparser.accepts("mod", "The mod to dump").withRequiredArg();
|
+ OptionSpec<String> mod = optionparser.accepts("mod", "A modid to dump").withRequiredArg().withValuesSeparatedBy(",");
|
||||||
+ net.minecraft.util.registry.Bootstrap.func_151354_b();
|
|
||||||
+ net.minecraftforge.fml.ModLoader.get().loadMods();
|
|
||||||
OptionSet optionset = optionparser.parse(p_main_0_);
|
OptionSet optionset = optionparser.parse(p_main_0_);
|
||||||
- if (!optionset.has(optionspec) && optionset.hasOptions()) {
|
- if (!optionset.has(optionspec) && optionset.hasOptions()) {
|
||||||
+ if (!optionset.has(optionspec) && optionset.hasOptions() && !(optionset.specs().size() == 1 && optionset.has(gameDir))) {
|
+ if (!optionset.has(optionspec) && optionset.hasOptions() && !(optionset.specs().size() == 1 && optionset.has(gameDir))) {
|
||||||
Path path = Paths.get(optionspec7.value(optionset));
|
Path path = Paths.get(optionspec7.value(optionset));
|
||||||
boolean flag = optionset.has(optionspec6);
|
boolean flag = optionset.has(optionspec6);
|
||||||
boolean flag1 = flag || optionset.has(optionspec2);
|
boolean flag1 = flag || optionset.has(optionspec2);
|
||||||
@@ -30,10 +35,23 @@
|
@@ -30,10 +33,11 @@
|
||||||
boolean flag3 = flag || optionset.has(optionspec3);
|
boolean flag3 = flag || optionset.has(optionspec3);
|
||||||
boolean flag4 = flag || optionset.has(optionspec4);
|
boolean flag4 = flag || optionset.has(optionspec4);
|
||||||
boolean flag5 = flag || optionset.has(optionspec5);
|
boolean flag5 = flag || optionset.has(optionspec5);
|
||||||
|
@ -30,20 +28,8 @@
|
||||||
- }).collect(Collectors.toList()), flag1, flag2, flag3, flag4, flag5);
|
- }).collect(Collectors.toList()), flag1, flag2, flag3, flag4, flag5);
|
||||||
- datagenerator.func_200392_c();
|
- datagenerator.func_200392_c();
|
||||||
+ Collection<Path> inputs = optionset.valuesOf(optionspec8).stream().map(Paths::get).collect(Collectors.toList());
|
+ Collection<Path> inputs = optionset.valuesOf(optionspec8).stream().map(Paths::get).collect(Collectors.toList());
|
||||||
+ java.util.Set<String> mods = optionset.valuesOf(mod).stream().collect(Collectors.toSet());
|
+ java.util.Set<String> mods = new java.util.HashSet<>(optionset.valuesOf(mod));
|
||||||
+ net.minecraftforge.fml.ModList.get().forEachModContainer((modid, mc) -> {
|
+ net.minecraftforge.fml.ModLoader.get().runDataGenerator(mods, path, inputs, flag2, flag1, flag3, flag4, flag5);
|
||||||
+ try {
|
|
||||||
+ //We have to go to the subclass, as ModContainer doesn't have the event bus.
|
|
||||||
+ if (mods.contains(modid) && mc instanceof net.minecraftforge.fml.javafmlmod.FMLModContainer) {
|
|
||||||
+ DataGenerator gen = new DataGenerator(mods.size() == 1 ? path : path.resolve(modid), inputs);
|
|
||||||
+ ((net.minecraftforge.fml.javafmlmod.FMLModContainer)mc).getEventBus().post(new net.minecraftforge.event.GatherDataEvent(gen, flag2, flag1, flag3, flag4, flag5));
|
|
||||||
+ gen.func_200392_c();
|
|
||||||
+ }
|
|
||||||
+ } catch (IOException e) {
|
|
||||||
+ e.printStackTrace();
|
|
||||||
+ }
|
|
||||||
+ });
|
|
||||||
+
|
|
||||||
+ if (mods.contains("minecraft") || mods.isEmpty())
|
+ if (mods.contains("minecraft") || mods.isEmpty())
|
||||||
+ func_200264_a(mods.isEmpty() ? path : path.resolve("minecraft"), inputs, flag1, flag2, flag3, flag4, flag5).func_200392_c();
|
+ func_200264_a(mods.isEmpty() ? path : path.resolve("minecraft"), inputs, flag1, flag2, flag3, flag4, flag5).func_200392_c();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -54,7 +54,7 @@ import net.minecraftforge.common.data.ForgeBlockTagsProvider;
|
||||||
import net.minecraftforge.common.data.ForgeItemTagsProvider;
|
import net.minecraftforge.common.data.ForgeItemTagsProvider;
|
||||||
import net.minecraftforge.common.model.animation.CapabilityAnimation;
|
import net.minecraftforge.common.model.animation.CapabilityAnimation;
|
||||||
import net.minecraftforge.energy.CapabilityEnergy;
|
import net.minecraftforge.energy.CapabilityEnergy;
|
||||||
import net.minecraftforge.event.GatherDataEvent;
|
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent;
|
||||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
import net.minecraftforge.resource.ISelectiveResourceReloadListener;
|
import net.minecraftforge.resource.ISelectiveResourceReloadListener;
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2019.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.event;
|
|
||||||
|
|
||||||
import net.minecraft.data.DataGenerator;
|
|
||||||
import net.minecraftforge.eventbus.api.Event;
|
|
||||||
|
|
||||||
public class GatherDataEvent extends Event
|
|
||||||
{
|
|
||||||
private final DataGenerator generator;
|
|
||||||
private final boolean server;
|
|
||||||
private final boolean client;
|
|
||||||
private final boolean dev;
|
|
||||||
private final boolean reports;
|
|
||||||
private final boolean validate;
|
|
||||||
|
|
||||||
public GatherDataEvent(DataGenerator gen, boolean server, boolean client, boolean dev, boolean reports, boolean validate)
|
|
||||||
{
|
|
||||||
this.generator = gen;
|
|
||||||
this.server = server;
|
|
||||||
this.client = client;
|
|
||||||
this.dev = dev;
|
|
||||||
this.reports = reports;
|
|
||||||
this.validate = validate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DataGenerator getGenerator() { return this.generator; }
|
|
||||||
public boolean includeServer() { return this.server; }
|
|
||||||
public boolean includeClient() { return this.client; }
|
|
||||||
public boolean includeDev() { return this.dev; }
|
|
||||||
public boolean includeReports() { return this.reports; }
|
|
||||||
public boolean validate() { return this.validate; }
|
|
||||||
}
|
|
|
@ -37,7 +37,8 @@ public enum LifecycleEventProvider
|
||||||
SIDED_SETUP(()->new LifecycleEvent(ModLoadingStage.SIDED_SETUP)),
|
SIDED_SETUP(()->new LifecycleEvent(ModLoadingStage.SIDED_SETUP)),
|
||||||
ENQUEUE_IMC(()->new LifecycleEvent(ModLoadingStage.ENQUEUE_IMC)),
|
ENQUEUE_IMC(()->new LifecycleEvent(ModLoadingStage.ENQUEUE_IMC)),
|
||||||
PROCESS_IMC(()->new LifecycleEvent(ModLoadingStage.PROCESS_IMC)),
|
PROCESS_IMC(()->new LifecycleEvent(ModLoadingStage.PROCESS_IMC)),
|
||||||
COMPLETE(()->new LifecycleEvent(ModLoadingStage.COMPLETE));
|
COMPLETE(()->new LifecycleEvent(ModLoadingStage.COMPLETE)),
|
||||||
|
GATHERDATA(()->new GatherDataLifecycleEvent(ModLoadingStage.GATHERDATA), ModList.inlineDispatcher);
|
||||||
|
|
||||||
private final Supplier<? extends LifecycleEvent> event;
|
private final Supplier<? extends LifecycleEvent> event;
|
||||||
private final BiConsumer<LifecycleEvent, Consumer<List<ModLoadingException>>> eventDispatcher;
|
private final BiConsumer<LifecycleEvent, Consumer<List<ModLoadingException>>> eventDispatcher;
|
||||||
|
@ -130,4 +131,20 @@ public enum LifecycleEventProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class GatherDataLifecycleEvent extends LifecycleEvent {
|
||||||
|
GatherDataLifecycleEvent(final ModLoadingStage stage) {
|
||||||
|
super(stage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ModLoadingStage fromStage() {
|
||||||
|
return ModLoadingStage.COMMON_SETUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ModLoadingStage toStage() {
|
||||||
|
return ModLoadingStage.DONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,12 +21,16 @@ package net.minecraftforge.fml;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import cpw.mods.modlauncher.TransformingClassLoader;
|
import cpw.mods.modlauncher.TransformingClassLoader;
|
||||||
|
import net.minecraft.data.DataGenerator;
|
||||||
|
import net.minecraft.util.registry.Bootstrap;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||||
import net.minecraftforge.fml.config.ConfigTracker;
|
import net.minecraftforge.fml.config.ConfigTracker;
|
||||||
import net.minecraftforge.fml.config.ModConfig;
|
import net.minecraftforge.fml.config.ModConfig;
|
||||||
|
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent;
|
||||||
|
import net.minecraftforge.fml.event.lifecycle.ModLifecycleEvent;
|
||||||
import net.minecraftforge.fml.loading.FMLLoader;
|
import net.minecraftforge.fml.loading.FMLLoader;
|
||||||
import net.minecraftforge.fml.loading.FMLPaths;
|
import net.minecraftforge.fml.loading.FMLPaths;
|
||||||
import net.minecraftforge.fml.loading.LoadingModList;
|
import net.minecraftforge.fml.loading.LoadingModList;
|
||||||
|
@ -41,11 +45,9 @@ import net.minecraftforge.registries.ObjectHolderRegistry;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -97,6 +99,8 @@ public class ModLoader
|
||||||
|
|
||||||
private final List<ModLoadingException> loadingExceptions;
|
private final List<ModLoadingException> loadingExceptions;
|
||||||
private final List<ModLoadingWarning> loadingWarnings;
|
private final List<ModLoadingWarning> loadingWarnings;
|
||||||
|
private GatherDataEvent.DataGeneratorConfig dataGeneratorConfig;
|
||||||
|
|
||||||
private ModLoader()
|
private ModLoader()
|
||||||
{
|
{
|
||||||
INSTANCE = this;
|
INSTANCE = this;
|
||||||
|
@ -120,6 +124,15 @@ public class ModLoader
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadMods() {
|
public void loadMods() {
|
||||||
|
gatherAndInitializeMods();
|
||||||
|
DistExecutor.runWhenOn(Dist.CLIENT, ()->()-> ConfigTracker.INSTANCE.loadConfigs(ModConfig.Type.CLIENT, FMLPaths.CONFIGDIR.get()));
|
||||||
|
ConfigTracker.INSTANCE.loadConfigs(ModConfig.Type.COMMON, FMLPaths.CONFIGDIR.get());
|
||||||
|
dispatchAndHandleError(LifecycleEventProvider.SETUP);
|
||||||
|
DistExecutor.runWhenOn(Dist.CLIENT, ModLoader::fireClientEvents);
|
||||||
|
dispatchAndHandleError(LifecycleEventProvider.SIDED_SETUP);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void gatherAndInitializeMods() {
|
||||||
final ModList modList = ModList.of(loadingModList.getModFiles().stream().map(ModFileInfo::getFile).collect(Collectors.toList()), loadingModList.getMods());
|
final ModList modList = ModList.of(loadingModList.getModFiles().stream().map(ModFileInfo::getFile).collect(Collectors.toList()), loadingModList.getMods());
|
||||||
if (!this.loadingExceptions.isEmpty()) {
|
if (!this.loadingExceptions.isEmpty()) {
|
||||||
throw new LoadingFailedException(loadingExceptions);
|
throw new LoadingFailedException(loadingExceptions);
|
||||||
|
@ -139,11 +152,6 @@ public class ModLoader
|
||||||
ObjectHolderRegistry.findObjectHolders();
|
ObjectHolderRegistry.findObjectHolders();
|
||||||
CapabilityManager.INSTANCE.injectCapabilities(modList.getAllScanData());
|
CapabilityManager.INSTANCE.injectCapabilities(modList.getAllScanData());
|
||||||
GameData.fireRegistryEvents(rl->true, LifecycleEventProvider.LOAD_REGISTRIES, this::dispatchAndHandleError);
|
GameData.fireRegistryEvents(rl->true, LifecycleEventProvider.LOAD_REGISTRIES, this::dispatchAndHandleError);
|
||||||
DistExecutor.runWhenOn(Dist.CLIENT, ()->()-> ConfigTracker.INSTANCE.loadConfigs(ModConfig.Type.CLIENT, FMLPaths.CONFIGDIR.get()));
|
|
||||||
ConfigTracker.INSTANCE.loadConfigs(ModConfig.Type.COMMON, FMLPaths.CONFIGDIR.get());
|
|
||||||
dispatchAndHandleError(LifecycleEventProvider.SETUP);
|
|
||||||
DistExecutor.runWhenOn(Dist.CLIENT, ModLoader::fireClientEvents);
|
|
||||||
dispatchAndHandleError(LifecycleEventProvider.SIDED_SETUP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dispatchAndHandleError(LifecycleEventProvider event) {
|
private void dispatchAndHandleError(LifecycleEventProvider event) {
|
||||||
|
@ -211,4 +219,18 @@ public class ModLoader
|
||||||
{
|
{
|
||||||
this.loadingWarnings.add(warning);
|
this.loadingWarnings.add(warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void runDataGenerator(final Set<String> mods, final Path path, final Collection<Path> inputs, final boolean serverGenerators, final boolean clientGenerators, final boolean devToolGenerators, final boolean reportsGenerator, final boolean structureValidator) {
|
||||||
|
if (mods.contains("minecraft") && mods.size() == 1) return;
|
||||||
|
LOGGER.info("Initializing Data Gatherer for mods {}", mods);
|
||||||
|
Bootstrap.register();
|
||||||
|
dataGeneratorConfig = new GatherDataEvent.DataGeneratorConfig(mods, path, inputs, serverGenerators, clientGenerators, devToolGenerators, reportsGenerator, structureValidator);
|
||||||
|
gatherAndInitializeMods();
|
||||||
|
dispatchAndHandleError(LifecycleEventProvider.GATHERDATA);
|
||||||
|
dataGeneratorConfig.runAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Function<ModContainer, ModLifecycleEvent> getDataGeneratorEvent() {
|
||||||
|
return mc -> new GatherDataEvent(mc, dataGeneratorConfig.makeGenerator(p->dataGeneratorConfig.getMods().size() == 1 ? p : p.resolve(mc.getModId())), dataGeneratorConfig);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,8 @@ public enum ModLoadingStage
|
||||||
ENQUEUE_IMC(()-> InterModEnqueueEvent::new),
|
ENQUEUE_IMC(()-> InterModEnqueueEvent::new),
|
||||||
PROCESS_IMC(()-> InterModProcessEvent::new),
|
PROCESS_IMC(()-> InterModProcessEvent::new),
|
||||||
COMPLETE(()-> FMLLoadCompleteEvent::new),
|
COMPLETE(()-> FMLLoadCompleteEvent::new),
|
||||||
DONE(null);
|
DONE(null),
|
||||||
|
GATHERDATA(ModLoader.get()::getDataGeneratorEvent);
|
||||||
private final Supplier<Function<ModContainer, ModLifecycleEvent>> modLifecycleEventFunction;
|
private final Supplier<Function<ModContainer, ModLifecycleEvent>> modLifecycleEventFunction;
|
||||||
|
|
||||||
ModLoadingStage(Supplier<Function<ModContainer, ModLifecycleEvent>> modLifecycleEventFunction)
|
ModLoadingStage(Supplier<Function<ModContainer, ModLifecycleEvent>> modLifecycleEventFunction)
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2019.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.event.lifecycle;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
|
||||||
|
import net.minecraft.data.DataGenerator;
|
||||||
|
import net.minecraftforge.fml.ModContainer;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class GatherDataEvent extends ModLifecycleEvent
|
||||||
|
{
|
||||||
|
private final DataGenerator dataGenerator;
|
||||||
|
private final DataGeneratorConfig config;
|
||||||
|
public GatherDataEvent(final ModContainer modContainer, final DataGenerator dataGenerator, final DataGeneratorConfig dataGeneratorConfig)
|
||||||
|
{
|
||||||
|
super(modContainer);
|
||||||
|
this.dataGenerator = dataGenerator;
|
||||||
|
this.config = dataGeneratorConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataGenerator getGenerator() { return this.dataGenerator; }
|
||||||
|
public boolean includeServer() { return this.config.server; }
|
||||||
|
public boolean includeClient() { return this.config.client; }
|
||||||
|
public boolean includeDev() { return this.config.dev; }
|
||||||
|
public boolean includeReports() { return this.config.reports; }
|
||||||
|
public boolean validate() { return this.config.validate; }
|
||||||
|
|
||||||
|
public static class DataGeneratorConfig {
|
||||||
|
private final Set<String> mods;
|
||||||
|
private final Path path;
|
||||||
|
private final Collection<Path> inputs;
|
||||||
|
private final boolean server;
|
||||||
|
private final boolean client;
|
||||||
|
private final boolean dev;
|
||||||
|
private final boolean reports;
|
||||||
|
private final boolean validate;
|
||||||
|
private List<DataGenerator> generators = new ArrayList<>();
|
||||||
|
|
||||||
|
public DataGeneratorConfig(final Set<String> mods, final Path path, final Collection<Path> inputs, final boolean server, final boolean client, final boolean dev, final boolean reports, final boolean validate) {
|
||||||
|
this.mods = mods;
|
||||||
|
this.path = path;
|
||||||
|
this.inputs = inputs;
|
||||||
|
this.server = server;
|
||||||
|
this.client = client;
|
||||||
|
this.dev = dev;
|
||||||
|
this.reports = reports;
|
||||||
|
this.validate = validate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getMods() {
|
||||||
|
return mods;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataGenerator makeGenerator(final Function<Path,Path> pathEnhancer) {
|
||||||
|
final DataGenerator generator = new DataGenerator(pathEnhancer.apply(path), inputs);
|
||||||
|
generators.add(generator);
|
||||||
|
return generator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void runAll() {
|
||||||
|
generators.forEach(LamdbaExceptionUtils.rethrowConsumer(DataGenerator::run));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -61,6 +61,7 @@ public class FMLModContainer extends ModContainer
|
||||||
triggerMap.put(ModLoadingStage.ENQUEUE_IMC, dummy().andThen(this::beforeEvent).andThen(this::initMod).andThen(this::fireEvent).andThen(this::afterEvent));
|
triggerMap.put(ModLoadingStage.ENQUEUE_IMC, dummy().andThen(this::beforeEvent).andThen(this::initMod).andThen(this::fireEvent).andThen(this::afterEvent));
|
||||||
triggerMap.put(ModLoadingStage.PROCESS_IMC, dummy().andThen(this::beforeEvent).andThen(this::fireEvent).andThen(this::afterEvent));
|
triggerMap.put(ModLoadingStage.PROCESS_IMC, dummy().andThen(this::beforeEvent).andThen(this::fireEvent).andThen(this::afterEvent));
|
||||||
triggerMap.put(ModLoadingStage.COMPLETE, dummy().andThen(this::beforeEvent).andThen(this::completeLoading).andThen(this::fireEvent).andThen(this::afterEvent));
|
triggerMap.put(ModLoadingStage.COMPLETE, dummy().andThen(this::beforeEvent).andThen(this::completeLoading).andThen(this::fireEvent).andThen(this::afterEvent));
|
||||||
|
triggerMap.put(ModLoadingStage.GATHERDATA, dummy().andThen(this::beforeEvent).andThen(this::fireEvent).andThen(this::afterEvent));
|
||||||
this.eventBus = BusBuilder.builder().setExceptionHandler(this::onEventFailed).setTrackPhases(false).build();
|
this.eventBus = BusBuilder.builder().setExceptionHandler(this::onEventFailed).setTrackPhases(false).build();
|
||||||
this.configHandler = Optional.of(event -> this.eventBus.post(event));
|
this.configHandler = Optional.of(event -> this.eventBus.post(event));
|
||||||
final FMLJavaModLoadingContext contextExtension = new FMLJavaModLoadingContext(this);
|
final FMLJavaModLoadingContext contextExtension = new FMLJavaModLoadingContext(this);
|
||||||
|
|
Loading…
Reference in a new issue