diff options
| author | shedaniel <daniel@shedaniel.me> | 2022-04-22 15:47:18 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2022-04-22 15:47:18 +0800 |
| commit | ca88276257bfccf055d03dcfce8df6b43ca40bf9 (patch) | |
| tree | 7ee656ab7a3a94a2cc15af07f56bd970300de586 | |
| parent | e3ab358e5fe608414629f4e214b1ec8f856dbe2d (diff) | |
| parent | 8eb903cc67d5e6813570ddd1d74bcfd3a3ffba45 (diff) | |
| download | RoughlyEnoughItems-ca88276257bfccf055d03dcfce8df6b43ca40bf9.tar.gz RoughlyEnoughItems-ca88276257bfccf055d03dcfce8df6b43ca40bf9.tar.bz2 RoughlyEnoughItems-ca88276257bfccf055d03dcfce8df6b43ca40bf9.zip | |
Merge remote-tracking branch 'origin/8.x-1.18.2' into 9.x-1.19
27 files changed, 885 insertions, 234 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/DelegateWidgetWithBounds.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/DelegateWidgetWithBounds.java new file mode 100644 index 000000000..cf2a9e025 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/DelegateWidgetWithBounds.java @@ -0,0 +1,42 @@ +/* + * 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.gui.widgets; + +import me.shedaniel.math.Rectangle; + +import java.util.function.Supplier; + +public class DelegateWidgetWithBounds extends DelegateWidget { + private final Supplier<Rectangle> bounds; + + public DelegateWidgetWithBounds(Widget widget, Supplier<Rectangle> bounds) { + super(widget); + this.bounds = bounds; + } + + @Override + public Rectangle getBounds() { + return bounds.get(); + } +}
\ No newline at end of file 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 fee50c9d5..9dbeb363c 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 @@ -24,9 +24,7 @@ package me.shedaniel.rei.api.client.gui.widgets; import com.google.common.collect.AbstractIterator; -import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Matrix4f; -import com.mojang.math.Vector4f; import me.shedaniel.math.Dimension; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; @@ -37,13 +35,13 @@ import me.shedaniel.rei.impl.ClientInternals; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiComponent; import net.minecraft.client.gui.components.events.ContainerEventHandler; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.resources.sounds.SimpleSoundInstance; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; import java.util.*; @@ -60,8 +58,51 @@ public final class Widgets { return ClientInternals.getWidgetsProvider().createDrawableWidget(drawable); } + public static WidgetWithBounds withTooltip(WidgetWithBounds widget, Component... texts) { + return withTooltip(widget, Arrays.asList(texts)); + } + + public static WidgetWithBounds withTooltip(WidgetWithBounds widget, Collection<Component> texts) { + return withBounds(concat( + widget, + createTooltip(widget::getBounds, texts) + ), widget::getBounds); + } + + public static Widget createTooltip(Rectangle bounds, Component... texts) { + return createTooltip(() -> bounds, Arrays.asList(texts)); + } + + public static Widget createTooltip(Rectangle bounds, Collection<Component> texts) { + return createTooltip(() -> bounds, texts); + } + + public static Widget createTooltip(Supplier<Rectangle> bounds, Component... texts) { + return createTooltip(bounds, Arrays.asList(texts)); + } + + public static Widget createTooltip(Supplier<Rectangle> bounds, Collection<Component> texts) { + return createTooltip(mouse -> { + if (bounds.get().contains(mouse)) { + return Tooltip.create(mouse, texts); + } else { + return null; + } + }); + } + + public static Widget createTooltip(Function<Point, @Nullable Tooltip> tooltipSupplier) { + return createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> { + Point mouse = new Point(mouseX, mouseY); + Tooltip tooltip = tooltipSupplier.apply(mouse); + if (tooltip != null) { + tooltip.queue(); + } + }); + } + public static Widget wrapVanillaWidget(GuiEventListener element) { - return new VanillaWrappedWidget(element); + return ClientInternals.getWidgetsProvider().wrapVanillaWidget(element); } public static WidgetWithBounds withTranslate(Widget widget, double x, double y, double z) { @@ -69,119 +110,16 @@ public final class Widgets { } public static WidgetWithBounds withTranslate(Widget widget, Matrix4f translate) { - WidgetWithBounds widgetWithBounds = wrapWidgetWithBounds(widget); - return new WidgetWithBoundsWithTranslate(widgetWithBounds, () -> translate); + return withTranslate(widget, () -> translate); } public static <T extends Widget> WidgetWithBounds withTranslate(T widget, Function<T, Matrix4f> translate) { - WidgetWithBounds widgetWithBounds = wrapWidgetWithBounds(widget); - return new WidgetWithBoundsWithTranslate(widgetWithBounds, () -> translate.apply(widget)); + return withTranslate(widget, () -> translate.apply(widget)); } public static WidgetWithBounds withTranslate(Widget widget, Supplier<Matrix4f> translate) { WidgetWithBounds widgetWithBounds = wrapWidgetWithBounds(widget); - return new WidgetWithBoundsWithTranslate(widgetWithBounds, translate); - } - - private static class WidgetWithBoundsWithTranslate extends DelegateWidget { - private final Supplier<Matrix4f> translate; - - private WidgetWithBoundsWithTranslate(WidgetWithBounds widget, Supplier<Matrix4f> translate) { - super(widget); - this.translate = translate; - } - - @Override - public void render(PoseStack poseStack, int i, int j, float f) { - poseStack.pushPose(); - poseStack.last().pose().multiply(translate.get()); - Vector4f mouse = transformMouse(i, j); - super.render(poseStack, (int) mouse.x(), (int) mouse.y(), f); - poseStack.popPose(); - } - - private Vector4f transformMouse(double mouseX, double mouseY) { - Vector4f mouse = new Vector4f((float) mouseX, (float) mouseY, 0, 1); - mouse.transform(translate.get()); - return mouse; - } - - @Override - public boolean containsMouse(double mouseX, double mouseY) { - Vector4f mouse = transformMouse(mouseX, mouseY); - return super.containsMouse(mouse.x(), mouse.y()); - } - - @Override - public boolean mouseClicked(double d, double e, int i) { - Vector4f mouse = transformMouse(d, e); - return super.mouseClicked(mouse.x(), mouse.y(), i); - } - - @Override - public boolean mouseReleased(double d, double e, int i) { - Vector4f mouse = transformMouse(d, e); - return super.mouseReleased(mouse.x(), mouse.y(), i); - } - - @Override - public boolean mouseDragged(double d, double e, int i, double f, double g) { - Vector4f mouse = transformMouse(d, e); - return super.mouseDragged(mouse.x(), mouse.y(), i, f, g); - } - - @Override - public boolean mouseScrolled(double d, double e, double f) { - Vector4f mouse = transformMouse(d, e); - return super.mouseScrolled(mouse.x(), mouse.y(), f); - } - } - - private static class VanillaWrappedWidget extends Widget { - private GuiEventListener element; - - public VanillaWrappedWidget(GuiEventListener element) { - this.element = Objects.requireNonNull(element); - setFocused(element); - } - - @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { - if (element instanceof GuiComponent component) - component.setBlitOffset(getZ()); - if (element instanceof net.minecraft.client.gui.components.Widget widget) - widget.render(matrices, mouseX, mouseY, delta); - } - - @Override - public List<? extends GuiEventListener> children() { - return Collections.singletonList(element); - } - - @Nullable - @Override - public GuiEventListener getFocused() { - return element; - } - - @Override - public void setFocused(@Nullable GuiEventListener guiEventListener) { - if (guiEventListener == element) { - super.setFocused(element); - } else if (element instanceof ContainerEventHandler handler) { - handler.setFocused(guiEventListener); - } - } - - @Override - public boolean isDragging() { - return true; - } - - @Override - public boolean containsMouse(double mouseX, double mouseY) { - return element.isMouseOver(mouseX, mouseY); - } + return ClientInternals.getWidgetsProvider().withTranslate(widgetWithBounds, translate); } public static WidgetWithBounds wrapRenderer(Rectangle bounds, Renderer renderer) { @@ -191,18 +129,45 @@ public final class Widgets { public static WidgetWithBounds wrapRenderer(Supplier<Rectangle> bounds, Renderer renderer) { if (renderer instanceof Widget widget) return wrapWidgetWithBoundsSupplier(widget, bounds); - return new RendererWrappedWidget(renderer, bounds); + return ClientInternals.getWidgetsProvider().wrapRenderer(bounds, renderer); } + /** + * @deprecated Use {@link #withBounds(Widget)} instead. + */ + @Deprecated(forRemoval = true) + @ApiStatus.ScheduledForRemoval public static WidgetWithBounds wrapWidgetWithBounds(Widget widget) { - return wrapWidgetWithBounds(widget, null); + return withBounds(widget); } + /** + * @deprecated Use {@link #withBounds(Widget, Rectangle)} instead. + */ + @Deprecated(forRemoval = true) + @ApiStatus.ScheduledForRemoval public static WidgetWithBounds wrapWidgetWithBounds(Widget widget, Rectangle bounds) { - return wrapWidgetWithBoundsSupplier(widget, bounds == null ? null : () -> bounds); + return withBounds(widget, bounds); } + /** + * @deprecated Use {@link #withBounds(Widget, Supplier)} instead. + */ + @Deprecated(forRemoval = true) + @ApiStatus.ScheduledForRemoval public static WidgetWithBounds wrapWidgetWithBoundsSupplier(Widget widget, Supplier<Rectangle> bounds) { + return withBounds(widget, bounds); + } + + public static WidgetWithBounds withBounds(Widget widget) { + return wrapWidgetWithBounds(widget, null); + } + + public static WidgetWithBounds withBounds(Widget widget, Rectangle bounds) { + return wrapWidgetWithBoundsSupplier(widget, bounds == null ? null : () -> bounds); + } + + public static WidgetWithBounds withBounds(Widget widget, Supplier<Rectangle> bounds) { if (widget instanceof WidgetWithBounds withBounds) return withBounds; if (bounds == null) @@ -210,57 +175,6 @@ public final class Widgets { return new DelegateWidgetWithBounds(widget, bounds); } - private static class RendererWrappedWidget extends WidgetWithBounds { - private final Renderer renderer; - private final Supplier<Rectangle> bounds; - - public RendererWrappedWidget(Renderer renderer, Supplier<Rectangle> bounds) { - this.renderer = Objects.requireNonNull(renderer); - this.bounds = Objects.requireNonNull(bounds); - } - - @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { - renderer.render(matrices, getBounds(), mouseX, mouseY, delta); - } - - @Override - public List<? extends GuiEventListener> children() { - if (renderer instanceof GuiEventListener listener) - return Collections.singletonList(listener); - return Collections.emptyList(); - } - - @Override - public void setZ(int z) { - renderer.setZ(z); - } - - @Override - public int getZ() { - return renderer.getZ(); - } - - @Override - public Rectangle getBounds() { - return bounds.get(); - } - } - - private static class DelegateWidgetWithBounds extends DelegateWidget { - private final Supplier<Rectangle> bounds; - - public DelegateWidgetWithBounds(Widget widget, Supplier<Rectangle> bounds) { - super(widget); - this.bounds = bounds; - } - - @Override - public Rectangle getBounds() { - return bounds.get(); - } - } - public static Widget createTexturedWidget(ResourceLocation identifier, Rectangle bounds) { return createTexturedWidget(identifier, bounds, 0, 0); } @@ -357,6 +271,14 @@ public final class Widgets { return createSlotBase(rectangle).color(color); } + public static Widget createShapelessIcon(Rectangle rectangle) { + return createShapelessIcon(new Point(rectangle.getMaxX() - 4, rectangle.y + 4)); + } + + public static Widget createShapelessIcon(Point topRightPos) { + return ClientInternals.getWidgetsProvider().createShapelessIcon(topRightPos); + } + public static Slot createSlot(Point point) { return ClientInternals.getWidgetsProvider().createSlot(point); } @@ -373,6 +295,14 @@ public final class Widgets { Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); } + public static Widget concat(Widget... widgets) { + return concat(Arrays.asList(widgets)); + } + + public static Widget concat(List<Widget> widgets) { + return ClientInternals.getWidgetsProvider().concatWidgets(widgets); + } + public static <T> Iterable<T> walk(Iterable<? extends GuiEventListener> listeners, Predicate<GuiEventListener> predicate) { return () -> new AbstractIterator<T>() { Stack<Iterator<? extends GuiEventListener>> stack; diff --git a/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java b/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java index 755ab943a..4341771d1 100644 --- a/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java +++ b/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java @@ -23,6 +23,7 @@ package me.shedaniel.rei.impl; +import com.mojang.math.Matrix4f; import com.mojang.serialization.DataResult; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; @@ -30,6 +31,7 @@ import me.shedaniel.rei.api.client.ClientHelper; import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer; import me.shedaniel.rei.api.client.favorites.FavoriteEntry; import me.shedaniel.rei.api.client.gui.DrawableConsumer; +import me.shedaniel.rei.api.client.gui.Renderer; import me.shedaniel.rei.api.client.gui.widgets.*; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.client.registry.screen.ClickArea; @@ -37,6 +39,7 @@ import me.shedaniel.rei.api.client.view.ViewSearchBuilder; import me.shedaniel.rei.api.common.plugins.PluginManager; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; @@ -155,6 +158,12 @@ public final class ClientInternals { public interface WidgetsProvider { boolean isRenderingPanel(Panel panel); + Widget wrapVanillaWidget(GuiEventListener element); + + WidgetWithBounds wrapRenderer(Supplier<Rectangle> bounds, Renderer renderer); + + WidgetWithBounds withTranslate(WidgetWithBounds widget, Supplier<Matrix4f> translate); + Widget createDrawableWidget(DrawableConsumer drawable); Slot createSlot(Point point); @@ -174,5 +183,9 @@ public final class ClientInternals { DrawableConsumer createTexturedConsumer(ResourceLocation texture, int x, int y, int width, int height, float u, float v, int uWidth, int vHeight, int textureWidth, int textureHeight); DrawableConsumer createFillRectangleConsumer(Rectangle rectangle, int color); + + Widget createShapelessIcon(Point point); + + Widget concatWidgets(List<Widget> widgets); } } diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/DefaultCraftingCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/DefaultCraftingCategory.java index f4a4d0ca6..55f0ba48a 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/DefaultCraftingCategory.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/DefaultCraftingCategory.java @@ -81,6 +81,9 @@ public class DefaultCraftingCategory implements DisplayCategory<DefaultCraftingD } widgets.addAll(slots); widgets.add(Widgets.createSlot(new Point(startPoint.x + 95, startPoint.y + 19)).entries(display.getOutputEntries().get(0)).disableBackground().markOutput()); + if (display.isShapeless()) { + widgets.add(Widgets.createShapelessIcon(bounds)); + } return widgets; } diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/DefaultPlugin.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/DefaultPlugin.java index 74adb6305..5ba026cc5 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/DefaultPlugin.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/DefaultPlugin.java @@ -88,7 +88,7 @@ public class DefaultPlugin implements BuiltinPlugin, REIServerPlugin { ItemStack stack = entry.getValue(); Item item = stack.getItem(); if (item instanceof BucketItem bucketItem) { - Fluid fluid = bucketItem.content; + Fluid fluid = getFluidFromBucket(bucketItem); if (fluid != null) { return CompoundEventResult.interruptTrue(Stream.of(EntryStacks.of(fluid, FluidStackHooks.bucketAmount()))); } @@ -103,7 +103,12 @@ public class DefaultPlugin implements BuiltinPlugin, REIServerPlugin { @ExpectPlatform @PlatformOnly(PlatformOnly.FORGE) private static void registerForgeFluidSupport(FluidSupportProvider support) { - + throw new AssertionError(); + } + + @ExpectPlatform + private static Fluid getFluidFromBucket(BucketItem item) { + throw new AssertionError(); } @Override diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/crafting/DefaultCraftingDisplay.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/crafting/DefaultCraftingDisplay.java index d405d9f5c..49be00f02 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/crafting/DefaultCraftingDisplay.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/crafting/DefaultCraftingDisplay.java @@ -143,6 +143,10 @@ public abstract class DefaultCraftingDisplay<C extends Recipe<?>> extends BasicD return list; } + public boolean isShapeless() { + return false; + } + public static int getSlotWithSize(DefaultCraftingDisplay<?> display, int index, int craftingGridWidth) { return getSlotWithSize(display.getInputWidth(), index, craftingGridWidth); } diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/crafting/DefaultShapelessDisplay.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/crafting/DefaultShapelessDisplay.java index 502c5c61b..8f500bfb9 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/crafting/DefaultShapelessDisplay.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/crafting/DefaultShapelessDisplay.java @@ -61,4 +61,9 @@ public class DefaultShapelessDisplay extends DefaultCraftingDisplay<ShapelessRec public int getInputHeight() { return (int) Math.ceil(recipe.get().getIngredients().size() / 3.0); } + + @Override + public boolean isShapeless() { + return true; + } } diff --git a/fabric/src/main/java/me/shedaniel/rei/plugin/common/fabric/DefaultPluginImpl.java b/fabric/src/main/java/me/shedaniel/rei/plugin/common/fabric/DefaultPluginImpl.java new file mode 100644 index 000000000..e86a7cb50 --- /dev/null +++ b/fabric/src/main/java/me/shedaniel/rei/plugin/common/fabric/DefaultPluginImpl.java @@ -0,0 +1,65 @@ +/* + * 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.plugin.common.fabric; + +import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.world.item.BucketItem; +import net.minecraft.world.level.material.Fluid; +import org.jetbrains.annotations.NotNull; + +import java.lang.reflect.Field; +import java.util.Optional; + +public class DefaultPluginImpl { + public static Fluid getFluidFromBucket(BucketItem item) { + Field field = getContentField(); + if (field == null) return null; + try { + return (Fluid) field.get(item); + } catch (IllegalAccessException e) { + e.printStackTrace(); + return null; + } + } + + private static Optional<Field> field = null; + + @NotNull + private static Field getContentField() { + if (field == null) { + try { + Field field = BucketItem.class.getDeclaredField(FabricLoader.getInstance().getMappingResolver().mapFieldName("intermediary", "net.minecraft.class_1755", "field_7905", "Lnet/minecraft/class_3611;")); + field.setAccessible(true); + DefaultPluginImpl.field = Optional.of(field); + return field; + } catch (Throwable throwable) { + throwable.printStackTrace(); + DefaultPluginImpl.field = Optional.empty(); + return null; + } + } + + return field.orElse(null); + } +} diff --git a/fabric/src/main/resources/roughlyenoughitems.accessWidener b/fabric/src/main/resources/roughlyenoughitems.accessWidener index baa66082a..a9714d123 100644 --- a/fabric/src/main/resources/roughlyenoughitems.accessWidener +++ b/fabric/src/main/resources/roughlyenoughitems.accessWidener @@ -20,7 +20,6 @@ accessible field net/minecraft/world/item/alchemy/PotionBrewing accessible field net/minecraft/world/item/alchemy/PotionBrewing$Mix from Ljava/lang/Object; accessible field net/minecraft/world/item/alchemy/PotionBrewing$Mix ingredient Lnet/minecraft/world/item/crafting/Ingredient; accessible field net/minecraft/world/item/alchemy/PotionBrewing$Mix to Ljava/lang/Object; -accessible field net/minecraft/world/item/BucketItem content Lnet/minecraft/world/level/material/Fluid; accessible field net/minecraft/world/item/crafting/UpgradeRecipe addition Lnet/minecraft/world/item/crafting/Ingredient; accessible field net/minecraft/world/item/crafting/UpgradeRecipe base Lnet/minecraft/world/item/crafting/Ingredient; accessible field net/minecraft/world/item/CreativeModeTab langId Ljava/lang/String; diff --git a/forge/src/main/java/me/shedaniel/rei/plugin/common/forge/DefaultPluginImpl.java b/forge/src/main/java/me/shedaniel/rei/plugin/common/forge/DefaultPluginImpl.java index a4db8f406..e2ee44500 100644 --- a/forge/src/main/java/me/shedaniel/rei/plugin/common/forge/DefaultPluginImpl.java +++ b/forge/src/main/java/me/shedaniel/rei/plugin/common/forge/DefaultPluginImpl.java @@ -28,7 +28,9 @@ import dev.architectury.e |
