Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
//$$ import net.neoforged.fml.ModContainer;
//$$ import net.neoforged.fml.ModList;
//$$ import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
//$$ import org.thinkingstudio.mafglib.loader.entrypoints.ConfigScreenEntrypoint;
//$$
//$$ import java.util.Optional;
//#endif

public class FastMasaGuiSwitcher {
Expand Down Expand Up @@ -81,14 +84,12 @@ public void init() {
throw new IllegalStateException("Re-trigger initialize.");
}

if (MagicLib.getInstance().getCurrentPlatform().getPlatformType().isFabricLike() &&
!MagicLib.getInstance().getCurrentPlatform().isModLoaded(ModId.mod_menu)) {
//#if FABRIC_LIKE
if (!MagicLib.getInstance().getCurrentPlatform().isModLoaded(ModId.mod_menu)) {
return;
}

Minecraft client = Minecraft.getInstance();

//#if FABRIC_LIKE
Minecraft mc = Minecraft.getInstance();
FabricLoader.getInstance().getEntrypointContainers("modmenu", Object.class).forEach(entrypoint -> {
ModMetadata metadata = entrypoint.getProvider().getMetadata();
try {
Expand Down Expand Up @@ -129,7 +130,7 @@ public void init() {
return;
}

Screen screen = configScreenFactoryCompat.create(client.screen);
Screen screen = configScreenFactoryCompat.create(mc.screen);

if (!(screen instanceof GuiConfigsBase)) {
return;
Expand All @@ -153,38 +154,55 @@ public void init() {
}
});
//#elseif FORGE_LIKE
//$$ ModList.get().getSortedMods().forEach(modContainer ->
//$$ modContainer.getCustomExtension(IConfigScreenFactory.class).ifPresent(
//$$ factory -> {
//$$ Screen screen = factory.createScreen(modContainer, client.screen);
//$$
//$$ if (!(screen instanceof GuiConfigsBase)) {
//$$ return;
//$$ }
//$$ for (ModContainer mod : ModList.get().getSortedMods()) {
//$$ // Backward compatibility
//$$ try {
//$$ Optional<ConfigScreenEntrypoint> entrypoint = mod.getCustomExtension(ConfigScreenEntrypoint.class);
//$$
//$$ String modName = modContainer.getModInfo().getDisplayName();
//$$ if (entrypoint.isPresent()) {
//$$ this.buildGuiMap(mod, entrypoint.get().getModConfigScreenFactory());
//$$ continue;
//$$ }
//$$ } catch (NoClassDefFoundError ignore) {
//$$ // NO-OP
//$$ }
//$$
//$$ if (!this.guiClass.containsKey(screen.getClass())) {
//$$ MasaGadgetScreenFactory masaGadgetScreenFactory = new MasaGadgetScreenFactory(modContainer, factory);
//$$ this.guiModName.put(masaGadgetScreenFactory, () -> modName);
//$$ this.guiClass.put(screen.getClass(), masaGadgetScreenFactory);
//$$ } else {
//$$ MasaGadgetScreenFactory savedConfigScreenFactory = this.guiClass.get(screen.getClass());
//$$ String savedName = savedConfigScreenFactory.getClass().getName();
//$$
//$$ if (savedName.length() > modName.length()) {
//$$ MasaGadgetScreenFactory masaGadgetScreenFactory = new MasaGadgetScreenFactory(modContainer, factory);
//$$ this.guiModName.put(masaGadgetScreenFactory, () -> modName);
//$$ }
//$$ }
//$$ }
//$$ )
//$$ );
//$$ mod.getCustomExtension(IConfigScreenFactory.class).ifPresent(factory ->
//$$ this.buildGuiMap(mod, factory)
//$$ );
//$$ }
//#endif

this.initialized.set(true);
}

//#if FORGE_LIKE
//$$ private void buildGuiMap(ModContainer mod, IConfigScreenFactory factory) {
//$$ Minecraft mc = Minecraft.getInstance();
//$$ Screen screen = factory.createScreen(mod, mc.screen);
//$$
//$$ if (!(screen instanceof GuiConfigsBase)) {
//$$ return;
//$$ }
//$$
//$$ String modName = mod.getModInfo().getDisplayName();
//$$
//$$ if (!this.guiClass.containsKey(screen.getClass())) {
//$$ MasaGadgetScreenFactory masaGadgetScreenFactory = new MasaGadgetScreenFactory(mod, factory);
//$$ this.guiModName.put(masaGadgetScreenFactory, () -> modName);
//$$ this.guiClass.put(screen.getClass(), masaGadgetScreenFactory);
//$$ } else {
//$$ MasaGadgetScreenFactory savedConfigScreenFactory = this.guiClass.get(screen.getClass());
//$$ String savedName = savedConfigScreenFactory.getClass().getName();
//$$
//$$ if (savedName.length() > modName.length()) {
//$$ MasaGadgetScreenFactory masaGadgetScreenFactory = new MasaGadgetScreenFactory(mod, factory);
//$$ this.guiModName.put(masaGadgetScreenFactory, () -> modName);
//$$ }
//$$ }
//$$ }
//#endif

public List<IStringValue> getModNameList() {
return this.guiModName.values()
.stream()
Expand Down
6 changes: 3 additions & 3 deletions versions/1.21.1-neoforge/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ dependencies.api.fabric_api_version=0.104.0+2.0.14+1.21.1

# Compatible Libraries
dependencies.api.itemscroller_version=0.2.2-mc1.21.1
dependencies.api.litematica_version=0.2.3-mc1.21.1
dependencies.api.minihud_version=0.2.2-mc1.21.1
dependencies.api.tweakeroo_version=0.2.4-mc1.21.1
dependencies.api.litematica_version=0.3.1-mc1.21.1
dependencies.api.minihud_version=0.3.1-mc1.21.1
dependencies.api.tweakeroo_version=0.3.1-mc1.21.1

# Loom Properties
loom.platform=neoforge
Expand Down