-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved screen factory to mod menu class
- Loading branch information
1 parent
4439cc3
commit 555a2f8
Showing
2 changed files
with
43 additions
and
49 deletions.
There are no files selected for viewing
38 changes: 0 additions & 38 deletions
38
src/main/java/com/mikitellurium/potionsreglint/config/modmenu/ClothConfigScreen.java
This file was deleted.
Oops, something went wrong.
54 changes: 43 additions & 11 deletions
54
src/main/java/com/mikitellurium/potionsreglint/config/modmenu/ModMenuIntegration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} |