Package net.replaceitem.reconfigure.api
Interface Config
- All Known Implementing Classes:
ConfigImpl
public interface Config
-
Method Summary
Modifier and TypeMethodDescriptionstatic ConfigBuilder
This is the entrypoint for starting to build a config and all its tabs, properties and widgets.Creates the default tab for the config.createScreen
(@Nullable net.minecraft.client.gui.screen.Screen parent) Deprecated.Creates a new tab for the config.boolean
isDirty()
void
load()
Loads the config from a file using theSerializer
defined in the config.void
save()
Saves the config to a file using theSerializer
defined in the config.void
Saves the config only if any property has been changed since last saving.void
scheduleSave
(Duration duration) Schedules a call tosaveIfDirty()
with the specified delay.
-
Method Details
-
builder
This is the entrypoint for starting to build a config and all its tabs, properties and widgets.- Parameters:
namespace
- The namespace to identify the config. This should be your mod id.- Returns:
- The config builder.
-
createTab
Creates a new tab for the config. Use this if you want to split your config into multiple tabs.- Parameters:
name
- The name of the tab- Returns:
- A new config tab builder
-
createDefaultTab
ConfigTabBuilder createDefaultTab()Creates the default tab for the config. Use this if you don't want to use multiple tabs for your config. This will create the single default tab to which you can add all your properties.- Returns:
- The default config tab builder
-
createScreen
@Deprecated ConfigScreen createScreen(@Nullable @Nullable net.minecraft.client.gui.screen.Screen parent) Deprecated.Creates a screen for the config. Use this withMinecraftClient.setScreen(Screen)
to show the config screen.- Parameters:
parent
- The parent screen to return to when closing the config screen- Returns:
- The config screen
-
save
void save()Saves the config to a file using theSerializer
defined in the config. -
load
void load()Loads the config from a file using theSerializer
defined in the config. -
isDirty
boolean isDirty()- Returns:
- Whether any property has been changed since the config was last saved.
-
saveIfDirty
void saveIfDirty()Saves the config only if any property has been changed since last saving. -
scheduleSave
Schedules a call tosaveIfDirty()
with the specified delay. If this method is called again during that delay, the old delay is overridden and the time starts again. That makes it useful for debouncing repeated modification of a property from user input outside a config screen. If this method is invoked after every change of a property, it will only be saved once, assuming the delay is set longer than the gaps between property changes.
-