use of mekanism.api.gear.config.ModuleBooleanData in project Mekanism by mekanism.
the class Module method init.
public void init() {
enabled = addConfigItem(new ModuleConfigItem<Boolean>(this, ENABLED_KEY, MekanismLang.MODULE_ENABLED, new ModuleBooleanData(!data.isDisabledByDefault())) {
@Override
public void set(@Nonnull Boolean val, @Nullable Runnable callback) {
// Custom override of set to see if it changed and if so notify the custom module of that fact
boolean wasEnabled = get();
super.set(val, callback);
// we can assume it is server side
if (callback == null && wasEnabled != get()) {
customModule.onEnabledStateChange(Module.this);
}
}
});
if (data.handlesModeChange()) {
handleModeChange = addConfigItem(new ModuleConfigItem<>(this, HANDLE_MODE_CHANGE_KEY, MekanismLang.MODULE_HANDLE_MODE_CHANGE, new ModuleBooleanData()));
}
if (data.rendersHUD()) {
renderHUD = addConfigItem(new ModuleConfigItem<>(this, "renderHUD", MekanismLang.MODULE_RENDER_HUD, new ModuleBooleanData()));
}
customModule.init(this, new ModuleConfigItemCreator() {
@Override
public <TYPE> IModuleConfigItem<TYPE> createConfigItem(String name, ILangEntry description, ModuleConfigData<TYPE> data) {
return addConfigItem(new ModuleConfigItem<>(Module.this, name, description, data));
}
@Override
public IModuleConfigItem<Boolean> createDisableableConfigItem(String name, ILangEntry description, boolean def, BooleanSupplier isConfigEnabled) {
return addConfigItem(new DisableableModuleConfigItem(Module.this, name, description, def, isConfigEnabled));
}
});
}
Aggregations