From 94e323f75c17e297c33fba1d3afb5c47ae66a8ad Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sun, 28 Aug 2022 18:50:24 +0900 Subject: Separate EntryListWidget and FavoritesListWidget more --- .../client/gui/forge/ScreenOverlayImplForge.java | 61 ---------------------- .../impl/client/gui/forge/TooltipRendererImpl.java | 60 +++++++++++++++++++++ 2 files changed, 60 insertions(+), 61 deletions(-) delete mode 100644 forge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/ScreenOverlayImplForge.java create mode 100644 forge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/TooltipRendererImpl.java (limited to 'forge/src/main/java') diff --git a/forge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/ScreenOverlayImplForge.java b/forge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/ScreenOverlayImplForge.java deleted file mode 100644 index e18ba2e23..000000000 --- a/forge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/ScreenOverlayImplForge.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020, 2021, 2022 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.forge; - -import com.mojang.blaze3d.vertex.PoseStack; -import me.shedaniel.rei.api.client.gui.widgets.Tooltip; -import me.shedaniel.rei.api.common.entry.EntryStack; -import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; -import me.shedaniel.rei.api.common.util.CollectionUtils; -import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; -import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; -import net.minecraft.network.chat.Component; -import net.minecraft.world.inventory.tooltip.TooltipComponent; -import net.minecraft.world.item.ItemStack; -import net.minecraftforge.client.ForgeHooksClient; - -import java.util.ArrayList; -import java.util.List; - -public class ScreenOverlayImplForge extends ScreenOverlayImpl { - @Override - public void renderTooltipInner(Screen screen, PoseStack matrices, Tooltip tooltip, int mouseX, int mouseY) { - matrices.pushPose(); - EntryStack stack = tooltip.getContextStack(); - ItemStack itemStack = stack.getType() == VanillaEntryTypes.ITEM ? stack.castValue() : ItemStack.EMPTY; - List texts = CollectionUtils.filterAndMap(tooltip.entries(), Tooltip.Entry::isText, Tooltip.Entry::getAsText); - List components = ForgeHooksClient.gatherTooltipComponents(itemStack, texts, mouseX, screen.width, screen.height, null, screen.getMinecraft().font); - components = new ArrayList<>(components); - for (Tooltip.Entry entry : tooltip.entries()) { - if (!entry.isText()) { - components.add(1, entry.getAsComponent()); - } - } - screen.tooltipStack = itemStack; - screen.renderTooltipInternal(matrices, components, mouseX, mouseY); - screen.tooltipStack = ItemStack.EMPTY; - matrices.popPose(); - } -} diff --git a/forge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/TooltipRendererImpl.java b/forge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/TooltipRendererImpl.java new file mode 100644 index 000000000..d957d2642 --- /dev/null +++ b/forge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/TooltipRendererImpl.java @@ -0,0 +1,60 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021, 2022 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.forge; + +import com.mojang.blaze3d.vertex.PoseStack; +import me.shedaniel.rei.api.client.gui.widgets.Tooltip; +import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; +import me.shedaniel.rei.api.common.util.CollectionUtils; +import me.shedaniel.rei.impl.client.provider.TooltipRenderer; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.client.ForgeHooksClient; + +import java.util.ArrayList; +import java.util.List; + +public class TooltipRendererImpl implements TooltipRenderer { + @Override + public void renderTooltip(Screen screen, PoseStack matrices, Tooltip tooltip, int mouseX, int mouseY) { + matrices.pushPose(); + EntryStack stack = tooltip.getContextStack(); + ItemStack itemStack = stack.getType() == VanillaEntryTypes.ITEM ? stack.castValue() : ItemStack.EMPTY; + List texts = CollectionUtils.filterAndMap(tooltip.entries(), Tooltip.Entry::isText, Tooltip.Entry::getAsText); + List components = ForgeHooksClient.gatherTooltipComponents(itemStack, texts, mouseX, screen.width, screen.height, null, screen.getMinecraft().font); + components = new ArrayList<>(components); + for (Tooltip.Entry entry : tooltip.entries()) { + if (!entry.isText()) { + components.add(1, entry.getAsComponent()); + } + } + screen.tooltipStack = itemStack; + screen.renderTooltipInternal(matrices, components, mouseX, mouseY); + screen.tooltipStack = ItemStack.EMPTY; + matrices.popPose(); + } +} -- cgit