From 52f57d2bbad57ee735214678696d4b76df0da411 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sat, 8 Jun 2024 23:21:12 +0200 Subject: [PATCH 1/2] chore: move REI integration to addon mod --- CHANGELOG.md | 4 + build.gradle | 1 - .../platform/api/PlatformApi.java | 6 +- .../platform/api/PlatformApiProxy.java | 8 +- .../platform/api/recipemod/package-info.java | 7 - .../RecipeModIngredientConverter.java} | 6 +- .../platform/common/PlatformApiImpl.java | 15 +- .../common/recipemod/package-info.java | 7 - ...ompositeRecipeModIngredientConverter.java} | 10 +- .../assets/refinedstorage2/lang/en_us.json | 4 - refinedstorage2-platform-fabric/build.gradle | 13 +- .../fabric/ClientModInitializerImpl.java | 31 +---- .../rei/CraftingGridTransferHandler.java | 126 ----------------- .../rei/DraggableStackVisitorImpl.java | 88 ------------ .../rei/ExclusionZonesProviderImpl.java | 18 --- .../rei/GridFocusedStackProvider.java | 35 ----- .../rei/IngredientConverterImpl.java | 41 ------ .../recipemod/rei/MissingIngredients.java | 30 ---- .../rei/RefinedStorageREIClientPlugin.java | 130 ------------------ .../recipemod/rei/ReiGridSynchronizer.java | 51 ------- .../fabric/recipemod/rei/ReiProxy.java | 24 ---- .../rei/ResourceFocusedStackProvider.java | 36 ----- .../fabric/recipemod/rei/package-info.java | 7 - .../src/main/resources/fabric.mod.json | 3 - refinedstorage2-platform-forge/build.gradle | 11 +- .../platform/forge/ClientModInitializer.java | 33 +---- .../rei/CraftingGridTransferHandler.java | 126 ----------------- .../rei/DraggableStackVisitorImpl.java | 88 ------------ .../rei/ExclusionZonesProviderImpl.java | 18 --- .../rei/GridFocusedStackProvider.java | 35 ----- .../rei/IngredientConverterImpl.java | 41 ------ .../recipemod/rei/MissingIngredients.java | 30 ---- .../rei/RefinedStorageREIClientPlugin.java | 128 ----------------- .../recipemod/rei/ReiGridSynchronizer.java | 51 ------- .../forge/recipemod/rei/ReiProxy.java | 24 ---- .../rei/ResourceFocusedStackProvider.java | 36 ----- .../forge/recipemod/rei/package-info.java | 7 - .../src/main/resources/fabric.mod.json | 19 +++ 38 files changed, 49 insertions(+), 1299 deletions(-) delete mode 100644 refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/recipemod/package-info.java rename refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/{recipemod/IngredientConverter.java => support/resource/RecipeModIngredientConverter.java} (58%) delete mode 100644 refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/package-info.java rename refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/{recipemod/CompositeIngredientConverter.java => support/resource/CompositeRecipeModIngredientConverter.java} (62%) delete mode 100644 refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/CraftingGridTransferHandler.java delete mode 100644 refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/DraggableStackVisitorImpl.java delete mode 100644 refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/ExclusionZonesProviderImpl.java delete mode 100644 refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/GridFocusedStackProvider.java delete mode 100644 refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/IngredientConverterImpl.java delete mode 100644 refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/MissingIngredients.java delete mode 100644 refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/RefinedStorageREIClientPlugin.java delete mode 100644 refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/ReiGridSynchronizer.java delete mode 100644 refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/ReiProxy.java delete mode 100644 refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/ResourceFocusedStackProvider.java delete mode 100644 refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/package-info.java delete mode 100644 refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/CraftingGridTransferHandler.java delete mode 100644 refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/DraggableStackVisitorImpl.java delete mode 100644 refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/ExclusionZonesProviderImpl.java delete mode 100644 refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/GridFocusedStackProvider.java delete mode 100644 refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/IngredientConverterImpl.java delete mode 100644 refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/MissingIngredients.java delete mode 100644 refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/RefinedStorageREIClientPlugin.java delete mode 100644 refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/ReiGridSynchronizer.java delete mode 100644 refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/ReiProxy.java delete mode 100644 refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/ResourceFocusedStackProvider.java delete mode 100644 refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/package-info.java create mode 100644 refinedstorage2-query-parser/src/main/resources/fabric.mod.json diff --git a/CHANGELOG.md b/CHANGELOG.md index c6fdda420..1cb2bd58e 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 REI integration has been removed and will be moved to an addon mod. + ## [2.0.0-milestone.3.7] - 2024-06-03 ### Removed diff --git a/build.gradle b/build.gradle index e48c4a030..cbdf95842 100644 --- a/build.gradle +++ b/build.gradle @@ -22,6 +22,5 @@ enableSonarQube("refinedmods_refinedstorage2") sonarqube { properties { property "sonar.coverage.exclusions", "refinedstorage2-platform-forge/**/*,refinedstorage2-platform-fabric/**/*,refinedstorage2-platform-common/**/*,refinedstorage2-platform-api/**/*" - property "sonar.cpd.exclusions", "refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/*,refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/*" } } diff --git a/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApi.java b/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApi.java index 61c859046..0fb88e195 100644 --- a/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApi.java +++ b/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApi.java @@ -21,7 +21,6 @@ import com.refinedmods.refinedstorage2.platform.api.grid.strategy.GridScrollingStrategy; import com.refinedmods.refinedstorage2.platform.api.grid.strategy.GridScrollingStrategyFactory; import com.refinedmods.refinedstorage2.platform.api.importer.ImporterTransferStrategyFactory; -import com.refinedmods.refinedstorage2.platform.api.recipemod.IngredientConverter; import com.refinedmods.refinedstorage2.platform.api.security.BuiltinPermissions; import com.refinedmods.refinedstorage2.platform.api.security.PlatformPermission; import com.refinedmods.refinedstorage2.platform.api.storage.StorageContainerItemHelper; @@ -38,6 +37,7 @@ import com.refinedmods.refinedstorage2.platform.api.support.network.bounditem.SlotReferenceFactory; import com.refinedmods.refinedstorage2.platform.api.support.network.bounditem.SlotReferenceProvider; import com.refinedmods.refinedstorage2.platform.api.support.registry.PlatformRegistry; +import com.refinedmods.refinedstorage2.platform.api.support.resource.RecipeModIngredientConverter; import com.refinedmods.refinedstorage2.platform.api.support.resource.ResourceFactory; import com.refinedmods.refinedstorage2.platform.api.support.resource.ResourceRendering; import com.refinedmods.refinedstorage2.platform.api.support.resource.ResourceType; @@ -165,9 +165,9 @@ GridScrollingStrategy createGridScrollingStrategy(AbstractContainerMenu containe ResourceRendering getResourceRendering(ResourceKey resource); - void registerIngredientConverter(IngredientConverter converter); + void addIngredientConverter(RecipeModIngredientConverter converter); - IngredientConverter getIngredientConverter(); + RecipeModIngredientConverter getIngredientConverter(); void addWirelessTransmitterRangeModifier(WirelessTransmitterRangeModifier rangeModifier); diff --git a/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApiProxy.java b/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApiProxy.java index ae84a0e00..abfbb6044 100644 --- a/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApiProxy.java +++ b/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApiProxy.java @@ -21,7 +21,6 @@ import com.refinedmods.refinedstorage2.platform.api.grid.strategy.GridScrollingStrategy; import com.refinedmods.refinedstorage2.platform.api.grid.strategy.GridScrollingStrategyFactory; import com.refinedmods.refinedstorage2.platform.api.importer.ImporterTransferStrategyFactory; -import com.refinedmods.refinedstorage2.platform.api.recipemod.IngredientConverter; import com.refinedmods.refinedstorage2.platform.api.security.BuiltinPermissions; import com.refinedmods.refinedstorage2.platform.api.security.PlatformPermission; import com.refinedmods.refinedstorage2.platform.api.storage.StorageContainerItemHelper; @@ -38,6 +37,7 @@ import com.refinedmods.refinedstorage2.platform.api.support.network.bounditem.SlotReferenceFactory; import com.refinedmods.refinedstorage2.platform.api.support.network.bounditem.SlotReferenceProvider; import com.refinedmods.refinedstorage2.platform.api.support.registry.PlatformRegistry; +import com.refinedmods.refinedstorage2.platform.api.support.resource.RecipeModIngredientConverter; import com.refinedmods.refinedstorage2.platform.api.support.resource.ResourceFactory; import com.refinedmods.refinedstorage2.platform.api.support.resource.ResourceRendering; import com.refinedmods.refinedstorage2.platform.api.support.resource.ResourceType; @@ -307,12 +307,12 @@ public ResourceRendering getResourceRendering(final ResourceKey resource) { } @Override - public void registerIngredientConverter(final IngredientConverter converter) { - ensureLoaded().registerIngredientConverter(converter); + public void addIngredientConverter(final RecipeModIngredientConverter converter) { + ensureLoaded().addIngredientConverter(converter); } @Override - public IngredientConverter getIngredientConverter() { + public RecipeModIngredientConverter getIngredientConverter() { return ensureLoaded().getIngredientConverter(); } diff --git a/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/recipemod/package-info.java b/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/recipemod/package-info.java deleted file mode 100644 index 5edfdcca5..000000000 --- a/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/recipemod/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@ParametersAreNonnullByDefault -@FieldsAndMethodsAreNonnullByDefault -package com.refinedmods.refinedstorage2.platform.api.recipemod; - -import com.refinedmods.refinedstorage2.api.core.FieldsAndMethodsAreNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/recipemod/IngredientConverter.java b/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/support/resource/RecipeModIngredientConverter.java similarity index 58% rename from refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/recipemod/IngredientConverter.java rename to refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/support/resource/RecipeModIngredientConverter.java index aa2ff7e8a..03d682761 100644 --- a/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/recipemod/IngredientConverter.java +++ b/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/support/resource/RecipeModIngredientConverter.java @@ -1,13 +1,11 @@ -package com.refinedmods.refinedstorage2.platform.api.recipemod; - -import com.refinedmods.refinedstorage2.platform.api.support.resource.PlatformResourceKey; +package com.refinedmods.refinedstorage2.platform.api.support.resource; import java.util.Optional; import org.apiguardian.api.API; @API(status = API.Status.STABLE, since = "2.0.0-milestone.2.5") -public interface IngredientConverter { +public interface RecipeModIngredientConverter { Optional convertToResource(Object ingredient); Optional convertToIngredient(PlatformResourceKey resource); diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/PlatformApiImpl.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/PlatformApiImpl.java index 1af68b0b1..14b6c9380 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/PlatformApiImpl.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/PlatformApiImpl.java @@ -25,7 +25,6 @@ import com.refinedmods.refinedstorage2.platform.api.grid.strategy.GridScrollingStrategy; import com.refinedmods.refinedstorage2.platform.api.grid.strategy.GridScrollingStrategyFactory; import com.refinedmods.refinedstorage2.platform.api.importer.ImporterTransferStrategyFactory; -import com.refinedmods.refinedstorage2.platform.api.recipemod.IngredientConverter; import com.refinedmods.refinedstorage2.platform.api.security.BuiltinPermissions; import com.refinedmods.refinedstorage2.platform.api.security.PlatformPermission; import com.refinedmods.refinedstorage2.platform.api.storage.StorageContainerItemHelper; @@ -43,6 +42,7 @@ import com.refinedmods.refinedstorage2.platform.api.support.network.bounditem.SlotReferenceFactory; import com.refinedmods.refinedstorage2.platform.api.support.network.bounditem.SlotReferenceProvider; import com.refinedmods.refinedstorage2.platform.api.support.registry.PlatformRegistry; +import com.refinedmods.refinedstorage2.platform.api.support.resource.RecipeModIngredientConverter; import com.refinedmods.refinedstorage2.platform.api.support.resource.ResourceFactory; import com.refinedmods.refinedstorage2.platform.api.support.resource.ResourceRendering; import com.refinedmods.refinedstorage2.platform.api.support.resource.ResourceType; @@ -56,7 +56,6 @@ import com.refinedmods.refinedstorage2.platform.common.grid.strategy.CompositeGridExtractionStrategy; import com.refinedmods.refinedstorage2.platform.common.grid.strategy.CompositeGridInsertionStrategy; import com.refinedmods.refinedstorage2.platform.common.grid.strategy.CompositeGridScrollingStrategy; -import com.refinedmods.refinedstorage2.platform.common.recipemod.CompositeIngredientConverter; import com.refinedmods.refinedstorage2.platform.common.security.BuiltinPermission; import com.refinedmods.refinedstorage2.platform.common.storage.ClientStorageRepository; import com.refinedmods.refinedstorage2.platform.common.storage.StorageContainerItemHelperImpl; @@ -73,6 +72,7 @@ import com.refinedmods.refinedstorage2.platform.common.support.network.bounditem.InventorySlotReference; import com.refinedmods.refinedstorage2.platform.common.support.network.bounditem.NetworkBoundItemHelperImpl; import com.refinedmods.refinedstorage2.platform.common.support.registry.PlatformRegistryImpl; +import com.refinedmods.refinedstorage2.platform.common.support.resource.CompositeRecipeModIngredientConverter; import com.refinedmods.refinedstorage2.platform.common.support.resource.FluidResourceFactory; import com.refinedmods.refinedstorage2.platform.common.support.resource.ItemResourceFactory; import com.refinedmods.refinedstorage2.platform.common.upgrade.BuiltinUpgradeDestinationsImpl; @@ -147,7 +147,8 @@ public class PlatformApiImpl implements PlatformApi { new CompositeStorageMonitorInsertionStrategy(); private final CompositeStorageMonitorExtractionStrategy storageMonitorExtractionStrategy = new CompositeStorageMonitorExtractionStrategy(); - private final CompositeIngredientConverter compositeConverter = new CompositeIngredientConverter(); + private final CompositeRecipeModIngredientConverter ingredientConverter = + new CompositeRecipeModIngredientConverter(); private final StorageContainerItemHelper storageContainerItemHelper = new StorageContainerItemHelperImpl(); private final List gridInsertionStrategyFactories = new ArrayList<>(); private final GridInsertionHintsImpl gridInsertionHints = new GridInsertionHintsImpl( @@ -463,13 +464,13 @@ public ResourceRendering getResourceRendering(final ResourceKey resource) { } @Override - public void registerIngredientConverter(final IngredientConverter converter) { - this.compositeConverter.addConverter(converter); + public void addIngredientConverter(final RecipeModIngredientConverter converter) { + ingredientConverter.addConverter(converter); } @Override - public IngredientConverter getIngredientConverter() { - return compositeConverter; + public RecipeModIngredientConverter getIngredientConverter() { + return ingredientConverter; } @Override diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/package-info.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/package-info.java deleted file mode 100644 index 51b4e8ecf..000000000 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@ParametersAreNonnullByDefault -@FieldsAndMethodsAreNonnullByDefault -package com.refinedmods.refinedstorage2.platform.common.recipemod; - -import com.refinedmods.refinedstorage2.api.core.FieldsAndMethodsAreNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/CompositeIngredientConverter.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/support/resource/CompositeRecipeModIngredientConverter.java similarity index 62% rename from refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/CompositeIngredientConverter.java rename to refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/support/resource/CompositeRecipeModIngredientConverter.java index fec6421ed..cdbd95455 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/recipemod/CompositeIngredientConverter.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/support/resource/CompositeRecipeModIngredientConverter.java @@ -1,14 +1,14 @@ -package com.refinedmods.refinedstorage2.platform.common.recipemod; +package com.refinedmods.refinedstorage2.platform.common.support.resource; -import com.refinedmods.refinedstorage2.platform.api.recipemod.IngredientConverter; import com.refinedmods.refinedstorage2.platform.api.support.resource.PlatformResourceKey; +import com.refinedmods.refinedstorage2.platform.api.support.resource.RecipeModIngredientConverter; import java.util.Collection; import java.util.HashSet; import java.util.Optional; -public class CompositeIngredientConverter implements IngredientConverter { - private final Collection converters = new HashSet<>(); +public class CompositeRecipeModIngredientConverter implements RecipeModIngredientConverter { + private final Collection converters = new HashSet<>(); @Override public Optional convertToResource(final Object ingredient) { @@ -24,7 +24,7 @@ public Optional convertToIngredient(final PlatformResourceKey resource) .findFirst(); } - public void addConverter(final IngredientConverter converter) { + public void addConverter(final RecipeModIngredientConverter converter) { this.converters.add(converter); } } 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 6dd9b4194..d607aef97 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.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", - "gui.refinedstorage2.grid.synchronizer.rei.two_way.help": "Sync the search box text to the REI filter, and the REI filter to the search box text.", "gui.refinedstorage2.grid.resource_type": "Resource type", "gui.refinedstorage2.grid.resource_type.all": "All", "gui.refinedstorage2.grid.resource_type.help": "Filter specific resource types.", diff --git a/refinedstorage2-platform-fabric/build.gradle b/refinedstorage2-platform-fabric/build.gradle index 953c652fb..b2614b15f 100644 --- a/refinedstorage2-platform-fabric/build.gradle +++ b/refinedstorage2-platform-fabric/build.gradle @@ -6,7 +6,7 @@ repositories { url 'https://maven.terraformersmc.com/' } maven { - name = 'Cloth Config, REI' + name = 'Cloth Config' url 'https://maven.shedaniel.me/' } maven { @@ -41,17 +41,6 @@ dependencies { modImplementation fabric.modmenu - modCompileOnly(common.rei.api) { - exclude(group: 'me.shedaniel.cloth') - exclude(group: 'dev.architectury') - } - modCompileOnly(fabric.rei.plugin) { - exclude(group: 'me.shedaniel.cloth') - exclude(group: 'dev.architectury') - } - modCompileOnly fabric.rei.architectury - modRuntimeOnly fabric.rei.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/ClientModInitializerImpl.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/ClientModInitializerImpl.java index 44e702874..495897fc5 100644 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/ClientModInitializerImpl.java +++ b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/ClientModInitializerImpl.java @@ -1,7 +1,6 @@ package com.refinedmods.refinedstorage2.platform.fabric; import com.refinedmods.refinedstorage2.api.resource.ResourceAmount; -import com.refinedmods.refinedstorage2.platform.api.PlatformApi; import com.refinedmods.refinedstorage2.platform.api.support.HelpTooltipComponent; import com.refinedmods.refinedstorage2.platform.api.upgrade.AbstractUpgradeItem; import com.refinedmods.refinedstorage2.platform.common.AbstractClientModInitializer; @@ -33,9 +32,6 @@ import com.refinedmods.refinedstorage2.platform.fabric.packet.s2c.ResourceSlotUpdatePacket; import com.refinedmods.refinedstorage2.platform.fabric.packet.s2c.StorageInfoResponsePacket; import com.refinedmods.refinedstorage2.platform.fabric.packet.s2c.WirelessTransmitterRangePacket; -import com.refinedmods.refinedstorage2.platform.fabric.recipemod.rei.RefinedStorageREIClientPlugin; -import com.refinedmods.refinedstorage2.platform.fabric.recipemod.rei.ReiGridSynchronizer; -import com.refinedmods.refinedstorage2.platform.fabric.recipemod.rei.ReiProxy; import com.refinedmods.refinedstorage2.platform.fabric.storage.diskdrive.DiskDriveBlockEntityRendererImpl; import com.refinedmods.refinedstorage2.platform.fabric.storage.diskdrive.DiskDriveUnbakedModel; import com.refinedmods.refinedstorage2.platform.fabric.storage.portablegrid.PortableGridBlockEntityRendererImpl; @@ -53,7 +49,6 @@ import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.fabricmc.fabric.api.client.rendering.v1.TooltipComponentCallback; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.KeyMapping; import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.client.gui.screens.Screen; @@ -96,7 +91,7 @@ public > void }); registerKeyBindings(); registerModelPredicates(); - registerGridSynchronizers(); + registerBaseGridSynchronizer(); registerResourceRendering(); registerAlternativeGridHints(); registerItemProperties(); @@ -433,30 +428,6 @@ private void registerModelPredicates() { )); } - private void registerGridSynchronizers() { - registerBaseGridSynchronizer(); - final FabricLoader loader = FabricLoader.getInstance(); - if (loader.isModLoaded("roughlyenoughitems")) { - registerReiGridSynchronizers(); - } - } - - private void registerReiGridSynchronizers() { - LOGGER.debug("Enabling REI grid synchronizers"); - // This is so the ingredient converters are only registered once - // see https://github.com/refinedmods/refinedstorage2/pull/302#discussion_r1070015672 - RefinedStorageREIClientPlugin.registerIngredientConverters(); - final ReiProxy reiProxy = new ReiProxy(); - PlatformApi.INSTANCE.getGridSynchronizerRegistry().register( - createIdentifier("rei"), - new ReiGridSynchronizer(reiProxy, false) - ); - PlatformApi.INSTANCE.getGridSynchronizerRegistry().register( - createIdentifier("rei_two_way"), - new ReiGridSynchronizer(reiProxy, true) - ); - } - private void registerItemProperties() { ItemProperties.register( Items.INSTANCE.getWirelessGrid(), diff --git a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/CraftingGridTransferHandler.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/CraftingGridTransferHandler.java deleted file mode 100644 index 3b8878195..000000000 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/CraftingGridTransferHandler.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.fabric.recipemod.rei; - -import com.refinedmods.refinedstorage2.api.resource.list.ResourceList; -import com.refinedmods.refinedstorage2.platform.common.grid.CraftingGridContainerMenu; -import com.refinedmods.refinedstorage2.platform.common.support.resource.ItemResource; - -import java.awt.Color; -import java.util.List; - -import com.mojang.blaze3d.vertex.PoseStack; -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.client.gui.widgets.Slot; -import me.shedaniel.rei.api.client.gui.widgets.Widget; -import me.shedaniel.rei.api.client.registry.transfer.TransferHandler; -import me.shedaniel.rei.api.client.registry.transfer.TransferHandlerRenderer; -import me.shedaniel.rei.api.common.category.CategoryIdentifier; -import me.shedaniel.rei.api.common.entry.EntryIngredient; -import me.shedaniel.rei.api.common.entry.EntryStack; -import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; -import me.shedaniel.rei.api.common.util.CollectionUtils; -import me.shedaniel.rei.plugin.common.displays.crafting.DefaultCraftingDisplay; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.world.item.ItemStack; - -class CraftingGridTransferHandler implements TransferHandler { - private static final Color MISSING_COLOR = new Color(1.0f, 0.0f, 0.0f, 0.4f); - private static final CategoryIdentifier CRAFTING = CategoryIdentifier.of("minecraft", "plugins/crafting"); - - @Override - public Result handle(final Context context) { - if (!(context.getMenu() instanceof CraftingGridContainerMenu containerMenu) - || !context.getDisplay().getCategoryIdentifier().equals(CRAFTING) - || !(context.getDisplay() instanceof DefaultCraftingDisplay defaultCraftingDisplay)) { - return Result.createNotApplicable(); - } - final List ingredients = defaultCraftingDisplay.getOrganisedInputEntries(3, 3); - if (context.isActuallyCrafting()) { - doTransfer(ingredients, containerMenu); - return Result.createSuccessful().blocksFurtherHandling(); - } - final ResourceList available = containerMenu.getAvailableListForRecipeTransfer(); - final MissingIngredients missingIngredients = findMissingIngredients(ingredients, available); - if (missingIngredients.isEmpty()) { - return Result.createSuccessful().blocksFurtherHandling(); - } - return Result.createSuccessful() - .color(MISSING_COLOR.getRGB()) - .tooltipMissing(missingIngredients.getIngredients()) - .renderer(createMissingItemsRenderer(missingIngredients)) - .blocksFurtherHandling(); - } - - private void doTransfer(final List ingredients, final CraftingGridContainerMenu containerMenu) { - final List> inputs = getInputs(ingredients); - containerMenu.transferRecipe(inputs); - } - - private MissingIngredients findMissingIngredients(final List ingredients, - final ResourceList available) { - final MissingIngredients missingIngredients = new MissingIngredients(); - for (int i = 0; i < ingredients.size(); ++i) { - final EntryIngredient ingredient = ingredients.get(i); - if (ingredient.isEmpty()) { - continue; - } - if (!isAvailable(available, ingredient)) { - missingIngredients.addIngredient(ingredient, i); - } - } - return missingIngredients; - } - - private boolean isAvailable(final ResourceList available, final EntryIngredient ingredient) { - final List possibilities = convertIngredientToItemStacks(ingredient); - 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 List ingredients) { - return ingredients.stream() - .map(this::convertIngredientToItemStacks) - .map(list -> list.stream().map(ItemResource::ofItemStack).toList()) - .toList(); - } - - private List convertIngredientToItemStacks(final EntryIngredient ingredient) { - return CollectionUtils., ItemStack>filterAndMap( - ingredient, - stack -> stack.getType() == VanillaEntryTypes.ITEM, - EntryStack::castValue - ); - } - - private TransferHandlerRenderer createMissingItemsRenderer(final MissingIngredients missingIngredients) { - return (graphics, mouseX, mouseY, delta, widgets, bounds, display) -> { - int index = 0; - for (final Widget widget : widgets) { - if (widget instanceof Slot slot - && slot.getNoticeMark() == Slot.INPUT - && missingIngredients.isMissing(index++)) { - renderMissingItemOverlay(graphics, slot); - } - } - }; - } - - private void renderMissingItemOverlay(final GuiGraphics graphics, final Slot slot) { - final PoseStack poseStack = graphics.pose(); - poseStack.pushPose(); - poseStack.translate(0, 0, 400); - final Rectangle innerBounds = slot.getInnerBounds(); - graphics.fill( - innerBounds.x, - innerBounds.y, - innerBounds.getMaxX(), - innerBounds.getMaxY(), - MISSING_COLOR.getRGB() - ); - poseStack.popPose(); - } -} diff --git a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/DraggableStackVisitorImpl.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/DraggableStackVisitorImpl.java deleted file mode 100644 index f8dd525f8..000000000 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/DraggableStackVisitorImpl.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.fabric.recipemod.rei; - -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.List; -import java.util.stream.Stream; - -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.client.gui.drag.DraggableStack; -import me.shedaniel.rei.api.client.gui.drag.DraggableStackVisitor; -import me.shedaniel.rei.api.client.gui.drag.DraggedAcceptorResult; -import me.shedaniel.rei.api.client.gui.drag.DraggingContext; -import net.minecraft.client.gui.screens.Screen; - -class DraggableStackVisitorImpl - implements DraggableStackVisitor> { - private final IngredientConverter ingredientConverter; - - DraggableStackVisitorImpl(final IngredientConverter ingredientConverter) { - this.ingredientConverter = ingredientConverter; - } - - @Override - public Stream getDraggableAcceptingBounds( - final DraggingContext> context, - final DraggableStack stack - ) { - final var screen = context.getScreen(); - final var menu = screen.getMenu(); - final var value = stack.getStack().getValue(); - final List bounds = new ArrayList<>(); - ingredientConverter.convertToResource(value).ifPresent(resource -> { - for (final ResourceSlot slot : menu.getResourceSlots()) { - if (slot.isFilter() && slot.isValid(resource)) { - bounds.add(BoundsProvider.ofRectangle(toRectangle(screen, slot))); - } - } - }); - return bounds.stream(); - } - - @Override - public DraggedAcceptorResult acceptDraggedStack( - final DraggingContext> context, - final DraggableStack stack - ) { - final var screen = context.getScreen(); - final var menu = screen.getMenu(); - final Object value = stack.getStack().getValue(); - return ingredientConverter.convertToResource(value) - .map(resource -> accept(context, menu, screen, resource)) - .orElse(DraggedAcceptorResult.PASS); - } - - private DraggedAcceptorResult accept( - final DraggingContext> context, - final AbstractResourceContainerMenu menu, - final AbstractBaseScreen screen, - final PlatformResourceKey resource - ) { - for (final ResourceSlot slot : menu.getResourceSlots()) { - final Rectangle slotBounds = toRectangle(screen, slot); - if (!slotBounds.contains(context.getCurrentPosition())) { - continue; - } - Platform.INSTANCE.getClientToServerCommunications().sendResourceFilterSlotChange(resource, slot.index); - return DraggedAcceptorResult.ACCEPTED; - } - return DraggedAcceptorResult.PASS; - } - - private static Rectangle toRectangle(final AbstractBaseScreen screen, - final ResourceSlot slot) { - return new Rectangle(screen.getLeftPos() + slot.x, screen.getTopPos() + slot.y, 18, 18); - } - - @Override - public boolean isHandingScreen(final R screen) { - return screen instanceof AbstractBaseScreen - && ((AbstractBaseScreen) screen).getMenu() instanceof AbstractResourceContainerMenu; - } -} diff --git a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/ExclusionZonesProviderImpl.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/ExclusionZonesProviderImpl.java deleted file mode 100644 index 822a1532c..000000000 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/ExclusionZonesProviderImpl.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.fabric.recipemod.rei; - -import com.refinedmods.refinedstorage2.platform.common.support.AbstractBaseScreen; - -import java.util.Collection; -import java.util.stream.Collectors; - -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.client.registry.screen.ExclusionZonesProvider; - -class ExclusionZonesProviderImpl implements ExclusionZonesProvider> { - @Override - public Collection provide(final AbstractBaseScreen screen) { - return screen.getExclusionZones().stream() - .map(rect -> new Rectangle(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight())) - .collect(Collectors.toSet()); - } -} diff --git a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/GridFocusedStackProvider.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/GridFocusedStackProvider.java deleted file mode 100644 index 4ce3cb754..000000000 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/GridFocusedStackProvider.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.fabric.recipemod.rei; - -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 dev.architectury.event.CompoundEventResult; -import me.shedaniel.math.Point; -import me.shedaniel.rei.api.client.registry.screen.FocusedStackProvider; -import me.shedaniel.rei.api.common.entry.EntryStack; -import net.minecraft.client.gui.screens.Screen; - -class GridFocusedStackProvider implements FocusedStackProvider { - private final IngredientConverter converter; - - GridFocusedStackProvider(final IngredientConverter converter) { - this.converter = converter; - } - - @Override - public CompoundEventResult> provide(final Screen screen, final Point mouse) { - if (!(screen instanceof AbstractGridScreen gridScreen)) { - return CompoundEventResult.pass(); - } - final PlatformResourceKey resource = gridScreen.getCurrentResource(); - if (resource == null) { - return CompoundEventResult.pass(); - } - final Object converted = converter.convertToIngredient(resource).orElse(null); - if (converted instanceof EntryStack stack) { - return CompoundEventResult.interruptTrue(stack); - } - return CompoundEventResult.pass(); - } -} diff --git a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/IngredientConverterImpl.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/IngredientConverterImpl.java deleted file mode 100644 index 454255833..000000000 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/IngredientConverterImpl.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.fabric.recipemod.rei; - -import com.refinedmods.refinedstorage2.platform.api.recipemod.IngredientConverter; -import com.refinedmods.refinedstorage2.platform.api.support.resource.PlatformResourceKey; -import com.refinedmods.refinedstorage2.platform.common.support.resource.FluidResource; -import com.refinedmods.refinedstorage2.platform.common.support.resource.ItemResource; - -import java.util.Optional; - -import dev.architectury.fluid.FluidStack; -import me.shedaniel.rei.api.common.util.EntryStacks; -import net.minecraft.world.item.ItemStack; - -class IngredientConverterImpl implements IngredientConverter { - @Override - public Optional convertToResource(final Object ingredient) { - if (ingredient instanceof FluidStack fluidStack) { - return Optional.of(new FluidResource(fluidStack.getFluid(), fluidStack.getTag())); - } - 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(EntryStacks.of(itemResource.toItemStack())); - } - if (resource instanceof FluidResource fluidResource) { - final FluidStack fluidStack = FluidStack.create( - fluidResource.fluid(), - FluidStack.bucketAmount(), - fluidResource.tag() - ); - return Optional.of(EntryStacks.of(fluidStack)); - } - return Optional.empty(); - } -} diff --git a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/MissingIngredients.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/MissingIngredients.java deleted file mode 100644 index 6503aefaa..000000000 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/MissingIngredients.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.fabric.recipemod.rei; - -import java.util.ArrayList; -import java.util.List; - -import it.unimi.dsi.fastutil.ints.IntOpenHashSet; -import it.unimi.dsi.fastutil.ints.IntSet; -import me.shedaniel.rei.api.common.entry.EntryIngredient; - -class MissingIngredients { - private final List ingredients = new ArrayList<>(); - private final IntSet indices = new IntOpenHashSet(); - - boolean isEmpty() { - return indices.isEmpty(); - } - - void addIngredient(final EntryIngredient ingredient, final int slotIndex) { - ingredients.add(ingredient); - indices.add(slotIndex); - } - - List getIngredients() { - return ingredients; - } - - boolean isMissing(final int slotIndex) { - return indices.contains(slotIndex); - } -} diff --git a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/RefinedStorageREIClientPlugin.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/RefinedStorageREIClientPlugin.java deleted file mode 100644 index a61e0be9f..000000000 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/RefinedStorageREIClientPlugin.java +++ /dev/null @@ -1,130 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.fabric.recipemod.rei; - -import com.refinedmods.refinedstorage2.platform.api.PlatformApi; -import com.refinedmods.refinedstorage2.platform.api.recipemod.IngredientConverter; -import com.refinedmods.refinedstorage2.platform.common.content.BlockColorMap; -import com.refinedmods.refinedstorage2.platform.common.content.Blocks; -import com.refinedmods.refinedstorage2.platform.common.content.ContentIds; -import com.refinedmods.refinedstorage2.platform.common.content.Items; -import com.refinedmods.refinedstorage2.platform.common.content.Tags; -import com.refinedmods.refinedstorage2.platform.common.controller.ControllerBlockItem; -import com.refinedmods.refinedstorage2.platform.common.support.AbstractBaseScreen; - -import java.util.function.Supplier; - -import me.shedaniel.rei.api.client.plugins.REIClientPlugin; -import me.shedaniel.rei.api.client.registry.entry.CollapsibleEntryRegistry; -import me.shedaniel.rei.api.client.registry.screen.ExclusionZones; -import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry; -import me.shedaniel.rei.api.client.registry.transfer.TransferHandlerRegistry; -import me.shedaniel.rei.api.common.entry.comparison.ItemComparatorRegistry; -import me.shedaniel.rei.api.common.util.EntryIngredients; -import me.shedaniel.rei.api.common.util.EntryStacks; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.TagKey; -import net.minecraft.world.item.Item; - -import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createIdentifier; -import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createTranslation; - -@Environment(EnvType.CLIENT) -public class RefinedStorageREIClientPlugin implements REIClientPlugin { - @Override - public void registerScreens(final ScreenRegistry registry) { - final IngredientConverter converter = PlatformApi.INSTANCE.getIngredientConverter(); - registry.registerFocusedStack(new GridFocusedStackProvider(converter)); - registry.registerFocusedStack(new ResourceFocusedStackProvider(converter)); - registry.registerDraggableStackVisitor(new DraggableStackVisitorImpl(converter)); - } - - @Override - public void registerTransferHandlers(final TransferHandlerRegistry registry) { - registry.register(new CraftingGridTransferHandler()); - } - - public static void registerIngredientConverters() { - PlatformApi.INSTANCE.registerIngredientConverter(new IngredientConverterImpl()); - } - - @Override - public void registerItemComparators(final ItemComparatorRegistry registry) { - Items.INSTANCE.getControllers().stream().map(Supplier::get).forEach(registry::registerNbt); - } - - @SuppressWarnings("UnstableApiUsage") - @Override - public void registerCollapsibleEntries(final CollapsibleEntryRegistry registry) { - groupItems(registry, Blocks.INSTANCE.getCable(), ContentIds.CABLE, Tags.CABLES); - groupItems(registry, Blocks.INSTANCE.getGrid(), ContentIds.GRID, Tags.GRIDS); - groupItems(registry, Blocks.INSTANCE.getCraftingGrid(), ContentIds.CRAFTING_GRID, Tags.CRAFTING_GRIDS); - groupItems(registry, Blocks.INSTANCE.getImporter(), ContentIds.IMPORTER, Tags.IMPORTERS); - groupItems(registry, Blocks.INSTANCE.getExporter(), ContentIds.EXPORTER, Tags.EXPORTERS); - groupItems(registry, Blocks.INSTANCE.getDetector(), ContentIds.DETECTOR, Tags.DETECTORS); - groupItems(registry, Blocks.INSTANCE.getDestructor(), ContentIds.DESTRUCTOR, Tags.DESTRUCTORS); - groupItems(registry, Blocks.INSTANCE.getConstructor(), ContentIds.CONSTRUCTOR, Tags.CONSTRUCTORS); - groupItems(registry, Blocks.INSTANCE.getExternalStorage(), ContentIds.EXTERNAL_STORAGE, Tags.EXTERNAL_STORAGES); - groupItems(registry, Blocks.INSTANCE.getController(), ContentIds.CONTROLLER, Tags.CONTROLLERS); - registry.group( - createIdentifier("fully_charged_controller"), - createTranslation("block", "controller.rei_fully_charged"), - Items.INSTANCE.getControllers() - .stream() - .map(Supplier::get) - .map(ControllerBlockItem::createAtEnergyCapacity) - .map(EntryStacks::of) - .toList() - ); - groupItems( - registry, - Blocks.INSTANCE.getCreativeController(), - ContentIds.CREATIVE_CONTROLLER, - Tags.CREATIVE_CONTROLLERS - ); - groupItems( - registry, - Blocks.INSTANCE.getWirelessTransmitter(), - ContentIds.WIRELESS_TRANSMITTER, - Tags.WIRELESS_TRANSMITTERS - ); - groupItems(registry, Blocks.INSTANCE.getNetworkReceiver(), ContentIds.NETWORK_RECEIVER, Tags.NETWORK_RECEIVERS); - groupItems( - registry, - Blocks.INSTANCE.getNetworkTransmitter(), - ContentIds.NETWORK_TRANSMITTER, - Tags.NETWORK_TRANSMITTERS - ); - groupItems( - registry, - Blocks.INSTANCE.getSecurityManager(), - ContentIds.SECURITY_MANAGER, - Tags.SECURITY_MANAGERS - ); - groupItems( - registry, - Blocks.INSTANCE.getRelay(), - ContentIds.RELAY, - Tags.RELAYS - ); - } - - @Override - public void registerExclusionZones(final ExclusionZones zones) { - zones.register(AbstractBaseScreen.class, new ExclusionZonesProviderImpl()); - } - - @SuppressWarnings("UnstableApiUsage") - private static void groupItems( - final CollapsibleEntryRegistry registry, - final BlockColorMap blocks, - final ResourceLocation itemIdentifier, - final TagKey tag - ) { - registry.group( - itemIdentifier, - blocks.getDefault().getName(), - EntryIngredients.ofItemTag(tag) - ); - } -} diff --git a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/ReiGridSynchronizer.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/ReiGridSynchronizer.java deleted file mode 100644 index 1fcd30c3c..000000000 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/ReiGridSynchronizer.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.fabric.recipemod.rei; - -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; - -public class ReiGridSynchronizer extends AbstractGridSynchronizer { - private static final MutableComponent TITLE = createTranslation("gui", "grid.synchronizer.rei"); - private static final MutableComponent TITLE_TWO_WAY = createTranslation("gui", "grid.synchronizer.rei.two_way"); - private static final Component HELP = createTranslation("gui", "grid.synchronizer.rei.help"); - private static final Component HELP_TWO_WAY = createTranslation("gui", "grid.synchronizer.rei.two_way.help"); - - private final ReiProxy reiProxy; - private final boolean twoWay; - - public ReiGridSynchronizer(final ReiProxy reiProxy, final boolean twoWay) { - this.reiProxy = reiProxy; - 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) { - reiProxy.setSearchFieldText(text); - } - - @Override - @Nullable - public String getTextToSynchronizeToGrid() { - return twoWay ? reiProxy.getSearchFieldText() : null; - } - - @Override - public int getXTexture() { - return twoWay ? 32 : 48; - } -} diff --git a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/ReiProxy.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/ReiProxy.java deleted file mode 100644 index 444926a43..000000000 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/ReiProxy.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.fabric.recipemod.rei; - -import javax.annotation.Nullable; - -import me.shedaniel.rei.api.client.REIRuntime; -import me.shedaniel.rei.api.client.gui.widgets.TextField; - -public class ReiProxy { - @Nullable - public String getSearchFieldText() { - final TextField field = REIRuntime.getInstance().getSearchTextField(); - if (field != null) { - return field.getText(); - } - return null; - } - - public void setSearchFieldText(final String text) { - final TextField field = REIRuntime.getInstance().getSearchTextField(); - if (field != null) { - field.setText(text); - } - } -} diff --git a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/ResourceFocusedStackProvider.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/ResourceFocusedStackProvider.java deleted file mode 100644 index b69667c36..000000000 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/ResourceFocusedStackProvider.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.fabric.recipemod.rei; - -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 dev.architectury.event.CompoundEventResult; -import me.shedaniel.math.Point; -import me.shedaniel.rei.api.client.registry.screen.FocusedStackProvider; -import me.shedaniel.rei.api.common.entry.EntryStack; -import net.minecraft.client.gui.screens.Screen; - -class ResourceFocusedStackProvider implements FocusedStackProvider { - private final IngredientConverter converter; - - ResourceFocusedStackProvider(final IngredientConverter converter) { - this.converter = converter; - } - - @Override - public CompoundEventResult> provide(final Screen screen, final Point mouse) { - if (!(screen instanceof AbstractBaseScreen baseScreen)) { - return CompoundEventResult.pass(); - } - final PlatformResourceKey hoveredResource = baseScreen.getHoveredResource(); - if (hoveredResource == null) { - return CompoundEventResult.pass(); - } - final Object converted = converter.convertToIngredient(hoveredResource).orElse(null); - if (converted instanceof EntryStack stack) { - return CompoundEventResult.interruptTrue(stack); - } - return CompoundEventResult.pass(); - } -} - diff --git a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/package-info.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/package-info.java deleted file mode 100644 index 54b746da3..000000000 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/recipemod/rei/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@ParametersAreNonnullByDefault -@FieldsAndMethodsAreNonnullByDefault -package com.refinedmods.refinedstorage2.platform.fabric.recipemod.rei; - -import com.refinedmods.refinedstorage2.api.core.FieldsAndMethodsAreNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/refinedstorage2-platform-fabric/src/main/resources/fabric.mod.json b/refinedstorage2-platform-fabric/src/main/resources/fabric.mod.json index 1a27e56b0..a2c72f825 100644 --- a/refinedstorage2-platform-fabric/src/main/resources/fabric.mod.json +++ b/refinedstorage2-platform-fabric/src/main/resources/fabric.mod.json @@ -24,9 +24,6 @@ ], "modmenu": [ "com.refinedmods.refinedstorage2.platform.fabric.modmenu.ModMenuApiImpl" - ], - "rei_client": [ - "com.refinedmods.refinedstorage2.platform.fabric.recipemod.rei.RefinedStorageREIClientPlugin" ] }, "custom": { diff --git a/refinedstorage2-platform-forge/build.gradle b/refinedstorage2-platform-forge/build.gradle index 6a5583b47..238158255 100644 --- a/refinedstorage2-platform-forge/build.gradle +++ b/refinedstorage2-platform-forge/build.gradle @@ -1,9 +1,6 @@ repositories { maven { - name = 'REI' - url 'https://maven.shedaniel.me/' - } - maven { + name = 'Curios' url = "https://maven.theillusivec4.top/" } } @@ -13,12 +10,6 @@ forgeProject("refinedstorage2", project(":refinedstorage2-platform-common"), api archivesBaseName = 'refinedstorage2-platform-forge' dependencies { - compileOnly forge.rei.impl - compileOnly forge.rei.architectury - compileOnly forge.rei.cloth.math -// runtimeOnly forge.rei.impl -// runtimeOnly forge.rei.architectury - runtimeOnly "top.theillusivec4.curios:curios-neoforge:7.1.0+1.20.4" compileOnly "top.theillusivec4.curios:curios-neoforge:7.1.0+1.20.4:api" } diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/ClientModInitializer.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/ClientModInitializer.java index d0bbe2230..278e35236 100644 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/ClientModInitializer.java +++ b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/ClientModInitializer.java @@ -1,7 +1,6 @@ package com.refinedmods.refinedstorage2.platform.forge; import com.refinedmods.refinedstorage2.api.resource.ResourceAmount; -import com.refinedmods.refinedstorage2.platform.api.PlatformApi; import com.refinedmods.refinedstorage2.platform.api.support.HelpTooltipComponent; import com.refinedmods.refinedstorage2.platform.api.upgrade.AbstractUpgradeItem; import com.refinedmods.refinedstorage2.platform.common.AbstractClientModInitializer; @@ -20,9 +19,6 @@ import com.refinedmods.refinedstorage2.platform.common.support.tooltip.ResourceClientTooltipComponent; import com.refinedmods.refinedstorage2.platform.common.upgrade.RegulatorUpgradeItem; import com.refinedmods.refinedstorage2.platform.common.upgrade.UpgradeDestinationClientTooltipComponent; -import com.refinedmods.refinedstorage2.platform.forge.recipemod.rei.RefinedStorageREIClientPlugin; -import com.refinedmods.refinedstorage2.platform.forge.recipemod.rei.ReiGridSynchronizer; -import com.refinedmods.refinedstorage2.platform.forge.recipemod.rei.ReiProxy; import com.refinedmods.refinedstorage2.platform.forge.storage.diskdrive.DiskDriveBlockEntityRendererImpl; import com.refinedmods.refinedstorage2.platform.forge.storage.diskdrive.DiskDriveGeometryLoader; import com.refinedmods.refinedstorage2.platform.forge.storage.portablegrid.PortableGridBlockEntityRendererImpl; @@ -40,7 +36,6 @@ import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.MenuType; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.ModList; import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; import net.neoforged.neoforge.client.event.InputEvent; import net.neoforged.neoforge.client.event.ModelEvent; @@ -71,7 +66,7 @@ public static void onClientSetup(final FMLClientSetupEvent e) { e.enqueueWork(ClientModInitializer::registerModelPredicates); e.enqueueWork(ClientModInitializer::registerItemProperties); registerBlockEntityRenderer(); - registerGridSynchronizers(); + registerBaseGridSynchronizer(); registerResourceRendering(); registerAlternativeGridHints(); registerDiskModels(); @@ -169,32 +164,6 @@ private static void registerBlockEntityRenderer() { ); } - private static void registerGridSynchronizers() { - registerBaseGridSynchronizer(); - final ModList list = ModList.get(); - // Give priority to REI, as REI requires a JEI compat mod on Forge. - // This means that both JEI + REI support would be activated. We only want REI in that case. - if (list.isLoaded("roughlyenoughitems")) { - registerReiGridSynchronizers(); - } - } - - private static void registerReiGridSynchronizers() { - LOGGER.debug("Enabling REI grid synchronizers"); - // This is so the ingredient converters are only registered once - // see https://github.com/refinedmods/refinedstorage2/pull/302#discussion_r1070015672 - RefinedStorageREIClientPlugin.registerIngredientConverters(); - final ReiProxy reiProxy = new ReiProxy(); - PlatformApi.INSTANCE.getGridSynchronizerRegistry().register( - createIdentifier("rei"), - new ReiGridSynchronizer(reiProxy, false) - ); - PlatformApi.INSTANCE.getGridSynchronizerRegistry().register( - createIdentifier("rei_two_way"), - new ReiGridSynchronizer(reiProxy, true) - ); - } - @SubscribeEvent public static void onRegisterTooltipFactories(final RegisterClientTooltipComponentFactoriesEvent e) { e.register( diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/CraftingGridTransferHandler.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/CraftingGridTransferHandler.java deleted file mode 100644 index 5c54da32e..000000000 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/CraftingGridTransferHandler.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.forge.recipemod.rei; - -import com.refinedmods.refinedstorage2.api.resource.list.ResourceList; -import com.refinedmods.refinedstorage2.platform.common.grid.CraftingGridContainerMenu; -import com.refinedmods.refinedstorage2.platform.common.support.resource.ItemResource; - -import java.awt.Color; -import java.util.List; - -import com.mojang.blaze3d.vertex.PoseStack; -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.client.gui.widgets.Slot; -import me.shedaniel.rei.api.client.gui.widgets.Widget; -import me.shedaniel.rei.api.client.registry.transfer.TransferHandler; -import me.shedaniel.rei.api.client.registry.transfer.TransferHandlerRenderer; -import me.shedaniel.rei.api.common.category.CategoryIdentifier; -import me.shedaniel.rei.api.common.entry.EntryIngredient; -import me.shedaniel.rei.api.common.entry.EntryStack; -import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; -import me.shedaniel.rei.api.common.util.CollectionUtils; -import me.shedaniel.rei.plugin.common.displays.crafting.DefaultCraftingDisplay; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.world.item.ItemStack; - -class CraftingGridTransferHandler implements TransferHandler { - private static final Color MISSING_COLOR = new Color(1.0f, 0.0f, 0.0f, 0.4f); - private static final CategoryIdentifier CRAFTING = CategoryIdentifier.of("minecraft", "plugins/crafting"); - - @Override - public Result handle(final Context context) { - if (!(context.getMenu() instanceof CraftingGridContainerMenu containerMenu) - || !context.getDisplay().getCategoryIdentifier().equals(CRAFTING) - || !(context.getDisplay() instanceof DefaultCraftingDisplay defaultCraftingDisplay)) { - return Result.createNotApplicable(); - } - final List ingredients = defaultCraftingDisplay.getOrganisedInputEntries(3, 3); - if (context.isActuallyCrafting()) { - doTransfer(ingredients, containerMenu); - return Result.createSuccessful().blocksFurtherHandling(); - } - final ResourceList available = containerMenu.getAvailableListForRecipeTransfer(); - final MissingIngredients missingIngredients = findMissingIngredients(ingredients, available); - if (missingIngredients.isEmpty()) { - return Result.createSuccessful().blocksFurtherHandling(); - } - return Result.createSuccessful() - .color(MISSING_COLOR.getRGB()) - .tooltipMissing(missingIngredients.getIngredients()) - .renderer(createMissingItemsRenderer(missingIngredients)) - .blocksFurtherHandling(); - } - - private void doTransfer(final List ingredients, final CraftingGridContainerMenu containerMenu) { - final List> inputs = getInputs(ingredients); - containerMenu.transferRecipe(inputs); - } - - private MissingIngredients findMissingIngredients(final List ingredients, - final ResourceList available) { - final MissingIngredients missingIngredients = new MissingIngredients(); - for (int i = 0; i < ingredients.size(); ++i) { - final EntryIngredient ingredient = ingredients.get(i); - if (ingredient.isEmpty()) { - continue; - } - if (!isAvailable(available, ingredient)) { - missingIngredients.addIngredient(ingredient, i); - } - } - return missingIngredients; - } - - private boolean isAvailable(final ResourceList available, final EntryIngredient ingredient) { - final List possibilities = convertIngredientToItemStacks(ingredient); - 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 List ingredients) { - return ingredients.stream() - .map(this::convertIngredientToItemStacks) - .map(list -> list.stream().map(ItemResource::ofItemStack).toList()) - .toList(); - } - - private List convertIngredientToItemStacks(final EntryIngredient ingredient) { - return CollectionUtils., ItemStack>filterAndMap( - ingredient, - stack -> stack.getType() == VanillaEntryTypes.ITEM, - EntryStack::castValue - ); - } - - private TransferHandlerRenderer createMissingItemsRenderer(final MissingIngredients missingIngredients) { - return (graphics, mouseX, mouseY, delta, widgets, bounds, display) -> { - int index = 0; - for (final Widget widget : widgets) { - if (widget instanceof Slot slot - && slot.getNoticeMark() == Slot.INPUT - && missingIngredients.isMissing(index++)) { - renderMissingItemOverlay(graphics, slot); - } - } - }; - } - - private void renderMissingItemOverlay(final GuiGraphics graphics, final Slot slot) { - final PoseStack poseStack = graphics.pose(); - poseStack.pushPose(); - poseStack.translate(0, 0, 400); - final Rectangle innerBounds = slot.getInnerBounds(); - graphics.fill( - innerBounds.x, - innerBounds.y, - innerBounds.getMaxX(), - innerBounds.getMaxY(), - MISSING_COLOR.getRGB() - ); - poseStack.popPose(); - } -} diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/DraggableStackVisitorImpl.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/DraggableStackVisitorImpl.java deleted file mode 100644 index bd3ed0f80..000000000 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/DraggableStackVisitorImpl.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.forge.recipemod.rei; - -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.List; -import java.util.stream.Stream; - -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.client.gui.drag.DraggableStack; -import me.shedaniel.rei.api.client.gui.drag.DraggableStackVisitor; -import me.shedaniel.rei.api.client.gui.drag.DraggedAcceptorResult; -import me.shedaniel.rei.api.client.gui.drag.DraggingContext; -import net.minecraft.client.gui.screens.Screen; - -class DraggableStackVisitorImpl - implements DraggableStackVisitor> { - private final IngredientConverter ingredientConverter; - - DraggableStackVisitorImpl(final IngredientConverter ingredientConverter) { - this.ingredientConverter = ingredientConverter; - } - - @Override - public Stream getDraggableAcceptingBounds( - final DraggingContext> context, - final DraggableStack stack - ) { - final var screen = context.getScreen(); - final var menu = screen.getMenu(); - final var value = stack.getStack().getValue(); - final List bounds = new ArrayList<>(); - ingredientConverter.convertToResource(value).ifPresent(resource -> { - for (final ResourceSlot slot : menu.getResourceSlots()) { - if (slot.isFilter() && slot.isValid(resource)) { - bounds.add(BoundsProvider.ofRectangle(toRectangle(screen, slot))); - } - } - }); - return bounds.stream(); - } - - @Override - public DraggedAcceptorResult acceptDraggedStack( - final DraggingContext> context, - final DraggableStack stack - ) { - final var screen = context.getScreen(); - final var menu = screen.getMenu(); - final Object value = stack.getStack().getValue(); - return ingredientConverter.convertToResource(value) - .map(resource -> accept(context, menu, screen, resource)) - .orElse(DraggedAcceptorResult.PASS); - } - - private DraggedAcceptorResult accept( - final DraggingContext> context, - final AbstractResourceContainerMenu menu, - final AbstractBaseScreen screen, - final PlatformResourceKey resource - ) { - for (final ResourceSlot slot : menu.getResourceSlots()) { - final Rectangle slotBounds = toRectangle(screen, slot); - if (!slotBounds.contains(context.getCurrentPosition())) { - continue; - } - Platform.INSTANCE.getClientToServerCommunications().sendResourceFilterSlotChange(resource, slot.index); - return DraggedAcceptorResult.ACCEPTED; - } - return DraggedAcceptorResult.PASS; - } - - private static Rectangle toRectangle(final AbstractBaseScreen screen, - final ResourceSlot slot) { - return new Rectangle(screen.getLeftPos() + slot.x, screen.getTopPos() + slot.y, 18, 18); - } - - @Override - public boolean isHandingScreen(final R screen) { - return screen instanceof AbstractBaseScreen - && ((AbstractBaseScreen) screen).getMenu() instanceof AbstractResourceContainerMenu; - } -} diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/ExclusionZonesProviderImpl.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/ExclusionZonesProviderImpl.java deleted file mode 100644 index d3b4cde20..000000000 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/ExclusionZonesProviderImpl.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.forge.recipemod.rei; - -import com.refinedmods.refinedstorage2.platform.common.support.AbstractBaseScreen; - -import java.util.Collection; -import java.util.stream.Collectors; - -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.client.registry.screen.ExclusionZonesProvider; - -class ExclusionZonesProviderImpl implements ExclusionZonesProvider> { - @Override - public Collection provide(final AbstractBaseScreen screen) { - return screen.getExclusionZones().stream() - .map(rect -> new Rectangle(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight())) - .collect(Collectors.toSet()); - } -} diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/GridFocusedStackProvider.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/GridFocusedStackProvider.java deleted file mode 100644 index baa9f3989..000000000 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/GridFocusedStackProvider.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.forge.recipemod.rei; - -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 dev.architectury.event.CompoundEventResult; -import me.shedaniel.math.Point; -import me.shedaniel.rei.api.client.registry.screen.FocusedStackProvider; -import me.shedaniel.rei.api.common.entry.EntryStack; -import net.minecraft.client.gui.screens.Screen; - -class GridFocusedStackProvider implements FocusedStackProvider { - private final IngredientConverter converter; - - GridFocusedStackProvider(final IngredientConverter converter) { - this.converter = converter; - } - - @Override - public CompoundEventResult> provide(final Screen screen, final Point mouse) { - if (!(screen instanceof AbstractGridScreen gridScreen)) { - return CompoundEventResult.pass(); - } - final PlatformResourceKey underlyingResource = gridScreen.getCurrentResource(); - if (underlyingResource == null) { - return CompoundEventResult.pass(); - } - final Object converted = converter.convertToIngredient(underlyingResource).orElse(null); - if (converted instanceof EntryStack stack) { - return CompoundEventResult.interruptTrue(stack); - } - return CompoundEventResult.pass(); - } -} diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/IngredientConverterImpl.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/IngredientConverterImpl.java deleted file mode 100644 index 1adb1d641..000000000 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/IngredientConverterImpl.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.forge.recipemod.rei; - -import com.refinedmods.refinedstorage2.platform.api.recipemod.IngredientConverter; -import com.refinedmods.refinedstorage2.platform.api.support.resource.PlatformResourceKey; -import com.refinedmods.refinedstorage2.platform.common.support.resource.FluidResource; -import com.refinedmods.refinedstorage2.platform.common.support.resource.ItemResource; - -import java.util.Optional; - -import dev.architectury.fluid.FluidStack; -import me.shedaniel.rei.api.common.util.EntryStacks; -import net.minecraft.world.item.ItemStack; - -class IngredientConverterImpl implements IngredientConverter { - @Override - public Optional convertToResource(final Object ingredient) { - if (ingredient instanceof FluidStack fluidStack) { - return Optional.of(new FluidResource(fluidStack.getFluid(), fluidStack.getTag())); - } - 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(EntryStacks.of(itemResource.toItemStack())); - } - if (resource instanceof FluidResource fluidResource) { - final FluidStack fluidStack = FluidStack.create( - fluidResource.fluid(), - FluidStack.bucketAmount(), - fluidResource.tag() - ); - return Optional.of(EntryStacks.of(fluidStack)); - } - return Optional.empty(); - } -} diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/MissingIngredients.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/MissingIngredients.java deleted file mode 100644 index 9f8f5a9f0..000000000 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/MissingIngredients.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.forge.recipemod.rei; - -import java.util.ArrayList; -import java.util.List; - -import it.unimi.dsi.fastutil.ints.IntOpenHashSet; -import it.unimi.dsi.fastutil.ints.IntSet; -import me.shedaniel.rei.api.common.entry.EntryIngredient; - -class MissingIngredients { - private final List ingredients = new ArrayList<>(); - private final IntSet indices = new IntOpenHashSet(); - - boolean isEmpty() { - return indices.isEmpty(); - } - - void addIngredient(final EntryIngredient ingredient, final int slotIndex) { - ingredients.add(ingredient); - indices.add(slotIndex); - } - - List getIngredients() { - return ingredients; - } - - boolean isMissing(final int slotIndex) { - return indices.contains(slotIndex); - } -} diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/RefinedStorageREIClientPlugin.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/RefinedStorageREIClientPlugin.java deleted file mode 100644 index eee99d6e6..000000000 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/RefinedStorageREIClientPlugin.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.forge.recipemod.rei; - -import com.refinedmods.refinedstorage2.platform.api.PlatformApi; -import com.refinedmods.refinedstorage2.platform.api.recipemod.IngredientConverter; -import com.refinedmods.refinedstorage2.platform.common.content.BlockColorMap; -import com.refinedmods.refinedstorage2.platform.common.content.Blocks; -import com.refinedmods.refinedstorage2.platform.common.content.ContentIds; -import com.refinedmods.refinedstorage2.platform.common.content.Items; -import com.refinedmods.refinedstorage2.platform.common.content.Tags; -import com.refinedmods.refinedstorage2.platform.common.controller.ControllerBlockItem; -import com.refinedmods.refinedstorage2.platform.common.support.AbstractBaseScreen; - -import java.util.function.Supplier; - -import me.shedaniel.rei.api.client.plugins.REIClientPlugin; -import me.shedaniel.rei.api.client.registry.entry.CollapsibleEntryRegistry; -import me.shedaniel.rei.api.client.registry.screen.ExclusionZones; -import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry; -import me.shedaniel.rei.api.client.registry.transfer.TransferHandlerRegistry; -import me.shedaniel.rei.api.common.entry.comparison.ItemComparatorRegistry; -import me.shedaniel.rei.api.common.util.EntryIngredients; -import me.shedaniel.rei.api.common.util.EntryStacks; -import me.shedaniel.rei.forge.REIPluginClient; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.TagKey; -import net.minecraft.world.item.Item; - -import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createIdentifier; -import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createTranslation; - -@REIPluginClient -public class RefinedStorageREIClientPlugin implements REIClientPlugin { - @Override - public void registerScreens(final ScreenRegistry registry) { - final IngredientConverter converter = PlatformApi.INSTANCE.getIngredientConverter(); - registry.registerFocusedStack(new GridFocusedStackProvider(converter)); - registry.registerFocusedStack(new ResourceFocusedStackProvider(converter)); - registry.registerDraggableStackVisitor(new DraggableStackVisitorImpl(converter)); - } - - public static void registerIngredientConverters() { - PlatformApi.INSTANCE.registerIngredientConverter(new IngredientConverterImpl()); - } - - @Override - public void registerTransferHandlers(final TransferHandlerRegistry registry) { - registry.register(new CraftingGridTransferHandler()); - } - - @Override - public void registerItemComparators(final ItemComparatorRegistry registry) { - Items.INSTANCE.getControllers().stream().map(Supplier::get).forEach(registry::registerNbt); - } - - @SuppressWarnings("UnstableApiUsage") - @Override - public void registerCollapsibleEntries(final CollapsibleEntryRegistry registry) { - groupItems(registry, Blocks.INSTANCE.getCable(), ContentIds.CABLE, Tags.CABLES); - groupItems(registry, Blocks.INSTANCE.getGrid(), ContentIds.GRID, Tags.GRIDS); - groupItems(registry, Blocks.INSTANCE.getCraftingGrid(), ContentIds.CRAFTING_GRID, Tags.CRAFTING_GRIDS); - groupItems(registry, Blocks.INSTANCE.getImporter(), ContentIds.IMPORTER, Tags.IMPORTERS); - groupItems(registry, Blocks.INSTANCE.getExporter(), ContentIds.EXPORTER, Tags.EXPORTERS); - groupItems(registry, Blocks.INSTANCE.getDetector(), ContentIds.DETECTOR, Tags.DETECTORS); - groupItems(registry, Blocks.INSTANCE.getDestructor(), ContentIds.DESTRUCTOR, Tags.DESTRUCTORS); - groupItems(registry, Blocks.INSTANCE.getConstructor(), ContentIds.CONSTRUCTOR, Tags.CONSTRUCTORS); - groupItems(registry, Blocks.INSTANCE.getExternalStorage(), ContentIds.EXTERNAL_STORAGE, Tags.EXTERNAL_STORAGES); - groupItems(registry, Blocks.INSTANCE.getController(), ContentIds.CONTROLLER, Tags.CONTROLLERS); - registry.group( - createIdentifier("fully_charged_controller"), - createTranslation("block", "controller.rei_fully_charged"), - Items.INSTANCE.getControllers().stream() - .map(Supplier::get) - .map(ControllerBlockItem::createAtEnergyCapacity) - .map(EntryStacks::of) - .toList() - ); - groupItems( - registry, - Blocks.INSTANCE.getCreativeController(), - ContentIds.CREATIVE_CONTROLLER, - Tags.CREATIVE_CONTROLLERS - ); - groupItems( - registry, - Blocks.INSTANCE.getWirelessTransmitter(), - ContentIds.WIRELESS_TRANSMITTER, - Tags.WIRELESS_TRANSMITTERS - ); - groupItems(registry, Blocks.INSTANCE.getNetworkReceiver(), ContentIds.NETWORK_RECEIVER, Tags.NETWORK_RECEIVERS); - groupItems( - registry, - Blocks.INSTANCE.getNetworkTransmitter(), - ContentIds.NETWORK_TRANSMITTER, - Tags.NETWORK_TRANSMITTERS - ); - groupItems( - registry, - Blocks.INSTANCE.getSecurityManager(), - ContentIds.SECURITY_MANAGER, - Tags.SECURITY_MANAGERS - ); - groupItems( - registry, - Blocks.INSTANCE.getRelay(), - ContentIds.RELAY, - Tags.RELAYS - ); - } - - @Override - public void registerExclusionZones(final ExclusionZones zones) { - zones.register(AbstractBaseScreen.class, new ExclusionZonesProviderImpl()); - } - - @SuppressWarnings("UnstableApiUsage") - private static void groupItems( - final CollapsibleEntryRegistry registry, - final BlockColorMap blocks, - final ResourceLocation itemIdentifier, - final TagKey tag - ) { - registry.group( - itemIdentifier, - blocks.getDefault().getName(), - EntryIngredients.ofItemTag(tag) - ); - } -} diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/ReiGridSynchronizer.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/ReiGridSynchronizer.java deleted file mode 100644 index e3cea565a..000000000 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/ReiGridSynchronizer.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.forge.recipemod.rei; - -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; - -public class ReiGridSynchronizer extends AbstractGridSynchronizer { - private static final MutableComponent TITLE = createTranslation("gui", "grid.synchronizer.rei"); - private static final MutableComponent TITLE_TWO_WAY = createTranslation("gui", "grid.synchronizer.rei.two_way"); - private static final Component HELP = createTranslation("gui", "grid.synchronizer.rei.help"); - private static final Component HELP_TWO_WAY = createTranslation("gui", "grid.synchronizer.rei.two_way.help"); - - private final ReiProxy reiProxy; - private final boolean twoWay; - - public ReiGridSynchronizer(final ReiProxy reiProxy, final boolean twoWay) { - this.reiProxy = reiProxy; - 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) { - reiProxy.setSearchFieldText(text); - } - - @Override - @Nullable - public String getTextToSynchronizeToGrid() { - return twoWay ? reiProxy.getSearchFieldText() : null; - } - - @Override - public int getXTexture() { - return twoWay ? 32 : 48; - } -} diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/ReiProxy.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/ReiProxy.java deleted file mode 100644 index 9195e3df8..000000000 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/ReiProxy.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.forge.recipemod.rei; - -import javax.annotation.Nullable; - -import me.shedaniel.rei.api.client.REIRuntime; -import me.shedaniel.rei.api.client.gui.widgets.TextField; - -public class ReiProxy { - @Nullable - public String getSearchFieldText() { - final TextField field = REIRuntime.getInstance().getSearchTextField(); - if (field != null) { - return field.getText(); - } - return null; - } - - public void setSearchFieldText(final String text) { - final TextField field = REIRuntime.getInstance().getSearchTextField(); - if (field != null) { - field.setText(text); - } - } -} diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/ResourceFocusedStackProvider.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/ResourceFocusedStackProvider.java deleted file mode 100644 index 6ee58c9e3..000000000 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/ResourceFocusedStackProvider.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.forge.recipemod.rei; - -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 dev.architectury.event.CompoundEventResult; -import me.shedaniel.math.Point; -import me.shedaniel.rei.api.client.registry.screen.FocusedStackProvider; -import me.shedaniel.rei.api.common.entry.EntryStack; -import net.minecraft.client.gui.screens.Screen; - -class ResourceFocusedStackProvider implements FocusedStackProvider { - private final IngredientConverter converter; - - ResourceFocusedStackProvider(final IngredientConverter converter) { - this.converter = converter; - } - - @Override - public CompoundEventResult> provide(final Screen screen, final Point mouse) { - if (!(screen instanceof AbstractBaseScreen baseScreen)) { - return CompoundEventResult.pass(); - } - final PlatformResourceKey hoveredResource = baseScreen.getHoveredResource(); - if (hoveredResource == null) { - return CompoundEventResult.pass(); - } - final Object converted = converter.convertToIngredient(hoveredResource).orElse(null); - if (converted instanceof EntryStack stack) { - return CompoundEventResult.interruptTrue(stack); - } - return CompoundEventResult.pass(); - } -} - diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/package-info.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/package-info.java deleted file mode 100644 index a157b3201..000000000 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/recipemod/rei/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@ParametersAreNonnullByDefault -@FieldsAndMethodsAreNonnullByDefault -package com.refinedmods.refinedstorage2.platform.forge.recipemod.rei; - -import com.refinedmods.refinedstorage2.api.core.FieldsAndMethodsAreNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/refinedstorage2-query-parser/src/main/resources/fabric.mod.json b/refinedstorage2-query-parser/src/main/resources/fabric.mod.json new file mode 100644 index 000000000..7b57211c5 --- /dev/null +++ b/refinedstorage2-query-parser/src/main/resources/fabric.mod.json @@ -0,0 +1,19 @@ +{ + "schemaVersion": 1, + "id": "refinedstorage2-query-parser", + "version": "${version}", + "name": "Refined Storage 2 Query Parser", + "authors": [ + "Refined Mods" + ], + "license": "MIT", + "environment": "*", + "custom": { + "modmenu": { + "parent": "refinedstorage2", + "badges": [ + "library" + ] + } + } +} From f159409e5d492ddccaea8e1abbdda6bbb2507d25 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sat, 8 Jun 2024 22:48:49 +0000 Subject: [PATCH 2/2] chore: prepare release v2.0.0-milestone.3.8 --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cb2bd58e..1a5258d74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [2.0.0-milestone.3.8] - 2024-06-08 + ### Removed - The REI integration has been removed and will be moved to an addon mod. @@ -582,7 +584,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - The Grid can now use smooth scrolling. - The Grid now has syntax highlighting for the search query. -[Unreleased]: https://github.com/refinedmods/refinedstorage2/compare/v2.0.0-milestone.3.7...HEAD +[Unreleased]: https://github.com/refinedmods/refinedstorage2/compare/v2.0.0-milestone.3.8...HEAD + +[2.0.0-milestone.3.8]: https://github.com/refinedmods/refinedstorage2/compare/v2.0.0-milestone.3.7...v2.0.0-milestone.3.8 [2.0.0-milestone.3.7]: https://github.com/refinedmods/refinedstorage2/compare/v2.0.0-milestone.3.6...v2.0.0-milestone.3.7