aboutsummaryrefslogtreecommitdiff
path: root/api/src/main/java/me
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-05-19 20:59:12 +0800
committershedaniel <daniel@shedaniel.me>2022-05-19 20:59:12 +0800
commit0623523b54de12ff4e05a9b9d9bcf60b7e7ab006 (patch)
tree2a73181a6af7629b1ce2a6b12e3def5b08a4c18a /api/src/main/java/me
parent743916df79d86d1c2885ab0b9c7952f6a0507e9a (diff)
downloadRoughlyEnoughItems-0623523b54de12ff4e05a9b9d9bcf60b7e7ab006.tar.gz
RoughlyEnoughItems-0623523b54de12ff4e05a9b9d9bcf60b7e7ab006.tar.bz2
RoughlyEnoughItems-0623523b54de12ff4e05a9b9d9bcf60b7e7ab006.zip
API Changes for REI 9
Documented Here: https://shedaniel.gitbook.io/roughly-enough-items/api-migration/rei-8-greater-than-rei-9
Diffstat (limited to 'api/src/main/java/me')
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Label.java101
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Tooltip.java38
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandler.java36
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandlerErrorRenderer.java44
4 files changed, 6 insertions, 213 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Label.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Label.java
index ae813ad4b..b1d3c0bd9 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Label.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Label.java
@@ -146,53 +146,17 @@ public abstract class Label extends WidgetWithBounds {
/**
* @return the tooltip from the current tooltip function, null if no tooltip.
- * @deprecated use {@link #getTooltipLines}
- */
- @Nullable
- @Deprecated
- @ApiStatus.ScheduledForRemoval
- public String getTooltip() {
- Component[] lines = getTooltipLines();
- String tooltip = null;
- if(lines != null) {
- StringBuilder tooltipBuilder = new StringBuilder();
- for (Component line:lines) {
- tooltipBuilder.append(line.getContents()).append("\n");
- }
- tooltip = tooltipBuilder.toString();
- }
- return tooltip;
- }
-
- /**
- * @return the tooltip from the current tooltip function, null if no tooltip.
*/
@Nullable
public abstract Component[] getTooltipLines();
-
- /**
- * Sets the tooltip function used to get the tooltip.
- *
- * @param tooltip the tooltip function used to get the tooltip.
- * @deprecated use {@link #setTooltipFunction(Function)}
- */
- @Deprecated
- @ApiStatus.ScheduledForRemoval
- public void setTooltip(@Nullable Function<Label, @Nullable String> tooltip) {
- if(tooltip != null) setTooltipFunction((label) -> {
- String text = tooltip.apply(label);
- if(text != null) return Stream.of(text.split("\n")).map(Component::literal).toArray(Component[]::new);
- return null;
- });
- }
-
+
/**
* Sets the tooltip function used to get the tooltip.
*
* @param tooltip the tooltip function used to get the tooltip.
*/
public abstract void setTooltipFunction(@Nullable Function<Label, @Nullable Component[]> tooltip);
-
+
/**
* Sets the tooltip.
*
@@ -201,76 +165,17 @@ public abstract class Label extends WidgetWithBounds {
public void setTooltip(Component... tooltip) {
setTooltipFunction((label) -> tooltip);
}
-
- /**
- * Sets the tooltip.
- *
- * @param tooltip the tooltip.
- */
- public void setTooltip(String... tooltip) {
- setTooltipFunction((label) -> Stream.of(tooltip).map(Component::literal).toArray(Component[]::new));
- }
/**
* Sets the tooltip.
*
* @param tooltip the lines of tooltip.
* @return the label itself.
- * @deprecated use {@link #tooltip(String...)}
- */
- @Deprecated
- @ApiStatus.ScheduledForRemoval
- public final Label tooltipLines(String... tooltip) {
- return tooltip(tooltip);
- }
-
- /**
- * Sets the tooltip.
- *
- * @param tooltip the line of tooltip.
- * @return the label itself.
- * @deprecated use {@link #tooltip(String...)}
- */
- @Deprecated
- @ApiStatus.ScheduledForRemoval
- public final Label tooltipLine(String tooltip) {
- return tooltip(tooltip);
- }
-
- /**
- * Sets the tooltip.
- *
- * @param tooltip the lines of tooltip.
- * @return the label itself.
- */
- public final Label tooltip(String... tooltip) {
- return tooltipFunction(label -> Stream.of(tooltip).map(Component::literal).toArray(Component[]::new));
- }
-
- /**
- * Sets the tooltip.
- *
- * @param tooltip the lines of tooltip.
- * @return the label itself.
*/
public final Label tooltip(Component... tooltip) {
return tooltipFunction(label -> tooltip);
}
-
- /**
- * Sets the tooltip function.
- *
- * @param tooltip the tooltip function used to get the tooltip.
- * @return the label itself.
- * @deprecated use {@link #tooltipFunction}
- */
- @Deprecated
- @ApiStatus.ScheduledForRemoval(inVersion = "8.0.0")
- public final Label tooltipSupplier(@Nullable Function<Label, @Nullable String> tooltip) {
- setTooltip(tooltip);
- return this;
- }
-
+
/**
* Sets the tooltip function.
*
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Tooltip.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Tooltip.java
index 0a5c1062d..a9caf9577 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Tooltip.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Tooltip.java
@@ -48,14 +48,6 @@ public interface Tooltip {
return ClientInternals.createTooltipEntry(text);
}
- @Deprecated
- @ApiStatus.ScheduledForRemoval
- static Tooltip.Entry entry(ClientTooltipComponent text) {
- return ClientInternals.createTooltipEntry(text);
- }
-
- @Deprecated
- @ApiStatus.ScheduledForRemoval
static Tooltip.Entry entry(TooltipComponent text) {
return ClientInternals.createTooltipEntry(text);
}
@@ -98,14 +90,6 @@ public interface Tooltip {
List<Entry> entries();
- @Deprecated
- @ApiStatus.ScheduledForRemoval
- List<TooltipComponent> components();
-
- @Deprecated
- @ApiStatus.ScheduledForRemoval
- Tooltip add(ClientTooltipComponent component);
-
Tooltip add(Component text);
Tooltip add(TooltipComponent component);
@@ -117,15 +101,6 @@ public interface Tooltip {
return this;
}
- @Deprecated
- @ApiStatus.ScheduledForRemoval
- default Tooltip addAll(ClientTooltipComponent... components) {
- for (ClientTooltipComponent component : components) {
- add(component);
- }
- return this;
- }
-
default Tooltip addAll(Component... text) {
for (Component component : text) {
add(component);
@@ -140,15 +115,6 @@ public interface Tooltip {
return this;
}
- @Deprecated
- @ApiStatus.ScheduledForRemoval
- default Tooltip addAllComponents(Iterable<ClientTooltipComponent> text) {
- for (ClientTooltipComponent component : text) {
- add(component);
- }
- return this;
- }
-
default Tooltip addAllTexts(Iterable<Component> text) {
for (Component component : text) {
add(component);
@@ -175,9 +141,5 @@ public interface Tooltip {
Component getAsText();
TooltipComponent getAsTooltipComponent();
-
- @Deprecated
- @ApiStatus.ScheduledForRemoval
- ClientTooltipComponent getAsComponent();
}
}
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandler.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandler.java
index ad79d1d92..bfb63808d 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandler.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandler.java
@@ -65,14 +65,6 @@ public interface TransferHandler extends Comparable<TransferHandler> {
return Double.compare(getPriority(), o.getPriority());
}
- @Deprecated
- @Environment(EnvType.CLIENT)
- @Nullable
- @ApiStatus.ScheduledForRemoval
- default TransferHandlerErrorRenderer provideErrorRenderer(Context context, Object data) {
- return null;
- }
-
@ApiStatus.NonExtendable
interface Result {
/**
@@ -132,12 +124,6 @@ public interface TransferHandler extends Comparable<TransferHandler> {
*/
Result color(int color);
- /**
- * Sets the error data, to be passed to {@link TransferHandler#provideErrorRenderer(Context, Object)}.
- */
- @Deprecated
- Result errorRenderer(Object data);
-
Result renderer(TransferHandlerRenderer renderer);
@ApiStatus.Experimental
@@ -191,12 +177,6 @@ public interface TransferHandler extends Comparable<TransferHandler> {
@ApiStatus.NonExtendable
interface Context {
- @Deprecated
- @ApiStatus.ScheduledForRemoval
- static Context create(boolean actuallyCrafting, @Nullable AbstractContainerScreen<?> containerScreen, Display display) {
- return create(actuallyCrafting, Screen.hasShiftDown(), containerScreen, display);
- }
-
static Context create(boolean actuallyCrafting, boolean stackedCrafting, @Nullable AbstractContainerScreen<?> containerScreen, Display display) {
return new ContextImpl(actuallyCrafting, stackedCrafting, containerScreen, () -> display);
}
@@ -229,7 +209,7 @@ public interface TransferHandler extends Comparable<TransferHandler> {
final class ResultImpl implements Result {
private boolean successful, applicable, returningToScreen, blocking;
private Component error;
- private Object errorRenderer;
+ private TransferHandlerRenderer renderer;
private BiConsumer<Point, TooltipSink> tooltipRenderer;
private int color;
@@ -272,14 +252,8 @@ public interface TransferHandler extends Comparable<TransferHandler> {
}
@Override
- public Result errorRenderer(Object data) {
- this.errorRenderer = data;
- return this;
- }
-
- @Override
public Result renderer(TransferHandlerRenderer renderer) {
- this.errorRenderer = renderer;
+ this.renderer = renderer;
return this;
}
@@ -316,11 +290,7 @@ public interface TransferHandler extends Comparable<TransferHandler> {
@Override
public TransferHandlerRenderer getRenderer(TransferHandler handler, Context context) {
- if (errorRenderer == null) return null;
- if (errorRenderer instanceof TransferHandlerRenderer) return (TransferHandlerRenderer) errorRenderer;
- if (isSuccessful()) return null;
- TransferHandlerErrorRenderer renderer = handler.provideErrorRenderer(context, this.errorRenderer);
- return renderer == null ? null : renderer.asNew();
+ return renderer;
}
@Override
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandlerErrorRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandlerErrorRenderer.java
deleted file mode 100644
index 6c890f8fc..000000000
--- a/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandlerErrorRenderer.java
+++ /dev/null
@@ -1,44 +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.api.client.registry.transfer;
-
-import com.mojang.blaze3d.vertex.PoseStack;
-import me.shedaniel.math.Rectangle;
-import me.shedaniel.rei.api.client.gui.widgets.Widget;
-import me.shedaniel.rei.api.common.display.Display;
-import org.jetbrains.annotations.ApiStatus;
-
-import java.util.List;
-
-@ApiStatus.Experimental
-@FunctionalInterface
-@Deprecated
-@ApiStatus.ScheduledForRemoval
-public interface TransferHandlerErrorRenderer {
- void render(PoseStack matrices, int mouseX, int mouseY, float delta, List<Widget> widgets, Rectangle bounds, Display display);
-
- default TransferHandlerRenderer asNew() {
- return this::render;
- }
-}