Search in sources :

Example 1 with FabricLoader

use of net.fabricmc.loader.api.FabricLoader in project UniversalGraves by Patbox.

the class GravesMod method onInitialize.

@Override
public void onInitialize() {
    this.crabboardDetection();
    FabricLoader loader = FabricLoader.getInstance();
    Registry.register(Registry.BLOCK, new Identifier("universal_graves", "grave"), GraveBlock.INSTANCE);
    GraveBlockEntity.BLOCK_ENTITY_TYPE = Registry.register(Registry.BLOCK_ENTITY_TYPE, "universal_graves:grave", FabricBlockEntityTypeBuilder.create(GraveBlockEntity::new, GraveBlock.INSTANCE).build(null));
    Commands.register();
    BlockHelper.registerVirtualBlockEntity(GraveBlockEntity.BLOCK_ENTITY_TYPE);
    if (loader.isModLoaded("trinkets")) {
        TrinketsCompat.register();
    }
    if (loader.isModLoaded("goml")) {
        GomlCompat.register();
    }
    if (loader.isModLoaded("inventorio")) {
        InventorioCompat.register();
    }
    ServerLifecycleEvents.SERVER_STARTING.register((server) -> ConfigManager.loadConfig());
    ServerLifecycleEvents.SERVER_STARTED.register(server -> {
        this.crabboardDetection();
        GraveManager.INSTANCE = (GraveManager) server.getOverworld().getPersistentStateManager().getOrCreate(GraveManager::fromNbt, GraveManager::new, "universal-graves");
    });
    ServerTickEvents.END_SERVER_TICK.register(s -> {
        var copied = new ArrayList<>(DO_ON_NEXT_TICK);
        DO_ON_NEXT_TICK.clear();
        for (var c : copied) {
            c.run();
        }
    });
}
Also used : Identifier(net.minecraft.util.Identifier) FabricLoader(net.fabricmc.loader.api.FabricLoader) ArrayList(java.util.ArrayList) GraveManager(eu.pb4.graves.grave.GraveManager)

Example 2 with FabricLoader

use of net.fabricmc.loader.api.FabricLoader in project pollen by MoonflowerTeam.

the class PollenFabricMixinPlugin method onLoad.

@Override
public void onLoad(String mixinPackage) {
    FabricLoader loader = FabricLoader.getInstance();
    this.sodiumLoaded = loader.isModLoaded("sodium");
    this.irisLoaded = loader.isModLoaded("iris");
}
Also used : FabricLoader(net.fabricmc.loader.api.FabricLoader)

Example 3 with FabricLoader

use of net.fabricmc.loader.api.FabricLoader in project frame-fabric by moddingplayground.

the class DataMain method main.

public static void main(String[] strings) throws IOException {
    OptionParser opts = new OptionParser();
    OptionSpec<Void> help = opts.accepts("help", "Show the help menu").forHelp();
    OptionSpec<Void> server = opts.accepts("server", "Include server generators");
    OptionSpec<Void> client = opts.accepts("client", "Include client generators");
    OptionSpec<Void> dev = opts.accepts("dev", "Include development tools");
    OptionSpec<Void> reports = opts.accepts("reports", "Include data reports");
    OptionSpec<Void> validate = opts.accepts("validate", "Validate inputs");
    OptionSpec<Void> all = opts.accepts("all", "Include all generators");
    OptionSpec<String> output = opts.accepts("output", "Output folder").withRequiredArg().defaultsTo("generated");
    OptionSpec<String> extra = opts.accepts("extra", "Additional output folder to copy assets to").withRequiredArg();
    OptionSpec<String> input = opts.accepts("input", "Input folder").withRequiredArg();
    OptionSet optionSet = opts.parse(strings);
    if (!optionSet.has(help) && optionSet.hasOptions()) {
        Path path = Paths.get(output.value(optionSet));
        boolean genAll = optionSet.has(all);
        boolean genClient = genAll || optionSet.has(client);
        boolean genServer = genAll || optionSet.has(server);
        boolean genDev = genAll || optionSet.has(dev);
        boolean genReports = genAll || optionSet.has(reports);
        boolean genValidate = genAll || optionSet.has(validate);
        FabricLoader loader = FabricLoader.getInstance();
        List<EntrypointContainer<ToymakerEntrypoint>> initializers = loader.getEntrypointContainers("toymaker", ToymakerEntrypoint.class);
        if (initializers.isEmpty()) {
            LOGGER.error("No data generators were initialized!");
        } else {
            for (EntrypointContainer<ToymakerEntrypoint> initializer : initializers) {
                ModMetadata meta = initializer.getProvider().getMetadata();
                if (TARGET_MOD_ID != null && !meta.getId().equals(TARGET_MOD_ID))
                    continue;
                LOGGER.info("Initializing data generator for " + meta.getId());
                initializer.getEntrypoint().onInitializeToymaker();
            }
        }
        DataGenerator gen = create(path, optionSet.valuesOf(input).stream().map(Paths::get).collect(Collectors.toList()), genClient, genServer, genDev, genReports, genValidate);
        DataGenAccess access = (DataGenAccess) gen;
        access.run(config -> optionSet.valuesOf(extra).stream().map(Paths::get).forEach(config::addCopyPath));
    } else {
        opts.printHelpOn(System.out);
    }
}
Also used : Path(java.nio.file.Path) FabricLoader(net.fabricmc.loader.api.FabricLoader) OptionParser(joptsimple.OptionParser) EntrypointContainer(net.fabricmc.loader.api.entrypoint.EntrypointContainer) ModMetadata(net.fabricmc.loader.api.metadata.ModMetadata) DataGenerator(net.minecraft.data.DataGenerator) Paths(java.nio.file.Paths) OptionSet(joptsimple.OptionSet) ToymakerEntrypoint(net.moddingplayground.frame.api.toymaker.v0.ToymakerEntrypoint)

Example 4 with FabricLoader

use of net.fabricmc.loader.api.FabricLoader in project spark by lucko.

the class FabricSparkMod method onInitialize.

@Override
public void onInitialize() {
    FabricSparkMod.mod = this;
    FabricLoader loader = FabricLoader.getInstance();
    this.container = loader.getModContainer("spark").orElseThrow(() -> new IllegalStateException("Unable to get container for spark"));
    this.configDirectory = loader.getConfigDir().resolve("spark");
    // lifecycle hooks
    ServerLifecycleEvents.SERVER_STARTING.register(this::initializeServer);
    ServerLifecycleEvents.SERVER_STOPPING.register(this::onServerStopping);
    // events to propagate to active server plugin
    CommandRegistrationCallback.EVENT.register(this::onCommandRegister);
}
Also used : FabricLoader(net.fabricmc.loader.api.FabricLoader)

Aggregations

FabricLoader (net.fabricmc.loader.api.FabricLoader)4 GraveManager (eu.pb4.graves.grave.GraveManager)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 ArrayList (java.util.ArrayList)1 OptionParser (joptsimple.OptionParser)1 OptionSet (joptsimple.OptionSet)1 EntrypointContainer (net.fabricmc.loader.api.entrypoint.EntrypointContainer)1 ModMetadata (net.fabricmc.loader.api.metadata.ModMetadata)1 DataGenerator (net.minecraft.data.DataGenerator)1 Identifier (net.minecraft.util.Identifier)1 ToymakerEntrypoint (net.moddingplayground.frame.api.toymaker.v0.ToymakerEntrypoint)1