From 995b8b58aa8c890c9181ae479e12a4facfa05a25 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Thu, 25 Mar 2021 03:55:36 +0800 Subject: Relocate most of the internal classes to match the api Signed-off-by: shedaniel --- .../me/shedaniel/rei/api/client/ClientHelper.java | 2 +- .../rei/api/client/config/ConfigObject.java | 2 +- .../entry/renderer/AbstractEntryRenderer.java | 29 +++ .../client/entry/renderer/BatchEntryRenderer.java | 61 ++++++ .../api/client/entry/renderer/EntryRenderer.java | 49 +++++ .../client/entry/type/BuiltinClientEntryTypes.java | 36 ++++ .../rei/api/client/favorites/FavoriteEntry.java | 2 +- .../api/client/favorites/FavoriteEntryType.java | 2 +- .../rei/api/client/gui/SimpleDisplayRenderer.java | 6 +- .../rei/api/client/gui/drag/DraggableStack.java | 2 +- .../shedaniel/rei/api/client/gui/widgets/Slot.java | 2 +- .../entry/renderer/AbstractEntryRenderer.java | 29 --- .../entry/renderer/BatchEntryRenderer.java | 61 ------ .../ingredient/entry/renderer/EntryRenderer.java | 49 ----- .../entry/type/BuiltinClientEntryTypes.java | 36 ---- .../ingredient/util/ClientEntryIngredients.java | 35 ---- .../client/ingredient/util/ClientEntryStacks.java | 40 ---- .../rei/api/client/plugins/REIClientPlugin.java | 5 + .../client/registry/category/CategoryRegistry.java | 4 +- .../client/registry/display/DisplayCategory.java | 2 +- .../registry/display/LiveDisplayGenerator.java | 2 +- .../api/client/registry/entry/EntryRegistry.java | 2 +- .../registry/screen/FocusedStackProvider.java | 2 +- .../api/client/registry/screen/ScreenRegistry.java | 2 +- .../client/registry/transfer/TransferHandler.java | 9 + .../rei/api/client/search/SearchFilter.java | 2 +- .../rei/api/client/subsets/SubsetsRegistry.java | 2 +- .../api/client/util/ClientEntryIngredients.java | 35 ++++ .../rei/api/client/util/ClientEntryStacks.java | 40 ++++ .../rei/api/client/view/ViewSearchBuilder.java | 2 +- .../me/shedaniel/rei/api/client/view/Views.java | 2 +- .../shedaniel/rei/api/common/display/Display.java | 2 +- .../common/display/SimpleDisplaySerializer.java | 2 +- .../rei/api/common/display/basic/BasicDisplay.java | 4 +- .../rei/api/common/entry/EntryIngredient.java | 64 ++++++ .../rei/api/common/entry/EntrySerializer.java | 41 ++++ .../shedaniel/rei/api/common/entry/EntryStack.java | 227 ++++++++++++++++++++ .../common/entry/comparison/ComparisonContext.java | 49 +++++ .../common/entry/comparison/ItemComparator.java | 67 ++++++ .../entry/comparison/ItemComparatorRegistry.java | 63 ++++++ .../api/common/entry/type/BuiltinEntryTypes.java | 35 ++++ .../rei/api/common/entry/type/EntryDefinition.java | 71 +++++++ .../rei/api/common/entry/type/EntryType.java | 44 ++++ .../rei/api/common/entry/type/EntryTypeBridge.java | 35 ++++ .../api/common/entry/type/EntryTypeRegistry.java | 99 +++++++++ .../api/common/entry/type/VanillaEntryTypes.java | 35 ++++ .../rei/api/common/fluid/FluidSupportProvider.java | 2 +- .../rei/api/common/ingredient/EntryIngredient.java | 64 ------ .../rei/api/common/ingredient/EntryStack.java | 228 --------------------- .../common/ingredient/entry/EntrySerializer.java | 42 ---- .../entry/comparison/ComparisonContext.java | 49 ----- .../entry/comparison/ItemComparator.java | 67 ------ .../entry/comparison/ItemComparatorRegistry.java | 63 ------ .../ingredient/entry/type/BuiltinEntryTypes.java | 35 ---- .../ingredient/entry/type/EntryDefinition.java | 71 ------- .../common/ingredient/entry/type/EntryType.java | 44 ---- .../ingredient/entry/type/EntryTypeBridge.java | 35 ---- .../ingredient/entry/type/EntryTypeRegistry.java | 99 --------- .../ingredient/entry/type/VanillaEntryTypes.java | 35 ---- .../common/ingredient/util/EntryIngredients.java | 173 ---------------- .../api/common/ingredient/util/EntryStacks.java | 207 ------------------- .../rei/api/common/plugins/REIPlugin.java | 4 +- .../rei/api/common/plugins/REIPluginProvider.java | 3 +- .../rei/api/common/plugins/REIServerPlugin.java | 5 + .../rei/api/common/transfer/info/MenuInfo.java | 2 +- .../api/common/transfer/info/MenuInfoRegistry.java | 4 + .../rei/api/common/util/CollectionUtils.java | 3 +- .../rei/api/common/util/EntryIngredients.java | 173 ++++++++++++++++ .../shedaniel/rei/api/common/util/EntryStacks.java | 207 +++++++++++++++++++ .../me/shedaniel/rei/impl/ClientInternals.java | 8 +- .../main/java/me/shedaniel/rei/impl/Internals.java | 14 +- 71 files changed, 1529 insertions(+), 1500 deletions(-) create mode 100644 api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/AbstractEntryRenderer.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/BatchEntryRenderer.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRenderer.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/client/entry/type/BuiltinClientEntryTypes.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/client/ingredient/entry/renderer/AbstractEntryRenderer.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/client/ingredient/entry/renderer/BatchEntryRenderer.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/client/ingredient/entry/renderer/EntryRenderer.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/client/ingredient/entry/type/BuiltinClientEntryTypes.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/client/ingredient/util/ClientEntryIngredients.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/client/ingredient/util/ClientEntryStacks.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/client/util/ClientEntryIngredients.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/client/util/ClientEntryStacks.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/common/entry/EntryIngredient.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/common/entry/EntrySerializer.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ComparisonContext.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ItemComparator.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ItemComparatorRegistry.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/common/entry/type/BuiltinEntryTypes.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryDefinition.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryType.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryTypeBridge.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryTypeRegistry.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/common/entry/type/VanillaEntryTypes.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/common/ingredient/EntryIngredient.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/common/ingredient/EntryStack.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/common/ingredient/entry/EntrySerializer.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/common/ingredient/entry/comparison/ComparisonContext.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/common/ingredient/entry/comparison/ItemComparator.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/common/ingredient/entry/comparison/ItemComparatorRegistry.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/common/ingredient/entry/type/BuiltinEntryTypes.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/common/ingredient/entry/type/EntryDefinition.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/common/ingredient/entry/type/EntryType.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/common/ingredient/entry/type/EntryTypeBridge.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/common/ingredient/entry/type/EntryTypeRegistry.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/common/ingredient/entry/type/VanillaEntryTypes.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/common/ingredient/util/EntryIngredients.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/common/ingredient/util/EntryStacks.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/common/util/EntryIngredients.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/common/util/EntryStacks.java (limited to 'api/src/main') diff --git a/api/src/main/java/me/shedaniel/rei/api/client/ClientHelper.java b/api/src/main/java/me/shedaniel/rei/api/client/ClientHelper.java index 4193fbc22..5b8a0a210 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/ClientHelper.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/ClientHelper.java @@ -25,7 +25,7 @@ package me.shedaniel.rei.api.client; import me.shedaniel.rei.api.client.config.ConfigManager; import me.shedaniel.rei.api.client.view.ViewSearchBuilder; -import me.shedaniel.rei.api.common.ingredient.EntryStack; +import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.util.FormattingUtils; import me.shedaniel.rei.impl.ClientInternals; import net.fabricmc.api.EnvType; diff --git a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java index db654e089..1af08129d 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java @@ -26,7 +26,7 @@ package me.shedaniel.rei.api.client.config; import me.shedaniel.clothconfig2.api.ModifierKeyCode; import me.shedaniel.rei.api.client.favorites.FavoriteEntry; import me.shedaniel.rei.api.client.gui.config.*; -import me.shedaniel.rei.api.common.ingredient.EntryStack; +import me.shedaniel.rei.api.common.entry.EntryStack; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import org.jetbrains.annotations.ApiStatus; diff --git a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/AbstractEntryRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/AbstractEntryRenderer.java new file mode 100644 index 000000000..ac92e83c2 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/AbstractEntryRenderer.java @@ -0,0 +1,29 @@ +/* + * 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.client.entry.renderer; + +import net.minecraft.client.gui.GuiComponent; + +public abstract class AbstractEntryRenderer extends GuiComponent implements EntryRenderer { +} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/BatchEntryRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/BatchEntryRenderer.java new file mode 100644 index 000000000..89f1d0034 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/BatchEntryRenderer.java @@ -0,0 +1,61 @@ +/* + * 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.client.entry.renderer; + +import com.mojang.blaze3d.vertex.PoseStack; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.common.entry.EntryStack; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.MultiBufferSource; + +public interface BatchEntryRenderer extends EntryRenderer { + static int getBatchIdFrom(EntryStack entry) { + EntryRenderer renderer = entry.getRenderer(); + if (renderer instanceof BatchEntryRenderer) return ((BatchEntryRenderer) renderer).getBatchId(entry); + return renderer.getClass().hashCode(); + } + + default int getBatchId(EntryStack entry) { + return getClass().hashCode(); + } + + void startBatch(EntryStack entry, PoseStack matrices, float delta); + + void renderBase(EntryStack entry, PoseStack matrices, MultiBufferSource.BufferSource immediate, Rectangle bounds, int mouseX, int mouseY, float delta); + + void renderOverlay(EntryStack entry, PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta); + + void endBatch(EntryStack entry, PoseStack matrices, float delta); + + @Deprecated + @Override + default void render(EntryStack entry, PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) { + startBatch(entry, matrices, delta); + MultiBufferSource.BufferSource immediate = Minecraft.getInstance().renderBuffers().bufferSource(); + renderBase(entry, matrices, immediate, bounds, mouseX, mouseY, delta); + immediate.endBatch(); + renderOverlay(entry, matrices, bounds, mouseX, mouseY, delta); + endBatch(entry, matrices, delta); + } +} \ No newline at end of file diff --git a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRenderer.java new file mode 100644 index 000000000..14cbcaa04 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRenderer.java @@ -0,0 +1,49 @@ +/* + * 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.client.entry.renderer; + +import com.mojang.blaze3d.vertex.PoseStack; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.gui.widgets.Tooltip; +import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.impl.ClientInternals; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +public interface EntryRenderer { + static EntryRenderer empty() { + return ClientInternals.getEmptyEntryRenderer(); + } + + void render(EntryStack entry, PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta); + + @Nullable + Tooltip getTooltip(EntryStack entry, Point mouse); + + @ApiStatus.NonExtendable + default EntryRenderer cast() { + return (EntryRenderer) this; + } +} \ No newline at end of file diff --git a/api/src/main/java/me/shedaniel/rei/api/client/entry/type/BuiltinClientEntryTypes.java b/api/src/main/java/me/shedaniel/rei/api/client/entry/type/BuiltinClientEntryTypes.java new file mode 100644 index 000000000..405afccac --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/entry/type/BuiltinClientEntryTypes.java @@ -0,0 +1,36 @@ +/* + * 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.client.entry.type; + +import me.shedaniel.rei.api.client.gui.Renderer; +import me.shedaniel.rei.api.common.entry.type.EntryType; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.ApiStatus; + +@ApiStatus.NonExtendable +public interface BuiltinClientEntryTypes { + ResourceLocation RENDERING_ID = new ResourceLocation("rendering"); + + EntryType RENDERING = EntryType.deferred(RENDERING_ID); +} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntry.java b/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntry.java index ec2662677..da68b4d39 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntry.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntry.java @@ -25,7 +25,7 @@ package me.shedaniel.rei.api.client.favorites; import com.google.gson.JsonObject; import me.shedaniel.rei.api.client.gui.Renderer; -import me.shedaniel.rei.api.common.ingredient.EntryStack; +import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.impl.ClientInternals; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.Nullable; diff --git a/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntryType.java b/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntryType.java index 939fdcac4..c341581a9 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntryType.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntryType.java @@ -25,7 +25,7 @@ package me.shedaniel.rei.api.client.favorites; import com.google.gson.JsonObject; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; -import me.shedaniel.rei.api.common.ingredient.EntryStack; +import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.registry.Reloadable; import net.minecraft.network.chat.Component; diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java index c7400784a..12dec407f 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java @@ -31,9 +31,9 @@ import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.widgets.Slot; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; import me.shedaniel.rei.api.client.gui.widgets.Widgets; -import me.shedaniel.rei.api.common.ingredient.EntryIngredient; -import me.shedaniel.rei.api.common.ingredient.EntryStack; -import me.shedaniel.rei.api.common.ingredient.util.EntryStacks; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.util.EntryStacks; import me.shedaniel.rei.api.common.util.CollectionUtils; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/drag/DraggableStack.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/drag/DraggableStack.java index 3be6cc6d9..9a5d17f1e 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/drag/DraggableStack.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/drag/DraggableStack.java @@ -25,7 +25,7 @@ package me.shedaniel.rei.api.client.gui.drag; import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.common.ingredient.EntryStack; +import me.shedaniel.rei.api.common.entry.EntryStack; public interface DraggableStack { EntryStack getStack(); diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Slot.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Slot.java index d3eb4be5c..36eb3b1da 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Slot.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Slot.java @@ -25,7 +25,7 @@ package me.shedaniel.rei.api.client.gui.widgets; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.common.ingredient.EntryStack; +import me.shedaniel.rei.api.common.entry.EntryStack; import org.jetbrains.annotations.Nullable; import java.util.Collection; diff --git a/api/src/main/java/me/shedaniel/rei/api/client/ingredient/entry/renderer/AbstractEntryRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/ingredient/entry/renderer/AbstractEntryRenderer.java deleted file mode 100644 index 6dfc64ecd..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/client/ingredient/entry/renderer/AbstractEntryRenderer.java +++ /dev/null @@ -1,29 +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.api.client.ingredient.entry.renderer; - -import net.minecraft.client.gui.GuiComponent; - -public abstract class AbstractEntryRenderer extends GuiComponent implements EntryRenderer { -} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/ingredient/entry/renderer/BatchEntryRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/ingredient/entry/renderer/BatchEntryRenderer.java deleted file mode 100644 index 422f05902..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/client/ingredient/entry/renderer/BatchEntryRenderer.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 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.ingredient.entry.renderer; - -import com.mojang.blaze3d.vertex.PoseStack; -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.common.ingredient.EntryStack; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.MultiBufferSource; - -public interface BatchEntryRenderer extends EntryRenderer { - static int getBatchIdFrom(EntryStack entry) { - EntryRenderer renderer = entry.getRenderer(); - if (renderer instanceof BatchEntryRenderer) return ((BatchEntryRenderer) renderer).getBatchId(entry); - return renderer.getClass().hashCode(); - } - - default int getBatchId(EntryStack entry) { - return getClass().hashCode(); - } - - void startBatch(EntryStack entry, PoseStack matrices, float delta); - - void renderBase(EntryStack entry, PoseStack matrices, MultiBufferSource.BufferSource immediate, Rectangle bounds, int mouseX, int mouseY, float delta); - - void renderOverlay(EntryStack entry, PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta); - - void endBatch(EntryStack entry, PoseStack matrices, float delta); - - @Deprecated - @Override - default void render(EntryStack entry, PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) { - startBatch(entry, matrices, delta); - MultiBufferSource.BufferSource immediate = Minecraft.getInstance().renderBuffers().bufferSource(); - renderBase(entry, matrices, immediate, bounds, mouseX, mouseY, delta); - immediate.endBatch(); - renderOverlay(entry, matrices, bounds, mouseX, mouseY, delta); - endBatch(entry, matrices, delta); - } -} \ No newline at end of file diff --git a/api/src/main/java/me/shedaniel/rei/api/client/ingredient/entry/renderer/EntryRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/ingredient/entry/renderer/EntryRenderer.java deleted file mode 100644 index c6b5ca961..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/client/ingredient/entry/renderer/EntryRenderer.java +++ /dev/null @@ -1,49 +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.api.client.ingredient.entry.renderer; - -import com.mojang.blaze3d.vertex.PoseStack; -import me.shedaniel.math.Point; -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.client.gui.widgets.Tooltip; -import me.shedaniel.rei.api.common.ingredient.EntryStack; -import me.shedaniel.rei.impl.ClientInternals; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; - -public interface EntryRenderer { - static EntryRenderer empty() { - return ClientInternals.getEmptyEntryRenderer(); - } - - void render(EntryStack entry, PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta); - - @Nullable - Tooltip getTooltip(EntryStack entry, Point mouse); - - @ApiStatus.NonExtendable - default EntryRenderer cast() { - return (EntryRenderer) this; - } -} \ No newline at end of file diff --git a/api/src/main/java/me/shedaniel/rei/api/client/ingredient/entry/type/BuiltinClientEntryTypes.java b/api/src/main/java/me/shedaniel/rei/api/client/ingredient/entry/type/BuiltinClientEntryTypes.java deleted file mode 100644 index 6e98db863..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/client/ingredient/entry/type/BuiltinClientEntryTypes.java +++ /dev/null @@ -1,36 +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.api.client.ingredient.entry.type; - -import me.shedaniel.rei.api.client.gui.Renderer; -import me.shedaniel.rei.api.common.ingredient.entry.type.EntryType; -import net.minecraft.resources.ResourceLocation; -import org.jetbrains.annotations.ApiStatus; - -@ApiStatus.NonExtendable -public interface BuiltinClientEntryTypes { - ResourceLocation RENDERING_ID = new ResourceLocation("rendering"); - - EntryType RENDERING = EntryType.deferred(RENDERING_ID); -} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/ingredient/util/ClientEntryIngredients.java b/api/src/main/java/me/shedaniel/rei/api/client/ingredient/util/ClientEntryIngredients.java deleted file mode 100644 index 078c6a7e2..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/client/ingredient/util/ClientEntryIngredients.java +++ /dev/null @@ -1,35 +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.api.client.ingredient.util; - -import me.shedaniel.rei.api.client.gui.Renderer; -import me.shedaniel.rei.api.common.ingredient.EntryIngredient; - -public final class ClientEntryIngredients { - private ClientEntryIngredients() {} - - public static EntryIngredient of(Renderer renderer) { - return EntryIngredient.of(ClientEntryStacks.of(renderer)); - } -} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/ingredient/util/ClientEntryStacks.java b/api/src/main/java/me/shedaniel/rei/api/client/ingredient/util/ClientEntryStacks.java deleted file mode 100644 index 76f7ddba1..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/client/ingredient/util/ClientEntryStacks.java +++ /dev/null @@ -1,40 +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.api.client.ingredient.util; - -import me.shedaniel.rei.api.client.gui.Renderer; -import me.shedaniel.rei.api.client.ingredient.entry.type.BuiltinClientEntryTypes; -import me.shedaniel.rei.api.common.ingredient.EntryStack; - -public final class ClientEntryStacks { - private ClientEntryStacks() {} - - public static EntryStack of(Renderer renderer) { - if (renderer instanceof EntryStack) { - return (EntryStack) renderer; - } - - return EntryStack.of(BuiltinClientEntryTypes.RENDERING, renderer); - } -} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/plugins/REIClientPlugin.java b/api/src/main/java/me/shedaniel/rei/api/client/plugins/REIClientPlugin.java index 7a51c9789..596281509 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/plugins/REIClientPlugin.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/plugins/REIClientPlugin.java @@ -106,4 +106,9 @@ public interface REIClientPlugin extends REIPlugin { @ApiStatus.OverrideOnly default void registerTransferHandlers(TransferHandlerRegistry registry) { } + + @Override + default Class getPluginProviderClass() { + return REIClientPlugin.class; + } } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/category/CategoryRegistry.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/category/CategoryRegistry.java index 8775f1277..90abba478 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/category/CategoryRegistry.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/category/CategoryRegistry.java @@ -27,8 +27,8 @@ import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.client.registry.display.DisplayCategory; import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.display.Display; -import me.shedaniel.rei.api.common.ingredient.EntryIngredient; -import me.shedaniel.rei.api.common.ingredient.EntryStack; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.registry.Reloadable; import me.shedaniel.rei.api.common.util.CollectionUtils; diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayCategory.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayCategory.java index 2eda48d8a..f209ac35c 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayCategory.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayCategory.java @@ -58,7 +58,7 @@ public interface DisplayCategory extends Identifiable { Component getTitle(); /** - * Gets the recipe renderer for the category, used in {@link me.shedaniel.rei.gui.CompositeRecipeViewingScreen} for rendering simple recipes + * Gets the recipe renderer for the category, used in {@link me.shedaniel.rei.impl.client.gui.CompositeRecipeViewingScreen} for rendering simple recipes * * @param display the display to render * @return the display renderer diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/display/LiveDisplayGenerator.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/display/LiveDisplayGenerator.java index cb57ad11c..3f97c9822 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/display/LiveDisplayGenerator.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/display/LiveDisplayGenerator.java @@ -25,7 +25,7 @@ package me.shedaniel.rei.api.client.registry.display; import me.shedaniel.rei.api.client.view.ViewSearchBuilder; import me.shedaniel.rei.api.common.display.Display; -import me.shedaniel.rei.api.common.ingredient.EntryStack; +import me.shedaniel.rei.api.common.entry.EntryStack; import java.util.List; import java.util.Optional; diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/EntryRegistry.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/EntryRegistry.java index d1962aef2..141799a8a 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/EntryRegistry.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/EntryRegistry.java @@ -24,7 +24,7 @@ package me.shedaniel.rei.api.client.registry.entry; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; -import me.shedaniel.rei.api.common.ingredient.EntryStack; +import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.registry.Reloadable; import net.fabricmc.api.EnvType; diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/FocusedStackProvider.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/FocusedStackProvider.java index 70c236050..0758914ff 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/FocusedStackProvider.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/FocusedStackProvider.java @@ -24,7 +24,7 @@ package me.shedaniel.rei.api.client.registry.screen; import me.shedaniel.math.Point; -import me.shedaniel.rei.api.common.ingredient.EntryStack; +import me.shedaniel.rei.api.common.entry.EntryStack; import net.minecraft.client.gui.screens.Screen; import net.minecraft.world.InteractionResultHolder; diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/ScreenRegistry.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/ScreenRegistry.java index b006ba5bd..916168aa3 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/ScreenRegistry.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/ScreenRegistry.java @@ -28,7 +28,7 @@ import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.config.DisplayPanelLocation; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.common.category.CategoryIdentifier; -import me.shedaniel.rei.api.common.ingredient.EntryStack; +import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.registry.Reloadable; import net.fabricmc.api.EnvType; 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 969b05ade..86c520636 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 @@ -38,6 +38,15 @@ import org.jetbrains.annotations.Nullable; import java.util.function.Supplier; +/** + * Handler for display transfer, only executed on the client, implementations of this handler should sync recipes to the server to transfer recipes themselves. + *

+ * REI provides a {@link TransferHandler} that handles displays that are provided with {@link me.shedaniel.rei.api.common.transfer.info.MenuInfo}, + * as a lightweight and simple way to implement recipe transfers. + * + * @see TransferHandlerRegistry + * @see me.shedaniel.rei.api.common.transfer.info.MenuInfo + */ @Environment(EnvType.CLIENT) public interface TransferHandler extends Comparable { /** diff --git a/api/src/main/java/me/shedaniel/rei/api/client/search/SearchFilter.java b/api/src/main/java/me/shedaniel/rei/api/client/search/SearchFilter.java index 243353182..735e5fddf 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/search/SearchFilter.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/search/SearchFilter.java @@ -23,7 +23,7 @@ package me.shedaniel.rei.api.client.search; -import me.shedaniel.rei.api.common.ingredient.EntryStack; +import me.shedaniel.rei.api.common.entry.EntryStack; import java.util.function.Predicate; diff --git a/api/src/main/java/me/shedaniel/rei/api/client/subsets/SubsetsRegistry.java b/api/src/main/java/me/shedaniel/rei/api/client/subsets/SubsetsRegistry.java index 31b9544f5..e1f8fc475 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/subsets/SubsetsRegistry.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/subsets/SubsetsRegistry.java @@ -24,7 +24,7 @@ package me.shedaniel.rei.api.client.subsets; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; -import me.shedaniel.rei.api.common.ingredient.EntryStack; +import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.registry.Reloadable; import net.fabricmc.api.EnvType; diff --git a/api/src/main/java/me/shedaniel/rei/api/client/util/ClientEntryIngredients.java b/api/src/main/java/me/shedaniel/rei/api/client/util/ClientEntryIngredients.java new file mode 100644 index 000000000..f01589c48 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/util/ClientEntryIngredients.java @@ -0,0 +1,35 @@ +/* + * 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.client.util; + +import me.shedaniel.rei.api.client.gui.Renderer; +import me.shedaniel.rei.api.common.entry.EntryIngredient; + +public final class ClientEntryIngredients { + private ClientEntryIngredients() {} + + public static EntryIngredient of(Renderer renderer) { + return EntryIngredient.of(ClientEntryStacks.of(renderer)); + } +} 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 new file mode 100644 index 000000000..85d3d4a84 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/util/ClientEntryStacks.java @@ -0,0 +1,40 @@ +/* + * 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.client.util; + +import me.shedaniel.rei.api.client.gui.Renderer; +import me.shedaniel.rei.api.client.entry.type.BuiltinClientEntryTypes; +import me.shedaniel.rei.api.common.entry.EntryStack; + +public final class ClientEntryStacks { + private ClientEntryStacks() {} + + public static EntryStack of(Renderer renderer) { + if (renderer instanceof EntryStack) { + return (EntryStack) renderer; + } + + return EntryStack.of(BuiltinClientEntryTypes.RENDERING, renderer); + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/view/ViewSearchBuilder.java b/api/src/main/java/me/shedaniel/rei/api/client/view/ViewSearchBuilder.java index fe596a8b1..068057dca 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/view/ViewSearchBuilder.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/view/ViewSearchBuilder.java @@ -27,7 +27,7 @@ import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; import me.shedaniel.rei.api.client.registry.display.DisplayCategory; import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.display.Display; -import me.shedaniel.rei.api.common.ingredient.EntryStack; +import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.util.CollectionUtils; import me.shedaniel.rei.impl.ClientInternals; import org.jetbrains.annotations.Nullable; diff --git a/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java b/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java index 4d0eb2d5d..7a74f3d8b 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java @@ -26,7 +26,7 @@ package me.shedaniel.rei.api.client.view; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.client.registry.display.DisplayCategory; import me.shedaniel.rei.api.common.display.Display; -import me.shedaniel.rei.api.common.ingredient.EntryStack; +import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.registry.Reloadable; diff --git a/api/src/main/java/me/shedaniel/rei/api/common/display/Display.java b/api/src/main/java/me/shedaniel/rei/api/common/display/Display.java index 66b3ee0f2..8db2b2bb9 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/display/Display.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/display/Display.java @@ -24,7 +24,7 @@ package me.shedaniel.rei.api.common.display; import me.shedaniel.rei.api.common.category.CategoryIdentifier; -import me.shedaniel.rei.api.common.ingredient.EntryIngredient; +import me.shedaniel.rei.api.common.entry.EntryIngredient; import net.minecraft.resources.ResourceLocation; import java.util.List; diff --git a/api/src/main/java/me/shedaniel/rei/api/common/display/SimpleDisplaySerializer.java b/api/src/main/java/me/shedaniel/rei/api/common/display/SimpleDisplaySerializer.java index fec822384..203082a30 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/display/SimpleDisplaySerializer.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/display/SimpleDisplaySerializer.java @@ -23,7 +23,7 @@ package me.shedaniel.rei.api.common.display; -import me.shedaniel.rei.api.common.ingredient.util.EntryIngredients; +import me.shedaniel.rei.api.common.util.EntryIngredients; import net.minecraft.nbt.CompoundTag; public interface SimpleDisplaySerializer extends DisplaySerializer { diff --git a/api/src/main/java/me/shedaniel/rei/api/common/display/basic/BasicDisplay.java b/api/src/main/java/me/shedaniel/rei/api/common/display/basic/BasicDisplay.java index 4cab665dc..2778fc7a8 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/display/basic/BasicDisplay.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/display/basic/BasicDisplay.java @@ -26,8 +26,8 @@ package me.shedaniel.rei.api.common.display.basic; import me.shedaniel.architectury.utils.NbtType; import me.shedaniel.rei.api.common.display.Display; import me.shedaniel.rei.api.common.display.SimpleDisplaySerializer; -import me.shedaniel.rei.api.common.ingredient.EntryIngredient; -import me.shedaniel.rei.api.common.ingredient.util.EntryIngredients; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.util.EntryIngredients; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryIngredient.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryIngredient.java new file mode 100644 index 000000000..fde4d8d8b --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryIngredient.java @@ -0,0 +1,64 @@ +/* + * 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.entry; + +import me.shedaniel.rei.impl.Internals; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; + +import java.util.List; + +/** + * An immutable representation of a list of {@link EntryStack}. + */ +public interface EntryIngredient extends List> { + static EntryIngredient empty() { + return Internals.getEntryIngredientProvider().empty(); + } + + static EntryIngredient of(EntryStack stack) { + return Internals.getEntryIngredientProvider().of(stack); + } + + @SafeVarargs + static EntryIngredient of(EntryStack... stacks) { + return Internals.getEntryIngredientProvider().of(stacks); + } + + @SuppressWarnings({"RedundantCast", "rawtypes"}) + static EntryIngredient of(Iterable> stacks) { + return Internals.getEntryIngredientProvider().of((Iterable>) (Iterable) stacks); + } + + static EntryIngredient from(ListTag tag) { + if (tag.isEmpty()) return empty(); + EntryStack[] stacks = new EntryStack[tag.size()]; + for (int i = 0; i < tag.size(); i++) { + stacks[i] = EntryStack.read((CompoundTag) tag.get(i)); + } + return Internals.getEntryIngredientProvider().of(stacks); + } + + ListTag save(); +} diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/EntrySerializer.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/EntrySerializer.java new file mode 100644 index 000000000..9f603802d --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/EntrySerializer.java @@ -0,0 +1,41 @@ +/* + * 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.entry; + +import net.minecraft.nbt.CompoundTag; + +/** + * A serializer for {@link EntryStack}, optionally supporting saving and reading. + * + * @param the type of object to serialize + */ +public interface EntrySerializer { + boolean supportSaving(); + + boolean supportReading(); + + CompoundTag save(EntryStack entry, T value); + + T read(CompoundTag tag); +} diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java new file mode 100644 index 000000000..d251f8a14 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java @@ -0,0 +1,227 @@ +/* + * 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.entry; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.mojang.serialization.Dynamic; +import com.mojang.serialization.JsonOps; +import me.shedaniel.rei.api.client.gui.Renderer; +import me.shedaniel.rei.api.client.gui.widgets.Tooltip; +import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer; +import me.shedaniel.rei.api.common.entry.comparison.ComparisonContext; +import me.shedaniel.rei.api.common.entry.type.EntryDefinition; +import me.shedaniel.rei.api.common.entry.type.EntryType; +import me.shedaniel.rei.api.common.entry.type.EntryTypeRegistry; +import me.shedaniel.rei.api.common.util.TextRepresentable; +import me.shedaniel.rei.impl.Internals; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtOps; +import net.minecraft.nbt.TagParser; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.GsonHelper; +import net.minecraft.util.Unit; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.function.Supplier; + +@Environment(EnvType.CLIENT) +public interface EntryStack extends TextRepresentable, Renderer { + static EntryStack empty() { + return Internals.getEntryStackProvider().empty(); + } + + static EntryStack of(EntryDefinition definition, T value) { + return Internals.getEntryStackProvider().of(definition, value); + } + + static EntryStack of(EntryType type, T value) { + return of(type.getDefinition(), value); + } + + @ApiStatus.Internal + static EntryStack readFromJson(JsonElement jsonElement) { + try { + JsonObject obj = jsonElement.getAsJsonObject(); + EntryType type = EntryType.deferred(new ResourceLocation(GsonHelper.getAsString(obj, "type"))); + EntrySerializer serializer = type.getDefinition().getSerializer(); + if (serializer != null && serializer.supportReading()) { + Object o = serializer.read(TagParser.parseTag(obj.toString())); + return EntryStack.of(type, o); + } + } catch (Exception e) { + e.printStackTrace(); + } + return EntryStack.empty(); + } + + @ApiStatus.Internal + @Nullable + default JsonElement toJson() { + try { + EntrySerializer serializer = getDefinition().getSerializer(); + if (serializer != null && serializer.supportSaving()) { + JsonObject object = Dynamic.convert(NbtOps.INSTANCE, JsonOps.INSTANCE, serializer.save(this, getValue())).getAsJsonObject(); + object.addProperty("type", getType().getId().toString()); + return object; + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + static EntryStack read(CompoundTag tag) { + EntryDefinition definition = EntryTypeRegistry.getInstance().get(new ResourceLocation(tag.getString("type"))); + EntrySerializer serializer = definition.getSerializer(); + if (serializer != null && serializer.supportReading()) { + return EntryStack.of((EntryType) definition, serializer.read(tag)); + } + throw new UnsupportedOperationException(definition.getType().getId() + " does not support deserialization!"); + } + + @Nullable + default CompoundTag save() { + EntrySerializer serializer = getDefinition().getSerializer(); + if (serializer !=