diff --git a/common/src/main/java/ziyue/tjmetro/Config.java b/common/src/main/java/ziyue/tjmetro/Config.java index ac8edc2..c065f08 100644 --- a/common/src/main/java/ziyue/tjmetro/Config.java +++ b/common/src/main/java/ziyue/tjmetro/Config.java @@ -55,8 +55,8 @@ public void set(Boolean value) { () -> IDrawingExtends.format(Text.translatable("footer.tjmetro.weblate"), IDrawingExtends.LINK_STYLE.apply(Reference.WEBLATE)) ); - public static Screen getConfigScreen() { - ConfigBuilder builder = ConfigBuilder.create().setTitle(Text.translatable("gui.tjmetro.options")).transparentBackground(); + public static Screen getConfigScreen(Screen parent) { + ConfigBuilder builder = ConfigBuilder.create().setParentScreen(parent).setTitle(Text.translatable("gui.tjmetro.options")).transparentBackground(); ConfigEntryBuilder entryBuilder = builder.entryBuilder(); ConfigCategory categoryTianjinMetro = builder.getOrCreateCategory(Text.translatable("config.category.tjmetro")); BooleanListEntry booleanMTRFilters = entryBuilder.startBooleanToggle(Text.translatable("config.tjmetro.enable_mtr_filters"), ENABLE_MTR_FILTERS.get()).setDefaultValue(ENABLE_MTR_FILTERS.getDefault()).build(); diff --git a/common/src/main/java/ziyue/tjmetro/mixin/CreativeModeInventoryScreenMixin.java b/common/src/main/java/ziyue/tjmetro/mixin/CreativeModeInventoryScreenMixin.java index c59a605..d927ee0 100644 --- a/common/src/main/java/ziyue/tjmetro/mixin/CreativeModeInventoryScreenMixin.java +++ b/common/src/main/java/ziyue/tjmetro/mixin/CreativeModeInventoryScreenMixin.java @@ -102,7 +102,7 @@ protected void afterInit(CallbackInfo ci) { filter.btnScrollDown = new IconButton(this.leftPos - 22, this.topPos + 127, Text.translatable("button.tjmetro.scroll_down").withStyle(ChatFormatting.WHITE), button -> filter.filterIndex++, tianjin_Metro$ICONS, 16, 0); filter.btnEnableAll = new IconButton(this.leftPos - 50, this.topPos + 10, Text.translatable("button.tjmetro.enable_all").withStyle(ChatFormatting.WHITE), button -> Filter.FILTERS.get(tianjin_Metro$getSelectedTab()).forEach(filter1 -> filter1.enabled = true), tianjin_Metro$ICONS, 32, 0); filter.btnDisableAll = new IconButton(this.leftPos - 50, this.topPos + 32, Text.translatable("button.tjmetro.disable_all").withStyle(ChatFormatting.WHITE), button -> Filter.FILTERS.get(tianjin_Metro$getSelectedTab()).forEach(filter1 -> filter1.enabled = false), tianjin_Metro$ICONS, 48, 0); - filter.btnOptions = new IconButton(this.leftPos - 50, this.topPos + 54, Text.translatable("button.tjmetro.tianjin_metro_options").withStyle(ChatFormatting.WHITE), button -> minecraft.setScreen(Config.getConfigScreen()), tianjin_Metro$ICONS, 64, 0); + filter.btnOptions = new IconButton(this.leftPos - 50, this.topPos + 54, Text.translatable("button.tjmetro.tianjin_metro_options").withStyle(ChatFormatting.WHITE), button -> minecraft.setScreen(Config.getConfigScreen(this)), tianjin_Metro$ICONS, 64, 0); addButton(filter.btnScrollUp); addButton(filter.btnScrollDown); addButton(filter.btnEnableAll); diff --git a/fabric/src/main/java/ziyue/tjmetro/ModMenuConfig.java b/fabric/src/main/java/ziyue/tjmetro/ModMenuConfig.java index 0c213d1..0468478 100644 --- a/fabric/src/main/java/ziyue/tjmetro/ModMenuConfig.java +++ b/fabric/src/main/java/ziyue/tjmetro/ModMenuConfig.java @@ -7,6 +7,6 @@ public class ModMenuConfig implements ModMenuApi { @Override public ConfigScreenFactory getModConfigScreenFactory() { - return parent -> Config.getConfigScreen(); + return Config::getConfigScreen; } } diff --git a/forge/src/main/java/ziyue/tjmetro/MainForge.java b/forge/src/main/java/ziyue/tjmetro/MainForge.java index 3103935..4293bb3 100644 --- a/forge/src/main/java/ziyue/tjmetro/MainForge.java +++ b/forge/src/main/java/ziyue/tjmetro/MainForge.java @@ -45,7 +45,7 @@ public MainForge() { final IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus(); EventBuses.registerModEventBus(Reference.MOD_ID, eventBus); - ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.CONFIGGUIFACTORY, () -> (client, parent) -> Config.getConfigScreen()); + ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.CONFIGGUIFACTORY, () -> (client, parent) -> Config.getConfigScreen(parent)); ITEMS.register(); BLOCKS.register();