diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ce45fae3..f525a7272 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Removed + +- The JEI integration has been removed and will be moved to an addon mod. + ## [2.0.0-milestone.3.6] - 2024-05-18 ### Added diff --git a/refinedstorage2-platform-common/build.gradle b/refinedstorage2-platform-common/build.gradle index 7773745f5..ef6c81907 100644 --- a/refinedstorage2-platform-common/build.gradle +++ b/refinedstorage2-platform-common/build.gradle @@ -1,16 +1,8 @@ archivesBaseName = 'refinedstorage2-platform-common' -repositories { - maven { - name = 'JEI' - url = "https://maven.blamejared.com/" - } -} - commonProject() dependencies { - compileOnly common.jei.api implementation project(':refinedstorage2-platform-api') implementation project(':refinedstorage2-core-api') implementation project(':refinedstorage2-resource-api') diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/Platform.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/Platform.java index 132868491..81851872f 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/Platform.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/Platform.java @@ -72,8 +72,6 @@ public interface Platform { Optional getContainedFluid(ItemStack stack); - Optional convertJeiIngredientToFluid(Object ingredient); - Optional convertToBucket(FluidResource fluidResource); TransferManager createTransferManager(AbstractContainerMenu containerMenu); diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/PlatformProxy.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/PlatformProxy.java index 21da8eb65..651d552e5 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/PlatformProxy.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/PlatformProxy.java @@ -120,11 +120,6 @@ public Optional getContainedFluid(final ItemStack stack) { return ensureLoaded().getContainedFluid(stack); } - @Override - public Optional convertJeiIngredientToFluid(final Object ingredient) { - return ensureLoaded().convertJeiIngredientToFluid(ingredient); - } - @Override public Optional convertToBucket(final FluidResource fluidResource) { return ensureLoaded().convertToBucket(fluidResource); diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/ClickableIngredient.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/ClickableIngredient.java deleted file mode 100644 index b686450c9..000000000 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/ClickableIngredient.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.common.recipemod.jei; - -import mezz.jei.api.ingredients.ITypedIngredient; -import mezz.jei.api.runtime.IClickableIngredient; -import net.minecraft.client.renderer.Rect2i; - -class ClickableIngredient implements IClickableIngredient { - private final ITypedIngredient ingredient; - private final Rect2i area; - - ClickableIngredient(final ITypedIngredient ingredient, final int x, final int y) { - this.ingredient = ingredient; - area = new Rect2i(x, y, 16, 16); - } - - @Override - public ITypedIngredient getTypedIngredient() { - return ingredient; - } - - @Override - public Rect2i getArea() { - return area; - } -} diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/CraftingGridRecipeTransferHandler.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/CraftingGridRecipeTransferHandler.java deleted file mode 100644 index e377b7a27..000000000 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/CraftingGridRecipeTransferHandler.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.common.recipemod.jei; - -import com.refinedmods.refinedstorage2.api.resource.list.ResourceList; -import com.refinedmods.refinedstorage2.platform.common.content.Menus; -import com.refinedmods.refinedstorage2.platform.common.grid.CraftingGridContainerMenu; -import com.refinedmods.refinedstorage2.platform.common.support.resource.ItemResource; - -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; -import javax.annotation.Nullable; - -import mezz.jei.api.constants.RecipeTypes; -import mezz.jei.api.gui.ingredient.IRecipeSlotView; -import mezz.jei.api.gui.ingredient.IRecipeSlotsView; -import mezz.jei.api.recipe.RecipeIngredientRole; -import mezz.jei.api.recipe.RecipeType; -import mezz.jei.api.recipe.transfer.IRecipeTransferError; -import mezz.jei.api.recipe.transfer.IRecipeTransferHandler; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.inventory.MenuType; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.CraftingRecipe; -import net.minecraft.world.item.crafting.RecipeHolder; - -class CraftingGridRecipeTransferHandler implements - IRecipeTransferHandler> { - @Override - public Class getContainerClass() { - return CraftingGridContainerMenu.class; - } - - @Override - public Optional> getMenuType() { - return Optional.of(Menus.INSTANCE.getCraftingGrid()); - } - - @Override - public RecipeType> getRecipeType() { - return RecipeTypes.CRAFTING; - } - - @Override - @Nullable - public IRecipeTransferError transferRecipe(final CraftingGridContainerMenu containerMenu, - final RecipeHolder recipe, - final IRecipeSlotsView recipeSlots, - final Player player, - final boolean maxTransfer, - final boolean doTransfer) { - if (doTransfer) { - doTransfer(recipeSlots, containerMenu); - return null; - } - final ResourceList available = containerMenu.getAvailableListForRecipeTransfer(); - final List missingSlots = findMissingSlots(recipeSlots, available); - return missingSlots.isEmpty() ? null : new MissingItemRecipeTransferError(missingSlots); - } - - private void doTransfer(final IRecipeSlotsView recipeSlots, final CraftingGridContainerMenu containerMenu) { - final List> inputs = getInputs(recipeSlots); - containerMenu.transferRecipe(inputs); - } - - private List findMissingSlots(final IRecipeSlotsView recipeSlots, final ResourceList available) { - return recipeSlots.getSlotViews(RecipeIngredientRole.INPUT).stream().filter(slotView -> { - if (slotView.isEmpty()) { - return false; - } - return !isAvailable(available, slotView); - }).toList(); - } - - private boolean isAvailable(final ResourceList available, final IRecipeSlotView slotView) { - final List possibilities = slotView.getItemStacks().toList(); - for (final ItemStack possibility : possibilities) { - final ItemResource possibilityResource = ItemResource.ofItemStack(possibility); - if (available.remove(possibilityResource, 1).isPresent()) { - return true; - } - } - return false; - } - - 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(); - }).toList(); - } - - private void prioritizeDisplayedStack(final IRecipeSlotView slotView, final List stacks) { - slotView.getDisplayedItemStack().ifPresent(displayed -> { - final int index = stacks.indexOf(displayed); - if (index > 0) { - return; - } - stacks.remove(index); - stacks.add(0, displayed); - }); - } -} diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/ExclusionZonesGuiContainerHandler.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/ExclusionZonesGuiContainerHandler.java deleted file mode 100644 index 4f16d153a..000000000 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/ExclusionZonesGuiContainerHandler.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.common.recipemod.jei; - -import com.refinedmods.refinedstorage2.platform.common.support.AbstractBaseScreen; - -import java.util.List; - -import mezz.jei.api.gui.handlers.IGuiContainerHandler; -import net.minecraft.client.renderer.Rect2i; - -class ExclusionZonesGuiContainerHandler implements IGuiContainerHandler> { - @Override - public List getGuiExtraAreas(final AbstractBaseScreen screen) { - return screen.getExclusionZones(); - } -} diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/GhostIngredientHandler.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/GhostIngredientHandler.java deleted file mode 100644 index df62f1a8e..000000000 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/GhostIngredientHandler.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.common.recipemod.jei; - -import com.refinedmods.refinedstorage2.platform.api.recipemod.IngredientConverter; -import com.refinedmods.refinedstorage2.platform.api.support.resource.PlatformResourceKey; -import com.refinedmods.refinedstorage2.platform.common.Platform; -import com.refinedmods.refinedstorage2.platform.common.support.AbstractBaseScreen; -import com.refinedmods.refinedstorage2.platform.common.support.containermenu.AbstractResourceContainerMenu; -import com.refinedmods.refinedstorage2.platform.common.support.containermenu.ResourceSlot; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import mezz.jei.api.gui.handlers.IGhostIngredientHandler; -import mezz.jei.api.ingredients.ITypedIngredient; -import net.minecraft.client.renderer.Rect2i; - -@SuppressWarnings("rawtypes") -class GhostIngredientHandler implements IGhostIngredientHandler { - private final IngredientConverter ingredientConverter; - - GhostIngredientHandler(final IngredientConverter ingredientConverter) { - this.ingredientConverter = ingredientConverter; - } - - @Override - public List> getTargetsTyped(final AbstractBaseScreen screen, - final ITypedIngredient ingredient, - final boolean doStart) { - if (screen.getMenu() instanceof AbstractResourceContainerMenu menu) { - return getTargets(screen, ingredient.getIngredient(), menu); - } - return Collections.emptyList(); - } - - private List> getTargets(final AbstractBaseScreen screen, - final I ingredient, - final AbstractResourceContainerMenu menu) { - final List> targets = new ArrayList<>(); - ingredientConverter.convertToResource(ingredient).ifPresent(resource -> { - for (final ResourceSlot slot : menu.getResourceSlots()) { - if (slot.isFilter() && slot.isValid(resource)) { - final Rect2i bounds = getBounds(screen, slot); - targets.add(new TargetImpl<>(bounds, slot.index)); - } - } - }); - return targets; - } - - private Rect2i getBounds(final AbstractBaseScreen screen, final ResourceSlot slot) { - return new Rect2i(screen.getLeftPos() + slot.x, screen.getTopPos() + slot.y, 17, 17); - } - - @Override - public void onComplete() { - // no op - } - - private class TargetImpl implements Target { - private final Rect2i area; - private final int slotIndex; - - TargetImpl(final Rect2i area, final int slotIndex) { - this.area = area; - this.slotIndex = slotIndex; - } - - @Override - public Rect2i getArea() { - return area; - } - - @Override - public void accept(final I ingredient) { - ingredientConverter.convertToResource(ingredient).ifPresent(this::accept); - } - - private void accept(final PlatformResourceKey resource) { - Platform.INSTANCE.getClientToServerCommunications().sendResourceFilterSlotChange( - resource, - slotIndex - ); - } - } -} - diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/GridGuiContainerHandler.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/GridGuiContainerHandler.java deleted file mode 100644 index a11f0ce02..000000000 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/GridGuiContainerHandler.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.common.recipemod.jei; - -import com.refinedmods.refinedstorage2.platform.api.grid.view.PlatformGridResource; -import com.refinedmods.refinedstorage2.platform.api.recipemod.IngredientConverter; -import com.refinedmods.refinedstorage2.platform.api.support.resource.PlatformResourceKey; -import com.refinedmods.refinedstorage2.platform.common.grid.screen.AbstractGridScreen; - -import java.util.Optional; - -import mezz.jei.api.gui.handlers.IGuiContainerHandler; -import mezz.jei.api.ingredients.IIngredientHelper; -import mezz.jei.api.ingredients.ITypedIngredient; -import mezz.jei.api.runtime.IClickableIngredient; -import mezz.jei.api.runtime.IIngredientManager; - -class GridGuiContainerHandler implements IGuiContainerHandler> { - private final IngredientConverter converter; - private final IIngredientManager ingredientManager; - - GridGuiContainerHandler(final IngredientConverter converter, final IIngredientManager ingredientManager) { - this.converter = converter; - this.ingredientManager = ingredientManager; - } - - @Override - public Optional> getClickableIngredientUnderMouse( - final AbstractGridScreen screen, - final double mouseX, - final double mouseY - ) { - final PlatformGridResource resource = screen.getCurrentGridResource(); - if (resource == null) { - return Optional.empty(); - } - final PlatformResourceKey underlyingResource = resource.getUnderlyingResource(); - if (underlyingResource == null) { - return Optional.empty(); - } - return converter.convertToIngredient(underlyingResource).flatMap( - ingredient -> convertToClickableIngredient(mouseX, mouseY, ingredient) - ); - } - - private Optional> convertToClickableIngredient(final double x, - final double y, - final Object ingredient) { - final IIngredientHelper helper = ingredientManager.getIngredientHelper(ingredient); - final Optional> maybeTypedIngredient = - ingredientManager.createTypedIngredient(helper.getIngredientType(), ingredient); - return maybeTypedIngredient - .map(typedIngredient -> new ClickableIngredient<>(typedIngredient, (int) x, (int) y)); - } -} diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/IngredientConvertImpl.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/IngredientConvertImpl.java deleted file mode 100644 index c9bcc7efd..000000000 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/IngredientConvertImpl.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.common.recipemod.jei; - -import com.refinedmods.refinedstorage2.platform.api.recipemod.IngredientConverter; -import com.refinedmods.refinedstorage2.platform.api.support.resource.PlatformResourceKey; -import com.refinedmods.refinedstorage2.platform.common.Platform; -import com.refinedmods.refinedstorage2.platform.common.support.resource.FluidResource; -import com.refinedmods.refinedstorage2.platform.common.support.resource.ItemResource; - -import java.util.Optional; - -import mezz.jei.api.helpers.IPlatformFluidHelper; -import net.minecraft.world.item.ItemStack; - -class IngredientConvertImpl implements IngredientConverter { - private final IPlatformFluidHelper fluidHelper; - - IngredientConvertImpl(final IPlatformFluidHelper fluidHelper) { - this.fluidHelper = fluidHelper; - } - - @Override - public Optional convertToResource(final Object ingredient) { - final var fluid = Platform.INSTANCE.convertJeiIngredientToFluid(ingredient); - if (fluid.isPresent()) { - return fluid.map(f -> f); - } - if (ingredient instanceof ItemStack itemStack) { - return Optional.of(ItemResource.ofItemStack(itemStack)); - } - return Optional.empty(); - } - - @Override - public Optional convertToIngredient(final PlatformResourceKey resource) { - if (resource instanceof ItemResource itemResource) { - return Optional.of(itemResource.toItemStack()); - } - if (resource instanceof FluidResource fluidResource) { - return Optional.of(fluidHelper.create( - fluidResource.fluid(), - fluidHelper.bucketVolume(), - fluidResource.tag() - )); - } - return Optional.empty(); - } -} diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/JeiGridSynchronizer.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/JeiGridSynchronizer.java deleted file mode 100644 index 828bf95a6..000000000 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/JeiGridSynchronizer.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.common.recipemod.jei; - -import com.refinedmods.refinedstorage2.platform.common.grid.AbstractGridSynchronizer; - -import javax.annotation.Nullable; - -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.MutableComponent; - -import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createTranslation; - -class JeiGridSynchronizer extends AbstractGridSynchronizer { - private static final MutableComponent TITLE = createTranslation("gui", "grid.synchronizer.jei"); - private static final MutableComponent TITLE_TWO_WAY = createTranslation("gui", "grid.synchronizer.jei.two_way"); - private static final Component HELP = createTranslation("gui", "grid.synchronizer.jei.help"); - private static final Component HELP_TWO_WAY = createTranslation("gui", "grid.synchronizer.jei.two_way.help"); - - private final JeiProxy jeiProxy; - private final boolean twoWay; - - JeiGridSynchronizer(final JeiProxy jeiProxy, final boolean twoWay) { - this.jeiProxy = jeiProxy; - this.twoWay = twoWay; - } - - @Override - public MutableComponent getTitle() { - return twoWay ? TITLE_TWO_WAY : TITLE; - } - - @Override - public Component getHelpText() { - return twoWay ? HELP_TWO_WAY : HELP; - } - - @Override - public void synchronizeFromGrid(final String text) { - jeiProxy.setSearchFieldText(text); - } - - @Override - @Nullable - public String getTextToSynchronizeToGrid() { - return twoWay ? jeiProxy.getSearchFieldText() : null; - } - - @Override - public int getXTexture() { - return twoWay ? 32 : 48; - } -} diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/JeiProxy.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/JeiProxy.java deleted file mode 100644 index fc1f40c9e..000000000 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/JeiProxy.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.common.recipemod.jei; - -import mezz.jei.api.runtime.IJeiRuntime; - -public class JeiProxy { - public String getSearchFieldText() { - final IJeiRuntime runtime = RefinedStorageJeiModPlugin.getRuntime(); - if (runtime == null) { - return ""; - } - return runtime.getIngredientFilter().getFilterText(); - } - - public void setSearchFieldText(final String text) { - final IJeiRuntime runtime = RefinedStorageJeiModPlugin.getRuntime(); - if (runtime != null) { - runtime.getIngredientFilter().setFilterText(text); - } - } -} diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/MissingItemRecipeTransferError.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/MissingItemRecipeTransferError.java deleted file mode 100644 index 698f0a00e..000000000 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/MissingItemRecipeTransferError.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.common.recipemod.jei; - -import java.awt.Color; -import java.util.List; - -import com.mojang.blaze3d.vertex.PoseStack; -import mezz.jei.api.gui.ingredient.IRecipeSlotView; -import mezz.jei.api.gui.ingredient.IRecipeSlotsView; -import mezz.jei.api.recipe.transfer.IRecipeTransferError; -import net.minecraft.ChatFormatting; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.gui.screens.Screen; -import net.minecraft.network.chat.Component; -import net.minecraft.util.FormattedCharSequence; - -class MissingItemRecipeTransferError implements IRecipeTransferError { - private static final Color COLOR = new Color(1.0f, 0.0f, 0.0f, 0.4f); - private static final List MISSING_MESSAGE = List.of( - Component.translatable("jei.tooltip.transfer").getVisualOrderText(), - Component.translatable("jei.tooltip.error.recipe.transfer.missing").withStyle(ChatFormatting.RED) - .getVisualOrderText() - ); - - private final List slotsWithMissingItems; - - MissingItemRecipeTransferError(final List slotsWithMissingItems) { - this.slotsWithMissingItems = slotsWithMissingItems; - } - - @Override - public Type getType() { - return Type.COSMETIC; - } - - @Override - public int getButtonHighlightColor() { - return COLOR.getRGB(); - } - - @Override - public void showError(final GuiGraphics graphics, - final int mouseX, - final int mouseY, - final IRecipeSlotsView recipeSlotsView, - final int recipeX, - final int recipeY) { - final PoseStack poseStack = graphics.pose(); - poseStack.pushPose(); - poseStack.translate(recipeX, recipeY, 0); - slotsWithMissingItems.forEach(slot -> slot.drawHighlight(graphics, COLOR.getRGB())); - poseStack.popPose(); - final Screen screen = Minecraft.getInstance().screen; - if (screen != null) { - graphics.renderTooltip(Minecraft.getInstance().font, MISSING_MESSAGE, mouseX, mouseY); - } - } -} diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/RefinedStorageJeiModPlugin.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/RefinedStorageJeiModPlugin.java deleted file mode 100644 index 5f4657f2f..000000000 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/RefinedStorageJeiModPlugin.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.common.recipemod.jei; - -import com.refinedmods.refinedstorage2.platform.api.PlatformApi; -import com.refinedmods.refinedstorage2.platform.api.recipemod.IngredientConverter; -import com.refinedmods.refinedstorage2.platform.common.grid.screen.AbstractGridScreen; -import com.refinedmods.refinedstorage2.platform.common.support.AbstractBaseScreen; - -import javax.annotation.Nullable; - -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; - -import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createIdentifier; - -@JeiPlugin -public class RefinedStorageJeiModPlugin implements IModPlugin { - private static final ResourceLocation ID = createIdentifier("plugin"); - private static final Logger LOGGER = LoggerFactory.getLogger(RefinedStorageJeiModPlugin.class); - @Nullable - private static IJeiRuntime runtime; - - @Override - public ResourceLocation getPluginUid() { - return ID; - } - - @Override - public void registerRecipeTransferHandlers(final IRecipeTransferRegistration registration) { - registration.addRecipeTransferHandler(new CraftingGridRecipeTransferHandler(), RecipeTypes.CRAFTING); - } - - @Override - public void onRuntimeAvailable(final IJeiRuntime newRuntime) { - if (runtime == null) { - initializePlatform(newRuntime.getJeiHelpers().getPlatformFluidHelper()); - } - RefinedStorageJeiModPlugin.runtime = newRuntime; - } - - @Override - public void registerGuiHandlers(final IGuiHandlerRegistration registration) { - final IngredientConverter converter = PlatformApi.INSTANCE.getIngredientConverter(); - registration.addGenericGuiContainerHandler( - AbstractBaseScreen.class, - new ResourceGuiContainerHandler(converter, registration.getJeiHelpers().getIngredientManager()) - ); - registration.addGenericGuiContainerHandler( - AbstractGridScreen.class, - new GridGuiContainerHandler(converter, registration.getJeiHelpers().getIngredientManager()) - ); - registration.addGenericGuiContainerHandler( - AbstractBaseScreen.class, - new ExclusionZonesGuiContainerHandler() - ); - registration.addGhostIngredientHandler(AbstractBaseScreen.class, new GhostIngredientHandler(converter)); - } - - @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( - createIdentifier("jei"), - new JeiGridSynchronizer(jeiProxy, false) - ); - PlatformApi.INSTANCE.getGridSynchronizerRegistry().register( - createIdentifier("jei_two_way"), - new JeiGridSynchronizer(jeiProxy, true) - ); - } - - private void registerIngredientConverters(final IPlatformFluidHelper fluidHelper) { - PlatformApi.INSTANCE.registerIngredientConverter(new IngredientConvertImpl(fluidHelper)); - } -} diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/ResourceGuiContainerHandler.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/ResourceGuiContainerHandler.java deleted file mode 100644 index a6dc2c7c1..000000000 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/ResourceGuiContainerHandler.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.common.recipemod.jei; - -import com.refinedmods.refinedstorage2.platform.api.recipemod.IngredientConverter; -import com.refinedmods.refinedstorage2.platform.api.support.resource.PlatformResourceKey; -import com.refinedmods.refinedstorage2.platform.common.support.AbstractBaseScreen; - -import java.util.Optional; -import javax.annotation.Nullable; - -import mezz.jei.api.gui.handlers.IGuiContainerHandler; -import mezz.jei.api.ingredients.IIngredientHelper; -import mezz.jei.api.ingredients.ITypedIngredient; -import mezz.jei.api.runtime.IClickableIngredient; -import mezz.jei.api.runtime.IIngredientManager; - -class ResourceGuiContainerHandler implements IGuiContainerHandler> { - private final IngredientConverter converter; - private final IIngredientManager ingredientManager; - - ResourceGuiContainerHandler(final IngredientConverter converter, - final IIngredientManager ingredientManager) { - this.converter = converter; - this.ingredientManager = ingredientManager; - } - - @Override - public Optional> getClickableIngredientUnderMouse( - final AbstractBaseScreen baseScreen, - final double mouseX, - final double mouseY - ) { - return convertToIngredient(baseScreen.getHoveredResource()).flatMap(this::convertToClickableIngredient); - } - - public Optional convertToIngredient(@Nullable final PlatformResourceKey resource) { - if (resource == null) { - return Optional.empty(); - } - return converter.convertToIngredient(resource); - } - - private Optional> convertToClickableIngredient(final Object ingredient) { - final IIngredientHelper helper = ingredientManager.getIngredientHelper(ingredient); - final Optional> maybeTypedIngredient = ingredientManager.createTypedIngredient( - helper.getIngredientType(), - ingredient - ); - return maybeTypedIngredient.map(typedIngredient -> new ClickableIngredient<>(typedIngredient, 16, 16)); - } -} diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/package-info.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/package-info.java deleted file mode 100644 index 7d9498461..000000000 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/jei/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@ParametersAreNonnullByDefault -@FieldsAndMethodsAreNonnullByDefault -package com.refinedmods.refinedstorage2.platform.common.recipemod.jei; - -import com.refinedmods.refinedstorage2.api.core.FieldsAndMethodsAreNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/lang/en_us.json b/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/lang/en_us.json index 6e06c5772..6dd9b4194 100644 --- a/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/lang/en_us.json +++ b/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/lang/en_us.json @@ -56,10 +56,6 @@ "gui.refinedstorage2.grid.synchronizer": "Synchronization mode", "gui.refinedstorage2.grid.synchronizer.off": "Off", "gui.refinedstorage2.grid.synchronizer.off.help": "Don't sync the search box text.", - "gui.refinedstorage2.grid.synchronizer.jei": "JEI", - "gui.refinedstorage2.grid.synchronizer.jei.help": "Sync the search box text to the JEI filter.", - "gui.refinedstorage2.grid.synchronizer.jei.two_way": "JEI two-way", - "gui.refinedstorage2.grid.synchronizer.jei.two_way.help": "Sync the search box text to the JEI filter, and the JEI filter to the search box text.", "gui.refinedstorage2.grid.synchronizer.rei": "REI", "gui.refinedstorage2.grid.synchronizer.rei.help": "Sync the search box text to the REI filter.", "gui.refinedstorage2.grid.synchronizer.rei.two_way": "REI two-way", diff --git a/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/TestPlatform.java b/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/TestPlatform.java index 5f1e86fef..7a0c108bd 100644 --- a/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/TestPlatform.java +++ b/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/TestPlatform.java @@ -115,11 +115,6 @@ public Optional getContainedFluid(final ItemStack stack) { throw new UnsupportedOperationException(); } - @Override - public Optional convertJeiIngredientToFluid(final Object ingredient) { - throw new UnsupportedOperationException(); - } - @Override public Optional convertToBucket(final FluidResource fluidResource) { throw new UnsupportedOperationException(); diff --git a/refinedstorage2-platform-fabric/build.gradle b/refinedstorage2-platform-fabric/build.gradle index 3b0b5bbb4..953c652fb 100644 --- a/refinedstorage2-platform-fabric/build.gradle +++ b/refinedstorage2-platform-fabric/build.gradle @@ -1,10 +1,6 @@ archivesBaseName = 'refinedstorage2-platform-fabric' repositories { - maven { - name = 'JEI' - url = "https://maven.blamejared.com/" - } maven { name = 'ModMenu' url 'https://maven.terraformersmc.com/' @@ -56,10 +52,6 @@ dependencies { modCompileOnly fabric.rei.architectury modRuntimeOnly fabric.rei.impl - modCompileOnly common.jei.api - modCompileOnly fabric.jei.api - // modRuntimeOnly fabric.jei.impl - modRuntimeOnly fabric.wthit // https://www.curseforge.com/minecraft/mc-mods/trinkets/files diff --git a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/PlatformImpl.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/PlatformImpl.java index 6757008a1..e23f64cc8 100644 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/PlatformImpl.java +++ b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/PlatformImpl.java @@ -29,7 +29,6 @@ import javax.annotation.Nullable; import com.mojang.blaze3d.platform.InputConstants; -import mezz.jei.api.fabric.ingredients.fluids.IJeiFluidIngredient; import net.fabricmc.fabric.api.entity.FakePlayer; import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents; import net.fabricmc.fabric.api.transfer.v1.context.ContainerItemContext; @@ -165,17 +164,6 @@ public Optional getContainedFluid(final ItemStack stack) { } } - @Override - public Optional convertJeiIngredientToFluid(final Object ingredient) { - if (ingredient instanceof IJeiFluidIngredient fluidIngredient) { - return Optional.of(new FluidResource( - fluidIngredient.getFluid(), - fluidIngredient.getTag().orElse(null) - )); - } - return Optional.empty(); - } - @Override public Optional convertToBucket(final FluidResource fluidResource) { final SimpleSingleStackStorage interceptingStorage = SimpleSingleStackStorage.forEmptyBucket(); diff --git a/refinedstorage2-platform-fabric/src/main/resources/fabric.mod.json b/refinedstorage2-platform-fabric/src/main/resources/fabric.mod.json index e9adbd5d4..1a27e56b0 100644 --- a/refinedstorage2-platform-fabric/src/main/resources/fabric.mod.json +++ b/refinedstorage2-platform-fabric/src/main/resources/fabric.mod.json @@ -25,9 +25,6 @@ "modmenu": [ "com.refinedmods.refinedstorage2.platform.fabric.modmenu.ModMenuApiImpl" ], - "jei_mod_plugin": [ - "com.refinedmods.refinedstorage2.platform.common.recipemod.jei.RefinedStorageJeiModPlugin" - ], "rei_client": [ "com.refinedmods.refinedstorage2.platform.fabric.recipemod.rei.RefinedStorageREIClientPlugin" ] @@ -52,7 +49,6 @@ }, "suggests": { "roughlyenoughitems": "*", - "jei": "*", "modmenu": "*" } } diff --git a/refinedstorage2-platform-forge/build.gradle b/refinedstorage2-platform-forge/build.gradle index 3e5fc0444..6a5583b47 100644 --- a/refinedstorage2-platform-forge/build.gradle +++ b/refinedstorage2-platform-forge/build.gradle @@ -1,8 +1,4 @@ repositories { - maven { - name = 'JEI' - url = "https://maven.blamejared.com/" - } maven { name = 'REI' url 'https://maven.shedaniel.me/' @@ -17,11 +13,6 @@ forgeProject("refinedstorage2", project(":refinedstorage2-platform-common"), api archivesBaseName = 'refinedstorage2-platform-forge' dependencies { - compileOnly common.jei.api - testCompileOnly common.jei.api - compileOnly forge.jei.api - runtimeOnly forge.jei.impl - compileOnly forge.rei.impl compileOnly forge.rei.architectury compileOnly forge.rei.cloth.math diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/PlatformImpl.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/PlatformImpl.java index 7c7f53d80..f5a354da3 100644 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/PlatformImpl.java +++ b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/PlatformImpl.java @@ -159,14 +159,6 @@ public Optional getContainedFluid(final ItemStack stack) { )); } - @Override - public Optional convertJeiIngredientToFluid(final Object ingredient) { - if (ingredient instanceof FluidStack fluidStack) { - return Optional.of(ofFluidStack(fluidStack)); - } - return Optional.empty(); - } - @Override public Optional convertToBucket(final FluidResource fluidResource) { return Optional.ofNullable(