From 1d8b8e4e91adb33d208a5c3b4b2ccc36a0ef25a4 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Wed, 27 Jul 2022 01:31:56 +0800 Subject: Add many more logging --- forge/src/main/java/me/shedaniel/rei/mixin/forge/MixinTagLoader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'forge/src/main/java') diff --git a/forge/src/main/java/me/shedaniel/rei/mixin/forge/MixinTagLoader.java b/forge/src/main/java/me/shedaniel/rei/mixin/forge/MixinTagLoader.java index cb622841e..b48ddc175 100644 --- a/forge/src/main/java/me/shedaniel/rei/mixin/forge/MixinTagLoader.java +++ b/forge/src/main/java/me/shedaniel/rei/mixin/forge/MixinTagLoader.java @@ -28,8 +28,8 @@ import com.mojang.datafixers.util.Either; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.objects.Reference2ObjectMaps; -import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.common.util.CollectionUtils; +import me.shedaniel.rei.impl.common.InternalLogger; import me.shedaniel.rei.plugin.common.displays.tag.TagNodes; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; @@ -96,7 +96,7 @@ public class MixinTagLoader { } } - RoughlyEnoughItemsCore.LOGGER.info("Processed %d tags in %s for %s", tagDataMap.size(), stopwatch.stop(), resourceKey.location()); + InternalLogger.getInstance().debug("Processed %d tags in %s for %s", tagDataMap.size(), stopwatch.stop(), resourceKey.location()); } @Inject(method = "build(Lnet/minecraft/tags/TagEntry$Lookup;Ljava/util/List;)Lcom/mojang/datafixers/util/Either;", at = @At("RETURN")) -- cgit From f2345acc57d7d347507505a6976e20378bc0fbf9 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Wed, 27 Jul 2022 02:13:43 +0800 Subject: Make Architectury Plugin compile only --- .../me/shedaniel/rei/forge/AnnotationUtils.java | 4 +- .../me/shedaniel/rei/forge/PluginDetectorImpl.java | 44 ++++++++------ .../rei/forge/PrimitivePlatformAdapterImpl.java | 69 ++++++++++++++++++++++ .../rei/forge/RoughlyEnoughItemsForge.java | 2 +- .../forge/RoughlyEnoughItemsInitializerImpl.java | 63 -------------------- .../client/gui/forge/ScreenOverlayImplForge.java | 68 +++++++++++++++++++++ .../client/gui/forge/ScreenOverlayImplImpl.java | 66 --------------------- .../client/forge/DefaultClientPluginImpl.java | 6 +- .../rei/plugin/common/forge/DefaultPluginImpl.java | 11 ++-- 9 files changed, 174 insertions(+), 159 deletions(-) create mode 100644 forge/src/main/java/me/shedaniel/rei/forge/PrimitivePlatformAdapterImpl.java delete mode 100644 forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java create mode 100644 forge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/ScreenOverlayImplForge.java delete 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/AnnotationUtils.java b/forge/src/main/java/me/shedaniel/rei/forge/AnnotationUtils.java index 70d8de46d..949e7f775 100644 --- a/forge/src/main/java/me/shedaniel/rei/forge/AnnotationUtils.java +++ b/forge/src/main/java/me/shedaniel/rei/forge/AnnotationUtils.java @@ -24,7 +24,7 @@ package me.shedaniel.rei.forge; import com.google.common.collect.Lists; -import me.shedaniel.rei.RoughlyEnoughItemsInitializer; +import me.shedaniel.rei.impl.init.PrimitivePlatformAdapter; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.loading.FMLEnvironment; @@ -99,7 +99,7 @@ public class AnnotationUtils { } catch (Throwable throwable) { Throwable t = throwable; while (t != null) { - if (t.getMessage() != null && t.getMessage().contains("invalid dist DEDICATED_SERVER") && !RoughlyEnoughItemsInitializer.isClient()) { + if (t.getMessage() != null && t.getMessage().contains("invalid dist DEDICATED_SERVER") && !PrimitivePlatformAdapter.get().isClient()) { LOGGER.warn("Plugin " + annotation.memberName() + " is attempting to load on the server, but is not compatible with the server. " + "The mod should declare the environments it is compatible with in the @" + annotationType.getClassName() + " annotation."); continue out; 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 aa53a7866..7c6092240 100644 --- a/forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java +++ b/forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java @@ -30,9 +30,10 @@ import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.plugins.PluginView; import me.shedaniel.rei.api.common.plugins.REIPluginProvider; import me.shedaniel.rei.api.common.plugins.REIServerPlugin; -import me.shedaniel.rei.plugin.client.DefaultClientPlugin; +import me.shedaniel.rei.impl.init.PluginDetector; +import me.shedaniel.rei.plugin.client.forge.DefaultClientPluginImpl; import me.shedaniel.rei.plugin.client.runtime.DefaultClientRuntimePlugin; -import me.shedaniel.rei.plugin.common.DefaultPlugin; +import me.shedaniel.rei.plugin.common.forge.DefaultPluginImpl; import me.shedaniel.rei.plugin.common.runtime.DefaultRuntimePlugin; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -41,7 +42,7 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import java.util.*; import java.util.function.Supplier; -public class PluginDetectorImpl { +public class PluginDetectorImpl implements PluginDetector { private static

> REIPluginProvider

wrapPlugin(List modId, REIPluginProvider

plugin) { return new REIPluginProvider

() { String nameSuffix = " [" + String.join(", ", modId) + "]"; @@ -71,8 +72,9 @@ public class PluginDetectorImpl { return list; }); - public static void detectServerPlugins() { - PluginView.getServerInstance().registerPlugin(wrapPlugin(Collections.singletonList("roughlyenoughitems"), new DefaultPlugin())); + @Override + public void detectServerPlugins() { + PluginView.getServerInstance().registerPlugin(wrapPlugin(Collections.singletonList("roughlyenoughitems"), new DefaultPluginImpl())); PluginView.getServerInstance().registerPlugin(wrapPlugin(Collections.singletonList("roughlyenoughitems"), new DefaultRuntimePlugin())); AnnotationUtils.scanAnnotation(REIPlugin.class, REIServerPlugin.class::isAssignableFrom, (modId, plugin, clazz) -> { ((PluginView) PluginManager.getServerInstance()).registerPlugin(wrapPlugin(modId, plugin.get())); @@ -89,7 +91,8 @@ public class PluginDetectorImpl { } } - public static void detectCommonPlugins() { + @Override + public void detectCommonPlugins() { EventBuses.registerModEventBus("roughlyenoughitems", FMLJavaModLoadingContext.get().getModEventBus()); AnnotationUtils.>scanAnnotation(REIPlugin.class, me.shedaniel.rei.api.common.plugins.REIPlugin.class::isAssignableFrom, (modId, plugin, clazz) -> { ((PluginView) PluginManager.getInstance()).registerPlugin(wrapPlugin(modId, plugin.get())); @@ -97,21 +100,23 @@ public class PluginDetectorImpl { } @OnlyIn(Dist.CLIENT) - public static void detectClientPlugins() { - PluginView.getClientInstance().registerPlugin(wrapPlugin(Collections.singletonList("roughlyenoughitems"), new DefaultClientPlugin())); - PluginView.getClientInstance().registerPlugin(wrapPlugin(Collections.singletonList("roughlyenoughitems"), new DefaultClientRuntimePlugin())); - AnnotationUtils.scanAnnotation(REIPlugin.class, REIClientPlugin.class::isAssignableFrom, (modId, plugin, clazz) -> { - ((PluginView) PluginManager.getClientInstance()).registerPlugin(wrapPlugin(modId, plugin.get())); - }); - for (Map.Entry>, List> entry : loaderProvided.get()) { - REIPluginProvider> provider = entry.getKey(); - Collection> objects = provider.provide(); - for (me.shedaniel.rei.api.common.plugins.REIPlugin plugin : objects) { - if (plugin instanceof REIClientPlugin) { - ((PluginView) PluginManager.getClientInstance()).registerPlugin(wrapPlugin(entry.getValue(), (REIClientPlugin) plugin)); + @Override + public Supplier detectClientPlugins() { + return () -> () -> { + PluginView.getClientInstance().registerPlugin(wrapPlugin(Collections.singletonList("roughlyenoughitems"), new DefaultClientPluginImpl())); + PluginView.getClientInstance().registerPlugin(wrapPlugin(Collections.singletonList("roughlyenoughitems"), new DefaultClientRuntimePlugin())); + AnnotationUtils.scanAnnotation(REIPlugin.class, REIClientPlugin.class::isAssignableFrom, (modId, plugin, clazz) -> { + ((PluginView) PluginManager.getClientInstance()).registerPlugin(wrapPlugin(modId, plugin.get())); + }); + for (Map.Entry>, List> entry : loaderProvided.get()) { + REIPluginProvider> provider = entry.getKey(); + Collection> objects = provider.provide(); + for (me.shedaniel.rei.api.common.plugins.REIPlugin plugin : objects) { + if (plugin instanceof REIClientPlugin) { + ((PluginView) PluginManager.getClientInstance()).registerPlugin(wrapPlugin(entry.getValue(), (REIClientPlugin) plugin)); + } } } - } // ClientInternals.attachInstance((Supplier>) () -> { // List modIds = new ArrayList<>(); // for (REIPluginProvider plugin : PluginManager.getClientInstance().getPluginProviders()) { @@ -121,5 +126,6 @@ public class PluginDetectorImpl { // } // return modIds; // }, "jeiCompatMods"); + }; } } diff --git a/forge/src/main/java/me/shedaniel/rei/forge/PrimitivePlatformAdapterImpl.java b/forge/src/main/java/me/shedaniel/rei/forge/PrimitivePlatformAdapterImpl.java new file mode 100644 index 000000000..5553597c7 --- /dev/null +++ b/forge/src/main/java/me/shedaniel/rei/forge/PrimitivePlatformAdapterImpl.java @@ -0,0 +1,69 @@ +/* + * 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.forge; + +import me.shedaniel.rei.RoughlyEnoughItemsState; +import me.shedaniel.rei.impl.init.PrimitivePlatformAdapter; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.fml.ModList; +import net.minecraftforge.fml.loading.FMLEnvironment; +import net.minecraftforge.fml.loading.FMLLoader; +import org.apache.maven.artifact.versioning.ComparableVersion; + +public class PrimitivePlatformAdapterImpl implements PrimitivePlatformAdapter { + @Override + public boolean isClient() { + return FMLEnvironment.dist == Dist.CLIENT; + } + + @Override + public void checkMods() { + if (ModList.get().isLoaded("moreoverlays")) { + RoughlyEnoughItemsState.error("REI is not compatible with MoreOverlays, and actually contains Builtin Inventory Highlighting, other features can be installed via different mods!"); + } + } + + @Override + public boolean isDev() { + return !FMLLoader.isProduction(); + } + + @Override + public String getMinecraftVersion() { + return ModList.get().getModContainerById("minecraft").get().getModInfo().getVersion().toString(); + } + + @Override + public int compareVersions(String version1, String version2) { + ComparableVersion v1 = new ComparableVersion(version1); + ComparableVersion v2 = new ComparableVersion(version2); + + try { + return v1.compareTo(v2); + } catch (IllegalStateException e) { + new IllegalStateException("Failed to compare versions: " + version1 + " and " + version2, e).printStackTrace(); + return 0; + } + } +} 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 563f5f31a..961659619 100644 --- a/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java +++ b/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java @@ -23,7 +23,7 @@ package me.shedaniel.rei.forge; -import me.shedaniel.rei.RoughlyEnoughItemsInitializer; +import me.shedaniel.rei.impl.init.RoughlyEnoughItemsInitializer; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.data.loading.DatagenModLoader; import net.minecraftforge.fml.DistExecutor; diff --git a/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java b/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java deleted file mode 100644 index 76952dd4b..000000000 --- a/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.shedaniel.rei.forge; - -import me.shedaniel.rei.RoughlyEnoughItemsState; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.fml.ModList; -import net.minecraftforge.fml.loading.FMLEnvironment; -import net.minecraftforge.fml.loading.FMLLoader; -import org.apache.maven.artifact.versioning.ComparableVersion; - -public class RoughlyEnoughItemsInitializerImpl { - public static boolean isClient() { - return FMLEnvironment.dist == Dist.CLIENT; - } - - public static void checkMods() { - if (ModList.get().isLoaded("moreoverlays")) { - RoughlyEnoughItemsState.error("REI is not compatible with MoreOverlays, and actually contains Builtin Inventory Highlighting, other features can be installed via different mods!"); - } - } - - public static boolean isDev() { - return !FMLLoader.isProduction(); - } - - public static String getMinecraftVersion() { - return ModList.get().getModContainerById("minecraft").get().getModInfo().getVersion().toString(); - } - - public static int compareVersions(String version1, String version2) { - ComparableVersion v1 = new ComparableVersion(version1); - ComparableVersion v2 = new ComparableVersion(version2); - - try { - return v1.compareTo(v2); - } catch (IllegalStateException e) { - new IllegalStateException("Failed to compare versions: " + version1 + " and " + version2, e).printStackTrace(); - return 0; - } - } -} diff --git a/forge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/ScreenOverlayImplForge.java b/forge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/ScreenOverlayImplForge.java new file mode 100644 index 000000000..7b9c52c40 --- /dev/null +++ b/forge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/ScreenOverlayImplForge.java @@ -0,0 +1,68 @@ +/* + * 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.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 me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; +import me.shedaniel.rei.api.common.util.CollectionUtils; +import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.world.inventory.tooltip.TooltipComponent; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.client.ForgeHooksClient; + +import java.util.ArrayList; +import java.util.List; + +public class ScreenOverlayImplForge extends ScreenOverlayImpl { + @Override + public void renderTooltipInner(Screen screen, PoseStack matrices, Tooltip tooltip, int mouseX, int mouseY) { + matrices.pushPose(); + EntryStack stack = tooltip.getContextStack(); + ItemStack itemStack = stack.getType() == VanillaEntryTypes.ITEM ? stack.castValue() : ItemStack.EMPTY; + List texts = CollectionUtils.filterAndMap(tooltip.entries(), Tooltip.Entry::isText, Tooltip.Entry::getAsText); + List components = ForgeHooksClient.gatherTooltipComponents(itemStack, texts, mouseX, screen.width, screen.height, null, screen.getMinecraft().font); + components = new ArrayList<>(components); + for (Tooltip.Entry entry : tooltip.entries()) { + if (!entry.isText()) { + TooltipComponent component = entry.getAsTooltipComponent(); + + if (component instanceof ClientTooltipComponent client) { + components.add(client); + continue; + } + + components.add(1, ClientTooltipComponent.create(component)); + } + } + screen.tooltipStack = itemStack; + screen.renderTooltipInternal(matrices, components, mouseX, mouseY); + screen.tooltipStack = ItemStack.EMPTY; + matrices.popPose(); + } +} 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 deleted file mode 100644 index 259633e2d..000000000 --- a/forge/src/main/java/me/shedaniel/rei/impl/client/gui/forge/ScreenOverlayImplImpl.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.shedaniel.rei.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 me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; -import me.shedaniel.rei.api.common.util.CollectionUtils; -import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; -import net.minecraft.network.chat.Component; -import net.minecraft.world.inventory.tooltip.TooltipComponent; -import net.minecraft.world.item.ItemStack; -import net.minecraftforge.client.ForgeHooksClient; - -import java.util.ArrayList; -import java.util.List; - -public class ScreenOverlayImplImpl { - public static void renderTooltipInner(Screen screen, PoseStack matrices, Tooltip tooltip, int mouseX, int mouseY) { - matrices.pushPose(); - EntryStack stack = tooltip.getContextStack(); - ItemStack itemStack = stack.getType() == VanillaEntryTypes.ITEM ? stack.castValue() : ItemStack.EMPTY; - List texts = CollectionUtils.filterAndMap(tooltip.entries(), Tooltip.Entry::isText, Tooltip.Entry::getAsText); - List components = ForgeHooksClient.gatherTooltipComponents(itemStack, texts, mouseX, screen.width, screen.height, null, screen.getMinecraft().font); - components = new ArrayList<>(components); - for (Tooltip.Entry entry : tooltip.entries()) { - if (!entry.isText()) { - TooltipComponent component = entry.getAsTooltipComponent(); - - if (component instanceof ClientTooltipComponent client) { - components.add(client); - continue; - } - - components.add(1, ClientTooltipComponent.create(component)); - } - } - screen.tooltipStack = itemStack; - screen.renderTooltipInternal(matrices, components, mouseX, mouseY); - screen.tooltipStack = ItemStack.EMPTY; - 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 23aac8d92..81f5ff7e5 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 @@ -26,6 +26,7 @@ package me.shedaniel.rei.plugin.client.forge; import com.google.common.collect.Sets; import me.shedaniel.rei.api.client.registry.display.DisplayRegistry; import me.shedaniel.rei.plugin.client.BuiltinClientPlugin; +import me.shedaniel.rei.plugin.client.DefaultClientPlugin; import net.minecraft.core.Holder; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -41,8 +42,9 @@ import net.minecraftforge.common.brewing.VanillaBrewingRecipe; import java.util.Arrays; import java.util.Set; -public class DefaultClientPluginImpl { - public static void registerForgePotions(DisplayRegistry registry, BuiltinClientPlugin clientPlugin) { +public class DefaultClientPluginImpl extends DefaultClientPlugin { + @Override + public void registerForgePotions(DisplayRegistry registry, BuiltinClientPlugin clientPlugin) { for (IBrewingRecipe recipe : BrewingRecipeRegistry.getRecipes()) { if (recipe instanceof VanillaBrewingRecipe) { registerVanillaPotions(registry, clientPlugin); 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 e2ee44500..687d4689c 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,6 +28,7 @@ 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 me.shedaniel.rei.plugin.common.DefaultPlugin; import net.minecraft.world.item.BucketItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.material.Fluid; @@ -38,8 +39,10 @@ import net.minecraftforge.fluids.capability.IFluidHandlerItem; import java.util.stream.IntStream; -public class DefaultPluginImpl { - public static void registerForgeFluidSupport(FluidSupportProvider support) { +public class DefaultPluginImpl extends DefaultPlugin { + @Override + public void registerFluidSupport(FluidSupportProvider support) { + super.registerFluidSupport(support); support.register(stack -> { ItemStack itemStack = stack.getValue(); LazyOptional handlerOptional = FluidUtil.getFluidHandler(itemStack); @@ -57,8 +60,4 @@ public class DefaultPluginImpl { return CompoundEventResult.pass(); }); } - - public static Fluid getFluidFromBucket(BucketItem item) { - return item.getFluid(); - } } -- cgit