aboutsummaryrefslogtreecommitdiff
path: root/runtime/src/main/java/me
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2021-11-21 19:10:50 +0800
committershedaniel <daniel@shedaniel.me>2021-11-21 19:10:50 +0800
commit85e72e9a9bc70cf283ba872172985b338be59233 (patch)
treebce73cb38c00b73d1323c7a014701ee638f2224b /runtime/src/main/java/me
parenta437fe0560478c636526862679ba1098688bf2c1 (diff)
parentc4cdd997f981d0a3b763140d1515a73941b18f5c (diff)
downloadRoughlyEnoughItems-85e72e9a9bc70cf283ba872172985b338be59233.tar.gz
RoughlyEnoughItems-85e72e9a9bc70cf283ba872172985b338be59233.tar.bz2
RoughlyEnoughItems-85e72e9a9bc70cf283ba872172985b338be59233.zip
Merge remote-tracking branch 'origin/6.x-1.17' into 7.x-1.18
# Conflicts: # api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfo.java # gradle.properties # runtime/src/main/java/me/shedaniel/rei/impl/client/search/argument/type/TooltipArgumentType.java # runtime/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultCategoryHandler.java
Diffstat (limited to 'runtime/src/main/java/me')
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java9
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java7
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java5
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/FilteringCache.java31
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/FilteringCacheImpl.java44
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/FilteringContextImpl.java42
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/FilteringRule.java6
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/ManualFilteringRule.java52
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/SearchFilteringRule.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryStacksRegionWidget.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/FavoritesListWidget.java6
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/InternalWidgets.java203
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/search/argument/type/TooltipArgumentType.java31
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/view/ViewsImpl.java29
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/entry/AbstractEntryStack.java5
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/EntryRegistryImpl.java111
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/types/BuiltinEntryDefinition.java5
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java9
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/transfer/InputSlotCrafter.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultCategoryHandler.java37
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/FluidEntryDefinition.java11
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java5
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/DefaultClientRuntimePlugin.java12
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/FilteredStacksVisibilityHandler.java116
24 files changed, 598 insertions, 185 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java
index ee054dcd8..227389f37 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java
@@ -75,15 +75,6 @@ import java.util.function.Supplier;
@Environment(EnvType.CLIENT)
public class ClientHelperImpl implements ClientHelper {
@ApiStatus.Internal
- public final LazyLoadedValue<Boolean> isYog = new LazyLoadedValue<>(() -> {
- try {
- if (Minecraft.getInstance().getUser().getGameProfile().getId().equals(UUID.fromString("f9546389-9415-4358-9c29-2c26b25bff5b")))
- return true;
- } catch (Throwable ignored) {
- }
- return false;
- });
- @ApiStatus.Internal
public final LazyLoadedValue<Boolean> isAprilFools = new LazyLoadedValue<>(() -> {
try {
LocalDateTime now = LocalDateTime.now();
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java
index 672032940..8a253265f 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java
@@ -311,6 +311,12 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData {
return advanced.filtering.filteredStacks;
}
+ @ApiStatus.Experimental
+ @Override
+ public boolean shouldFilterDisplays() {
+ return advanced.filtering.shouldFilterDisplays;
+ }
+
@ApiStatus.Internal
public List<FilteringRule<?>> getFilteringRules() {
return advanced.filtering.filteringRules;
@@ -576,6 +582,7 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData {
public static class Filtering {
@UseFilteringScreen private List<EntryStackProvider<?>> filteredStacks = new ArrayList<>();
+ public boolean shouldFilterDisplays = true;
@ConfigEntry.Gui.Excluded public List<FilteringRule<?>> filteringRules = new ArrayList<>();
}
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java
index 9026127f3..2d70af051 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java
@@ -41,6 +41,7 @@ import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
import me.shedaniel.rei.api.client.registry.entry.EntryRegistry;
import me.shedaniel.rei.api.client.search.SearchFilter;
import me.shedaniel.rei.api.client.search.SearchProvider;
+import me.shedaniel.rei.api.common.entry.EntrySerializer;
import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl;
import me.shedaniel.rei.impl.client.gui.widget.BatchedEntryRendererManager;
@@ -320,6 +321,10 @@ public class FilteringScreen extends Screen {
}
public boolean matches(EntryStack<?> stack) {
+ EntrySerializer<?> serializer = stack.getDefinition().getSerializer();
+ if (serializer == null || !serializer.supportReading() || !serializer.supportSaving()) {
+ return false;
+ }
return lastFilter.test(stack);
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/FilteringCache.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/FilteringCache.java
new file mode 100644
index 000000000..d2779211a
--- /dev/null
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/FilteringCache.java
@@ -0,0 +1,31 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020, 2021 shedaniel
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.shedaniel.rei.impl.client.entry.filtering;
+
+import org.jetbrains.annotations.Nullable;
+
+public interface FilteringCache {
+ @Nullable
+ Object getCache(FilteringRule<?> rule);
+}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/FilteringCacheImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/FilteringCacheImpl.java
new file mode 100644
index 000000000..cd4030fec
--- /dev/null
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/FilteringCacheImpl.java
@@ -0,0 +1,44 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020, 2021 shedaniel
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.shedaniel.rei.impl.client.entry.filtering;
+
+import org.jetbrains.annotations.Nullable;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+public class FilteringCacheImpl implements FilteringCache {
+ private final Map<FilteringRule<?>, Optional<?>> CACHE = new HashMap<>();
+
+ @Override
+ @Nullable
+ public Object getCache(FilteringRule<?> rule) {
+ return CACHE.getOrDefault(rule, Optional.empty()).orElse(null);
+ }
+
+ public void setCache(FilteringRule<?> rule, @Nullable Object value) {
+ CACHE.put(rule, Optional.ofNullable(value));
+ }
+}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/FilteringContextImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/FilteringContextImpl.java
index 1d52db2d9..adda65797 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/FilteringContextImpl.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/FilteringContextImpl.java
@@ -43,20 +43,28 @@ import java.util.concurrent.TimeoutException;
@Environment(EnvType.CLIENT)
public class FilteringContextImpl implements FilteringContext {
+ private final boolean async;
public final Map<FilteringContextType, Set<HashedEntryStackWrapper>> stacks;
private final Map<FilteringContextType, Collection<EntryStack<?>>> cachedStacks;
public FilteringContextImpl(Collection<EntryStack<?>> allStacks) {
+ this(true, allStacks);
+ }
+
+ public FilteringContextImpl(boolean async, Collection<EntryStack<?>> allStacks) {
+ this.async = async;
this.stacks = Maps.newHashMap();
this.cachedStacks = Maps.newHashMap();
for (FilteringContextType type : FilteringContextType.values()) {
this.stacks.computeIfAbsent(type, t -> Sets.newHashSet());
}
- this.stacks.get(FilteringContextType.DEFAULT).addAll(CollectionUtils.mapParallel(allStacks, HashedEntryStackWrapper::new));
+ this.stacks.get(FilteringContextType.DEFAULT).addAll(async ? CollectionUtils.mapParallel(allStacks, HashedEntryStackWrapper::new)
+ : CollectionUtils.map(allStacks, HashedEntryStackWrapper::new));
fillCache();
}
public FilteringContextImpl(Map<FilteringContextType, Set<HashedEntryStackWrapper>> stacks) {
+ this.async = false;
this.stacks = stacks;
this.cachedStacks = Maps.newHashMap();
for (FilteringContextType type : FilteringContextType.values()) {
@@ -81,24 +89,34 @@ public class FilteringContextImpl implements FilteringContext {
Collection<HashedEntryStackWrapper> hiddenStacks = result.getHiddenStacks();
Collection<HashedEntryStackWrapper> shownStacks = result.getShownStacks();
- List<CompletableFuture<Void>> completableFutures = Lists.newArrayList();
- completableFutures.add(CompletableFuture.runAsync(() -> {
+ if (async) {
+ List<CompletableFuture<Void>> completableFutures = Lists.newArrayList();
+ completableFutures.add(CompletableFuture.runAsync(() -> {
+ this.stacks.get(FilteringContextType.DEFAULT).removeAll(hiddenStacks);
+ this.stacks.get(FilteringContextType.DEFAULT).removeAll(shownStacks);
+ }));
+ completableFutures.add(CompletableFuture.runAsync(() -> {
+ this.stacks.get(FilteringContextType.SHOWN).removeAll(hiddenStacks);
+ this.stacks.get(FilteringContextType.SHOWN).addAll(shownStacks);
+ }));
+ completableFutures.add(CompletableFuture.runAsync(() -> {
+ this.stacks.get(FilteringContextType.HIDDEN).addAll(hiddenStacks);
+ this.stacks.get(FilteringContextType.HIDDEN).removeAll(shownStacks);
+ }));
+ try {
+ CompletableFuture.allOf(completableFutures.toArray(new CompletableFuture[0])).get(20, TimeUnit.SECONDS);
+ } catch (InterruptedException | ExecutionException | TimeoutException e) {
+ e.printStackTrace();
+ }
+ } else {
this.stacks.get(FilteringContextType.DEFAULT).removeAll(hiddenStacks);
this.stacks.get(FilteringContextType.DEFAULT).removeAll(shownStacks);
- }));
- completableFutures.add(CompletableFuture.runAsync(() -> {
this.stacks.get(FilteringContextType.SHOWN).removeAll(hiddenStacks);
this.stacks.get(FilteringContextType.SHOWN).addAll(shownStacks);
- }));
- completableFutures.add(CompletableFuture.runAsync(() -> {
this.stacks.get(FilteringContextType.HIDDEN).addAll(hiddenStacks);
this.stacks.get(FilteringContextType.HIDDEN).removeAll(shownStacks);
- }));
- try {
- CompletableFuture.allOf(completableFutures.toArray(new CompletableFuture[0])).get(20, TimeUnit.SECONDS);
- } catch (InterruptedException | ExecutionException | TimeoutException e) {
- e.printStackTrace();
}
+
fillCache();
}
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/FilteringRule.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/FilteringRule.java
index 122e2e3f7..40593dc66 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/FilteringRule.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/FilteringRule.java
@@ -66,7 +66,7 @@ public interface FilteringRule<T extends FilteringRule<?>> {
T createFromTag(CompoundTag tag);
- FilteringResult processFilteredStacks(FilteringContext context);
+ FilteringResult processFilteredStacks(FilteringContext context, FilteringCache cache, boolean async);
@ApiStatus.Internal
default Optional<BiFunction<FilteringEntry, Screen, Screen>> createEntryScreen() {
@@ -81,5 +81,9 @@ public interface FilteringRule<T extends FilteringRule<?>> {
return Component.nullToEmpty(null);
}
+ default Object prepareCache(boolean async) {
+ return null;
+ }
+
T createNew();
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/ManualFilteringRule.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/ManualFilteringRule.java
index c8fb61998..8ba2e83fb 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/ManualFilteringRule.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/ManualFilteringRule.java
@@ -23,6 +23,7 @@
package me.shedaniel.rei.impl.client.entry.filtering.rules;
+import com.google.common.collect.Lists;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import it.unimi.dsi.fastutil.longs.LongSet;
import me.shedaniel.rei.api.client.config.ConfigObject;
@@ -31,6 +32,7 @@ import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.api.common.util.CollectionUtils;
import me.shedaniel.rei.api.common.util.EntryStacks;
import me.shedaniel.rei.impl.client.entry.filtering.AbstractFilteringRule;
+import me.shedaniel.rei.impl.client.entry.filtering.FilteringCache;
import me.shedaniel.rei.impl.client.entry.filtering.FilteringContext;
import me.shedaniel.rei.impl.client.entry.filtering.FilteringResult;
import net.minecraft.nbt.CompoundTag;
@@ -38,6 +40,11 @@ import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
public class ManualFilteringRule extends AbstractFilteringRule<ManualFilteringRule> {
@@ -52,16 +59,49 @@ public class ManualFilteringRule extends AbstractFilteringRule<ManualFilteringRu
}
@Override
- public FilteringResult processFilteredStacks(FilteringContext context) {
+ public Object prepareCache(boolean async) {
+ if (async) {
+ LongSet all = new LongOpenHashSet();
+ List<CompletableFuture<LongSet>> completableFutures = Lists.newArrayList();
+ for (Iterable<EntryStackProvider<?>> partitionStacks : CollectionUtils.partition(ConfigObject.getInstance().getFilteredStackProviders(), 100)) {
+ completableFutures.add(CompletableFuture.supplyAsync(() -> {
+ LongSet output = new LongOpenHashSet();
+ for (EntryStackProvider<?> provider : partitionStacks) {
+ if (provider != null && provider.isValid()) {
+ output.add(EntryStacks.hashExact(provider.provide()));
+ }
+ }
+ return output;
+ }));
+ }
+ try {
+ CompletableFuture.allOf(completableFutures.toArray(new CompletableFuture[0])).get(10, TimeUnit.SECONDS);
+ } catch (InterruptedException | ExecutionException | TimeoutException e) {
+ e.printStackTrace();
+ }
+ for (CompletableFuture<LongSet> future : completableFutures) {
+ LongSet now = future.getNow(null);
+ if (now != null) {
+ all.addAll(now);
+ }
+ }
+ return all;
+ } else {
+ return ConfigObject.getInstance().getFilteredStackProviders().stream().filter(EntryStackProvider::isValid).map(provider -> EntryStacks.hashExact(provider.provide())).collect(Collectors.toCollection(LongOpenHashSet::new));
+ }
+ }
+
+ @Override
+ public FilteringResult processFilteredStacks(FilteringContext context, FilteringCache cache, boolean async) {
+ LongSet filteredStacks = (LongSet) cache.getCache(this);
FilteringResult result = FilteringResult.create();
- processList(context.getShownStacks(), result);
- processList(context.getUnsetStacks(), result);
+ processList(context.getShownStacks(), result, async, filteredStacks);
+ processList(context.getUnsetStacks(), result, async, filteredStacks);
return result;
}
- private void processList(Collection<EntryStack<?>> stacks, FilteringResult result) {
- LongSet filteredStacks = CollectionUtils.filterAndMapParallel(ConfigObject.getInstance().getFilteredStackProviders(), EntryStackProvider::isValid, provider -> EntryStacks.hashExact(provider.provide()), LongOpenHashSet::new);
- result.hide(stacks.parallelStream().filter(stack -> filteredStacks.contains(EntryStacks.hashExact(stack))).collect(Collectors.toList()));
+ private void processList(Collection<EntryStack<?>> stacks, FilteringResult result, boolean async, LongSet filteredStacks) {
+ result.hide((async ? stacks.parallelStream() : stacks.stream()).filter(stack -> filteredStacks.contains(EntryStacks.hashExact(stack))).collect(Collectors.toList()));
}
@Override
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/SearchFilteringRule.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/SearchFilteringRule.java
index 9e00dec60..b1e9b122f 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/SearchFilteringRule.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/SearchFilteringRule.java
@@ -31,6 +31,7 @@ import me.shedaniel.rei.api.common.util.CollectionUtils;
import me.shedaniel.rei.impl.client.config.entries.FilteringEntry;
import me.shedaniel.rei.impl.client.config.entries.FilteringRuleOptionsScreen;
import me.shedaniel.rei.impl.client.entry.filtering.AbstractFilteringRule;
+import me.shedaniel.rei.impl.client.entry.filtering.FilteringCache;
import me.shedaniel.rei.impl.client.entry.filtering.FilteringContext;
import me.shedaniel.rei.impl.client.entry.filtering.FilteringResult;
import net.fabricmc.api.EnvType;
@@ -79,7 +80,7 @@ public class SearchFilteringRule extends AbstractFilteringRule<SearchFilteringRu
}
@Override
- public FilteringResult processFilteredStacks(FilteringContext context) {
+ public FilteringResult processFilteredStacks(FilteringContext context, FilteringCache cache, boolean async) {
List<CompletableFuture<List<EntryStack<?>>>> completableFutures = Lists.newArrayList();
processList(context.getUnsetStacks(), completableFutures);
if (show) processList(context.getHiddenStacks(), completableFutures);
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryStacksRegionWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryStacksRegionWidget.java
index 557b2af0f..28669cb53 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryStacksRegionWidget.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryStacksRegionWidget.java
@@ -237,7 +237,7 @@ public class EntryStacksRegionWidget<T extends RegionEntry<T>> extends WidgetWit
public Optional<RealRegionEntry<T>> checkDraggedStacks(DraggingContext<Screen> context, DraggableStack stack) {
EntrySerializer<?> serializer = stack.getStack().getDefinition().getSerializer();
- if (stack instanceof RegionDraggableStack || (serializer.supportReading() && serializer.supportSaving())) {
+ if (serializer != null && (stack instanceof RegionDraggableStack || (serializer.supportReading() && serializer.supportSaving()))) {
try {
T regionEntry = stack instanceof RegionDraggableStack ? ((RegionDraggableStack<T>) stack).getEntry().getEntry().copy()
: listener.convertDraggableStack(context, stack);
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/FavoritesListWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/FavoritesListWidget.java
index d55f2a2a3..903adfd53 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/FavoritesListWidget.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/FavoritesListWidget.java
@@ -255,7 +255,7 @@ public class FavoritesListWidget extends WidgetWithBounds implements DraggableSt
this.trashBoundsHeight.update(delta);
double trashBoundsHeight = this.trashBoundsHeight.value();
- if (trashBoundsHeight > 0) {
+ if (Math.round(trashBoundsHeight) > 0) {
double trashBoundsHeightTarget = Math.min(150D, fullBounds.height * 0.15D);
double progress = Math.pow(Mth.clamp(trashBoundsHeight / trashBoundsHeightTarget, 0, 1), 7);
int y = this.fullBounds.getMaxY() - 4 - favoritePanel.getBounds().height;
@@ -289,9 +289,9 @@ public class FavoritesListWidget extends WidgetWithBounds implements DraggableSt
systemHeight += 4;
}
if (favoritePanel.getBounds().height > 20)
- region.getBounds().setBounds(this.fullBounds.x, this.fullBounds.y + systemHeight, this.fullBounds.width, this.fullBounds.height - systemHeight - (this.fullBounds.getMaxY() - this.favoritePanel.bounds.y) - 4 - (trashBoundsHeight <= 0 ? 0 : trashBoundsHeight));
+ region.getBounds().setBounds(this.fullBounds.x, this.fullBounds.y + systemHeight, this.fullBounds.width, this.fullBounds.height - systemHeight - (this.fullBounds.getMaxY() - this.favoritePanel.bounds.y) - 4 - (Math.round(trashBoundsHeight) <= 0 ? 0 : trashBoundsHeight));
else
- region.getBounds().setBounds(this.fullBounds.x, this.fullBounds.y + systemHeight, this.fullBounds.width, this.fullBounds.height - systemHeight - (trashBoundsHeight <= 0 ? 0 : trashBoundsHeight + 24));
+ region.getBounds().setBounds(this.fullBounds.x, this.fullBounds.y + systemHeight, this.fullBounds.width, this.fullBounds.height - systemHeight - (Math.round(trashBoundsHeight) <= 0 ? 0 : trashBoundsHeight + 24));
systemRegion.render(matrices, mouseX, mouseY, delta);
region.render(matrices, mouseX, mouseY, delta);
renderAddFavorite(matrices, mouseX, mouseY, delta);
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/InternalWidgets.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/InternalWidgets.java
index 62b5960ad..5a9712575 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/InternalWidgets.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/InternalWidgets.java
@@ -25,7 +25,6 @@ package me.shedaniel.rei.impl.client.gui.widget;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.vertex.PoseStack;
-import it.unimi.dsi.fastutil.ints.IntList;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.math.impl.PointHelper;
@@ -34,13 +33,12 @@ import me.shedaniel.rei.api.client.config.ConfigObject;
import me.shedaniel.rei.api.client.gui.DrawableConsumer;
import me.shedaniel.rei.api.client.gui.widgets.*;
import me.shedaniel.rei.api.client.registry.display.DisplayCategory;
-import me.shedaniel.rei.api.client.registry.display.TransferDisplayCategory;
import me.shedaniel.rei.api.client.registry.transfer.TransferHandler;
+import me.shedaniel.rei.api.client.registry.transfer.TransferHandlerErrorRenderer;
import me.shedaniel.rei.api.client.registry.transfer.TransferHandlerRegistry;
import me.shedaniel.rei.api.common.display.Display;
import me.shedaniel.rei.api.common.util.CollectionUtils;
import me.shedaniel.rei.impl.ClientInternals;
-import me.shedaniel.rei.impl.client.ClientHelperImpl;
import me.shedaniel.rei.impl.client.gui.toast.CopyRecipeIdentifierToast;
import me.shedaniel.rei.impl.client.gui.widget.basewidgets.*;
import net.fabricmc.api.EnvType;
@@ -48,14 +46,12 @@ import net.fabricmc.api.Environment;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.events.GuiEventListener;
-import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.resources.language.I18n;
-import net.minecraft.network.chat.Component;
-import net.minecraft.network.chat.FormattedText;
-import net.minecraft.network.chat.TextComponent;
-import net.minecraft.network.chat.TranslatableComponent;
+import net.minecraft.network.chat.*;
import net.minecraft.resources.ResourceLocation;
+import org.apache.commons.lang3.mutable.Mutable;
+import org.apache.commons.lang3.mutable.MutableObject;
import org.jetbrains.annotations.ApiStatus;
import java.util.ArrayList;
@@ -71,8 +67,7 @@ public final class InternalWidgets {
public static Widget createAutoCraftingButtonWidget(Rectangle displayBounds, Rectangle rectangle, Component text, Supplier<Display> displaySupplier, Supplier<Collection<ResourceLocation>> idsSupplier, List<Widget> setupDisplay, DisplayCategory<?> category) {
AbstractContainerScreen<?> containerScreen = REIRuntime.getInstance().getPreviousContainerScreen();
- boolean[] visible = {false};
- List<Component>[] errorTooltip = new List[]{null};
+ Mutable<List<Component>> errorTooltip = new MutableObject<>(new ArrayList<>());
Button autoCraftingButton = Widgets.createButton(rectangle, text)
.focusable(false)
.onClick(button -> {
@@ -92,93 +87,10 @@ public final class InternalWidgets {
Minecraft.getInstance().setScreen(containerScreen);
REIRuntime.getInstance().getOverlay().get().queueReloadOverlay();
})
- .onRender((matrices, button) -> {
- button.setEnabled(false);
- if (containerScreen == null) {
- button.setTint(0);
- return;
- }
- List<Component> error = null;
- int color = 0;
- visible[0] = false;
- IntList redSlots = null;
- TransferHandler.Context context = TransferHandler.Context.create(false, containerScreen, displaySupplier.get());
- for (TransferHandler transferHandler : TransferHandlerRegistry.getInstance()) {
- try {
- TransferHandler.Result result = transferHandler.handle(context);
- if (result.isApplicable()) {
- visible[0] = true;
- }
- if (result.isSuccess