From b866becfb620c02a74fb990915001e154b5d2b0b Mon Sep 17 00:00:00 2001 From: shedaniel Date: Mon, 2 Aug 2021 19:54:29 +0800 Subject: Welcome, Forge 1.17 --- .../me/shedaniel/rei/forge/PluginDetectorImpl.java | 4 +- .../rei/forge/RoughlyEnoughItemsForge.java | 8 ++-- .../client/gui/forge/ScreenOverlayImplImpl.java | 45 ++++++++++++++++++++++ .../client/forge/DefaultClientPluginImpl.java | 8 ++-- .../rei/plugin/common/forge/DefaultPluginImpl.java | 8 ++-- 5 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 forge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/ScreenOverlayImplImpl.java (limited to 'forge/src/main/java') diff --git a/forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java b/forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java index e299054c0..8ee7a0a99 100644 --- a/forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java +++ b/forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java @@ -32,8 +32,9 @@ import me.shedaniel.rei.api.common.plugins.REIServerPlugin; import me.shedaniel.rei.impl.ClientInternals; import me.shedaniel.rei.jeicompat.JEIPluginDetector; import me.shedaniel.rei.plugin.client.DefaultClientPlugin; -import me.shedaniel.rei.plugin.client.DefaultClientRuntimePlugin; +import me.shedaniel.rei.plugin.client.runtime.DefaultClientRuntimePlugin; import me.shedaniel.rei.plugin.common.DefaultPlugin; +import me.shedaniel.rei.plugin.common.runtime.DefaultRuntimePlugin; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @@ -69,6 +70,7 @@ public class PluginDetectorImpl { public static void detectServerPlugins() { PluginView.getServerInstance().registerPlugin(wrapPlugin(Collections.singletonList("roughlyenoughitems"), new DefaultPlugin())); + PluginView.getServerInstance().registerPlugin(wrapPlugin(Collections.singletonList("roughlyenoughitems"), new DefaultRuntimePlugin())); RoughlyEnoughItemsForge.scanAnnotation(REIPlugin.class, REIServerPlugin.class::isAssignableFrom, (modId, plugin) -> { ((PluginView) PluginManager.getServerInstance()).registerPlugin(wrapPlugin(modId, plugin.get())); }); diff --git a/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java b/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java index 61593fd84..db5da78bd 100644 --- a/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java +++ b/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java @@ -67,21 +67,21 @@ public class RoughlyEnoughItemsForge { .map(IModInfo::getModId) .collect(Collectors.toList()); for (ModFileScanData.AnnotationData annotation : data.getAnnotations()) { - if (annotationType.equals(annotation.getAnnotationType())) { + if (annotationType.equals(annotation.targetType())) { try { - Class clazz = (Class) Class.forName(annotation.getMemberName()); + Class clazz = (Class) Class.forName(annotation.memberName()); if (predicate.test(clazz)) { instances.add(new ImmutablePair<>(modIds, () -> { try { return clazz.getDeclaredConstructor().newInstance(); } catch (Throwable throwable) { - LOGGER.error("Failed to load plugin: " + annotation.getMemberName(), throwable); + LOGGER.error("Failed to load plugin: " + annotation.memberName(), throwable); return null; } })); } } catch (Throwable throwable) { - LOGGER.error("Failed to load plugin: " + annotation.getMemberName(), throwable); + LOGGER.error("Failed to load plugin: " + annotation.memberName(), throwable); } } } diff --git a/forge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/ScreenOverlayImplImpl.java b/forge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/ScreenOverlayImplImpl.java new file mode 100644 index 000000000..1b27ecf80 --- /dev/null +++ b/forge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/ScreenOverlayImplImpl.java @@ -0,0 +1,45 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 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.forge; + +import com.mojang.blaze3d.vertex.PoseStack; +import me.shedaniel.rei.api.client.gui.widgets.Tooltip; +import me.shedaniel.rei.api.common.entry.EntryStack; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.fmlclient.gui.GuiUtils; + +public class ScreenOverlayImplImpl { + public static void renderTooltipInner(Screen screen, PoseStack matrices, Tooltip tooltip, int mouseX, int mouseY) { + matrices.pushPose(); + matrices.translate(0, 0, 500); + EntryStack stack = tooltip.getContextStack(); + ItemStack itemStack = stack.getValue() instanceof ItemStack ? stack.castValue() : ItemStack.EMPTY; + GuiUtils.preItemToolTip(itemStack); + GuiUtils.drawHoveringText(matrices, tooltip.getText(), mouseX, mouseY, screen.width, screen.height, screen.width, Minecraft.getInstance().font); + GuiUtils.postItemToolTip(); + matrices.popPose(); + } +} diff --git a/forge/src/main/java/me/shedaniel/rei/plugin/client/forge/DefaultClientPluginImpl.java b/forge/src/main/java/me/shedaniel/rei/plugin/client/forge/DefaultClientPluginImpl.java index 7c47d1c84..9ad85f452 100644 --- a/forge/src/main/java/me/shedaniel/rei/plugin/client/forge/DefaultClientPluginImpl.java +++ b/forge/src/main/java/me/shedaniel/rei/plugin/client/forge/DefaultClientPluginImpl.java @@ -42,9 +42,9 @@ public class DefaultClientPluginImpl { Set potions = Sets.newLinkedHashSet(); for (Ingredient container : PotionBrewing.ALLOWED_CONTAINERS) { for (PotionBrewing.Mix mix : PotionBrewing.POTION_MIXES) { - IRegistryDelegate from = mix.from; + IRegistryDelegate from = mix.f_43532_; Ingredient ingredient = mix.ingredient; - IRegistryDelegate to = mix.to; + IRegistryDelegate to = mix.f_43534_; Ingredient base = Ingredient.of(Arrays.stream(container.getItems()) .map(ItemStack::copy) .map(stack -> PotionUtils.setPotion(stack, from.get()))); @@ -59,9 +59,9 @@ public class DefaultClientPluginImpl { } for (Potion potion : potions) { for (PotionBrewing.Mix mix : PotionBrewing.CONTAINER_MIXES) { - IRegistryDelegate from = mix.from; + IRegistryDelegate from = mix.f_43532_; Ingredient ingredient = mix.ingredient; - IRegistryDelegate to = mix.to; + IRegistryDelegate to = mix.f_43534_; Ingredient base = Ingredient.of(PotionUtils.setPotion(new ItemStack(from.get()), potion)); ItemStack output = PotionUtils.setPotion(new ItemStack(to.get()), potion); clientPlugin.registerBrewingRecipe(base, ingredient, output); 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 bc7780d11..cc87da5b9 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 @@ -24,10 +24,10 @@ package me.shedaniel.rei.plugin.common.forge; import com.google.common.base.Predicates; -import dev.architectury.hooks.forge.FluidStackHooksForge; +import dev.architectury.event.CompoundEventResult; +import dev.architectury.hooks.fluid.forge.FluidStackHooksForge; import me.shedaniel.rei.api.common.fluid.FluidSupportProvider; import me.shedaniel.rei.api.common.util.EntryStacks; -import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.item.ItemStack; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidStack; @@ -44,7 +44,7 @@ public class DefaultPluginImpl { if (handlerOptional.isPresent()) { IFluidHandlerItem handler = handlerOptional.orElse(null); if (handler.getTanks() > 0) { - return InteractionResultHolder.success(IntStream.range(0, handler.getTanks()) + return CompoundEventResult.interruptTrue(IntStream.range(0, handler.getTanks()) .mapToObj(handler::getFluidInTank) .filter(Predicates.not(FluidStack::isEmpty)) .map(FluidStackHooksForge::fromForge) @@ -52,7 +52,7 @@ public class DefaultPluginImpl { } } - return InteractionResultHolder.pass(null); + return CompoundEventResult.pass(); }); } } -- cgit