From f8e6de6909b4c9b4e725bd79e154374aeb0290f8 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Tue, 15 Feb 2022 01:44:20 +0800 Subject: Support JEI API 9.3 --- .../client/gui/widget/CatchingExceptionUtils.java | 23 ++++++++++++++++++++++ .../shedaniel/rei/impl/client/view/ViewsImpl.java | 19 ++++++++++++++++++ .../plugin/client/entry/ItemEntryDefinition.java | 1 - 3 files changed, 42 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CatchingExceptionUtils.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CatchingExceptionUtils.java index 1015160f8..74b5e220a 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CatchingExceptionUtils.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CatchingExceptionUtils.java @@ -1,3 +1,26 @@ +/* + * 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.impl.client.gui.widget; import me.shedaniel.rei.api.common.util.ImmutableTextComponent; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/view/ViewsImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/view/ViewsImpl.java index c07a29072..df371c961 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/view/ViewsImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/view/ViewsImpl.java @@ -56,6 +56,7 @@ import net.minecraft.client.player.LocalPlayer; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.inventory.AbstractContainerMenu; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; import java.util.*; import java.util.function.Consumer; @@ -64,7 +65,25 @@ import java.util.stream.Stream; @ApiStatus.Internal public class ViewsImpl implements Views { + private static final ThreadLocal BUILDER = new ThreadLocal<>(); + + @Nullable + @Override + public ViewSearchBuilder getContext() { + return BUILDER.get(); + } + public static Map, List> buildMapFor(ViewSearchBuilder builder) { + BUILDER.set(builder); + + try { + return _buildMapFor(builder); + } finally { + BUILDER.remove(); + } + } + + private static Map, List> _buildMapFor(ViewSearchBuilder builder) { if (PluginManager.areAnyReloading()) { RoughlyEnoughItemsCore.LOGGER.info("Cancelled Views buildMap since plugins have not finished reloading."); return Maps.newLinkedHashMap(); diff --git a/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java b/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java index 62ec927db..1515ed6ae 100644 --- a/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java +++ b/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java @@ -298,7 +298,6 @@ public class ItemEntryDefinition implements EntryDefinition, EntrySer Minecraft.getInstance().getItemRenderer().render(value, ItemTransforms.TransformType.GUI, false, matrices, immediate, ITEM_LIGHT, OverlayTexture.NO_OVERLAY, model); matrices.popPose(); - throw new AssertionError(); /*ItemStack value = entry.getValue(); matrices.pushPose(); -- cgit