From c65b2a347b38724ccb777114f5353e7f18b978b5 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Thu, 14 Oct 2021 20:50:18 +0800 Subject: Make search report better errors, and cache more --- .../java/me/shedaniel/rei/impl/client/REIRuntimeImpl.java | 3 +++ .../me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java | 9 --------- .../shedaniel/rei/impl/client/search/argument/Argument.java | 11 ++++++++++- .../me/shedaniel/rei/impl/client/util/CrashReportUtils.java | 7 +++++++ 4 files changed, 20 insertions(+), 10 deletions(-) (limited to 'runtime') diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/REIRuntimeImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/REIRuntimeImpl.java index 07a94a0b3..e80e5f572 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/REIRuntimeImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/REIRuntimeImpl.java @@ -43,6 +43,7 @@ import me.shedaniel.rei.api.common.registry.ReloadStage; import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; import me.shedaniel.rei.impl.client.gui.hints.HintProvider; import me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchField; +import me.shedaniel.rei.impl.client.search.argument.Argument; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; @@ -216,6 +217,7 @@ public class REIRuntimeImpl implements REIRuntime { @Override public void startReload() { + Argument.SEARCH_CACHE.clear(); getOverlay().ifPresent(ScreenOverlay::queueReloadOverlay); lastDisplayScreen.clear(); } @@ -227,6 +229,7 @@ public class REIRuntimeImpl implements REIRuntime { @Override public void endReload(ReloadStage stage) { + Argument.SEARCH_CACHE.clear(); getOverlay().ifPresent(ScreenOverlay::queueReloadOverlay); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java index b8525b6dc..04901ba45 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java @@ -58,7 +58,6 @@ import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.util.CollectionUtils; import me.shedaniel.rei.api.common.util.EntryStacks; import me.shedaniel.rei.api.common.util.ImmutableTextComponent; -import me.shedaniel.rei.impl.ClientInternals; import me.shedaniel.rei.impl.client.ClientHelperImpl; import me.shedaniel.rei.impl.client.REIRuntimeImpl; import me.shedaniel.rei.impl.client.gui.craftable.CraftableFilter; @@ -70,29 +69,24 @@ import me.shedaniel.rei.impl.client.gui.widget.FavoritesListWidget; import me.shedaniel.rei.impl.client.gui.widget.InternalWidgets; import me.shedaniel.rei.impl.client.gui.widget.LateRenderable; import me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchField; -import me.shedaniel.rei.impl.client.search.argument.Argument; import me.shedaniel.rei.impl.common.util.Weather; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.chat.NarratorChatListener; 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.gui.screens.inventory.tooltip.ClientTooltipComponent; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.PlayerInfo; import net.minecraft.client.renderer.entity.ItemRenderer; import net.minecraft.client.resources.language.I18n; import net.minecraft.client.resources.sounds.SimpleSoundInstance; -import net.minecraft.locale.Language; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.Style; import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.InteractionResult; import net.minecraft.world.inventory.Slot; -import net.minecraft.world.inventory.tooltip.TooltipComponent; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.Blocks; @@ -102,8 +96,6 @@ import org.jetbrains.annotations.Nullable; import java.util.*; import java.util.function.Consumer; import java.util.function.Predicate; -import java.util.stream.Collectors; -import java.util.stream.Stream; @ApiStatus.Internal public class ScreenOverlayImpl extends ScreenOverlay { @@ -225,7 +217,6 @@ public class ScreenOverlayImpl extends ScreenOverlay { } public void init() { - Argument.SEARCH_CACHE.clear(); draggingStack.set(DraggableStackProvider.from(() -> ScreenRegistry.getInstance().getDraggableProviders()), DraggableStackVisitor.from(() -> ScreenRegistry.getInstance().getDraggableVisitors())); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/search/argument/Argument.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/search/argument/Argument.java index b7e733321..0d1ba77b4 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/search/argument/Argument.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/search/argument/Argument.java @@ -29,6 +29,7 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectMaps; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import it.unimi.dsi.fastutil.shorts.Short2ObjectMap; +import it.unimi.dsi.fastutil.shorts.Short2ObjectMaps; import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap; import me.shedaniel.rei.api.client.gui.config.SearchMode; import me.shedaniel.rei.api.common.entry.EntryStack; @@ -40,6 +41,7 @@ import me.shedaniel.rei.impl.client.search.argument.type.ArgumentTypesRegistry; import me.shedaniel.rei.impl.client.search.result.ArgumentApplicableResult; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.minecraft.client.Minecraft; import net.minecraft.util.Unit; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.mutable.Mutable; @@ -50,6 +52,8 @@ import org.jetbrains.annotations.Nullable; import java.util.Collection; import java.util.List; import java.util.Locale; +import java.util.Objects; +import java.util.concurrent.atomic.AtomicReference; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -57,7 +61,8 @@ import java.util.regex.Pattern; @Environment(EnvType.CLIENT) public class Argument { public static final String SPACE = " ", EMPTY = ""; - public static final Short2ObjectMap> SEARCH_CACHE = new Short2ObjectOpenHashMap<>(); + public static final Short2ObjectMap> SEARCH_CACHE = Short2ObjectMaps.synchronize(new Short2ObjectOpenHashMap<>()); + private static final AtomicReference lastLanguage = new AtomicReference<>(); static final Argument ALWAYS = new Argument<>(AlwaysMatchingArgumentType.INSTANCE, EMPTY, true, -1, -1, true); private ArgumentType argumentType; private String text; @@ -169,6 +174,10 @@ public class Argument { @ApiStatus.Internal public static boolean matches(EntryStack stack, List compoundArguments) { if (compoundArguments.isEmpty()) return true; + String newLanguage = Minecraft.getInstance().options.languageCode; + if (!Objects.equals(lastLanguage.getAndSet(newLanguage), newLanguage)) { + SEARCH_CACHE.clear(); + } Mutable mutable = new MutableObject<>(); a: diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/util/CrashReportUtils.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/util/CrashReportUtils.java index d55567909..ac7cc3777 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/util/CrashReportUtils.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/util/CrashReportUtils.java @@ -32,6 +32,13 @@ import net.minecraft.client.gui.screens.Screen; public class CrashReportUtils { public static CrashReport essential(Throwable throwable, String task) { + Throwable temp = throwable; + while (temp != null) { + temp = temp.getCause(); + if (temp instanceof ReportedException reportedException) { + return essential(reportedException, task); + } + } CrashReport report = CrashReport.forThrowable(throwable, task); screen(report, Minecraft.getInstance().screen); return report; -- cgit From a7b0a0dd4b305eb8655b008ebcfdcd2f7b70079a Mon Sep 17 00:00:00 2001 From: shedaniel Date: Fri, 15 Oct 2021 02:43:07 +0800 Subject: Fix merge conflicts --- .../main/java/me/shedaniel/rei/impl/client/util/CrashReportUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/util/CrashReportUtils.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/util/CrashReportUtils.java index ac7cc3777..d3159a9ca 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/util/CrashReportUtils.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/util/CrashReportUtils.java @@ -35,8 +35,8 @@ public class CrashReportUtils { Throwable temp = throwable; while (temp != null) { temp = temp.getCause(); - if (temp instanceof ReportedException reportedException) { - return essential(reportedException, task); + if (temp instanceof ReportedException) { + return essential(temp, task); } } CrashReport report = CrashReport.forThrowable(throwable, task); -- cgit From 3a84bfa28bb233b3a6f0a14f2e90956a98512453 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Fri, 15 Oct 2021 02:43:32 +0800 Subject: Add tag match & JEI recipe ids --- .../gui/screen/DefaultDisplayViewingScreen.java | 43 ++++++++++++++++++++++ .../rei/impl/client/gui/widget/EntryWidget.java | 9 +++++ .../impl/client/gui/widget/InternalWidgets.java | 3 +- .../assets/roughlyenoughitems/lang/en_us.json | 1 + 4 files changed, 55 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java index 08fa19f81..c190033b2 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java @@ -29,6 +29,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.math.Matrix4f; +import me.shedaniel.architectury.fluid.FluidStack; import me.shedaniel.clothconfig2.api.ModifierKeyCode; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; @@ -46,6 +47,9 @@ import me.shedaniel.rei.api.client.view.ViewSearchBuilder; import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.display.Display; import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.entry.type.EntryType; +import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; import me.shedaniel.rei.api.common.util.CollectionUtils; import me.shedaniel.rei.api.common.util.ImmutableTextComponent; import me.shedaniel.rei.impl.client.ClientHelperImpl; @@ -67,7 +71,11 @@ import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; +import net.minecraft.tags.Tag; +import net.minecraft.tags.TagCollection; +import net.minecraft.tags.TagContainer; import net.minecraft.util.Mth; +import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; @@ -246,8 +254,12 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen { int displayWidth = getCurrentCategory().getDisplayWidth(displaySupplier.get()); final Rectangle displayBounds = new Rectangle(getBounds().getCenterX() - displayWidth / 2, getBounds().getCenterY() + 16 - recipeHeight * (getRecipesPerPage() + 1) / 2 - 2 * (getRecipesPerPage() + 1) + recipeHeight * i + 4 * i, displayWidth, recipeHeight); List setupDisplay = getCurrentCategory().setupDisplay(display, displayBounds); + setupTags(setupDisplay); transformIngredientNotice(setupDisplay, ingredientStackToNotice); transformResultNotice(setupDisplay, resultStackToNotice); + for (EntryWidget widget : Widgets.walk(widgets, EntryWidget.class::isInstance)) { + widget.removeTagMatch = true; + } recipeBounds.put(displayBounds, setupDisplay); this.widgets.addAll(setupDisplay); if (supplier.isPresent() && supplier.get().get(displayBounds) != null) @@ -287,6 +299,37 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen { _children().addAll(preWidgets); } + private void setupTags(List widgets) { + TagContainer tags = Minecraft.getInstance().getConnection().getTags(); + outer: + for (EntryWidget widget : Widgets.walk(widgets, EntryWidget.class::isInstance)) { + widget.removeTagMatch = false; + if (widget.getEntries().size() <= 1) continue; + EntryType type = null; + for (EntryStack entry : widget.getEntries()) { + if (type == null) { + type = entry.getType(); + } else if (type != entry.getType()) { + continue outer; + } + } + // TODO: Don't hardcode + TagCollection collection; + List objects; + if (type == VanillaEntryTypes.ITEM) { + collection = tags.getItems(); + objects = CollectionUtils.map(widget.getEntries(), stack -> stack.castValue().getItem()); + } else if (type == VanillaEntryTypes.FLUID) { + collection = tags.getFluids(); + objects = CollectionUtils.map(widget.getEntries(), stack -> stack.castValue().getFluid()); + } else continue; + Map.Entry> firstOrNull = CollectionUtils.findFirstOrNull(collection.getAllTags().entrySet(), entry -> entry.getValue().getValues().equals(objects)); + if (firstOrNull != null) { + widget.tagMatch = firstOrNull.getKey(); + } + } + } + public List getWidgets() { return widgets; } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java index 053186a50..f1693459b 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java @@ -43,12 +43,14 @@ import me.shedaniel.rei.api.client.view.ViewSearchBuilder; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.impl.client.REIRuntimeImpl; import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; +import net.minecraft.ChatFormatting; import net.minecraft.CrashReport; import net.minecraft.CrashReportCategory; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.resources.language.I18n; import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import org.jetbrains.annotations.ApiStatus; @@ -77,6 +79,8 @@ public class EntryWidget extends Slot implements DraggableStackProviderWidget { protected boolean wasClicked = false; private Rectangle bounds; private List> entryStacks; + public ResourceLocation tagMatch; + public boolean removeTagMatch = true; public EntryWidget(Point point) { this(new Rectangle(point.x - 1, point.y - 1, 18, 18)); @@ -231,6 +235,7 @@ public class EntryWidget extends Slot implements DraggableStackProviderWidget { } entryStacks.add(stack); } + if (removeTagMatch) tagMatch = null; return this; } @@ -241,6 +246,7 @@ public class EntryWidget extends Slot implements DraggableStackProviderWidget { entryStacks = new ArrayList<>(entryStacks); } entryStacks.addAll(stacks); + if (removeTagMatch) tagMatch = null; } return this; } @@ -318,6 +324,9 @@ public class EntryWidget extends Slot implements DraggableStackProviderWidget { tooltip.addAllTexts(Stream.of(I18n.get("text.rei.favorites_tooltip", name).split("\n")) .map(TextComponent::new).collect(Collectors.toList())); } + if (tagMatch != null) { + tooltip.add(new TranslatableComponent("text.rei.tag_match", tagMatch.toString()).withStyle(ChatFormatting.GRAY)); + } tooltip.queue(); } } 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 8df053102..1529a9e4b 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 @@ -48,6 +48,7 @@ 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; @@ -176,7 +177,7 @@ public final class InternalWidgets { str.add(errorTooltip[0].get(0).copy().withStyle(ChatFormatting.RED)); } } - if (Minecraft.getInstance().options.advancedItemTooltips && displaySupplier.get().getDisplayLocation().isPresent()) { + if ((Minecraft.getInstance().options.advancedItemTooltips || Screen.hasShiftDown()) && displaySupplier.get().getDisplayLocation().isPresent()) { str.add(new TranslatableComponent("text.rei.recipe_id", "", new TextComponent(displaySupplier.get().getDisplayLocation().get().toString()).withStyle(ChatFormatting.GRAY)).withStyle(ChatFormatting.GRAY)); } return str.toArray(new Component[0]); diff --git a/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json b/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json index bd3b05295..beddd9239 100755 --- a/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json +++ b/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json @@ -47,6 +47,7 @@ "text.rei.cheat_items": "Gave [{item_name}§f] x{item_count} to {player_name}.", "text.rei.failed_cheat_items": "§cFailed to give items.", "text.rei.too_long_nbt": "§cItem NBT is too long to be applied in multiplayer.", + "text.rei.tag_match": "Tag: %s", "ordering.rei.ascending": "Ascending", "ordering.rei.descending": "Descending", "ordering.rei.registry": "Registry", -- cgit From 6e7a641926d8b0ea2d0a1caddbf348fe24b669ce Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 16 Oct 2021 00:37:19 +0800 Subject: Fix JEI recipes duplicating and going to the wrong category, Fix JER's insane resource reload during plugin application, Add DisplayAdditionReason, Safeguard DisplayCategory#setupDisplay --- .../gui/screen/AbstractDisplayViewingScreen.java | 40 ++++++++++++++++ .../gui/screen/CompositeDisplayViewingScreen.java | 17 ++++++- .../gui/screen/DefaultDisplayViewingScreen.java | 55 +++++----------------- .../registry/display/DisplayRegistryImpl.java | 23 ++++++--- .../rei/impl/common/plugins/PluginManagerImpl.java | 49 +++++++++++++++---- 5 files changed, 122 insertions(+), 62 deletions(-) (limited to 'runtime') diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java index 0d69d3fce..48aea3c1a 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java @@ -24,6 +24,7 @@ package me.shedaniel.rei.impl.client.gui.screen; import com.google.common.collect.Lists; +import me.shedaniel.architectury.fluid.FluidStack; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.screen.DisplayScreen; import me.shedaniel.rei.api.client.gui.widgets.Slot; @@ -33,12 +34,20 @@ import me.shedaniel.rei.api.client.registry.display.DisplayCategory; import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.display.Display; import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.entry.type.EntryType; +import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; import me.shedaniel.rei.api.common.util.CollectionUtils; import me.shedaniel.rei.impl.client.ClientHelperImpl; import me.shedaniel.rei.impl.client.gui.widget.EntryWidget; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.chat.NarratorChatListener; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.Tag; +import net.minecraft.tags.TagCollection; +import net.minecraft.tags.TagContainer; +import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -151,4 +160,35 @@ public abstract class AbstractDisplayViewingScreen extends Screen implements Dis } } } + + protected void setupTags(List widgets) { + TagContainer tags = Minecraft.getInstance().getConnection().getTags(); + outer: + for (EntryWidget widget : Widgets.walk(widgets, EntryWidget.class::isInstance)) { + widget.removeTagMatch = false; + if (widget.getEntries().size() <= 1) continue; + EntryType type = null; + for (EntryStack entry : widget.getEntries()) { + if (type == null) { + type = entry.getType(); + } else if (type != entry.getType()) { + continue outer; + } + } + // TODO: Don't hardcode + TagCollection collection; + List objects; + if (type == VanillaEntryTypes.ITEM) { + collection = tags.getItems(); + objects = CollectionUtils.map(widget.getEntries(), stack -> stack.castValue().getItem()); + } else if (type == VanillaEntryTypes.FLUID) { + collection = tags.getFluids(); + objects = CollectionUtils.map(widget.getEntries(), stack -> stack.castValue().getFluid()); + } else continue; + Map.Entry> firstOrNull = CollectionUtils.findFirstOrNull(collection.getAllTags().entrySet(), entry -> entry.getValue().getValues().equals(objects)); + if (firstOrNull != null) { + widget.tagMatch = firstOrNull.getKey(); + } + } + } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java index b2b86fb47..5d1d66a98 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java @@ -47,6 +47,7 @@ import me.shedaniel.rei.api.common.display.Display; import me.shedaniel.rei.api.common.entry.EntryIngredient; import me.shedaniel.rei.impl.client.ClientHelperImpl; import me.shedaniel.rei.impl.client.REIRuntimeImpl; +import me.shedaniel.rei.impl.client.gui.widget.EntryWidget; import me.shedaniel.rei.impl.client.gui.widget.InternalWidgets; import me.shedaniel.rei.impl.client.gui.widget.TabWidget; import net.minecraft.client.Minecraft; @@ -61,6 +62,7 @@ import net.minecraft.util.Mth; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Optional; @@ -152,9 +154,22 @@ public class CompositeDisplayViewingScreen extends AbstractDisplayViewingScreen this.widgets.add(Widgets.createSlotBase(scrollListBounds)); Rectangle recipeBounds = new Rectangle(bounds.x + 100 + (guiWidth - 100) / 2 - category.getDisplayWidth(display) / 2, bounds.y + bounds.height / 2 - category.getDisplayHeight() / 2, category.getDisplayWidth(display), category.getDisplayHeight()); - List setupDisplay = category.setupDisplay(display, recipeBounds); + List setupDisplay; + try { + setupDisplay = category.setupDisplay(display, recipeBounds); + } catch (Throwable throwable) { + throwable.printStackTrace(); + setupDisplay = new ArrayList<>(); + setupDisplay.add(Widgets.createRecipeBase(bounds).color(0xFFBB0000)); + setupDisplay.add(Widgets.createLabel(new Point(bounds.getCenterX(), bounds.getCenterY() - 8), new TextComponent("Failed to initiate setupDisplay"))); + setupDisplay.add(Widgets.createLabel(new Point(bounds.getCenterX(), bounds.getCenterY() + 1), new TextComponent("Check console for error"))); + } + setupTags(setupDisplay); transformIngredientNotice(setupDisplay, ingredientStackToNotice); transformResultNotice(setupDisplay, resultStackToNotice); + for (EntryWidget widget : Widgets.walk(widgets, EntryWidget.class::isInstance)) { + widget.removeTagMatch = true; + } this.widgets.addAll(setupDisplay); Optional supplier = CategoryRegistry.getInstance().get(category.getCategoryIdentifier()).getPlusButtonArea(); if (supplier.isPresent() && supplier.get().get(recipeBounds) != null) diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java index c190033b2..52e5b3a67 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java @@ -29,7 +29,6 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.math.Matrix4f; -import me.shedaniel.architectury.fluid.FluidStack; import me.shedaniel.clothconfig2.api.ModifierKeyCode; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; @@ -47,9 +46,6 @@ import me.shedaniel.rei.api.client.view.ViewSearchBuilder; import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.display.Display; import me.shedaniel.rei.api.common.entry.EntryIngredient; -import me.shedaniel.rei.api.common.entry.EntryStack; -import me.shedaniel.rei.api.common.entry.type.EntryType; -import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; import me.shedaniel.rei.api.common.util.CollectionUtils; import me.shedaniel.rei.api.common.util.ImmutableTextComponent; import me.shedaniel.rei.impl.client.ClientHelperImpl; @@ -71,18 +67,11 @@ import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; -import net.minecraft.tags.Tag; -import net.minecraft.tags.TagCollection; -import net.minecraft.tags.TagContainer; import net.minecraft.util.Mth; -import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; import java.util.function.Supplier; @ApiStatus.Internal @@ -253,7 +242,16 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen { final Supplier displaySupplier = () -> display; int displayWidth = getCurrentCategory().getDisplayWidth(displaySupplier.get()); final Rectangle displayBounds = new Rectangle(getBounds().getCenterX() - displayWidth / 2, getBounds().getCenterY() + 16 - recipeHeight * (getRecipesPerPage() + 1) / 2 - 2 * (getRecipesPerPage() + 1) + recipeHeight * i + 4 * i, displayWidth, recipeHeight); - List setupDisplay = getCurrentCategory().setupDisplay(display, displayBounds); + List setupDisplay; + try { + setupDisplay = getCurrentCategory().setupDisplay(display, displayBounds); + } catch (Throwable throwable) { + throwable.printStackTrace(); + setupDisplay = new ArrayList<>(); + setupDisplay.add(Widgets.createRecipeBase(bounds).color(0xFFBB0000)); + setupDisplay.add(Widgets.createLabel(new Point(bounds.getCenterX(), bounds.getCenterY() - 8), new TextComponent("Failed to initiate setupDisplay"))); + setupDisplay.add(Widgets.createLabel(new Point(bounds.getCenterX(), bounds.getCenterY() + 1), new TextComponent("Check console for error"))); + } setupTags(setupDisplay); transformIngredientNotice(setupDisplay, ingredientStackToNotice); transformResultNotice(setupDisplay, resultStackToNotice); @@ -299,37 +297,6 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen { _children().addAll(preWidgets); } - private void setupTags(List widgets) { - TagContainer tags = Minecraft.getInstance().getConnection().getTags(); - outer: - for (EntryWidget widget : Widgets.walk(widgets, EntryWidget.class::isInstance)) { - widget.removeTagMatch = false; - if (widget.getEntries().size() <= 1) continue; - EntryType type = null; - for (EntryStack entry : widget.getEntries()) { - if (type == null) { - type = entry.getType(); - } else if (type != entry.getType()) { - continue outer; - } - } - // TODO: Don't hardcode - TagCollection collection; - List objects; - if (type == VanillaEntryTypes.ITEM) { - collection = tags.getItems(); - objects = CollectionUtils.map(widget.getEntries(), stack -> stack.castValue().getItem()); - } else if (type == VanillaEntryTypes.FLUID) { - collection = tags.getFluids(); - objects = CollectionUtils.map(widget.getEntries(), stack -> stack.castValue().getFluid()); - } else continue; - Map.Entry> firstOrNull = CollectionUtils.findFirstOrNull(collection.getAllTags().entrySet(), entry -> entry.getValue().getValues().equals(objects)); - if (firstOrNull != null) { - widget.tagMatch = firstOrNull.getKey(); - } - } - } - public List getWidgets() { return widgets; } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayRegistryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayRegistryImpl.java index e638f14fd..bfc975188 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayRegistryImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayRegistryImpl.java @@ -31,6 +31,8 @@ import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; import me.shedaniel.rei.api.client.registry.display.DisplayCategory; import me.shedaniel.rei.api.client.registry.display.DisplayRegistry; import me.shedaniel.rei.api.client.registry.display.DynamicDisplayGenerator; +import me.shedaniel.rei.api.client.registry.display.reason.DisplayAdditionReason; +import me.shedaniel.rei.api.client.registry.display.reason.DisplayAdditionReasons; import me.shedaniel.rei.api.client.registry.display.visibility.DisplayVisibilityPredicate; import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.display.Display; @@ -41,6 +43,7 @@ import org.jetbrains.annotations.Nullable; import java.util.*; import java.util.concurrent.ConcurrentHashMap; +import java.util.function.BiPredicate; import java.util.function.Function; import java.util.function.Predicate; @@ -139,9 +142,14 @@ public class DisplayRegistryImpl extends RecipeManagerContextImpl typeClass.isInstance(o) && ((Predicate) predicate).test((T) o), o -> ((Function) filler).apply((T) o)); } + @Override + public void registerFiller(Class typeClass, BiPredicate predicate, Function filler) { + fillers.add(new DisplayFiller<>((o, s) -> typeClass.isInstance(o) && ((BiPredicate) predicate).test(o, s), (Function) filler)); + } + @Override public void registerFiller(Predicate predicate, Function filler) { - fillers.add(new DisplayFiller<>((Predicate) predicate, (Function) filler)); + fillers.add(new DisplayFiller<>((o, s) -> ((Predicate) predicate).test(o), (Function) filler)); } @Override @@ -160,17 +168,18 @@ public class DisplayRegistryImpl extends RecipeManagerContextImpl> allSortedRecipes = getAllSortedRecipes(); for (int i = allSortedRecipes.size() - 1; i >= 0; i--) { Recipe recipe = allSortedRecipes.get(i); - add(recipe); + addWithReason(recipe, DisplayAdditionReason.RECIPE_MANAGER); } } } @Override - public Collection tryFillDisplay(T value) { + public Collection tryFillDisplay(T value, DisplayAdditionReason... reason) { if (value instanceof Display) return Collections.singleton((Display) value); List displays = null; + DisplayAdditionReasons reasons = reason.length == 0 ? DisplayAdditionReasons.Impl.EMPTY : new DisplayAdditionReasons.Impl(reason); for (DisplayFiller filler : fillers) { - Display display = tryFillDisplayGenerics(filler, value); + Display display = tryFillDisplayGenerics(filler, value, reasons); if (display != null) { if (displays == null) displays = Collections.singletonList(display); else { @@ -185,9 +194,9 @@ public class DisplayRegistryImpl extends RecipeManagerContextImpl D tryFillDisplayGenerics(DisplayFiller filler, Object value) { + private D tryFillDisplayGenerics(DisplayFiller filler, Object value, DisplayAdditionReasons reasons) { try { - if (filler.predicate.test(value)) { + if (filler.predicate.test(value, reasons)) { return filler.mappingFunction.apply(value); } } catch (Throwable e) { @@ -204,7 +213,7 @@ public class DisplayRegistryImpl extends RecipeManagerContextImpl( - Predicate predicate, + BiPredicate predicate, Function mappingFunction ) {} diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java index 82bc8f518..f3421e76e 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java @@ -23,10 +23,13 @@ package me.shedaniel.rei.impl.common.plugins; -import com.google.common.base.MoreObjects; import com.google.common.base.Stopwatch; import com.google.common.collect.FluentIterable; import com.google.common.collect.Iterables; +import me.shedaniel.architectury.platform.Platform; +import me.shedaniel.architectury.utils.Env; +import me.shedaniel.architectury.utils.EnvExecutor; +import me.shedaniel.architectury.utils.GameInstance; import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.plugins.PluginView; @@ -36,8 +39,11 @@ import me.shedaniel.rei.api.common.registry.ReloadStage; import me.shedaniel.rei.api.common.registry.Reloadable; import me.shedaniel.rei.api.common.util.CollectionUtils; import net.minecraft.Util; +import net.minecraft.client.Minecraft; +import net.minecraft.server.MinecraftServer; import org.apache.commons.lang3.tuple.MutablePair; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; import java.io.Closeable; import java.util.*; @@ -103,7 +109,7 @@ public class PluginManagerImpl

> implements PluginManager< @Override public void registerPlugin(REIPluginProvider plugin) { plugins.add((REIPluginProvider

) plugin); - RoughlyEnoughItemsCore.LOGGER.info("Registered plugin provider %s for %s", plugin.getPluginProviderName(), pluginClass.getSimpleName()); + RoughlyEnoughItemsCore.LOGGER.info("Registered plugin provider %s for %s", plugin.getPluginProviderName(), name(pluginClass)); } @Override @@ -139,23 +145,40 @@ public class PluginManagerImpl

> implements PluginManager< return new SectionClosable(sectionData, section); } - private void pluginSection(MutablePair sectionData, String sectionName, List

list, Consumer

consumer) { + private void pluginSection(MutablePair sectionData, String sectionName, List

list, @Nullable Reloadable reloadable, Consumer

consumer) { for (P plugin : list) { try (SectionClosable section = section(sectionData, sectionName + " for " + plugin.getPluginProviderName())) { - consumer.accept(plugin); + if (reloadable == null || !plugin.shouldBeForcefullyDoneOnMainThread(reloadable)) { + consumer.accept(plugin); + } else if (Platform.getEnvironment() == Env.CLIENT) { + EnvExecutor.runInEnv(Env.CLIENT, () -> () -> queueExecutionClient(() -> consumer.accept(plugin))); + } else { + queueExecution(() -> consumer.accept(plugin)); + } } catch (Throwable throwable) { RoughlyEnoughItemsCore.LOGGER.error(plugin.getPluginProviderName() + " plugin failed to " + sectionName + "!", throwable); } } } + private void queueExecution(Runnable runnable) { + MinecraftServer server = GameInstance.getServer(); + if (server != null) { + server.executeBlocking(runnable); + } + } + + private void queueExecutionClient(Runnable runnable) { + Minecraft.getInstance().executeBlocking(runnable); + } + @Override public void pre() { List

plugins = new ArrayList<>(getPlugins().toList()); plugins.sort(Comparator.comparingDouble(P::getPriority).reversed()); Collections.reverse(plugins); MutablePair sectionData = new MutablePair<>(Stopwatch.createUnstarted(), ""); - pluginSection(sectionData, "pre-register", plugins, REIPlugin::preRegister); + pluginSection(sectionData, "pre-register", plugins, null, REIPlugin::preRegister); } @Override @@ -164,7 +187,13 @@ public class PluginManagerImpl

> implements PluginManager< plugins.sort(Comparator.comparingDouble(P::getPriority).reversed()); Collections.reverse(plugins); MutablePair sectionData = new MutablePair<>(Stopwatch.createUnstarted(), ""); - pluginSection(sectionData, "post-register", plugins, REIPlugin::postRegister); + pluginSection(sectionData, "post-register", plugins, null, REIPlugin::postRegister); + } + + private static String name(Class clazz) { + String simpleName = clazz.getSimpleName(); + if (simpleName.isEmpty()) return clazz.getName(); + return simpleName; } @Override @@ -176,7 +205,7 @@ public class PluginManagerImpl

> implements PluginManager< for (Reloadable

reloadable : reloadables) { Class reloadableClass = reloadable.getClass(); - try (SectionClosable startReload = section(sectionData, "start-reload-" + MoreObjects.firstNonNull(reloadableClass.getSimpleName(), reloadableClass.getName()))) { + try (SectionClosable startReload = section(sectionData, "start-reload-" + name(reloadableClass))) { reloadable.startReload(stage); } catch (Throwable throwable) { throwable.printStackTrace(); @@ -185,17 +214,17 @@ public class PluginManagerImpl

> implements PluginManager< List

plugins = new ArrayList<>(getPlugins().toList()); plugins.sort(Comparator.comparingDouble(P::getPriority).reversed()); - RoughlyEnoughItemsCore.LOGGER.info("Reloading Plugin Manager [%s] stage [%s], registered %d plugins: %s", pluginClass.getSimpleName(), stage.toString(), plugins.size(), CollectionUtils.mapAndJoinToString(plugins, REIPlugin::getPluginProviderName, ", ")); + RoughlyEnoughItemsCore.LOGGER.info("Reloading Plugin Manager [%s] stage [%s], registered %d plugins: %s", name(pluginClass), stage.toString(), plugins.size(), CollectionUtils.mapAndJoinToString(plugins, REIPlugin::getPluginProviderName, ", ")); Collections.reverse(plugins); for (Reloadable

reloadable : getReloadables()) { Class reloadableClass = reloadable.getClass(); - pluginSection(sectionData, "reloadable-plugin-" + MoreObjects.firstNonNull(reloadableClass.getSimpleName(), reloadableClass.getName()), plugins, plugin -> reloadable.acceptPlugin(plugin, stage)); + pluginSection(sectionData, "reloadable-plugin-" + name(reloadableClass), plugins, reloadable, plugin -> reloadable.acceptPlugin(plugin, stage)); } for (Reloadable

reloadable : reloadables) { Class reloadableClass = reloadable.getClass(); - try (SectionClosable endReload = section(sectionData, "end-reload-" + MoreObjects.firstNonNull(reloadableClass.getSimpleName(), reloadableClass.getName()))) { + try (SectionClosable endReload = section(sectionData, "end-reload-" + name(reloadableClass))) { reloadable.endReload(stage); } catch (Throwable throwable) { throwable.printStackTrace(); -- cgit From 1dcf535cdf25c808ee4c0827a27c5b0e50094fda Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 16 Oct 2021 00:59:29 +0800 Subject: Fix merge conflicts --- .../rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java | 7 ++++--- .../me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'runtime') diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java index 48aea3c1a..c9015efa3 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java @@ -24,7 +24,7 @@ package me.shedaniel.rei.impl.client.gui.screen; import com.google.common.collect.Lists; -import me.shedaniel.architectury.fluid.FluidStack; +import dev.architectury.fluid.FluidStack; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.screen.DisplayScreen; import me.shedaniel.rei.api.client.gui.widgets.Slot; @@ -43,6 +43,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.chat.NarratorChatListener; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; +import net.minecraft.core.Registry; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.Tag; import net.minecraft.tags.TagCollection; @@ -179,10 +180,10 @@ public abstract class AbstractDisplayViewingScreen extends Screen implements Dis TagCollection collection; List objects; if (type == VanillaEntryTypes.ITEM) { - collection = tags.getItems(); + collection = tags.getOrEmpty(Registry.ITEM_REGISTRY); objects = CollectionUtils.map(widget.getEntries(), stack -> stack.castValue().getItem()); } else if (type == VanillaEntryTypes.FLUID) { - collection = tags.getFluids(); + collection = tags.getOrEmpty(Registry.FLUID_REGISTRY); objects = CollectionUtils.map(widget.getEntries(), stack -> stack.castValue().getFluid()); } else continue; Map.Entry> firstOrNull = CollectionUtils.findFirstOrNull(collection.getAllTags().entrySet(), entry -> entry.getValue().getValues().equals(objects)); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java index f3421e76e..5969aada1 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java @@ -26,10 +26,10 @@ package me.shedaniel.rei.impl.common.plugins; import com.google.common.base.Stopwatch; import com.google.common.collect.FluentIterable; import com.google.common.collect.Iterables; -import me.shedaniel.architectury.platform.Platform; -import me.shedaniel.architectury.utils.Env; -import me.shedaniel.architectury.utils.EnvExecutor; -import me.shedaniel.architectury.utils.GameInstance; +import dev.architectury.platform.Platform; +import dev.architectury.utils.Env; +import dev.architectury.utils.EnvExecutor; +import dev.architectury.utils.GameInstance; import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.plugins.PluginView; -- cgit From 23e61ae08a66fa07f045c91bcbe2d46f705deacd Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 16 Oct 2021 01:06:55 +0800 Subject: Remove favorites dragging overlay --- .../me/shedaniel/rei/impl/client/gui/widget/FavoritesListWidget.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') 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 e89ff560e..5041887a4 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 @@ -276,7 +276,7 @@ public class FavoritesListWidget extends WidgetWithBounds implements DraggableSt @Override public Stream getDraggableAcceptingBounds(DraggingContext context, DraggableStack stack) { - return checkDraggedStacks(context, stack).isPresent() ? Stream.of(DraggableStackVisitor.BoundsProvider.ofShape(buildBounds())) : Stream.empty(); + return Stream.empty(); } private VoxelShape buildBounds() { -- cgit From abca1dbfc50a4fcc15fbabf370a5c7338151e204 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 16 Oct 2021 02:06:00 +0800 Subject: Update translations --- .../assets/roughlyenoughitems/lang/de_de.json | 11 ++++++++ .../assets/roughlyenoughitems/lang/fr_fr.json | 33 ++++++++++++---------- 2 files changed, 29 insertions(+), 15 deletions(-) (limited to 'runtime') diff --git a/runtime/src/main/resources/assets/roughlyenoughitems/lang/de_de.json b/runtime/src/main/resources/assets/roughlyenoughitems/lang/de_de.json index f19427e89..583b25ba6 100644 --- a/runtime/src/main/resources/assets/roughlyenoughitems/lang/de_de.json +++ b/runtime/src/main/resources/assets/roughlyenoughitems/lang/de_de.json @@ -7,6 +7,12 @@ "text.rei.cheating_limited_creative_enabled": "§aCheating aktiviert (Kreativ verwenden)", "text.rei.no_permission_cheat": "Operator-Berechtigungen sind erforderlich, um Gegenstände zu cheaten", "text.rei.search.field.suggestion": "Suche...", + "text.rei.feedback": "Möchtest du dem REI Entwickler dein Feedback geben? %s um dein Feedback einzureichen!", + "text.rei.feedback.link": "Klicke hier um das Google-Form zu besuchen", + "text.rei.not.fully.initialized": "REI noch nicht vollständig initialisiert!", + "text.rei.not.fully.initialized.tooltip": "Fehlende Stufen: %s\nFalls dies nicht weggeht,\nversuche mit den Logs nach Unterstützung zu suchen!", + "text.rei.inventory.highlighting.enabled": "Inventarhervorhebung an", + "text.rei.inventory.highlighting.enabled.tooltip": "Dies macht Slots, die nicht mit dem\nSuchfilter übereinstimmen grau.\nDoppelklicke die Suchleiste, um diesen Modus an- und auszuschalten.", "category.rei.crafting": "Herstellen", "category.rei.smelting": "Schmelzen", "category.rei.smelting.fuel": "Brennstoff", @@ -40,6 +46,7 @@ "text.rei.config_tooltip": "Öffne das Konfig-Menü\n§7Shift-Klick um den Cheatenmodus ein-/auszuschalten", "text.rei.cheat_items": "[{item_name}] x{item_count} {player_name} gegeben.", "text.rei.failed_cheat_items": "§cItems geben fehlgeschlagen.", + "text.rei.too_long_nbt": "§cGegenstand NBT ist zu lang, um im Multiplayer angewendet zu werden.", "ordering.rei.ascending": "Aufsteigend", "ordering.rei.descending": "Absteigend", "ordering.rei.registry": "Registrierung", @@ -97,6 +104,7 @@ "text.rei.jei_compat.false": "JEI-Kompatibilitätsschicht: Deaktiviert", "text.rei.jei_compat.true": "JEI-Kompatibilitätsschicht: Deaktiviert", "text.rei.jei_compat.sub": "Soll JEI Kompabilität geladen werden %s§7?\n§7Dies lädt JEI Plugins aus diesen Quellen:\n%s\n\n§7REI's JEI Kompabilität ist nicht ausgereift und kann Probleme verursachen.\n§cBENUTZUNG AUF EIGENE GEFAHR!", + "text.rei.jei_compat.sub.stability": "§c§l(ALPHA)", "text.rei.view_recipes_for": "Rezepte für %s anzeigen", "text.rei.subsets": "Untergruppen", "text.rei.tiny_potato": "Kleine Kartöffelchen", @@ -104,6 +112,7 @@ "favorite.section.gamemode": "Spielmodus", "favorite.section.weather": "Wetter", "tooltip.rei.fluid_amount": "§7%d Einheit", + "tooltip.rei.fluid_amount.forge": "§7%d mB", "tooltip.rei.drag_to_add_favorites": "§7Ziehe dies zu deinen Favoriten!", "msg.rei.copied_recipe_id": "Rezept-Identifizierer kopiert", "msg.rei.recipe_id_details": "Rezept-ID: %s", @@ -129,6 +138,7 @@ "config.roughlyenoughitems.keyBindings.copyRecipeIdentifierKeybind": "Rezept-Identifizierer kopieren:", "config.roughlyenoughitems.keyBindings.exportImageKeybind": "Rezept exportieren", "config.roughlyenoughitems.keyBindings.favoriteKeybind": "Favoriten-Eintrag:", + "config.roughlyenoughitems.keyBindings.previousScreenKeybind": "Vorheriger Bildschirm:", "config.roughlyenoughitems.cheatingStyle": "Cheating Style:", "config.roughlyenoughitems.cheatingStyle.grab": "Nehmen", "config.roughlyenoughitems.cheatingStyle.give": "Geben", @@ -140,6 +150,7 @@ "config.roughlyenoughitems.recipeScreenType.config": "Art des Rezept-Bildschirms: %s", "config.roughlyenoughitems.recipeScreenType.unset": "Nicht Gesetzt", "config.roughlyenoughitems.recipeScreenType.original": "Standard", + "config.roughlyenoughitems.recipeScreenType.composite": "Komposit", "config.roughlyenoughitems.layout": "Layout", "config.roughlyenoughitems.tooltips": "Tooltips", "config.roughlyenoughitems.accessibility": "Bedienungshilfen", diff --git a/runtime/src/main/resources/assets/roughlyenoughitems/lang/fr_fr.json b/runtime/src/main/resources/assets/roughlyenoughitems/lang/fr_fr.json index e9e3bd0cd..a3e5b974c 100644 --- a/runtime/src/main/resources/assets/roughlyenoughitems/lang/fr_fr.json +++ b/runtime/src/main/resources/assets/roughlyenoughitems/lang/fr_fr.json @@ -11,6 +11,8 @@ "text.rei.feedback.link": "Clickez ici pour visiter le formulaire Google", "text.rei.not.fully.initialized": "REI pas encore complètement initialisé !", "text.rei.not.fully.initialized.tooltip": "Étapes manquantes : %s\nSi cela ne disparaît pas,\nessayez de chercher de l'aide avec les logs !", + "text.rei.inventory.highlighting.enabled": "Surbrillance de l'inventaire activé", + "text.rei.inventory.highlighting.enabled.tooltip": "Cela rend les emplacements non correspondant gris.\nDouble-cliquez sur la barre de recherche pour activer ce mode.", "category.rei.crafting": "Fabrication", "category.rei.smelting": "Cuisson", "category.rei.smelting.fuel": "Combustible", @@ -96,7 +98,7 @@ "text.rei.working_station": "Poste de travail", "text.rei.release_export": "Relâchez %s pour exporter", "text.rei.recipe_id": "\n%sID de recette : %s", - "text.rei.recipe_screen_type.selection": "Sélection du type d'affichage des recettes", + "text.rei.recipe_screen_type.selection": "Écran de sélection du type d'affichage des recettes", "text.rei.recipe_screen_type.selection.sub": "Vous pouvez toujours changer cette option dans l'écran de configuration.", "text.rei.jei_compat": "Couche de compatibilité pour JEI", "text.rei.jei_compat.false": "Couche de compatibilité JEI : Désactivé", @@ -140,7 +142,7 @@ "config.roughlyenoughitems.cheatingStyle": "Style de triche :", "config.roughlyenoughitems.cheatingStyle.grab": "Saisir", "config.roughlyenoughitems.cheatingStyle.give": "Donner", - "config.roughlyenoughitems.motion": "Paramètres animation / de mouvement", + "config.roughlyenoughitems.motion": "Paramètres d'animations / de mouvements", "config.roughlyenoughitems.motion.configScreenAnimation": "Écran de configuration animé :", "config.roughlyenoughitems.motion.creditsScreenAnimation": "Ecran de fin animé :", "config.roughlyenoughitems.motion.favoritesAnimation": "Favoris animés :", @@ -161,12 +163,12 @@ "config.roughlyenoughitems.allowInventoryHighlighting": "Activer la mise en évidence d'inventaire :", "config.roughlyenoughitems.miscellaneous.renderEntryEnchantmentGlint": "Afficher l'aura des enchantements :", "config.roughlyenoughitems.layout.configButtonLocation": "Position du bouton de configuration :", - "config.roughlyenoughitems.layout.configButtonLocation.upper": "Haut", + "config.roughlyenoughitems.layout.configButtonLocation.upper": "Plus haut", "config.roughlyenoughitems.layout.configButtonLocation.lower": "Bas", - "config.roughlyenoughitems.filteredEntries.selectAll": "Sélect. tout", - "config.roughlyenoughitems.filteredEntries.selectNone": "Désélect. tout", + "config.roughlyenoughitems.filteredEntries.selectAll": "Tout sélectionner", + "config.roughlyenoughitems.filteredEntries.selectNone": "Tout désélectionner", "config.roughlyenoughitems.filteredEntries.hide": "Masquer", - "config.roughlyenoughitems.filteredEntries.show": "Afficher", + "config.roughlyenoughitems.filteredEntries.show": "Afficher la sélection", "config.roughlyenoughitems.filteredEntries.loadWorldFirst": "Charger d'abord le monde !", "config.roughlyenoughitems.accessibility.entrySize": "Taille des entrées :", "config.roughlyenoughitems.search.asyncSearch": "Recherche Asynchrone :", @@ -183,10 +185,10 @@ "config.roughlyenoughitems.accessibility.displayPanelLocation": "Position du panneau d'entrée:", "config.roughlyenoughitems.accessibility.displayPanelLocation.left": "Côté gauche", "config.roughlyenoughitems.accessibility.displayPanelLocation.right": "Côté droit", - "config.roughlyenoughitems.search.tooltipSearch": "Recherche par infobulle", - "config.roughlyenoughitems.search.tagSearch": "Recherche par tag", - "config.roughlyenoughitems.search.identifierSearch": "Recherche d'identifiant (*) :", - "config.roughlyenoughitems.search.modSearch": "Recherche par mod", + "config.roughlyenoughitems.search.tooltipSearch": "Recherche par infobulle (#) :", + "config.roughlyenoughitems.search.tagSearch": "Recherche par tag ($) :", + "config.roughlyenoughitems.search.identifierSearch": "Recherche par identifiant (*) :", + "config.roughlyenoughitems.search.modSearch": "Recherche par mod (@) :", "config.roughlyenoughitems.search_mode.always": "Toujours activé", "config.roughlyenoughitems.search_mode.prefix": "En utilisant un préfix", "config.roughlyenoughitems.search_mode.never": "Toujours désactivé", @@ -194,8 +196,8 @@ "config.roughlyenoughitems.search.debugSearchTimeRequired": "Mode de débogage de la recherche :", "config.roughlyenoughitems.accessibility.resizeDynamically": "Redimensionner dynamiquement :", "config.roughlyenoughitems.layout.searchFieldLocation": "Position du champ de recherche :", - "config.roughlyenoughitems.layout.searchFieldLocation.bottom_side": "Bas à gauche/droite", - "config.roughlyenoughitems.layout.searchFieldLocation.top_side": "Haut à gauche/droite", + "config.roughlyenoughitems.layout.searchFieldLocation.bottom_side": "En bas à gauche/droite", + "config.roughlyenoughitems.layout.searchFieldLocation.top_side": "En haut à gauche/droite", "config.roughlyenoughitems.layout.searchFieldLocation.center": "Milieu", "config.roughlyenoughitems.accessibility.compositeScrollBarPermanent": "Fondu de la barre de défilement :", "config.roughlyenoughitems.accessibility.compositeScrollBarPermanent.boolean.true": "Jamais", @@ -203,7 +205,7 @@ "config.roughlyenoughitems.disableRecipeBook": "Livre de recettes :", "config.roughlyenoughitems.disableRecipeBook.boolean.true": "§cNon", "config.roughlyenoughitems.disableRecipeBook.boolean.false": "§aOui", - "config.roughlyenoughitems.fixTabCloseContainer": "Corriger \"Tab\" dans les contenants (livre de recettes désactivé) :", + "config.roughlyenoughitems.fixTabCloseContainer": "Corriger l'onglet Vanilla dans les contenants (livre de recettes désactivé) :", "config.roughlyenoughitems.lighterButtonHover": "Bouton survolé plus clair :", "config.roughlyenoughitems.layout.enableCraftableOnlyButton": "Filtre des recettes réalisables :", "config.roughlyenoughitems.layout.showUtilsButtons": "Boutons utilitaires :", @@ -212,8 +214,8 @@ "config.roughlyenoughitems.miscellaneous.loadDefaultPlugin": "Charger le plugin par défaut :", "config.roughlyenoughitems.miscellaneous.loadDefaultPlugin.boolean.false": "§cNon (dangereux)", "config.roughlyenoughitems.miscellaneous.registerRecipesInAnotherThread": "Recharger le thread REI", - "config.roughlyenoughitems.miscellaneous.registerRecipesInAnotherThread.boolean.true": "Fil REI", - "config.roughlyenoughitems.miscellaneous.registerRecipesInAnotherThread.boolean.false": "§cThread de Paquet", + "config.roughlyenoughitems.miscellaneous.registerRecipesInAnotherThread.boolean.true": "Thread REI", + "config.roughlyenoughitems.miscellaneous.registerRecipesInAnotherThread.boolean.false": "§cThread des Paquets", "config.roughlyenoughitems.commands.weatherCommand": "Commande pour la météo :", "config.roughlyenoughitems.layout.entryPanelOrdering": "Ordre du panneau d'entrée", "config.roughlyenoughitems.list_ordering_button": "%s [%s]", @@ -224,6 +226,7 @@ "config.roughlyenoughitems.search.searchFavorites": "Filtre de recherche des favoris :", "config.roughlyenoughitems.tooltips.appendModNames": "Ajouter les noms des mods :", "config.roughlyenoughitems.tooltips.displayFavoritesTooltip": "Ajouter un indice aux favoris", + "config.roughlyenoughitems.accessibility.snapToRows": "Rangées d'ancrage du panneau d'entrée :", "config.roughlyenoughitems.accessibility.toastDisplayedOnCopyIdentifier": "Copier l'identifiant de la notification :", "config.roughlyenoughitems.scrollingEntryListWidget": "Type de navigation dans la liste :", "config.roughlyenoughitems.scrollingEntryListWidget.boolean.true": "Défilement", -- cgit From 2b5c4148b5964309d80f731d67d14675981c0e18 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 16 Oct 2021 03:02:14 +0800 Subject: Try to remove excessive spacing and keep the top bar stationary --- .../rei/impl/client/config/ConfigObjectImpl.java | 2 +- .../gui/screen/CompositeDisplayViewingScreen.java | 6 +- .../gui/screen/DefaultDisplayViewingScreen.java | 116 ++++++++++++--------- 3 files changed, 68 insertions(+), 56 deletions(-) (limited to 'runtime') 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 089819553..fba1fd4c2 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 @@ -493,7 +493,7 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) private EntryPanelOrderingConfig entryPanelOrdering = EntryPanelOrderingConfig.REGISTRY_ASCENDING; @Comment("Declares the maximum amount of recipes displayed in a page if possible.") @ConfigEntry.BoundedDiscrete(min = 2, max = 99) - private int maxRecipesPerPage = 15; + private int maxRecipesPerPage = 3; @Comment("Declares whether entry rendering time should be debugged.") private boolean debugRenderTimeRequired = false; } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java index 5d1d66a98..115d44f3d 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDispla