From 40b5e5432f91cb53eac7027e941b17b579317378 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Fri, 10 Jan 2025 18:15:16 -0500 Subject: [PATCH 1/2] Fix IClientItemExtensions#renderHelmetOverlay never being called --- patches/net/minecraft/client/gui/Gui.java.patch | 9 +++++++++ .../client/extensions/common/IClientItemExtensions.java | 3 +++ 2 files changed, 12 insertions(+) diff --git a/patches/net/minecraft/client/gui/Gui.java.patch b/patches/net/minecraft/client/gui/Gui.java.patch index f48725af15..b980596d9d 100644 --- a/patches/net/minecraft/client/gui/Gui.java.patch +++ b/patches/net/minecraft/client/gui/Gui.java.patch @@ -101,6 +101,15 @@ } private void renderCameraOverlays(GuiGraphics p_316735_, DeltaTracker p_348538_) { +@@ -238,6 +_,8 @@ + Equippable equippable = itemstack.get(DataComponents.EQUIPPABLE); + if (equippable != null && equippable.slot() == equipmentslot && equippable.cameraOverlay().isPresent()) { + this.renderTextureOverlay(p_316735_, equippable.cameraOverlay().get().withPath(p_380782_ -> "textures/" + p_380782_ + ".png"), 1.0F); ++ } else { ++ net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(itemstack).renderHelmetOverlay(itemstack, this.minecraft.player, p_316735_.guiWidth(), p_316735_.guiHeight(), p_348538_.getGameTimeDeltaPartialTick(true)); + } + } + } @@ -289,8 +_,12 @@ } diff --git a/src/main/java/net/neoforged/neoforge/client/extensions/common/IClientItemExtensions.java b/src/main/java/net/neoforged/neoforge/client/extensions/common/IClientItemExtensions.java index 4ba1dfb5b9..ac79653701 100644 --- a/src/main/java/net/neoforged/neoforge/client/extensions/common/IClientItemExtensions.java +++ b/src/main/java/net/neoforged/neoforge/client/extensions/common/IClientItemExtensions.java @@ -23,6 +23,7 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.component.DyedItemColor; +import net.minecraft.world.item.equipment.Equippable; import net.neoforged.fml.LogicalSide; import net.neoforged.neoforge.client.ClientHooks; import net.neoforged.neoforge.client.IArmPoseTransformer; @@ -145,6 +146,8 @@ default void setupModelAnimations(LivingEntity livingEntity, ItemStack itemStack * Called when the client starts rendering the HUD, and is wearing this item in the helmet slot. *

* This is where pumpkins would render their overlay. + *

+ * Note: Only use this if {@link Equippable#cameraOverlay()} doesn't suit your use case * * @param stack The item stack * @param player The player entity From 943b02b2cb353f1ac22927122283d37b4c9883e7 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Fri, 10 Jan 2025 19:31:57 -0500 Subject: [PATCH 2/2] add more context to the method --- patches/net/minecraft/client/gui/Gui.java.patch | 2 +- .../extensions/common/IClientItemExtensions.java | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/patches/net/minecraft/client/gui/Gui.java.patch b/patches/net/minecraft/client/gui/Gui.java.patch index b980596d9d..7fe3d1496c 100644 --- a/patches/net/minecraft/client/gui/Gui.java.patch +++ b/patches/net/minecraft/client/gui/Gui.java.patch @@ -106,7 +106,7 @@ if (equippable != null && equippable.slot() == equipmentslot && equippable.cameraOverlay().isPresent()) { this.renderTextureOverlay(p_316735_, equippable.cameraOverlay().get().withPath(p_380782_ -> "textures/" + p_380782_ + ".png"), 1.0F); + } else { -+ net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(itemstack).renderHelmetOverlay(itemstack, this.minecraft.player, p_316735_.guiWidth(), p_316735_.guiHeight(), p_348538_.getGameTimeDeltaPartialTick(true)); ++ net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(itemstack).renderHelmetOverlay(itemstack, this.minecraft.player, p_316735_, p_348538_); } } } diff --git a/src/main/java/net/neoforged/neoforge/client/extensions/common/IClientItemExtensions.java b/src/main/java/net/neoforged/neoforge/client/extensions/common/IClientItemExtensions.java index ac79653701..41f4fbf1ed 100644 --- a/src/main/java/net/neoforged/neoforge/client/extensions/common/IClientItemExtensions.java +++ b/src/main/java/net/neoforged/neoforge/client/extensions/common/IClientItemExtensions.java @@ -6,7 +6,9 @@ package net.neoforged.neoforge.client.extensions.common; import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.DeltaTracker; import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.Model; import net.minecraft.client.player.LocalPlayer; @@ -149,13 +151,12 @@ default void setupModelAnimations(LivingEntity livingEntity, ItemStack itemStack *

* Note: Only use this if {@link Equippable#cameraOverlay()} doesn't suit your use case * - * @param stack The item stack - * @param player The player entity - * @param width The viewport width - * @param height Viewport height - * @param partialTick Partial tick time, useful for interpolation + * @param stack The item stack + * @param player The player entity + * @param guiGraphics The gui graphics + * @param deltaTracker The delta tracker */ - default void renderHelmetOverlay(ItemStack stack, Player player, int width, int height, float partialTick) {} + default void renderHelmetOverlay(ItemStack stack, Player player, GuiGraphics guiGraphics, DeltaTracker deltaTracker) {} /** * {@return Whether the item should bob when rendered in the world as an entity}