aboutsummaryrefslogtreecommitdiff
path: root/runtime/src
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2023-11-09 17:09:54 +0800
committershedaniel <daniel@shedaniel.me>2024-04-16 00:38:18 +0900
commitd35588ecbdae04bb097958519f233948310daf52 (patch)
tree63a24f8539fe38b61edba14d0320eabc6ba54d1d /runtime/src
parent6f63c7fb4cfa2254c0d5d7d4c81b6543f15a5888 (diff)
downloadRoughlyEnoughItems-d35588ecbdae04bb097958519f233948310daf52.tar.gz
RoughlyEnoughItems-d35588ecbdae04bb097958519f233948310daf52.tar.bz2
RoughlyEnoughItems-d35588ecbdae04bb097958519f233948310daf52.zip
Save rendering hidden stacks
Diffstat (limited to 'runtime/src')
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntriesScreen.java21
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntryWidget.java7
2 files changed, 21 insertions, 7 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntriesScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntriesScreen.java
index 21ec75301..054f7651b 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntriesScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntriesScreen.java
@@ -31,6 +31,7 @@ import com.mojang.math.Matrix4f;
import me.shedaniel.clothconfig2.ClothConfigInitializer;
import me.shedaniel.clothconfig2.api.scroll.ScrollingContainer;
import me.shedaniel.math.Rectangle;
+import me.shedaniel.rei.api.client.config.ConfigObject;
import me.shedaniel.rei.api.client.config.entry.EntryStackProvider;
import me.shedaniel.rei.api.client.gui.widgets.CloseableScissors;
import me.shedaniel.rei.api.client.gui.widgets.Widget;
@@ -53,6 +54,7 @@ import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.GameRenderer;
+import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
@@ -176,6 +178,19 @@ public class CollapsibleEntriesScreen extends Screen {
this.listWidget.render(poses, mouseX, mouseY, delta);
super.render(poses, mouseX, mouseY, delta);
this.font.drawShadow(poses, this.title, this.width / 2.0F - this.font.width(this.title) / 2.0F, 12.0F, -1);
+
+ if (ConfigObject.getInstance().doDebugRenderTimeRequired()) {
+ Component debugText = new TextComponent(String.format("%s fps", minecraft.fpsString.split(" ")[0]));
+ int stringWidth = font.width(debugText);
+ fillGradient(poses, minecraft.screen.width - stringWidth - 2, 32, minecraft.screen.width, 32 + font.lineHeight + 2, -16777216, -16777216);
+ MultiBufferSource.BufferSource immediate = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
+ poses.pushPose();
+ poses.translate(0.0D, 0.0D, getBlitOffset());
+ Matrix4f matrix = poses.last().pose();
+ font.drawInBatch(debugText.getVisualOrderText(), minecraft.screen.width - stringWidth, 32 + 2, -1, false, matrix, immediate, false, 0, 15728880);
+ immediate.endBatch();
+ poses.popPose();
+ }
}
@Override
@@ -272,9 +287,9 @@ public class CollapsibleEntriesScreen extends Screen {
private int getMaxScrollDist() {
return Arrays.stream(this.columns).mapToInt(ListWidget::getHeightOf)
- .max()
- .orElse(0)
- + PADDING * 2;
+ .max()
+ .orElse(0)
+ + PADDING * 2;
}
@Override
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 574a3d7a3..8ad908c34 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
@@ -225,14 +225,13 @@ public class CollapsibleEntryWidget extends WidgetWithBounds {
private void renderStacks(PoseStack poses, int mouseX, int mouseY, float delta, Rectangle bounds, int y) {
poses.pushPose();
try (CloseableScissors outerScissors = scissor(poses, new Rectangle(bounds.x, y, bounds.width, bounds.getMaxY() - 3 - y))) {
- bounds.y += (bounds.height - 6 - 10) * 0.0;
y = bounds.y + 37 - this.scroller.scrollAmountInt();
int x = bounds.getCenterX() - 8 * rowSize;
int xIndex = 0;
poses.translate(0, 0, 100);
- BatchedEntryRendererManager manager = new BatchedEntryRendererManager();
+ BatchedEntryRendererManager<EntryWidget> manager = new BatchedEntryRendererManager<>();
for (Slot stack : this.stacks) {
- if (y + 16 >= 30) {
+ if (y + 16 >= 30 && y + 16 >= bounds.y + 37) {
stack.getBounds().setBounds(x + 16 * xIndex - 1, y - 1, 18, 18);
manager.add((EntryWidget) stack);
}
@@ -240,7 +239,7 @@ public class CollapsibleEntryWidget extends WidgetWithBounds {
if (xIndex >= this.rowSize) {
y += 16;
xIndex = 0;
- if (y >= bounds.getMaxY()) {
+ if (y >= bounds.getMaxY() || y >= minecraft.screen.height) {
break;
}
}