From 90b8a8181eb7e642fb88832f8bd8baa3acdcf804 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Fri, 11 Dec 2020 20:24:47 +0800 Subject: Remove deprecated classes Signed-off-by: shedaniel --- .../me/shedaniel/rei/RoughlyEnoughItemsCore.java | 2 +- .../me/shedaniel/rei/gui/RecipeViewingScreen.java | 2 +- .../me/shedaniel/rei/gui/TransformingScreen.java | 2 - .../rei/gui/VillagerRecipeViewingScreen.java | 2 +- .../rei/gui/config/entry/FilteringScreen.java | 4 +- .../me/shedaniel/rei/gui/modules/MenuEntry.java | 1 + .../rei/gui/plugin/DefaultRuntimePlugin.java | 2 - .../me/shedaniel/rei/gui/widget/ButtonWidget.java | 221 --------------------- .../rei/gui/widget/CategoryBaseWidget.java | 50 ----- .../rei/gui/widget/ClickableLabelWidget.java | 137 ------------- .../shedaniel/rei/gui/widget/EntryListWidget.java | 1 - .../me/shedaniel/rei/gui/widget/EntryWidget.java | 24 +-- .../me/shedaniel/rei/gui/widget/LabelWidget.java | 194 ------------------ .../me/shedaniel/rei/gui/widget/PanelWidget.java | 140 ------------- .../rei/gui/widget/RecipeArrowWidget.java | 86 -------- .../shedaniel/rei/gui/widget/RecipeBaseWidget.java | 60 ------ .../shedaniel/rei/gui/widget/SlotBaseWidget.java | 67 ------- .../me/shedaniel/rei/impl/ClientHelperImpl.java | 24 +-- .../me/shedaniel/rei/impl/ConfigManagerImpl.java | 5 +- .../me/shedaniel/rei/impl/ConfigObjectImpl.java | 15 -- .../me/shedaniel/rei/impl/DisplayHelperImpl.java | 52 +---- .../java/me/shedaniel/rei/impl/ScreenHelper.java | 37 +--- .../me/shedaniel/rei/impl/widgets/PanelWidget.java | 13 -- 23 files changed, 22 insertions(+), 1119 deletions(-) delete mode 100644 RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java delete mode 100644 RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/CategoryBaseWidget.java delete mode 100644 RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/ClickableLabelWidget.java delete mode 100644 RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java delete mode 100644 RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/PanelWidget.java delete mode 100644 RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/RecipeArrowWidget.java delete mode 100644 RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/RecipeBaseWidget.java delete mode 100644 RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/SlotBaseWidget.java (limited to 'RoughlyEnoughItems-runtime/src/main/java') diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java index 60ff88f70..fb2728932 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java @@ -151,7 +151,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { @Override public me.shedaniel.rei.api.widgets.Slot createSlot(Point point) { - return EntryWidget.create(point); + return new EntryWidget(point); } @Override diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java index bcc21caa7..c24164451 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java @@ -258,7 +258,7 @@ public class RecipeViewingScreen extends Screen implements RecipeScreen { ClientHelperImpl.getInstance().openRecipeViewingScreen(categoriesMap, categories.get(currentCategoryIndex).getIdentifier(), ingredientStackToNotice, resultStackToNotice); }).tooltipLine(I18n.get("text.rei.previous_category"))); widgets.add(Widgets.createClickableLabel(new Point(bounds.getCenterX(), bounds.getY() + 7), new TextComponent(selectedCategory.getCategoryName()), clickableLabelWidget -> { - ClientHelper.getInstance().executeViewAllRecipesKeyBind(); + ClientHelper.getInstance().openView(ClientHelper.ViewSearchBuilder.builder().addAllCategories().fillPreferredOpenedCategory()); }).tooltipLine(I18n.get("text.rei.view_all_categories"))); widgets.add(categoryNext = Widgets.createButton(new Rectangle(bounds.getMaxX() - 17, bounds.getY() + 5, 12, 12), new TranslatableComponent("text.rei.right_arrow")) .onClick(button -> { diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/TransformingScreen.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/TransformingScreen.java index e8c2e615c..e72c921e1 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/TransformingScreen.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/TransformingScreen.java @@ -29,10 +29,8 @@ import me.shedaniel.clothconfig2.api.ScissorsScreen; import me.shedaniel.math.Rectangle; import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screens.DeathScreen; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.TitleScreen; -import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen; import org.jetbrains.annotations.Nullable; import java.util.function.BooleanSupplier; diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java index 36a18ac78..9eecc4616 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java @@ -241,7 +241,7 @@ public class VillagerRecipeViewingScreen extends Screen implements RecipeScreen .enabled(categories.size() > tabsPerPage)); this.widgets.add(Widgets.createClickableLabel(new Point(bounds.x + 4 + scrollListBounds.width / 2, bounds.y + 6), new TextComponent(categories.get(selectedCategoryIndex).getCategoryName()), label -> { - ClientHelper.getInstance().executeViewAllRecipesKeyBind(); + ClientHelper.getInstance().openView(ClientHelper.ViewSearchBuilder.builder().addAllCategories().fillPreferredOpenedCategory()); }).tooltipLine(I18n.get("text.rei.view_all_categories")).noShadow().color(0xFF404040, 0xFFBBBBBB).hoveredColor(0xFF0041FF, 0xFFFFBD4D)); this.children.addAll(buttonList); diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringScreen.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringScreen.java index 31e2a3948..1d3d37014 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringScreen.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringScreen.java @@ -309,11 +309,11 @@ public class FilteringScreen extends Screen { public void updateSearch(String searchTerm) { lastSearchArguments = SearchArgument.processSearchTerm(searchTerm); Set list = Sets.newLinkedHashSet(); - for (EntryStack stack : EntryRegistry.getInstance().getStacksList()) { + EntryRegistry.getInstance().getEntryStacks().forEach(stack -> { if (canLastSearchTermsBeAppliedTo(stack)) { list.add(stack.copy().setting(EntryStack.Settings.CHECK_AMOUNT, EntryStack.Settings.FALSE).setting(EntryStack.Settings.RENDER_COUNTS, EntryStack.Settings.FALSE).setting(EntryStack.Settings.CHECK_TAGS, EntryStack.Settings.TRUE)); } - } + }); entryStacks = Lists.newArrayList(list); updateEntriesPosition(); diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/modules/MenuEntry.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/modules/MenuEntry.java index 455dae30b..7a1101a9d 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/modules/MenuEntry.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/modules/MenuEntry.java @@ -29,6 +29,7 @@ import org.jetbrains.annotations.ApiStatus; @ApiStatus.Experimental @ApiStatus.Internal public abstract class MenuEntry extends Widget { + @ApiStatus.Internal @Deprecated Menu parent = null; diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java index 71f6f8dfe..05a450867 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java @@ -33,10 +33,8 @@ import me.shedaniel.rei.api.favorites.FavoriteEntryType; import me.shedaniel.rei.api.plugins.REIPluginV0; import me.shedaniel.rei.api.widgets.Panel; import me.shedaniel.rei.api.widgets.Tooltip; -import me.shedaniel.rei.gui.ContainerScreenOverlay; import me.shedaniel.rei.gui.RecipeViewingScreen; import me.shedaniel.rei.gui.VillagerRecipeViewingScreen; -import me.shedaniel.rei.gui.widget.FavoritesListWidget; import me.shedaniel.rei.impl.ClientHelperImpl; import me.shedaniel.rei.impl.RenderingEntry; import me.shedaniel.rei.plugin.autocrafting.DefaultCategoryHandler; diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java deleted file mode 100644 index 48214cda9..000000000 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java +++ /dev/null @@ -1,221 +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.gui.widget; - -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; -import me.shedaniel.math.Point; -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.REIHelper; -import me.shedaniel.rei.api.widgets.Tooltip; -import net.minecraft.client.gui.components.events.GuiEventListener; -import net.minecraft.client.resources.sounds.SimpleSoundInstance; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.sounds.SoundEvents; -import net.minecraft.util.Mth; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.function.Consumer; -import java.util.function.Supplier; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * @see me.shedaniel.rei.api.widgets.Widgets#createButton(me.shedaniel.math.Rectangle, Text) - */ -@Deprecated -@ApiStatus.ScheduledForRemoval -public abstract class ButtonWidget extends WidgetWithBounds { - - protected static final ResourceLocation BUTTON_LOCATION = new ResourceLocation("roughlyenoughitems", "textures/gui/button.png"); - protected static final ResourceLocation BUTTON_LOCATION_DARK = new ResourceLocation("roughlyenoughitems", "textures/gui/button_dark.png"); - public boolean enabled = true; - public boolean focused = false; - private boolean canChangeFocuses = true; - private String text; - private Rectangle bounds; - private Supplier tooltipSupplier; - - protected ButtonWidget(Rectangle rectangle, Component text) { - this.bounds = Objects.requireNonNull(rectangle); - this.text = Objects.requireNonNull(text).getString(); - } - - public static ButtonWidget create(Rectangle point, String text, Consumer onClick) { - return create(point, new TextComponent(text), onClick); - } - - public static ButtonWidget create(Rectangle point, Component text, Consumer onClick) { - ButtonWidget[] widget = {null}; - widget[0] = new ButtonWidget(point, text) { - @Override - public void onPressed() { - onClick.accept(widget[0]); - } - }; - return widget[0]; - } - - public ButtonWidget tooltip(Supplier tooltipSupplier) { - this.tooltipSupplier = tooltipSupplier; - return this; - } - - public ButtonWidget enabled(boolean enabled) { - this.enabled = enabled; - return this; - } - - public ButtonWidget canChangeFocuses(boolean canChangeFocuses) { - this.canChangeFocuses = canChangeFocuses; - return this; - } - - public boolean canChangeFocuses() { - return canChangeFocuses; - } - - @NotNull - public Rectangle getBounds() { - return bounds; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - protected int getTextureId(boolean boolean_1) { - int int_1 = 1; - if (!this.enabled) { - int_1 = 0; - } else if (boolean_1) { - int_1 = 4; // 2 is the old blue highlight, 3 is the 1.15 outline, 4 is the 1.15 online + light hover - } - - return int_1; - } - - protected void renderBackground(PoseStack matrices, int x, int y, int width, int height, int textureOffset) { - minecraft.getTextureManager().bind(REIHelper.getInstance().isDarkThemeEnabled() ? BUTTON_LOCATION_DARK : BUTTON_LOCATION); - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - RenderSystem.enableBlend(); - RenderSystem.blendFuncSeparate(770, 771, 1, 0); - RenderSystem.blendFunc(770, 771); - //Four Corners - blit(matrices, x, y, getBlitOffset(), 0, textureOffset * 80, 4, 4, 512, 256); - blit(matrices, x + width - 4, y, getBlitOffset(), 252, textureOffset * 80, 4, 4, 512, 256); - blit(matrices, x, y + height - 4, getBlitOffset(), 0, textureOffset * 80 + 76, 4, 4, 512, 256); - blit(matrices, x + width - 4, y + height - 4, getBlitOffset(), 252, textureOffset * 80 + 76, 4, 4, 512, 256); - - //Sides - blit(matrices, x + 4, y, getBlitOffset(), 4, textureOffset * 80, Mth.ceil((width - 8) / 2f), 4, 512, 256); - blit(matrices, x + 4, y + height - 4, getBlitOffset(), 4, textureOffset * 80 + 76, Mth.ceil((width - 8) / 2f), 4, 512, 256); - blit(matrices, x + 4 + Mth.ceil((width - 8) / 2f), y + height - 4, getBlitOffset(), 252 - Mth.floor((width - 8) / 2f), textureOffset * 80 + 76, Mth.floor((width - 8) / 2f), 4, 512, 256); - blit(matrices, x + 4 + Mth.ceil((width - 8) / 2f), y, getBlitOffset(), 252 - Mth.floor((width - 8) / 2f), textureOffset * 80, Mth.floor((width - 8) / 2f), 4, 512, 256); - for (int i = y + 4; i < y + height - 4; i += 76) { - blit(matrices, x, i, getBlitOffset(), 0, 4 + textureOffset * 80, Mth.ceil(width / 2f), Mth.clamp(y + height - 4 - i, 0, 76), 512, 256); - blit(matrices, x + Mth.ceil(width / 2f), i, getBlitOffset(), 256 - Mth.floor(width / 2f), 4 + textureOffset * 80, Mth.floor(width / 2f), Mth.clamp(y + height - 4 - i, 0, 76), 512, 256); - } - } - - @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { - int x = bounds.x, y = bounds.y, width = bounds.width, height = bounds.height; - renderBackground(matrices, x, y, width, height, this.getTextureId(isHovered(mouseX, mouseY))); - - int color = 14737632; - if (!this.enabled) { - color = 10526880; - } else if (isHovered(mouseX, mouseY)) { - color = 16777120; - } - - this.drawCenteredString(matrices, font, getText(), x + width / 2, y + (height - 8) / 2, color); - - if (getTooltips().isPresent()) - if (!focused && containsMouse(mouseX, mouseY)) - Tooltip.create(Stream.of(getTooltips().get().split("\n")).map(TextComponent::new).collect(Collectors.toList())).queue(); - else if (focused) - Tooltip.create(new Point(x + width / 2, y + height / 2), Stream.of(getTooltips().get().split("\n")).map(TextComponent::new).collect(Collectors.toList())).queue(); - } - - public boolean isHovered(int mouseX, int mouseY) { - return isMouseOver(mouseX, mouseY) || focused; - } - - @Override - public boolean changeFocus(boolean boolean_1) { - if (!enabled || !canChangeFocuses) - return false; - this.focused = !this.focused; - return true; - } - - @Override - public List children() { - return Collections.emptyList(); - } - - @Override - public boolean mouseClicked(double mouseX, double mouseY, int button) { - if (isMouseOver(mouseX, mouseY) && enabled && button == 0) { - minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); - onPressed(); - return true; - } - return false; - } - - @Override - public boolean keyPressed(int int_1, int int_2, int int_3) { - if (this.enabled && focused) { - if (int_1 != 257 && int_1 != 32 && int_1 != 335) { - return false; - } else { - minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); - this.onPressed(); - return true; - } - } - return false; - } - - public abstract void onPressed(); - - public Optional getTooltips() { - return Optional.ofNullable(tooltipSupplier).map(Supplier::get); - } - -} diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/CategoryBaseWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/CategoryBaseWidget.java deleted file mode 100644 index e8cadf77a..000000000 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/CategoryBaseWidget.java +++ /dev/null @@ -1,50 +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.gui.widget; - -import me.shedaniel.math.Rectangle; -import org.jetbrains.annotations.ApiStatus; - -/** - * @see me.shedaniel.rei.api.widgets.Widgets#createCategoryBase(me.shedaniel.math.Rectangle) - * @see me.shedaniel.rei.api.widgets.Widgets#createCategoryBase(me.shedaniel.math.Rectangle, int) - */ -@Deprecated -@ApiStatus.ScheduledForRemoval -public class CategoryBaseWidget extends RecipeBaseWidget { - - public CategoryBaseWidget(Rectangle bounds) { - super(bounds); - } - - @Override - protected int getYTextureOffset() { - return 66; - } - - @Override - protected boolean isRendering() { - return true; - } -} diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/ClickableLabelWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/ClickableLabelWidget.java deleted file mode 100644 index 6ec14c747..000000000 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/ClickableLabelWidget.java +++ /dev/null @@ -1,137 +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.gui.widget; - -import com.mojang.blaze3d.vertex.PoseStack; -import me.shedaniel.math.Point; -import me.shedaniel.rei.api.REIHelper; -import me.shedaniel.rei.api.widgets.Tooltip; -import me.shedaniel.rei.api.widgets.Widgets; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; -import org.jetbrains.annotations.ApiStatus; - -import java.util.function.Consumer; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * @see Widgets#createClickableLabel(Point, String, Consumer) - */ -@Deprecated -@ApiStatus.ScheduledForRemoval -public abstract class ClickableLabelWidget extends LabelWidget { - - public boolean focused; - private boolean clickable = true; - private int hoveredColor; - - @ApiStatus.Internal - protected ClickableLabelWidget(Point point, Component text) { - super(point, text); - this.hoveredColor = REIHelper.getInstance().isDarkThemeEnabled() ? -1 : 0xFF66FFCC; - } - - public LabelWidget hoveredColor(int hoveredColor) { - this.hoveredColor = hoveredColor; - return this; - } - - public LabelWidget clickable(boolean clickable) { - this.clickable = clickable; - return this; - } - - public boolean isClickable() { - return clickable; - } - - @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { - int color = getDefaultColor(); - if (isClickable() && isHovered(mouseX, mouseY)) - color = getHoveredColor(); - Point pos = getLocation(); - int width = font.width(getText()); - if (isCentered()) { - if (isHasShadows()) - font.drawShadow(matrices, text.getVisualOrderText(), pos.x - width / 2f, pos.y, color); - else - font.draw(matrices, text.getVisualOrderText(), pos.x - width / 2f, pos.y, color); - } else { - if (isHasShadows()) - font.drawShadow(matrices, text.getVisualOrderText(), pos.x, pos.y, color); - else - font.draw(matrices, text.getVisualOrderText(), pos.x, pos.y, color); - } - drawTooltips(mouseX, mouseY); - } - - @Override - protected void drawTooltips(int mouseX, int mouseY) { - if (isClickable() && getTooltips().isPresent()) - if (!focused && containsMouse(mouseX, mouseY)) - Tooltip.create(Stream.of(getTooltips().get().split("\n")).map(TextComponent::new).collect(Collectors.toList())).queue(); - else if (focused) - Tooltip.create(getLocation(), Stream.of(getTooltips().get().split("\n")).map(TextComponent::new).collect(Collectors.toList())).queue(); - } - - public int getHoveredColor() { - return hoveredColor; - } - - @Override - public boolean mouseClicked(double mouseX, double mouseY, int button) { - if (button == 0 && isClickable() && containsMouse(mouseX, mouseY)) { - onLabelClicked(); - return true; - } - return false; - } - - @Override - public boolean keyPressed(int int_1, int int_2, int int_3) { - if (!isClickable() || !focused) - return false; - if (int_1 != 257 && int_1 != 32 && int_1 != 335) - return false; - this.onLabelClicked(); - return true; - } - - @Override - public boolean changeFocus(boolean boolean_1) { - if (!isClickable()) - return false; - this.focused = !this.focused; - return true; - } - - public boolean isHovered(int mouseX, int mouseY) { - return isClickable() && (containsMouse(mouseX, mouseY) || focused); - } - - public abstract void onLabelClicked(); - -} diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java index 2ca72fee7..3555ef44a 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java @@ -60,7 +60,6 @@ import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.mutable.MutableLong; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.util.Collections; import java.util.Comparator; diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java index 9a8383391..5a820ac0e 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java @@ -69,35 +69,15 @@ public class EntryWidget extends Slot { private Rectangle bounds; private List entryStacks; - protected EntryWidget(int x, int y) { + public EntryWidget(int x, int y) { this(new Point(x, y)); } - protected EntryWidget(Point point) { + public EntryWidget(Point point) { this.bounds = new Rectangle(point.x - 1, point.y - 1, 18, 18); this.entryStacks = new ArrayList<>(); } - /** - * @see me.shedaniel.rei.api.widgets.Widgets#createSlot(me.shedaniel.math.Point) - */ - @ApiStatus.ScheduledForRemoval - @Deprecated - @NotNull - public static EntryWidget create(int x, int y) { - return create(new Point(x, y)); - } - - /** - * @see me.shedaniel.rei.api.widgets.Widgets#createSlot(me.shedaniel.math.Point) - */ - @ApiStatus.ScheduledForRemoval - @Deprecated - @NotNull - public static EntryWidget create(Point point) { - return new EntryWidget(point); - } - @Override @NotNull public EntryWidget unmarkInputOrOutput() { diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java deleted file mode 100644 index 78efdfc80..000000000 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java +++ /dev/null @@ -1,194 +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.gui.widget; - -import com.mojang.blaze3d.vertex.PoseStack; -import me.shedaniel.math.Point; -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.REIHelper; -import me.shedaniel.rei.api.widgets.Tooltip; -import me.shedaniel.rei.api.widgets.Widgets; -import net.minecraft.client.gui.components.events.GuiEventListener; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.function.Consumer; -import java.util.function.Supplier; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * @see Widgets#createLabel(Point, Text) - * @see Widgets#createClickableLabel(Point, Text, Consumer) - */ -@Deprecated -@ApiStatus.ScheduledForRemoval -public class LabelWidget extends WidgetWithBounds { - - private Point pos; - protected Component text; - private int defaultColor; - private boolean hasShadows = true; - private boolean centered = true; - private Supplier tooltipSupplier; - - @ApiStatus.Internal - public LabelWidget(Point point, Component text) { - this.pos = point; - this.text = text; - this.defaultColor = REIHelper.getInstance().isDarkThemeEnabled() ? 0xFFBBBBBB : -1; - } - - public static LabelWidget create(Point point, String text) { - return new LabelWidget(point, new TextComponent(text)); - } - - public static ClickableLabelWidget createClickable(Point point, String text, Consumer onClicked) { - ClickableLabelWidget[] widget = {null}; - widget[0] = new ClickableLabelWidget(point, new TextComponent(text)) { - @Override - public void onLabelClicked() { - onClicked.accept(widget[0]); - } - }; - return widget[0]; - } - - public LabelWidget tooltip(Supplier tooltipSupplier) { - this.tooltipSupplier = tooltipSupplier; - return this; - } - - public boolean isCentered() { - return centered; - } - - public void setCentered(boolean centered) { - this.centered = centered; - } - - public LabelWidget centered() { - setCentered(true); - return this; - } - - public LabelWidget leftAligned() { - setCentered(false); - return this; - } - - public boolean isHasShadows() { - return hasShadows; - } - - public void setHasShadows(boolean hasShadows) { - this.hasShadows = hasShadows; - } - - public LabelWidget noShadow() { - setHasShadows(false); - return this; - } - - public int getDefaultColor() { - return defaultColor; - } - - public void setDefaultColor(int defaultColor) { - this.defaultColor = defaultColor; - } - - /** - * @return the position of this label - */ - public Point getLocation() { - return pos; - } - - public LabelWidget setLocation(Point position) { - this.pos = position; - return this; - } - - public String getText() { - return text.getString(); - } - - public LabelWidget setText(String text) { - this.text = new TextComponent(text); - return this; - } - - public LabelWidget color(int defaultColor) { - this.defaultColor = defaultColor; - return this; - } - - public Optional getTooltips() { - return Optional.ofNullable(tooltipSupplier).map(Supplier::get); - } - - @NotNull - @Override - public Rectangle getBounds() { - int width = font.width(text); - Point pos = getLocation(); - if (isCentered()) - return new Rectangle(pos.x - width / 2 - 1, pos.y - 5, width + 2, 14); - return new Rectangle(pos.x - 1, pos.y - 5, width + 2, 14); - } - - @Override - public List children() { - return Collections.emptyList(); - } - - @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { - int width = font.width(text); - Point pos = getLocation(); - if (isCentered()) { - if (hasShadows) - font.drawShadow(matrices, text.getVisualOrderText(), pos.x - width / 2f, pos.y, defaultColor); - else - font.draw(matrices, text.getVisualOrderText(), pos.x - width / 2f, pos.y, defaultColor); - } else { - if (hasShadows) - font.drawShadow(matrices, text.getVisualOrderText(), pos.x, pos.y, defaultColor); - else - font.draw(matrices, text.getVisualOrderText(), pos.x, pos.y, defaultColor); - } - } - - protected void drawTooltips(int mouseX, int mouseY) { - if (getTooltips().isPresent()) - if (containsMouse(mouseX, mouseY)) - Tooltip.create(Stream.of(getTooltips().get().split("\n")).map(TextComponent::new).collect(Collectors.toList())).queue(); - } -} diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/PanelWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/PanelWidget.java deleted file mode 100644 index 1c56fadcd..000000000 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/PanelWidget.java +++ /dev/null @@ -1,140 +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.gui.widget; - -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.ConfigObject; -import me.shedaniel.rei.api.REIHelper; -import me.shedaniel.rei.gui.config.RecipeBorderType; -import me.shedaniel.rei.gui.config.RecipeScreenType; -import net.minecraft.resources.ResourceLocation; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -/** - * @see me.shedaniel.rei.api.widgets.Widgets#createRecipeBase(me.shedaniel.math.Rectangle) - * @see me.shedaniel.rei.api.widgets.Widgets#createRecipeBase(me.shedaniel.math.Rectangle, int) - * @see me.shedaniel.rei.api.widgets.Widgets#createSlotBase(me.shedaniel.math.Rectangle) - * @see me.shedaniel.rei.api.widgets.Widgets#createSlotBase(me.shedaniel.math.Rectangle, int) - */ -@ApiStatus.ScheduledForRemoval -@Deprecated -public class PanelWidget extends WidgetWithBounds { - - private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/recipecontainer.png"); - private static final ResourceLocation CHEST_GUI_TEXTURE_DARK = new ResourceLocation("roughlyenoughitems", "textures/gui/recipecontainer_dark.png"); - - private static final PanelWidget TEMP = new PanelWidget(new Rectangle()); - private Rectangle bounds; - private int color = -1; - - public PanelWidget(Rectangle bounds) { - this.bounds = bounds; - } - - public static void render(Rectangle bounds, int color) { - TEMP.bounds = bounds; - TEMP.color = color; - TEMP.render(); - } - - @NotNull - @Override - public Rectangle getBounds() { - return bounds; - } - - @Override - public List children() { - return Collections.emptyList(); - } - - public void render() { - render(new PoseStack(), 0, 0, 0); - } - - public int getColor() { - return color; - } - - public void setColor(int color) { - this.color = color; - } - - @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { - if (!isRendering()) - return; - float alpha = ((color >> 24) & 0xFF) / 255f; - float red = ((color >> 16) & 0xFF) / 255f; - float green = ((color >> 8) & 0xFF) / 255f; - float blue = (color & 0xFF) / 255f; - RenderSystem.color4f(red, green, blue, alpha); - minecraft.getTextureManager().bind(REIHelper.getInstance().isDarkThemeEnabled() ? CHEST_GUI_TEXTURE_DARK : CHEST_GUI_TEXTURE); - int x = bounds.x, y = bounds.y, width = bounds.width, height = bounds.height; - int xTextureOffset = getXTextureOffset(); - int yTextureOffset = getYTextureOffset(); - - //Four Corners - this.blit(matrices, x, y, 106 + xTextureOffset, 124 + yTextureOffset, 4, 4); - this.blit(matrices, x + width - 4, y, 252 + xTextureOffset, 124 + yTextureOffset, 4, 4); - this.blit(matrices, x, y + height - 4, 106 + xTextureOffset, 186 + yTextureOffset, 4, 4); - this.blit(matrices, x + width - 4, y + height - 4, 252 + xTextureOffset, 186 + yTextureOffset, 4, 4); - - //Sides - for (int xx = 4; xx < width - 4; xx += 128) { - int thisWidth = Math.min(128, width - 4 - xx); - this.blit(matrices, x + xx, y, 110 + xTextureOffset, 124 + yTextureOffset, thisWidth, 4); - this.blit(matrices, x + xx, y + height - 4, 110 + xTextureOffset, 186 + yTextureOffset, thisWidth, 4); - } - for (int yy = 4; yy < height - 4; yy += 50) { - int thisHeight = Math.min(50, height - 4 - yy); - this.blit(matrices, x, y + yy, 106 + xTextureOffset, 128 + yTextureOffset, 4, thisHeight); - this.blit(matrices, x + width - 4, y + yy, 252 + xTextureOffset, 128 + yTextureOffset, 4, thisHeight); - } - fillGradient(matrices, x + 4, y + 4, x + width - 4, y + height - 4, getInnerColor(), getInnerColor()); - } - - protected boolean isRendering() { - return ConfigObject.getInstance().getRecipeScreenType() != RecipeScreenType.VILLAGER; - } - - protected int getInnerColor() { - return REIHelper.getInstance().isDarkThemeEnabled() ? -13750738 : -3750202; - } - - protected int getXTextureOffset() { - return 0; - } - - protected int getYTextureOffset() { - return RecipeBorderType.DEFAULT.getYOffset(); - } - -} diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/RecipeArrowWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/RecipeArrowWidget.java deleted file mode 100644 index 1c2845877..000000000 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/RecipeArrowWidget.java +++ /dev/null @@ -1,86 +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.gui.widget; - -import com.mojang.blaze3d.vertex.PoseStack; -import me.shedaniel.math.Point; -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.REIHelper; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.components.events.GuiEventListener; -import net.minecraft.util.Mth; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -/** - * @see me.shedaniel.rei.api.widgets.Widgets#createArrow(me.shedaniel.math.Point) - */ -@ApiStatus.ScheduledForRemoval -@Deprecated -public class RecipeArrowWidget extends WidgetWithBounds { - - private int x, y; - private double time = 250d; - private boolean animated; - - @ApiStatus.Internal - public RecipeArrowWidget(int x, int y, boolean animated) { - this.x = x; - this.y = y; - this.animated = animated; - } - - public static RecipeArrowWidget create(Point point, boolean animated) { - return new RecipeArrowWidget(point.x, point.y, animated); - } - - public RecipeArrowWidget time(double time) { - this.time = time; - return this; - } - - @NotNull - @Override - public Rectangle getBounds() { - return new Rectangle(x, y, 24, 17); - } - - @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { - Minecraft.getInstance().getTextureManager().bind(REIHelper.getInstance().getDefaultDisplayTexture()); - blit(matrices, x, y, 106, 91, 24, 17); - if (animated) { - int width = Mth.ceil((System.currentTimeMillis() / (time / 24) % 24d) / 1f); - blit(matrices, x, y, 82, 91, width, 17); - } - } - - @Override - public List children() { - return Collections.emptyList(); - } -} diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/RecipeBaseWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/RecipeBaseWidget.java deleted file mode 100644 index f6244fd86..000000000 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/RecipeBaseWidget.java +++ /dev/null @@ -1,60 +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.gui.widget; - -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.ConfigObject; -import org.jetbrains.annotations.ApiStatus; - -/** - * @see me.shedaniel.rei.api.widgets.Widgets#createRecipeBase(me.shedaniel.math.Rectangle) - * @see me.shedaniel.rei.api.widgets.Widgets#createRecipeBase(me.shedaniel.math.Rectangle, int) - */ -@Deprecated -@ApiStatus.ScheduledForRemoval -public class RecipeBaseWidget extends PanelWidget { - - /** - * Creates a recipe base drawable - * - * @param bounds the bounds of the base - * @see me.shedaniel.rei.api.widgets.Widgets#createRecipeBase(me.shedaniel.math.Rectangle) - * @see me.shedaniel.rei.api.widgets.Widgets#createRecipeBase(me.shedaniel.math.Rectangle, int) - */ - @ApiStatus.Internal - @Deprecated - public RecipeBaseWidget(Rectangle bounds) { - super(bounds); - } - - @Override - protected int getYTextureOffset() { - return ConfigObject.getInstance().getRecipeBorderType().getYOffset(); - } - - @Override - protected boolean isRendering() { - return super.isRendering() && ConfigObject.getInstance().getRecipeBorderType().isRendering(); - } -} diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/SlotBaseWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/SlotBaseWidget.java deleted file mode 100644 index 783dc73be..000000000 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/SlotBaseWidget.java +++ /dev/null @@ -1,67 +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.gui.widget; - -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.REIHelper; -import org.jetbrains.annotations.ApiStatus; - -/** - * @see me.shedaniel.rei.api.widgets.Widgets#createSlotBase(me.shedaniel.math.Rectangle) - * @see me.shedaniel.rei.api.widgets.Widgets#createSlotBase(me.shedaniel.math.Rectangle, int) - */ -@ApiStatus.ScheduledForRemoval -@Deprecated -public class SlotBaseWidget extends RecipeBaseWidget { - - /** - * Creates a recipe base drawable - * - * @param bounds the bounds of the base - * @see me.shedaniel.rei.api.widgets.Widgets#createSlotBase(me.shedaniel.math.Rectangle) - * @see me.shedaniel.rei.api.widgets.Widgets#createSlotBase(me.shedaniel.math.Rectangle, int) - */ - @ApiStatus.Internal - @Deprecated - public SlotBaseWidget(Rectangle bounds) { - super(bounds); - } - - @Override - public int getInnerColor() { - return REIHelper.getInstance().isDarkThemeEnabled() ? -13619152 : -7631989; - } - - @Override - protected int getYTextureOffset() { - return -66; - } - - @Override - protected boolean isRendering() { - return true; - } - -} - diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java index 35900f2ff..254f5d3ab 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java @@ -95,14 +95,14 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer { } @Override - public String getModFromModId(String modid) { - if (modid == null) + public String getModFromModId(String modId) { + if (modId == null) return ""; - String any = modNameCache.getOrDefault(modid, null); + String any = modNameCache.getOrDefault(modId, null); if (any != null) return any; - String s = FabricLoader.getInstance().getModContainer(modid).map(ModContainer::getMetadata).map(ModMetadata::getName).orElse(modid); - modNameCache.put(modid, s); + String s = FabricLoader.getInstance().getModContainer(modId).map(ModContainer::getMetadata).map(ModMetadata::getName).orElse(modId); + modNameCache.put(modId, s); return s; } @@ -175,11 +175,6 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer { } } - @Override - public List getInventoryItemsTypes() { - return Minecraft.getInstance().player.getInventory().compartments.stream().flatMap(Collection::stream).collect(Collectors.toList()); - } - @ApiStatus.Internal public Set _getInventoryItemsTypes() { return Minecraft.getInstance().player.getInventory().compartments.stream() @@ -188,15 +183,6 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer { .collect(Collectors.toSet()); } - @ApiStatus.ScheduledForRemoval - @Deprecated - @Override - public void openRecipeViewingScreen(Map, List> map) { - openRecipeViewingScreen(map, null, null, null); - } - - @ApiStatus.ScheduledForRemoval - @Deprecated @ApiStatus.Internal public void openRecipeViewingScreen(Map, List> map, @Nullable ResourceLocation category, @Nullable EntryStack ingredientNotice, @Nullable EntryStack resultNotice) { openView(new LegacyWrapperViewSearchBuilder(map).setPreferredOpenedCategory(category).setInputNotice(ingredientNotice).setOutputNotice(resultNotice).fillPreferredOpenedCategory()); diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java index 517df76ba..1ea511159 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java @@ -48,7 +48,10 @@ import me.shedaniel.clothconfig2.api.ModifierKeyCode; import me.shedaniel.clothconfig2.gui.entries.KeyCodeEntry; import me.shedaniel.clothconfig2.impl.EasingMethod; import me.shedaniel.rei.RoughlyEnoughItemsCore; -import me.shedaniel.rei.api.*; +import me.shedaniel.rei.api.ConfigManager; +import me.shedaniel.rei.api.EntryRegistry; +import me.shedaniel.rei.api.EntryStack; +import me.shedaniel.rei.api.REIHelper; import me.shedaniel.rei.api.favorites.FavoriteEntry; import me.shedaniel.rei.gui.ContainerScreenOverlay; import me.shedaniel.rei.gui.TransformingScreen; diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java index d6e3156dc..119016687 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java @@ -111,11 +111,6 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { return advanced.accessibility.toastDisplayedOnCopyIdentifier; } - @Override - public boolean doesRenderEntryEnchantmentGlint() { - return true; - } - @Override public boolean isEntryListWidgetScrolled() { return appearance.scrollingEntryListWidget; @@ -136,11 +131,6 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { appearance.recipeScreenType = recipeScreenType; } - @Override - public boolean isLoadingDefaultPlugin() { - return true; - } - @Override public SearchFieldLocation getSearchFieldLocation() { return appearance.layout.searchFieldLocation; @@ -344,11 +334,6 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { return functionality.allowInventoryHighlighting; } - @Override - public boolean shouldResizeDynamically() { - return false; - } - @ApiStatus.Experimental @Override public double getHorizontalEntriesBoundaries() { diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/DisplayHelperImpl.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/DisplayHelperImpl.java index 0c368be21..2c6ef4cb1 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/DisplayHelperImpl.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/DisplayHelperImpl.java @@ -45,55 +45,20 @@ import java.util.Map; @ApiStatus.Internal @Environment(EnvType.CLIENT) public class DisplayHelperImpl implements DisplayHelper { - private static final Comparator BOUNDS_HANDLER_COMPARATOR = Comparator.comparingDouble(OverlayDecider::getPriority).reversed(); - private static final DisplayBoundsHandler EMPTY = new DisplayBoundsHandler() { - @Override - public Class getBaseSupportedClass() { - return null; - } - - @Override - public Rectangle getLeftBounds(Object screen) { - return new Rectangle(); - } - - @Override - public Rectangle getRightBounds(Object screen) { - return new Rectangle(); - } - - @Override - public float getPriority() { - return -10f; - } - }; private List screenDisplayBoundsHandlers = Lists.newArrayList(); - private Map, DisplayBoundsHandler> handlerCache = Maps.newHashMap(); private Map, List> deciderSortedCache = Maps.newHashMap(); - private Map, List>> handlerSortedCache = Maps.newHashMap(); private BaseBoundsHandler baseBoundsHandler; private Class tempScreen; - @SuppressWarnings("rawtypes") - @Override - public List> getSortedBoundsHandlers(Class screenClass) { - List> possibleCached = handlerSortedCache.get(screenClass); - if (possibleCached != null) - return possibleCached; - tempScreen = screenClass; - handlerSortedCache.put(screenClass, (List) CollectionUtils.castAndMap(CollectionUtils.filter(screenDisplayBoundsHandlers, this::filterResponsible), DisplayBoundsHandler.class)); - return handlerSortedCache.get(screenClass); - } - @Override public List getSortedOverlayDeciders(Class screenClass) { List possibleCached = deciderSortedCache.get(screenClass); if (possibleCached != null) return possibleCached; tempScreen = screenClass; - deciderSortedCache.put(screenClass, (List) CollectionUtils.filter(screenDisplayBoundsHandlers, this::filterResponsible)); + deciderSortedCache.put(screenClass, CollectionUtils.filter(screenDisplayBoundsHandlers, this::filterResponsible)); return deciderSortedCache.get(screenClass); } @@ -102,16 +67,6 @@ public class DisplayHelperImpl implements DisplayHelper { return Collections.unmodifiableList(screenDisplayBoundsHandlers); } - @Override - public DisplayBoundsHandler getResponsibleBoundsHandler(Class screenClass) { - DisplayBoundsHandler possibleCached = handlerCache.get(screenClass); - if (possibleCached != null) - return possibleCached; - List> handlers = getSortedBoundsHandlers(screenClass); - handlerCache.put(screenClass, handlers.isEmpty() ? EMPTY : handlers.get(0)); - return handlerCache.get(screenClass); - } - @Override public Rectangle getOverlayBounds(DisplayPanelLocation location, T screen) { Window window = Minecraft.getInstance().getWindow(); @@ -127,8 +82,6 @@ public class DisplayHelperImpl implements DisplayHelper { if (scaledWidth - containerBounds.getMaxX() < 10) continue; return new Rectangle(containerBounds.getMaxX() + 2, 0, scaledWidth - containerBounds.getMaxX() - 4, scaledHeight); } - } else if (decider instanceof DisplayBoundsHandler) { - return location == DisplayPanelLocation.LEFT ? ((DisplayBoundsHandler) decider).getLeftBounds(screen) : ((DisplayBoundsHandler) decider).getRightBounds(screen); } } return new Rectangle(); @@ -163,9 +116,6 @@ public class DisplayHelperImpl implements DisplayHelper { @ApiStatus.Experimental @Override public void resetCache() { - handlerCache.clear(); deciderSortedCache.clear(); - handlerSortedCache.clear(); } - } diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java index 767ef019b..fbb5e6662 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java @@ -44,20 +44,19 @@ import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.InteractionResult; -import net.minecraft.world.item.ItemStack; import org.apache.logging.log4j.util.TriConsumer; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; -import java.util.stream.Collectors; +import java.util.LinkedHashSet; +import java.util.Optional; +import java.util.Set; import static me.shedaniel.rei.impl.Internals.attachInstance; @@ -98,14 +97,6 @@ public class ScreenHelper implements ClientModInitializer, REIHelper { return searchField; } - @Override - public @NotNull List getInventoryStacks() { - return inventoryStacks.stream() - .map(EntryStack::getItemStack) - .filter(Objects::nonNull) - .collect(Collectors.toList()); - } - @Nullable public static OverlaySearchField getSearchField() { return (OverlaySearchField) getInstance().getSearchTextField(); @@ -169,16 +160,6 @@ public class ScreenHelper implements ClientModInitializer, REIHelper { return getLastOverlay(false, false); } - /** - * @see REIHelper#getPreviousContainerScreen() - */ - @Deprecated - @ApiStatus.ScheduledForRemoval - @Nullable - public static AbstractContainerScreen getLastHandledScreen() { - return previousContainerScreen; - } - @Override public AbstractContainerScreen getPreviousContainerScreen() { return previousContainerScreen; @@ -203,19 +184,9 @@ public class ScreenHelper implements ClientModInitializer, REIHelper { consumer.accept(matrices, new Point(actualX, actualY), delta); } - /** - * @deprecated Please switch to {@link REIHelper#isDarkThemeEnabled()} - */ - @Deprecated - @ApiStatus.Internal - @ApiStatus.ScheduledForRemoval - public static boolean isDarkModeEnabled() { - return ConfigObject.getInstance().isUsingDarkTheme(); - } - @Override public boolean isDarkThemeEnabled() { - return isDarkModeEnabled(); + return ConfigObject.getInstance().isUsingDarkTheme(); } @Override diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/widgets/PanelWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/widgets/PanelWidget.java index 82459e9c0..31a94d1f4 100