2016-06-22 23:49:47 -04:00
|
|
|
/*
|
2022-04-14 03:42:00 +00:00
|
|
|
* Copyright (c) Forge Development LLC and contributors
|
2022-02-28 13:41:23 -08:00
|
|
|
* SPDX-License-Identifier: LGPL-2.1-only
|
2016-06-22 23:49:47 -04:00
|
|
|
*/
|
|
|
|
|
|
2021-11-26 18:57:41 +00:00
|
|
|
package net.minecraftforge.client;
|
2013-12-16 11:48:09 -05:00
|
|
|
|
2018-06-11 09:56:44 -04:00
|
|
|
import net.minecraft.client.Minecraft;
|
2021-07-17 00:08:49 -05:00
|
|
|
import net.minecraft.client.gui.screens.Screen;
|
2018-06-15 15:03:35 -04:00
|
|
|
import net.minecraftforge.fml.ModList;
|
2021-07-17 00:08:49 -05:00
|
|
|
import net.minecraftforge.fml.IExtensionPoint;
|
|
|
|
|
import net.minecraftforge.forgespi.language.IModInfo;
|
2018-06-11 09:56:44 -04:00
|
|
|
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
import java.util.function.BiFunction;
|
|
|
|
|
|
|
|
|
|
public class ConfigGuiHandler
|
2013-12-16 11:48:09 -05:00
|
|
|
{
|
2021-07-17 00:08:49 -05:00
|
|
|
public record ConfigGuiFactory(BiFunction<Minecraft, Screen, Screen> screenFunction) implements IExtensionPoint<ConfigGuiFactory> {}
|
|
|
|
|
public static Optional<BiFunction<Minecraft, Screen, Screen>> getGuiFactoryFor(IModInfo selectedMod)
|
2018-06-11 09:56:44 -04:00
|
|
|
{
|
2018-06-15 15:03:35 -04:00
|
|
|
return ModList.get().getModContainerById(selectedMod.getModId()).
|
2021-07-17 00:08:49 -05:00
|
|
|
flatMap(mc -> mc.getCustomExtension(ConfigGuiFactory.class).map(ConfigGuiFactory::screenFunction));
|
2018-06-11 09:56:44 -04:00
|
|
|
}
|
2013-12-16 11:48:09 -05:00
|
|
|
}
|