1+ /*
2+ * MIT License
3+ *
4+ * Copyright (c) 2018-2020 Prospector
5+ *
6+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7+ * of this software and associated documentation files (the "Software"), to deal
8+ * in the Software without restriction, including without limitation the rights
9+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ * copies of the Software, and to permit persons to whom the Software is
11+ * furnished to do so, subject to the following conditions:
12+ *
13+ * The above copyright notice and this permission notice shall be included in all
14+ * copies or substantial portions of the Software.
15+ *
16+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+ * SOFTWARE.
23+ */
24+ package com .terraformersmc .modmenu .api ;
25+
26+ import com .google .common .collect .ImmutableMap ;
27+ import net .minecraft .client .gui .screens .Screen ;
28+ import net .minecraft .network .chat .CommonComponents ;
29+ import net .minecraft .network .chat .Component ;
30+ import net .minecraftforge .client .gui .ModListScreen ;
31+
32+ import java .util .Map ;
33+ import java .util .function .Consumer ;
34+
35+ public interface ModMenuApi {
36+
37+ /**
38+ * Used for creating a {@link Screen} instance of the Mod Menu
39+ * "Mods" screen
40+ *
41+ * @param previous The screen before opening
42+ * @return A "Mods" Screen
43+ */
44+ static Screen createModsScreen (Screen previous ) {
45+ return new ModListScreen (previous );
46+ }
47+
48+ /**
49+ * Used for creating a {@link Component} just like what would appear
50+ * on a Mod Menu Mods button
51+ *
52+ * @return The text that would be displayed on a Mods button
53+ */
54+ static Component createModsButtonText () {
55+ return CommonComponents .EMPTY ;
56+ }
57+
58+ /**
59+ * Used to construct a new config screen instance when your mod's
60+ * configuration button is selected on the mod menu screen. The
61+ * screen instance parameter is the active mod menu screen.
62+ *
63+ * @return A factory for constructing config screen instances.
64+ */
65+ default ConfigScreenFactory <?> getModConfigScreenFactory () {
66+ return screen -> null ;
67+ }
68+
69+ /**
70+ * Used to provide config screen factories for other mods. This takes second
71+ * priority to a mod's own config screen factory provider. For example, if
72+ * mod `xyz` supplies a config screen factory, mod `abc` providing a config
73+ * screen to `xyz` will be pointless, as the one provided by `xyz` will be
74+ * used.
75+ * <p>
76+ * This method is NOT meant to be used to add a config screen factory to
77+ * your own mod.
78+ *
79+ * @return a map of mod ids to screen factories.
80+ */
81+ default Map <String , ConfigScreenFactory <?>> getProvidedConfigScreenFactories () {
82+ return ImmutableMap .of ();
83+ }
84+
85+ /**
86+ * Used to mark mods with a badge indicating that they are
87+ * provided by a modpack.
88+ * <p>
89+ * Builtin mods such as `minecraft` cannot be marked as
90+ * provided by a modpack.
91+ */
92+ default void attachModpackBadges (Consumer <String > consumer ) {
93+
94+ }
95+ }
0 commit comments