Skip to content

Commit

Permalink
Moved screen factory to mod menu class
Browse files Browse the repository at this point in the history
  • Loading branch information
Miki-Tellurium committed Jun 18, 2024
1 parent 4439cc3 commit 555a2f8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 49 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,45 @@
package com.mikitellurium.potionsreglint.config.modmenu;

//import com.terraformersmc.modmenu.api.ConfigScreenFactory;
//import com.terraformersmc.modmenu.api.ModMenuApi;
//
//public class ModMenuIntegration implements ModMenuApi {
//
// @Override
// public ConfigScreenFactory<?> getModConfigScreenFactory() {
// return (ClothConfigScreen::createConfigScreen);
// }
//
//}
import com.mikitellurium.potionsreglint.PotionsReGlint;
import com.mikitellurium.potionsreglint.config.Configuration;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import me.shedaniel.clothconfig2.api.ConfigBuilder;
import me.shedaniel.clothconfig2.api.ConfigCategory;
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.text.Text;

public class ModMenuIntegration implements ModMenuApi {

@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return (this::createConfigScreen);
}

private Screen createConfigScreen(Screen parent) {

ConfigBuilder builder = ConfigBuilder.create()
.setParentScreen(parent)
.setTitle(Text.translatable("config.potionsreglint.title"));

ConfigCategory general = builder.getOrCreateCategory(Text.empty());

ConfigEntryBuilder entryBuilder = builder.entryBuilder();

general.addEntry(entryBuilder
.startBooleanToggle(
Text.translatable("config.potionsreglint.enablePotionGlint"),
Configuration.ENABLE_POTION_GLINT.getValue())
.setDefaultValue(true)
.setSaveConsumer((newValue) -> Configuration.ENABLE_POTION_GLINT.setValue(newValue))
.build());

builder.setSavingRunnable(() -> {
Configuration.MOD_CONFIG.save();
PotionsReGlint.LOGGER.info("Saved Potion Re-Glint config");
});
return builder.build();
}

}

0 comments on commit 555a2f8

Please sign in to comment.