Skip to content

Commit a549fe6

Browse files
committed
Updated to latest nightly (thanks to @bigsir24).
1 parent 5c3448f commit a549fe6

35 files changed

Lines changed: 3198 additions & 3349 deletions

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ base.archivesName = modName
1515
group = modGroup.get()
1616
version = modVersion.get()
1717
loom {
18-
customMinecraftMetadata.set("https://downloads.betterthanadventure.net/bta-client/${libs.versions.btaChannel.get()}/v${libs.versions.bta.get()}/manifest.json")
18+
customMinecraftMetadata.set("https://downloads.betterthanadventure.net/bta-client/${libs.versions.btaChannel.get()}/${libs.versions.bta.get()}/manifest.json")
1919
}
2020
repositories {
2121
mavenCentral()

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ org.gradle.warning.mode = all
88
org.gradle.configuration-cache = false
99
##########################################################################
1010
# Mod Properties
11-
mod_version = 4.0.0
11+
mod_version = 5.0.0-nightly
1212
mod_group = turniplabs
1313
mod_name = modmenu-bta
1414
##########################################################################

gradle/libs.versions.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ lwjglPlugin = "1.0.2"
88
##########################################################################
99
# Java Configuration
1010
# The Java version the JDK will be for compiling and running code.
11-
java = "8"
11+
java = "17"
1212
# The Java version the JDK will be for running Gradle.
1313
gradleJava = "21"
1414
##########################################################################
1515
# Mod Dependencies
1616
# Check this on https://downloads.betterthanadventure.net/bta-client/
17-
bta = "7.3_04"
17+
bta = "2026-04-03"
1818
# Options are release, prerelease, nightly, and misc.
19-
btaChannel = "release"
19+
btaChannel = "nightly"
2020
# Check this on https://maven.thesignalumproject.net/#/infrastructure/net/fabricmc/fabric-loader/
2121
loader = "0.18.4-bta.10"
2222
# Check this on https://github.com/Better-than-Adventure/legacy-lwjgl3/releases/latest/

src/main/java/io/github/prospector/modmenu/ModMenu.java

Lines changed: 93 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -18,124 +18,121 @@
1818
import net.minecraft.client.gui.Screen;
1919
import net.minecraft.client.gui.options.ScreenOptions;
2020
import net.minecraft.client.gui.options.data.OptionsPages;
21-
import org.jspecify.annotations.NonNull;
2221
import org.slf4j.Logger;
2322
import org.slf4j.LoggerFactory;
2423

2524
import java.text.NumberFormat;
2625
import java.util.*;
2726
import java.util.function.Function;
2827

29-
@SuppressWarnings("java:S2386")
3028
public class ModMenu implements ModInitializer {
31-
public static final String MOD_ID = "modmenu";
32-
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
33-
public static final Gson GSON = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).setPrettyPrinting().create();
29+
public static final String MOD_ID = "modmenu";
30+
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
31+
public static final Gson GSON = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).setPrettyPrinting().create();
3432

35-
private static final Map<String, Runnable> LEGACY_CONFIG_SCREEN_TASKS = new HashMap<>();
36-
public static final List<String> LIBRARY_MODS = new ArrayList<>();
37-
public static final Set<String> CLIENTSIDE_MODS = new HashSet<>();
33+
private static final Map<String, Runnable> LEGACY_CONFIG_SCREEN_TASKS = new HashMap<>();
34+
public static final List<String> LIBRARY_MODS = new ArrayList<>();
35+
public static final Set<String> CLIENTSIDE_MODS = new HashSet<>();
3836
public static final Set<String> DEPRECATED_MODS = new HashSet<>();
39-
public static final Set<String> PATCHWORK_FORGE_MODS = new HashSet<>();
37+
public static final Set<String> PATCHWORK_FORGE_MODS = new HashSet<>();
4038
public static final Map<String, Map<String, Map.Entry<Integer, Integer>>> CUSTOM_BADGE_MODS = new HashMap<>();
41-
public static final LinkedListMultimap<ModContainer, ModContainer> PARENT_MAP = LinkedListMultimap.create();
42-
private static ImmutableMap<@NonNull String, @NonNull Function<Screen, ? extends Screen>> configScreenFactories = ImmutableMap.of();
43-
44-
public static boolean hasConfigScreenFactory(String modid) {
45-
return configScreenFactories.containsKey(modid);
46-
}
47-
48-
public static Screen getConfigScreen(String modid, Screen menuScreen) {
49-
Function<Screen, ? extends Screen> factory = configScreenFactories.get(modid);
50-
return factory != null ? factory.apply(menuScreen) : null;
51-
}
52-
53-
public static void openConfigScreen(String modid) {
54-
Runnable opener = LEGACY_CONFIG_SCREEN_TASKS.get(modid);
55-
if (opener != null) opener.run();
56-
}
57-
58-
@SuppressWarnings("unused")
59-
public static void addLegacyConfigScreenTask(String modid, Runnable task) {
60-
LEGACY_CONFIG_SCREEN_TASKS.putIfAbsent(modid, task);
61-
}
62-
63-
public static boolean hasLegacyConfigScreenTask(String modid) {
64-
return LEGACY_CONFIG_SCREEN_TASKS.containsKey(modid);
65-
}
66-
67-
public static void addLibraryMod(String modid) {
68-
if (LIBRARY_MODS.contains(modid)) return;
69-
70-
LIBRARY_MODS.add(modid);
71-
}
72-
73-
@SuppressWarnings("RedundantCollectionOperation")
74-
@Override
75-
public void onInitialize() {
76-
ModMenuConfigManager.initializeConfig();
77-
ImmutableMap.Builder<@NonNull String, @NonNull Function<Screen, ? extends Screen>> factories = ImmutableMap.builder();
78-
FabricLoader.getInstance().getEntrypointContainers(MOD_ID, ModMenuApi.class).forEach(entrypoint -> {
79-
ModMenuApi api = entrypoint.getEntrypoint();
80-
ModContainer mod = entrypoint.getProvider();
39+
public static final LinkedListMultimap<ModContainer, ModContainer> PARENT_MAP = LinkedListMultimap.create();
40+
private static ImmutableMap<String, Function<Screen, ? extends Screen>> configScreenFactories = ImmutableMap.of();
41+
42+
public static boolean hasConfigScreenFactory(String modid) {
43+
return configScreenFactories.containsKey(modid);
44+
}
45+
46+
public static Screen getConfigScreen(String modid, Screen menuScreen) {
47+
Function<Screen, ? extends Screen> factory = configScreenFactories.get(modid);
48+
return factory != null ? factory.apply(menuScreen) : null;
49+
}
50+
51+
public static void openConfigScreen(String modid) {
52+
Runnable opener = LEGACY_CONFIG_SCREEN_TASKS.get(modid);
53+
if (opener != null) opener.run();
54+
}
55+
56+
public static void addLegacyConfigScreenTask(String modid, Runnable task) {
57+
LEGACY_CONFIG_SCREEN_TASKS.putIfAbsent(modid, task);
58+
}
59+
60+
public static boolean hasLegacyConfigScreenTask(String modid) {
61+
return LEGACY_CONFIG_SCREEN_TASKS.containsKey(modid);
62+
}
63+
64+
public static void addLibraryMod(String modid) {
65+
if (LIBRARY_MODS.contains(modid)) return;
66+
67+
LIBRARY_MODS.add(modid);
68+
}
69+
70+
@SuppressWarnings("RedundantCollectionOperation")
71+
@Override
72+
public void onInitialize() {
73+
ModMenuConfigManager.initializeConfig();
74+
ImmutableMap.Builder<String, Function<Screen, ? extends Screen>> factories = ImmutableMap.builder();
75+
FabricLoader.getInstance().getEntrypointContainers("modmenu", ModMenuApi.class).forEach(entrypoint -> {
76+
ModMenuApi api = entrypoint.getEntrypoint();
77+
ModContainer mod = entrypoint.getProvider();
8178
try {
8279
api.getClass().getDeclaredMethod("getConfigScreenFactory"); // Make sure the method is implemented
8380
factories.put(mod.getMetadata().getId(), api.getConfigScreenFactory());
84-
} catch (NoSuchMethodException ignored) { /* noop */}
81+
} catch (NoSuchMethodException ignored) {}
8582
api.attachCustomBadges((name, outlineColor, fillColor) -> {
8683
Map<String, Map.Entry<Integer, Integer>> map = new HashMap<>();
8784
map.put(name, new AbstractMap.SimpleEntry<>(outlineColor, fillColor));
8885
CUSTOM_BADGE_MODS.put(mod.getMetadata().getId(), map);
8986
});
9087
});
91-
factories.put("minecraft", (screenBase -> new ScreenOptions(screenBase, OptionsPages.GENERAL)));
92-
configScreenFactories = factories.build();
93-
Collection<ModContainer> mods = FabricLoader.getInstance().getAllMods();
94-
HardcodedUtil.initializeHardcodings();
95-
for (ModContainer mod : mods) {
96-
ModMetadata metadata = mod.getMetadata();
97-
String id = metadata.getId();
98-
// API badges
99-
if (metadata.containsCustomValue("modmenu:api") && metadata.getCustomValue("modmenu:api").getAsBoolean()) {
100-
addLibraryMod(id);
101-
}
102-
103-
// Client side badges
104-
if (metadata.getEnvironment().equals(ModEnvironment.CLIENT)) {
105-
CLIENTSIDE_MODS.add(id);
106-
}
107-
if (metadata.containsCustomValue("modmenu:clientsideOnly") && metadata.getCustomValue("modmenu:clientsideOnly").getAsBoolean()) {
108-
LOGGER.warn("Found mod with id \"{}\" using deprecated value \"modmenu:clientsideOnly\"!", metadata.getId());
109-
if (!(CLIENTSIDE_MODS.contains(id))) CLIENTSIDE_MODS.add(id);
110-
}
111-
112-
// Deprecated badges
88+
factories.put("minecraft", (screenBase -> new ScreenOptions(screenBase, OptionsPages.GENERAL)));
89+
configScreenFactories = factories.build();
90+
Collection<ModContainer> mods = FabricLoader.getInstance().getAllMods();
91+
HardcodedUtil.initializeHardcodings();
92+
for (ModContainer mod : mods) {
93+
ModMetadata metadata = mod.getMetadata();
94+
String id = metadata.getId();
95+
// API badges
96+
if (metadata.containsCustomValue("modmenu:api") && metadata.getCustomValue("modmenu:api").getAsBoolean()) {
97+
addLibraryMod(id);
98+
}
99+
100+
// Client side badges
101+
if (metadata.getEnvironment().equals(ModEnvironment.CLIENT)) {
102+
CLIENTSIDE_MODS.add(id);
103+
}
104+
if (metadata.containsCustomValue("modmenu:clientsideOnly") && metadata.getCustomValue("modmenu:clientsideOnly").getAsBoolean()) {
105+
LOGGER.warn("Found mod with id \"{}\" using deprecated value \"modmenu:clientsideOnly\"!", metadata.getId());
106+
if (!(CLIENTSIDE_MODS.contains(id))) CLIENTSIDE_MODS.add(id);
107+
}
108+
109+
// Deprecated badges
113110
if (metadata.containsCustomValue("modmenu:deprecated") && metadata.getCustomValue("modmenu:deprecated").getAsBoolean()) {
114111
DEPRECATED_MODS.add(id);
115112
}
116113

117-
// Patchwork (unused)
118-
if (metadata.containsCustomValue("patchwork:source") && metadata.getCustomValue("patchwork:source").getAsObject() != null) {
119-
CustomValue.CvObject object = metadata.getCustomValue("patchwork:source").getAsObject();
120-
if ("forge".equals(object.get("loader").getAsString())) {
121-
PATCHWORK_FORGE_MODS.add(id);
122-
}
123-
}
124-
125-
// Parent mods
126-
if (metadata.containsCustomValue("modmenu:parent")) {
127-
String parentId = metadata.getCustomValue("modmenu:parent").getAsString();
128-
if (parentId != null) {
129-
Optional<ModContainer> parent = FabricLoader.getInstance().getModContainer(parentId);
130-
parent.ifPresent(modContainer -> PARENT_MAP.put(modContainer, mod));
131-
}
132-
} else {
133-
HardcodedUtil.hardcodeModuleMetadata(mod, metadata, id);
134-
}
135-
}
136-
}
137-
138-
public static String getFormattedModCount() {
139-
return NumberFormat.getInstance().format(FabricLoader.getInstance().getAllMods().size());
140-
}
114+
// Patchwork (unused)
115+
if (metadata.containsCustomValue("patchwork:source") && metadata.getCustomValue("patchwork:source").getAsObject() != null) {
116+
CustomValue.CvObject object = metadata.getCustomValue("patchwork:source").getAsObject();
117+
if ("forge".equals(object.get("loader").getAsString())) {
118+
PATCHWORK_FORGE_MODS.add(id);
119+
}
120+
}
121+
122+
// Parent mods
123+
if (metadata.containsCustomValue("modmenu:parent")) {
124+
String parentId = metadata.getCustomValue("modmenu:parent").getAsString();
125+
if (parentId != null) {
126+
Optional<ModContainer> parent = FabricLoader.getInstance().getModContainer(parentId);
127+
parent.ifPresent(modContainer -> PARENT_MAP.put(modContainer, mod));
128+
}
129+
} else {
130+
HardcodedUtil.hardcodeModuleMetadata(mod, metadata, id);
131+
}
132+
}
133+
}
134+
135+
public static String getFormattedModCount() {
136+
return NumberFormat.getInstance().format(FabricLoader.getInstance().getAllMods().size());
137+
}
141138
}

src/main/java/io/github/prospector/modmenu/api/ModMenuApi.java

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,61 @@
11
package io.github.prospector.modmenu.api;
22

3+
4+
import io.github.prospector.modmenu.ModMenu;
35
import io.github.prospector.modmenu.util.TriConsumer;
46
import net.minecraft.client.gui.Screen;
7+
import org.jetbrains.annotations.ApiStatus;
58

9+
import java.util.Optional;
610
import java.util.function.Function;
11+
import java.util.function.Supplier;
712

813
public interface ModMenuApi {
9-
/**
10-
* Used to construct a new config screen instance when your mod's
11-
* configuration button is selected on the mod menu screen. The
12-
* screen instance parameter is the active mod menu screen.
13-
*
14-
* @return A factory function for constructing config screen instances.
15-
*/
16-
default Function<Screen, ? extends Screen> getConfigScreenFactory() {
17-
return screen -> null;
18-
}
14+
/**
15+
* Replaced with {@link ModMenuApi#getConfigScreen(Screen)}, with
16+
* the ModMenuApi implemented onto a class that is added as an
17+
* entry point to your fabric mod metadata.
18+
*
19+
* @deprecated Will be removed in 1.15 snapshots.
20+
*/
21+
@Deprecated
22+
static void addConfigOverride(String modid, Runnable action) {
23+
ModMenu.addLegacyConfigScreenTask(modid, action);
24+
}
25+
26+
/**
27+
* Used to determine the owner of this API implementation.
28+
*
29+
* @deprecated This method is deprecated as Fabric Loader
30+
* itself provides provider info for entrypoints.
31+
*/
32+
@Deprecated
33+
String getModId();
34+
35+
/**
36+
* Replaced with {@link ModMenuApi#getConfigScreenFactory()}, which
37+
* now allows ModMenu to open the screen for you, rather than depending
38+
* on you to open it, and gets rid of the messy Optional->Supplier wrapping.
39+
*
40+
* @deprecated For internal use only.
41+
*/
42+
@Deprecated
43+
@ApiStatus.Internal
44+
default Optional<Supplier<Screen>> getConfigScreen(Screen screen) {
45+
return Optional.empty();
46+
}
47+
48+
/**
49+
* Used to construct a new config screen instance when your mod's
50+
* configuration button is selected on the mod menu screen. The
51+
* screen instance parameter is the active mod menu screen.
52+
*
53+
* @return A factory function for constructing config screen instances.
54+
*/
55+
default Function<Screen, ? extends Screen> getConfigScreenFactory() {
56+
return screen -> getConfigScreen(screen).map(Supplier::get).orElse(null);
57+
}
58+
1959

2060
/**
2161
* Add custom badges for mods to use.

0 commit comments

Comments
 (0)