From 2a9bf6f5d355a3dfc82e7aeab344a7c051642fcf Mon Sep 17 00:00:00 2001 From: deirn Date: Sun, 12 Jan 2025 00:30:28 +0700 Subject: [PATCH] post cherry-pick fixes --- .../mcp/mobius/waila/plugin/extra/provider/FluidProvider.java | 4 ++-- .../java/mcp/mobius/waila/plugin/vanilla/config/Options.java | 4 ++++ .../plugin/vanilla/provider/BlockAttributesProvider.java | 2 +- .../waila/plugin/vanilla/provider/ItemEntityProvider.java | 4 ++-- .../mobius/waila/plugin/vanilla/provider/PandaProvider.java | 4 ++-- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/pluginExtra/java/mcp/mobius/waila/plugin/extra/provider/FluidProvider.java b/src/pluginExtra/java/mcp/mobius/waila/plugin/extra/provider/FluidProvider.java index 2f7a5832f..0cb26a634 100644 --- a/src/pluginExtra/java/mcp/mobius/waila/plugin/extra/provider/FluidProvider.java +++ b/src/pluginExtra/java/mcp/mobius/waila/plugin/extra/provider/FluidProvider.java @@ -12,7 +12,7 @@ import mcp.mobius.waila.api.component.WrappedComponent; import mcp.mobius.waila.api.data.FluidData; import mcp.mobius.waila.plugin.extra.data.FluidDataImpl; -import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.Registry; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; @@ -65,7 +65,7 @@ private void addFluidTooltip(ITooltip tooltip, FluidDataImpl data, IPluginConfig text += " " + displayUnit.symbol; var sprite = desc.sprite(); - tooltip.setLine(FluidData.ID.withSuffix("." + BuiltInRegistries.FLUID.getKey(entry.fluid()).toLanguageKey()), new PairComponent( + tooltip.setLine(new ResourceLocation(FluidData.ID.getNamespace(), FluidData.ID.getPath() + "." + Registry.FLUID.getKey(entry.fluid()).toLanguageKey()), new PairComponent( new WrappedComponent(desc.name().getString()), new SpriteBarComponent(ratio, sprite, 16, 16, desc.tint(), Component.literal(text)))); } diff --git a/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/config/Options.java b/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/config/Options.java index dda82ef6e..922fc9c92 100644 --- a/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/config/Options.java +++ b/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/config/Options.java @@ -90,4 +90,8 @@ private static ResourceLocation rl(String rl) { return new ResourceLocation(rl); } + public static ResourceLocation withSuffix(ResourceLocation rl, String suffix) { + return new ResourceLocation(rl.getNamespace(), rl.getPath() + suffix); + } + } diff --git a/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/provider/BlockAttributesProvider.java b/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/provider/BlockAttributesProvider.java index ec9f347ef..958a7d375 100644 --- a/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/provider/BlockAttributesProvider.java +++ b/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/provider/BlockAttributesProvider.java @@ -30,7 +30,7 @@ public void appendBody(ITooltip tooltip, IBlockAccessor accessor, IPluginConfig valueText.withStyle(value == Boolean.TRUE ? ChatFormatting.GREEN : ChatFormatting.RED); } var name = property.getName(); - tooltip.setLine(Options.BLOCK_STATE.withSuffix("." + name), new PairComponent(Component.literal(name), valueText)); + tooltip.setLine(Options.withSuffix(Options.BLOCK_POSITION, "." + name), new PairComponent(Component.literal(name), valueText)); } } } diff --git a/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/provider/ItemEntityProvider.java b/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/provider/ItemEntityProvider.java index f74c48c3f..180603a7b 100644 --- a/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/provider/ItemEntityProvider.java +++ b/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/provider/ItemEntityProvider.java @@ -34,8 +34,8 @@ public enum ItemEntityProvider implements IEntityComponentProvider { INSTANCE; - private static final ResourceLocation AUTHOR = Options.BOOK_WRITTEN.withSuffix(".author"); - private static final ResourceLocation GENERATION = Options.BOOK_WRITTEN.withSuffix(".generation"); + private static final ResourceLocation AUTHOR = Options.withSuffix(Options.BOOK_WRITTEN, ".author"); + private static final ResourceLocation GENERATION = Options.withSuffix(Options.BOOK_WRITTEN, ".generation"); private static long lastEnchantmentTime = 0; private static int enchantmentIndex = 0; diff --git a/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/provider/PandaProvider.java b/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/provider/PandaProvider.java index 9f8b87f57..0cb5296e7 100644 --- a/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/provider/PandaProvider.java +++ b/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/provider/PandaProvider.java @@ -17,8 +17,8 @@ public enum PandaProvider implements IEntityComponentProvider { INSTANCE; - private static final ResourceLocation PERSONALITY = Options.PANDA_GENES.withSuffix(".personality"); - private static final ResourceLocation TRAITS = Options.PANDA_GENES.withSuffix(".traits"); + private static final ResourceLocation PERSONALITY = Options.withSuffix(Options.PANDA_GENES, ".personality"); + private static final ResourceLocation TRAITS = Options.withSuffix(Options.PANDA_GENES, ".traits"); @Override public void appendBody(ITooltip tooltip, IEntityAccessor accessor, IPluginConfig config) {