| 1 | package net.minecraft.client.data;
|
| 2 |
|
| 3 | import java.io.IOException;
|
| 4 | import java.nio.file.Path;
|
| 5 | import java.nio.file.Paths;
|
| 6 | import joptsimple.OptionParser;
|
| 7 | import joptsimple.OptionSet;
|
| 8 | import joptsimple.OptionSpec;
|
| 9 | import net.fabricmc.api.EnvType;
|
| 10 | import net.fabricmc.api.Environment;
|
| 11 | import net.minecraft.SharedConstants;
|
| 12 | import net.minecraft.SuppressForbidden;
|
| 13 | import net.minecraft.client.ClientBootstrap;
|
| 14 | import net.minecraft.client.data.models.EquipmentAssetProvider;
|
| 15 | import net.minecraft.client.data.models.ModelProvider;
|
| 16 | import net.minecraft.client.data.models.WaypointStyleProvider;
|
| 17 | import net.minecraft.data.DataGenerator;
|
| 18 | import net.minecraft.data.DataGenerator.Cached;
|
| 19 | import net.minecraft.data.DataGenerator.PackGenerator;
|
| 20 | import net.minecraft.server.Bootstrap;
|
| 21 | import net.minecraft.util.Util;
|
| 22 |
|
| 23 | @Environment(EnvType.CLIENT)
|
| 24 | public class Main {
|
| 25 | @SuppressForbidden(reason = "System.out needed before bootstrap")
|
| 26 | public static void main(final String[] args) throws IOException {
|
| 27 | SharedConstants.tryDetectVersion();
|
| 28 | OptionParser parser = new OptionParser();
|
| 29 | OptionSpec<Void> helpOption = parser.accepts("help", "Show the help menu").forHelp();
|
| 30 | OptionSpec<Void> clientOption = parser.accepts("client", "Include client generators");
|
| 31 | OptionSpec<Void> allOption = parser.accepts("all", "Include all generators");
|
| 32 | OptionSpec<String> outputOption = parser.accepts("output", "Output folder").withRequiredArg().defaultsTo("generated");
|
| 33 | OptionSet optionSet = parser.parse(args);
|
| 34 | if (!optionSet.has(helpOption) && optionSet.hasOptions()) {
|
| 35 | Path output = Paths.get(outputOption.value(optionSet));
|
| 36 | boolean allOptions = optionSet.has(allOption);
|
| 37 | boolean client = allOptions || optionSet.has(clientOption);
|
| 38 | Bootstrap.bootStrap();
|
| 39 | ClientBootstrap.bootstrap();
|
| 40 | DataGenerator generator = new Cached(output, SharedConstants.getCurrentVersion(), true);
|
| 41 | addClientProviders(generator, client);
|
| 42 | generator.run();
|
| 43 | Util.shutdownExecutors();
|
| 44 | } else {
|
| 45 | parser.printHelpOn(System.out);
|
| 46 | }
|
| 47 | }
|
| 48 |
|
| 49 | public static void addClientProviders(final DataGenerator generator, final boolean client) {
|
| 50 | PackGenerator clientVanillaPack = generator.getVanillaPack(client);
|
| 51 | clientVanillaPack.addProvider(ModelProvider::new);
|
| 52 | clientVanillaPack.addProvider(EquipmentAssetProvider::new);
|
| 53 | clientVanillaPack.addProvider(WaypointStyleProvider::new);
|
| 54 | clientVanillaPack.addProvider(AtlasProvider::new);
|
| 55 | }
|
| 56 | }
|
| 57 |
|