diff --git a/gradle.properties b/gradle.properties index 62dcff1877..fac3bdc2b8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -33,7 +33,7 @@ forge_config_api_version = v8.0.0-1.20.1-Fabric port_lib_version = 2.1.1148+1.20-entity-refactor # adding a module also requires adding a dependency to the FMJ -port_lib_modules = accessors,base,config,entity,extensions,networking,obj_loader,tags,transfer,models,tool_actions,client_events,brewing +port_lib_modules = accessors,base,entity,extensions,networking,obj_loader,tags,transfer,models,tool_actions,client_events,brewing night_config_version = 3.6.3 jsr305_version = 3.0.2 diff --git a/src/main/java/com/simibubi/create/foundation/config/ConfigBase.java b/src/main/java/com/simibubi/create/foundation/config/ConfigBase.java index 7e6005a896..e8921fbf78 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ConfigBase.java +++ b/src/main/java/com/simibubi/create/foundation/config/ConfigBase.java @@ -5,23 +5,23 @@ import java.util.function.Function; import java.util.function.Supplier; -import io.github.fabricators_of_create.porting_lib.config.ModConfigSpec; -import io.github.fabricators_of_create.porting_lib.config.ModConfigSpec.BooleanValue; -import io.github.fabricators_of_create.porting_lib.config.ModConfigSpec.Builder; -import io.github.fabricators_of_create.porting_lib.config.ModConfigSpec.ConfigValue; -import io.github.fabricators_of_create.porting_lib.config.ModConfigSpec.DoubleValue; -import io.github.fabricators_of_create.porting_lib.config.ModConfigSpec.EnumValue; -import io.github.fabricators_of_create.porting_lib.config.ModConfigSpec.IntValue; +import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.common.ForgeConfigSpec.BooleanValue; +import net.minecraftforge.common.ForgeConfigSpec.Builder; +import net.minecraftforge.common.ForgeConfigSpec.ConfigValue; +import net.minecraftforge.common.ForgeConfigSpec.DoubleValue; +import net.minecraftforge.common.ForgeConfigSpec.EnumValue; +import net.minecraftforge.common.ForgeConfigSpec.IntValue; public abstract class ConfigBase { - public ModConfigSpec specification; + public ForgeConfigSpec specification; protected int depth; protected List> allValues; protected List children; - public void registerAll(final ModConfigSpec.Builder builder) { + public void registerAll(final ForgeConfigSpec.Builder builder) { for (CValue cValue : allValues) cValue.register(builder); } @@ -40,7 +40,7 @@ public void onReload() { @FunctionalInterface protected static interface IValueProvider> - extends Function { + extends Function { } protected ConfigBool b(boolean current, String name, String... comment) { @@ -78,7 +78,7 @@ protected ConfigGroup group(int depth, String name, String... comment) { protected T nested(int depth, Supplier constructor, String... comment) { T config = constructor.get(); new ConfigGroup(config.getName(), depth, comment); - new CValue(config.getName(), builder -> { + new CValue(config.getName(), builder -> { config.depth = depth; config.registerAll(builder); if (config.depth > depth) @@ -117,7 +117,7 @@ public void addComments(Builder builder, String... comment) { builder.comment("."); } - public void register(ModConfigSpec.Builder builder) { + public void register(ForgeConfigSpec.Builder builder) { value = provider.apply(builder); } diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/BaseConfigScreen.java b/src/main/java/com/simibubi/create/foundation/config/ui/BaseConfigScreen.java index ba1e4ded9e..675505e988 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/BaseConfigScreen.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/BaseConfigScreen.java @@ -8,9 +8,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import io.github.fabricators_of_create.porting_lib.config.ConfigType; -import io.github.fabricators_of_create.porting_lib.config.ModConfigSpec; - import org.lwjgl.glfw.GLFW; import com.simibubi.create.Create; @@ -28,6 +25,8 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; +import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.fml.config.ModConfig; public class BaseConfigScreen extends ConfigScreen { @@ -45,7 +44,7 @@ public class BaseConfigScreen extends ConfigScreen { * If you are a Create Addon dev and want to change the config labels, * add a default action here. * - * Make sure you call either {@link #withSpecs(ModConfigSpec, ModConfigSpec, ModConfigSpec)} + * Make sure you call either {@link #withSpecs(ForgeConfigSpec, ForgeConfigSpec, ForgeConfigSpec)} * or {@link #searchForSpecsInModContainer()} * * @param modID the modID of your addon/mod @@ -68,9 +67,9 @@ public static BaseConfigScreen forCreate(Screen parent) { protected BoxWidget others; protected BoxWidget title; - protected ModConfigSpec clientSpec; - protected ModConfigSpec commonSpec; - protected ModConfigSpec serverSpec; + protected ForgeConfigSpec clientSpec; + protected ForgeConfigSpec commonSpec; + protected ForgeConfigSpec serverSpec; protected String clientTitle = "Client Config"; protected String commonTitle = "Common Config"; protected String serverTitle = "Server Config"; @@ -94,7 +93,7 @@ private BaseConfigScreen(Screen parent) { /** * If you have static references to your Configs or ConfigSpecs (like Create does in {@link AllConfigs}), - * please use {@link #withSpecs(ModConfigSpec, ModConfigSpec, ModConfigSpec)} instead + * please use {@link #withSpecs(ForgeConfigSpec, ForgeConfigSpec, ForgeConfigSpec)} instead */ public BaseConfigScreen searchForSpecsInModContainer() { if (!ConfigHelper.hasAnyForgeConfig(this.modID)){ @@ -102,19 +101,19 @@ public BaseConfigScreen searchForSpecsInModContainer() { } try { - clientSpec = ConfigHelper.findForgeConfigSpecFor(ConfigType.CLIENT, this.modID); + clientSpec = ConfigHelper.findForgeConfigSpecFor(ModConfig.Type.CLIENT, this.modID); } catch (Exception e) { Create.LOGGER.debug("Unable to find ClientConfigSpec for mod: " + this.modID); } try { - commonSpec = ConfigHelper.findForgeConfigSpecFor(ConfigType.COMMON, this.modID); + commonSpec = ConfigHelper.findForgeConfigSpecFor(ModConfig.Type.COMMON, this.modID); } catch (Exception e) { Create.LOGGER.debug("Unable to find CommonConfigSpec for mod: " + this.modID); } try { - serverSpec = ConfigHelper.findForgeConfigSpecFor(ConfigType.SERVER, this.modID); + serverSpec = ConfigHelper.findForgeConfigSpecFor(ModConfig.Type.SERVER, this.modID); } catch (Exception e) { Create.LOGGER.debug("Unable to find ServerConfigSpec for mod: " + this.modID); } @@ -122,7 +121,7 @@ public BaseConfigScreen searchForSpecsInModContainer() { return this; } - public BaseConfigScreen withSpecs(@Nullable ModConfigSpec client, @Nullable ModConfigSpec common, @Nullable ModConfigSpec server) { + public BaseConfigScreen withSpecs(@Nullable ForgeConfigSpec client, @Nullable ForgeConfigSpec common, @Nullable ForgeConfigSpec server) { clientSpec = client; commonSpec = common; serverSpec = server; @@ -151,7 +150,7 @@ protected void init() { addRenderableWidget(clientConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15 - 30, 200, 16).showingElement(clientText)); if (clientSpec != null) { - clientConfigWidget.withCallback(() -> linkTo(new SubMenuConfigScreen(this, ConfigType.CLIENT, clientSpec))); + clientConfigWidget.withCallback(() -> linkTo(new SubMenuConfigScreen(this, ModConfig.Type.CLIENT, clientSpec))); clientText.withElementRenderer(BoxWidget.gradientFactory.apply(clientConfigWidget)); } else { clientConfigWidget.active = false; @@ -163,7 +162,7 @@ protected void init() { addRenderableWidget(commonConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15, 200, 16).showingElement(commonText)); if (commonSpec != null) { - commonConfigWidget.withCallback(() -> linkTo(new SubMenuConfigScreen(this, ConfigType.COMMON, commonSpec))); + commonConfigWidget.withCallback(() -> linkTo(new SubMenuConfigScreen(this, ModConfig.Type.COMMON, commonSpec))); commonText.withElementRenderer(BoxWidget.gradientFactory.apply(commonConfigWidget)); } else { commonConfigWidget.active = false; @@ -188,7 +187,7 @@ protected void init() { "Gameplay settings can only be accessed from the in-game menu after joining a World or Server."), Palette.ALL_GRAY)); } else { - serverConfigWidget.withCallback(() -> linkTo(new SubMenuConfigScreen(this, ConfigType.SERVER, serverSpec))); + serverConfigWidget.withCallback(() -> linkTo(new SubMenuConfigScreen(this, ModConfig.Type.SERVER, serverSpec))); serverText.withElementRenderer(BoxWidget.gradientFactory.apply(serverConfigWidget)); } diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/CConfigureConfigPacket.java b/src/main/java/com/simibubi/create/foundation/config/ui/CConfigureConfigPacket.java index c266c8c215..2c0b896da3 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/CConfigureConfigPacket.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/CConfigureConfigPacket.java @@ -5,10 +5,10 @@ import com.simibubi.create.Create; import com.simibubi.create.foundation.networking.SimplePacketBase; -import io.github.fabricators_of_create.porting_lib.config.ConfigType; -import io.github.fabricators_of_create.porting_lib.config.ModConfigSpec; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerPlayer; +import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.fml.config.ModConfig; public class CConfigureConfigPacket extends SimplePacketBase { @@ -43,11 +43,11 @@ public boolean handle(Context context) { if (sender == null || !sender.hasPermissions(2)) return; - ModConfigSpec spec = ConfigHelper.findForgeConfigSpecFor(ConfigType.SERVER, modID); + ForgeConfigSpec spec = ConfigHelper.findForgeConfigSpecFor(ModConfig.Type.SERVER, modID); if (spec == null) return; - ModConfigSpec.ValueSpec valueSpec = spec.getRaw(path); - ModConfigSpec.ConfigValue configValue = spec.getValues().get(path); + ForgeConfigSpec.ValueSpec valueSpec = spec.getRaw(path); + ForgeConfigSpec.ConfigValue configValue = spec.getValues().get(path); T v = (T) deserialize(configValue.get(), value); if (!valueSpec.test(v)) diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigHelper.java b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigHelper.java index 0f02912829..b76a588c1b 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigHelper.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigHelper.java @@ -22,10 +22,10 @@ import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.infrastructure.config.AllConfigs; -import io.github.fabricators_of_create.porting_lib.config.ConfigTracker; -import io.github.fabricators_of_create.porting_lib.config.ConfigType; -import io.github.fabricators_of_create.porting_lib.config.ModConfig; -import io.github.fabricators_of_create.porting_lib.config.ModConfigSpec; +import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.fml.config.ConfigTracker; +import net.minecraftforge.fml.config.IConfigSpec; +import net.minecraftforge.fml.config.ModConfig; public class ConfigHelper { @@ -33,19 +33,19 @@ public class ConfigHelper { public static final Pattern annotationPattern = Pattern.compile("\\[@cui:([^:]*)(?::(.*))?]"); public static final Map changes = new HashMap<>(); - private static final LoadingCache> configCache = + private static final LoadingCache> configCache = CacheBuilder.newBuilder() .expireAfterAccess(5, TimeUnit.MINUTES) - .build(new CacheLoader>() { + .build(new CacheLoader>() { @Override - public EnumMap load(@Nonnull String key) { + public EnumMap load(@Nonnull String key) { return findModConfigsUncached(key); } }); // FIXME compat with other config libs? - private static EnumMap findModConfigsUncached(String modID) { - EnumMap configs = new EnumMap<>(ConfigType.class); + private static EnumMap findModConfigsUncached(String modID) { + EnumMap configs = new EnumMap<>(ModConfig.Type.class); ConfigTracker.INSTANCE.configSets().forEach((type, modConfigs) -> { modConfigs.forEach(modConfig -> { if(modConfig.getModId().equals(modID)) @@ -55,7 +55,7 @@ private static EnumMap findModConfigsUncached(String modI return Objects.requireNonNull(configs); } - public static ModConfigSpec findConfigSpecFor(ConfigType type, String modID) { + public static IConfigSpec findConfigSpecFor(ModConfig.Type type, String modID) { if (!modID.equals(Create.ID)) return configCache.getUnchecked(modID) .get(type) @@ -64,10 +64,10 @@ public static ModConfigSpec findConfigSpecFor(ConfigType type, String modID) { } @Nullable - public static ModConfigSpec findForgeConfigSpecFor(ConfigType type, String modID) { - ModConfigSpec spec = findConfigSpecFor(type, modID); - if (spec instanceof ModConfigSpec) { - return (ModConfigSpec) spec; + public static ForgeConfigSpec findForgeConfigSpecFor(ModConfig.Type type, String modID) { + IConfigSpec spec = findConfigSpecFor(type, modID); + if (spec instanceof ForgeConfigSpec) { + return (ForgeConfigSpec) spec; } return null; } @@ -84,19 +84,20 @@ public static boolean hasAnyForgeConfig(String modID) { return configCache.getUnchecked(modID) .values() .stream() - .anyMatch(config -> config.getSpec() instanceof ModConfigSpec); + .anyMatch(config -> config.getSpec() instanceof ForgeConfigSpec); return true; } // Directly set a value public static void setConfigValue(ConfigPath path, String value) throws InvalidValueException { - ModConfigSpec spec = findForgeConfigSpecFor(path.getType(), path.getModID()); + ForgeConfigSpec spec = findForgeConfigSpecFor(path.getType(), path.getModID()); if (spec == null) return; List pathList = Arrays.asList(path.getPath()); - ModConfigSpec.ValueSpec valueSpec = spec.getSpec().getRaw(pathList); - ModConfigSpec.ConfigValue configValue = spec.getValues().get(pathList); + ForgeConfigSpec.ValueSpec valueSpec = spec.getRaw(pathList); + ForgeConfigSpec.ConfigValue configValue = spec.getValues() + .get(pathList); T v = (T) CConfigureConfigPacket.deserialize(configValue.get(), value); if (!valueSpec.test(v)) throw new InvalidValueException(); @@ -105,7 +106,7 @@ public static void setConfigValue(ConfigPath path, String value) throws Inva } // Add a value to the current UI's changes list - public static void setValue(String path, ModConfigSpec.ConfigValue configValue, T value, + public static void setValue(String path, ForgeConfigSpec.ConfigValue configValue, T value, @Nullable Map annotations) { if (value.equals(configValue.get())) { changes.remove(path); @@ -116,7 +117,7 @@ public static void setValue(String path, ModConfigSpec.ConfigValue config // Get a value from the current UI's changes list or the config value, if its // unchanged - public static T getValue(String path, ModConfigSpec.ConfigValue configValue) { + public static T getValue(String path, ForgeConfigSpec.ConfigValue configValue) { ConfigChange configChange = changes.get(path); if (configChange != null) // noinspection unchecked @@ -157,7 +158,7 @@ public static Pair> readMetadataFromComment(List { - ModConfigSpec.ConfigValue configValue = values.get(path); + ForgeConfigSpec.ConfigValue configValue = values.get(path); configValue.set(change.value); - if (type == ConfigType.SERVER) { + if (type == ModConfig.Type.SERVER) { AllPackets.getChannel().sendToServer(new CConfigureConfigPacket<>(ConfigScreen.modID, path, change.value)); } @@ -150,9 +149,9 @@ protected void resetConfig(UnmodifiableConfig values) { values.valueMap().forEach((key, obj) -> { if (obj instanceof AbstractConfig) { resetConfig((UnmodifiableConfig) obj); - } else if (obj instanceof ModConfigSpec.ConfigValue) { - ModConfigSpec.ConfigValue configValue = (ModConfigSpec.ConfigValue) obj; - ModConfigSpec.ValueSpec valueSpec = spec.getRaw((List) configValue.getPath()); + } else if (obj instanceof ForgeConfigSpec.ConfigValue) { + ForgeConfigSpec.ConfigValue configValue = (ForgeConfigSpec.ConfigValue) obj; + ForgeConfigSpec.ValueSpec valueSpec = spec.getRaw((List) configValue.getPath()); List comments = new ArrayList<>(); @@ -271,16 +270,16 @@ protected void init() { ScreenOpener.open( new SubMenuConfigScreen(parent, humanKey, type, spec, (UnmodifiableConfig) obj)); - } else if (obj instanceof ModConfigSpec.ConfigValue) { - ModConfigSpec.ConfigValue configValue = (ModConfigSpec.ConfigValue) obj; - ModConfigSpec.ValueSpec valueSpec = spec.getRaw(configValue.getPath()); + } else if (obj instanceof ForgeConfigSpec.ConfigValue) { + ForgeConfigSpec.ConfigValue configValue = (ForgeConfigSpec.ConfigValue) obj; + ForgeConfigSpec.ValueSpec valueSpec = spec.getRaw(configValue.getPath()); Object value = configValue.get(); ConfigScreenList.Entry entry = null; if (value instanceof Boolean) { - entry = new BooleanEntry(humanKey, (ModConfigSpec.ConfigValue) configValue, valueSpec); + entry = new BooleanEntry(humanKey, (ForgeConfigSpec.ConfigValue) configValue, valueSpec); } else if (value instanceof Enum) { - entry = new EnumEntry(humanKey, (ModConfigSpec.ConfigValue>) configValue, valueSpec); + entry = new EnumEntry(humanKey, (ForgeConfigSpec.ConfigValue>) configValue, valueSpec); } else if (value instanceof Number) { entry = NumberEntry.create(value, humanKey, configValue, valueSpec); } @@ -312,7 +311,7 @@ protected void init() { list.search(highlights.stream().findFirst().orElse("")); //extras for server configs - if (type != ConfigType.SERVER) + if (type != ModConfig.Type.SERVER) return; if (minecraft.hasSingleplayerServer()) return; diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/compat/flywheel/FlwConfigScreen.java b/src/main/java/com/simibubi/create/foundation/config/ui/compat/flywheel/FlwConfigScreen.java index f584e6559c..1155591920 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/compat/flywheel/FlwConfigScreen.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/compat/flywheel/FlwConfigScreen.java @@ -2,8 +2,6 @@ import java.util.Locale; -import io.github.fabricators_of_create.porting_lib.config.ConfigType; - import org.jetbrains.annotations.NotNull; import com.jozufozu.flywheel.config.FlwConfig; @@ -18,6 +16,7 @@ import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; +import net.minecraftforge.fml.config.ModConfig; public class FlwConfigScreen extends BaseConfigScreen { @@ -40,7 +39,7 @@ protected void init() { addRenderableWidget(clientConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15 - 30, 200, 16).showingElement(clientText)); if (flwConfig != null) { - clientConfigWidget.withCallback(() -> linkTo(new FlwSubMenuConfigScreen(this, ConfigType.CLIENT, flwConfig))); + clientConfigWidget.withCallback(() -> linkTo(new FlwSubMenuConfigScreen(this, ModConfig.Type.CLIENT, flwConfig))); clientText.withElementRenderer(BoxWidget.gradientFactory.apply(clientConfigWidget)); } else { clientConfigWidget.active = false; diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/compat/flywheel/FlwSubMenuConfigScreen.java b/src/main/java/com/simibubi/create/foundation/config/ui/compat/flywheel/FlwSubMenuConfigScreen.java index 9581efbcf0..0ff266b94e 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/compat/flywheel/FlwSubMenuConfigScreen.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/compat/flywheel/FlwSubMenuConfigScreen.java @@ -21,23 +21,23 @@ import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Couple; -import io.github.fabricators_of_create.porting_lib.config.ConfigType; import net.minecraft.ChatFormatting; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; import io.github.fabricators_of_create.porting_lib.mixin.accessors.client.accessor.AbstractSelectionListAccessor; +import net.minecraftforge.fml.config.ModConfig; public class FlwSubMenuConfigScreen extends SubMenuConfigScreen { private final FlwConfig flwConfig; - public FlwSubMenuConfigScreen(Screen parent, String title, ConfigType type, FlwConfig flwConfig) { + public FlwSubMenuConfigScreen(Screen parent, String title, ModConfig.Type type, FlwConfig flwConfig) { super(parent, title, type, null, null); this.flwConfig = flwConfig; } - public FlwSubMenuConfigScreen(Screen parent, ConfigType type, FlwConfig flwConfig) { + public FlwSubMenuConfigScreen(Screen parent, ModConfig.Type type, FlwConfig flwConfig) { this(parent, "root", type, flwConfig); } @@ -179,7 +179,7 @@ protected void init() { list.search(highlights.stream().findFirst().orElse("")); //extras for server configs - if (type != ConfigType.SERVER) + if (type != ModConfig.Type.SERVER) return; if (minecraft.hasSingleplayerServer()) return; diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/entries/BooleanEntry.java b/src/main/java/com/simibubi/create/foundation/config/ui/entries/BooleanEntry.java index 3af1ff2571..52b6f3b09d 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/entries/BooleanEntry.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/entries/BooleanEntry.java @@ -6,9 +6,9 @@ import com.simibubi.create.foundation.gui.element.RenderElement; import com.simibubi.create.foundation.gui.widget.BoxWidget; -import io.github.fabricators_of_create.porting_lib.config.ModConfigSpec; import net.minecraft.client.gui.GuiGraphics; import io.github.fabricators_of_create.porting_lib.mixin.accessors.client.accessor.AbstractWidgetAccessor; +import net.minecraftforge.common.ForgeConfigSpec; public class BooleanEntry extends ValueEntry { @@ -16,7 +16,7 @@ public class BooleanEntry extends ValueEntry { RenderElement disabled; BoxWidget button; - public BooleanEntry(String label, ModConfigSpec.ConfigValue value, ModConfigSpec.ValueSpec spec) { + public BooleanEntry(String label, ForgeConfigSpec.ConfigValue value, ForgeConfigSpec.ValueSpec spec) { super(label, value, spec); enabled = AllIcons.I_CONFIRM.asStencil() diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/entries/EnumEntry.java b/src/main/java/com/simibubi/create/foundation/config/ui/entries/EnumEntry.java index 69d4977f74..3e8c59f79c 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/entries/EnumEntry.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/entries/EnumEntry.java @@ -11,9 +11,9 @@ import com.simibubi.create.foundation.gui.element.TextStencilElement; import com.simibubi.create.foundation.gui.widget.BoxWidget; -import io.github.fabricators_of_create.porting_lib.config.ModConfigSpec; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; +import net.minecraftforge.common.ForgeConfigSpec; public class EnumEntry extends ValueEntry> { @@ -23,7 +23,7 @@ public class EnumEntry extends ValueEntry> { protected BoxWidget cycleLeft; protected BoxWidget cycleRight; - public EnumEntry(String label, ModConfigSpec.ConfigValue> value, ModConfigSpec.ValueSpec spec) { + public EnumEntry(String label, ForgeConfigSpec.ConfigValue> value, ForgeConfigSpec.ValueSpec spec) { super(label, value, spec); valueText = new TextStencilElement(Minecraft.getInstance().font, "YEP").centered(true, true); diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/entries/NumberEntry.java b/src/main/java/com/simibubi/create/foundation/config/ui/entries/NumberEntry.java index 90c53acff4..a8f0040b74 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/entries/NumberEntry.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/entries/NumberEntry.java @@ -12,13 +12,13 @@ import com.simibubi.create.foundation.gui.element.TextStencilElement; import com.simibubi.create.foundation.utility.Components; -import io.github.fabricators_of_create.porting_lib.config.ModConfigSpec; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.EditBox; import net.minecraft.network.chat.MutableComponent; import io.github.fabricators_of_create.porting_lib.mixin.accessors.client.accessor.AbstractWidgetAccessor; +import net.minecraftforge.common.ForgeConfigSpec; public abstract class NumberEntry extends ValueEntry { @@ -27,19 +27,19 @@ public abstract class NumberEntry extends ValueEntry { protected EditBox textField; @Nullable - public static NumberEntry create(Object type, String label, ModConfigSpec.ConfigValue value, ModConfigSpec.ValueSpec spec) { + public static NumberEntry create(Object type, String label, ForgeConfigSpec.ConfigValue value, ForgeConfigSpec.ValueSpec spec) { if (type instanceof Integer) { - return new IntegerEntry(label, (ModConfigSpec.ConfigValue) value, spec); + return new IntegerEntry(label, (ForgeConfigSpec.ConfigValue) value, spec); } else if (type instanceof Float) { - return new FloatEntry(label, (ModConfigSpec.ConfigValue) value, spec); + return new FloatEntry(label, (ForgeConfigSpec.ConfigValue) value, spec); } else if (type instanceof Double) { - return new DoubleEntry(label, (ModConfigSpec.ConfigValue) value, spec); + return new DoubleEntry(label, (ForgeConfigSpec.ConfigValue) value, spec); } return null; } - public NumberEntry(String label, ModConfigSpec.ConfigValue value, ModConfigSpec.ValueSpec spec) { + public NumberEntry(String label, ForgeConfigSpec.ConfigValue value, ForgeConfigSpec.ValueSpec spec) { super(label, value, spec); textField = new ConfigTextField(Minecraft.getInstance().font, 0, 0, 200, 20); if (this instanceof IntegerEntry && annotations.containsKey("IntDisplay")) { @@ -171,7 +171,7 @@ public void render(GuiGraphics graphics, int index, int y, int x, int width, int public static class IntegerEntry extends NumberEntry { - public IntegerEntry(String label, ModConfigSpec.ConfigValue value, ModConfigSpec.ValueSpec spec) { + public IntegerEntry(String label, ForgeConfigSpec.ConfigValue value, ForgeConfigSpec.ValueSpec spec) { super(label, value, spec); } @@ -203,7 +203,7 @@ protected Function getParser() { public static class FloatEntry extends NumberEntry { - public FloatEntry(String label, ModConfigSpec.ConfigValue value, ModConfigSpec.ValueSpec spec) { + public FloatEntry(String label, ForgeConfigSpec.ConfigValue value, ForgeConfigSpec.ValueSpec spec) { super(label, value, spec); } @@ -225,7 +225,7 @@ protected Function getParser() { public static class DoubleEntry extends NumberEntry { - public DoubleEntry(String label, ModConfigSpec.ConfigValue value, ModConfigSpec.ValueSpec spec) { + public DoubleEntry(String label, ForgeConfigSpec.ConfigValue value, ForgeConfigSpec.ValueSpec spec) { super(label, value, spec); } diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/entries/SubMenuEntry.java b/src/main/java/com/simibubi/create/foundation/config/ui/entries/SubMenuEntry.java index d6f44c3552..b824d5ec7e 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/entries/SubMenuEntry.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/entries/SubMenuEntry.java @@ -8,15 +8,15 @@ import com.simibubi.create.foundation.gui.element.DelegatedStencilElement; import com.simibubi.create.foundation.gui.widget.BoxWidget; -import io.github.fabricators_of_create.porting_lib.config.ModConfigSpec; import net.minecraft.client.gui.GuiGraphics; import io.github.fabricators_of_create.porting_lib.mixin.accessors.client.accessor.AbstractWidgetAccessor; +import net.minecraftforge.common.ForgeConfigSpec; public class SubMenuEntry extends ConfigScreenList.LabeledEntry { protected BoxWidget button; - public SubMenuEntry(SubMenuConfigScreen parent, String label, ModConfigSpec spec, UnmodifiableConfig config) { + public SubMenuEntry(SubMenuConfigScreen parent, String label, ForgeConfigSpec spec, UnmodifiableConfig config) { super(label); button = new BoxWidget(0, 0, 35, 16) diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/entries/ValueEntry.java b/src/main/java/com/simibubi/create/foundation/config/ui/entries/ValueEntry.java index 1e94161298..f147d35d10 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/entries/ValueEntry.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/entries/ValueEntry.java @@ -21,22 +21,22 @@ import com.simibubi.create.foundation.utility.Components; import com.simibubi.create.foundation.utility.Pair; -import io.github.fabricators_of_create.porting_lib.config.ModConfigSpec; import net.minecraft.ChatFormatting; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractSelectionList; import io.github.fabricators_of_create.porting_lib.mixin.accessors.client.accessor.AbstractSelectionList$EntryAccessor; +import net.minecraftforge.common.ForgeConfigSpec; public class ValueEntry extends ConfigScreenList.LabeledEntry { protected static final int resetWidth = 28;//including 6px offset on either side - protected ModConfigSpec.ConfigValue value; - protected ModConfigSpec.ValueSpec spec; + protected ForgeConfigSpec.ConfigValue value; + protected ForgeConfigSpec.ValueSpec spec; protected BoxWidget resetButton; protected boolean editable = true; - public ValueEntry(String label, ModConfigSpec.ConfigValue value, ModConfigSpec.ValueSpec spec) { + public ValueEntry(String label, ForgeConfigSpec.ConfigValue value, ForgeConfigSpec.ValueSpec spec) { super(label); this.value = value; this.spec = spec; diff --git a/src/main/java/com/simibubi/create/infrastructure/command/ConfigCommand.java b/src/main/java/com/simibubi/create/infrastructure/command/ConfigCommand.java index bdbe12d9a4..798f464710 100644 --- a/src/main/java/com/simibubi/create/infrastructure/command/ConfigCommand.java +++ b/src/main/java/com/simibubi/create/infrastructure/command/ConfigCommand.java @@ -8,10 +8,10 @@ import com.simibubi.create.foundation.config.ui.ConfigHelper; import com.simibubi.create.foundation.utility.Components; -import io.github.fabricators_of_create.porting_lib.config.ConfigType; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; import net.minecraft.server.level.ServerPlayer; +import net.minecraftforge.fml.config.ModConfig; /** * Examples: @@ -52,7 +52,7 @@ public class ConfigCommand { return 0; } - if (configPath.getType() == ConfigType.CLIENT) { + if (configPath.getType() == ModConfig.Type.CLIENT) { ServerPlayer player = ctx.getSource().getPlayerOrException(); AllPackets.getChannel().sendToClient(new SConfigureConfigPacket("SET" + path, value), player); diff --git a/src/main/java/com/simibubi/create/infrastructure/command/SConfigureConfigPacket.java b/src/main/java/com/simibubi/create/infrastructure/command/SConfigureConfigPacket.java index 26f3034ac3..bf7594386c 100644 --- a/src/main/java/com/simibubi/create/infrastructure/command/SConfigureConfigPacket.java +++ b/src/main/java/com/simibubi/create/infrastructure/command/SConfigureConfigPacket.java @@ -5,8 +5,6 @@ import com.simibubi.create.foundation.utility.CameraAngleAnimationService; -import io.github.fabricators_of_create.porting_lib.config.ConfigType; - import org.slf4j.Logger; import com.mojang.logging.LogUtils; @@ -34,6 +32,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.fml.config.ModConfig; public class SConfigureConfigPacket extends SimplePacketBase { @@ -89,7 +88,7 @@ private static void trySetConfig(String option, String value) { return; } - if (configPath.getType() != ConfigType.CLIENT) { + if (configPath.getType() != ModConfig.Type.CLIENT) { Create.LOGGER.warn("Received type-mismatched config packet on client"); return; } diff --git a/src/main/java/com/simibubi/create/infrastructure/config/AllConfigs.java b/src/main/java/com/simibubi/create/infrastructure/config/AllConfigs.java index db4db9dc13..45af37c5bf 100644 --- a/src/main/java/com/simibubi/create/infrastructure/config/AllConfigs.java +++ b/src/main/java/com/simibubi/create/infrastructure/config/AllConfigs.java @@ -5,12 +5,8 @@ import java.util.Map.Entry; import java.util.function.Supplier; -import io.github.fabricators_of_create.porting_lib.config.ConfigEvents; -import io.github.fabricators_of_create.porting_lib.config.ConfigRegistry; -import io.github.fabricators_of_create.porting_lib.config.ConfigType; -import io.github.fabricators_of_create.porting_lib.config.ModConfig; - -import io.github.fabricators_of_create.porting_lib.config.ModConfigSpec; +import fuzs.forgeconfigapiport.api.config.v2.ForgeConfigRegistry; +import fuzs.forgeconfigapiport.api.config.v2.ModConfigEvents; import org.apache.commons.lang3.tuple.Pair; @@ -18,9 +14,12 @@ import com.simibubi.create.content.kinetics.BlockStressValues; import com.simibubi.create.foundation.config.ConfigBase; +import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.fml.config.ModConfig; + public class AllConfigs { - private static final Map CONFIGS = new EnumMap<>(ConfigType.class); + private static final Map CONFIGS = new EnumMap<>(ModConfig.Type.class); private static CClient client; private static CCommon common; @@ -38,12 +37,12 @@ public static CServer server() { return server; } - public static ConfigBase byType(ConfigType type) { + public static ConfigBase byType(ModConfig.Type type) { return CONFIGS.get(type); } - private static T register(Supplier factory, ConfigType side) { - Pair specPair = new ModConfigSpec.Builder().configure(builder -> { + private static T register(Supplier factory, ModConfig.Type side) { + Pair specPair = new ForgeConfigSpec.Builder().configure(builder -> { T config = factory.get(); config.registerAll(builder); return config; @@ -56,17 +55,17 @@ private static T register(Supplier factory, ConfigType } public static void register() { - client = register(CClient::new, ConfigType.CLIENT); - common = register(CCommon::new, ConfigType.COMMON); - server = register(CServer::new, ConfigType.SERVER); + client = register(CClient::new, ModConfig.Type.CLIENT); + common = register(CCommon::new, ModConfig.Type.COMMON); + server = register(CServer::new, ModConfig.Type.SERVER); - for (Entry pair : CONFIGS.entrySet()) - ConfigRegistry.registerConfig(Create.ID, pair.getKey(), pair.getValue().specification); + for (Entry pair : CONFIGS.entrySet()) + ForgeConfigRegistry.INSTANCE.register(Create.ID, pair.getKey(), pair.getValue().specification); BlockStressValues.registerProvider(Create.ID, server().kinetics.stressValues); - ConfigEvents.LOADING.register(AllConfigs::onLoad); - ConfigEvents.RELOADING.register(AllConfigs::onReload); + ModConfigEvents.loading(Create.ID).register(AllConfigs::onLoad); + ModConfigEvents.reloading(Create.ID).register(AllConfigs::onReload); } public static void onLoad(ModConfig modConfig) { diff --git a/src/main/java/com/simibubi/create/infrastructure/config/CStress.java b/src/main/java/com/simibubi/create/infrastructure/config/CStress.java index 2ef37a05fa..13e0b7b257 100644 --- a/src/main/java/com/simibubi/create/infrastructure/config/CStress.java +++ b/src/main/java/com/simibubi/create/infrastructure/config/CStress.java @@ -11,19 +11,19 @@ import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.RegisteredObjects; -import io.github.fabricators_of_create.porting_lib.config.ModConfigSpec; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; - +import net.minecraftforge.common.ForgeConfigSpec.Builder; +import net.minecraftforge.common.ForgeConfigSpec.ConfigValue; public class CStress extends ConfigBase implements IStressValueProvider { - private final Map> capacities = new HashMap<>(); - private final Map> impacts = new HashMap<>(); + private final Map> capacities = new HashMap<>(); + private final Map> impacts = new HashMap<>(); @Override - public void registerAll(ModConfigSpec.Builder builder) { + public void registerAll(Builder builder) { builder.comment(".", Comments.su, Comments.impact) .push("impact"); BlockStressDefaults.DEFAULT_IMPACTS.forEach((r, i) -> { @@ -47,7 +47,7 @@ public void registerAll(ModConfigSpec.Builder builder) { public double getImpact(Block block) { block = redirectValues(block); ResourceLocation key = RegisteredObjects.getKeyOrThrow(block); - ModConfigSpec.ConfigValue value = getImpacts().get(key); + ConfigValue value = getImpacts().get(key); if (value != null) return value.get(); return 0; @@ -57,7 +57,7 @@ public double getImpact(Block block) { public double getCapacity(Block block) { block = redirectValues(block); ResourceLocation key = RegisteredObjects.getKeyOrThrow(block); - ModConfigSpec.ConfigValue value = getCapacities().get(key); + ConfigValue value = getCapacities().get(key); if (value != null) return value.get(); return 0; @@ -96,11 +96,11 @@ public String getName() { return "stressValues.v" + BlockStressDefaults.FORCED_UPDATE_VERSION; } - public Map> getImpacts() { + public Map> getImpacts() { return impacts; } - public Map> getCapacities() { + public Map> getCapacities() { return capacities; } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 4525d5eb22..4a2fb771ab 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -58,7 +58,6 @@ "porting_lib_accessors": ">=${port_lib_accessors_version}", "porting_lib_base": ">=${port_lib_base_version}", - "porting_lib_config": ">=${port_lib_config_version}", "porting_lib_entity": ">=${port_lib_entity_version}", "porting_lib_extensions": ">=${port_lib_extensions_version}", "porting_lib_networking": ">=${port_lib_networking_version}",