aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2024-04-17 02:58:51 +0900
committershedaniel <daniel@shedaniel.me>2024-04-17 03:00:17 +0900
commit90fd49a7d1decc43c41c23550afe326b6df570eb (patch)
treefafd3093735c60d326e1e5043a30ac33e96035db /runtime
parentd96699c5e2858ef1d25d2a2fc77deff59041af81 (diff)
parent3411a078ef92b06fb1f5b12116a8241811ff9aab (diff)
downloadRoughlyEnoughItems-90fd49a7d1decc43c41c23550afe326b6df570eb.tar.gz
RoughlyEnoughItems-90fd49a7d1decc43c41c23550afe326b6df570eb.tar.bz2
RoughlyEnoughItems-90fd49a7d1decc43c41c23550afe326b6df570eb.zip
Merge remote-tracking branch 'origin/11.x-1.19.4' into 12.x-1.20
# Conflicts: # runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntryWidget.java
Diffstat (limited to 'runtime')
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntryWidget.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayRegistryImpl.java8
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayValidator.java54
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/view/ViewsImpl.java4
-rwxr-xr-xruntime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json1
7 files changed, 70 insertions, 6 deletions
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 323cc0df0..6d56afca1 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
@@ -38,6 +38,7 @@ import me.shedaniel.rei.api.client.gui.widgets.*;
import me.shedaniel.rei.api.client.registry.category.ButtonArea;
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.view.ViewSearchBuilder;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.display.Display;
@@ -46,6 +47,7 @@ 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.display.DisplaySpec;
+import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.events.GuiEventListener;
@@ -179,7 +181,7 @@ public class CompositeDisplayViewingScreen extends AbstractDisplayViewingScreen
this.widgets.add(Widgets.createClickableLabel(new Point(bounds.x + 4 + scrollListBounds.width / 2, bounds.y + 6), categories.get(selectedCategoryIndex).getTitle(), label -> {
ViewSearchBuilder.builder().addAllCategories().open();
- }).tooltip(Component.translatable("text.rei.view_all_categories")).noShadow().color(0xFF404040, 0xFFBBBBBB).hoveredColor(0xFF0041FF, 0xFFFFBD4D));
+ }).tooltip(Component.translatable("text.rei.view_all_categories"), Component.translatable("text.rei.view_all_categories.tooltip", CategoryRegistry.getInstance().stream().filter(config -> !DisplayRegistry.getInstance().get(config.getCategoryIdentifier()).isEmpty()).count()).withStyle(ChatFormatting.DARK_GRAY)).noShadow().color(0xFF404040, 0xFFBBBBBB).hoveredColor(0xFF0041FF, 0xFFFFBD4D));
this.widgets.add(new ButtonListWidget(buttonList));
this.children().addAll(widgets);
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 edb30f51b..05c712269 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
@@ -45,6 +45,7 @@ import me.shedaniel.rei.api.client.gui.widgets.Widgets;
import me.shedaniel.rei.api.client.registry.category.ButtonArea;
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.view.ViewSearchBuilder;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.display.Display;
@@ -164,7 +165,7 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen {
.onClick(button -> previousCategory()).tooltipLine(Component.translatable("text.rei.previous_category")));
this.widgets.add(Widgets.createClickableLabel(new Point(bounds.getCenterX(), bounds.getY() + 7), getCurrentCategory().getTitle(), clickableLabelWidget -> {
ViewSearchBuilder.builder().addAllCategories().open();
- }).tooltip(Component.translatable("text.rei.view_all_categories")));
+ }).tooltip(Component.translatable("text.rei.view_all_categories"), Component.translatable("text.rei.view_all_categories.tooltip", CategoryRegistry.getInstance().stream().filter(config -> !DisplayRegistry.getInstance().get(config.getCategoryIdentifier()).isEmpty()).count()).withStyle(ChatFormatting.DARK_GRAY)));
this.widgets.add(categoryNext = Widgets.createButton(new Rectangle(bounds.getCenterX() + guiWidth / 2 - 17, bounds.getY() + 5, 12, 12), Component.literal(""))
.onClick(button -> nextCategory()).tooltipLine(Component.translatable("text.rei.next_category")));
this.categoryBack.setEnabled(categories.size() > 1);
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntryWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntryWidget.java
index e93d5d733..0914377c8 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntryWidget.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntryWidget.java
@@ -125,7 +125,7 @@ public class CollapsibleEntryWidget extends WidgetWithBounds {
public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
super.render(graphics, mouseX, mouseY, delta);
RenderSystem.setShaderTexture(0, InternalTextures.CHEST_GUI_TEXTURE);
- graphics.blit(InternalTextures.CHEST_GUI_TEXTURE, x + 3, y + 3, 0, 0, 14, 14);
+ graphics.blit(InternalTextures.CHEST_GUI_TEXTURE, getX() + 3, getY() + 3, 0, 0, 14, 14);
}
};
} else {
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 655466211..277ba64d7 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
@@ -79,7 +79,9 @@ public class DisplayRegistryImpl extends RecipeManagerContextImpl<REIClientPlugi
lastAddWarning = System.currentTimeMillis();
}
- this.displaysHolder.add(display, origin);
+ if (DisplayValidator.validate(display)) {
+ this.displaysHolder.add(display, origin);
+ }
}
@Override
@@ -199,6 +201,10 @@ public class DisplayRegistryImpl extends RecipeManagerContextImpl<REIClientPlugi
}
}
+ for (List<Display> displays : getAll().values()) {
+ displays.removeIf(display -> !DisplayValidator.validate(display));
+ }
+
this.displaysHolder.endReload();
InternalLogger.getInstance().debug("Registered %d displays", displaySize());
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayValidator.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayValidator.java
new file mode 100644
index 000000000..6ebd4dbf0
--- /dev/null
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayValidator.java
@@ -0,0 +1,54 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023 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.registry.display;
+
+import me.shedaniel.rei.api.client.registry.category.CategoryRegistry;
+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.impl.common.InternalLogger;
+
+public class DisplayValidator {
+ public static boolean validate(Display display) {
+ CategoryIdentifier<?> identifier = display.getCategoryIdentifier();
+
+ try {
+ CategoryRegistry.CategoryConfiguration<?> configuration = CategoryRegistry.getInstance().get(identifier);
+
+ try {
+ DisplayCategory<Display> category = (DisplayCategory<Display>) configuration.getCategory();
+ category.getDisplayWidth(display);
+ return true;
+ } catch (ClassCastException exception) {
+ InternalLogger.getInstance().error("Display [%s] %s failed validation check for category [%s] %s", display.getDisplayLocation().orElse(null), display, identifier, configuration.getCategory());
+ return false;
+ }
+ } catch (NullPointerException exception) {
+ return true;
+ } catch (Throwable throwable) {
+ InternalLogger.getInstance().error("Display [%s] %s failed validation check for category [%s]".formatted(display.getDisplayLocation().orElse(null), display, identifier), throwable);
+ return false;
+ }
+ }
+}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/view/ViewsImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/view/ViewsImpl.java
index aebdbb6c1..34bff7be2 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/view/ViewsImpl.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/view/ViewsImpl.java
@@ -31,7 +31,7 @@ import it.unimi.dsi.fastutil.longs.Long2LongMaps;
import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
-import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
+import it.unimi.dsi.fastutil.objects.ReferenceLinkedOpenHashSet;
import me.shedaniel.rei.api.client.REIRuntime;
import me.shedaniel.rei.api.client.config.ConfigObject;
import me.shedaniel.rei.api.client.registry.category.CategoryRegistry;
@@ -281,7 +281,7 @@ public class ViewsImpl implements Views {
if (b != null) {
return b;
}
- map.put(key, new ReferenceOpenHashSet<>());
+ map.put(key, new ReferenceLinkedOpenHashSet<>());
return map.get(key);
}
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 73bcb103a..fa6f3dbd4 100755
--- a/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json
+++ b/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json
@@ -137,6 +137,7 @@
"text.rei.left_arrow": "<",
"text.rei.right_arrow": ">",
"text.rei.view_all_categories": "View All Categories",
+ "text.rei.view_all_categories.tooltip": "%d categories",
"text.rei.go_back_first_page": "Back to Page 1",
"text.rei.choose_page": "Choose Page",
"text.rei.shift_click_to": "Shift-Click to %s",