From 0e96125db3f91890657d1026feb0879bbf761dc7 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 10 Apr 2021 14:28:46 +0800 Subject: BatchEntryRenderer -> BatchedEntryRenderer Signed-off-by: shedaniel --- .../client/config/entries/FilteringScreen.java | 4 +- .../gui/widget/BatchEntryRendererManager.java | 143 -------------------- .../gui/widget/BatchedEntryRendererManager.java | 144 +++++++++++++++++++++ .../impl/client/gui/widget/EntryListWidget.java | 4 +- .../client/gui/widget/FavoritesListWidget.java | 2 +- .../OverlaySearchFieldSyntaxHighlighter.java | 4 +- .../shedaniel/rei/impl/client/search/IntRange.java | 38 ++++++ .../rei/impl/client/search/argument/Argument.java | 2 +- .../search/result/ArgumentApplicableResult.java | 2 +- .../rei/impl/common/entry/AbstractEntryStack.java | 2 +- .../plugin/client/entry/ItemEntryDefinition.java | 6 +- 11 files changed, 195 insertions(+), 156 deletions(-) delete mode 100644 runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchEntryRendererManager.java create mode 100644 runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchedEntryRendererManager.java create mode 100644 runtime/src/main/java/me/shedaniel/rei/impl/client/search/IntRange.java (limited to 'runtime/src/main/java/me') 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 7a6e9f32d..9717f1cf1 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 @@ -46,7 +46,7 @@ import me.shedaniel.rei.api.client.search.SearchFilter; import me.shedaniel.rei.api.client.search.SearchProvider; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.impl.client.gui.ContainerScreenOverlay; -import me.shedaniel.rei.impl.client.gui.widget.BatchEntryRendererManager; +import me.shedaniel.rei.impl.client.gui.widget.BatchedEntryRendererManager; import me.shedaniel.rei.impl.client.gui.widget.EntryWidget; import me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchField; import net.minecraft.client.Minecraft; @@ -222,7 +222,7 @@ public class FilteringScreen extends Screen { int skip = Math.max(0, Mth.floor(scrolling.scrollAmount / (float) entrySize())); int nextIndex = skip * innerBounds.width / entrySize(); int i = nextIndex; - BatchEntryRendererManager manager = new BatchEntryRendererManager(); + BatchedEntryRendererManager manager = new BatchedEntryRendererManager(); for (; i < entryStacks.size(); i++) { EntryStack stack = entryStacks.get(i); EntryListEntry entry = entries.get(nextIndex); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchEntryRendererManager.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchEntryRendererManager.java deleted file mode 100644 index 6cafecb90..000000000 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchEntryRendererManager.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020 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.gui.widget; - -import com.google.common.collect.Iterables; -import com.mojang.blaze3d.vertex.PoseStack; -import it.unimi.dsi.fastutil.ints.Int2ObjectMap; -import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import me.shedaniel.rei.api.client.config.ConfigObject; -import me.shedaniel.rei.api.client.entry.renderer.BatchEntryRenderer; -import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer; -import me.shedaniel.rei.api.common.entry.EntryStack; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.MultiBufferSource; -import org.apache.commons.lang3.mutable.MutableInt; -import org.apache.commons.lang3.mutable.MutableLong; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -public class BatchEntryRendererManager { - private boolean fastEntryRendering = ConfigObject.getInstance().doesFastEntryRendering(); - private Int2ObjectMap> grouping = new Int2ObjectOpenHashMap<>(); - private List toRender = new ArrayList<>(); - - public BatchEntryRendererManager() { - } - - public BatchEntryRendererManager(Collection widgets) { - addAll(widgets); - } - - public void addAll(Collection widgets) { - if (fastEntryRendering) { - for (EntryWidget widget : widgets) { - add(widget); - } - } else { - toRender.addAll(widgets); - } - } - - public void add(EntryWidget widget) { - if (fastEntryRendering) { - EntryStack currentEntry = widget.getCurrentEntry(); - EntryRenderer renderer = currentEntry.getRenderer(); - if (renderer instanceof BatchEntryRenderer) { - int hash = ((BatchEntryRenderer) renderer).getBatchId(currentEntry.cast()); - List entries = grouping.get(hash); - if (entries == null) { - grouping.put(hash, entries = new ArrayList<>()); - } - entries.add(widget); - return; - } - } - toRender.add(widget); - } - - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { - render(false, null, null, matrices, mouseX, mouseY, delta); - } - - public void render(boolean debugTime, MutableInt size, MutableLong time, PoseStack matrices, int mouseX, int mouseY, float delta) { - if (fastEntryRendering) { - for (List entries : grouping.values()) { - renderEntries(debugTime, size, time, fastEntryRendering, matrices, mouseX, mouseY, delta, entries); - } - } - if (!toRender.isEmpty()) { - renderEntries(debugTime, size, time, fastEntryRendering, matrices, mouseX, mouseY, delta, toRender); - } - } - - - public static void renderEntries(boolean debugTime, MutableInt size, MutableLong time, boolean fastEntryRendering, PoseStack matrices, int mouseX, int mouseY, float delta, Iterable entries) { - T firstWidget = Iterables.getFirst(entries, null); - if (firstWidget == null) return; - @SuppressWarnings("rawtypes") - EntryStack first = firstWidget.getCurrentEntry(); - EntryRenderer renderer = first.getRenderer(); - if (fastEntryRendering && renderer instanceof BatchEntryRenderer) { - BatchEntryRenderer firstRenderer = (BatchEntryRenderer) renderer; - firstRenderer.startBatch(first, matrices, delta); - long l = debugTime ? System.nanoTime() : 0; - MultiBufferSource.BufferSource immediate = Minecraft.getInstance().renderBuffers().bufferSource(); - for (T listEntry : entries) { - @SuppressWarnings("rawtypes") - EntryStack currentEntry = listEntry.getCurrentEntry(); - currentEntry.setZ(100); - listEntry.drawBackground(matrices, mouseX, mouseY, delta); - firstRenderer.renderBase(currentEntry, matrices, immediate, listEntry.getInnerBounds(), mouseX, mouseY, delta); - if (debugTime && !currentEntry.isEmpty()) size.increment(); - } - immediate.endBatch(); - for (T listEntry : entries) { - @SuppressWarnings("rawtypes") - EntryStack currentEntry = listEntry.getCurrentEntry(); - firstRenderer.renderOverlay(currentEntry, matrices, immediate, listEntry.getInnerBounds(), mouseX, mouseY, delta); - if (listEntry.containsMouse(mouseX, mouseY)) { - listEntry.queueTooltip(matrices, mouseX, mouseY, delta); - listEntry.drawHighlighted(matrices, mouseX, mouseY, delta); - } - } - immediate.endBatch(); - if (debugTime) time.add(System.nanoTime() - l); - firstRenderer.endBatch(first, matrices, delta); - } else { - for (T entry : entries) { - if (entry.getCurrentEntry().isEmpty()) - continue; - if (debugTime) { - size.increment(); - long l = System.nanoTime(); - entry.render(matrices, mouseX, mouseY, delta); - time.add(System.nanoTime() - l); - } else entry.render(matrices, mouseX, mouseY, delta); - } - } - } -} diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchedEntryRendererManager.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchedEntryRendererManager.java new file mode 100644 index 000000000..a410a24a3 --- /dev/null +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchedEntryRendererManager.java @@ -0,0 +1,144 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 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.gui.widget; + +import com.google.common.collect.Iterables; +import com.mojang.blaze3d.vertex.PoseStack; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import me.shedaniel.rei.api.client.config.ConfigObject; +import me.shedaniel.rei.api.client.entry.renderer.BatchedEntryRenderer; +import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer; +import me.shedaniel.rei.api.common.entry.EntryStack; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.MultiBufferSource; +import org.apache.commons.lang3.mutable.MutableInt; +import org.apache.commons.lang3.mutable.MutableLong; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class BatchedEntryRendererManager { + private boolean fastEntryRendering = ConfigObject.getInstance().doesFastEntryRendering(); + private Int2ObjectMap> grouping = new Int2ObjectOpenHashMap<>(); + private List toRender = new ArrayList<>(); + + public BatchedEntryRendererManager() { + } + + public BatchedEntryRendererManager(Collection widgets) { + addAll(widgets); + } + + public void addAll(Collection widgets) { + if (fastEntryRendering) { + for (EntryWidget widget : widgets) { + add(widget); + } + } else { + toRender.addAll(widgets); + } + } + + public void add(EntryWidget widget) { + if (fastEntryRendering) { + EntryStack currentEntry = widget.getCurrentEntry(); + EntryRenderer renderer = currentEntry.getRenderer(); + if (renderer instanceof BatchedEntryRenderer) { + int hash = ((BatchedEntryRenderer) renderer).getBatchIdentifier(currentEntry.cast(), widget.getBounds()); + List entries = grouping.get(hash); + if (entries == null) { + grouping.put(hash, entries = new ArrayList<>()); + } + entries.add(widget); + return; + } + } + toRender.add(widget); + } + + public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { + render(false, null, null, matrices, mouseX, mouseY, delta); + } + + public void render(boolean debugTime, MutableInt size, MutableLong time, PoseStack matrices, int mouseX, int mouseY, float delta) { + if (fastEntryRendering) { + for (List entries : grouping.values()) { + renderEntries(debugTime, size, time, fastEntryRendering, matrices, mouseX, mouseY, delta, entries); + } + } + if (!toRender.isEmpty()) { + renderEntries(debugTime, size, time, fastEntryRendering, matrices, mouseX, mouseY, delta, toRender); + } + } + + + public static void renderEntries(boolean debugTime, MutableInt size, MutableLong time, boolean fastEntryRendering, PoseStack matrices, int mouseX, int mouseY, float delta, Iterable entries) { + T firstWidget = Iterables.getFirst(entries, null); + if (firstWidget == null) return; + @SuppressWarnings("rawtypes") + EntryStack first = firstWidget.getCurrentEntry(); + EntryRenderer renderer = first.getRenderer(); + if (fastEntryRendering && renderer instanceof BatchedEntryRenderer) { + BatchedEntryRenderer firstRenderer = (BatchedEntryRenderer) renderer; + matrices = firstRenderer.batchModifyMatrices(matrices); + firstRenderer.startBatch(first, matrices, delta); + long l = debugTime ? System.nanoTime() : 0; + MultiBufferSource.BufferSource immediate = Minecraft.getInstance().renderBuffers().bufferSource(); + for (T listEntry : entries) { + @SuppressWarnings("rawtypes") + EntryStack currentEntry = listEntry.getCurrentEntry(); + currentEntry.setZ(100); + listEntry.drawBackground(matrices, mouseX, mouseY, delta); + firstRenderer.renderBase(currentEntry, matrices, immediate, listEntry.getInnerBounds(), mouseX, mouseY, delta); + if (debugTime && !currentEntry.isEmpty()) size.increment(); + } + immediate.endBatch(); + for (T listEntry : entries) { + @SuppressWarnings("rawtypes") + EntryStack currentEntry = listEntry.getCurrentEntry(); + firstRenderer.renderOverlay(currentEntry, matrices, immediate, listEntry.getInnerBounds(), mouseX, mouseY, delta); + if (listEntry.containsMouse(mouseX, mouseY)) { + listEntry.queueTooltip(matrices, mouseX, mouseY, delta); + listEntry.drawHighlighted(matrices, mouseX, mouseY, delta); + } + } + immediate.endBatch(); + if (debugTime) time.add(System.nanoTime() - l); + firstRenderer.endBatch(first, matrices, delta); + } else { + for (T entry : entries) { + if (entry.getCurrentEntry().isEmpty()) + continue; + if (debugTime) { + size.increment(); + long l = System.nanoTime(); + entry.render(matrices, mouseX, mouseY, delta); + time.add(System.nanoTime() - l); + } else entry.render(matrices, mouseX, mouseY, delta); + } + } + } +} diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryListWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryListWidget.java index ec57bf1d1..44e0589d9 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryListWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryListWidget.java @@ -220,7 +220,7 @@ public class EntryListWidget extends WidgetWithBounds { int skip = Math.max(0, Mth.floor(scrolling.scrollAmount / (float) entrySize())); int nextIndex = skip * innerBounds.width / entrySize(); this.blockedCount = 0; - BatchEntryRendererManager helper = new BatchEntryRendererManager(); + BatchedEntryRendererManager helper = new BatchedEntryRendererManager(); int i = nextIndex; for (int cont = nextIndex; cont < entries.size(); cont++) { @@ -253,7 +253,7 @@ public class EntryListWidget extends WidgetWithBounds { for (Widget widget : renders) { widget.render(matrices, mouseX, mouseY, delta); } - new BatchEntryRendererManager(entries).render(debugTime, size, time, matrices, mouseX, mouseY, delta); + new BatchedEntryRendererManager(entries).render(debugTime, size, time, matrices, mouseX, mouseY, delta); } if (debugTime) { 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 57ccd0b6a..1433c65de 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 @@ -251,7 +251,7 @@ public class FavoritesListWidget extends WidgetWithBounds implements DraggableSt Stream entryStream = this.entriesList.stream() .filter(entry -> entry.getBounds().getMaxY() >= this.currentBounds.getY() && entry.getBounds().y <= this.currentBounds.getMaxY()); - new BatchEntryRendererManager(entryStream.collect(Collectors.toList())) + new BatchedEntryRendererManager(entryStream.collect(Collectors.toList())) .render(matrices, mouseX, mouseY, delta); updatePosition(delta); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/OverlaySearchFieldSyntaxHighlighter.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/OverlaySearchFieldSyntaxHighlighter.java index 42308f678..0af21de72 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/OverlaySearchFieldSyntaxHighlighter.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/OverlaySearchFieldSyntaxHighlighter.java @@ -23,9 +23,9 @@ package me.shedaniel.rei.impl.client.gui.widget.search; +import me.shedaniel.rei.impl.client.search.IntRange; import me.shedaniel.rei.impl.client.search.argument.Argument; import me.shedaniel.rei.impl.client.search.argument.type.ArgumentTypesRegistry; -import net.minecraft.util.IntRange; import org.jetbrains.annotations.ApiStatus; import java.util.Collection; @@ -63,7 +63,7 @@ public class OverlaySearchFieldSyntaxHighlighter implements Consumer { highlighted[i] = (byte) argIndex; } for (IntRange grammarRange : grammarRanges) { - for (int i = grammarRange.getMinInclusive(); i <= grammarRange.getMaxInclusive(); i++) { + for (int i = grammarRange.min(); i <= grammarRange.max(); i++) { highlighted[i + index] = (byte) (argIndex + 1); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/search/IntRange.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/search/IntRange.java new file mode 100644 index 000000000..05c5e1ca4 --- /dev/null +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/search/IntRange.java @@ -0,0 +1,38 @@ +package me.shedaniel.rei.impl.client.search; + +import java.util.Objects; + +public class IntRange { + private final int min; + private final int max; + + private IntRange(int min, int max) { + this.min = min; + this.max = max; + } + + public static IntRange of(int min, int max) { + return new IntRange(min, max); + } + + public int min() { + return min; + } + + public int max() { + return max; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + IntRange intRange = (IntRange) o; + return min == intRange.min && max == intRange.max; + } + + @Override + public int hashCode() { + return Objects.hash(min, max); + } +} 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 67520b666..dcabfbdf2 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 @@ -27,13 +27,13 @@ import com.google.common.base.MoreObjects; import com.google.common.collect.Lists; import me.shedaniel.rei.api.client.gui.config.SearchMode; import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.impl.client.search.IntRange; import me.shedaniel.rei.impl.client.search.argument.type.AlwaysMatchingArgumentType; import me.shedaniel.rei.impl.client.search.argument.type.ArgumentType; 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.util.IntRange; import net.minecraft.util.Unit; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.mutable.Mutable; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/search/result/ArgumentApplicableResult.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/search/result/ArgumentApplicableResult.java index e25b89326..3014c9771 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/search/result/ArgumentApplicableResult.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/search/result/ArgumentApplicableResult.java @@ -23,8 +23,8 @@ package me.shedaniel.rei.impl.client.search.result; +import me.shedaniel.rei.impl.client.search.IntRange; import me.shedaniel.rei.impl.client.search.argument.type.MatchType; -import net.minecraft.util.IntRange; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/AbstractEntryStack.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/AbstractEntryStack.java index 618674152..3cbf8d511 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/AbstractEntryStack.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/AbstractEntryStack.java @@ -154,7 +154,7 @@ public abstract class AbstractEntryStack extends AbstractRenderer implements @Override @Nullable public Tooltip getTooltip(Point mouse, boolean appendModName) { - Mutable tooltip = new MutableObject<>(this.get(Settings.RENDER).apply(this).cast().getTooltip(this, mouse)); + Mutable tooltip = new MutableObject<>(this.get(Settings.RENDERER).apply(this).cast().getTooltip(this, mouse)); if (tooltip.getValue() == null) return null; tooltip.getValue().getText().addAll(get(EntryStack.Settings.TOOLTIP_APPEND_EXTRA).apply(this)); tooltip.setValue(get(Settings.TOOLTIP_PROCESSOR).apply(this, tooltip.getValue())); diff --git a/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java b/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java index 453df00c3..a6a102ea8 100644 --- a/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java +++ b/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java @@ -33,7 +33,7 @@ import it.unimi.dsi.fastutil.objects.ReferenceSet; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.entry.renderer.AbstractEntryRenderer; -import me.shedaniel.rei.api.client.entry.renderer.BatchEntryRenderer; +import me.shedaniel.rei.api.client.entry.renderer.BatchedEntryRenderer; import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; import me.shedaniel.rei.api.common.entry.EntrySerializer; @@ -185,9 +185,9 @@ public class ItemEntryDefinition implements EntryDefinition, EntrySer } @SuppressWarnings("deprecation") - public class ItemEntryRenderer extends AbstractEntryRenderer implements BatchEntryRenderer { + public class ItemEntryRenderer extends AbstractEntryRenderer implements BatchedEntryRenderer { @Override - public int getBatchId(EntryStack entry) { + public int getBatchIdentifier(EntryStack entry, Rectangle bounds) { return 1738923 + (getModelFromStack(entry.getValue()).usesBlockLight() ? 1 : 0); } -- cgit From 5bfc72d5037b6e1c9a0e3adac15f7ebbeffd2a93 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 10 Apr 2021 14:29:01 +0800 Subject: Apply license to IntRange Signed-off-by: shedaniel --- .../shedaniel/rei/impl/client/search/IntRange.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'runtime/src/main/java/me') diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/search/IntRange.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/search/IntRange.java index 05c5e1ca4..28b3720a0 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/search/IntRange.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/search/IntRange.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 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.search; import java.util.Objects; -- cgit From 6d7690b3410e6aa837089987c08598cb9ecbe45a Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 10 Apr 2021 14:30:41 +0800 Subject: Change how EntryStack.Settings is exposed Signed-off-by: shedaniel --- .../java/me/shedaniel/rei/impl/common/entry/AbstractEntryStack.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/src/main/java/me') diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/AbstractEntryStack.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/AbstractEntryStack.java index 3cbf8d511..e272a8d70 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/AbstractEntryStack.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/AbstractEntryStack.java @@ -154,7 +154,7 @@ public abstract class AbstractEntryStack extends AbstractRenderer implements @Override @Nullable public Tooltip getTooltip(Point mouse, boolean appendModName) { - Mutable tooltip = new MutableObject<>(this.get(Settings.RENDERER).apply(this).cast().getTooltip(this, mouse)); + Mutable tooltip = new MutableObject<>(getRenderer().cast().getTooltip(this, mouse)); if (tooltip.getValue() == null) return null; tooltip.getValue().getText().addAll(get(EntryStack.Settings.TOOLTIP_APPEND_EXTRA).apply(this)); tooltip.setValue(get(Settings.TOOLTIP_PROCESSOR).apply(this, tooltip.getValue())); -- cgit