Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make clientside config editable with Configured on Forge 1.19.2 #3148

Open
wants to merge 8 commits into
base: 1.19
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

import javax.annotation.ParametersAreNonnullByDefault;

import mezz.jei.core.FieldsAndMethodsAreNonnullByDefault;
import mezz.jei.api.FieldsAndMethodsAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import mezz.jei.common.network.PacketIdServer;
import mezz.jei.common.network.ServerPacketContext;
import mezz.jei.common.network.ServerPacketData;
import mezz.jei.core.config.GiveMode;
import mezz.jei.api.config.GiveMode;
import mezz.jei.common.util.ServerCommandUtil;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.MinecraftServer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import mezz.jei.common.network.IConnectionToClient;
import mezz.jei.common.network.ServerPacketContext;
import mezz.jei.common.network.packets.PacketCheatPermission;
import mezz.jei.core.config.GiveMode;
import mezz.jei.api.config.GiveMode;
import mezz.jei.core.config.IServerConfig;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mezz.jei.core;
package mezz.jei.api;

import javax.annotation.Nonnull;
import javax.annotation.meta.TypeQualifierDefault;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mezz.jei.core.config;
package mezz.jei.api.config;

public enum GiveMode {
INVENTORY, MOUSE_PICKUP;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package mezz.jei.gui.config;
package mezz.jei.api.config;

import mezz.jei.core.config.GiveMode;
import mezz.jei.core.config.IngredientSortStage;

import java.util.List;
import java.util.stream.Stream;

public interface IClientConfig {
int minRecipeGuiHeight = 175;
Expand All @@ -22,5 +19,5 @@ public interface IClientConfig {

int getMaxRecipeGuiHeight();

List<IngredientSortStage> getIngredientSorterStages();
Stream<IngredientSortStage> getIngredientSorterStages();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package mezz.jei.gui.config;
package mezz.jei.api.config;

public interface IJeiClientConfigs {
public interface IClientConfigs {
IClientConfig getClientConfig();

IIngredientFilterConfig getIngredientFilterConfig();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
package mezz.jei.gui.config;

import mezz.jei.core.search.SearchMode;
package mezz.jei.api.config;

public interface IIngredientFilterConfig {
SearchMode getModNameSearchMode();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package mezz.jei.api.config;

import mezz.jei.api.config.gui.HorizontalAlignment;
import mezz.jei.api.config.gui.NavigationVisibility;
import mezz.jei.api.config.gui.VerticalAlignment;

public interface IIngredientGridConfig {
int minNumRows = 1;
int defaultNumRows = 48;
int largestNumRows = 100;

int minNumColumns = 4;
int defaultNumColumns = 9;
int largestNumColumns = 100;

VerticalAlignment defaultVerticalAlignment = VerticalAlignment.TOP;
NavigationVisibility defaultButtonNavigationVisibility = NavigationVisibility.ENABLED;
boolean defaultDrawBackground = false;

int getMaxColumns();
int getMinColumns();
int getMaxRows();
int getMinRows();
boolean drawBackground();
HorizontalAlignment getHorizontalAlignment();
VerticalAlignment getVerticalAlignment();
NavigationVisibility getButtonNavigationVisibility();
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mezz.jei.core.config;
package mezz.jei.api.config;

import java.util.List;

Expand All @@ -10,4 +10,14 @@ public enum IngredientSortStage {
IngredientSortStage.INGREDIENT_TYPE,
IngredientSortStage.CREATIVE_MENU
);
public static final List<String> defaultStagesNames = defaultStages.stream().map(stage -> stage.name()).toList();

public static boolean isValidName(String name) {
try {
valueOf(name);
return true;
} catch (IllegalArgumentException e) {
return false;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mezz.jei.core.search;
package mezz.jei.api.config;

public enum SearchMode {
ENABLED, REQUIRE_PREFIX, DISABLED
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mezz.jei.gui.util;
package mezz.jei.api.config.gui;

public enum HorizontalAlignment {
LEFT, CENTER, RIGHT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mezz.jei.gui.overlay.options;
package mezz.jei.api.config.gui;

public enum NavigationVisibility {
ENABLED, AUTO_HIDE, DISABLED
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mezz.jei.gui.util;
package mezz.jei.api.config.gui;

public enum VerticalAlignment {
TOP, CENTER, BOTTOM
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@ParametersAreNonnullByDefault
@FieldsAndMethodsAreNonnullByDefault
package mezz.jei.api.config.gui;


import mezz.jei.api.FieldsAndMethodsAreNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package mezz.jei.gui.overlay.options;
package mezz.jei.api.config;

import net.minecraft.MethodsReturnNonnullByDefault;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package mezz.jei.api.registration;

import mezz.jei.api.config.IClientConfigs;
import mezz.jei.api.helpers.IJeiHelpers;
import mezz.jei.api.recipe.IRecipeManager;
import mezz.jei.api.recipe.transfer.IRecipeTransferManager;
Expand Down Expand Up @@ -88,4 +89,7 @@ public interface IRuntimeRegistration {
* This is used by JEI's GUI and can be used by other mods that want to use the same information from JEI.
*/
IEditModeConfig getEditModeConfig();

// TODO: docs
IClientConfigs getClientConfigs();
}
1 change: 1 addition & 0 deletions Core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dependencies {
name = "log4j-api",
version = "2.17.0"
)
implementation(project(mapOf("path" to ":CommonApi")))
testImplementation(
group = "org.junit.jupiter",
name = "junit-jupiter-api",
Expand Down
2 changes: 1 addition & 1 deletion Core/src/main/java/mezz/jei/core/collect/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
@FieldsAndMethodsAreNonnullByDefault
package mezz.jei.core.collect;

import mezz.jei.core.FieldsAndMethodsAreNonnullByDefault;
import mezz.jei.api.FieldsAndMethodsAreNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
@FieldsAndMethodsAreNonnullByDefault
package mezz.jei.core.config.file;

import mezz.jei.core.FieldsAndMethodsAreNonnullByDefault;
import mezz.jei.api.FieldsAndMethodsAreNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
@FieldsAndMethodsAreNonnullByDefault
package mezz.jei.core.config.file.serializers;

import mezz.jei.core.FieldsAndMethodsAreNonnullByDefault;
import mezz.jei.api.FieldsAndMethodsAreNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
2 changes: 1 addition & 1 deletion Core/src/main/java/mezz/jei/core/config/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
@FieldsAndMethodsAreNonnullByDefault
package mezz.jei.core.config;

import mezz.jei.core.FieldsAndMethodsAreNonnullByDefault;
import mezz.jei.api.FieldsAndMethodsAreNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
@FieldsAndMethodsAreNonnullByDefault
package mezz.jei.core.config.sorting;

import mezz.jei.core.FieldsAndMethodsAreNonnullByDefault;
import mezz.jei.api.FieldsAndMethodsAreNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
@FieldsAndMethodsAreNonnullByDefault
package mezz.jei.core.config.sorting.serializers;

import mezz.jei.core.FieldsAndMethodsAreNonnullByDefault;
import mezz.jei.api.FieldsAndMethodsAreNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
2 changes: 2 additions & 0 deletions Core/src/main/java/mezz/jei/core/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
@FieldsAndMethodsAreNonnullByDefault
package mezz.jei.core;

import mezz.jei.api.FieldsAndMethodsAreNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package mezz.jei.core.search;

import mezz.jei.api.config.SearchMode;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
Expand Down
2 changes: 2 additions & 0 deletions Core/src/main/java/mezz/jei/core/search/ISearchable.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package mezz.jei.core.search;

import mezz.jei.api.config.SearchMode;

import java.util.Set;

public interface ISearchable<T> {
Expand Down
1 change: 1 addition & 0 deletions Core/src/main/java/mezz/jei/core/search/PrefixInfo.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package mezz.jei.core.search;

import mezz.jei.api.config.SearchMode;
import org.jetbrains.annotations.Unmodifiable;

import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package mezz.jei.core.search;

import mezz.jei.api.config.SearchMode;

import java.util.Collection;
import java.util.Set;

Expand Down
2 changes: 1 addition & 1 deletion Core/src/main/java/mezz/jei/core/search/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
@FieldsAndMethodsAreNonnullByDefault
package mezz.jei.core.search;

import mezz.jei.core.FieldsAndMethodsAreNonnullByDefault;
import mezz.jei.api.FieldsAndMethodsAreNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
@FieldsAndMethodsAreNonnullByDefault
package mezz.jei.core.search.suffixtree;

import mezz.jei.core.FieldsAndMethodsAreNonnullByDefault;
import mezz.jei.api.FieldsAndMethodsAreNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
@FieldsAndMethodsAreNonnullByDefault
package mezz.jei.core.util.function;

import mezz.jei.core.FieldsAndMethodsAreNonnullByDefault;
import mezz.jei.api.FieldsAndMethodsAreNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
2 changes: 1 addition & 1 deletion Core/src/main/java/mezz/jei/core/util/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
@FieldsAndMethodsAreNonnullByDefault
package mezz.jei.core.util;

import mezz.jei.core.FieldsAndMethodsAreNonnullByDefault;
import mezz.jei.api.FieldsAndMethodsAreNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
@FieldsAndMethodsAreNonnullByDefault
package mezz.jei.test.search.suffixtree;

import mezz.jei.core.FieldsAndMethodsAreNonnullByDefault;
import mezz.jei.api.FieldsAndMethodsAreNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
2 changes: 1 addition & 1 deletion Core/src/test/java/mezz/jei/test/util/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
@FieldsAndMethodsAreNonnullByDefault
package mezz.jei.test.util;

import mezz.jei.core.FieldsAndMethodsAreNonnullByDefault;
import mezz.jei.api.FieldsAndMethodsAreNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
12 changes: 11 additions & 1 deletion Fabric/src/main/java/mezz/jei/fabric/JustEnoughItemsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import mezz.jei.common.Internal;
import mezz.jei.common.gui.textures.JeiSpriteUploader;
import mezz.jei.common.gui.textures.Textures;
import mezz.jei.common.platform.Services;
import mezz.jei.core.config.IServerConfig;
import mezz.jei.fabric.config.ClientConfigs;
import mezz.jei.fabric.config.ServerConfig;
import mezz.jei.fabric.events.JeiIdentifiableResourceReloadListener;
import mezz.jei.fabric.events.JeiLifecycleEvents;
Expand All @@ -13,7 +15,12 @@
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.minecraft.server.packs.PackType;

import java.nio.file.Path;

public class JustEnoughItemsClient implements ClientModInitializer {



@Override
public void onInitializeClient() {
JeiLifecycleEvents.REGISTER_RESOURCE_RELOAD_LISTENER.register((resourceManager, textureManager) -> {
Expand All @@ -24,8 +31,11 @@ public void onInitializeClient() {
Internal.setTextures(textures);

ClientLifecycleEvents.CLIENT_STARTED.register(event -> {
Path configDir = Services.PLATFORM.getConfigHelper().createJeiConfigDir();
ClientConfigs jeiClientConfigs = new ClientConfigs(configDir.resolve("jei-client.ini"));

IServerConfig serverConfig = ServerConfig.getInstance();
ClientLifecycleHandler clientLifecycleHandler = new ClientLifecycleHandler(textures, serverConfig);
ClientLifecycleHandler clientLifecycleHandler = new ClientLifecycleHandler(textures, serverConfig, jeiClientConfigs);
clientLifecycleHandler.registerEvents();

ResourceManagerHelper.get(PackType.SERVER_DATA)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package mezz.jei.gui.config;
package mezz.jei.fabric.config;

import com.google.common.base.Preconditions;
import mezz.jei.api.config.IClientConfig;
import mezz.jei.core.config.file.IConfigCategoryBuilder;
import mezz.jei.core.config.file.IConfigSchemaBuilder;
import mezz.jei.core.config.file.serializers.EnumSerializer;
import mezz.jei.core.config.file.serializers.ListSerializer;
import mezz.jei.core.config.GiveMode;
import mezz.jei.core.config.IngredientSortStage;
import mezz.jei.api.config.GiveMode;
import mezz.jei.api.config.IngredientSortStage;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.function.Supplier;
import java.util.stream.Stream;

public final class ClientConfig implements IClientConfig {
@Nullable
Expand Down Expand Up @@ -110,7 +112,7 @@ public int getMaxRecipeGuiHeight() {
}

@Override
public List<IngredientSortStage> getIngredientSorterStages() {
return ingredientSorterStages.get();
public Stream<IngredientSortStage> getIngredientSorterStages() {
return ingredientSorterStages.get().stream();
}
}
Loading