Skip to content

Commit

Permalink
v1.9.0 - Actually add impl for new config factory providing features,…
Browse files Browse the repository at this point in the history
… add impl for vanilla options screen
  • Loading branch information
Prospector committed Feb 8, 2020
1 parent fd53293 commit ea704ae
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/io/github/prospector/modmenu/ModMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ public static void addLibraryMod(String modid) {
@Override
public void onInitializeClient() {
ModMenuConfigManager.initializeConfig();
ImmutableMap.Builder<String, ConfigScreenFactory<?>> factories = ImmutableMap.builder();
Map<String, ConfigScreenFactory<?>> factories = new HashMap<>();
FabricLoader.getInstance().getEntrypoints("modmenu", ModMenuApi.class).forEach(api -> {
factories.put(api.getModId(), api.getModConfigScreenFactory());
api.getProvidedConfigScreenFactories().forEach(factories::putIfAbsent);
});
configScreenFactories = factories.build();
configScreenFactories = new ImmutableMap.Builder<String, ConfigScreenFactory<?>>().putAll(factories).build();
Collection<ModContainer> mods = FabricLoader.getInstance().getAllMods();
HardcodedUtil.initializeHardcodings();
for (ModContainer mod : mods) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.github.prospector.modmenu;

import com.google.common.collect.ImmutableMap;
import io.github.prospector.modmenu.api.ConfigScreenFactory;
import io.github.prospector.modmenu.api.ModMenuApi;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.SettingsScreen;

import java.util.Map;

public class VanillaModMenuCompat implements ModMenuApi {
@Override
public String getModId() {
return ModMenu.MOD_ID;
}

@Override
public Map<String, ConfigScreenFactory<?>> getProvidedConfigScreenFactories() {
return ImmutableMap.of("minecraft", parent -> new SettingsScreen(parent, MinecraftClient.getInstance().options));
}
}
3 changes: 3 additions & 0 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"entrypoints": {
"client": [
"io.github.prospector.modmenu.ModMenu"
],
"modmenu": [
"io.github.prospector.modmenu.VanillaModMenuCompat"
]
},
"contact": {
Expand Down

0 comments on commit ea704ae

Please sign in to comment.