diff --git a/CHANGELOG.md b/CHANGELOG.md
index ca4cbe0..83eab81 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
+### Fixed
+
+- Potential loading order issues on Fabric.
+
## [0.2.1] - 2024-06-16
### Fixed
diff --git a/config/checkstyle/checkstyle-suppressions.xml b/config/checkstyle/checkstyle-suppressions.xml
index 3d00140..a39ac62 100644
--- a/config/checkstyle/checkstyle-suppressions.xml
+++ b/config/checkstyle/checkstyle-suppressions.xml
@@ -5,4 +5,5 @@
+
diff --git a/refinedstorage-jei-integration-common/build.gradle b/refinedstorage-jei-integration-common/build.gradle
index 90d6587..ce91890 100644
--- a/refinedstorage-jei-integration-common/build.gradle
+++ b/refinedstorage-jei-integration-common/build.gradle
@@ -23,6 +23,7 @@ commonProject()
dependencies {
api "com.refinedmods.refinedstorage2:refinedstorage2-platform-common:${refinedstorageVersion}"
api "mezz.jei:jei-${minecraftVersion}-common-api:${jeiVersion}"
+ api "mezz.jei:jei-${minecraftVersion}-common:${jeiVersion}"
}
enablePublishing()
\ No newline at end of file
diff --git a/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/Common.java b/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/Common.java
index 7914423..e013854 100644
--- a/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/Common.java
+++ b/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/Common.java
@@ -1,5 +1,8 @@
package com.refinedmods.refinedstorage.jei.common;
+import com.refinedmods.refinedstorage2.platform.api.PlatformApi;
+import net.minecraft.resources.ResourceLocation;
+
import static java.util.Objects.requireNonNull;
public final class Common {
@@ -17,4 +20,16 @@ public static void setPlatform(final Platform platform) {
public static Platform getPlatform() {
return requireNonNull(platform, "Platform isn't set yet");
}
+
+ public static void init(final PlatformApi platformApi) {
+ platformApi.addIngredientConverter(new JeiRecipeModIngredientConverter());
+ platformApi.getGridSynchronizerRegistry().register(
+ new ResourceLocation(Common.MOD_ID, "jei"),
+ new JeiGridSynchronizer(false)
+ );
+ platformApi.getGridSynchronizerRegistry().register(
+ new ResourceLocation(Common.MOD_ID, "jei_two_way"),
+ new JeiGridSynchronizer(true)
+ );
+ }
}
diff --git a/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/GhostIngredientHandler.java b/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/GhostIngredientHandler.java
index 80ef8aa..f91364a 100644
--- a/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/GhostIngredientHandler.java
+++ b/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/GhostIngredientHandler.java
@@ -4,8 +4,8 @@
import java.util.Collections;
import java.util.List;
+import com.refinedmods.refinedstorage2.platform.api.PlatformApi;
import com.refinedmods.refinedstorage2.platform.api.support.resource.PlatformResourceKey;
-import com.refinedmods.refinedstorage2.platform.api.support.resource.RecipeModIngredientConverter;
import com.refinedmods.refinedstorage2.platform.common.Platform;
import com.refinedmods.refinedstorage2.platform.common.support.AbstractBaseScreen;
import com.refinedmods.refinedstorage2.platform.common.support.containermenu.AbstractResourceContainerMenu;
@@ -16,12 +16,6 @@
@SuppressWarnings("rawtypes")
class GhostIngredientHandler implements IGhostIngredientHandler {
- private final RecipeModIngredientConverter ingredientConverter;
-
- GhostIngredientHandler(final RecipeModIngredientConverter ingredientConverter) {
- this.ingredientConverter = ingredientConverter;
- }
-
@Override
public List> getTargetsTyped(final AbstractBaseScreen screen,
final ITypedIngredient ingredient,
@@ -36,7 +30,7 @@ private List> getTargets(final AbstractBaseScreen screen,
final I ingredient,
final AbstractResourceContainerMenu menu) {
final List> targets = new ArrayList<>();
- ingredientConverter.convertToResource(ingredient).ifPresent(resource -> {
+ PlatformApi.INSTANCE.getIngredientConverter().convertToResource(ingredient).ifPresent(resource -> {
for (final ResourceSlot slot : menu.getResourceSlots()) {
if (slot.isFilter() && slot.isValid(resource)) {
final Rect2i bounds = getBounds(screen, slot);
@@ -72,7 +66,7 @@ public Rect2i getArea() {
@Override
public void accept(final I ingredient) {
- ingredientConverter.convertToResource(ingredient).ifPresent(this::accept);
+ PlatformApi.INSTANCE.getIngredientConverter().convertToResource(ingredient).ifPresent(this::accept);
}
private void accept(final PlatformResourceKey resource) {
diff --git a/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/GridGuiContainerHandler.java b/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/GridGuiContainerHandler.java
index 5ed7a5f..7cf476b 100644
--- a/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/GridGuiContainerHandler.java
+++ b/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/GridGuiContainerHandler.java
@@ -2,9 +2,9 @@
import java.util.Optional;
+import com.refinedmods.refinedstorage2.platform.api.PlatformApi;
import com.refinedmods.refinedstorage2.platform.api.grid.view.PlatformGridResource;
import com.refinedmods.refinedstorage2.platform.api.support.resource.PlatformResourceKey;
-import com.refinedmods.refinedstorage2.platform.api.support.resource.RecipeModIngredientConverter;
import com.refinedmods.refinedstorage2.platform.common.grid.screen.AbstractGridScreen;
import mezz.jei.api.gui.handlers.IGuiContainerHandler;
import mezz.jei.api.ingredients.IIngredientHelper;
@@ -13,11 +13,9 @@
import mezz.jei.api.runtime.IIngredientManager;
class GridGuiContainerHandler implements IGuiContainerHandler> {
- private final RecipeModIngredientConverter converter;
private final IIngredientManager ingredientManager;
- GridGuiContainerHandler(final RecipeModIngredientConverter converter, final IIngredientManager ingredientManager) {
- this.converter = converter;
+ GridGuiContainerHandler(final IIngredientManager ingredientManager) {
this.ingredientManager = ingredientManager;
}
@@ -35,7 +33,7 @@ public Optional> getClickableIngredientUnderMouse(
if (underlyingResource == null) {
return Optional.empty();
}
- return converter.convertToIngredient(underlyingResource).flatMap(
+ return PlatformApi.INSTANCE.getIngredientConverter().convertToIngredient(underlyingResource).flatMap(
ingredient -> convertToClickableIngredient(mouseX, mouseY, ingredient)
);
}
diff --git a/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/JeiGridSynchronizer.java b/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/JeiGridSynchronizer.java
index 35d1382..c39595f 100644
--- a/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/JeiGridSynchronizer.java
+++ b/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/JeiGridSynchronizer.java
@@ -18,11 +18,9 @@ class JeiGridSynchronizer extends AbstractGridSynchronizer {
"gui.%s.grid.synchronizer.two_way.help".formatted(MOD_ID)
);
- private final JeiProxy jeiProxy;
private final boolean twoWay;
- JeiGridSynchronizer(final JeiProxy jeiProxy, final boolean twoWay) {
- this.jeiProxy = jeiProxy;
+ JeiGridSynchronizer(final boolean twoWay) {
this.twoWay = twoWay;
}
@@ -38,13 +36,13 @@ public Component getHelpText() {
@Override
public void synchronizeFromGrid(final String text) {
- jeiProxy.setSearchFieldText(text);
+ JeiHelper.setSearchFieldText(text);
}
@Override
@Nullable
public String getTextToSynchronizeToGrid() {
- return twoWay ? jeiProxy.getSearchFieldText() : null;
+ return twoWay ? JeiHelper.getSearchFieldText() : null;
}
@Override
diff --git a/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/JeiProxy.java b/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/JeiHelper.java
similarity index 73%
rename from refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/JeiProxy.java
rename to refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/JeiHelper.java
index 22667ea..3fa9157 100644
--- a/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/JeiProxy.java
+++ b/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/JeiHelper.java
@@ -2,8 +2,11 @@
import mezz.jei.api.runtime.IJeiRuntime;
-public class JeiProxy {
- public String getSearchFieldText() {
+public final class JeiHelper {
+ private JeiHelper() {
+ }
+
+ public static String getSearchFieldText() {
final IJeiRuntime runtime = RefinedStorageModPlugin.getRuntime();
if (runtime == null) {
return "";
@@ -11,7 +14,7 @@ public String getSearchFieldText() {
return runtime.getIngredientFilter().getFilterText();
}
- public void setSearchFieldText(final String text) {
+ public static void setSearchFieldText(final String text) {
final IJeiRuntime runtime = RefinedStorageModPlugin.getRuntime();
if (runtime != null) {
runtime.getIngredientFilter().setFilterText(text);
diff --git a/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/JeiRecipeModIngredientConverter.java b/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/JeiRecipeModIngredientConverter.java
index 010dce0..ba26af1 100644
--- a/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/JeiRecipeModIngredientConverter.java
+++ b/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/JeiRecipeModIngredientConverter.java
@@ -7,15 +7,10 @@
import com.refinedmods.refinedstorage2.platform.common.support.resource.FluidResource;
import com.refinedmods.refinedstorage2.platform.common.support.resource.ItemResource;
import mezz.jei.api.helpers.IPlatformFluidHelper;
+import mezz.jei.common.platform.Services;
import net.minecraft.world.item.ItemStack;
class JeiRecipeModIngredientConverter implements RecipeModIngredientConverter {
- private final IPlatformFluidHelper> fluidHelper;
-
- JeiRecipeModIngredientConverter(final IPlatformFluidHelper> fluidHelper) {
- this.fluidHelper = fluidHelper;
- }
-
@Override
public Optional convertToResource(final Object ingredient) {
final var fluid = Common.getPlatform().convertJeiIngredientToFluid(ingredient);
@@ -34,6 +29,7 @@ public Optional