From 999272a4ccf0c2868b79e65a1e56205edaf4ea18 Mon Sep 17 00:00:00 2001 From: Patbox <39821509+Patbox@users.noreply.github.com> Date: Sun, 22 Dec 2024 11:15:09 +0100 Subject: [PATCH] Update compat code --- polymer-core/build.gradle | 6 ++-- .../impl/client/compat/JadeCompatibility.java | 23 ++++++------- .../impl/client/compat/JeiCompatibility.java | 4 +-- .../client/compat/WthitCompatibility.java | 34 +++++++++---------- .../client/compat/jei_StackHelperMixin.java | 4 +-- .../src/main/resources/waila_plugins.json | 4 ++- 6 files changed, 38 insertions(+), 37 deletions(-) diff --git a/polymer-core/build.gradle b/polymer-core/build.gradle index 7917a3b0..86c4612b 100644 --- a/polymer-core/build.gradle +++ b/polymer-core/build.gradle @@ -52,10 +52,10 @@ dependencies { } - modCompileOnly /*modLocalRuntime*/("maven.modrinth:jade:14.1.0+fabric") - modCompileOnly /*modLocalRuntime*/("mcp.mobius.waila:wthit:fabric-11.2.0") + modCompileOnly /*modLocalRuntime*/("maven.modrinth:jade:17.1.2+fabric") + modCompileOnly /*modLocalRuntime*/("mcp.mobius.waila:wthit:fabric-14.0.1") - modCompileOnly /*modLocalRuntime*/ ("me.shedaniel:RoughlyEnoughItems-fabric:17.0.789") + modCompileOnly /*modLocalRuntime*/ ("me.shedaniel:RoughlyEnoughItems-fabric:18.0.796") modCompileOnly /*modLocalRuntime*/("dev.emi:emi-fabric:1.1.6+1.20.6") //modCompileOnlyApi modLocalRuntime("mezz.jei:jei-1.19-common:11.0.0.206") diff --git a/polymer-core/src/main/java/eu/pb4/polymer/core/impl/client/compat/JadeCompatibility.java b/polymer-core/src/main/java/eu/pb4/polymer/core/impl/client/compat/JadeCompatibility.java index 595dea54..402e2214 100644 --- a/polymer-core/src/main/java/eu/pb4/polymer/core/impl/client/compat/JadeCompatibility.java +++ b/polymer-core/src/main/java/eu/pb4/polymer/core/impl/client/compat/JadeCompatibility.java @@ -8,7 +8,6 @@ import net.minecraft.block.BlockState; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Entity; -import net.minecraft.item.PlayerHeadItem; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -77,15 +76,15 @@ public void appendTooltip(ITooltip tooltip, BlockAccessor accessor, IPluginConfi var block = InternalClientRegistry.getBlockAt(accessor.getPosition()); if (block != ClientPolymerBlock.NONE_STATE) { - var formatting = IWailaConfig.get().getFormatting(); + var formatting = IWailaConfig.get().formatting(); tooltip.clear(); try { - tooltip.add(IThemeHelper.get().title(block.block().name().getString()), Identifiers.CORE_OBJECT_NAME); + tooltip.add(IThemeHelper.get().title(block.block().name().getString()), JadeIds.CORE_OBJECT_NAME); } catch (Throwable e) { } try { - RegistryNameProvider.Mode mode = config.getEnum(Identifiers.DEBUG_REGISTRY_NAME); + RegistryNameProvider.Mode mode = config.getEnum(JadeIds.DEBUG_REGISTRY_NAME); if (mode != RegistryNameProvider.Mode.OFF) { if (mode != RegistryNameProvider.Mode.ADVANCED_TOOLTIPS || MinecraftClient.getInstance().options.advancedItemTooltips) { @@ -97,7 +96,7 @@ public void appendTooltip(ITooltip tooltip, BlockAccessor accessor, IPluginConfi try { - if (config.get(Identifiers.DEBUG_BLOCK_STATES)) { + if (config.get(JadeIds.DEBUG_BLOCK_STATES)) { IElementHelper helper = IElementHelper.get(); ITooltip box = helper.tooltip(); block.states().entrySet().forEach((p) -> { @@ -114,13 +113,13 @@ public void appendTooltip(ITooltip tooltip, BlockAccessor accessor, IPluginConfi } try { - if (config.get(Identifiers.CORE_MOD_NAME)) { + if (config.get(JadeIds.CORE_MOD_NAME)) { String modName = ModIdentification.getModName(block.block().identifier()); if (modName == null || modName.isEmpty() || modName.equals("Minecraft")) { modName = "Server"; } - tooltip.add(IThemeHelper.get().modName(modName), Identifiers.CORE_MOD_NAME); + tooltip.add(IThemeHelper.get().modName(modName), JadeIds.CORE_MOD_NAME); } } catch (Throwable e) { } @@ -165,13 +164,13 @@ public void appendTooltip(ITooltip tooltip, EntityAccessor accessor, IPluginConf if (type != null) { try { - tooltip.add(IThemeHelper.get().title(entity.getDisplayName().getString()), Identifiers.CORE_OBJECT_NAME); + tooltip.add(IThemeHelper.get().title(entity.getDisplayName().getString()), JadeIds.CORE_OBJECT_NAME); } catch (Throwable e) { } - var formatting = IWailaConfig.get().getFormatting(); + var formatting = IWailaConfig.get().formatting(); - RegistryNameProvider.Mode mode = config.getEnum(Identifiers.DEBUG_REGISTRY_NAME); + RegistryNameProvider.Mode mode = config.getEnum(JadeIds.DEBUG_REGISTRY_NAME); try { if (mode != RegistryNameProvider.Mode.OFF) { @@ -182,13 +181,13 @@ public void appendTooltip(ITooltip tooltip, EntityAccessor accessor, IPluginConf } catch (Throwable e) { } try { - if (config.get(Identifiers.CORE_MOD_NAME)) { + if (config.get(JadeIds.CORE_MOD_NAME)) { String modName = ModIdentification.getModName(type.identifier()); if (modName == null || modName.isEmpty() || modName.equals("Minecraft")) { modName = "Server"; } - tooltip.add(IThemeHelper.get().modName(modName), Identifiers.CORE_MOD_NAME); + tooltip.add(IThemeHelper.get().modName(modName), JadeIds.CORE_MOD_NAME); } } catch (Throwable e) { } diff --git a/polymer-core/src/main/java/eu/pb4/polymer/core/impl/client/compat/JeiCompatibility.java b/polymer-core/src/main/java/eu/pb4/polymer/core/impl/client/compat/JeiCompatibility.java index 67e673ec..919789a1 100644 --- a/polymer-core/src/main/java/eu/pb4/polymer/core/impl/client/compat/JeiCompatibility.java +++ b/polymer-core/src/main/java/eu/pb4/polymer/core/impl/client/compat/JeiCompatibility.java @@ -19,7 +19,7 @@ public class JeiCompatibility implements IModPlugin { @Override public void registerRecipes(IRecipeRegistration registration) { if (PolymerImpl.IS_CLIENT) { - //update(registration.getIngredientManager()); + update(registration.getIngredientManager()); } } @@ -27,7 +27,7 @@ private static void update(IIngredientManager manager) { synchronized (manager) { try { var list = manager.getAllIngredients(VanillaTypes.ITEM_STACK).stream().filter(PolymerImplUtils::isPolymerControlled).toList(); - if (list.size() > 0) { + if (!list.isEmpty()) { manager.removeIngredientsAtRuntime(VanillaTypes.ITEM_STACK, list); } diff --git a/polymer-core/src/main/java/eu/pb4/polymer/core/impl/client/compat/WthitCompatibility.java b/polymer-core/src/main/java/eu/pb4/polymer/core/impl/client/compat/WthitCompatibility.java index d365ea63..16fa84c9 100644 --- a/polymer-core/src/main/java/eu/pb4/polymer/core/impl/client/compat/WthitCompatibility.java +++ b/polymer-core/src/main/java/eu/pb4/polymer/core/impl/client/compat/WthitCompatibility.java @@ -1,12 +1,11 @@ package eu.pb4.polymer.core.impl.client.compat; +import eu.pb4.polymer.common.impl.entity.InternalEntityHelpers; import eu.pb4.polymer.core.api.client.ClientPolymerBlock; import eu.pb4.polymer.core.api.client.PolymerClientUtils; import eu.pb4.polymer.core.api.item.PolymerItemUtils; import eu.pb4.polymer.core.impl.client.InternalClientRegistry; -import eu.pb4.polymer.common.impl.entity.InternalEntityHelpers; import mcp.mobius.waila.api.*; -import mcp.mobius.waila.api.component.EmptyComponent; import mcp.mobius.waila.api.component.ItemComponent; import mcp.mobius.waila.api.component.PairComponent; import net.minecraft.block.Block; @@ -14,7 +13,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.ItemEntity; import net.minecraft.item.ItemStack; -import net.minecraft.item.PlayerHeadItem; +import net.minecraft.item.Items; import net.minecraft.registry.Registries; import net.minecraft.text.Style; import net.minecraft.text.Text; @@ -24,24 +23,24 @@ import org.jetbrains.annotations.Nullable; @ApiStatus.Internal -public class WthitCompatibility implements IWailaPlugin { +public class WthitCompatibility implements IWailaClientPlugin { private static final Identifier BLOCK_STATES = Identifier.tryParse("attribute.block_state"); @Override - public void register(IRegistrar registrar) { - registrar.addRedirect(BlockOverride.INSTANCE, Block.class, 400); - registrar.addComponent(BlockOverride.INSTANCE, TooltipPosition.HEAD, Block.class, 100000); - registrar.addComponent(BlockOverride.INSTANCE, TooltipPosition.BODY, Block.class, 100000); - registrar.addComponent(BlockOverride.INSTANCE, TooltipPosition.TAIL, Block.class, 100000); - registrar.addIcon(BlockOverride.INSTANCE, Block.class, 500); + public void register(IClientRegistrar registrar) { + registrar.redirect(BlockOverride.INSTANCE, Block.class, 400); + registrar.head(BlockOverride.INSTANCE, Block.class, 100000); + registrar.body(BlockOverride.INSTANCE, Block.class, 100000); + registrar.tail(BlockOverride.INSTANCE, Block.class, 100000); + registrar.icon(BlockOverride.INSTANCE, Block.class, 500); - registrar.addComponent(ItemEntityOverride.INSTANCE, TooltipPosition.HEAD, ItemEntity.class, 100000); - registrar.addComponent(ItemEntityOverride.INSTANCE, TooltipPosition.TAIL, ItemEntity.class, 100000); + registrar.head(ItemEntityOverride.INSTANCE, ItemEntity.class, 100000); + registrar.tail(ItemEntityOverride.INSTANCE, ItemEntity.class, 100000); - registrar.addComponent(EntityOverride.INSTANCE, TooltipPosition.HEAD, Entity.class, 100000); - registrar.addComponent(EntityOverride.INSTANCE, TooltipPosition.TAIL, Entity.class, 100000); + registrar.head(EntityOverride.INSTANCE, Entity.class, 100000); + registrar.tail(EntityOverride.INSTANCE, Entity.class, 100000); - registrar.addEventListener(OtherOverrides.INSTANCE); + registrar.eventListener(OtherOverrides.INSTANCE); } private static class OtherOverrides implements IEventListener { @@ -58,7 +57,8 @@ private static class BlockOverride implements IBlockComponentProvider { @Override public @Nullable ITargetRedirector.Result redirect(ITargetRedirector redirect, IBlockAccessor accessor, IPluginConfig config) { - if (InternalClientRegistry.getBlockAt(accessor.getPosition()) != ClientPolymerBlock.NONE_STATE) return redirect.toSelf(); + if (InternalClientRegistry.getBlockAt(accessor.getPosition()) != ClientPolymerBlock.NONE_STATE) + return redirect.toSelf(); return null; } @@ -154,7 +154,7 @@ public void appendTail(ITooltip tooltip, IEntityAccessor accessor, IPluginConfig if (id != null) { String modName = null; var regBlock = Registries.ITEM.get(id); - if (regBlock != null) { + if (regBlock != null && regBlock != Items.AIR) { modName = IModInfo.get(regBlock).getName(); } diff --git a/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/client/compat/jei_StackHelperMixin.java b/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/client/compat/jei_StackHelperMixin.java index 247b4483..cd2f3f69 100644 --- a/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/client/compat/jei_StackHelperMixin.java +++ b/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/client/compat/jei_StackHelperMixin.java @@ -14,12 +14,12 @@ @Pseudo @Environment(EnvType.CLIENT) @Mixin(StackHelper.class) -public class jei_StackHelperMixin {/* +public class jei_StackHelperMixin { @Inject(method = "getRegistryNameForStack", at = @At("HEAD"), cancellable = true, remap = false, require = 0) private static void polymer$changeId(ItemStack stack, CallbackInfoReturnable cir) { var id = PolymerItemUtils.getServerIdentifier(stack); if (id != null) { cir.setReturnValue(id.toString()); } - }*/ + } } diff --git a/polymer-core/src/main/resources/waila_plugins.json b/polymer-core/src/main/resources/waila_plugins.json index f76fa13d..3bd047de 100644 --- a/polymer-core/src/main/resources/waila_plugins.json +++ b/polymer-core/src/main/resources/waila_plugins.json @@ -1,6 +1,8 @@ { "polymer:core": { - "initializer": "eu.pb4.polymer.core.impl.client.compat.WthitCompatibility", + "entrypoints": { + "client": "eu.pb4.polymer.core.impl.client.compat.WthitCompatibility" + }, "side": "client" } } \ No newline at end of file