From 12d411ea7f58ca62b4667194993e25cae2508672 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 12 Nov 2022 13:26:56 +0800 Subject: Fix #1207 --- .../client/registry/display/DisplayCategory.java | 2 +- .../rei/api/common/util/CollectionUtils.java | 27 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) (limited to 'api/src/main/java/me') diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayCategory.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayCategory.java index c01d1a9f3..0f82e6705 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayCategory.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayCategory.java @@ -104,7 +104,7 @@ public interface DisplayCategory extends DisplayCategoryView< * @return the display width */ default int getDisplayWidth(T display) { - return 150; + return getCategoryIdentifier().getPath().equals("plugins/campfire") ? 190 : 150; } /** 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 Optional mapAndMin(Collection list, Function function, Comparator comparator) { + if (list.isEmpty()) { + return Optional.empty(); + } + return list.stream().min(Comparator.comparing(function, comparator)).map(function); + } + + public static Optional mapAndMin(T[] list, Function function, Comparator comparator) { + if (list.length <= 0) + return Optional.empty(); + return Stream.of(list).min(Comparator.comparing(function, comparator)).map(function); + } + + public static Optional min(Collection list, Comparator comparator) { + if (list.isEmpty()) { + return Optional.empty(); + } + return list.stream().min(comparator); + } + + public static Optional min(T[] list, Comparator comparator) { + if (list.length <= 0) { + return Optional.empty(); + } + return Stream.of(list).min(comparator); + } + public static String joinToString(Iterable list, CharSequence separator) { return String.join(separator, list); } -- cgit From 7d18e7ed9db822639121831922b30cf824fe974c Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 12 Nov 2022 14:46:44 +0800 Subject: Solve some z-fighting for auto crafting --- .../main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'api/src/main/java/me') 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 { 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(); -- cgit From e24dc179b48ae842a26170dd775201bb80ce4f1d Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 12 Nov 2022 20:18:47 +0800 Subject: Fix campfire displays being too big --- .../me/shedaniel/rei/api/client/registry/display/DisplayCategory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'api/src/main/java/me') diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayCategory.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayCategory.java index 0f82e6705..c01d1a9f3 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayCategory.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayCategory.java @@ -104,7 +104,7 @@ public interface DisplayCategory extends DisplayCategoryView< * @return the display width */ default int getDisplayWidth(T display) { - return getCategoryIdentifier().getPath().equals("plugins/campfire") ? 190 : 150; + return 150; } /** -- cgit From 2123544fcf3ad7ec6d89e671a993a75737e3a44e Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sun, 27 Nov 2022 17:50:11 +0800 Subject: Make filtering more immediate --- .../client/entry/filtering/FilteringContext.java | 25 ++++++++++++++++++++++ .../api/client/entry/filtering/FilteringRule.java | 22 +++++++++++++++++++ .../entry/filtering/base/BasicFilteringRule.java | 12 +++++++++++ .../api/client/registry/entry/EntryRegistry.java | 5 +++++ 4 files changed, 64 insertions(+) (limited to 'api/src/main/java/me') 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> getHiddenStacks(); + + /** + * Returns the list of hashes that are previously marked as shown 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 hidden 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 hidden 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 { * @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> 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 extends Reloadable, FilteringRule, FilteringResult { + MarkDirty hide(Supplier>> provider); + + MarkDirty show(Supplier>> 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 63ed14d72..9e4713957 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; @@ -207,4 +209,7 @@ public interface EntryRegistry extends Reloadable { * @return whether the registry is in its reloading phase */ boolean isReloading(); + + @ApiStatus.Experimental + void markFilteringRuleDirty(FilteringRule cacheFilteringRule, Collection> stacks, @Nullable LongCollection hashes); } -- cgit