aboutsummaryrefslogtreecommitdiff
path: root/api/src
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-12-09 02:08:47 +0800
committershedaniel <daniel@shedaniel.me>2022-12-09 02:08:47 +0800
commitdc6351d3b4893c316854f7a9fc6f8d95320046ee (patch)
treea74dc043393b9f228473766cb7ce126cf080c206 /api/src
parent00029913ffe72ee1b6cdff64ffe1fd9e56ac15a1 (diff)
parent2caa595aa94d46ddaefc5ecdb79f7ec834f7eae8 (diff)
downloadRoughlyEnoughItems-dc6351d3b4893c316854f7a9fc6f8d95320046ee.tar.gz
RoughlyEnoughItems-dc6351d3b4893c316854f7a9fc6f8d95320046ee.tar.bz2
RoughlyEnoughItems-dc6351d3b4893c316854f7a9fc6f8d95320046ee.zip
Merge remote-tracking branch 'origin/9.x-1.19' into feature/1.19.3
# Conflicts: # runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringRulesScreen.java
Diffstat (limited to 'api/src')
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/FilteringContext.java25
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/FilteringRule.java22
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/base/BasicFilteringRule.java12
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/entry/EntryRegistry.java5
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfo.java2
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java27
6 files changed, 92 insertions, 1 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/FilteringContext.java b/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/FilteringContext.java
index d46709af9..8cf2179e0 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/FilteringContext.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/FilteringContext.java
@@ -23,6 +23,7 @@
package me.shedaniel.rei.api.client.entry.filtering;
+import it.unimi.dsi.fastutil.longs.LongCollection;
import me.shedaniel.rei.api.common.entry.EntryStack;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
@@ -53,4 +54,28 @@ public interface FilteringContext {
* @return the list of stacks that are previously marked as hidden from other filtering rules.
*/
Collection<EntryStack<?>> getHiddenStacks();
+
+ /**
+ * Returns the list of hashes that are previously marked as <b>shown</b> from other filtering rules.
+ *
+ * @return the list of hashes that are previously marked as shown from other filtering rules.
+ */
+ @ApiStatus.Experimental
+ LongCollection getShownExactHashes();
+
+ /**
+ * Returns the list of hashes that are previously marked as <b>hidden</b> from other filtering rules.
+ *
+ * @return the list of hashes that are previously marked as hidden from other filtering rules.
+ */
+ @ApiStatus.Experimental
+ LongCollection getUnsetExactHashes();
+
+ /**
+ * Returns the list of hashes that are previously marked as <b>hidden</b> from other filtering rules.
+ *
+ * @return the list of hashes that are previously marked as hidden from other filtering rules.
+ */
+ @ApiStatus.Experimental
+ LongCollection getHiddenExactHashes();
}
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/FilteringRule.java b/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/FilteringRule.java
index 1f3cb5b50..a133de686 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/FilteringRule.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/FilteringRule.java
@@ -23,9 +23,15 @@
package me.shedaniel.rei.api.client.entry.filtering;
+import it.unimi.dsi.fastutil.longs.LongCollection;
+import me.shedaniel.rei.api.client.registry.entry.EntryRegistry;
+import me.shedaniel.rei.api.common.entry.EntryStack;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collection;
/**
* A filtering rule type that is used to filter the entries on the entry panel,
@@ -63,4 +69,20 @@ public interface FilteringRule<Cache> {
* @return the result of the processing
*/
FilteringResult processFilteredStacks(FilteringContext context, FilteringResultFactory resultFactory, Cache cache, boolean async);
+
+ /**
+ * Returns whether the entry registry is in its reloading phase.
+ * Registration after the reloading phase will be slow and may not be reflected immediately.
+ *
+ * @return whether the entry registry is in its reloading phase
+ */
+ @ApiStatus.NonExtendable
+ default boolean isReloading() {
+ return EntryRegistry.getInstance().isReloading();
+ }
+
+ @ApiStatus.NonExtendable
+ default void markDirty(Collection<EntryStack<?>> stacks, @Nullable LongCollection hashes) {
+ EntryRegistry.getInstance().markFilteringRuleDirty(this, stacks, hashes);
+ }
} \ No newline at end of file
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/base/BasicFilteringRule.java b/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/base/BasicFilteringRule.java
index 26b2986c2..4800a430e 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/base/BasicFilteringRule.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/base/BasicFilteringRule.java
@@ -26,11 +26,15 @@ package me.shedaniel.rei.api.client.entry.filtering.base;
import me.shedaniel.rei.api.client.entry.filtering.FilteringResult;
import me.shedaniel.rei.api.client.entry.filtering.FilteringRule;
import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
+import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.api.common.registry.Reloadable;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.jetbrains.annotations.ApiStatus;
+import java.util.Collection;
+import java.util.function.Supplier;
+
/**
* The basic filtering rule that can be used to filter entries,
* without registering a new filtering rule type, for external
@@ -41,4 +45,12 @@ import org.jetbrains.annotations.ApiStatus;
@ApiStatus.Experimental
@Environment(EnvType.CLIENT)
public interface BasicFilteringRule<Cache> extends Reloadable<REIClientPlugin>, FilteringRule<Cache>, FilteringResult {
+ MarkDirty hide(Supplier<Collection<EntryStack<?>>> provider);
+
+ MarkDirty show(Supplier<Collection<EntryStack<?>>> provider);
+
+ @ApiStatus.NonExtendable
+ interface MarkDirty {
+ void markDirty();
+ }
}
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/EntryRegistry.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/EntryRegistry.java
index d2deaac32..7cfbc27ed 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/EntryRegistry.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/EntryRegistry.java
@@ -23,6 +23,8 @@
package me.shedaniel.rei.api.client.registry.entry;
+import it.unimi.dsi.fastutil.longs.LongCollection;
+import me.shedaniel.rei.api.client.entry.filtering.FilteringRule;
import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.api.common.plugins.PluginManager;
@@ -209,4 +211,7 @@ public interface EntryRegistry extends Reloadable<REIClientPlugin> {
* @return whether the registry is in its reloading phase
*/
boolean isReloading();
+
+ @ApiStatus.Experimental
+ <Cache> void markFilteringRuleDirty(FilteringRule<Cache> cacheFilteringRule, Collection<EntryStack<?>> stacks, @Nullable LongCollection hashes);
}
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfo.java b/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfo.java
index 9769d073e..08165839f 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfo.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfo.java
@@ -189,7 +189,7 @@ public interface MenuInfo<T extends AbstractContainerMenu, D extends Display> {
if (widget instanceof Slot && ((Slot) widget).getNoticeMark() == Slot.INPUT) {
if (missingIndices.contains(i++)) {
matrices.pushPose();
- matrices.translate(0, 0, 400);
+ matrices.translate(0, 0, 50);
Rectangle innerBounds = ((Slot) widget).getInnerBounds();
GuiComponent.fill(matrices, innerBounds.x, innerBounds.y, innerBounds.getMaxX(), innerBounds.getMaxY(), 0x40ff0000);
matrices.popPose();
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java b/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java
index 67894fb27..3b625d888 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java
@@ -241,6 +241,33 @@ public class CollectionUtils {
return Stream.of(list).max(comparator);
}
+ public static <T, R> Optional<R> mapAndMin(Collection<T> list, Function<T, R> function, Comparator<R> comparator) {
+ if (list.isEmpty()) {
+ return Optional.empty();
+ }
+ return list.stream().min(Comparator.comparing(function, comparator)).map(function);
+ }
+
+ public static <T, R> Optional<R> mapAndMin(T[] list, Function<T, R> function, Comparator<R> comparator) {
+ if (list.length <= 0)
+ return Optional.empty();
+ return Stream.of(list).min(Comparator.comparing(function, comparator)).map(function);
+ }
+
+ public static <T> Optional<T> min(Collection<T> list, Comparator<T> comparator) {
+ if (list.isEmpty()) {
+ return Optional.empty();
+ }
+ return list.stream().min(comparator);
+ }
+
+ public static <T> Optional<T> min(T[] list, Comparator<T> comparator) {
+ if (list.length <= 0) {
+ return Optional.empty();
+ }
+ return Stream.of(list).min(comparator);
+ }
+
public static String joinToString(Iterable<CharSequence> list, CharSequence separator) {
return String.join(separator, list);
}