From 261ba9677ad230110849b0b8103a303eb892f712 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Tue, 18 Jun 2024 10:27:41 +0200 Subject: [PATCH 1/5] build: remove trinkets and curios repo --- gradle.properties | 2 +- refinedstorage-jei-integration-common/build.gradle | 10 +++++----- refinedstorage-jei-integration-fabric/build.gradle | 10 +++------- refinedstorage-jei-integration-forge/build.gradle | 14 +++++--------- 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/gradle.properties b/gradle.properties index 58ffed3..9ae9233 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -refinedstorageVersion=2.0.0-milestone.3.10 +refinedstorageVersion=2.0.0-milestone.3.13 jeiVersion=17.3.0.52 # Gradle org.gradle.jvmargs=-Xmx1G diff --git a/refinedstorage-jei-integration-common/build.gradle b/refinedstorage-jei-integration-common/build.gradle index aa799c0..90d6587 100644 --- a/refinedstorage-jei-integration-common/build.gradle +++ b/refinedstorage-jei-integration-common/build.gradle @@ -5,10 +5,6 @@ plugins { archivesBaseName = 'refinedstorage-jei-integration-common' repositories { - maven { - name = 'JEI' - url = "https://maven.blamejared.com/" - } maven { url = uri("https://maven.pkg.github.com/refinedmods/refinedstorage2") credentials { @@ -16,13 +12,17 @@ repositories { password = "\u0067hp_oGjcDFCn8jeTzIj4Ke9pLoEVtpnZMP4VQgaX" } } + maven { + name = 'JEI' + url = "https://maven.blamejared.com/" + } } commonProject() dependencies { - api "mezz.jei:jei-${minecraftVersion}-common-api:${jeiVersion}" api "com.refinedmods.refinedstorage2:refinedstorage2-platform-common:${refinedstorageVersion}" + api "mezz.jei:jei-${minecraftVersion}-common-api:${jeiVersion}" } enablePublishing() \ No newline at end of file diff --git a/refinedstorage-jei-integration-fabric/build.gradle b/refinedstorage-jei-integration-fabric/build.gradle index 39a841e..de007bc 100644 --- a/refinedstorage-jei-integration-fabric/build.gradle +++ b/refinedstorage-jei-integration-fabric/build.gradle @@ -3,10 +3,6 @@ archivesBaseName = 'refinedstorage-jei-integration-fabric' fabricProject("refinedstorage_jei_integration", project(":refinedstorage-jei-integration-common")) repositories { - maven { - name = 'JEI' - url = "https://maven.blamejared.com/" - } maven { url = uri("https://maven.pkg.github.com/refinedmods/refinedstorage2") credentials { @@ -27,14 +23,14 @@ repositories { url = 'https://maven.cafeteria.dev/releases/' } maven { - name = "Trinkets" - url = 'https://maven.ladysnake.org/releases' + name = 'JEI' + url = "https://maven.blamejared.com/" } } dependencies { modApi "com.refinedmods.refinedstorage2:refinedstorage2-platform-fabric:${refinedstorageVersion}" - modApi "mezz.jei:jei-${minecraftVersion}-fabric:${jeiVersion}" + modRuntimeOnly "mezz.jei:jei-${minecraftVersion}-fabric:${jeiVersion}" modCompileOnlyApi "mezz.jei:jei-${minecraftVersion}-common-api:${jeiVersion}" modCompileOnlyApi "mezz.jei:jei-${minecraftVersion}-fabric-api:${jeiVersion}" } diff --git a/refinedstorage-jei-integration-forge/build.gradle b/refinedstorage-jei-integration-forge/build.gradle index 34fa228..d8a3555 100644 --- a/refinedstorage-jei-integration-forge/build.gradle +++ b/refinedstorage-jei-integration-forge/build.gradle @@ -7,14 +7,6 @@ archivesBaseName = 'refinedstorage-jei-integration-forge' forgeProject("refinedstorage_jei_integration", project(":refinedstorage-jei-integration-common")) repositories { - maven { - name = 'JEI' - url = "https://maven.blamejared.com/" - } - maven { - name = 'Curios' - url = "https://maven.theillusivec4.top/" - } maven { url = uri("https://maven.pkg.github.com/refinedmods/refinedstorage2") credentials { @@ -22,11 +14,15 @@ repositories { password = "\u0067hp_oGjcDFCn8jeTzIj4Ke9pLoEVtpnZMP4VQgaX" } } + maven { + name = 'JEI' + url = "https://maven.blamejared.com/" + } } dependencies { api "com.refinedmods.refinedstorage2:refinedstorage2-platform-forge:${refinedstorageVersion}" - api "mezz.jei:jei-${minecraftVersion}-neoforge:${jeiVersion}" + runtimeOnly "mezz.jei:jei-${minecraftVersion}-neoforge:${jeiVersion}" compileOnlyApi "mezz.jei:jei-${minecraftVersion}-common-api:${jeiVersion}" compileOnlyApi "mezz.jei:jei-${minecraftVersion}-neoforge-api:${jeiVersion}" } From b30f9cf761501358e3dfcd84aba678132ebf3108 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Tue, 18 Jun 2024 10:27:59 +0200 Subject: [PATCH 2/5] refactor: rename mod plugin class --- .../com/refinedmods/refinedstorage/jei/common/JeiProxy.java | 4 ++-- ...torageJeiModPlugin.java => RefinedStorageModPlugin.java} | 6 +++--- .../src/main/resources/fabric.mod.json | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) rename refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/{RefinedStorageJeiModPlugin.java => RefinedStorageModPlugin.java} (95%) 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/JeiProxy.java index 88ff332..22667ea 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/JeiProxy.java @@ -4,7 +4,7 @@ public class JeiProxy { public String getSearchFieldText() { - final IJeiRuntime runtime = RefinedStorageJeiModPlugin.getRuntime(); + final IJeiRuntime runtime = RefinedStorageModPlugin.getRuntime(); if (runtime == null) { return ""; } @@ -12,7 +12,7 @@ public String getSearchFieldText() { } public void setSearchFieldText(final String text) { - final IJeiRuntime runtime = RefinedStorageJeiModPlugin.getRuntime(); + 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/RefinedStorageJeiModPlugin.java b/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/RefinedStorageModPlugin.java similarity index 95% rename from refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/RefinedStorageJeiModPlugin.java rename to refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/RefinedStorageModPlugin.java index 75b4b76..1c04784 100644 --- a/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/RefinedStorageJeiModPlugin.java +++ b/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/RefinedStorageModPlugin.java @@ -18,9 +18,9 @@ import org.slf4j.LoggerFactory; @JeiPlugin -public class RefinedStorageJeiModPlugin implements IModPlugin { +public class RefinedStorageModPlugin implements IModPlugin { private static final ResourceLocation ID = new ResourceLocation(Common.MOD_ID, "plugin"); - private static final Logger LOGGER = LoggerFactory.getLogger(RefinedStorageJeiModPlugin.class); + private static final Logger LOGGER = LoggerFactory.getLogger(RefinedStorageModPlugin.class); @Nullable private static IJeiRuntime runtime; @@ -39,7 +39,7 @@ public void onRuntimeAvailable(final IJeiRuntime newRuntime) { if (runtime == null) { initializePlatform(newRuntime.getJeiHelpers().getPlatformFluidHelper()); } - RefinedStorageJeiModPlugin.runtime = newRuntime; + RefinedStorageModPlugin.runtime = newRuntime; } @Override diff --git a/refinedstorage-jei-integration-fabric/src/main/resources/fabric.mod.json b/refinedstorage-jei-integration-fabric/src/main/resources/fabric.mod.json index 2cb0937..a020cd9 100644 --- a/refinedstorage-jei-integration-fabric/src/main/resources/fabric.mod.json +++ b/refinedstorage-jei-integration-fabric/src/main/resources/fabric.mod.json @@ -18,7 +18,7 @@ "com.refinedmods.refinedstorage.jei.fabric.ModInitializerImpl" ], "jei_mod_plugin": [ - "com.refinedmods.refinedstorage.jei.common.RefinedStorageJeiModPlugin" + "com.refinedmods.refinedstorage.jei.common.RefinedStorageModPlugin" ] }, "custom": { From f87e91d20a05bed987222485f1d9b1022fcd1980 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Thu, 20 Jun 2024 23:01:35 +0200 Subject: [PATCH 3/5] fix: loading order issues on fabric --- CHANGELOG.md | 4 ++ config/checkstyle/checkstyle-suppressions.xml | 1 + .../build.gradle | 1 + .../refinedstorage/jei/common/Common.java | 15 +++++++ .../jei/common/GhostIngredientHandler.java | 12 ++---- .../jei/common/GridGuiContainerHandler.java | 8 ++-- .../jei/common/JeiGridSynchronizer.java | 8 ++-- .../common/{JeiProxy.java => JeiHelper.java} | 9 ++-- .../JeiRecipeModIngredientConverter.java | 8 +--- .../jei/common/RefinedStorageModPlugin.java | 43 ++++--------------- .../common/ResourceGuiContainerHandler.java | 9 ++-- .../jei/fabric/JeiRefinedStoragePlugin.java | 13 ++++++ .../src/main/resources/fabric.mod.json | 3 ++ .../jei/forge/ModInitializer.java | 11 +++++ 14 files changed, 76 insertions(+), 69 deletions(-) rename refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/{JeiProxy.java => JeiHelper.java} (73%) create mode 100644 refinedstorage-jei-integration-fabric/src/main/java/com/refinedmods/refinedstorage/jei/fabric/JeiRefinedStoragePlugin.java 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 convertToIngredient(final PlatformResourceKey resource) return Optional.of(itemResource.toItemStack()); } if (resource instanceof FluidResource fluidResource) { + final IPlatformFluidHelper fluidHelper = Services.PLATFORM.getFluidHelper(); return Optional.of(fluidHelper.create( fluidResource.fluid(), fluidHelper.bucketVolume(), diff --git a/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/RefinedStorageModPlugin.java b/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/RefinedStorageModPlugin.java index 1c04784..789061f 100644 --- a/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/RefinedStorageModPlugin.java +++ b/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/RefinedStorageModPlugin.java @@ -2,25 +2,19 @@ import javax.annotation.Nullable; -import com.refinedmods.refinedstorage2.platform.api.PlatformApi; -import com.refinedmods.refinedstorage2.platform.api.support.resource.RecipeModIngredientConverter; import com.refinedmods.refinedstorage2.platform.common.grid.screen.AbstractGridScreen; import com.refinedmods.refinedstorage2.platform.common.support.AbstractBaseScreen; import mezz.jei.api.IModPlugin; import mezz.jei.api.JeiPlugin; import mezz.jei.api.constants.RecipeTypes; -import mezz.jei.api.helpers.IPlatformFluidHelper; import mezz.jei.api.registration.IGuiHandlerRegistration; import mezz.jei.api.registration.IRecipeTransferRegistration; import mezz.jei.api.runtime.IJeiRuntime; import net.minecraft.resources.ResourceLocation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; @JeiPlugin public class RefinedStorageModPlugin implements IModPlugin { private static final ResourceLocation ID = new ResourceLocation(Common.MOD_ID, "plugin"); - private static final Logger LOGGER = LoggerFactory.getLogger(RefinedStorageModPlugin.class); @Nullable private static IJeiRuntime runtime; @@ -36,54 +30,33 @@ public void registerRecipeTransferHandlers(final IRecipeTransferRegistration reg @Override public void onRuntimeAvailable(final IJeiRuntime newRuntime) { - if (runtime == null) { - initializePlatform(newRuntime.getJeiHelpers().getPlatformFluidHelper()); - } RefinedStorageModPlugin.runtime = newRuntime; } + @Override + public void onRuntimeUnavailable() { + RefinedStorageModPlugin.runtime = null; + } + @Override public void registerGuiHandlers(final IGuiHandlerRegistration registration) { - final RecipeModIngredientConverter converter = PlatformApi.INSTANCE.getIngredientConverter(); registration.addGenericGuiContainerHandler( AbstractBaseScreen.class, - new ResourceGuiContainerHandler(converter, registration.getJeiHelpers().getIngredientManager()) + new ResourceGuiContainerHandler(registration.getJeiHelpers().getIngredientManager()) ); registration.addGenericGuiContainerHandler( AbstractGridScreen.class, - new GridGuiContainerHandler(converter, registration.getJeiHelpers().getIngredientManager()) + new GridGuiContainerHandler(registration.getJeiHelpers().getIngredientManager()) ); registration.addGenericGuiContainerHandler( AbstractBaseScreen.class, new ExclusionZonesGuiContainerHandler() ); - registration.addGhostIngredientHandler(AbstractBaseScreen.class, new GhostIngredientHandler(converter)); + registration.addGhostIngredientHandler(AbstractBaseScreen.class, new GhostIngredientHandler()); } @Nullable public static IJeiRuntime getRuntime() { return runtime; } - - private void initializePlatform(final IPlatformFluidHelper fluidHelper) { - LOGGER.debug("Enabling JEI integration"); - registerIngredientConverters(fluidHelper); - registerGridSynchronizers(); - } - - private void registerGridSynchronizers() { - final JeiProxy jeiProxy = new JeiProxy(); - PlatformApi.INSTANCE.getGridSynchronizerRegistry().register( - new ResourceLocation(Common.MOD_ID, "jei"), - new JeiGridSynchronizer(jeiProxy, false) - ); - PlatformApi.INSTANCE.getGridSynchronizerRegistry().register( - new ResourceLocation(Common.MOD_ID, "jei_two_way"), - new JeiGridSynchronizer(jeiProxy, true) - ); - } - - private void registerIngredientConverters(final IPlatformFluidHelper fluidHelper) { - PlatformApi.INSTANCE.addIngredientConverter(new JeiRecipeModIngredientConverter(fluidHelper)); - } } diff --git a/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/ResourceGuiContainerHandler.java b/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/ResourceGuiContainerHandler.java index 6c8285a..f9808f6 100644 --- a/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/ResourceGuiContainerHandler.java +++ b/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/ResourceGuiContainerHandler.java @@ -3,8 +3,8 @@ import java.util.Optional; import javax.annotation.Nullable; +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.support.AbstractBaseScreen; import mezz.jei.api.gui.handlers.IGuiContainerHandler; import mezz.jei.api.ingredients.IIngredientHelper; @@ -13,12 +13,9 @@ import mezz.jei.api.runtime.IIngredientManager; class ResourceGuiContainerHandler implements IGuiContainerHandler> { - private final RecipeModIngredientConverter converter; private final IIngredientManager ingredientManager; - ResourceGuiContainerHandler(final RecipeModIngredientConverter converter, - final IIngredientManager ingredientManager) { - this.converter = converter; + ResourceGuiContainerHandler(final IIngredientManager ingredientManager) { this.ingredientManager = ingredientManager; } @@ -35,7 +32,7 @@ public Optional convertToIngredient(@Nullable final PlatformResourceKey if (resource == null) { return Optional.empty(); } - return converter.convertToIngredient(resource); + return PlatformApi.INSTANCE.getIngredientConverter().convertToIngredient(resource); } private Optional> convertToClickableIngredient(final Object ingredient) { diff --git a/refinedstorage-jei-integration-fabric/src/main/java/com/refinedmods/refinedstorage/jei/fabric/JeiRefinedStoragePlugin.java b/refinedstorage-jei-integration-fabric/src/main/java/com/refinedmods/refinedstorage/jei/fabric/JeiRefinedStoragePlugin.java new file mode 100644 index 0000000..ae72857 --- /dev/null +++ b/refinedstorage-jei-integration-fabric/src/main/java/com/refinedmods/refinedstorage/jei/fabric/JeiRefinedStoragePlugin.java @@ -0,0 +1,13 @@ +package com.refinedmods.refinedstorage.jei.fabric; + +import com.refinedmods.refinedstorage2.platform.api.PlatformApi; +import com.refinedmods.refinedstorage2.platform.api.RefinedStoragePlugin; + +import static com.refinedmods.refinedstorage.jei.common.Common.init; + +public class JeiRefinedStoragePlugin implements RefinedStoragePlugin { + @Override + public void onPlatformApiAvailable(final PlatformApi platformApi) { + init(platformApi); + } +} diff --git a/refinedstorage-jei-integration-fabric/src/main/resources/fabric.mod.json b/refinedstorage-jei-integration-fabric/src/main/resources/fabric.mod.json index a020cd9..f4414c5 100644 --- a/refinedstorage-jei-integration-fabric/src/main/resources/fabric.mod.json +++ b/refinedstorage-jei-integration-fabric/src/main/resources/fabric.mod.json @@ -19,6 +19,9 @@ ], "jei_mod_plugin": [ "com.refinedmods.refinedstorage.jei.common.RefinedStorageModPlugin" + ], + "refinedstorage_plugin": [ + "com.refinedmods.refinedstorage.jei.fabric.JeiRefinedStoragePlugin" ] }, "custom": { diff --git a/refinedstorage-jei-integration-forge/src/main/java/com/refinedmods/refinedstorage/jei/forge/ModInitializer.java b/refinedstorage-jei-integration-forge/src/main/java/com/refinedmods/refinedstorage/jei/forge/ModInitializer.java index 641554b..f6a266d 100644 --- a/refinedstorage-jei-integration-forge/src/main/java/com/refinedmods/refinedstorage/jei/forge/ModInitializer.java +++ b/refinedstorage-jei-integration-forge/src/main/java/com/refinedmods/refinedstorage/jei/forge/ModInitializer.java @@ -2,12 +2,23 @@ import com.refinedmods.refinedstorage.jei.common.Common; +import com.refinedmods.refinedstorage2.platform.api.PlatformApi; import net.neoforged.bus.api.IEventBus; +import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.common.Mod; +import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; + +import static com.refinedmods.refinedstorage.jei.common.Common.init; @Mod(Common.MOD_ID) public class ModInitializer { public ModInitializer(final IEventBus eventBus) { Common.setPlatform(new ForgePlatform()); + eventBus.addListener(ModInitializer::onCommonSetup); + } + + @SubscribeEvent + public static void onCommonSetup(final FMLCommonSetupEvent e) { + init(PlatformApi.INSTANCE); } } From 76fba3eaed44f1086f1716a8b0f4b10bbc5f8ffa Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Thu, 20 Jun 2024 23:03:55 +0200 Subject: [PATCH 4/5] fix: recipe transfer being broken --- CHANGELOG.md | 1 + .../jei/common/CraftingGridRecipeTransferHandler.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83eab81..c79baa1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Fixed - Potential loading order issues on Fabric. +- Broken recipe transfer. ## [0.2.1] - 2024-06-16 diff --git a/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/CraftingGridRecipeTransferHandler.java b/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/CraftingGridRecipeTransferHandler.java index 886224d..0be287d 100644 --- a/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/CraftingGridRecipeTransferHandler.java +++ b/refinedstorage-jei-integration-common/src/main/java/com/refinedmods/refinedstorage/jei/common/CraftingGridRecipeTransferHandler.java @@ -85,7 +85,7 @@ private List> getInputs(final IRecipeSlotsView recipeSlots) { return recipeSlots.getSlotViews(RecipeIngredientRole.INPUT).stream().map(slotView -> { final List stacks = slotView.getItemStacks().collect(Collectors.toList()); prioritizeDisplayedStack(slotView, stacks); - return stacks.stream().map(ItemResource::ofItemStack).toList(); + return stacks.stream().map(ItemResource::ofItemStack).collect(Collectors.toList()); }).toList(); } From 472d5240543a61a7df67ad6f42ed6f78604a4c50 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Thu, 20 Jun 2024 21:04:32 +0000 Subject: [PATCH 5/5] chore: prepare release v0.2.2 --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c79baa1..2982d38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [0.2.2] - 2024-06-20 + ### Fixed - Potential loading order issues on Fabric. @@ -34,7 +36,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Recipe transfer integration for the Crafting Grid. - Grid / JEI search box synchronization options. -[Unreleased]: https://github.com/refinedmods/refinedstorage-jei-integration/compare/v0.2.1...HEAD +[Unreleased]: https://github.com/refinedmods/refinedstorage-jei-integration/compare/v0.2.2...HEAD + +[0.2.2]: https://github.com/refinedmods/refinedstorage-jei-integration/compare/v0.2.1...v0.2.2 [0.2.1]: https://github.com/refinedmods/refinedstorage-jei-integration/compare/v0.2.0...v0.2.1