From 5729d39a0f85413b4c4ada56e17514d09c7de4a4 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Fri, 16 Apr 2021 21:08:44 +0800 Subject: Fix icons for JEI categories with null icons Signed-off-by: shedaniel --- .../shedaniel/rei/api/client/gui/widgets/WidgetWithBounds.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'api/src/main/java') diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/WidgetWithBounds.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/WidgetWithBounds.java index a303bdd44..d61d58f4d 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/WidgetWithBounds.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/WidgetWithBounds.java @@ -23,6 +23,7 @@ package me.shedaniel.rei.api.client.gui.widgets; +import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.math.Rectangle; public abstract class WidgetWithBounds extends Widget { @@ -32,4 +33,13 @@ public abstract class WidgetWithBounds extends Widget { public boolean containsMouse(double mouseX, double mouseY) { return getBounds().contains(mouseX, mouseY); } + + @Deprecated + @Override + public void render(PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) { + Rectangle clone = getBounds().clone(); + getBounds().setBounds(bounds); + render(matrices, mouseX, mouseY, delta); + getBounds().setBounds(clone); + } } -- cgit From 2020b3d10ff9b6b1eaed26bbcf42c3dcff5a8724 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Fri, 16 Apr 2021 21:09:16 +0800 Subject: Fix license Signed-off-by: shedaniel --- .../api/common/transfer/info/MenuInfoProvider.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'api/src/main/java') diff --git a/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfoProvider.java b/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfoProvider.java index 1e43dbbdc..d6a824843 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfoProvider.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfoProvider.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.api.common.transfer.info; import me.shedaniel.rei.api.common.category.CategoryIdentifier; -- cgit From 29b2ae2033557c6c3824543e15611ebd175bce51 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Fri, 16 Apr 2021 22:08:47 +0800 Subject: Fix #506 Signed-off-by: shedaniel --- .../shedaniel/rei/api/client/util/ClientEntryStacks.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'api/src/main/java') diff --git a/api/src/main/java/me/shedaniel/rei/api/client/util/ClientEntryStacks.java b/api/src/main/java/me/shedaniel/rei/api/client/util/ClientEntryStacks.java index 7409f1150..ab471cf77 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/util/ClientEntryStacks.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/util/ClientEntryStacks.java @@ -44,22 +44,22 @@ public final class ClientEntryStacks { return EntryStack.of(BuiltinClientEntryTypes.RENDERING, renderer); } - public static EntryStack setNotRenderer(EntryStack stack) { + public static EntryStack setNotRenderer(EntryStack stack) { return setRenderer(stack, EntryRenderer.empty()); } - public static EntryStack setRenderer(EntryStack stack, EntryRenderer renderer) { - return stack.setting(EntryStack.Settings.RENDERER, s -> renderer); + public static EntryStack setRenderer(EntryStack stack, EntryRenderer renderer) { + return stack.setting(EntryStack.Settings.RENDERER, s -> renderer).cast(); } @SuppressWarnings("rawtypes") - public static EntryStack setRenderer(EntryStack stack, Function, EntryRenderer> rendererProvider) { - return stack.setting(EntryStack.Settings.RENDERER, (Function) rendererProvider); + public static EntryStack setRenderer(EntryStack stack, Function, EntryRenderer> rendererProvider) { + return stack.setting(EntryStack.Settings.RENDERER, (Function) rendererProvider).cast(); } @SuppressWarnings("rawtypes") - public static EntryStack setTooltipProcessor(EntryStack stack, BiFunction, Tooltip, Tooltip> processor) { - return stack.setting(EntryStack.Settings.TOOLTIP_PROCESSOR, (BiFunction) processor); + public static EntryStack setTooltipProcessor(EntryStack stack, BiFunction, Tooltip, Tooltip> processor) { + return stack.setting(EntryStack.Settings.TOOLTIP_PROCESSOR, (BiFunction) processor).cast(); } public static EntryStack setFluidRenderRatio(EntryStack stack, float ratio) { -- cgit From 2118580fc418b272723766e080209f06bdf9a2a9 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Fri, 16 Apr 2021 22:30:08 +0800 Subject: Support Fluid Overlays, fix #505 Signed-off-by: shedaniel --- .../rei/api/client/gui/widgets/Widgets.java | 36 +++++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'api/src/main/java') diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java index 0ac417634..52d0cc172 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java @@ -172,12 +172,12 @@ public final class Widgets { ((ContainerEventHandler) element).setFocused(guiEventListener); } } - + @Override public boolean isDragging() { return true; } - + @Override public boolean containsMouse(double mouseX, double mouseY) { return element.isMouseOver(mouseX, mouseY); @@ -186,22 +186,29 @@ public final class Widgets { public static WidgetWithBounds wrapRenderer(Rectangle bounds, Renderer renderer) { if (renderer instanceof Widget) - return wrapWidgetWithBounds((Widget) renderer); - return new RendererWrappedWidget(renderer); + return wrapWidgetWithBounds((Widget) renderer, bounds); + return new RendererWrappedWidget(renderer, bounds); } public static WidgetWithBounds wrapWidgetWithBounds(Widget widget) { + return wrapWidgetWithBounds(widget, null); + } + + public static WidgetWithBounds wrapWidgetWithBounds(Widget widget, Rectangle bounds) { if (widget instanceof WidgetWithBounds) return (WidgetWithBounds) widget; - return new DelegateWidget(widget); + if (bounds == null) + return new DelegateWidget(widget); + return new DelegateWidgetWithBounds(widget, bounds); } private static class RendererWrappedWidget extends WidgetWithBounds { - private Renderer renderer; - private Rectangle bounds; + private final Renderer renderer; + private final Rectangle bounds; - public RendererWrappedWidget(Renderer renderer) { + public RendererWrappedWidget(Renderer renderer, Rectangle bounds) { this.renderer = Objects.requireNonNull(renderer); + this.bounds = Objects.requireNonNull(bounds); } @Override @@ -232,6 +239,19 @@ public final class Widgets { } } + private static class DelegateWidgetWithBounds extends DelegateWidget { + private final Rectangle bounds; + + public DelegateWidgetWithBounds(Widget widget, Rectangle bounds) { + super(widget); + this.bounds = bounds; + } + + @Override + public Rectangle getBounds() { + return bounds; + } + } public static Widget createTexturedWidget(ResourceLocation identifier, Rectangle bounds) { return createTexturedWidget(identifier, bounds, 0, 0); -- cgit